aboutsummaryrefslogtreecommitdiff
path: root/js/lib/drawing
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/drawing')
-rwxr-xr-xjs/lib/drawing/world.js22
1 files changed, 15 insertions, 7 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 08f9d319..71d0d098 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,9 +484,13 @@ 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++;
488 } 492 }
493 }
489 494
490 // delete all of the child nodes 495 // delete all of the child nodes
491 var i; 496 var i;
@@ -505,17 +510,19 @@ 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++;
518 } 524 }
525 }
519 526
520 // send a notification that the tree has changed 527 // send a notification that the tree has changed
521 this._notifier.sendNotification( this._notifier.OBJECT_CHANGE ); 528 this._notifier.sendNotification( this._notifier.OBJECT_CHANGE );
@@ -647,6 +654,7 @@ World.prototype.clearTree = function()
647 654
648 if (this._useWebGL) 655 if (this._useWebGL)
649 { 656 {
657 this.stop();
650 var root = this._rootNode; 658 var root = this._rootNode;
651 root.children = new Array(); 659 root.children = new Array();
652 RDGE.globals.engine.unregisterCanvas( this._canvas.rdgeid ); 660 RDGE.globals.engine.unregisterCanvas( this._canvas.rdgeid );