aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/drawing/world.js361
-rwxr-xr-xjs/lib/geom/circle.js66
-rwxr-xr-xjs/lib/geom/geom-obj.js29
-rwxr-xr-xjs/lib/geom/rectangle.js105
-rw-r--r--js/lib/geom/shape-primitive.js130
-rwxr-xr-xjs/lib/math/matrix.js9
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js168
-rw-r--r--js/lib/rdge/materials/cloud-material.js437
-rw-r--r--js/lib/rdge/materials/deform-material.js31
-rw-r--r--js/lib/rdge/materials/flag-material.js133
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js97
-rw-r--r--js/lib/rdge/materials/fly-material.js33
-rw-r--r--js/lib/rdge/materials/julia-material.js47
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js47
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js248
-rw-r--r--js/lib/rdge/materials/mandel-material.js44
-rwxr-xr-xjs/lib/rdge/materials/material.js302
-rw-r--r--js/lib/rdge/materials/plasma-material.js59
-rw-r--r--js/lib/rdge/materials/pulse-material.js183
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js117
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js275
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js44
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js40
-rw-r--r--js/lib/rdge/materials/star-material.js48
-rw-r--r--js/lib/rdge/materials/taper-material.js127
-rw-r--r--js/lib/rdge/materials/tunnel-material.js40
-rw-r--r--js/lib/rdge/materials/twist-material.js53
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js325
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js119
-rw-r--r--js/lib/rdge/materials/water-material.js310
-rw-r--r--js/lib/rdge/materials/z-invert-material.js45
-rw-r--r--js/lib/rdge/texture.js335
32 files changed, 2333 insertions, 2074 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 0dde9af4..8068284e 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -29,13 +29,19 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
29 } 29 }
30 30
31 this._canvas = canvas; 31 this._canvas = canvas;
32 if (this._useWebGL) { 32 if (this._useWebGL)
33 if(preserveDrawingBuffer) { 33 {
34 if(preserveDrawingBuffer)
35 {
34 this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true}); 36 this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true});
35 } else { 37 }
38 else
39 {
36 this._glContext = canvas.getContext("experimental-webgl"); 40 this._glContext = canvas.getContext("experimental-webgl");
37 } 41 }
38 } else { 42 }
43 else
44 {
39 this._2DContext = canvas.getContext( "2d" ); 45 this._2DContext = canvas.getContext( "2d" );
40 } 46 }
41 47
@@ -77,6 +83,9 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
77 // keep a counter for generating node names 83 // keep a counter for generating node names
78 this._nodeCounter = 0; 84 this._nodeCounter = 0;
79 85
86 // for sending notifications to listeners
87 this._notifier = new Notifier();
88
80 /////////////////////////////////////////////////////////////////////// 89 ///////////////////////////////////////////////////////////////////////
81 // Property accessors 90 // Property accessors
82 /////////////////////////////////////////////////////////////////////// 91 ///////////////////////////////////////////////////////////////////////
@@ -119,6 +128,7 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
119 128
120 // Flag to play/pause animation at authortime 129 // Flag to play/pause animation at authortime
121 this._previewAnimation = true; 130 this._previewAnimation = true;
131
122 //////////////////////////////////////////////////////////////////////////////////// 132 ////////////////////////////////////////////////////////////////////////////////////
123 // RDGE 133 // RDGE
124 // local variables 134 // local variables
@@ -143,7 +153,8 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
143 this.setCameraMat( camMat ); 153 this.setCameraMat( camMat );
144 154
145 // post-load processing of the scene 155 // post-load processing of the scene
146 this.init = function() { 156 this.init = function()
157 {
147 var ctx1 = RDGE.globals.engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle), 158 var ctx1 = RDGE.globals.engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle),
148 ctx2 = RDGE.globals.engine.getContext(); 159 ctx2 = RDGE.globals.engine.getContext();
149 if (ctx1 != ctx2) console.log( "***** different contexts *****" ); 160 if (ctx1 != ctx2) console.log( "***** different contexts *****" );
@@ -169,14 +180,14 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
169 180
170 // create some lights 181 // create some lights
171 // light 1 182 // light 1
172 this.light = RDGE.createLightNode("myLight"); 183// this.light = RDGE.createLightNode("myLight");
173 this.light.setPosition([0,0,1.2]); 184// this.light.setPosition([0,0,1.2]);
174 this.light.setDiffuseColor([0.75,0.9,1.0,1.0]); 185// this.light.setDiffuseColor([0.75,0.9,1.0,1.0]);
175 186
176 // light 2 187 // light 2
177 this.light2 = RDGE.createLightNode("myLight2"); 188// this.light2 = RDGE.createLightNode("myLight2");
178 this.light2.setPosition([-0.5,0,1.2]); 189// this.light2.setPosition([-0.5,0,1.2]);
179 this.light2.setDiffuseColor([1.0,0.9,0.75,1.0]); 190// this.light2.setDiffuseColor([1.0,0.9,0.75,1.0]);
180 191
181 // create a light transform 192 // create a light transform
182 var lightTr = RDGE.createTransformNode("lightTr"); 193 var lightTr = RDGE.createTransformNode("lightTr");
@@ -185,8 +196,8 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
185 lightTr.attachMaterial(RDGE.createMaterialNode("lights")); 196 lightTr.attachMaterial(RDGE.createMaterialNode("lights"));
186 197
187 // enable light channels 1, 2 - channel 0 is used by the default shader 198 // enable light channels 1, 2 - channel 0 is used by the default shader
188 lightTr.materialNode.enableLightChannel(1, this.light); 199// lightTr.materialNode.enableLightChannel(1, this.light);
189 lightTr.materialNode.enableLightChannel(2, this.light2); 200// lightTr.materialNode.enableLightChannel(2, this.light2);
190 201
191 // all added objects are parented to the light node 202 // all added objects are parented to the light node
192 this._rootNode = lightTr; 203 this._rootNode = lightTr;
@@ -201,19 +212,21 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
201 }; 212 };
202 213
203 // main code for handling user interaction and updating the scene 214 // main code for handling user interaction and updating the scene
204 this.update = function(dt) { 215 this.update = function(dt)
216 {
205 if (!dt) dt = 0.2; 217 if (!dt) dt = 0.2;
206 218
207 dt = 0.01; // use our own internal throttle 219 dt = 0.01; // use our own internal throttle
208 this.elapsed += dt; 220 this.elapsed += dt;
209 221
210 if (this._useWebGL) { 222 if (this._useWebGL)
223 {
211 // changed the global position uniform of light 0, another way to change behavior of a light 224 // changed the global position uniform of light 0, another way to change behavior of a light
212 RDGE.rdgeGlobalParameters.u_light0Pos.set([5 * Math.cos(this.elapsed), 5 * Math.sin(this.elapsed), 20]); 225 RDGE.rdgeGlobalParameters.u_light0Pos.set([5 * Math.cos(this.elapsed), 5 * Math.sin(this.elapsed), 20]);
213 226
214 // orbit the light nodes around the boxes 227 // orbit the light nodes around the boxes
215 this.light.setPosition([1.2*Math.cos(this.elapsed*2.0), 1.2*Math.sin(this.elapsed*2.0), 1.2*Math.cos(this.elapsed*2.0)]); 228// this.light.setPosition([1.2*Math.cos(this.elapsed*2.0), 1.2*Math.sin(this.elapsed*2.0), 1.2*Math.cos(this.elapsed*2.0)]);
216 this.light2.setPosition([-1.2*Math.cos(this.elapsed*2.0), 1.2*Math.sin(this.elapsed*2.0), -1.2*Math.cos(this.elapsed)]); 229// this.light2.setPosition([-1.2*Math.cos(this.elapsed*2.0), 1.2*Math.sin(this.elapsed*2.0), -1.2*Math.cos(this.elapsed)]);
217 } 230 }
218 231
219 this.updateMaterials( this.getGeomRoot(), this.elapsed ); 232 this.updateMaterials( this.getGeomRoot(), this.elapsed );
@@ -224,35 +237,48 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
224 }; 237 };
225 238
226 // defining the draw function to control how the scene is rendered 239 // defining the draw function to control how the scene is rendered
227 this.draw = function() { 240 this.draw = function()
228 if (this._useWebGL) { 241 {
242 if (this._useWebGL)
243 {
229 RDGE.globals.engine.setContext( this._canvas.rdgeid ); 244 RDGE.globals.engine.setContext( this._canvas.rdgeid );
230 var ctx = RDGE.globals.engine.getContext(); 245 var ctx = RDGE.globals.engine.getContext();
231 var renderer = ctx.renderer; 246 var renderer = ctx.renderer;
232 if (renderer.unloadedTextureCount <= 0) { 247 if (renderer.unloadedTextureCount <= 0)
248 {
233 renderer.disableCulling(); 249 renderer.disableCulling();
234 renderer._clear(); 250 renderer._clear();
235 this.myScene.render(); 251 this.myScene.render();
236 252
237 if (this._firstRender) { 253 if (this._firstRender)
238 if (this._canvas.task) { 254 {
255 this._notifier.sendNotification( this._notifier.FIRST_RENDER );
256 if (this._canvas.task)
257 {
239 this._firstRender = false; 258 this._firstRender = false;
240 259
241 if (!this.hasAnimatedMaterials() || !this._previewAnimation) { 260 if (!this.hasAnimatedMaterials() || !this._previewAnimation)
261 {
242 this._canvas.task.stop(); 262 this._canvas.task.stop();
243 //this._renderCount = 10; 263 //this._renderCount = 10;
244 } 264 }
245 } 265 }
246