diff options
Diffstat (limited to 'js/lib/rdge/materials/pulse-material.js')
-rw-r--r-- | js/lib/rdge/materials/pulse-material.js | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index 81db36c6..2075d1ff 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js | |||
@@ -125,18 +125,6 @@ var PulseMaterial = function PulseMaterial() { | |||
125 | var texMapName = this._propValues[this._propNames[0]]; | 125 | var texMapName = this._propValues[this._propNames[0]]; |
126 | var wrap = 'REPEAT', mips = true; | 126 | var wrap = 'REPEAT', mips = true; |
127 | var tex = this.loadTexture( texMapName, wrap, mips ); | 127 | var tex = this.loadTexture( texMapName, wrap, mips ); |
128 | |||
129 | /* | ||
130 | var glTex = new GLTexture( this.getWorld() ); | ||
131 | var prevWorld = this.findPreviousWorld(); | ||
132 | if (prevWorld) | ||
133 | { | ||
134 | var srcCanvas = prevWorld.getCanvas(); | ||
135 | tex = glTex.loadFromCanvas( srcCanvas ); | ||
136 | } | ||
137 | else | ||
138 | tex = glTex.loadFromFile( texMapName, wrap, mips ); | ||
139 | */ | ||
140 | 128 | ||
141 | if (tex) { | 129 | if (tex) { |
142 | technique.u_tex0.set( tex ); | 130 | technique.u_tex0.set( tex ); |
@@ -174,6 +162,38 @@ var PulseMaterial = function PulseMaterial() { | |||
174 | } | 162 | } |
175 | }; | 163 | }; |
176 | 164 | ||
165 | // JSON export | ||
166 | this.exportJSON = function() | ||
167 | { | ||
168 | var jObj = | ||
169 | { | ||
170 | 'material' : this.getShaderName(), | ||
171 | 'name' : this.getName(), | ||
172 | 'texture' : this._propValues[this._propNames[0]], | ||
173 | 'dTime' : this._dTime | ||
174 | }; | ||
175 | |||
176 | return jObj; | ||
177 | }; | ||
178 | |||
179 | this.importJSON = function( jObj ) | ||
180 | { | ||
181 | if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); | ||
182 | this.setName( jObj.name ); | ||
183 | |||
184 | try { | ||
185 | this._propValues[this._propNames[0]] = jObj.texture; | ||
186 | this._texMap = jObj.texture; | ||
187 | if (jObj.dTime) | ||
188 | this._dTime = jObj.dTime; | ||
189 | } | ||
190 | catch (e) | ||
191 | { | ||
192 | throw new Error( "could not import material: " + jObj ); | ||
193 | } | ||
194 | } | ||
195 | |||
196 | |||
177 | this.export = function() { | 197 | this.export = function() { |
178 | // every material needs the base type and instance name | 198 | // every material needs the base type and instance name |
179 | var exportStr = "material: " + this.getShaderName() + "\n"; | 199 | var exportStr = "material: " + this.getShaderName() + "\n"; |