aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/lib/drawing/world.js76
1 files changed, 38 insertions, 38 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 3c93b2b7..228c0d94 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -437,15 +437,15 @@ World.prototype.getGeomRoot = function() {
437World.prototype.updateObject = function (obj) { 437World.prototype.updateObject = function (obj) {
438 if (!this._useWebGL) return; 438 if (!this._useWebGL) return;
439 439
440 var prims = obj.getPrimitiveArray(); 440 var prims = obj.getPrimitiveArray();
441 var materialNodes = obj.getMaterialNodeArray(); 441 var materialNodes = obj.getMaterialNodeArray();
442 if (prims.length != materialNodes.length) 442 if (prims.length != materialNodes.length)
443 throw new Error("inconsistent material and primitive counts"); 443 throw new Error("inconsistent material and primitive counts");
444 var nPrims = prims.length; 444 var nPrims = prims.length;
445 var ctrTrNode; 445 var ctrTrNode;
446 if (nPrims > 0) 446 if (nPrims > 0)
447 { 447 {
448 ctrTrNode = obj.getTransformNode(); 448 ctrTrNode = obj.getTransformNode();
449 if (ctrTrNode == null) { 449 if (ctrTrNode == null) {
450 ctrTrNode = RDGE.createTransformNode("objRootNode_" + this._nodeCounter++); 450 ctrTrNode = RDGE.createTransformNode("objRootNode_" + this._nodeCounter++);
451 this._rootNode.insertAsChild( ctrTrNode ); 451 this._rootNode.insertAsChild( ctrTrNode );
@@ -459,42 +459,42 @@ World.prototype.updateObject = function (obj) {
459 ); 459 );
460 ctrTrNode.meshes = []; 460 ctrTrNode.meshes = [];
461 461
462 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]); 462 ctrTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prims[0]);
463 ctrTrNode.attachMaterial(materialNodes[0]); 463 ctrTrNode.attachMaterial(materialNodes[0]);
464 } 464 }
465 465
466 // delete all of the child nodes
467 var i;
468 var childTrNode;
466 var children = ctrTrNode.children; 469 var children = ctrTrNode.children;
467 for (var i = 1; i < nPrims; i++) 470 for (i=0; i<children.length; i++)
468 { 471 {
469 // get the next primitive 472 childTrNode = children[i].transformNode;
470 var prim = prims[i]; 473 childTrNode.meshes.forEach(
471 474 function(thisMesh)
472 // get a previously created transform node. If the transform has not been created, create it 475 {
473 var childTrNode; 476 RDGE.globals.meshMan.deleteMesh(thisMesh.mesh.name);
474 if (children && children.length >= i) { 477 }
475 childTrNode = children[i-1].transformNode; 478 );
476 479 childTrNode.meshes = [];
477 childTrNode.meshes.forEach( 480 children[i] = null;
478 function(thisMesh) 481 }
479 { 482 ctrTrNode.children = [];
480 RDGE.globals.meshMan.deleteMesh(thisMesh.mesh.name);
481 }
482 );
483 childTrNode.meshes = [];
484 }
485 else
486 {
487 childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++);
488 ctrTrNode.insertAsChild(childTrNode);
489 }
490 483
491 // attach the instanced box goe 484 for (var i = 1; i < nPrims; i++)
492 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim); 485 {
493 childTrNode.attachMaterial(materialNodes[i]); 486 // get the next primitive
494 } 487 var prim = prims[i];
488 childTrNode = RDGE.createTransformNode("objNode_" + this._nodeCounter++);
489 ctrTrNode.insertAsChild(childTrNode);
490
491 // attach the instanced box goe
492 childTrNode.attachMeshNode(this.renderer.id + "_prim_" + this._nodeCounter++, prim);
493 childTrNode.attachMaterial(materialNodes[i]);
494 }
495 495
496 // send a notification that the tree has changed 496 // send a notification that the tree has changed
497 this._notifier.sendNotification( this._notifier.OBJECT_CHANGE ); 497 this._notifier.sendNotification( this._notifier.OBJECT_CHANGE );
498}; 498};
499 499
500World.prototype.addObject = function( obj ) 500World.prototype.addObject = function( obj )