diff options
Diffstat (limited to 'js/lib/drawing/world.js')
-rwxr-xr-x | js/lib/drawing/world.js | 21 |
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 |