From 5fcb96cae89007c684df3ce948831e2fcf9fd8b7 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 14 May 2012 10:00:52 -0700 Subject: Fixing merge issues --- js/controllers/elements/shapes-controller.js | 46 +++++----------------------- js/lib/drawing/world.js | 2 -- js/lib/geom/geom-obj.js | 36 +++++----------------- js/tools/LineTool.js | 2 +- js/tools/OvalTool.js | 4 +-- js/tools/RectTool.js | 4 +-- 6 files changed, 19 insertions(+), 75 deletions(-) diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 0d6defe2..da4e6d1b 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -142,7 +142,7 @@ exports.ShapesController = Montage.create(CanvasController, { if(m) { el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(m); - color = this.getMaterialColor(m); + color = this.getMaterialColor(value); if(color) { el.elementModel.shapeModel.GLGeomObj.setStrokeColor(color); @@ -156,7 +156,7 @@ exports.ShapesController = Montage.create(CanvasController, { if(m) { el.elementModel.shapeModel.GLGeomObj.setFillMaterial(m); - color = this.getMaterialColor(m); + color = this.getMaterialColor(value); if(color) { el.elementModel.shapeModel.GLGeomObj.setFillColor(color); @@ -750,34 +750,14 @@ exports.ShapesController = Montage.create(CanvasController, { value: function(m) { var css, - colorObj, - c, - mName = m.getName(); - if(mName === "LinearGradientMaterial") + colorObj; + if(m === "LinearGradientMaterial") { - css = "-webkit-gradient(linear, left top, right top, from("; - c = this.webGlColorToCss(m, 1); - css += c.rgb + ")"; - c = this.webGlColorToCss(m, 2); - css += ", color-stop(" + c.stop + ", " + c.rgb + ")"; - c = this.webGlColorToCss(m, 3); - css += ", color-stop(" + c.stop + ", " + c.rgb + ")"; - c = this.webGlColorToCss(m, 4); - css += ", to(" + c.rgb + "))"; -// console.log(css); + css = "-webkit-gradient(linear, left top, right top, from(rgb(255, 0, 0)), color-stop(0.3, rgb(0, 255, 0)), color-stop(0.6, rgb(0, 0, 255)), to(rgb(0, 255, 255)))"; } - else if(mName === "RadialGradientMaterial") + else if(m === "RadialGradientMaterial") { - css = "-webkit-radial-gradient(50% 50%, ellipse cover, "; - c = this.webGlColorToCss(m, 1); - css += c.rgb + " " + c.stop*100 + "%"; - c = this.webGlColorToCss(m, 2); - css += c.rgb + " " + c.stop*100 + "%"; - c = this.webGlColorToCss(m, 3); - css += c.rgb + " " + c.stop*100 + "%"; - c = this.webGlColorToCss(m, 4); - css += c.rgb + " " + c.stop*100 + "%)"; -// console.log(css); + css = "-webkit-radial-gradient(50% 50%, ellipse cover, rgb(255, 0, 0) 0%, rgb(0, 255, 0) 30%, rgb(0, 0, 255) 60%, rgb(0, 255, 255) 100%)"; } if(css) @@ -791,18 +771,6 @@ exports.ShapesController = Montage.create(CanvasController, { return null; } - }, - - webGlColorToCss: { - value: function(m, index) - { - var color, rgba, cStop; - color = m["getColor" + index](); - rgba = 'rgba(' + color[0]*255 + ',' + color[1]*255 + ',' + color[2]*255 + ',' + color[3] + ')'; - cStop = m["getColorStop" + index](); - - return {rgb:rgba, stop: cStop}; - } } }); diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index b46a002b..14e63f4a 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -31,7 +31,6 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { this._canvas = canvas; if (this._useWebGL) { - preserveDrawingBuffer = true; if(preserveDrawingBuffer) { this._glContext = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true}); @@ -79,7 +78,6 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { this._firstRender = true; this._worldCount = worldCounter; - console.log( "creating world " + this._worldCount ); worldCounter++; // keep a counter for generating node names diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 803dbb53..6f37ad1c 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js @@ -11,7 +11,6 @@ var MaterialsModel = require("js/models/materials-model").MaterialsModel; // Super class for all geometry classes /////////////////////////////////////////////////////////////////////// exports.GeomObj = Object.create(Object.prototype, { -{ /////////////////////////////////////////////////////////////////////// // Constants /////////////////////////////////////////////////////////////////////// @@ -181,14 +180,12 @@ exports.GeomObj = Object.create(Object.prototype, { /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// - setMaterialColor: { + setMaterialColor: { value: function(c, type) { var i = 0, nMats = 0; if (c) { if (c.gradientMode) { - if (c.gradientMode) - { // Gradient support if (this._materialArray && this._materialTypeArray) { nMats = this._materialArray.length; @@ -204,7 +201,6 @@ exports.GeomObj = Object.create(Object.prototype, { } for (var n = 0; n < len; n++) { - { var position = colors[n].position / 100; var cs = colors[n].value; var stop = [cs.r / 255, cs.g / 255, cs.b / 255, cs.a]; @@ -213,9 +209,6 @@ exports.GeomObj = Object.create(Object.prototype, { if (nMats === this._materialTypeArray.length) { for (i = 0; i < nMats; i++) { if (this._materialTypeArray[i] == type) { - { - if (this._materialTypeArray[i] == type) - { this._materialArray[i].setProperty("color" + (n + 1), stop.slice(0)); this._materialArray[i].setProperty("colorStop" + (n + 1), position); } @@ -225,15 +218,12 @@ exports.GeomObj = Object.create(Object.prototype, { if (type === "fill") { this._fillColor = c; } else { - else { this._strokeColor = c; } } else { - else { if (type === "fill") { this._fillColor = c.slice(0); } else { - else { this._strokeColor = c.slice(0); } @@ -241,7 +231,6 @@ exports.GeomObj = Object.create(Object.prototype, { nMats = this._materialArray.length; if (nMats === this._materialTypeArray.length) { for (i = 0; i < nMats; i++) { - { if (this._materialTypeArray[i] == type) { this._materialArray[i].setProperty("color", c.slice(0)); } @@ -250,24 +239,17 @@ exports.GeomObj = Object.create(Object.prototype, { } } } else { - else - { if (type === "fill") { this._fillColor = null; } else { - else { this._strokeColor = null; } if (this._materialArray && this._materialTypeArray) { - { nMats = this._materialArray.length; if (nMats === this._materialTypeArray.length) { for (i = 0; i < nMats; i++) { if (this._materialTypeArray[i] == type) { - { - if (this._materialTypeArray[i] == type) - { // TODO - Not sure how to set color to null values in shaders this._materialArray[i].setProperty("color", [0, 0, 0, 0]); } @@ -289,7 +271,6 @@ exports.GeomObj = Object.create(Object.prototype, { if (this.getStrokeMaterial()) { strokeMaterial = this.getStrokeMaterial().dup(); } else { - else { strokeMaterial = MaterialsModel.exportFlatMaterial(); } @@ -304,7 +285,7 @@ exports.GeomObj = Object.create(Object.prototype, { this.setStrokeColor(this._strokeColor); } - this._strokeMaterial = strokeMaterial; + this._strokeMaterial = strokeMaterial; return strokeMaterial; } @@ -316,7 +297,6 @@ exports.GeomObj = Object.create(Object.prototype, { if (this.getFillMaterial()) { fillMaterial = this.getFillMaterial().dup(); } else { - else { fillMaterial = MaterialsModel.exportFlatMaterial(); } @@ -339,17 +319,17 @@ exports.GeomObj = Object.create(Object.prototype, { exportMaterialsJSON: { value: function() { - MaterialsModel = require("js/models/materials-model").MaterialsModel; + MaterialsModel = require("js/models/materials-model").MaterialsModel; var jObj; if (this._materialArray && this._materialNodeArray && this.getWorld().isWebGL()) { var nMats = this._materialArray.length; if (nMats > 0) { - { + { var arr = []; for (var i = 0; i < nMats; i++) { - { + { var matObj = { 'materialNodeName':this._materialNodeArray[i].name, @@ -373,7 +353,7 @@ exports.GeomObj = Object.create(Object.prototype, { importMaterialsJSON: { value: function(jObj) { - MaterialsModel = require("js/models/materials-model").MaterialsModel; + MaterialsModel = require("js/models/materials-model").MaterialsModel; this._materialArray = []; this._materialTypeArray = []; @@ -383,12 +363,10 @@ exports.GeomObj = Object.create(Object.prototype, { var nMaterials = jObj.nMaterials; var matArray = jObj.materials; for (var i = 0; i < nMaterials; i++) { - { var mat; var matObj = matArray[i].material; var shaderName = matObj.material; switch (shaderName) { - { case "flat": case "radialGradient": case "linearGradient": @@ -402,7 +380,7 @@ exports.GeomObj = Object.create(Object.prototype, { case "tunnel": case "reliefTunnel": case "squareTunnel": - case "flag": + case "flag": case "twist": case "fly": case "julia": diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index 6621d18b..d5bfa38a 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -226,7 +226,7 @@ exports.LineTool = Montage.create(ShapeTool, { { strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } - strokeColor = ShapesController.getMaterialColor(strokeMaterial) || strokeColor; + strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; } var world = this.getGLWorld(canvas, this.options.use3D); diff --git a/js/tools/OvalTool.js b/js/tools/OvalTool.js index 917da538..e9dc66bb 100755 --- a/js/tools/OvalTool.js +++ b/js/tools/OvalTool.js @@ -53,14 +53,14 @@ exports.OvalTool = Montage.create(ShapeTool, { { strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } - strokeColor = ShapesController.getMaterialColor(strokeMaterial) || strokeColor; + strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; var fillM = this.options.fillMaterial; if(fillM) { fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); } - fillColor = ShapesController.getMaterialColor(fillMaterial) || fillColor; + fillColor = ShapesController.getMaterialColor(fillM) || fillColor; } var world = this.getGLWorld(canvas, this.options.use3D); diff --git a/js/tools/RectTool.js b/js/tools/RectTool.js index a8c57688..0a3c8200 100755 --- a/js/tools/RectTool.js +++ b/js/tools/RectTool.js @@ -72,14 +72,14 @@ exports.RectTool = Montage.create(ShapeTool, { { strokeMaterial = Object.create(MaterialsModel.getMaterial(strokeM)); } - strokeColor = ShapesController.getMaterialColor(strokeMaterial) || strokeColor; + strokeColor = ShapesController.getMaterialColor(strokeM) || strokeColor; var fillM = this.options.fillMaterial; if(fillM) { fillMaterial = Object.create(MaterialsModel.getMaterial(fillM)); } - fillColor = ShapesController.getMaterialColor(fillMaterial) || fillColor; + fillColor = ShapesController.getMaterialColor(fillM) || fillColor; } var world = this.getGLWorld(canvas, this.options.use3D); -- cgit v1.2.3