aboutsummaryrefslogtreecommitdiff
path: root/js/lib/drawing/world.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/drawing/world.js')
-rwxr-xr-xjs/lib/drawing/world.js30
1 files changed, 28 insertions, 2 deletions
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index ca2f07cc..b9f9863f 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -439,6 +439,11 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) {
439 // in the case of a procedurally built scene an init state is not needed for loading data 439 // in the case of a procedurally built scene an init state is not needed for loading data
440 this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" ); 440 this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" );
441 if (this._useWebGL) { 441 if (this._useWebGL) {
442 // make sure the id is unique
443 var id = this.uniqueifyID( this._canvas.rdgeid );
444 this._canvas.rdgeid = id;
445 this._canvas.setAttribute( "data-rdge-id", id );
446
442 rdgeStarted = true; 447 rdgeStarted = true;
443 RDGE.globals.engine.unregisterCanvas( this._canvas ); 448 RDGE.globals.engine.unregisterCanvas( this._canvas );
444 RDGE.globals.engine.registerCanvas(this._canvas, this); 449 RDGE.globals.engine.registerCanvas(this._canvas, this);
@@ -673,13 +678,35 @@ World.prototype.updateMaterials = function( obj, time ) {
673 var n = matArray.length; 678 var n = matArray.length;
674 for (var i=0; i<n; i++) { 679 for (var i=0; i<n; i++) {
675 matArray[i].update( time ); 680 matArray[i].update( time );
676 } 681 }
677 } 682 }
678 683
679 this.updateMaterials( obj.getNext(), time ); 684 this.updateMaterials( obj.getNext(), time );
680 this.updateMaterials( obj.getChild(), time ); 685 this.updateMaterials( obj.getChild(), time );
681}; 686};
682 687
688
689World.prototype.uniqueifyID = function( id )
690{
691 var ctx = RDGE.globals.engine.getContext( id );
692 while ( ctx )
693 {
694 var num = 0;
695 var index = id.indexOf( "_" );
696 if (index >= 0)
697 {
698 var subStr = id.substr( index+1);
699 num = Number( subStr ) + 1;
700 id = id.substr( 0, index );
701 }
702
703 id = id + "_" + num;
704 ctx = RDGE.globals.engine.getContext( id );
705 }
706
707 return id;
708}
709
683// return the origin of the world in NDC 710// return the origin of the world in NDC
684World.prototype.getNDCOrigin = function() { 711World.prototype.getNDCOrigin = function() {
685 var pt = MathUtils.transformPoint( [0,0,0], this.getCameraMatInverse() ); 712 var pt = MathUtils.transformPoint( [0,0,0], this.getCameraMatInverse() );
@@ -973,7 +1000,6 @@ World.prototype.importJSON = function (jObj)
973 // start RDGE 1000 // start RDGE
974 rdgeStarted = true; 1001 rdgeStarted = true;
975 var id = this._canvas.getAttribute( "data-RDGE-id" ); 1002 var id = this._canvas.getAttribute( "data-RDGE-id" );
976 this._canvas.rdgeid = id;
977 RDGE.globals.engine.registerCanvas(this._canvas, this); 1003 RDGE.globals.engine.registerCanvas(this._canvas, this);
978 RDGE.RDGEStart(this._canvas); 1004 RDGE.RDGEStart(this._canvas);
979 this._canvas.task.stop() 1005 this._canvas.task.stop()