aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials
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/materials
parentc1a6cacf364d79cbf23b41e7089a1a6d39afea85 (diff)
downloadninja-1b7592f81c9b47c2b42d78efe385cd979d54d3ca.tar.gz
Cloud material
Diffstat (limited to 'js/lib/rdge/materials')
-rw-r--r--js/lib/rdge/materials/cloud-material.js12
1 files changed, 7 insertions, 5 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++ )