aboutsummaryrefslogtreecommitdiff
path: root/js/lib/drawing/world.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-09 14:16:17 -0700
committerValerio Virgillito2012-07-09 14:18:36 -0700
commit1bbba17e8605434356de0a477710d6a0136986fc (patch)
tree7cdc80226b776c6fb2250e250acdbcd53fdb1ddd /js/lib/drawing/world.js
parentdc5b7a479a185dda8e9a09f4bbe26bd290641624 (diff)
parentab80aa9c7da912db384ec48c656f84fd673b5253 (diff)
downloadninja-1bbba17e8605434356de0a477710d6a0136986fc.tar.gz
Merge branch 'Taper' of https://github.com/ericmueller/ninja-internal
Conflicts: js/lib/geom/circle.js js/lib/rdge/materials/linear-gradient-material.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/lib/drawing/world.js')
-rwxr-xr-xjs/lib/drawing/world.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 26f33a64..2b76161f 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -466,6 +466,7 @@ World.prototype.updateObject = function (obj) {
466 if (prims.length != materialNodes.length) 466 if (prims.length != materialNodes.length)
467 throw new Error("inconsistent material and primitive counts"); 467 throw new Error("inconsistent material and primitive counts");
468 var nPrims = prims.length; 468 var nPrims = prims.length;
469 var iPrim = 0;
469 var ctrTrNode; 470 var ctrTrNode;
470 if (nPrims > 0) 471 if (nPrims > 0)
471 { 472 {
@@ -483,8 +484,12 @@ World.prototype.updateObject = function (obj) {
483 ); 484 );
484 ctrTrNode.meshes = []; 485 ctrTrNode.meshes = [];
485 486
486 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]);
487 ctrTrNode.attachMaterial(materialNodes[0]); 487 ctrTrNode.attachMaterial(materialNodes[0]);
488 while ((iPrim < nPrims) && (materialNodes[iPrim] == materialNodes[0]))
489 {
490 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]);
491 iPrim++;
492 }
488 } 493 }
489 494
490 // delete all of the child nodes 495 // delete all of the child nodes
@@ -505,16 +510,18 @@ World.prototype.updateObject = function (obj) {
505 } 510 }
506 ctrTrNode.children = []; 511 ctrTrNode.children = [];
507 512
508 for (var i = 1; i < nPrims; i++) 513 while (iPrim < nPrims)
509 { 514 {
510 // get the next primitive
511 childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++); 515 childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++);
512 ctrTrNode.insertAsChild(childTrNode); 516 ctrTrNode.insertAsChild(childTrNode);
517 var matNode = materialNodes[iPrim];
518 childTrNode.attachMaterial(matNode);
513 519
514 // attach the instanced box goe 520 while ((iPrim < nPrims) && (materialNodes[iPrim] == matNode))
515 var prim = prims[i]; 521 {
516 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); 522 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[iPrim]);
517 childTrNode.attachMaterial(materialNodes[i]); 523 iPrim++;
524 }
518 } 525 }
519 526
520 // send a notification that the tree has changed 527 // send a notification that the tree has changed