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/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 +++++ 81 files changed, 11425 insertions(+), 11392 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 (limited to 'js/helper-classes') 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 -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 GLAnchorPoint -// GL representation of a point clicked -// and dragged during pen tool -// -// -///////////////////////////////////////////// -function GLAnchorPoint() { - ///////////////////////////////////////// - // Instance variables - ///////////////////////////////////////// - this._x = 0.0; - this._y = 0.0; - this._z = 0.0; - - this._prevX = 0.0; - this._prevY = 0.0; - this._prevZ = 0.0; - - this._nextX = 0.0; - this._nextY = 0.0; - this._nextZ = 0.0; -} - // *********** setters ************ -GLAnchorPoint.prototype.setPos = function (x, y, z) { this._x = x; this._y = y; this._z = z; } -GLAnchorPoint.prototype.setPrevPos = function (x, y, z) { this._prevX = x; this._prevY = y; this._prevZ = z; } -GLAnchorPoint.prototype.setNextPos = function (x, y, z) { this._nextX = x; this._nextY = y; this._nextZ = z; } - -GLAnchorPoint.prototype.setPrevFromNext = function () { - //set the previous control point by reflecting the next control point - var dispX = this._nextX - this._x; - var dispY = this._nextY - this._y; - var dispZ = this._nextZ - this._z; - - this._prevX = this._x - dispX; - this._prevY = this._y - dispY; - this._prevZ = this._z - dispZ; -} -GLAnchorPoint.prototype.setNextFromPrev = function () { - //set the previous control point by reflecting the next control point - var dispX = this._prevX - this._x; - var dispY = this._prevY - this._y; - var dispZ = this._prevZ - this._z; - - this._nextX = this._x - dispX; - this._nextY = this._y - dispY; - this._nextZ = this._z - dispZ; -} - -//translate the next point from the translation that was applied to the prev. point -GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) { - //do nothing if the total translation is zero - var totalTransSq = (tx*tx) + (ty*ty) + (tz*tz); - if (totalTransSq < 0.0000001) - return; - - // *** compute the rotation of the prev vector *** - var oldP = Vector.create([this._prevX + tx - this._x, this._prevY + ty - this._y, this._prevZ + tz - this._z]); - var newP = Vector.create([this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z]); - //compute angle between the two vectors - var axis = Vector.create([0, 0, 0]); - var angle = MathUtils.getAxisAngleBetween3DVectors(oldP, newP, axis); - if (angle === 0) - return; - - // *** compute the vector from anchor to next - var oldN = Vector.create([this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z]); - var rotMat = Matrix.Rotation(-angle, axis); - var newN = MathUtils.transformVector(oldN, rotMat); - - //TEMP for some situations the axis angle computation returns NaNs - if (isNaN(newN[0]) || isNaN(newN[1]) || isNaN(newN[2])) { - console.log("NaN in translateNextFromPrev"); - return; - } - //end TEMP - this._nextX = this._x + newN[0]; - this._nextY = this._y + newN[1]; - this._nextZ = this._z + newN[2]; -} -//translate the next point from the translation that was applied to the prev. point -GLAnchorPoint.prototype.translatePrevFromNext = function (tx, ty, tz) { - //do nothing if the total translation is zero - var totalTransSq = (tx*tx) + (ty*ty) + (tz*tz); - if (totalTransSq < 0.0000001) - return; - - // *** compute the rotation of the next vector *** - var oldN = Vector.create([this._nextX + tx - this._x, this._nextY + ty - this._y, this._nextZ + tz - this._z]); - var newN = Vector.create([this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z]); - //compute angle between the two vectors - var axis = Vector.create([0, 0, 0]); - var angle = MathUtils.getAxisAngleBetween3DVectors(oldN, newN, axis); - if (angle === 0) - return; - - // *** compute the vector from anchor to prev - var oldP = Vector.create([this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z]); - var rotMat = Matrix.Rotation(-angle, axis); - var newP = MathUtils.transformVector(oldP, rotMat); - - //TEMP for some situations the axis angle computation returns NaNs - if (isNaN(newP[0]) || isNaN(newP[1]) || isNaN(newP[2])) { - return; - } - //end TEMP - this._prevX = this._x + newP[0]; - this._prevY = this._y + newP[1]; - this._prevZ = this._z + newP[2]; -} - - -// ******* modifiers ******* -GLAnchorPoint.prototype.translatePrev = function (x, y, z) { - this._prevX += x; this._prevY += y; this._prevZ += z; -} -GLAnchorPoint.prototype.translateNext = function (x, y, z) { - this._nextX += x; this._nextY += y; this._nextZ += z; -} -GLAnchorPoint.prototype.translate = function (x, y, z) { - this._x += x; this._y += y; this._z += z; -} -GLAnchorPoint.prototype.translateAll = function (x, y, z) { - this.translate(x, y, z); - this.translatePrev(x, y, z); - this.translateNext(x, y, z); -} - - -GLAnchorPoint.prototype.scaleAll = function(sx,sy,sz){ - this._x *= sx;this._prevX *= sx;this._nextX *= sx; - this._y *= sy;this._prevY *= sy;this._nextY *= sy; - this._z *= sz;this._prevZ *= sz;this._nextZ *= sz; -} - - -// ********* getters ********** -GLAnchorPoint.prototype.getPosX = function () { return this._x; } -GLAnchorPoint.prototype.getPosY = function () { return this._y; } -GLAnchorPoint.prototype.getPosZ = function () { return this._z; } -GLAnchorPoint.prototype.getPrevX = function () { return this._prevX; } -GLAnchorPoint.prototype.getPrevY = function () { return this._prevY; } -GLAnchorPoint.prototype.getPrevZ = function () { return this._prevZ; } -GLAnchorPoint.prototype.getNextX = function () { return this._nextX; } -GLAnchorPoint.prototype.getNextY = function () { return this._nextY; } -GLAnchorPoint.prototype.getNextZ = function () { return this._nextZ; } -GLAnchorPoint.prototype.getPos = function() { return Vector.create([this._x, this._y, this._z]);} -GLAnchorPoint.prototype.getPrev = function() { return Vector.create([this._prevX, this._prevY, this._prevZ]);} -GLAnchorPoint.prototype.getNext = function() { return Vector.create([this._nextX, this._nextY, this._nextZ]);} -//return the square of distance from passed in point to the anchor position -GLAnchorPoint.prototype.getDistanceSq = function (x, y, z) { - return (this._x - x) * (this._x - x) + (this._y - y) * (this._y - y) + (this._z - z) * (this._z - z); -} -//return sq. of distance to prev. -GLAnchorPoint.prototype.getPrevDistanceSq = function (x, y, z) { - return (this._prevX - x) * (this._prevX - x) + (this._prevY - y) * (this._prevY - y) + (this._prevZ - z) * (this._prevZ - z); -} -//return sq. of distance to next -GLAnchorPoint.prototype.getNextDistanceSq = function (x, y, z) { - return (this._nextX - x) * (this._nextX - x) + (this._nextY - y) * (this._nextY - y) + (this._nextZ - z) * (this._nextZ - z); -} - diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js deleted file mode 100755 index 5d773c2d..00000000 --- a/js/helper-classes/RDGE/GLBrushStroke.js +++ /dev/null @@ -1,397 +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. -
*/ - -// Todo: This entire class should be converted to a module -var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; - -/////////////////////////////////////////////////////////////////////// -// Class GLBrushStroke -// representation a sequence points (polyline) created by brush tool. -// Derived from class GLGeomObj -/////////////////////////////////////////////////////////////////////// -function GLBrushStroke() { - /////////////////////////////////////////////////// - // Instance variables - /////////////////////////////////////////////////// - this._Points = []; - this._BBoxMin = [0, 0, 0]; - this._BBoxMax = [0, 0, 0]; - this._dirty = true; - - //whether or not to use the canvas drawing to stroke/fill - this._useCanvasDrawing = true; - - //the X and Y location of this subpath's canvas in stage world space of Ninja - this._canvasX = 0; - this._canvasY = 0; - - //stroke information - this._strokeWidth = 0.0; - this._strokeColor = [0.4, 0.4, 0.4, 1.0]; - this._strokeMaterial; - this._strokeStyle = "Solid"; - - //the wetness of the brush (currently this is multiplied to the square of the stroke width, but todo should be changed to not depend on stroke width entirely - //smaller value means more samples for the path - this._WETNESS_FACTOR = 0.25; - - //prevent extremely long paths that can take a long time to render - this._MAX_ALLOWED_SAMPLES = 500; - - //drawing context - this._world = null; - - //tool that owns this brushstroke - this._drawingTool = null; - this._planeMat = null; - this._planeMatInv = null; - this._planeCenter = null; - - // initialize the inherited members - this.inheritedFrom = GLGeomObj; - this.inheritedFrom(); - - ///////////////////////////////////////////////////////// - // Property Accessors/Setters - ///////////////////////////////////////////////////////// - this.setWorld = function (world) { this._world = world; } - this.getWorld = function () { return this._world; } - this.geomType = function () { return this.GEOM_TYPE_CUBIC_BEZIER; } - this.setDrawingTool = function (tool) {this._drawingTool = tool;} - this.getDrawingTool = function () {return this._drawingTool;} - this.setPlaneMatrix = function(planeMat){this._planeMat = planeMat;} - this.setPlaneMatrixInverse = function(planeMatInv){this._planeMatInv = planeMatInv;} - this.setPlaneCenter = function(pc){this._planeCenter = pc;} - - this.getCanvasX = function(){return this._canvasX;} - this.getCanvasY = function(){return this._canvasY;} - this.setCanvasX = function(cx){this._canvasX=cx;} - this.setCanvasY = function(cy){this._canvasY=cy;} - - - this.getNumPoints = function () { return this._Points.length; } - this.getPoint = function (index) { return this._Points[index]; } - this.addPoint = function (pt) - { - //add the point only if it is some epsilon away from the previous point - var numPoints = this._Points.length; - if (numPoints>0) { - var threshold = this._WETNESS_FACTOR*this._strokeWidth; - var prevPt = this._Points[numPoints-1]; - var diffPt = [prevPt[0]-pt[0], prevPt[1]-pt[1]]; - var diffPtMag = Math.sqrt(diffPt[0]*diffPt[0] + diffPt[1]*diffPt[1]); - if (diffPtMag>threshold){ - this._Points.push(pt); - this._dirty=true; - } - }else{ - this._Points.push(pt); - this._dirty=true; - } - } - - this.insertPoint = function(pt, index){ this._Points.splice(index, 0, pt); this._dirty=true;} - this.isDirty = function(){return this._dirty;} - this.makeDirty = function(){this._dirty=true;} - - this.getBBoxMin = function () { return this._BBoxMin; } - this.getBBoxMax = function () { return this._BBoxMax; } - - this.getStrokeWidth = function () { return this._strokeWidth; } - this.setStrokeWidth = function (w) { this._strokeWidth = w; this._dirty=true;} - this.getStrokeMaterial = function () { return this._strokeMaterial; } - this.setStrokeMaterial = function (m) { this._strokeMaterial = m; } - this.getStrokeColor = function () { return this._strokeColor; } - this.setStrokeColor = function (c) { this._strokeColor = c; } - this.getStrokeStyle = function () { return this._strokeStyle; } - this.setStrokeStyle = function (s) { this._strokeStyle = s; } - - this.setWidth = function () { }//NO-OP for now - this.setHeight = function () {}//NO-OP for now - - - //remove and return anchor at specified index, return null on error - this.removePoint = function (index) { - var retAnchor = null; - if (index < this._Points.length) { - retPt = this._Points.splice(index, 1); - this._dirty=true; - } - return retPoint; - } - - //remove all the points - this.clea