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.js92
-rwxr-xr-xjs/lib/geom/brush-stroke.js329
-rwxr-xr-xjs/lib/geom/circle.js8
-rwxr-xr-xjs/lib/geom/geom-obj.js87
-rwxr-xr-xjs/lib/geom/rectangle.js9
-rwxr-xr-xjs/lib/geom/sub-path.js84
-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
29 files changed, 662 insertions, 245 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js
index e16715a4..4f1082f9 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -116,7 +116,39 @@ exports.NJUtils = Object.create(Object.prototype, {
116 ///// TODO: Selection and model should be based on the element type 116 ///// TODO: Selection and model should be based on the element type
117 makeModelFromElement: { 117 makeModelFromElement: {
118 value: function(el) { 118 value: function(el) {
119 this.makeElementModel(el, "Div", "block", false); 119 var selection = "div",
120 controller = "block",
121 isShape = false;
122 switch(el.nodeName.toLowerCase())
123 {
124 case "div":
125 break;
126 case "img":
127 selection = "image";
128 controller = "image";
129 break;
130 case "video":
131 selection = "video";
132 controller = "video";
133 break;
134 case "canvas":
135 isShape = el.getAttribute("data-RDGE-id");
136 if(isShape)
137 {
138 // TODO - Need more info about the shape
139 selection = "canvas";
140 controller = "shape";
141 }
142 else
143 {
144 selection = "canvas";
145 controller = "canvas";
146 }
147 break;
148 case "shape":
149 break;
150 }
151 this.makeElementModel(el, selection, controller, isShape);
120 } 152 }
121 }, 153 },
122 154
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 04e4d96b..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,6 +11,8 @@ 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
@@ -80,6 +71,12 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
80 // no animated materials 71 // no animated materials
81 this._firstRender = true; 72 this._firstRender = true;
82 73
74 this._worldCount = worldCounter;
75 worldCounter++;
76
77 // keep a counter for generating node names
78 this._nodeCounter = 0;
79
83 /////////////////////////////////////////////////////////////////////// 80 ///////////////////////////////////////////////////////////////////////
84 // Property accessors 81 // Property accessors
85 /////////////////////////////////////////////////////////////////////// 82 ///////////////////////////////////////////////////////////////////////
@@ -354,9 +351,12 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
354 return false; 351 return false;
355 }; 352 };
356 353
357 354 this.generateUniqueNodeID = function()
358 // END RDGE 355 {
359 //////////////////////////////////////////////////////////////////////////////////// 356 var str = "" + this._nodeCounter;
357 this._nodeCounter++;
358 return str;
359 }
360 360
361 361
362 // 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
@@ -395,7 +395,7 @@ World.prototype.updateObject = function (obj) {
395 if (nPrims > 0) { 395 if (nPrims > 0) {
396 ctrTrNode = obj.getTransformNode(); 396 ctrTrNode = obj.getTransformNode();
397 if (ctrTrNode == null) { 397 if (ctrTrNode == null) {
398 ctrTrNode = createTransformNode("objRootNode_" + nodeCounter++); 398 ctrTrNode = createTransformNode("objRootNode_" + this._nodeCounter++);
399 this._rootNode.insertAsChild( ctrTrNode ); 399 this._rootNode.insertAsChild( ctrTrNode );
400 obj.setTransformNode( ctrTrNode ); 400 obj.setTransformNode( ctrTrNode );
401 } 401 }
@@ -405,7 +405,7 @@ World.prototype.updateObject = function (obj) {
405 }); 405 });
406 ctrTrNode.meshes = []; 406 ctrTrNode.meshes = [];
407 407
408 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prims[0]); 408 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]);
409 ctrTrNode.attachMaterial(materialNodes[0]); 409 ctrTrNode.attachMaterial(materialNodes[0]);
410 } 410 }
411 411
@@ -424,12 +424,12 @@ World.prototype.updateObject = function (obj) {
424 }); 424 });
425 childTrNode.meshes = []; 425 childTrNode.meshes = [];
426 } else { 426 } else {
427 childTrNode = createTransformNode("objNode_" + nodeCounter++); 427 childTrNode = createTransformNode("objNode_" + this._nodeCounter++);
428 ctrTrNode.insertAsChild(childTrNode); 428 ctrTrNode.insertAsChild(childTrNode);
429 } 429 }
430 430
431 // attach the instanced box goe 431 // attach the instanced box goe
432 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prim); 432 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim);
433 childTrNode.attachMaterial(materialNodes[i]); 433 childTrNode.attachMaterial(materialNodes[i]);
434 } 434 }
435}; 435};
@@ -731,7 +731,8 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) {
731 } 731 }
732}; 732};
733 733
734World.prototype.export = function() { 734World.prototype.export = function()
735{
735 var exportStr = "GLWorld 1.0\n"; 736 var exportStr = "GLWorld 1.0\n";
736 var id = this.getCanvas().getAttribute( "data-RDGE-id" ); 737 var id = this.getCanvas().getAttribute( "data-RDGE-id" );
737 exportStr += "id: " + id + "\n"; 738 exportStr += "id: " + id + "\n";
@@ -740,17 +741,29 @@ World.prototype.export = function() {
740 exportStr += "zNear: " + this._zNear + "\n"; 741 exportStr += "zNear: " + this._zNear + "\n";
741 exportStr += "zFar: " + this._zFar + "\n"; 742 exportStr += "zFar: " + this._zFar + "\n";
742 exportStr += "viewDist: " + this._viewDist + "\n"; 743 exportStr += "viewDist: " + this._viewDist + "\n";
744 if (this._useWebGL)
745 exportStr += "webGL: true\n";
743 746
744 // we need 2 export modes: One for save/restore, one for publish. 747 // we need 2 export modes: One for save/restore, one for publish.
745 // hardcoding for now 748 // hardcoding for now
746 var exportForPublish = false; 749 //var exportForPublish = false;
750 //if (!exportForPublish) exportForPublish = false;
751 var exportForPublish = true;
747 exportStr += "publish: " + exportForPublish + "\n"; 752 exportStr += "publish: " + exportForPublish + "\n";
748 753
749 if (exportForPublish) { 754 if (exportForPublish && this._useWebGL)
755 {
750 exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; 756 exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n";
751 } else {