From 431b6fa7610e59074b4ebb3e9e712672f185b8ad Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 19 Jul 2012 11:44:50 -0700 Subject: Renamed Raiders material to Dark Blur, and Paris to Blue Sky. --- js/lib/geom/geom-obj.js | 4 ++-- js/lib/rdge/materials/radial-blur-material.js | 14 +++++++------- js/lib/rdge/materials/water-material.js | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'js/lib') diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 3cd3a89b..e0ed51fb 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js @@ -385,8 +385,8 @@ exports.GeomObj = Object.create(Object.prototype, { case "plasma": case "deform": case "water": - case "paris": - case "raiders": + case "blueSky": + case "darkBlur": case "tunnel": case "reliefTunnel": case "squareTunnel": diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js index 1f89f79e..2d26638b 100644 --- a/js/lib/rdge/materials/radial-blur-material.js +++ b/js/lib/rdge/materials/radial-blur-material.js @@ -176,22 +176,22 @@ var radialBlurMaterialDef = }; -var RaidersMaterial = function RaidersMaterial() { +var DarkBlurMaterial = function DarkBlurMaterial() { // initialize the inherited members this.inheritedFrom = RadialBlurMaterial; this.inheritedFrom(); - this._name = "Raiders"; - this._shaderName = "raiders"; + this._name = "Dark Blur"; + this._shaderName = "darkBlur"; - this._texMap = 'assets/images/raiders.png'; + this._texMap = 'assets/images/darkblur.png'; this._propValues[this._propNames[0]] = this._texMap.slice(0); // duplicate method required this.dup = function (world) { // allocate a new uber material - var newMat = new RaidersMaterial(); + var newMat = new DarkBlurMaterial(); // copy over the current values; var propNames = [], propValues = [], propTypes = [], propLabels = []; @@ -204,10 +204,10 @@ var RaidersMaterial = function RaidersMaterial() { }; } -RaidersMaterial.prototype = new Material(); +DarkBlurMaterial.prototype = new Material(); if (typeof exports === "object") { - exports.RaidersMaterial = RaidersMaterial; + exports.DarkBlurMaterial = DarkBlurMaterial; } diff --git a/js/lib/rdge/materials/water-material.js b/js/lib/rdge/materials/water-material.js index c7e7313c..9997244c 100644 --- a/js/lib/rdge/materials/water-material.js +++ b/js/lib/rdge/materials/water-material.js @@ -165,16 +165,16 @@ var waterMaterialDef = } }; -var ParisMaterial = function ParisMaterial() +var BlueSkyMaterial = function BlueSkyMaterial() { // initialize the inherited members this.inheritedFrom = WaterMaterial; this.inheritedFrom(); - this._name = "Paris"; - this._shaderName = "paris"; + this._name = "Blue Sky"; + this._shaderName = "blueSky"; - this._defaultTexMap = 'assets/images/paris.png'; + this._defaultTexMap = 'assets/images/bluesky.png'; this._propValues[this._propNames[0]] = this._defaultTexMap.slice(0); //this._diffuseColor = [0.5, 0.5, 0.5, 0.5]; @@ -191,7 +191,7 @@ var ParisMaterial = function ParisMaterial() this._shader.init(); // set up the material node - this._materialNode = RDGE.createMaterialNode("parisMaterial" + "_" + world.generateUniqueNodeID()); + this._materialNode = RDGE.createMaterialNode("blueSkyMaterial" + "_" + world.generateUniqueNodeID()); this._materialNode.setShader(this._shader); this._time = 0; @@ -206,9 +206,9 @@ var ParisMaterial = function ParisMaterial() } -ParisMaterial.prototype = new PulseMaterial(); +BlueSkyMaterial.prototype = new PulseMaterial(); if (typeof exports === "object") { - exports.ParisMaterial = ParisMaterial; + exports.BlueSkyMaterial = BlueSkyMaterial; } -- cgit v1.2.3 From 4648e2eda9aa8c8f9b0aed4d12fef8b1d00f1769 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 19 Jul 2012 16:26:03 -0700 Subject: IKNINJA-1780 - [Shape] Error when opening document that contains a shape with gradient color or no color. Signed-off-by: Nivesh Rajbhandari --- js/lib/geom/circle.js | 57 ++++++++++++++++-------------------------------- js/lib/geom/geom-obj.js | 20 +++++++++++++++++ js/lib/geom/line.js | 26 +++++++++------------- js/lib/geom/rectangle.js | 57 ++++++++++++++++-------------------------------- 4 files changed, 68 insertions(+), 92 deletions(-) (limited to 'js/lib') diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index ba47603b..4995c2cb 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js @@ -83,31 +83,13 @@ exports.Circle = Object.create(GeomObj, { if(strokeMaterial) { this._strokeMaterial = strokeMaterial.dup(); - } else { - this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); - } - - if(strokeColor) { - if(this._strokeMaterial.hasProperty("color")) { - this._strokeMaterial.setProperty( "color", this._strokeColor ); - } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { - this._strokeMaterial.setGradientData(this._strokeColor.color); - } } if(fillMaterial) { this._fillMaterial = fillMaterial.dup(); - } else { - this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } - if(fillColor) { - if(this._fillMaterial.hasProperty("color")) { - this._fillMaterial.setProperty( "color", this._fillColor ); - } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { - this._fillMaterial.setGradientData(this._fillColor.color); - } - } + this.initColors(); } }, @@ -770,8 +752,8 @@ exports.Circle = Object.create(GeomObj, { 'fillColor' : this._fillColor, 'innerRadius' : this._innerRadius, 'strokeStyle' : this._strokeStyle, - 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), - 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : MaterialsModel.getDefaultMaterialName(), + 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null, + 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : null, 'materials' : this.exportMaterialsJSON() }; @@ -790,27 +772,26 @@ exports.Circle = Object.create(GeomObj, { this._fillColor = jObj.fillColor; this._innerRadius = jObj.innerRadius; this._strokeStyle = jObj.strokeStyle; - var strokeMaterialName = jObj.strokeMat; - var fillMaterialName = jObj.fillMat; - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); - if (!strokeMat) { - console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); + if(jObj.strokeMat) { + var strokeMat = MaterialsModel.getMaterial(jObj.strokeMat).dup(); + if (!strokeMat) { + console.log("object material not found in library: " + jObj.strokeMat); + } else { + this._strokeMaterial = strokeMat; + } } - this._strokeMaterial = strokeMat; - if (this._strokeMaterial.hasProperty( 'color' )) - this._strokeMaterial.setProperty( 'color', this._strokeColor ); - - var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); - if (!fillMat) { - console.log( "object material not found in library: " + fillMaterialName ); - fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); + + if(jObj.fillMat) { + var fillMat = MaterialsModel.getMaterial(jObj.fillMat).dup(); + if (!fillMat) { + console.log("object material not found in library: " + jObj.fillMat); + } else { + this._fillMaterial = fillMat; + } } - this._fillMaterial = fillMat; - if (this._fillMaterial.hasProperty( 'color' )) - this._fillMaterial.setProperty( 'color', this._fillColor ); + this.initColors(); this.importMaterialsJSON( jObj.materials ); } }, diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 3cd3a89b..dd60cdec 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js @@ -205,6 +205,26 @@ exports.GeomObj = Object.create(Object.prototype, { /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// + initColors: { + value: function() { + if(this._strokeColor && this._strokeMaterial) { + if(this._strokeMaterial.hasProperty("color")) { + this._strokeMaterial.setProperty( "color", this._strokeColor ); + } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { + this._strokeMaterial.setGradientData(this._strokeColor.color); + } + } + + if(this._fillColor && this._fillMaterial) { + if(this._fillMaterial.hasProperty("color")) { + this._fillMaterial.setProperty( "color", this._fillColor ); + } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { + this._fillMaterial.setGradientData(this._fillColor.color); + } + } + } + }, + setMaterialColor: { value: function(c, type) { var i = 0, diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index c0322f46..eec4f6d9 100755 --- a/js/lib/geom/line.js +++ b/js/lib/geom/line.js @@ -89,17 +89,9 @@ exports.Line = Object.create(GeomObj, { if(strokeMaterial) { this._strokeMaterial = strokeMaterial.dup(); - } else { - this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } - if(strokeColor) { - if(this._strokeMaterial.hasProperty("color")) { - this._strokeMaterial.setProperty( "color", this._strokeColor ); - } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { - this._strokeMaterial.setGradientData(this._strokeColor.color); - } - } + this.initColors(); } }, @@ -245,7 +237,7 @@ exports.Line = Object.create(GeomObj, { 'strokeWidth' : this._strokeWidth, 'strokeColor' : this._strokeColor, 'strokeStyle' : this._strokeStyle, - 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), + 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null, 'materials' : this.exportMaterialsJSON() }; @@ -265,15 +257,17 @@ exports.Line = Object.create(GeomObj, { this._slope = jObj.slope; this._strokeStyle = jObj.strokeStyle; this._strokeColor = jObj.strokeColor; - var strokeMaterialName = jObj.strokeMat; - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); - if (!strokeMat) { - console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + if(jObj.strokeMat) { + var strokeMat = MaterialsModel.getMaterial(jObj.strokeMat).dup(); + if (!strokeMat) { + console.log("object material not found in library: " + jObj.strokeMat); + } else { + this._strokeMaterial = strokeMat; + } } - this._strokeMaterial = strokeMat; + this.initColors(); this.importMaterialsJSON( jObj.materials ); } }, diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index f1da4918..f3db92af 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -99,31 +99,13 @@ exports.Rectangle = Object.create(GeomObj, { if(strokeMaterial) { this._strokeMaterial = strokeMaterial.dup(); - } else { - this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); - } - - if(strokeColor) { - if(this._strokeMaterial.hasProperty("color")) { - this._strokeMaterial.setProperty( "color", this._strokeColor ); - } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { - this._strokeMaterial.setGradientData(this._strokeColor.color); - } } if(fillMaterial) { this._fillMaterial = fillMaterial.dup(); - } else { - this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } - if(fillColor) { - if(this._fillMaterial.hasProperty("color")) { - this._fillMaterial.setProperty( "color", this._fillColor ); - } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { - this._fillMaterial.setGradientData(this._fillColor.color); - } - } + this.initColors(); } }, @@ -303,8 +285,8 @@ exports.Rectangle = Object.create(GeomObj, { 'brRadius' : this._brRadius, 'innerRadius' : this._innerRadius, 'strokeStyle' : this._strokeStyle, - 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), - 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : MaterialsModel.getDefaultMaterialName(), + 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null, + 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : null, 'materials' : this.exportMaterialsJSON() }; @@ -327,27 +309,26 @@ exports.Rectangle = Object.create(GeomObj, { this._brRadius = jObj.brRadius; this._innerRadius = jObj.innerRadius; this._strokeStyle = jObj.strokeStyle; - var strokeMaterialName = jObj.strokeMat; - var fillMaterialName = jObj.fillMat; - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); - if (!strokeMat) { - console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); + if(jObj.strokeMat) { + var strokeMat = MaterialsModel.getMaterial(jObj.strokeMat).dup(); + if (!strokeMat) { + console.log("object material not found in library: " + jObj.strokeMat); + } else { + this._strokeMaterial = strokeMat; + } } - this._strokeMaterial = strokeMat; - if (this._strokeMaterial.hasProperty( 'color' )) - this._strokeMaterial.setProperty( 'color', this._strokeColor ); - - var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); - if (!fillMat) { - console.log( "object material not found in library: " + fillMaterialName ); - fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); + + if(jObj.fillMat) { + var fillMat = MaterialsModel.getMaterial(jObj.fillMat).dup(); + if (!fillMat) { + console.log("object material not found in library: " + jObj.fillMat); + } else { + this._fillMaterial = fillMat; + } } - this._fillMaterial = fillMat; - if (this._fillMaterial.hasProperty( 'color' )) - this._fillMaterial.setProperty( 'color', this._fillColor ); + this.initColors(); this.importMaterialsJSON( jObj.materials ); } }, -- cgit v1.2.3 From e9d08c7af751d75af16371fcac06fd1af8a60fac Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 23 Jul 2012 14:37:51 -0700 Subject: Bugs fixed: 1915 - Data.JSON too large. Reduced mesh size and limited precision of fp numbers 1381 - Background transparency in preview. 1740 - File Save As caused WebGL to stop animating. Crossed RDGE IDs 1954 - Texture change from material popup broke screen rendering. Set correct context on property change. --- js/lib/drawing/world.js | 30 ++++++++++++++++++++++++++++-- js/lib/geom/brush-stroke.js | 14 +++++++++++++- js/lib/rdge/materials/material.js | 4 ++++ 3 files changed, 45 insertions(+), 3 deletions(-) (limited to 'js/lib') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index ca2f07cc..b9f9863f 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -439,6 +439,11 @@ var World = function GLWorld( canvas, use3D, preserveDrawingBuffer ) { // in the case of a procedurally built scene an init state is not needed for loading data this._canvas.rdgeid = this._canvas.getAttribute( "data-RDGE-id" ); if (this._useWebGL) { + // make sure the id is unique + var id = this.uniqueifyID( this._canvas.rdgeid ); + this._canvas.rdgeid = id; + this._canvas.setAttribute( "data-rdge-id", id ); + rdgeStarted = true; RDGE.globals.engine.unregisterCanvas( this._canvas ); RDGE.globals.engine.registerCanvas(this._canvas, this); @@ -673,13 +678,35 @@ World.prototype.updateMaterials = function( obj, time ) { var n = matArray.length; for (var i=0; i= 0) + { + var subStr = id.substr( index+1); + num = Number( subStr ) + 1; + id = id.substr( 0, index ); + } + + id = id + "_" + num; + ctx = RDGE.globals.engine.getContext( id ); + } + + return id; +} + // return the origin of the world in NDC World.prototype.getNDCOrigin = function() { var pt = MathUtils.transformPoint( [0,0,0], this.getCameraMatInverse() ); @@ -973,7 +1000,6 @@ World.prototype.importJSON = function (jObj) // start RDGE rdgeStarted = true; var id = this._canvas.getAttribute( "data-RDGE-id" ); - this._canvas.rdgeid = id; RDGE.globals.engine.registerCanvas(this._canvas, this); RDGE.RDGEStart(this._canvas); this._canvas.task.stop() diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index 12f5c5a1..164d31ee 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js @@ -864,6 +864,17 @@ BrushStroke.prototype.drawToContext = function(ctx, drawStageWorldPts, stageWorl }; //this.drawToCanvas() + +BrushStroke.prototype._fixCoordPrecision = function(coord, precision){ + var i=0; + var numPoints = coord.length; + for (i=0;i - + this._fixCoordPrecision(retObject.origLocalPoints, 4); retObject.stageWorldCenter = [this._stageWorldCenter[0],this._stageWorldCenter[1],this._stageWorldCenter[2]]; retObject.planeMat = this._planeMat; retObject.planeMatInv = this._planeMatInv; diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index e8571e9d..227a772a 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js @@ -263,6 +263,10 @@ var Material = function GLMaterial( world ) { var material = this._materialNode; if (material) technique = material.shaderProgram[this.getTechniqueName()]; + // make sure RDGE has the correct context + if (this.getWorld()) + RDGE.globals.engine.setContext( this.getWorld().getCanvas().rdgeid ); + if(prop === "gradient") { this.setGradientData(value); } else { -- cgit v1.2.3 From fb6b9cb1f7ee29bb2e8d7178479717f650d0b7b5 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 23 Jul 2012 16:59:28 -0700 Subject: Fix: Adding a check for element w/h/t/l This fixes an issue with elements with no set width, height, top, left values from being handling through the PI. Currently those values will default to zero, a secondary fix will address this to show no value in PI and other panels. --- js/lib/NJUtils.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index cfb7ef07..bca9b05b 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -241,6 +241,7 @@ exports.NJUtils = Montage.create(Component, { // 100px will return the following array: [100, px] getValueAndUnits: { value: function(input) { + if (!input) return [null, null]; var numberValue = parseFloat(input); // Ignore all whitespace, digits, negative sign and "." when looking for units label -- cgit v1.2.3