diff options
Diffstat (limited to 'js/lib/rdge/materials/pulse-material.js')
-rw-r--r-- | js/lib/rdge/materials/pulse-material.js | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js index 5461c5fb..e3490134 100644 --- a/js/lib/rdge/materials/pulse-material.js +++ b/js/lib/rdge/materials/pulse-material.js | |||
@@ -25,8 +25,8 @@ var PulseMaterial = function PulseMaterial() | |||
25 | this._name = "PulseMaterial"; | 25 | this._name = "PulseMaterial"; |
26 | this._shaderName = "pulse"; | 26 | this._shaderName = "pulse"; |
27 | 27 | ||
28 | //this._texMap = 'assets/images/cubelight.png'; | 28 | this._texMap = 'assets/images/cubelight.png'; |
29 | this._texMap = 'texture'; | 29 | //this._texMap = 'texture'; |
30 | 30 | ||
31 | this._time = 0.0; | 31 | this._time = 0.0; |
32 | this._dTime = 0.01; | 32 | this._dTime = 0.01; |
@@ -118,16 +118,8 @@ var PulseMaterial = function PulseMaterial() | |||
118 | this._shader['default'].u_time.set( [this._time] ); | 118 | this._shader['default'].u_time.set( [this._time] ); |
119 | } | 119 | } |
120 | 120 | ||
121 | // check if the texture uses a canvas as the source | ||
122 | var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; | ||
123 | var root = viewUtils.application.ninja.currentDocument.documentRoot; | ||
124 | var texMapName = this._propValues[this._propNames[0]]; | 121 | var texMapName = this._propValues[this._propNames[0]]; |
125 | var texWorld = this.findWorld( texMapName, root ); | 122 | this._glTex = new Texture( world, texMapName ); |
126 | if (texWorld) | ||
127 | { | ||
128 | this._glTex = new Texture( this.getWorld() ); | ||
129 | this._glTex.loadFromCanvas( texWorld.getCanvas() ); | ||
130 | } | ||
131 | 123 | ||
132 | // set the shader values in the shader | 124 | // set the shader values in the shader |
133 | this.updateTexture(); | 125 | this.updateTexture(); |
@@ -145,14 +137,10 @@ var PulseMaterial = function PulseMaterial() | |||
145 | var tex; | 137 | var tex; |
146 | if (this._glTex) | 138 | if (this._glTex) |
147 | { | 139 | { |
148 | this._glTex.rerender(); | 140 | if (this._glTex.isAnimated()) |
141 | this._glTex.rerender(); | ||
149 | tex = this._glTex.getTexture(); | 142 | tex = this._glTex.getTexture(); |
150 | } | 143 | } |
151 | else | ||
152 | { | ||
153 | var texMapName = this._propValues[this._propNames[0]]; | ||
154 | tex = this.loadTexture( texMapName, wrap, mips ); | ||
155 | } | ||
156 | 144 | ||
157 | if (tex) { | 145 | if (tex) { |
158 | technique.u_tex0.set( tex ); | 146 | technique.u_tex0.set( tex ); |
@@ -166,12 +154,20 @@ var PulseMaterial = function PulseMaterial() | |||
166 | var material = this._materialNode; | 154 | var material = this._materialNode; |
167 | if (material) | 155 | if (material) |
168 | { | 156 | { |
169 | if (this._glTex && this._glTex.isAnimated()) | ||
170 | this.updateTexture(); | ||
171 | |||
172 | var technique = material.shaderProgram['default']; | 157 | var technique = material.shaderProgram['default']; |
173 | var renderer = g_Engine.getContext().renderer; | 158 | var renderer = g_Engine.getContext().renderer; |
174 | if (renderer && technique) { | 159 | if (renderer && technique) |
160 | { | ||
161 | if (this._glTex) | ||
162 | { | ||
163 | //this.updateTexture(); | ||
164 | if (this._glTex.isAnimated()) | ||
165 | this._glTex.rerender(); | ||
166 | tex = this._glTex.getTexture(); | ||
167 | if (tex) | ||
168 | technique.u_tex0.set( tex ); | ||
169 | } | ||
170 | |||
175 | if (this._shader && this._shader['default']) { | 171 | if (this._shader && this._shader['default']) { |
176 | this._shader['default'].u_time.set( [this._time] ); | 172 | this._shader['default'].u_time.set( [this._time] ); |
177 | } | 173 | } |