aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/texture.js
diff options
context:
space:
mode:
authorhwc4872012-04-11 06:24:05 -0700
committerhwc4872012-04-11 06:24:05 -0700
commit1b7592f81c9b47c2b42d78efe385cd979d54d3ca (patch)
tree4a70966f636ccc33c4319530ae8458eeb74150ba /js/lib/rdge/texture.js
parentc1a6cacf364d79cbf23b41e7089a1a6d39afea85 (diff)
downloadninja-1b7592f81c9b47c2b42d78efe385cd979d54d3ca.tar.gz
Cloud material
Diffstat (limited to 'js/lib/rdge/texture.js')
-rw-r--r--js/lib/rdge/texture.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/js/lib/rdge/texture.js b/js/lib/rdge/texture.js
index 94147852..345effd6 100644
--- a/js/lib/rdge/texture.js
+++ b/js/lib/rdge/texture.js
@@ -19,8 +19,16 @@ function Texture( dstWorld, texMapName, wrap, mips )
19 /////////////////////////////////////////////////////////////////////// 19 ///////////////////////////////////////////////////////////////////////
20 this._texture; 20 this._texture;
21 21
22 // the canvas generating the texture map (if there is one)
23 this._srcCanvas;
24 this._srcWorld;
25
22 // texture attributes 26 // texture attributes
23 this._texMapName = texMapName.slice(); 27 if (typeof texMapName === "string")
28 this._texMapName = texMapName.slice();
29 else
30 this._srcCanvas = texMapName;
31
24 32
25 // set default values for wrap and mips 33 // set default values for wrap and mips
26 if (wrap === undefined) 34 if (wrap === undefined)
@@ -30,10 +38,6 @@ function Texture( dstWorld, texMapName, wrap, mips )
30 this._wrap = wrap; 38 this._wrap = wrap;
31 this._mips = mips; 39 this._mips = mips;
32 40
33 // the canvas generating the texture map (if there is one)
34 this._srcCanvas;
35 this._srcWorld;
36
37 // cache whether or not the source is animated 41 // cache whether or not the source is animated
38 this._isAnimated = false; 42 this._isAnimated = false;
39 43
@@ -65,7 +69,9 @@ function Texture( dstWorld, texMapName, wrap, mips )
65 // determine if the source is a canvas or an image file 69 // determine if the source is a canvas or an image file
66 var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; 70 var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils;
67 var root = viewUtils.application.ninja.currentDocument.documentRoot; 71 var root = viewUtils.application.ninja.currentDocument.documentRoot;
68 var srcCanvas = this.findCanvas( this._texMapName, root ); 72 var srcCanvas = this._srcCanvas;
73 if (!srcCanvas)
74 srcCanvas = this.findCanvas( this._texMapName, root );
69 if (srcCanvas) 75 if (srcCanvas)
70 { 76 {
71 this._srcCanvas = srcCanvas; 77 this._srcCanvas = srcCanvas;
@@ -169,7 +175,7 @@ function Texture( dstWorld, texMapName, wrap, mips )
169 175
170 // create the canvas and context to render into 176 // create the canvas and context to render into
171 var doc = srcCanvas.ownerDocument; 177 var doc = srcCanvas.ownerDocument;
172 this._renderCanvas = doc.createElement("canvas"); 178 this._renderCanvas = doc.createElement("texture_canvas");
173 179
174 this.render(); 180 this.render();
175 181