From 2815adfd7c19b3dff89dc3e1bda9af8d30dca8d6 Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Tue, 6 Mar 2012 11:31:26 -0800 Subject: Timeline Fix for layer/element selection Signed-off-by: Jonathan Duran --- js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 6 +++--- js/panels/Timeline/Tween.reel/Tween.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 93fd170e..91277a63 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -494,7 +494,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { var ptrParent = nj.queryParentSelector(event.target, ".container-layer"); if (ptrParent !== false) { var myIndex = this.getActiveLayerIndex(); - this.selectLayer(myIndex); + this.selectLayer(myIndex, true); } } }, @@ -978,7 +978,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { }, selectLayer:{ - value:function (layerIndex) { + value:function (layerIndex, userSelection) { var i = 0; var arrLayersLength = this.arrLayers.length; @@ -996,7 +996,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.layerRepetition.selectedIndexes = [layerIndex]; this.trackRepetition.selectedIndexes = [layerIndex]; this.currentLayerSelected = this.arrLayers[layerIndex]; - if(!this._openDoc){ + if(userSelection){ if(this._captureSelection){ if(this.currentLayerSelected.elementsList.length >= 1){ this.application.ninja.selectionController.selectElements(this.currentLayerSelected.elementsList); diff --git a/js/panels/Timeline/Tween.reel/Tween.js b/js/panels/Timeline/Tween.reel/Tween.js index 3a195f47..6ff38bef 100644 --- a/js/panels/Timeline/Tween.reel/Tween.js +++ b/js/panels/Timeline/Tween.reel/Tween.js @@ -175,7 +175,7 @@ var Tween = exports.Tween = Montage.create(Component, { // select the containing layer var selectIndex = this.application.ninja.timeline.getLayerIndexByID(this.parentComponent.parentComponent.trackID); - this.application.ninja.timeline.selectLayer(selectIndex); + this.application.ninja.timeline.selectLayer(selectIndex, true); // tell timeline to deselect all other tweens and push this one as the currentSelectedTweens in timeline this.application.ninja.timeline.deselectTweens(); -- cgit v1.2.3 From 342fb451bd251358068a0dcb10e9dc218b79a176 Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Tue, 6 Mar 2012 11:38:39 -0800 Subject: Squashed commit of the following: commit 1cd89d4d06e3a8f2c221628b19cf26a2c69f5d3f Author: Jose Antonio Marquez Date: Tue Mar 6 11:24:25 2012 -0800 Fixing WebGL not available bug commit 84332ab81c1b445195f1d9be8bbeae0725c8e758 Author: Valerio Virgillito Date: Tue Mar 6 10:58:25 2012 -0800 Squashed commit of preload-fix into Master - Requiring all the previously pre-loaded files - RDGE, Codemirror and gl-matrix are not included via a script tag. Signed-off-by: Valerio Virgillito commit 13f52cf0c74f53a919fa864f86669e8155f82961 Merge: dced508 abc04f3 Author: Valerio Virgillito Date: Fri Mar 2 15:46:11 2012 -0800 Merge pull request #93 from imix23ways/Timeline Timeline: Critical bug fixes commit dced508bb19a7bcd467ff1b86b5df5bbec4be794 Merge: 0aeb400 cc772ef Author: Valerio Virgillito Date: Fri Mar 2 15:45:35 2012 -0800 Merge pull request #92 from mqg734/WebGLFixes Selection Tool Fixes for elements flying off into space when they overlap commit 0aeb400070762cf01d83cf9f9ee25a5595098b7f Merge: ff0a956 aabb48a Author: Valerio Virgillito Date: Fri Mar 2 14:05:21 2012 -0800 Merge pull request #94 from ericguzman/PresetsPanel Presets Panel - Fix single-click activation, and transition cut-off bug. commit cc772ef3333ed419d269a2bda7aea5b0150a7bd9 Author: Nivesh Rajbhandari Date: Fri Mar 2 11:34:58 2012 -0800 Fixing flying off into space bug for translate tool too. Signed-off-by: Nivesh Rajbhandari commit abc04f3d50311ed1c21067344bc7e448686f8c5c Author: Jonathan Duran Date: Fri Mar 2 11:26:25 2012 -0800 Timeline Fix timing function Signed-off-by: Jonathan Duran commit aabb48a1c8d34bc968f4c6b0ffee4e31c1d5d286 Author: Eric Guzman Date: Fri Mar 2 11:22:44 2012 -0800 Presets Panel - Fix single-click activation, and transition cut-off bug. Use double-click as the activation event for transition presets. Also fixed the bug when applying a style preset before the transition preset, which disabled transitions after the first one. commit f3207f39ea9d8c1c34246217a23d3a689671903d Author: Nivesh Rajbhandari Date: Fri Mar 2 11:21:29 2012 -0800 Don't draw transform handles if the stage is the target element. Signed-off-by: Nivesh Rajbhandari commit 5425be91e7125c22955b4459a62412ff574e49a8 Author: Jonathan Duran Date: Fri Mar 2 11:11:48 2012 -0800 Timeline: Fix for animation iteration count Add default webkit css properties to allow animations with integer iteration counts. Signed-off-by: Jonathan Duran commit 1760bac1da9218315ad1bacdcf3a157495a049e8 Author: Nivesh Rajbhandari Date: Fri Mar 2 10:48:41 2012 -0800 Fix for jumping issue when moving items that have any 3d on them. We can't translate 3d moves into 2d space due to perspective, so we must update the matrix3d values instead of the top-left values if items have 3d. Signed-off-by: Nivesh Rajbhandari commit 2c04935f0ccb1cb7c98371fc10b43155f2d956c4 Author: Nivesh Rajbhandari Date: Thu Mar 1 22:20:06 2012 -0800 Fix for elements flying off into space when moving elements that overlap. This was happening because our hit record's element and the browser's element from point did not match. Signed-off-by: Nivesh Rajbhandari commit 50058746779f714ed9b0287f49e56c9f0d35593e Merge: 500426d ff0a956 Author: Nivesh Rajbhandari Date: Thu Mar 1 21:49:44 2012 -0800 Merge branch 'refs/heads/ninja-internal' into WebGLFixes commit 500426dea0ca95a6b45be8ea8d132cfdb4d2c940 Author: Nivesh Rajbhandari Date: Thu Mar 1 10:11:39 2012 -0800 Fixed logic error when resizing with the top-left transform handles. Signed-off-by: Nivesh Rajbhandari commit 7980d9bde2b43aa5a494ddf6f1db5c4959a57b91 Author: Nivesh Rajbhandari Date: Thu Mar 1 10:04:15 2012 -0800 Re-fixing IKNinja-940 - Can't select objects when in side/top view. Signed-off-by: Nivesh Rajbhandari commit f04cc0146d8f7573628678613a99c270116768e4 Author: Nivesh Rajbhandari Date: Wed Feb 29 16:45:40 2012 -0800 Last-used material (instead of FlatMaterial) is applied to shape when turning on use WebGL checkbox in the PI. Signed-off-by: Nivesh Rajbhandari Signed-off-by: Jonathan Duran --- js/controllers/elements/shapes-controller.js | 17 +- js/document/html-document.js | 6 +- js/helper-classes/3D/ParseUtils.js | 84 -- js/helper-classes/3D/Rectangle.js | 2 +- js/helper-classes/3D/StageLine.js | 8 +- js/helper-classes/3D/draw-utils.js | 2 +- js/helper-classes/3D/element-planes.js | 2 +- js/helper-classes/3D/glUtils.js | 319 ----- js/helper-classes/3D/math-utils.js | 87 +- js/helper-classes/3D/snap-2d-record.js | 2 +- js/helper-classes/3D/snap-manager.js | 78 +- js/helper-classes/3D/vec-utils.js | 16 +- js/helper-classes/3D/view-utils.js | 12 +- js/helper-classes/RDGE/GLAnchorPoint.js | 168 --- js/helper-classes/RDGE/GLBrushStroke.js | 397 ------ js/helper-classes/RDGE/GLCircle.js | 710 ----------- js/helper-classes/RDGE/GLGeomObj.js | 278 ----- js/helper-classes/RDGE/GLLight.js | 30 - js/helper-classes/RDGE/GLLine.js | 507 -------- js/helper-classes/RDGE/GLMaterial.js | 308 ----- js/helper-classes/RDGE/GLPath.js | 232 ---- js/helper-classes/RDGE/GLRectangle.js | 1236 ------------------- js/helper-classes/RDGE/GLSubpath.js | 1185 ------------------ js/helper-classes/RDGE/GLWorld.js | 1014 --------------- .../RDGE/Materials/BumpMetalMaterial.js | 302 ----- js/helper-classes/RDGE/Materials/DeformMaterial.js | 133 -- js/helper-classes/RDGE/Materials/FlatMaterial.js | 161 --- js/helper-classes/RDGE/Materials/FlyMaterial.js | 133 -- js/helper-classes/RDGE/Materials/JuliaMaterial.js | 150 --- .../RDGE/Materials/KeleidoscopeMaterial.js | 149 --- .../RDGE/Materials/LinearGradientMaterial.js | 379 ------ js/helper-classes/RDGE/Materials/MandelMaterial.js | 151 --- js/helper-classes/RDGE/Materials/PlasmaMaterial.js | 134 -- js/helper-classes/RDGE/Materials/PulseMaterial.js | 263 ---- .../RDGE/Materials/RadialBlurMaterial.js | 257 ---- .../RDGE/Materials/RadialGradientMaterial.js | 303 ----- .../RDGE/Materials/ReliefTunnelMaterial.js | 133 -- .../RDGE/Materials/SquareTunnelMaterial.js | 133 -- js/helper-classes/RDGE/Materials/StarMaterial.js | 133 -- js/helper-classes/RDGE/Materials/TaperMaterial.js | 223 ---- js/helper-classes/RDGE/Materials/TunnelMaterial.js | 133 -- js/helper-classes/RDGE/Materials/TwistMaterial.js | 149 --- .../RDGE/Materials/TwistVertMaterial.js | 248 ---- js/helper-classes/RDGE/Materials/UberMaterial.js | 673 ---------- js/helper-classes/RDGE/Materials/WaterMaterial.js | 133 -- .../RDGE/Materials/ZInvertMaterial.js | 133 -- js/helper-classes/RDGE/MaterialsLibrary.js | 230 ---- js/helper-classes/backup-delete/GLAnchorPoint.js | 168 +++ js/helper-classes/backup-delete/GLBrushStroke.js | 397 ++++++ js/helper-classes/backup-delete/GLCircle.js | 710 +++++++++++ js/helper-classes/backup-delete/GLGeomObj.js | 278 +++++ js/helper-classes/backup-delete/GLLight.js | 30 + js/helper-classes/backup-delete/GLLine.js | 507 ++++++++ js/helper-classes/backup-delete/GLMaterial.js | 308 +++++ js/helper-classes/backup-delete/GLPath.js | 232 ++++ js/helper-classes/backup-delete/GLRectangle.js | 1236 +++++++++++++++++++ js/helper-classes/backup-delete/GLSubpath.js | 1185 ++++++++++++++++++ js/helper-classes/backup-delete/GLWorld.js | 1014 +++++++++++++++ .../backup-delete/Materials/BumpMetalMaterial.js | 302 +++++ .../backup-delete/Materials/DeformMaterial.js | 133 ++ .../backup-delete/Materials/FlatMaterial.js | 161 +++ .../backup-delete/Materials/FlyMaterial.js | 133 ++ .../backup-delete/Materials/JuliaMaterial.js | 150 +++ .../Materials/KeleidoscopeMaterial.js | 149 +++ .../Materials/LinearGradientMaterial.js | 379 ++++++ .../backup-delete/Materials/MandelMaterial.js | 151 +++ .../backup-delete/Materials/PlasmaMaterial.js | 134 ++ .../backup-delete/Materials/PulseMaterial.js | 263 ++++ .../backup-delete/Materials/RadialBlurMaterial.js | 257 ++++ .../Materials/RadialGradientMaterial.js | 303 +++++ .../Materials/ReliefTunnelMaterial.js | 133 ++ .../Materials/SquareTunnelMaterial.js | 133 ++ .../backup-delete/Materials/StarMaterial.js | 133 ++ .../backup-delete/Materials/TaperMaterial.js | 223 ++++ .../backup-delete/Materials/TunnelMaterial.js | 133 ++ .../backup-delete/Materials/TwistMaterial.js | 149 +++ .../backup-delete/Materials/TwistVertMaterial.js | 248 ++++ .../backup-delete/Materials/UberMaterial.js | 673 ++++++++++ .../backup-delete/Materials/WaterMaterial.js | 133 ++ .../backup-delete/Materials/ZInvertMaterial.js | 133 ++ .../backup-delete/MaterialsLibrary.js | 230 ++++ js/helper-classes/backup-delete/ParseUtils.js | 84 ++ js/helper-classes/backup-delete/glUtils.js | 319 +++++ js/lib/drawing/world.js | 917 ++++++++++++++ js/lib/geom/anchor-point.js | 242 ++++ js/lib/geom/brush-stroke.js | 482 ++++++++ js/lib/geom/circle.js | 751 ++++++++++++ js/lib/geom/geom-obj.js | 280 +++++ js/lib/geom/line.js | 488 ++++++++ js/lib/geom/rectangle.js | 1165 ++++++++++++++++++ js/lib/geom/shape-primitive.js | 54 + js/lib/geom/sub-path.js | 1288 ++++++++++++++++++++ js/lib/math/matrix.js | 104 ++ js/lib/rdge/materials/bump-metal-material.js | 314 +++++ js/lib/rdge/materials/deform-material.js | 127 ++ js/lib/rdge/materials/flat-material.js | 159 +++ js/lib/rdge/materials/fly-material.js | 119 ++ js/lib/rdge/materials/julia-material.js | 136 +++ js/lib/rdge/materials/keleidoscope-material.js | 144 +++ js/lib/rdge/materials/linear-gradient-material.js | 434 +++++++ js/lib/rdge/materials/mandel-material.js | 147 +++ js/lib/rdge/materials/material-parser.js | 73 ++ js/lib/rdge/materials/material.js | 346 ++++++ js/lib/rdge/materials/plasma-material.js | 132 ++ js/lib/rdge/materials/pulse-material.js | 258 ++++ js/lib/rdge/materials/radial-blur-material.js | 244 ++++ js/lib/rdge/materials/radial-gradient-material.js | 351 ++++++ js/lib/rdge/materials/relief-tunnel-material.js | 122 ++ js/lib/rdge/materials/square-tunnel-material.js | 120 ++ js/lib/rdge/materials/star-material.js | 124 ++ js/lib/rdge/materials/taper-material.js | 223 ++++ js/lib/rdge/materials/tunnel-material.js | 125 ++ js/lib/rdge/materials/twist-material.js | 139 +++ js/lib/rdge/materials/twist-vert-material.js | 248 ++++ js/lib/rdge/materials/uber-material.js | 614 ++++++++++ js/lib/rdge/materials/water-material.js | 126 ++ js/lib/rdge/materials/z-invert-material.js | 125 ++ js/mediators/io-mediator.js | 4 +- js/models/materials-model.js | 225 ++++ js/models/properties-3d.js | 24 +- js/ninja.reel/ninja.html | 11 +- js/ninja.reel/ninja.js | 30 +- .../materials-popup.reel/materials-popup.js | 3 +- .../presets/style-presets.reel/style-presets.js | 4 +- .../transitions-presets.html | 1 + js/preloader/Preloader.js | 104 +- js/stage/stage-deps.js | 4 +- js/stage/tool-handle.js | 60 +- js/tools/BrushTool.js | 6 +- js/tools/LineTool.js | 14 +- js/tools/OvalTool.js | 25 +- js/tools/PenTool.js | 25 +- js/tools/RectTool.js | 24 +- js/tools/SelectionTool.js | 282 ++++- js/tools/ShapeTool.js | 4 +- js/tools/TranslateObject3DTool.js | 7 + js/tools/drawing-tool-base.js | 18 +- js/tools/modifier-tool-base.js | 7 + 138 files changed, 22802 insertions(+), 11641 deletions(-) delete mode 100755 js/helper-classes/3D/ParseUtils.js delete mode 100755 js/helper-classes/3D/glUtils.js delete mode 100755 js/helper-classes/RDGE/GLAnchorPoint.js delete mode 100755 js/helper-classes/RDGE/GLBrushStroke.js delete mode 100755 js/helper-classes/RDGE/GLCircle.js delete mode 100755 js/helper-classes/RDGE/GLGeomObj.js delete mode 100755 js/helper-classes/RDGE/GLLight.js delete mode 100755 js/helper-classes/RDGE/GLLine.js delete mode 100755 js/helper-classes/RDGE/GLMaterial.js delete mode 100755 js/helper-classes/RDGE/GLPath.js delete mode 100755 js/helper-classes/RDGE/GLRectangle.js delete mode 100755 js/helper-classes/RDGE/GLSubpath.js delete mode 100755 js/helper-classes/RDGE/GLWorld.js delete mode 100755 js/helper-classes/RDGE/Materials/BumpMetalMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/DeformMaterial.js delete mode 100755 js/helper-classes/RDGE/Materials/FlatMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/FlyMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/JuliaMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js delete mode 100755 js/helper-classes/RDGE/Materials/LinearGradientMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/MandelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/PlasmaMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/PulseMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/RadialBlurMaterial.js delete mode 100755 js/helper-classes/RDGE/Materials/RadialGradientMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/ReliefTunnelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/SquareTunnelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/StarMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TaperMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TunnelMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TwistMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/TwistVertMaterial.js delete mode 100755 js/helper-classes/RDGE/Materials/UberMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/WaterMaterial.js delete mode 100644 js/helper-classes/RDGE/Materials/ZInvertMaterial.js delete mode 100755 js/helper-classes/RDGE/MaterialsLibrary.js create mode 100755 js/helper-classes/backup-delete/GLAnchorPoint.js create mode 100755 js/helper-classes/backup-delete/GLBrushStroke.js create mode 100755 js/helper-classes/backup-delete/GLCircle.js create mode 100755 js/helper-classes/backup-delete/GLGeomObj.js create mode 100755 js/helper-classes/backup-delete/GLLight.js create mode 100755 js/helper-classes/backup-delete/GLLine.js create mode 100755 js/helper-classes/backup-delete/GLMaterial.js create mode 100755 js/helper-classes/backup-delete/GLPath.js create mode 100755 js/helper-classes/backup-delete/GLRectangle.js create mode 100755 js/helper-classes/backup-delete/GLSubpath.js create mode 100755 js/helper-classes/backup-delete/GLWorld.js create mode 100755 js/helper-classes/backup-delete/Materials/BumpMetalMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/DeformMaterial.js create mode 100755 js/helper-classes/backup-delete/Materials/FlatMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/FlyMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/JuliaMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/KeleidoscopeMaterial.js create mode 100755 js/helper-classes/backup-delete/Materials/LinearGradientMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/MandelMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/PlasmaMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/PulseMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/RadialBlurMaterial.js create mode 100755 js/helper-classes/backup-delete/Materials/RadialGradientMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/ReliefTunnelMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/SquareTunnelMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/StarMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/TaperMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/TunnelMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/TwistMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/TwistVertMaterial.js create mode 100755 js/helper-classes/backup-delete/Materials/UberMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/WaterMaterial.js create mode 100644 js/helper-classes/backup-delete/Materials/ZInvertMaterial.js create mode 100755 js/helper-classes/backup-delete/MaterialsLibrary.js create mode 100755 js/helper-classes/backup-delete/ParseUtils.js create mode 100755 js/helper-classes/backup-delete/glUtils.js create mode 100755 js/lib/drawing/world.js create mode 100755 js/lib/geom/anchor-point.js create mode 100755 js/lib/geom/brush-stroke.js create mode 100755 js/lib/geom/circle.js create mode 100755 js/lib/geom/geom-obj.js create mode 100755 js/lib/geom/line.js create mode 100755 js/lib/geom/rectangle.js create mode 100644 js/lib/geom/shape-primitive.js create mode 100755 js/lib/geom/sub-path.js create mode 100755 js/lib/math/matrix.js create mode 100755 js/lib/rdge/materials/bump-metal-material.js create mode 100644 js/lib/rdge/materials/deform-material.js create mode 100755 js/lib/rdge/materials/flat-material.js create mode 100644 js/lib/rdge/materials/fly-material.js create mode 100644 js/lib/rdge/materials/julia-material.js create mode 100644 js/lib/rdge/materials/keleidoscope-material.js create mode 100755 js/lib/rdge/materials/linear-gradient-material.js create mode 100644 js/lib/rdge/materials/mandel-material.js create mode 100755 js/lib/rdge/materials/material-parser.js create mode 100755 js/lib/rdge/materials/material.js create mode 100644 js/lib/rdge/materials/plasma-material.js create mode 100644 js/lib/rdge/materials/pulse-material.js create mode 100644 js/lib/rdge/materials/radial-blur-material.js create mode 100755 js/lib/rdge/materials/radial-gradient-material.js create mode 100644 js/lib/rdge/materials/relief-tunnel-material.js create mode 100644 js/lib/rdge/materials/square-tunnel-material.js create mode 100644 js/lib/rdge/materials/star-material.js create mode 100644 js/lib/rdge/materials/taper-material.js create mode 100644 js/lib/rdge/materials/tunnel-material.js create mode 100644 js/lib/rdge/materials/twist-material.js create mode 100644 js/lib/rdge/materials/twist-vert-material.js create mode 100755 js/lib/rdge/materials/uber-material.js create mode 100644 js/lib/rdge/materials/water-material.js create mode 100644 js/lib/rdge/materials/z-invert-material.js create mode 100755 js/models/materials-model.js (limited to 'js') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 749a1dd9..3423a5a7 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -8,6 +8,9 @@ var Montage = require("montage/core/core").Montage, CanvasController = require("js/controllers/elements/canvas-controller").CanvasController, njModule = require("js/lib/NJUtils"); +var World = require("js/lib/drawing/world").World; +var MaterialsModel = require("js/models/materials-model").MaterialsModel; + exports.ShapesController = Montage.create(CanvasController, { setProperty: { @@ -78,7 +81,7 @@ exports.ShapesController = Montage.create(CanvasController, { this.application.ninja.selectionController.selectElement(el); return; case "strokeMaterial": - var sm = Object.create(MaterialsLibrary.getMaterial(value)); + var sm = Object.create(MaterialsModel.getMaterial(value)); if(sm) { el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); @@ -88,7 +91,7 @@ exports.ShapesController = Montage.create(CanvasController, { } break; case "fillMaterial": - var fm = Object.create(MaterialsLibrary.getMaterial(value)); + var fm = Object.create(MaterialsModel.getMaterial(value)); if(fm) { el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); @@ -317,7 +320,7 @@ exports.ShapesController = Montage.create(CanvasController, { optionItem.innerText = "Default"; cb.appendChild(optionItem); - var materials = MaterialsLibrary.materials; + var materials = this.application.ninja.appModel.materials; var len = materials.length; var i; @@ -366,19 +369,19 @@ exports.ShapesController = Montage.create(CanvasController, { worldData = el.elementModel.shapeModel.GLWorld.export(); if(worldData) { - world = new GLWorld(el, true); + world = new World(el, true); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = true; world.import(worldData); el.elementModel.shapeModel.GLGeomObj = world.getGeomRoot(); - sm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); + sm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); if(sm) { el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(sm); el.elementModel.shapeModel.strokeMaterial = sm; } - fm = Object.create(MaterialsLibrary.getMaterial("FlatMaterial")); + fm = Object.create(MaterialsModel.getMaterial("FlatMaterial")); // TODO - Use consts after GL code is converted to object literal notation // if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== GLGeomObj.GEOM_TYPE_LINE) ) if( fm && (el.elementModel.shapeModel.GLGeomObj.geomType() !== 3) ) @@ -402,7 +405,7 @@ exports.ShapesController = Montage.create(CanvasController, { worldData = el.elementModel.shapeModel.GLWorld.export(); if(worldData) { - world = new GLWorld(el, false); + world = new World(el, false); el.elementModel.shapeModel.GLWorld = world; el.elementModel.shapeModel.useWebGl = false; world.import(worldData); diff --git a/js/document/html-document.js b/js/document/html-document.js index 5d507476..536fca47 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -668,7 +668,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } } - return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + //return {mode: 'html', document: this._userDocument, webgl: this.glData, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + return {mode: 'html', document: this._userDocument, styles: styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; } else if (this.currentView === "code"){ //TODO: Would this get call when we are in code of HTML? } else { @@ -691,7 +692,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } } - return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + //return {mode: 'html', document: this._userDocument, webgl: this.glData, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + return {mode: 'html', document: this._userDocument, css: css, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; } else if (this.currentView === "code"){ //TODO: Would this get call when we are in code of HTML? } else { diff --git a/js/helper-classes/3D/ParseUtils.js b/js/helper-classes/3D/ParseUtils.js deleted file mode 100755 index 556253e9..00000000 --- a/js/helper-classes/3D/ParseUtils.js +++ /dev/null @@ -1,84 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -/////////////////////////////////////////////////////////////////////// -// Class Utils -// Vector Utility functions -/////////////////////////////////////////////////////////////////////// -function ParseUtils( theStr ) -{ - /////////////////////////////////////////////////////////////////////// - // Instance variables - /////////////////////////////////////////////////////////////////////// - this._strBuffer = theStr; - - /////////////////////////////////////////////////////////////////////// - // Property accessors - /////////////////////////////////////////////////////////////////////// - this.getBuffer = function() { return this._strBuffer; } - this.setBuffer = function(b) { this._strBuffer = b; } - - /////////////////////////////////////////////////////////////////////// - // Methods - /////////////////////////////////////////////////////////////////////// - this.nextValue = function( prop, endKeyArg, advanceBufferArg ) - { - if (!this._strBuffer) return; - - // make the 2 & 3rd argument optional. default is to advance the string - var endKey = "\n", advanceBuffer = true; - if (endKeyArg) - endKey = endKeyArg; - if (advanceBufferArg) - advanceBuffer = advanceBufferArg; - - var iStart = this._strBuffer.indexOf( prop ); - if (iStart < 0) return; - - var iEnd = this._strBuffer.indexOf( endKey, iStart ); - if (iEnd < 0) throw new Error( "property " + prop + " improperly terminated: " + this._strBuffer); - - iStart += prop.length; - var nChars = iEnd - iStart; - var rtnStr = this._strBuffer.substr( iStart, nChars ); - - if (advanceBuffer) - this._strBuffer = this._strBuffer.substr( iEnd + endKey.length ); - - return rtnStr; - } - - this.nextToken = function() - { - if (!this._strBuffer) return; - - // find the limits - var index = this._strBuffer.search( /\S/ ); // first non-whitespace character - if (index > 0) this._strBuffer = this._strBuffer.slice(index); - index = this._strBuffer.search( /\s/ ); // first whitespace character marking the end of the token - - var token; - if (index > 0) - { - token = this._strBuffer.slice(0, index); - this._strBuffer = this._strBuffer.slice( index ); - } - - return token; - } - - this.advancePastToken = function( token ) - { - var index = this._strBuffer.indexOf( token ); - if (index < 0) - console.log( "could not find token: " + token + " in string: " + this._strBuffer ); - else - this._strBuffer = this._strBuffer.substr( index + token.length ); - } - -} - - diff --git a/js/helper-classes/3D/Rectangle.js b/js/helper-classes/3D/Rectangle.js index e797eedf..b8906f18 100755 --- a/js/helper-classes/3D/Rectangle.js +++ b/js/helper-classes/3D/Rectangle.js @@ -35,7 +35,7 @@ var Rectangle = exports.Rectangle = Object.create(Object.prototype, { getTop: { value: function() { return this.m_top; } }, setTop: { value: function(t) { this.m_top = t; } }, - getCenter: { value: function() { return Vector.create( [this.m_left + 0.5*this.m_width, this.m_top + 0.5*this.m_height] ); } }, + getCenter: { value: function() { return [this.m_left + 0.5*this.m_width, this.m_top + 0.5*this.m_height]; } }, getWidth: { value: function() { return this.m_width; } }, setWidth: { value: function(w) { this.m_width = w; } }, diff --git a/js/helper-classes/3D/StageLine.js b/js/helper-classes/3D/StageLine.js index e0e7a8e3..b86673d1 100755 --- a/js/helper-classes/3D/StageLine.js +++ b/js/helper-classes/3D/StageLine.js @@ -149,8 +149,8 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { var vec = vecUtils.vecSubtract(3, bPt1, bPt0); if (plane.isBackFacing()) MathUtils.negate( vec ); - planeEq = Vector.create( [-vec[1], vec[0], 0] ); - var normal = Vector.create( [planeEq[0], planeEq[1], planeEq[2]] ); + planeEq = [-vec[1], vec[0], 0]; + var normal = [planeEq[0], planeEq[1], planeEq[2]]; // var d = -planeEq.dot(bPt0); var d = -vecUtils.vecDot(3, planeEq, bPt0); planeEq[3] = d; @@ -414,8 +414,8 @@ var StageLine = exports.StageLine = Object.create(Object.prototype, { if (pt0[1] < pt1[1]) { yMin = pt0[1]; yMax = pt1[1]; } else { yMin = pt1[1]; yMax = pt0[1]; } if (pt0[2] < pt1[2]) { zMin = pt0[2]; zMax = pt1[2]; } else { zMin = pt1[2]; zMax = pt0[2]; } - this._minPt = Vector.create( [xMin, yMin, zMin] ); - this._maxPt = Vector.create( [xMax, yMax, zMax] ); + this._minPt = [xMin, yMin, zMin]; + this._maxPt = [xMax, yMax, zMax]; } }//, diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 85870097..02d946ae 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -123,7 +123,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { 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] ) ); + this.setWorkingPlane( [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._liveNodeList.length > 0){ diff --git a/js/helper-classes/3D/element-planes.js b/js/helper-classes/3D/element-planes.js index 7ccf311e..38a7bf47 100755 --- a/js/helper-classes/3D/element-planes.js +++ b/js/helper-classes/3D/element-planes.js @@ -88,7 +88,7 @@ var ElementPlanes = exports.ElementPlanes = Object.create(Object.prototype, { // create the plane equation //var d = -( nrm.dot( this._boundaryPts[0]) ); var d = -vecUtils.vecDot(3, nrm, this._boundaryPts[0]); - var planeEq = Vector.create( [nrm[0], nrm[1], nrm[2], d] ); + var planeEq = [nrm[0], nrm[1], nrm[2], d] ; this.setPlaneEq( planeEq ); // get the 2D rectangle diff --git a/js/helper-classes/3D/glUtils.js b/js/helper-classes/3D/glUtils.js deleted file mode 100755 index f6d075f8..00000000 --- a/js/helper-classes/3D/glUtils.js +++ /dev/null @@ -1,319 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -// Constructor function -function Vector() {} -Vector.create = function(elements) -{ - var rtn; - if (elements) - rtn = elements.slice( 0 ); - else - rtn = []; - - return rtn; -}; - -Vector.dup = function(srcPt) -{ - return srcPt.slice(0); -} - - - -function Matrix() {} - -Matrix.create = function( rowArray ) -{ - var mat = Matrix.I(4); - var index = 0; - for(var j=0; j<4; j++) - { - for (var i=0; i<4; i++) - { - mat[index] = rowArray[i][j]; - index++; - } - } - - return mat; -} -Matrix.I = function(dimen) -{ - var mat = []; - for (var i=0; i 4 || - this.elements[0].length > 4) - return null; - - for (var i = 0; i < this.elements.length; i++) { - for (var j = this.elements[i].length; j < 4; j++) { - if (i == j) - this.elements[i].push(1); - else - this.elements[i].push(0); - } - } - - for (var i = this.elements.length; i < 4; i++) { - if (i == 0) - this.elements.push([1, 0, 0, 0]); - else if (i == 1) - this.elements.push([0, 1, 0, 0]); - else if (i == 2) - this.elements.push([0, 0, 1, 0]); - else if (i == 3) - this.elements.push([0, 0, 0, 1]); - } - - return this; -}; - -Matrix.prototype.make3x3 = function() -{ - if (this.elements.length != 4 || - this.elements[0].length != 4) - return null; - - return Matrix.create([[this.elements[0][0], this.elements[0][1], this.elements[0][2]], - [this.elements[1][0], this.elements[1][1], this.elements[1][2]], - [this.elements[2][0], this.elements[2][1], this.elements[2][2]]]); -}; -*/ - -/* -///////////////////////////////////////////////////////////////////////////////////////////// -// SMatrix - -SMatrix.Translation = function (vec) -{ - var mat = SMatrix.I(4); - mat.elements[0][3] = vec[0]; - mat.elements[1][3] = vec[1]; - mat.elements[2][3] = vec[2]; - return mat; -} - -SMatrix.RotationX = function( angle ) -{ - var mat = SMatrix.I(4); - mat.rotateX(angle); - return mat; -} - -SMatrix.RotationY = function( angle ) -{ - var mat = SMatrix.I(4); - mat.rotateX(angle); - return mat; -} - -SMatrix.RotationZ = function( angle ) -{ - var mat = SMatrix.I(4); - mat.rotateZ(angle); - return mat; -} - -SMatrix.MatrixtoSMatrix = function( mat ) -{ - var smat = SMatrix.I(4); - var index = 0; - for (var j=0; j<4; j++) - { - for (var i=0; i<4; i++) - { - smat.elements[i][j] = mat[index]; - index++; - } - } - - return smat; -} - -SMatrix.MatEqSMat = function( mat, sMat ) -{ - var index = 0; - for (var j=0; j<4; j++) - { - for (var i=0; i<4; i++) - { - var m = mat[index]; - var s = smat.elements[i][j]; - if ( MathUtils.fpCmp(m,s) != 0) - throw new Error( "mat != smat" ); - index++; - } - } -} - -// Matrix -///////////////////////////////////////////////////////////////////////////////////////////// -*/ - -Vector.prototype.flatten = function () -{ - return this.elements; -}; - -function mht(m) { - var s = ""; - if (m.length == 16) { - for (var i = 0; i < 4; i++) { - s += "[" + m[i*4+0].toFixed(4) + "," + m[i*4+1].toFixed(4) + "," + m[i*4+2].toFixed(4) + "," + m[i*4+3].toFixed(4) + "]
"; - } - } else if (m.length == 9) { - for (var i = 0; i < 3; i++) { - s += "[" + m[i*3+0].toFixed(4) + "," + m[i*3+1].toFixed(4) + "," + m[i*3+2].toFixed(4) + "]
"; - } - } else { - return m.toString(); - } - return s; -} - -// -// gluLookAt -// -function makeLookAt(ex, ey, ez, - cx, cy, cz, - ux, uy, uz) -{ - var eye = $V([ex, ey, ez]); - var center = $V([cx, cy, cz]); - var up = $V([ux, uy, uz]); - - var mag; - - var z = eye.subtract(center).toUnitVector(); - var x = up.cross(z).toUnitVector(); - var y = z.cross(x).toUnitVector(); - - var m = $M([[x.e(1), x.e(2), x.e(3), 0], - [y.e(1), y.e(2), y.e(3), 0], - [z.e(1), z.e(2), z.e(3), 0], - [0, 0, 0, 1]]); - - var t = $M([[1, 0, 0, -ex], - [0, 1, 0, -ey], - [0, 0, 1, -ez], - [0, 0, 0, 1]]); - return m.x(t); -} - -// -// gluPerspective -// -function makePerspective(fovy, aspect, znear, zfar) -{ - var ymax = znear * Math.tan(fovy * Math.PI / 360.0); - var ymin = -ymax; - var xmin = ymin * aspect; - var xmax = ymax * aspect; - - return makeFrustum(xmin, xmax, ymin, ymax, znear, zfar); -} - -// -// glFrustum -// -function makeFrustum(left, right, - bottom, top, - znear, zfar) -{ - var X = 2*znear/(right-left); - var Y = 2*znear/(top-bottom); - var A = (right+left)/(right-left); - var B = (top+bottom)/(top-bottom); - var C = -(zfar+znear)/(zfar-znear); - var D = -2*zfar*znear/(zfar-znear); - - return Matrix.create([[X, 0, A, 0], - [0, Y, B, 0], - [0, 0, C, D], - [0, 0, -1, 0]]); -} - -// -// glOrtho -// -function makeOrtho(left, right, bottom, top, znear, zfar) -{ - var tx = - (right + left) / (right - left); - var ty = - (top + bottom) / (top - bottom); - var tz = - (zfar + znear) / (zfar - znear); - - return $M([[2 / (right - left), 0, 0, tx], - [0, 2 / (top - bottom), 0, ty], - [0, 0, -2 / (zfar - znear), tz], - [0, 0, 0, 1]]); -} diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js index 37044763..562a6e73 100755 --- a/js/helper-classes/3D/math-utils.js +++ b/js/helper-classes/3D/math-utils.js @@ -86,7 +86,7 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { if (b.length < n) n = b.length; if (n > 0) { - rtnVec = Vector.create([0]); + rtnVec = [0]; for (var i=0; i 0) { - rtnVec = Vector.create([0]); + rtnVec = [0]; for (var i=0; i 1.0 ) { - var intersection = Vector.create([ - segP0[0] + U * (segP1[0] - segP0[0]), - segP0[1] + U * (segP1[1] - segP0[1]), - segP0[2] + U * (segP1[2] - segP0[2])]); + var intersection = [ segP0[0] + U * (segP1[0] - segP0[0]), segP0[1] + U * (segP1[1] - segP0[1]), segP0[2] + U * (segP1[2] - segP0[2])]; return this.vecDist(intersection, pt); } @@ -538,6 +525,39 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { } }, + isIdentityMatrix: { + value: function( mat ) + { + if(!mat) + { + return false; + } + else + { + if(mat[0] !== 1) return false; + if(mat[1] !== 0) return false; + if(mat[2] !== 0) return false; + if(mat[3] !== 0) return false; + + if(mat[4] !== 0) return false; + if(mat[5] !== 1) return false; + if(mat[6] !== 0) return false; + if(mat[7] !== 0) return false; + + if(mat[8] !== 0) return false; + if(mat[9] !== 0) return false; + if(mat[10] !== 1) return false; + if(mat[11] !== 0) return false; + + if(mat[12] !== 0) return false; + if(mat[13] !== 0) return false; + if(mat[14] !== 0) return false; + if(mat[15] !== 1) return false; + } + return true; + } + }, + rectsOverlap: { value: function( pt, width, height, elt ) @@ -704,7 +724,7 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { yNrm += (zPts[i] - zPts[j]) * (xPts[i] + xPts[j]); zNrm += (xPts[i] - xPts[j]) * (yPts[i] + yPts[j]); } - var normal = Vector.create( [xNrm, yNrm, zNrm] ); + var normal = [xNrm, yNrm, zNrm]; // the area of the polygon is the length of the normal var area = VecUtils.vecMag(3, normal ); @@ -727,7 +747,7 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { yNrm += (b[i][2] - b[j][2]) * (b[i][0] + b[j][0]); zNrm += (b[i][0] - b[j][0]) * (b[i][1] + b[j][1]); } - var normal = Vector.create( [xNrm, yNrm, zNrm] ); + var normal = [xNrm, yNrm, zNrm]; // the area of the polygon is the length of the normal var area = VecUtils.vecMag(3, normal ); @@ -867,7 +887,7 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { // var v0 = pt0.slice(0); // var v1 = pt1.slice(0); // -// var origin = Vector.create([0, 0]); +// var origin = [0, 0]; // // if(origin) // { @@ -931,8 +951,7 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { if(!localPt) { return null; - return Vector.create( [1, 1]); - return [1, 1]; +// return [1, 1]; } localPt = this.transformPoint(localPt, matL); @@ -1023,12 +1042,12 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { perspectiveMatrix, inversePerspectiveMatrix, transposedInversePerspectiveMatrix, - perspective = Vector.create([0,0,0,0]), - translate = Vector.create([0,0,0]), - scale = Vector.create([0,0,0]), - skew = Vector.create([0,0,0]), - rotate = Vector.create([0,0,0]), - rightHandSide = Vector.create([0,0,0,0]); + perspective = [0,0,0,0], + translate = [0,0,0], + scale = [0,0,0], + skew = [0,0,0], + rotate = [0,0,0], + rightHandSide = [0,0,0,0]; // Normalize the matrix. if (matrix[15] === 0) { @@ -1106,9 +1125,9 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { } // Compute X scale factor and normalize first row. - var rowX = Vector.create([row[0], row[0+4], row[0+8]]); - var rowY = Vector.create([row[1], row[1+4], row[1+8]]); - var rowZ = Vector.create([row[2], row[2+4], row[2+8]]); + var rowX = [row[0], row[0+4], row[0+8]]; + var rowY = [row[1], row[1+4], row[1+8]]; + var rowZ = [row[2], row[2+4], row[2+8]]; scale[0] = VecUtils.vecMag(3, rowX); rowX = VecUtils.vecNormalize(3, rowX); row[0] = rowX[0]; diff --git a/js/helper-classes/3D/snap-2d-record.js b/js/helper-classes/3D/snap-2d-record.js index c77b28b3..844bb3be 100755 --- a/js/helper-classes/3D/snap-2d-record.js +++ b/js/helper-classes/3D/snap-2d-record.js @@ -78,7 +78,7 @@ var Snap2DRecord = exports.Snap2DRecord = Object.create(Object.prototype, // add the center point var xCtr = 0.5*(bounds[0][0] + bounds[3][0]), yCtr = 0.5*(bounds[0][1] + bounds[1][1]); - var ctr = Vector.create( [xCtr, yCtr, 0] ); + var ctr = [xCtr, yCtr, 0]; this._screenPtArray[4] = viewUtils.localToGlobal( ctr, elt ); var worldPt = viewUtils.localToStageWorld( ctr, elt ); this._alignPtArray[4] = MathUtils.transformPoint( worldPt, snapManager.SnapManager._worldToDragPlane ); diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 372be345..cf8a91db 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -40,6 +40,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { // keep a reference to the most recent hitRecord. Used for drawing feedback on the stage _lastHit : { value: null, writable: true }, + _hitRecords : { value: [], writable: true }, // keep a list of objects to avoid snapping to _avoidList : { value: [], writable: true }, @@ -210,9 +211,9 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { var stage = this.getStage(); var parentPt; if (quadPt) - parentPt = Vector.create([quadPt[0], quadPt[1], 0.0]); + parentPt = [quadPt[0], quadPt[1], 0.0]; else - parentPt = Vector.create([xScreen, yScreen, 0.0]); + parentPt = [xScreen, yScreen, 0.0]; var vec = viewUtils.parentToChildVec(parentPt, stage); if (vec) { @@ -274,6 +275,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { } //if (hitRecArray.length == 0) var rtnHit; + + // Save reference to hit records to verify last hit record's element matches browser's elementFromPoint + this._hitRecords.length = 0; + this._hitRecords = hitRecArray; + if (hitRecArray.length > 0) { this.sortHitRecords( hitRecArray ); @@ -315,7 +321,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { // get the point to the lower left of the plane point and // see if it falls within the snap distance - var origin = Vector.create( [-0.5*this.getStageWidth(), -0.5*this.getStageHeight()] ); + var origin = [-0.5*this.getStageWidth(), -0.5*this.getStageHeight()]; var planePt = hitRec.getLocalPoint(); var dToOrigin = MathUtils.vecSubtract(planePt, origin); var nx = Math.floor( dToOrigin[0]/dx), @@ -332,11 +338,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { return false; } - var pt00 = Vector.create( [ - origin[0] + nx*dx, - origin[1] + ny*dy, - 0.0 - ] ); + var pt00 = [ origin[0] + nx*dx, origin[1] + ny*dy, 0.0 ]; var planeMat = hitRec.getPlaneMatrix(); var scrPt2 = viewUtils.postViewToStageWorld( MathUtils.transformPoint(pt00,planeMat), stage ); scrPt2 = MathUtils.makeDimension3( scrPt2 ); @@ -360,11 +362,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { return true; // check the far corner point and 2 edges out from it - var pt11 = Vector.create( [ - origin[0] + (nx+1)*dx, - origin[1] + (ny+1)*dy, - 0.0 - ] ); + var pt11 = [ origin[0] + (nx+1)*dx, origin[1] + (ny+1)*dy, 0.0 ]; var scrPt4 = viewUtils.postViewToStageWorld( MathUtils.transformPoint(pt11,planeMat), stage ); scrPt4 = MathUtils.makeDimension3( scrPt4 ); scrPt4 = vecUtils.vecAdd(3, viewUtils.viewToScreen( MathUtils.transformPoint(scrPt4, stageMat) ), offset ); @@ -414,11 +412,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { horizontalLineCount = 2; } - var edgePt = Vector.create( [ - gridOrigin[0] + nx*dx, - gridOrigin[1] + ny*dy, - 0.0 - ] ); + var edgePt = [ gridOrigin[0] + nx*dx, gridOrigin[1] + ny*dy, 0.0 ]; var scrPt2 = viewUtils.postViewToStageWorld( MathUtils.transformPoint(edgePt,planeMat), stage ); scrPt2 = MathUtils.makeDimension3( scrPt2 ); scrPt2 = vecUtils.vecAdd(3, viewUtils.viewToScreen( MathUtils.transformPoint(scrPt2, stageMat) ), offset ); @@ -843,7 +837,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { MathUtils.makeDimension3( stageOffset ); var x = vPt[0], y = hPt[1]; - var localPt = Vector.create( [x,y,0,1] ); + var localPt = [x,y,0,1]; var viewPt = MathUtils.transformPoint( localPt, planeToViewMat ); var scrPt = vecUtils.vecAdd(3, viewUtils.viewToScreen( viewPt ), stageOffset ); @@ -1185,7 +1179,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { // Calculate the local point var planeMat; var mat = viewUtils.getMatrixFromElement( elt ); - var wp = Vector.create([0,0,1,0]); + var wp = [0,0,1,0]; wp = MathUtils.transformPlane( wp, mat ); var wpMat = drawUtils.getPlaneToWorldMatrix(wp, MathUtils.getPointOnPlane(wp)); //var wpMatInv = wpMat.inverse(); @@ -1277,7 +1271,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { { // convert to GL coordinates var glPt = this.globalScreenToWebGL( targetScrPt, elt ); - var eyePt = Vector.create( [0, 0, world.getViewDistance()] ); + var eyePt = [0, 0, world.getViewDistance()]; var dir = vecUtils.vecSubtract(3, glPt, eyePt); // recursively go through the tree testing all objects @@ -1528,7 +1522,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { viewUtils.pushViewportObj( elt ); var cop = viewUtils.getCenterOfProjection(); viewUtils.popViewportObj(); - var s2v = Matrix.Translation(Vector.create([-cop[0], -cop[1], 0])); + var s2v = Matrix.Translation([-cop[0], -cop[1], 0]); var vToNDC = Matrix.I(4); vToNDC[0] = 1.0/(0.5*world.getViewportWidth()); vToNDC[5] = 1.0/(0.5*world.getViewportHeight()); @@ -1566,11 +1560,11 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { tmpPt2 = MathUtils.applyHomogeneousCoordinate( tmpPt2 ); // project the 2 object space points onto the original plane of the object - var tmpPt3 = MathUtils.vecIntersectPlane( tmpPt1, vecUtils.vecSubtract(3, tmpPt2, tmpPt1), Vector.create([0,0,1,0]) ); + var tmpPt3 = MathUtils.vecIntersectPlane( tmpPt1, vecUtils.vecSubtract(3, tmpPt2, tmpPt1), [0,0,1,0]); //console.log( "object space pt: " + tmpPt3 ); // get the z value in NDC space of the projection plane - var ndcPt = MathUtils.transformHomogeneousPoint( Vector.create( [0, 0, 0] ), glToNDC ); + var ndcPt = MathUtils.transformHomogeneousPoint( [0, 0, 0], glToNDC ); ndcPt = MathUtils.applyHomogeneousCoordinate( ndcPt ); var zNDC = ndcPt[2]; @@ -1642,7 +1636,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { var drawingGrid = drawUtils.isDrawingGrid(); // get the Z axis of the matrix - var dir = Vector.create([mat[8], mat[9], mat[10]]); + var dir = [mat[8], mat[9], mat[10]]; dir = vecUtils.vecNormalize(3, dir, 1.0); var x = Math.abs(dir[0]), y = Math.abs(dir[1]), @@ -1653,7 +1647,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { //x = 0; y = 0; z = 1; // X/Y plane var id; - var plane = Vector.create([0, 0, 0, 0]); + var plane = [0, 0, 0, 0]; var change = false; if (x > y) { if (x > z) { @@ -1823,7 +1817,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { MathUtils.makeDimension3( stageOffset ); var x = vPt[0], y = hPt[1]; - var localPt = Vector.create( [x,y,0,1] ); + var localPt = [x,y,0,1]; var planeToViewMat = this.getPlaneToViewMat(); var viewPt = MathUtils.transformPoint( localPt, planeToViewMat ); var scrPt = vecUtils.vecAdd(3, viewUtils.viewToScreen( viewPt ), stageOffset ); @@ -1872,7 +1866,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { MathUtils.makeDimension3( stageOffset ); var y = hPt[1], x = vPt[0]; - var localPt = Vector.create( [x,y,0,1] ); + var localPt = [x,y,0,1]; var planeToViewMat = this.getPlaneToViewMat(); var viewPt = MathUtils.transformPoint( localPt, planeToViewMat ); var scrPt = vecUtils.vecAdd(3, viewUtils.viewToScreen( viewPt ), stageOffset ); @@ -1927,7 +1921,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { MathUtils.makeDimension3( stageOffset ); var y = hPt[1], x = vPt[0]; - var localPt = Vector.create( [x,y,0,1] ); + var localPt = [x,y,0,1]; var planeToViewMat = this.getPlaneToViewMat(); var viewPt = MathUtils.transformPoint( localPt, planeToViewMat ); var scrPt = vecUtils.vecAdd(3, viewUtils.viewToScreen( viewPt ), stageOffset ); @@ -2246,6 +2240,30 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { drawUtils.setDrawingSurfaceElement(saveContext); } } - } + }, + + findHitRecordForElement: { + value: function(elt) { + var rtnHit; + + if (!this._hitRecords) return; + var nHits = this._hitRecords.length; + + for (var i=0; i