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.js76
-rwxr-xr-xjs/helper-classes/RDGE/rdge-compiled.js12
-rwxr-xr-xjs/helper-classes/RDGE/src/core/script/runtime.js6
3 files changed, 76 insertions, 18 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index bd47ffc3..9c4f31b7 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -73,6 +73,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
73 73
74 // Properties that require element planes to be updated 74 // Properties that require element planes to be updated
75 _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height"], writable: false }, 75 _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height"], writable: false },
76 _recalculateScrollOffsets : { value: false },
76 77
77 /////////////////////////////////////////////////////////////////////// 78 ///////////////////////////////////////////////////////////////////////
78 // Property accessors 79 // Property accessors
@@ -117,7 +118,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
117 }, 118 },
118 119
119 initializeFromDocument:{ 120 initializeFromDocument:{
120 value:function(adjustScrollOffsets){ 121 value:function(adjustScrollOffsets, useStageValues){
121 var i, 122 var i,
122 documentRootChildren = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true), 123 documentRootChildren = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true),
123 stage = this.application.ninja.stage, 124 stage = this.application.ninja.stage,
@@ -141,6 +142,13 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
141 t, 142 t,
142 plane, 143 plane,
143 elt; 144 elt;
145 if(useStageValues) {
146 initL = stage.userPaddingLeft;
147 initT = stage.userPaddingTop;
148 minLeft = stage.templateLeft;
149 minTop = stage.templateTop;
150 this._recalculateScrollOffsets = false;
151 }
144 for(i=0; i<len; i++) { 152 for(i=0; i<len; i++) {
145 elt = documentRootChildren[i]; 153 elt = documentRootChildren[i];
146 plane = this.addElement(elt); 154 plane = this.addElement(elt);
@@ -149,17 +157,19 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
149 t = plane._rect.m_top - docTop; 157 t = plane._rect.m_top - docTop;
150 if(l < minLeft) { 158 if(l < minLeft) {
151 minLeft = l; 159 minLeft = l;
160 stage.minLeftElement = elt;
152 } 161 }
153 if(t < minTop) { 162 if(t < minTop) {
154 minTop = t; 163 minTop = t;
164 stage.minTopElement = elt;
155 } 165 }
156 } 166 }
157 } 167 }
158 if(minLeft !== initL) { 168 if(minLeft !== initL) {
159 stage.userPaddingLeft = minLeft; 169 stage.userPaddingLeft = (minLeft < 0) ? minLeft : 0;
160 } 170 }
161 if(minTop !== initT) { 171 if(minTop !== initT) {
162 stage.userPaddingTop = minTop; 172 stage.userPaddingTop = (minTop < 0) ? minTop : 0;
163 } 173 }
164 } 174 }
165 } 175 }
@@ -274,9 +284,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
274 t, 284 t,
275 plane, 285 plane,
276 changed = false, 286 changed = false,
287 elt,
277 adjustStagePadding = !isChanging || (event.detail.data.prop !== "matrix"); 288 adjustStagePadding = !isChanging || (event.detail.data.prop !== "matrix");
278 for(var i=0; i < len; i++) { 289 for(var i=0; i < len; i++) {
279 plane = els[i].elementModel.props3D.elementPlane; 290 elt = els[i];
291 plane = elt.elementModel.props3D.elementPlane;
280 if(plane) { 292 if(plane) {
281 plane.init(); 293 plane.init();
282 if(adjustStagePadding) { 294 if(adjustStagePadding) {
@@ -284,22 +296,34 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
284 t = plane._rect.m_top - docTop; 296 t = plane._rect.m_top - docTop;
285 if(l < minLeft) { 297 if(l < minLeft) {
286 minLeft = l; 298 minLeft = l;
299 stage.minLeftElement = elt;
300 } else if((elt === stage.minLeftElement) && (l > minLeft)) {
301 this._recalculateScrollOffsets = true;
287 } 302 }
303
288 if(t < minTop) { 304 if(t < minTop) {
289 minTop = t; 305 minTop = t;
306 stage.minTopElement = elt;
307 } else if((elt === stage.minTopElement) && (t > minTop)) {
308 this._recalculateScrollOffsets = true;
290 } 309 }
291 } 310 }
292 } 311 }
293 } 312 }
294 313
295 if(adjustStagePadding) { 314 if(adjustStagePadding) {
296 if(minLeft !== stage.userPaddingLeft) { 315 if(this._recalculateScrollOffsets && !isChanging) {
297 stage.userPaddingLeft = minLeft; 316 this.initializeFromDocument(true, true);
298 changed = true;
299 }
300 if(minTop !== stage.userPaddingTop) {
301 stage.userPaddingTop = minTop;
302 changed = true; 317 changed = true;
318 } else {
319 if(minLeft !== stage.userPaddingLeft) {
320 stage.userPaddingLeft = minLeft;
321 changed = true;
322 }
323 if(minTop !== stage.userPaddingTop) {
324 stage.userPaddingTop = minTop;
325 changed = true;
326 }
303 } 327 }
304 } 328 }
305 329
@@ -1185,8 +1209,38 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
1185 var context = this.application.ninja.stage.gridContext; 1209 var context = this.application.ninja.stage.gridContext;
1186 var stage = this.application.ninja.stage; 1210 var stage = this.application.ninja.stage;
1187 var stageRoot = this.application.ninja.currentDocument.model.documentRoot; 1211 var stageRoot = this.application.ninja.currentDocument.model.documentRoot;
1188 var bounds3D = this.viewUtils.getElementBoundsInGlobal(stageRoot);
1189 1212
1213 // draw an outline around the template body if stage has any transforms
1214 if(stage.currentDocument.model.views.design._template && !MathUtils.isIdentityMatrix(this.viewUtils.getMatrixFromElement(stageRoot))) {
1215 var saveContext = this.getDrawingSurfaceElement();
1216 this.setDrawingSurfaceElement(this.application.ninja.stage.gridCanvas);
1217
1218 var stagePt = MathUtils.getPointOnPlane([0,0,1,0]);
1219 var stageMat = this.getPlaneToWorldMatrix([0,0,1], stagePt);
1220 var width = this.snapManager.getStageWidth(),
1221 height = this.snapManager.getStageHeight(),
1222 pt0 = [0, 0, 0],
1223 pt1 = [0, height, 0],
1224 delta = [width, 0, 0];
1225
1226 this._gridLineArray.length = 0;
1227 this.drawGridLines(pt0, pt1, delta, stageMat, 2);
1228
1229 pt0 = [0, 0, 0];
1230 pt1 = [width, 0, 0];
1231 delta = [0, height, 0];
1232 this.drawGridLines(pt0, pt1, delta, stageMat, 2);
1233
1234 this._lineColor = "red";
1235 for (var i = 0; i < 4; i++) {
1236 this.drawIntersectedLine(this._gridLineArray[i], this._drawingContext);
1237 }
1238
1239 this.setDrawingSurfaceElement(saveContext);
1240 }
1241
1242 // draw reference lines across origin
1243 var bounds3D = this.viewUtils.getElementBoundsInGlobal(stageRoot);
1190 var l = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [0, 0, 0], [0, stage.canvas.height, 0], 0.1); 1244 var l = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [0, 0, 0], [0, stage.canvas.height, 0], 0.1);
1191 if(!l) return; 1245 if(!l) return;
1192 var r = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [stage.canvas.width, 0, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1); 1246 var r = MathUtils.segSegIntersection2D(bounds3D[0], bounds3D[3], [stage.canvas.width, 0, 0], [stage.canvas.width, stage.canvas.height, 0], 0.1);
diff --git a/js/helper-classes/RDGE/rdge-compiled.js b/js/helper-classes/RDGE/rdge-compiled.js
index 0bbcb05b..53a99c35 100755
--- a/js/helper-classes/RDGE/rdge-compiled.js
+++ b/js/helper-classes/RDGE/rdge-compiled.js
@@ -248,13 +248,13 @@ RDGE.SceneGraph.prototype.insertAbove=function(a,b){RDGE.verifyTransformNode(a);
248RDGE.SceneGraph.prototype._TraverseDFHelper=function(a,b,c){if("undefined"!=b.children){var d=[];for(d.push({node:b,parent:null});0<d.length;){c=d.pop();b=c.node;c=c.parent;if(void 0!==b.transformNode&&(b=b.transformNode,!1===a.process(b,c)))continue;if(void 0!==b.children)for(c=0;c<b.children.length;++c)d.push({node:b.children[c],parent:b})}}}; 248RDGE.SceneGraph.prototype._TraverseDFHelper=function(a,b,c){if("undefined"!=b.children){var d=[];for(d.push({node:b,parent:null});0<d.length;){c=d.pop();b=c.node;c=c.parent;if(void 0!==b.transformNode&&(b=b.transformNode,!1===a.process(b,c)))continue;if(void 0!==b.children)for(c=0;c<b.children.length;++c)d.push({node:b.children[c],parent:b})}}};
249RDGE.SceneGraph.prototype._TraverseDFPostOrderHelper=function(a,b,c){if("undefined"!=b.children){var d=[];d.push({node:b,parent:null});for(b=d.length;0<b;){for(var b=d.length,c=g.children[b-1],c=void 0==c.children?0:c.children.length,f=0;f<c;++f)d.push({node:g.children[f],parent:g});if(!(0<c)){var c=d.pop(),g=c.node,c=c.parent;void 0!==g.transformNode&&(g=g.transformNode,a.process(g,c))}}}}; 249RDGE.SceneGraph.prototype._TraverseDFPostOrderHelper=function(a,b,c){if("undefined"!=b.children){var d=[];d.push({node:b,parent:null});for(b=d.length;0<b;){for(var b=d.length,c=g.children[b-1],c=void 0==c.children?0:c.children.length,f=0;f<c;++f)d.push({node:g.children[f],parent:g});if(!(0<c)){var c=d.pop(),g=c.node,c=c.parent;void 0!==g.transformNode&&(g=g.transformNode,a.process(g,c))}}}};
250RDGE.SceneGraph.prototype.BuildBVHHelper=function(a){if("undefined"!=a.children){a.bbox_world?a.bbox_world.reset():a.bbox_world=new RDGE.box;void 0==a.local&&(a.local=RDGE.mat4.identity());var b=[],c=0;a.id="root";b.push({node:a,xfrm:RDGE.mat4.identity(),parent:null,visited:!1});for(var a=b.length,d=0;0<a;){var a=b.length,d=a-1,f=void 0==b[d].node.transformNode?b[d].node:b[d].node.transformNode,g=b[d].xfrm,h=b[d].parent,d=b[d].visited;void 0==f.id&&(f.id="id"+c);if(!d){if(void 0!==f.local&&(f.bbox_world? 250RDGE.SceneGraph.prototype.BuildBVHHelper=function(a){if("undefined"!=a.children){a.bbox_world?a.bbox_world.reset():a.bbox_world=new RDGE.box;void 0==a.local&&(a.local=RDGE.mat4.identity());var b=[],c=0;a.id="root";b.push({node:a,xfrm:RDGE.mat4.identity(),parent:null,visited:!1});for(var a=b.length,d=0;0<a;){var a=b.length,d=a-1,f=void 0==b[d].node.transformNode?b[d].node:b[d].node.transformNode,g=b[d].xfrm,h=b[d].parent,d=b[d].visited;void 0==f.id&&(f.id="id"+c);if(!d){if(void 0!==f.local&&(f.bbox_world?
251f.bbox_world.reset():f.bbox_world=new RDGE.box,d=this.GetBBoxForNode(f),f.world=RDGE.mat4.mul(f.local,g),d&&(f.bbox_world=d.transform(f.world)),!d||!d.isValid()))g=new RDGE.box,g.set(0,0),f.bbox_world=g;g=void 0==f.children?0:f.children.length;for(d=0;d<g;++d)b.push({node:f.children[d],xfrm:f.world,parent:f,visited:!1});c++;if(0<g)continue}h&&h.bbox_world&&h.bbox_world.isValid()&&f.bbox_world&&f.bbox_world.isValid()&&h.bbox_world.addBox(f.bbox_world);b.pop();a=b.length;if(0<a&&(void 0==b[a-1].node.transformNode? 251f.bbox_world.reset():f.bbox_world=new RDGE.box,d=this.GetBBoxForNode(f),f.world=RDGE.mat4.mul(f.local,g),d&&(f.bbox_world=d.transform(f.world)),!d||!d.isValid()))g=new RDGE.box,g.set(0,0),f.bbox_world=g;g=void 0==f.children?0:f.children.length;for(d=0;d<g;++d)b.push({node:f.children[d],xfrm:f.world,parent:f,visited:!1});c++;if(0<g)continue}h&&(h.bbox_world&&h.bbox_world.isValid()&&f.bbox_world&&f.bbox_world.isValid())&&h.bbox_world.addBox(f.bbox_world);b.pop();a=b.length;if(0<a&&(void 0==b[a-1].node.transformNode?
252b[a-1].node:b[a-1].node.transformNode).id==h.id)b[a-1].visited=!0}}};RDGE.SceneGraph.prototype._TraverseBFHelper=function(a,b){if("undefined"!=b.children){var c=[];for(c.push({node:b,parent:null});0<c.length;){var d=c.shift(),f=d.node,d=d.parent;void 0!==f.transformNode&&(f=f.transformNode,a.process(f,d));if(void 0!==f.children)for(d=0;d<f.children.length;++d)c.push({node:f.children[d],parent:f})}}}; 252b[a-1].node:b[a-1].node.transformNode).id==h.id)b[a-1].visited=!0}}};RDGE.SceneGraph.prototype._TraverseBFHelper=function(a,b){if("undefined"!=b.children){var c=[];for(c.push({node:b,parent:null});0<c.length;){var d=c.shift(),f=d.node,d=d.parent;void 0!==f.transformNode&&(f=f.transformNode,a.process(f,d));if(void 0!==f.children)for(d=0;d<f.children.length;++d)c.push({node:f.children[d],parent:f})}}};
253RDGE.SceneGraph.prototype.update=function(a){var b=RDGE.globals.engine.getContext().renderer;RDGE.globals.engine.getContext().debug.mat4CallCount=0;for(var c=this.animstack.length-1;0<=c;)this.animstack[c].step(a),--c;this.BuildBVHHelper(this.scene);RDGE.g_particleSystemManager.update(a);a=b.cameraManager().getActiveCamera();void 0!==a&&null!=a&&null!=a.controller&&void 0!==a.controller.world&&a.setWorld(a.controller.world);this.tick++}; 253RDGE.SceneGraph.prototype.update=function(a){var b=RDGE.globals.engine.getContext().renderer;RDGE.globals.engine.getContext().debug.mat4CallCount=0;for(var c=this.animstack.length-1;0<=c;)this.animstack[c].step(a),--c;this.BuildBVHHelper(this.scene);RDGE.g_particleSystemManager.update(a);a=b.cameraManager().getActiveCamera();void 0!==a&&(null!=a&&null!=a.controller&&void 0!==a.controller.world)&&a.setWorld(a.controller.world);this.tick++};
254RDGE.SceneGraph.prototype.render=function(a,b){if(0!=this.scene.children.length){var c=RDGE.globals.engine.getContext().renderer;RDGE.rdgeGlobalParameters.u_shadowLightFarZ.set([this.mainLight.zFar()]);this.renderList=this._RenderDFHelper(c,a,this.scene,b);this.shadowsEnabled&&(this.Traverse(this.shadowCuller,!0),this.shadowRenderList=this.shadowCuller.result);this.renderGraph.render(this);RDGE.g_particleSystemManager.render()}}; 254RDGE.SceneGraph.prototype.render=function(a,b){if(0!=this.scene.children.length){var c=RDGE.globals.engine.getContext().renderer;RDGE.rdgeGlobalParameters.u_shadowLightFarZ.set([this.mainLight.zFar()]);this.renderList=this._RenderDFHelper(c,a,this.scene,b);this.shadowsEnabled&&(this.Traverse(this.shadowCuller,!0),this.shadowRenderList=this.shadowCuller.result);this.renderGraph.render(this);RDGE.g_particleSystemManager.render()}};
255RDGE.SceneGraph.prototype.GetBBoxForNode=function(a){var b=null;if(a.materialNode&&a.materialNode.meshNode){var c=null,c=RDGE.globals.meshMan.getModelByName(a.materialNode.meshNode.mesh.name);null!=c&&(b=c.bbox)}return b}; 255RDGE.SceneGraph.prototype.GetBBoxForNode=function(a){var b=null;if(a.materialNode&&a.materialNode.meshNode){var c=null,c=RDGE.globals.meshMan.getModelByName(a.materialNode.meshNode.mesh.name);null!=c&&(b=c.bbox)}return b};
256RDGE.SceneGraph.prototype._RenderDFHelper=function(a,b,c){renderList=[];renderList[this.bckTypes.BACKGROUND]=[];renderList[this.bckTypes.OPAQUE]=[];renderList[this.bckTypes.TRANSPARENT]=[];renderList[this.bckTypes.ADDITIVE]=[];renderList[this.bckTypes.TRANSLUCENT]=[];renderList[this.bckTypes.FOREGROUND]=[];if("undefined"!=c.children){b=[];b.push({node:c,curCtx:RDGE.globals.engine.defaultContext});for(a=a.cameraManager().getActiveCamera();0<b.length;){var d=b.pop(),c=d.node,f=new RDGE.RenderContext; 256RDGE.SceneGraph.prototype._RenderDFHelper=function(a,b,c){renderList=[];renderList[this.bckTypes.BACKGROUND]=[];renderList[this.bckTypes.OPAQUE]=[];renderList[this.bckTypes.TRANSPARENT]=[];renderList[this.bckType