From 84332ab81c1b445195f1d9be8bbeae0725c8e758 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 6 Mar 2012 10:58:25 -0800 Subject: 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 --- 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 | 54 +++--- js/helper-classes/3D/snap-2d-record.js | 2 +- js/helper-classes/3D/snap-manager.js | 46 ++--- js/helper-classes/3D/vec-utils.js | 16 +- js/helper-classes/3D/view-utils.js | 12 +- 11 files changed, 57 insertions(+), 490 deletions(-) delete mode 100755 js/helper-classes/3D/ParseUtils.js delete mode 100755 js/helper-classes/3D/glUtils.js (limited to 'js/helper-classes/3D') 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 de63f880..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); } @@ -737,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 ); @@ -760,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 ); @@ -900,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) // { @@ -964,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); @@ -1056,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) { @@ -1139,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 596ba56a..cf8a91db 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -211,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) { @@ -321,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), @@ -338,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 ); @@ -366,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 ); @@ -420,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 ); @@ -849,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 ); @@ -1191,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(); @@ -1283,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 @@ -1534,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()); @@ -1572,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]; @@ -1648,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]), @@ -1659,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) { @@ -1829,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 ); @@ -1878,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 ); @@ -1933,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 ); diff --git a/js/helper-classes/3D/vec-utils.js b/js/helper-classes/3D/vec-utils.js index ceff4f64..3db95ab7 100755 --- a/js/helper-classes/3D/vec-utils.js +++ b/js/helper-classes/3D/vec-utils.js @@ -38,13 +38,13 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype, if (MathUtils.fpSign(sum) != 0) { var scale = len/sum; - rtnVec = Vector.create( [0] ); + rtnVec = [0]; for (var i=0; i