aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/lib/rdge/materials/cloud-material.js12
-rw-r--r--js/lib/rdge/texture.js20
2 files changed, 20 insertions, 12 deletions
diff --git a/js/lib/rdge/materials/cloud-material.js b/js/lib/rdge/materials/cloud-material.js
index 198f7cfa..c1dabce8 100644
--- a/js/lib/rdge/materials/cloud-material.js
+++ b/js/lib/rdge/materials/cloud-material.js
@@ -20,7 +20,7 @@ var CloudMaterial = function CloudMaterial() {
20 this._name = "CloudMaterial"; 20 this._name = "CloudMaterial";
21 this._shaderName = "cloud"; 21 this._shaderName = "cloud";
22 22
23 this._texMap = 'assets/images/cloud2.jpg'; 23 this._texMap = 'assets/images/cloud10.png';
24 this._diffuseColor = [0.5, 0.5, 0.5, 0.5]; 24 this._diffuseColor = [0.5, 0.5, 0.5, 0.5];
25 25
26 // base size of cloud polygons. Random adjustments made to each quad 26 // base size of cloud polygons. Random adjustments made to each quad
@@ -106,7 +106,8 @@ var CloudMaterial = function CloudMaterial() {
106 106
107 this.init = function( world ) 107 this.init = function( world )
108 { 108 {
109 var GLWorld = require("js/lib/drawing/world").World; 109 var GLWorld = require("js/lib/drawing/world").World,
110 NJUtils = require("js/lib/NJUtils").NJUtils;
110 111
111 // save the world 112 // save the world
112 if (world) this.setWorld( world ); 113 if (world) this.setWorld( world );
@@ -118,7 +119,8 @@ var CloudMaterial = function CloudMaterial() {
118 // create a canvas to render into 119 // create a canvas to render into
119 var doc = world.getCanvas().ownerDocument; 120 var doc = world.getCanvas().ownerDocument;
120 var canvasID = "__canvas__"; 121 var canvasID = "__canvas__";
121 this._srcCanvas = doc.createElement(canvasID); 122 //this._srcCanvas = doc.createElement(canvasID);
123 this._srcCanvas = NJUtils.makeNJElement("canvas", canvasID, "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true);
122 124
123 // build a world to do the rendering 125 // build a world to do the rendering
124 this._srcWorld = new GLWorld( this._srcCanvas, true ); 126 this._srcWorld = new GLWorld( this._srcCanvas, true );
@@ -157,7 +159,7 @@ var CloudMaterial = function CloudMaterial() {
157 159
158 // create the texture 160 // create the texture
159 var wrap = 'REPEAT', mips = true; 161 var wrap = 'REPEAT', mips = true;
160 this._glTex = new Texture( dstWorld, canvasID, wrap, mips ); 162 this._glTex = new Texture( world, this._srcCanvas, wrap, mips );
161 163
162 // set the shader values in the shader 164 // set the shader values in the shader
163 this.updateTexture(); 165 this.updateTexture();
@@ -213,7 +215,7 @@ var CloudMaterial = function CloudMaterial() {
213 RectangleGeometry.init(); 215 RectangleGeometry.init();
214 216
215 var verts = [], 217 var verts = [],
216 norms = [ [0,0,1], [0,0,1], [0,0,1], [0,0,1] ], 218 normals = [ [0,0,1], [0,0,1], [0,0,1], [0,0,1] ],
217 uvs = [ [0,0], [1,0], [1,1], [0,1] ]; 219 uvs = [ [0,0], [1,0], [1,1], [0,1] ];
218 220
219 for ( i = 0; i < 2; i++ ) 221 for ( i = 0; i < 2; i++ )
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