aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/NJUtils.js12
-rwxr-xr-xjs/lib/drawing/world.js407
-rwxr-xr-xjs/lib/geom/brush-stroke.js637
-rwxr-xr-xjs/lib/geom/circle.js113
-rwxr-xr-xjs/lib/geom/geom-obj.js538
-rwxr-xr-xjs/lib/geom/line.js82
-rwxr-xr-xjs/lib/geom/rectangle.js125
-rw-r--r--js/lib/geom/shape-primitive.js4
-rwxr-xr-xjs/lib/geom/sub-path.js18
-rwxr-xr-xjs/lib/nj-base.js13
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js114
-rw-r--r--js/lib/rdge/materials/cloud-material.js247
-rw-r--r--js/lib/rdge/materials/deform-material.js88
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js139
-rw-r--r--js/lib/rdge/materials/fly-material.js9
-rw-r--r--js/lib/rdge/materials/julia-material.js8
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js8
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js426
-rw-r--r--js/lib/rdge/materials/mandel-material.js8
-rwxr-xr-xjs/lib/rdge/materials/material-parser.js81
-rwxr-xr-xjs/lib/rdge/materials/material.js15
-rw-r--r--js/lib/rdge/materials/plasma-material.js12
-rw-r--r--js/lib/rdge/materials/pulse-material.js69
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js420
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js438
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js132
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js133
-rw-r--r--js/lib/rdge/materials/star-material.js133
-rw-r--r--js/lib/rdge/materials/taper-material.js396
-rw-r--r--js/lib/rdge/materials/tunnel-material.js79
-rw-r--r--js/lib/rdge/materials/twist-material.js161
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js370
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js1376
-rw-r--r--js/lib/rdge/materials/water-material.js275
-rw-r--r--js/lib/rdge/materials/z-invert-material.js132
-rw-r--r--js/lib/rdge/texture.js41
36 files changed, 3408 insertions, 3851 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js
index 904aa41e..67bb59c4 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -94,7 +94,10 @@ exports.NJUtils = Object.create(Object.prototype, {
94 ///// TODO: find a different place for this function 94 ///// TODO: find a different place for this function
95 makeElementModel: { 95 makeElementModel: {
96 value: function(el, selection, controller, isShape) { 96 value: function(el, selection, controller, isShape) {
97 var p3d = Montage.create(Properties3D).init(el); 97 var p3d = Montage.create(Properties3D);
98 if(selection === "Stage") {
99 p3d.init(el, true);
100 }
98 var shapeProps = null; 101 var shapeProps = null;
99 var pi = controller + "Pi"; 102 var pi = controller + "Pi";
100 103
@@ -136,7 +139,8 @@ exports.NJUtils = Object.create(Object.prototype, {
136 controller: { value: ControllerFactory.getController(controller)}, 139 controller: { value: ControllerFactory.getController(controller)},
137 pi: { value: pi}, 140 pi: { value: pi},
138 props3D: { value: p3d}, 141 props3D: { value: p3d},
139 shapeModel: { value: shapeProps} 142 shapeModel: { value: shapeProps},
143 isShape: { value: isShape}
140 }); 144 });
141 145
142 } 146 }
@@ -168,6 +172,7 @@ exports.NJUtils = Object.create(Object.prototype, {
168 // TODO - Need more info about the shape 172 // TODO - Need more info about the shape
169 selection = "canvas"; 173 selection = "canvas";
170 controller = "shape"; 174 controller = "shape";
175 isShape = true;
171 } 176 }
172 else 177 else
173 { 178 {
@@ -179,6 +184,9 @@ exports.NJUtils = Object.create(Object.prototype, {
179 break; 184 break;
180 } 185 }
181 this.makeElementModel(el, selection, controller, isShape); 186 this.makeElementModel(el, selection, controller, isShape);
187 if(el.elementModel && el.elementModel.props3D) {
188 el.elementModel.props3D.init(el, (selection === "Stage"));
189 }
182 } 190 }
183 }, 191 },
184 192
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 4ca738f4..eb06e59d 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -29,14 +29,20 @@ 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 {
33 preserveDrawingBuffer = true; 34 preserveDrawingBuffer = true;
34 if(preserveDrawingBuffer) { 35 if(preserveDrawingBuffer)
36 {
35 this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true}); 37 this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true});
36 } else { 38 }
39 else
40 {
37 this._glContext = canvas.getContext("experimental-webgl"); 41 this._glContext = canvas.getContext("experimental-webgl");
38 } 42 }
39 } else { 43 }
44 else
45 {
40 this._2DContext = canvas.getContext( "2d" ); 46 this._2DContext = canvas.getContext( "2d" );
41 } 47 }
42 48
@@ -124,6 +130,7 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
124 130
125 // Flag to play/pause animation at authortime 131 // Flag to play/pause animation at authortime
126 this._previewAnimation = true; 132 this._previewAnimation = true;
133
127 //////////////////////////////////////////////////////////////////////////////////// 134 ////////////////////////////////////////////////////////////////////////////////////
128 // RDGE 135 // RDGE
129 // local variables 136 // local variables
@@ -148,46 +155,47 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
148 this.setCameraMat( camMat ); 155 this.setCameraMat( camMat );
149 156
150 // post-load processing of the scene 157 // post-load processing of the scene
151 this.init = function() { 158 this.init = function()
152 var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle), 159 {
153 ctx2 = g_Engine.getContext(); 160 var ctx1 = RDGE.globals.engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle),
161 ctx2 = RDGE.globals.engine.getContext();
154 if (ctx1 != ctx2) console.log( "***** different contexts *****" ); 162 if (ctx1 != ctx2) console.log( "***** different contexts *****" );
155 this.renderer = ctx1.renderer; 163 this.renderer = ctx1.renderer;
156 this.renderer._world = this; 164 this.renderer._world = this;
157 165
158 // create a camera, set its perspective, and then point it at the origin 166 // create a camera, set its perspective, and then point it at the origin
159 var cam = new camera(); 167 var cam = new RDGE.camera();
160 this._camera = cam; 168 this._camera = cam;
161 cam.setPerspective(this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar()); 169 cam.setPerspective(this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar());
162 cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], vec3.up()); 170 cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], RDGE.vec3.up());
163 171
164 // make this camera the active camera 172 // make this camera the active camera
165 this.renderer.cameraManager().setActiveCamera(cam); 173 this.renderer.cameraManager().setActiveCamera(cam);
166 174
167 // change clear color 175 // change clear color
168 //this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT); 176 //this.renderer.setClearFlags(RDGE.globals.engine.getContext().DEPTH_BUFFER_BIT);
169 this.renderer.setClearColor([0.0, 0.0, 0.0, 0.0]); 177 this.renderer.setClearColor([0.0, 0.0, 0.0, 0.0]);
170 //this.renderer.NinjaWorld = this; 178 //this.renderer.NinjaWorld = this;
171 179
172 // create an empty scene graph 180 // create an empty scene graph
173 this.myScene = new SceneGraph(); 181 this.myScene = new RDGE.SceneGraph();
174 182
175 // create some lights 183 // create some lights
176 // light 1 184 // light 1
177 this.light = createLightNode("myLight"); 185 this.light = RDGE.createLightNode("myLight");
178 this.light.setPosition([0,0,1.2]); 186 this.light.setPosition([0,0,1.2]);
179 this.light.setDiffuseColor([0.75,0.9,1.0,1.0]); 187 this.light.setDiffuseColor([0.75,0.9,1.0,1.0]);
180 188
181 // light 2 189 // light 2
182 this.light2 = createLightNode("myLight2"); 190 this.light2 = RDGE.createLightNode("myLight2");
183 this.light2.setPosition([-0.5,0,1.2]); 191 this.light2.setPosition([-0.5,0,1.2]);
184 this.light2.setDiffuseColor([1.0,0.9,0.75,1.0]); 192 this.light2.setDiffuseColor([1.0,0.9,0.75,1.0]);
185 193
186 // create a light transform 194 // create a light transform
187 var lightTr = createTransformNode("lightTr"); 195 var lightTr = RDGE.createTransformNode("lightTr");
188 196
189 // create and attach a material - materials hold the light data 197 // create and attach a material - materials hold the light data
190 lightTr.attachMaterial(createMaterialNode("lights")); 198 lightTr.attachMaterial(RDGE.createMaterialNode("lights"));
191 199
192 // enable light channels 1, 2 - channel 0 is used by the default shader 200 // enable light channels 1, 2 - channel 0 is used by the default shader
193 lightTr.materialNode.enableLightChannel(1, this.light); 201 lightTr.materialNode.enableLightChannel(1, this.light);
@@ -200,21 +208,23 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
200 this.myScene.addNode(lightTr); 208 this.myScene.addNode(lightTr);
201 209
202 // Add the scene to the engine - necessary if you want the engine to draw for you 210 // Add the scene to the engine - necessary if you want the engine to draw for you
203 //g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); 211 //RDGE.globals.engine.AddScene("myScene" + this._canvas.id, this.myScene);
204 var name = this._canvas.getAttribute( "data-RDGE-id" ); 212 var name = this._canvas.getAttribute( "data-RDGE-id" );
205 g_Engine.AddScene("myScene" + name, this.myScene); 213 RDGE.globals.engine.AddScene("myScene" + name, this.myScene);
206 }; 214 };
207 215
208 // main code for handling user interaction and updating the scene 216 // main code for handling user interaction and updating the scene