aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/NJUtils.js34
-rwxr-xr-xjs/lib/drawing/world.js102
-rwxr-xr-xjs/lib/geom/brush-stroke.js329
-rwxr-xr-xjs/lib/geom/circle.js103
-rwxr-xr-xjs/lib/geom/geom-obj.js210
-rwxr-xr-xjs/lib/geom/line.js57
-rwxr-xr-xjs/lib/geom/rectangle.js111
-rwxr-xr-xjs/lib/geom/sub-path.js86
-rwxr-xr-xjs/lib/rdge/materials/bump-metal-material.js10
-rw-r--r--js/lib/rdge/materials/deform-material.js2
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js41
-rw-r--r--js/lib/rdge/materials/fly-material.js2
-rw-r--r--js/lib/rdge/materials/julia-material.js2
-rw-r--r--js/lib/rdge/materials/keleidoscope-material.js2
-rwxr-xr-xjs/lib/rdge/materials/linear-gradient-material.js2
-rw-r--r--js/lib/rdge/materials/mandel-material.js2
-rw-r--r--js/lib/rdge/materials/plasma-material.js37
-rw-r--r--js/lib/rdge/materials/pulse-material.js11
-rw-r--r--js/lib/rdge/materials/radial-blur-material.js9
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js7
-rw-r--r--js/lib/rdge/materials/relief-tunnel-material.js2
-rw-r--r--js/lib/rdge/materials/square-tunnel-material.js2
-rw-r--r--js/lib/rdge/materials/star-material.js2
-rw-r--r--js/lib/rdge/materials/taper-material.js8
-rw-r--r--js/lib/rdge/materials/tunnel-material.js2
-rw-r--r--js/lib/rdge/materials/twist-material.js2
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js6
-rwxr-xr-xjs/lib/rdge/materials/uber-material.js109
-rw-r--r--js/lib/rdge/materials/water-material.js2
-rw-r--r--js/lib/rdge/materials/z-invert-material.js2
30 files changed, 998 insertions, 298 deletions
<
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js
index fe8623a1..4c181ab8 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -118,7 +118,39 @@ exports.NJUtils = Object.create(Object.prototype, {
118 ///// TODO: Selection and model should be based on the element type 118 ///// TODO: Selection and model should be based on the element type
119 makeModelFromElement: { 119 makeModelFromElement: {
120 value: function(el) { 120 value: function(el) {
121 this.makeElementModel(el, "Div", "block", false); 121 var selection = "div",
122 controller = "block",
123 isShape = false;
124 switch(el.nodeName.toLowerCase())
125 {
126 case "div":
127 break;
128 case "img":
129 selection = "image";
130 controller = "image";
131 break;
132 case "video":
133 selection = "video";
134 controller = "video";
135 break;
136 case "canvas":
137 isShape = el.getAttribute("data-RDGE-id");
138 if(isShape)
139 {
140 // TODO - Need more info about the shape
141 selection = "canvas";
142 controller = "shape";
143 }
144 else
145 {
146 selection = "canvas";
147 controller = "canvas";
148 }
149 break;
150 case "shape":
151 break;
152 }
153 this.makeElementModel(el, selection, controller, isShape);
122 } 154 }
123 }, 155 },
124 156
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 3d6c6fc4..df24f556 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -4,17 +4,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7// Useless Global variables.
8// TODO: Remove this as soon as QE test pass
9/*
10var shaderProgramArray = new Array;
11var glContextArray = new Array;
12var vertexShaderSource = "";
13var fragmentShaderSource = "";
14var rdgeStarted = false;
15*/
16
17var nodeCounter = 0;
18 7
19var GeomObj = require("js/lib/geom/geom-obj").GeomObj; 8var GeomObj = require("js/lib/geom/geom-obj").GeomObj;
20var Line = require("js/lib/geom/line").Line; 9var Line = require("js/lib/geom/line").Line;
@@ -22,11 +11,13 @@ var Rectangle = require("js/lib/geom/rectangle").Rectangle;
22var Circle = require("js/lib/geom/circle").Circle; 11var Circle = require("js/lib/geom/circle").Circle;
23var MaterialsModel = require("js/models/materials-model").MaterialsModel; 12var MaterialsModel = require("js/models/materials-model").MaterialsModel;
24 13
14var worldCounter = 0;
15
25/////////////////////////////////////////////////////////////////////// 16///////////////////////////////////////////////////////////////////////
26// Class GLWorld 17// Class GLWorld
27// Manages display in a canvas 18// Manages display in a canvas
28/////////////////////////////////////////////////////////////////////// 19///////////////////////////////////////////////////////////////////////
29var World = function GLWorld( canvas, use3D ) { 20var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
30 /////////////////////////////////////////////////////////////////////// 21 ///////////////////////////////////////////////////////////////////////
31 // Instance variables 22 // Instance variables
32 /////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////
@@ -39,7 +30,11 @@ var World = function GLWorld( canvas, use3D ) {
39 30
40 this._canvas = canvas; 31 this._canvas = canvas;
41 if (this._useWebGL) { 32 if (this._useWebGL) {
42 this._glContext = canvas.getContext("experimental-webgl"); 33 if(preserveDrawingBuffer) {
34 this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true});
35 } else {
36 this._glContext = canvas.getContext("experimental-webgl");
37 }
43 } else { 38 } else {
44 this._2DContext = canvas.getContext( "2d" ); 39 this._2DContext = canvas.getContext( "2d" );
45 } 40 }
@@ -76,6 +71,12 @@ var World = function GLWorld( canvas, use3D ) {
76 // no animated materials 71 // no animated materials
77 this._firstRender = true; 72 this._firstRender = true;
78 73
74 this._worldCount = worldCounter;
75 worldCounter++;
76
77 // keep a counter for generating node names
78 this._nodeCounter = 0;
79
79 /////////////////////////////////////////////////////////////////////// 80 ///////////////////////////////////////////////////////////////////////
80 // Property accessors 81 // Property accessors
81 /////////////////////////////////////////////////////////////////////// 82 ///////////////////////////////////////////////////////////////////////
@@ -350,9 +351,12 @@ var World = function GLWorld( canvas, use3D ) {
350 return false; 351 return false;
351 }; 352 };
352 353
353 354 this.generateUniqueNodeID = function()
354 // END RDGE 355 {
355 //////////////////////////////////////////////////////////////////////////////////// 356 var str = "" + this._nodeCounter;
357 this._nodeCounter++;
358 return str;
359 }
356 360
357 361
358 // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state 362 // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state
@@ -391,7 +395,7 @@ World.prototype.updateObject = function (obj) {
391 if (nPrims > 0) { 395 if (nPrims > 0) {
392 ctrTrNode = obj.getTransformNode(); 396 ctrTrNode = obj.getTransformNode();
393 if (ctrTrNode == null) { 397 if (ctrTrNode == null) {
394 ctrTrNode = createTransformNode("objRootNode_" + nodeCounter++); 398 ctrTrNode = createTransformNode("objRootNode_" + this._nodeCounter++);
395 this._rootNode.insertAsChild( ctrTrNode ); 399 this._rootNode.insertAsChild( ctrTrNode );
396 obj.setTransformNode( ctrTrNode ); 400 obj.setTransformNode( ctrTrNode );
397 } 401 }
@@ -401,7 +405,7 @@ World.prototype.updateObject = function (obj) {
401 }); 405 });
402 ctrTrNode.meshes = []; 406 ctrTrNode.meshes = [];
403 407
404 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prims[0]); 408 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]);
405 ctrTrNode.attachMaterial(materialNodes[0]); 409 ctrTrNode.attachMaterial(materialNodes[0]);
406 } 410 }
407 411
@@ -420,12 +424,12 @@ World.prototype.updateObject = function (obj) {
420 }); 424 });
421 childTrNode.meshes = []; 425 childTrNode.meshes = [];
422 } else { 426 } else {
423 childTrNode = createTransformNode("objNode_" + nodeCounter++); 427 childTrNode = createTransformNode("objNode_" + this._nodeCounter++);
424 ctrTrNode.insertAsChild(childTrNode); 428 ctrTrNode.insertAsChild(childTrNode);
425 } 429 }
426 430
427 // attach the instanced box goe 431 // attach the instanced box goe
428 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prim); 432 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim);
429 childTrNode.attachMaterial(materialNodes[i]); 433 childTrNode.attachMaterial(materialNodes[i]);
430 } 434 }
431}; 435};
@@ -680,7 +684,7 @@ World.prototype.render = function() {
680 var root = this.getGeomRoot(); 684 var root = this.getGeomRoot();
681 this.hRender( root ); 685 this.hRender( root );
682 } else { 686 } else {
683 g_Engine.setContext( this._canvas.rdgeId ); 687 g_Engine.setContext( this._canvas.rdgeid );
684 //this.draw(); 688 //this.draw();
685 this.restartRenderLoop(); 689 this.restartRenderLoop();