diff options
author | Eric Guzman | 2012-03-27 10:22:42 -0700 |
---|---|---|
committer | Eric Guzman | 2012-03-27 10:22:42 -0700 |
commit | 309b201017da2a4094df4f06adeeff9d396b193a (patch) | |
tree | 92257b32855bcd31dd74967b085a6632fd7dbe9b /js/lib/rdge/materials/pulse-material.js | |
parent | da03585a0b03220281f6d54d9acf0ae0fafaef16 (diff) | |
parent | 309dde5a8c4599cef6a1052c1ff9ee1ad8ec5858 (diff) | |
download | ninja-309b201017da2a4094df4f06adeeff9d396b193a.tar.gz |
Merge branch 'refs/heads/master' into PresetsPI
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"; |