aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js4
-rwxr-xr-xjs/helper-classes/3D/snap-manager.js23
-rwxr-xr-xjs/helper-classes/3D/vec-utils.js2
-rwxr-xr-xjs/helper-classes/3D/view-utils.js13
-rwxr-xr-xjs/helper-classes/RDGE/rdge-compiled.js6
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/engine.js7
6 files changed, 40 insertions, 15 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index 1c00f7ea..d6334e6c 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -139,8 +139,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
139 handleCloseDocument:{ 139 handleCloseDocument:{
140 value: function() { 140 value: function() {
141 if(this.application.ninja.documentController._documents.length === 0){ 141 if(this.application.ninja.documentController._documents.length === 0){
142 this._eltArray = null; 142 this._eltArray.length = 0;
143 this._planesArray = null; 143 this._planesArray.length = 0;
144 } 144 }
145 } 145 }
146 }, 146 },
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js
index 1caacd00..5b467b41 100755
--- a/js/helper-classes/3D/snap-manager.js
+++ b/js/helper-classes/3D/snap-manager.js
@@ -471,7 +471,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
471 value: function( plane ) { 471 value: function( plane ) {
472 this._elementCache = new Array; 472 this._elementCache = new Array;
473 473
474 var stage = this.getStage(); 474// var stage = this.getStage();
475 var stage = this.application.ninja.currentSelectedContainer || this.getStage();
475 this.hLoadElementCache( stage, plane, 0 ); 476 this.hLoadElementCache( stage, plane, 0 );
476 this._isCacheInvalid = false; 477 this._isCacheInvalid = false;
477 478
@@ -570,6 +571,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
570 571
571 hLoadElementCache : { 572 hLoadElementCache : {
572 value: function( elt, plane, depth ) { 573 value: function( elt, plane, depth ) {
574 if(depth > 1)
575 {
576 return;
577 }
578
573 if (depth > 0) 579 if (depth > 0)
574 { 580 {
575 // check if the element is on the specified plane 581 // check if the element is on the specified plane
@@ -590,8 +596,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
590 elt.elementModel.isIn2DSnapCache = false; 596 elt.elementModel.isIn2DSnapCache = false;
591 } 597 }
592 598
593 // TODO - Don't traverse components' children 599 // TODO - Don't traverse svg and components' children
594// if(elt.elementModel && elt.elementModel.isComponent)
595 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG")))) 600 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG"))))
596 { 601 {
597 return; 602 return;
@@ -964,7 +969,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
964 snapToElements : { 969 snapToElements : {
965 value: function( screenPt, hitRecs ) { 970 value: function( screenPt, hitRecs ) {
966 // start at the stage. 971 // start at the stage.
967 var stage = this.getStage(); 972// var stage = this.getStage();
973 var stage = this.application.ninja.currentSelectedContainer || this.getStage();
968 974
969 // the root should be the 'view' canvas, so the first matrix is the camera 975 // the root should be the 'view' canvas, so the first matrix is the camera
970 viewUtils.setViewportObj( stage ); 976 viewUtils.setViewportObj( stage );
@@ -980,6 +986,10 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
980 { 986 {
981 value: function( elt, hitRecs, depth, globalScrPt ) 987 value: function( elt, hitRecs, depth, globalScrPt )
982 { 988 {
989 if(depth > 1)
990 {
991 return;
992 }
983 // hit test the current object 993 // hit test the current object
984 var hit; 994 var hit;
985 if (depth > 0) // don't snap to the root 995 if (depth > 0) // don't snap to the root
@@ -1001,8 +1011,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1001 } 1011 }
1002 } 1012 }
1003 1013
1004 // TODO - Don't traverse components' children 1014 // TODO - Don't traverse svg and components' children
1005// if(elt.elementModel && elt.elementModel.isComponent)
1006 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG")))) 1015 if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG"))))
1007 { 1016 {
1008 return; 1017 return;
@@ -1402,6 +1411,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, {
1402 case glObj.GEOM_TYPE_PATH: 1411 case glObj.GEOM_TYPE_PATH:
1403 // Snapping not implemented for these type, but don't throw an error... 1412 // Snapping not implemented for these type, but don't throw an error...
1404 break; 1413 break;
1414 case glObj.GEOM_TYPE_BRUSH_STROKE:
1415 break; //don't throw error because snapping not yet implemented
1405 case glObj.GEOM_TYPE_CUBIC_BEZIER: 1416 case glObj.GEOM_TYPE_CUBIC_BEZIER:
1406 { 1417 {
1407 var nearVrt = glObj.getNearVertex( eyePt, dir ); 1418 var nearVrt = glObj.getNearVertex( eyePt, dir );
diff --git a/js/helper-classes/3D/vec-utils.js b/js/helper-classes/3D/vec-utils.js
index e6db4a8d..4eacd856 100755
--- a/js/helper-classes/3D/vec-utils.js
+++ b/js/helper-classes/3D/vec-utils.js
@@ -259,6 +259,6 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype,
259 glmat4.rotate(mat, angle, axis); 259 glmat4.rotate(mat, angle, axis);
260 return mat; 260 return mat;
261 } 261 }
262 }, 262 }
263 263
264}); \ No newline at end of file 264}); \ No newline at end of file
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index 5a820fc2..a72b7906 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -1200,10 +1200,19 @@ exports.ViewUtils = Montage.create(Component, {
1200// MISCELLANEOUS 1200// MISCELLANEOUS
1201// event.layerX/Y: var pt = viewUtils.getMousePoint(event); 1201// event.layerX/Y: var pt = viewUtils.getMousePoint(event);
1202 1202
1203 getStageDimension: {
1204 value: function()
1205 {
1206 var width = parseInt(this.application.ninja.stage.documentRoot.elementModel.stageDimension.style.getProperty("width"));
1207 var height= parseInt(this.application.ninja.stage.documentRoot.elementModel.stageDimension.style.getProperty("height"));
1208 return[width,height];
1209 }
1210 },
1211
1203 getStage: { 1212 getStage: {
1204 value: function() 1213 value: function()
1205 { 1214 {
1206 return snapManagerModule.SnapManager.getStage(); 1215 return this.application.ninja.stage.snapManager.getStage();
1207 } 1216 }
1208 }, 1217 },
1209 1218
@@ -1303,7 +1312,7 @@ exports.ViewUtils = Montage.create(Component, {
1303 { 1312 {
1304 value: function() 1313 value: function()
1305 { 1314 {
1306 return this.application.ninjs.stage.canvas; 1315 return this.application.ninja.stage.canvas;
1307 } 1316 }
1308 }, 1317 },
1309 1318
diff --git a/js/helper-classes/RDGE/rdge-compiled.js b/js/helper-classes/RDGE/rdge-compiled.js
index d1040d73..caf58147 100755
--- a/js/helper-classes/RDGE/rdge-compiled.js
+++ b/js/helper-classes/RDGE/rdge-compiled.js
@@ -235,15 +235,15 @@ input.onMouseMove=function(a){for(var b=0,f=input.eventHandlers.length;b<f;){if(
235this.stateTop>0?this.stateTop-1:0;this.stateStack[this.stateTop]&&this.stateStack[this.stateTop].ReInit()};this.PopAll=function(){for(;this.stateStack[this.stateTop]!=null;)this.PopState()};this.tick=function(a){this.stateStack[this.stateTop]!=null&&(this.stateStack[this.stateTop].Update(a),this.stateStack[this.stateTop].Resize(),this.stateStack[this.stateTop].Draw())}};g_enableBenchmarks=!0; 235this.stateTop>0?this.stateTop-1:0;this.stateStack[this.stateTop]&&this.stateStack[this.stateTop].ReInit()};this.PopAll=function(){for(;this.stateStack[this.stateTop]!=null;)this.PopState()};this.tick=function(a){this.stateStack[this.stateTop]!=null&&(this.stateStack[this.stateTop].Update(a),this.stateStack[this.stateTop].Resize(),this.stateStack[this.stateTop].Draw())}};g_enableBenchmarks=!0;
236function Engine(){this._assetPath="assets/";this.sceneMap=[];this.stateTop=void 0;this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.lightManager=this.defaultContext=null;clearColor=[0,0,0,0];panelObjectManager=new objectManager;this.initializeComplete=!1;this.RDGECanvas=null;this.canvasToRendererMap={};this.canvasNameToStateStack={};this.canvasCtxList=[];invalidObj=/([()]|function)/;isValidObj=function(a){return invalidObj.test(a)?(window.console.error("invalid object name passed to RDGE, "+ 236function Engine(){this._assetPath="assets/";this.sceneMap=[];this.stateTop=void 0;this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.lightManager=this.defaultContext=null;clearColor=[0,0,0,0];panelObjectManager=new objectManager;this.initializeComplete=!1;this.RDGECanvas=null;this.canvasToRendererMap={};this.canvasNameToStateStack={};this.canvasCtxList=[];invalidObj=/([()]|function)/;isValidObj=function(a){return invalidObj.test(a)?(window.console.error("invalid object name passed to RDGE, "+
237a+" - looks like a function"),!1):!0};contextDef=function(){this.startUpState=this.ctxStateManager=this.renderer=this.id=null;this.sceneGraphMap=[];this.currentScene=null;this.getScene=function(){return this.sceneGraphMap[this.currentScene]};this.debug={frameCounter:0,mat4CallCount:0}};this.ctxMan=contextManager=new objectManager;contextManager.currentCtx=null;contextManager._addObject=contextManager.addObject;contextManager.contextMap={};contextManager.addObject=function(a){this.contextMap[a.id]= 237a+" - looks like a function"),!1):!0};contextDef=function(){this.startUpState=this.ctxStateManager=this.renderer=this.id=null;this.sceneGraphMap=[];this.currentScene=null;this.getScene=function(){return this.sceneGraphMap[this.currentScene]};this.debug={frameCounter:0,mat4CallCount:0}};this.ctxMan=contextManager=new objectManager;contextManager.currentCtx=null;contextManager._addObject=contextManager.addObject;contextManager.contextMap={};contextManager.addObject=function(a){this.contextMap[a.id]=
238a;return this._addObject(a)};contextManager.start=function(){for(var a=this.objects.length,b=0;b<a;++b)contextManager.currentCtx=this.objects[b],this.objects[b].ctxStateManager.PushState(this.objects[b].startUpState)};contextManager.forEach=function(a){for(var b=this.objects.length,f=0;f<b;++f)a(this.objects[f])};this.getContext=function(a){return a?contextManager.contextMap[a]:contextManager.currentCtx};this.setContext=function(a){contextManager.currentCtx=contextManager.contextMap[a]};this.tickContext= 238a;return this._addObject(a)};contextManager.start=function(){for(var a=this.objects.length,b=0;b<a;++b)contextManager.currentCtx=this.objects[b],this.objects[b].ctxStateManager.PushState(this.objects[b].startUpState)};contextManager.forEach=function(a){for(var b=this.objects.length,f=0;f<b;++f)a(this.objects[f])};this.getContext=function(a){return a?contextManager.contextMap[a]:contextManager.currentCtx};this.clearContext=function(a){contextManager.contextMap[a]=void 0};this.setContext=function(a){contextManager.currentCtx=
239function(a){var b=contextManager.currentCtx;contextManager.currentCtx=contextManager.contextMap[a];this.objects[i].ctxStateManager.tick(dt);contextManager.currentCtx=b};this.remapAssetFolder=function(a){var b=a.indexOf("assets/"),f=a;b>=0&&(f=a.substr(b+7),f=this._assetPath+f);return f}} 239contextManager.contextMap[a]};this.tickContext=function(a){var b=contextManager.currentCtx;contextManager.currentCtx=contextManager.contextMap[a];this.objects[i].ctxStateManager.tick(dt);contextManager.currentCtx=b};this.remapAssetFolder=function(a){var b=a.indexOf("assets/"),f=a;b>=0&&(f=a.substr(b+7),f=this._assetPath+f);return f}}
240Engine.prototype.init=function(a,b,f){this.GlInit(f);globalParamFuncSet=function(a){this.data=a.data;this.type=a.type;this.set=function(a){for(var b=this.data?this.data.length:0,f=0;f<b;++f)this.data[f]=a[f]};this.get=function(){return this.data.length==void 0?this.data:this.data.slice()}};this.lightManager=new LightManager(rdgeGlobalParameters.rdge_lights);for(var g in rdgeGlobalParameters)if(g!="rdge_lights")rdgeGlobalParameters[g]=new globalParamFuncSet(rdgeGlobalParameters[g]);else{var a=rdgeGlobalParameters[g], 240Engine.prototype.init=function(a,b,f){this.GlInit(f);globalParamFuncSet=function(a){this.data=a.data;this.type=a.type;this.set=function(a){for(var b=this.data?this.data.length:0,f=0;f<b;++f)this.data[f]=a[f]};this.get=function(){return this.data.length==void 0?this.data:this.data.slice()}};this.lightManager=new LightManager(rdgeGlobalParameters.rdge_lights);for(var g in rdgeGlobalParameters)if(g!="rdge_lights")rdgeGlobalParameters[g]=new globalParamFuncSet(rdgeGlobalParameters[g]);else{var a=rdgeGlobalParameters[g],
241h;for(h in a)rdgeGlobalParameters[h]=new globalParamFuncSet(a[h])}this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.defaultContext=new RenderContext;this.defaultContext.uniforms=[{name:"u_matAmbient",value:[0.02,0.02,0.02,1]},{name:"u_matDiffuse",value:[1,1,1,1]},{name:"u_matSpecular",value:[1,1,1,1]},{name:"u_matShininess",value:[128]},{name:"u_matEmission",value:[0,0,0,1]}];contextManager.start();this.initializeComplete=!0};Engine.prototype.Shutdown=function(){this.PopAll()}; 241h;for(h in a)rdgeGlobalParameters[h]=new globalParamFuncSet(a[h])}this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.defaultContext=new RenderContext;this.defaultContext.uniforms=[{name:"u_matAmbient",value:[0.02,0.02,0.02,1]},{name:"u_matDiffuse",value:[1,1,1,1]},{name:"u_matSpecular",value:[1,1,1,1]},{name:"u_matShininess",value:[128]},{name:"u_matEmission",value:[0,0,0,1]}];contextManager.start();this.initializeComplete=!0};Engine.prototype.Shutdown=function(){this.PopAll()};
242Engine.prototype.GlInit=function(){for(var a=document.getElementsByTagName("canvas"),b=a.length,f=0;f<b;++f){var g;a[f].getAttribute("rdge")=="true"&&(g=a[f],this.registerCanvas(g))}};Engine.prototype.loadScene=function(a){var b="assets_web/mesh/"+a+".json";contextManager.currentCtx.stateMan.currentState().name=="RunState"&&(contextManager.currentCtx.stateMan.PushState(contextManager.currentCtx.stateMan.RDGEInitState),contextManager.currentCtx.loadScene(b,a))};Engine.prototype.getScene=function(a){return contextManager.currentCtx.sceneGraphMap[a]}; 242Engine.prototype.GlInit=function(){for(var a=document.getElementsByTagName("canvas"),b=a.length,f=0;f<b;++f){var g;a[f].getAttribute("rdge")=="true"&&(g=a[f],this.registerCanvas(g))}};Engine.prototype.loadScene=function(a){var b="assets_web/mesh/"+a+".json";contextManager.currentCtx.stateMan.currentState().name=="RunState"&&(contextManager.currentCtx.stateMan.PushState(contextManager.currentCtx.stateMan.RDGEInitState),contextManager.currentCtx.loadScene(b,a))};Engine.prototype.getScene=function(a){return contextManager.currentCtx.sceneGraphMap[a]};
243Engine.prototype.AddScene=function(a,b){contextManager.currentCtx.sceneGraphMap[a]=b;contextManager.currentCtx.currentScene=a};Engine.prototype.createRDGEPanel=function(){var a=new utilDbgPanel("tools","WebGL Viewer Settings");a.appendLabel("","");return panelObjectManager.addObject(a)};Engine.prototype.getRDGEPanel=function(a){return panelObjectManager.handleToObject(a)}; 243Engine.prototype.AddScene=function(a,b){contextManager.currentCtx.sceneGraphMap[a]=b;contextManager.currentCtx.currentScene=a};Engine.prototype.createRDGEPanel=function(){var a=new utilDbgPanel("tools","WebGL Viewer Settings");a.appendLabel("","");return panelObjectManager.addObject(a)};Engine.prototype.getRDGEPanel=function(a){return panelObjectManager.handleToObject(a)};
244Engine.prototype.registerCanvas=function(a,b){if(!a||!this.getContext(a.rdgeid)){a.renderer=new _renderer(a);this.canvasToRendererMap[a.rdgeid]=a;a.renderer.id=a.rdgeid;var f=new stateManager,g=new contextDef;g.id=a.rdgeid;g.renderer=a.renderer;g.ctxStateManager=f;g.fpsTracker=new fpsTracker(a.rdgeid);g.renderer.mvMatrix=mat4.identity();g.renderer.invMvMatrix=mat4.identity();g.renderer.projectionMatrix=mat4.identity();g.renderer.normalMatrix=mat4.identity();a.rdgeCtxHandle=contextManager.addObject(g); 244Engine.prototype.registerCanvas=function(a,b){if(!a||!this.getContext(a.rdgeid)){a.renderer=new _renderer(a);this.canvasToRendererMap[a.rdgeid]=a;a.renderer.id=a.rdgeid;var f=new stateManager,g=new contextDef;g.id=a.rdgeid;g.renderer=a.renderer;g.ctxStateManager=f;g.fpsTracker=new fpsTracker(a.rdgeid);g.renderer.mvMatrix=mat4.identity();g.renderer.invMvMatrix=mat4.identity();g.renderer.projectionMatrix=mat4.identity();g.renderer.normalMatrix=mat4.identity();a.rdgeCtxHandle=contextManager.addObject(g);
245contextManager.currentCtx=g;var h;if(b)h=b;else{var l=a.getAttribute("rdgerun");if(l){if(!isValidObj(l))return;try{h=new (eval(l))}catch(n){window.console.error('The provided RDGE state object "'+l+'" is not defined')}}else h={},validateUserState(h)}l=a.getAttribute("rdgescene");f.RDGEInitState=new LoadState(h,g);f.RDGERunState=new RunState(h,g);validateUserState(h);l?(f.RDGEInitState.sceneName=l,f.PushState(f.RDGERunState,"noInit"),g.startUpState=f.RDGEInitState):g.startUpState=f.RDGERunState;this.initializeComplete&& 245contextManager.currentCtx=g;var h;if(b)h=b;else{var l=a.getAttribute("rdgerun");if(l){if(!isValidObj(l))return;try{h=new (eval(l))}catch(n){window.console.error('The provided RDGE state object "'+l+'" is not defined')}}else h={},validateUserState(h)}l=a.getAttribute("rdgescene");f.RDGEInitState=new LoadState(h,g);f.RDGERunState=new RunState(h,g);validateUserState(h);l?(f.RDGEInitState.sceneName=l,f.PushState(f.RDGERunState,"noInit"),g.startUpState=f.RDGEInitState):g.startUpState=f.RDGERunState;this.initializeComplete&&
246g.ctxStateManager.PushState(g.startUpState)}};Engine.prototype.unregisterCanvas=function(a){stat.closePage(a.rdgeid+"_fps");contextManager.removeObject(a.rdgeCtxHandle)};Engine.prototype.getCanvas=function(a){return this.canvasToRendererMap[a]};nodeIdGen={counter:0};nodeIdGen.getId=function(){return"gen_"+nodeIdGen.counter++};function createTransformNode(a){node={name:a};node.transformNodeTemplate=new transformNodeTemplate(node);return node}function createMaterialNode(a){node={name:a};node.materialNodeTemplate=new materialNodeTemplate(node);return node} 246g.ctxStateManager.PushState(g.startUpState)}};Engine.prototype.unregisterCanvas=function(a){stat.closePage(a.rdgeid+"_fps");contextManager.removeObject(a.rdgeCtxHandle);this.clearContext(a.rdgeid)};Engine.prototype.getCanvas=function(a){return this.can