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