From 7283884c39df537694b21419a3ea9e3ca7793b4b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 23 Feb 2012 13:43:35 -0800 Subject: switch html document - re-initialize draw-utils and snap-manager on opening a document and while switching documents Signed-off-by: Ananya Sen --- js/helper-classes/3D/draw-utils.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'js/helper-classes/3D/draw-utils.js') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index c07391db..37fc1cfc 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -115,6 +115,26 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } }, + initializeFromDocument:{ + value:function(){ + var documentRootChildren = null, i; + //initialize with current document + this._eltArray = []; + this._planesArray = []; + this.setDrawingSurfaceElement(this.application.ninja.stage.canvas); + this.setSourceSpaceElement( this.application.ninja.stage.stageDeps.currentStage ); + this.setWorkingPlane( Vector.create( [0,0,1,0] ) ); + + //Loop through all the top-level children of the current document and call drawUtils.addElement on them + if(this.application.ninja.currentDocument.documentRoot.hasChildNodes()){ + documentRootChildren = this.application.ninja.currentDocument.documentRoot.childNodes; + for(i=0;i --- js/helper-classes/3D/draw-utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/helper-classes/3D/draw-utils.js') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 37fc1cfc..85870097 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -126,8 +126,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { this.setWorkingPlane( Vector.create( [0,0,1,0] ) ); //Loop through all the top-level children of the current document and call drawUtils.addElement on them - if(this.application.ninja.currentDocument.documentRoot.hasChildNodes()){ - documentRootChildren = this.application.ninja.currentDocument.documentRoot.childNodes; + if(this.application.ninja.currentDocument._liveNodeList.length > 0){ + documentRootChildren = this.application.ninja.currentDocument._liveNodeList; for(i=0;i