diff options
author | Eric Guzman | 2012-03-17 00:05:14 -0700 |
---|---|---|
committer | Eric Guzman | 2012-03-17 00:05:14 -0700 |
commit | a3192d8bc0f8c0698265817c14dcd2284fd89d7d (patch) | |
tree | 497ac55f550ed52f9d73b464aafb2aa6cb5f5038 /js/lib | |
parent | a6a6f9bcc5ff92f5bb5e9275336dfaec2d8e8f4c (diff) | |
parent | 954f5a13e371febcb1c0fb8015c577ee51c23130 (diff) | |
download | ninja-a3192d8bc0f8c0698265817c14dcd2284fd89d7d.tar.gz |
Merge branch 'refs/heads/master' into AddAnimationsLibrary
Conflicts:
js/panels/presets/default-transition-presets.js
Diffstat (limited to 'js/lib')
30 files changed, 1094 insertions, 306 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 3d6c6fc4..049145ce 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 | /* | ||
10 | var shaderProgramArray = new Array; | ||
11 | var glContextArray = new Array; | ||
12 | var vertexShaderSource = ""; | ||
13 | var fragmentShaderSource = ""; | ||
14 | var rdgeStarted = false; | ||
15 | */ | ||
16 | |||
17 | var nodeCounter = 0; | ||
18 | 7 | ||
19 | var GeomObj = require("js/lib/geom/geom-obj").GeomObj; | 8 | var GeomObj = require("js/lib/geom/geom-obj").GeomObj; |
20 | var Line = require("js/lib/geom/line").Line; | 9 | var Line = require("js/lib/geom/line").Line; |
@@ -22,11 +11,13 @@ var Rectangle = require("js/lib/geom/rectangle").Rectangle; | |||
22 | var Circle = require("js/lib/geom/circle").Circle; | 11 | var Circle = require("js/lib/geom/circle").Circle; |
23 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; | 12 | var MaterialsModel = require("js/models/materials-model").MaterialsModel; |
24 | 13 | ||
14 | var 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 | /////////////////////////////////////////////////////////////////////// |
29 | var World = function GLWorld( canvas, use3D ) { | 20 | var 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,17 +351,18 @@ 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 | var str = "" + this._nodeCounter; |
355 | //////////////////////////////////////////////////////////////////////////////////// | 356 | this._nodeCounter++; |
357 | return str; | ||
358 | }; | ||
356 | 359 | ||
357 | 360 | ||
358 | // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state | 361 | // start RDGE passing your runtime object, and false to indicate we don't need a an initialization state |
359 | // in the case of a procedurally built scene an init state is not needed for loading data | 362 | // in the case of a procedurally built scene an init state is not needed for loading data |
360 | if (this._useWebGL) { | 363 | if (this._useWebGL) { |
361 | rdgeStarted = true; | 364 | rdgeStarted = true; |
362 | var id = this._canvas.getAttribute( "data-RDGE-id" ); | 365 | this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" ); |
363 | this._canvas.rdgeid = id; | ||
364 | g_Engine.registerCanvas(this._canvas, this); | 366 | g_Engine.registerCanvas(this._canvas, this); |
365 | RDGEStart( this._canvas ); | 367 | RDGEStart( this._canvas ); |
366 | this._canvas.task.stop() | 368 | this._canvas.task.stop() |
@@ -391,7 +393,7 @@ World.prototype.updateObject = function (obj) { | |||
391 | if (nPrims > 0) { | 393 | if (nPrims > 0) { |
392 | ctrTrNode = obj.getTransformNode(); | 394 | ctrTrNode = obj.getTransformNode(); |
393 | if (ctrTrNode == null) { | 395 | if (ctrTrNode == null) { |
394 | ctrTrNode = createTransformNode("objRootNode_" + nodeCounter++); | 396 | ctrTrNode = createTransformNode("objRootNode_" + this._nodeCounter++); |
395 | this._rootNode.insertAsChild( ctrTrNode ); | 397 | this._rootNode.insertAsChild( ctrTrNode ); |
396 | obj.setTransformNode( ctrTrNode ); | 398 | obj.setTransformNode( ctrTrNode ); |
397 | } | 399 | } |
@@ -401,7 +403,7 @@ World.prototype.updateObject = function (obj) { | |||
401 | }); | 403 | }); |
402 | ctrTrNode.meshes = []; | 404 | ctrTrNode.meshes = []; |
403 | 405 | ||
404 | ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prims[0]); | 406 | ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); |
405 | ctrTrNode.attachMaterial(materialNodes[0]); | 407 | ctrTrNode.attachMaterial(materialNodes[0]); |
406 | } | 408 | } |
407 | 409 | ||
@@ -420,12 +422,12 @@ World.prototype.updateObject = function (obj) { | |||
420 | }); | 422 | }); |
421 | childTrNode.meshes = []; | 423 | childTrNode.meshes = []; |
422 | } else { | 424 | } else { |
423 | childTrNode = createTransformNode("objNode_" + nodeCounter++); | 425 | childTrNode = createTransformNode("objNode_" + this._nodeCounter++); |
424 | ctrTrNode.insertAsChild(childTrNode); | 426 | ctrTrNode.insertAsChild(childTrNode); |
425 | } | 427 | } |
426 | 428 | ||
427 | // attach the instanced box goe | 429 | // attach the instanced box goe |
428 | childTrNode.attachMeshNode(this.renderer.id + "_prim_" + nodeCounter++, prim); | 430 | childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); |
429 | childTrNode.attachMaterial(materialNodes[i]); | 431 | childTrNode.attachMaterial(materialNodes[i]); |
430 | } | 432 | } |
431 | }; | 433 | }; |
@@ -680,7 +682,7 @@ World.prototype.render = function() { | |||
680 | var root = this.getGeomRoot(); | 682 | va |