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/tools/BrushTool.js | 6 ++++-- js/tools/LineTool.js | 7 +++++-- js/tools/OvalTool.js | 9 ++++++--- js/tools/PenTool.js | 25 ++++++++++++++----------- js/tools/RectTool.js | 9 ++++++--- js/tools/ShapeTool.js | 4 +++- js/tools/drawing-tool-base.js | 18 +++++++++--------- 7 files changed, 47 insertions(+), 31 deletions(-) (limited to 'js/tools') diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index fec89eb2..752aa2a3 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js @@ -13,6 +13,8 @@ var ElementMediator = require("js/mediators/element-mediator").ElementMediator; var TagTool = require("js/tools/TagTool").TagTool; var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; +var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke; + exports.BrushTool = Montage.create(ShapeTool, { hasReel: { value: false }, _toolID: { value: "brushTool" }, @@ -63,7 +65,7 @@ exports.BrushTool = Montage.create(ShapeTool, { } //start a new brush stroke if (this._selectedBrushStroke === null){ - this._selectedBrushStroke = new GLBrushStroke(); + this._selectedBrushStroke = new BrushStroke(); if (this.application.ninja.colorController.colorToolbar.stroke.webGlColor){ this._selectedBrushStroke.setStrokeColor(this.application.ninja.colorController.colorToolbar.stroke.webGlColor); } @@ -192,7 +194,7 @@ exports.BrushTool = Montage.create(ShapeTool, { var bboxMax = this._selectedBrushStroke.getBBoxMax(); var bboxWidth = bboxMax[0] - bboxMin[0]; var bboxHeight = bboxMax[1] - bboxMin[1]; - var bboxMid = Vector.create([0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]); + var bboxMid = [0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]; this._selectedBrushStroke.setCanvasX(bboxMid[0]); this._selectedBrushStroke.setCanvasY(bboxMid[1]); diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 32572af1..a61f8f79 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -13,6 +13,9 @@ var Montage = require("montage/core/core").Montage, ShapesController = require("js/controllers/elements/shapes-controller").ShapesController, ShapeModel = require("js/models/shape-model").ShapeModel; +var Line = require("js/lib/geom/line").Line; +var MaterialsModel = require("js/models/materials-model").MaterialsModel; + exports.LineTool = Montage.create(ShapeTool, { _toolID: { value: "lineTool" }, _imageID: { value: "lineToolImg" }, @@ -211,7 +214,7 @@ exports.LineTool = Montage.create(ShapeTool, { var strokeM = this.options.strokeMaterial; if(strokeM) { - strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); + strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } } @@ -220,7 +223,7 @@ exports.LineTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); - var line = new GLLine(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); + var line = new Line(world, xOffset, yOffset, w, h, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj); world.addObject(line); world.render(); diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index 911059a7..a10e0bb5 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js @@ -8,6 +8,9 @@ var Montage = require("montage/core/core").Montage, ShapeTool = require("js/tools/ShapeTool").ShapeTool, ShapesController = require("js/controllers/elements/shapes-controller").ShapesController; +var Circle = require("js/lib/geom/circle").Circle; +var MaterialsModel = require("js/models/materials-model").MaterialsModel; + exports.OvalTool = Montage.create(ShapeTool, { _toolID: { value: "ovalTool" }, @@ -48,13 +51,13 @@ exports.OvalTool = Montage.create(ShapeTool, { var strokeM = this.options.strokeMaterial; if(strokeM) { - strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); + strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } var fillM = this.options.fillMaterial; if(fillM) { - fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM)); + fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); } } @@ -63,7 +66,7 @@ exports.OvalTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); - var oval = new GLCircle(); + var oval = new Circle(); //GLCircle(); oval.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle); world.addObject(oval); diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index ddc8bc04..71a91870 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -15,6 +15,9 @@ var TagTool = require("js/tools/TagTool").TagTool; var ElementController = require("js/controllers/elements/element-controller").ElementController; var snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; +var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint; +var SubPath = require("js/lib/geom/sub-path").SubPath; + //todo remove this global var var g_DoPenToolMouseMove = true; @@ -146,7 +149,7 @@ exports.PenTool = Montage.create(ShapeTool, { if (mouseDownPos) { //if we had closed the selected subpath previously, or if we have not yet started anything, create a subpath if (this._selectedSubpath === null) { - this._selectedSubpath = new GLSubpath(); + this._selectedSubpath = new SubPath(); this._isNewPath = true; if (this._entryEditMode === this.ENTRY_SELECT_PATH){ //this should not happen, as ENTRY_SELECT_PATH implies there was a selected subpath @@ -212,13 +215,13 @@ exports.PenTool = Montage.create(ShapeTool, { this._penCanvas = null; this._penPlaneMat = null; this._snapTarget = null; - this._selectedSubpath = new GLSubpath(); + this._selectedSubpath = new SubPath(); this._isNewPath = true; } //add an anchor point to end of the subpath, and make it the selected anchor point if (!this._selectedSubpath.getIsClosed() || this._makeMultipleSubpaths) { - this._selectedSubpath.addAnchor(new GLAnchorPoint()); + this._selectedSubpath.addAnchor(new AnchorPoint()); var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); newAnchor.setPrevPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); @@ -231,7 +234,7 @@ exports.PenTool = Montage.create(ShapeTool, { if (this._isPickedEndPointInSelectPathMode){ //TODO clean up this code...very similar to the code block above if (!this._selectedSubpath.getIsClosed()) { - this._selectedSubpath.addAnchor(new GLAnchorPoint()); + this._selectedSubpath.addAnchor(new AnchorPoint()); var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); newAnchor.setPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); newAnchor.setPrevPos(mouseDownPos[0], mouseDownPos[1], mouseDownPos[2]); @@ -389,7 +392,7 @@ exports.PenTool = Montage.create(ShapeTool, { var bboxMax = this._selectedSubpath.getBBoxMax(); var bboxWidth = bboxMax[0] - bboxMin[0]; var bboxHeight = bboxMax[1] - bboxMin[1]; - var bboxMid = Vector.create([0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]); + var bboxMid = [0.5 * (bboxMax[0] + bboxMin[0]), 0.5 * (bboxMax[1] + bboxMin[1]), 0.5 * (bboxMax[2] + bboxMin[2])]; this._selectedSubpath.setCanvasX(bboxMid[0]); this._selectedSubpath.setCanvasY(bboxMid[1]); @@ -638,7 +641,7 @@ exports.PenTool = Montage.create(ShapeTool, { var baseline = VecUtils.vecNormalize(3, baselineOrig); var delta = VecUtils.vecSubtract(3, p2, p3); //component of the delta along baseline - var deltaB = Vector.create(baseline); + var deltaB = baseline; VecUtils.vecScale(3, deltaB, VecUtils.vecDot(3, baseline, delta)); //component of the delta orthogonal to baseline var deltaO = VecUtils.vecSubtract(3, delta, deltaB); @@ -655,7 +658,7 @@ exports.PenTool = Montage.create(ShapeTool, { //if there is a selected anchor point if (this._selectedSubpath && this._selectedSubpath.getSelectedAnchorIndex() !== -1) { var selAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); - var pos = Vector.create([selAnchor.getPosX(), selAnchor.getPosY(), selAnchor.getPosZ()]); + var pos = [selAnchor.getPosX(), selAnchor.getPosY(), selAnchor.getPosZ()]; var distToPrev = selAnchor.getPrevDistanceSq(pos[0], pos[1], pos[2]); var distToNext = selAnchor.getNextDistanceSq(pos[0], pos[1], pos[2]); var threshSq = 0; // 4 * this._PICK_POINT_RADIUS * this._PICK_POINT_RADIUS; @@ -671,8 +674,8 @@ exports.PenTool = Montage.create(ShapeTool, { nextAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()+1); else nextAnchor = this._selectedSubpath.getAnchor(0); - var nextAnchorPrev = Vector.create([nextAnchor.getPrevX(), nextAnchor.getPrevY(), nextAnchor.getPrevZ()]); - var nextAnchorPos = Vector.create([nextAnchor.getPosX(), nextAnchor.getPosY(), nextAnchor.getPosZ()]) + var nextAnchorPrev = [nextAnchor.getPrevX(), nextAnchor.getPrevY(), nextAnchor.getPrevZ()]; + var nextAnchorPos = [nextAnchor.getPosX(), nextAnchor.getPosY(), nextAnchor.getPosZ()]; var newNext = this.BuildSecondCtrlPoint(pos, nextAnchorPrev, nextAnchorPos); selAnchor.setNextPos(newNext[0], newNext[1], newNext[2]); //check if the next is still not over the threshSq..if so, add a constant horizontal amount @@ -688,8 +691,8 @@ exports.PenTool = Montage.create(ShapeTool, { prevAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()-1); else prevAnchor = this._selectedSubpath.getAnchor(numAnchors-1); - var prevAnchorNext = Vector.create([prevAnchor.getNextX(), prevAnchor.getNextY(), prevAnchor.getNextZ()]); - var prevAnchorPos = Vector.create([prevAnchor.getPosX(), prevAnchor.getPosY(), prevAnchor.getPosZ()]) + var prevAnchorNext = [prevAnchor.getNextX(), prevAnchor.getNextY(), prevAnchor.getNextZ()]; + var prevAnchorPos = [prevAnchor.getPosX(), prevAnchor.getPosY(), prevAnchor.getPosZ()]; var newPrev = this.BuildSecondCtrlPoint(pos, prevAnchorNext, prevAnchorPos); selAnchor.setPrevPos(newPrev[0], newPrev[1], newPrev[2]); //check if the prev is still not over the threshSq..if so, add a constant horizontal amount diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js index 5e148de3..957afea9 100755 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js @@ -8,6 +8,9 @@ var Montage = require("montage/core/core").Montage, ShapeTool = require("js/tools/ShapeTool").ShapeTool, ShapesController = require("js/controllers/elements/shapes-controller").ShapesController; +var Rectangle = require("js/lib/geom/rectangle").Rectangle; +var MaterialsModel = require("js/models/materials-model").MaterialsModel; + exports.RectTool = Montage.create(ShapeTool, { _toolID: { value: "rectTool" }, @@ -67,13 +70,13 @@ exports.RectTool = Montage.create(ShapeTool, { var strokeM = this.options.strokeMaterial; if(strokeM) { - strokeMaterial = Object.create(MaterialsLibrary.getMaterial(strokeM)); + strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } var fillM = this.options.fillMaterial; if(fillM) { - fillMaterial = Object.create(MaterialsLibrary.getMaterial(fillM)); + fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); } } @@ -82,7 +85,7 @@ exports.RectTool = Montage.create(ShapeTool, { var xOffset = ((left - canvas.offsetLeft + w/2) - canvas.width/2); var yOffset = (canvas.height/2 - (top - canvas.offsetTop + h/2)); - var rect = new GLRectangle(); + var rect = new Rectangle(); rect.init(world, xOffset, yOffset, w, h, strokeSize, strokeColor, fillColor, tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle); diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 29e9b99f..d3a36163 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -14,6 +14,8 @@ var Montage = require("montage/core/core").Montage, ShapeModel = require("js/models/shape-model").ShapeModel, TagTool = require("js/tools/TagTool").TagTool; +var World = require("js/lib/drawing/world").World; + exports.ShapeTool = Montage.create(DrawingTool, { drawingFeedback: { value: { mode: "Draw3D", type: "rectangle" } }, @@ -176,7 +178,7 @@ exports.ShapeTool = Montage.create(DrawingTool, { if(!world) { // create all the GL stuff - var world = new GLWorld(canvas, use3D); + var world = new World(canvas, use3D); ElementMediator.setShapeProperty(canvas, "GLWorld", world); } diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index cd895102..8d87605c 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js @@ -205,11 +205,11 @@ exports.DrawingToolBase = Montage.create(Montage, { thePlane[3] = -vecUtils.vecDot(3, thePlane, s0); } else { var vec = vecUtils.vecSubtract(3, s1, s0 ); - var yAxis = Vector.create([0,1,0]); + var yAxis = [0,1,0]; var tmp = vecUtils.vecCross( 3, vec, yAxis ); var mag = vecUtils.vecMag(3, tmp); if (MathUtils.fpSign(mag) === 0) { - thePlane = Vector.create( [0,0,1] ); + thePlane = [0,0,1]; thePlane[3] = -vecUtils.vecDot(3, thePlane, s0); } else { var xAxis = vecUtils.vecCross( 3, yAxis, tmp ); @@ -336,12 +336,12 @@ exports.DrawingToolBase = Montage.create(Montage, { else { var vec = vecUtils.vecSubtract(3, s1, s0 ); - var yAxis = Vector.create([0,1,0]); + var yAxis = [0,1,0]; var tmp = vecUtils.vecCross( 3, vec, yAxis ); var mag = vecUtils.vecMag(3, tmp); if (MathUtils.fpSign(mag) === 0) { - thePlane = Vector.create( [0,0,1] ); + thePlane = [0,0,1]; thePlane[3] = -vecUtils.vecDot(3, thePlane, s0); } else @@ -379,7 +379,7 @@ exports.DrawingToolBase = Montage.create(Montage, { } - var localPt = Vector.create([p0[0], p0[1], 0.0, 1.0]); + var localPt = [p0[0], p0[1], 0.0, 1.0]; s0 = viewUtils.postViewToStageWorld( MathUtils.transformPoint(localPt,planeMat), elt ); s0 = vecUtils.vecAdd(3, viewUtils.viewToScreen( MathUtils.transformPoint(s0, stageMat) ), offset ); @@ -513,8 +513,8 @@ exports.DrawingToolBase = Montage.create(Montage, { var z = p0[2]; // fill in the other 2 points on the plane to complete the 4 points - var p1 = Vector.create( [p0[0], p2[1], z] ), - p3 = Vector.create( [p2[0], p0[1], z] ); + var p1 = [p0[0], p2[1], z], + p3 = [p2[0], p0[1], z]; // convert back to 3D space s0 = MathUtils.transformPoint( p0, planeMat ); @@ -633,8 +633,8 @@ exports.DrawingToolBase = Montage.create(Montage, { var pt0 = ptArr[0], pt2 = ptArr[1]; z = pt0[2]; pt0[2] = z; pt2[2] = z; - var pt1 = Vector.create( [pt0[0], pt2[1], z] ), - pt3 = Vector.create( [pt2[0], pt0[1], z] ); + var pt1 = [pt0[0], pt2[1], z], + pt3 = [pt2[0], pt0[1], z]; // ptArr = [pt0, pt1, pt2, pt3]; -- cgit v1.2.3