From 98a02c1ac6f189aba93d7cce64ba5bdbc0617f6c Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 20 Mar 2012 16:26:52 -0700 Subject: Bug Fixes for Canvas & WebGL File IO --- js/lib/rdge/materials/julia-material.js | 6 +----- js/lib/rdge/materials/mandel-material.js | 6 +----- js/lib/rdge/materials/plasma-material.js | 19 ++++++++++++++++++ js/lib/rdge/materials/pulse-material.js | 1 + js/lib/rdge/materials/radial-blur-material.js | 29 ++++++++++++++++++++++++--- js/lib/rdge/materials/water-material.js | 25 +++++++++++++++++++++++ 6 files changed, 73 insertions(+), 13 deletions(-) (limited to 'js/lib/rdge/materials') diff --git a/js/lib/rdge/materials/julia-material.js b/js/lib/rdge/materials/julia-material.js index 976dfad3..a85bd6f7 100644 --- a/js/lib/rdge/materials/julia-material.js +++ b/js/lib/rdge/materials/julia-material.js @@ -21,11 +21,7 @@ var JuliaMaterial = function JuliaMaterial() { /////////////////////////////////////////////////////////////////////// // Properties /////////////////////////////////////////////////////////////////////// - // no properties - this._propNames = []; - this._propLabels = []; - this._propTypes = []; - this._propValues = []; + // properties inherited from PulseMaterial /////////////////////////////////////////////////////////////////////// // Methods diff --git a/js/lib/rdge/materials/mandel-material.js b/js/lib/rdge/materials/mandel-material.js index d9f00383..e7b105e1 100644 --- a/js/lib/rdge/materials/mandel-material.js +++ b/js/lib/rdge/materials/mandel-material.js @@ -21,11 +21,7 @@ var MandelMaterial = function MandelMaterial() { /////////////////////////////////////////////////////////////////////// // Properties /////////////////////////////////////////////////////////////////////// - // no properties - this._propNames = []; - this._propLabels = []; - this._propTypes = []; - this._propValues = []; + // properties inherited from PulseMaterial /////////////////////////////////////////////////////////////////////// // Material Property Accessors diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js index 86b1a93c..316a5989 100644 --- a/js/lib/rdge/materials/plasma-material.js +++ b/js/lib/rdge/materials/plasma-material.js @@ -67,6 +67,25 @@ var PlasmaMaterial = function PlasmaMaterial() { this._time += this._dTime; } + this.exportJSON = function() + { + + var jObj = + { + 'material' : this.getShaderName(), + 'name' : this.getName(), + 'speed' : this._speed, + 'dTime' : this._dTime + } + + return jObj; + } + + this.importJSON = function( jObj ) + { + this._speed = jObj.speed; + this._dTime = jObj.dTime; + } }; /////////////////////////////////////////////////////////////////////////////////////// diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index 6f19ab2b..fd2cbe0b 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js @@ -186,6 +186,7 @@ var PulseMaterial = function PulseMaterial() { try { this._propValues[this._propNames[0]] = jObj.texture; + this._texMap = jObj.texture; } catch (e) { diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js index e76b302f..d67a3d43 100644 --- a/js/lib/rdge/materials/radial-blur-material.js +++ b/js/lib/rdge/materials/radial-blur-material.js @@ -174,7 +174,7 @@ var RadialBlurMaterial = function RadialBlurMaterial() { return jObj; }; - this.importJSON = function( importStr ) + this.importJSON = function( jObj ) { if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); this.setName( jObj.name ); @@ -278,10 +278,33 @@ var radialBlurMaterialDef = } }; + +/* +var RaidersMaterial = function RaidersMaterial() +{ + // initialize the inherited members + this.inheritedFrom = RadialBlurMaterial; + this.inheritedFrom(); + + this._name = "RaidersMaterial"; + this._shaderName = "radialBlur"; + + this._texMap = 'assets/images/raiders.png'; + this._propValues[ this._propNames[0] ] = this._texMap.slice(0); +} + +RaidersMaterial.prototype = new Material(); + +if (typeof exports === "object") +{ + exports.RaidersMaterial = RaidersMaterial; +} +*/ + + RadialBlurMaterial.prototype = new Material(); -if (typeof exports === "object") { +if (typeof exports === "object") exports.RadialBlurMaterial = RadialBlurMaterial; -} diff --git a/js/lib/rdge/materials/water-material.js b/js/lib/rdge/materials/water-material.js index cac5a249..565055a1 100644 --- a/js/lib/rdge/materials/water-material.js +++ b/js/lib/rdge/materials/water-material.js @@ -18,6 +18,7 @@ var WaterMaterial = function WaterMaterial() { this._shaderName = "water"; this._texMap = 'assets/images/rocky-normal.jpg'; + //this._texMap = 'assets/images/powderblue.png'; this._time = 0.0; this._dTime = 0.01; @@ -27,6 +28,7 @@ var WaterMaterial = function WaterMaterial() { /////////////////////////////////////////////////////////////////////// // all defined in parent PulseMaterial.js // load the local default value + this._propValues = []; this._propValues[ this._propNames[0] ] = this._texMap.slice(0); /////////////////////////////////////////////////////////////////////// @@ -115,6 +117,29 @@ var waterMaterialDef = } }; +/* +var ParisMaterial = function ParisMaterial() +{ + // initialize the inherited members + this.inheritedFrom = WaterMaterial; + this.inheritedFrom(); + + this._name = "ParisMaterial"; + this._shaderName = "water"; + + this._texMap = 'assets/images/paris.png'; + this._propValues[ this._propNames[0] ] = this._texMap.slice(0); + + this._diffuseColor = [0.5, 0.5, 0.5, 0.5]; + this._propValues[ this._propNames[1] ] = this._diffuseColor.slice(); +} +ParisMaterial.prototype = new PulseMaterial(); +if (typeof exports === "object") { + exports.ParisMaterial = ParisMaterial; +} +*/ + + WaterMaterial.prototype = new PulseMaterial(); if (typeof exports === "object") { -- cgit v1.2.3