From ac27d538af33ca8d67d3d88729f49c05793afda7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 9 Jul 2012 11:43:36 -0700 Subject: PI, drawing and editing fixes for shapes and materials. IKNinja-1841 - Cannot change webgl shape with LinearGradient and RadialGradient to solid color. IKNINJA-1851 - Cannot draw webgl shapes with Linear/RadialGradient material. IKNINJA-1864 - PI doesn't update the color of shape if WebGL material switches to Flat. IKNINJA-1886 - Gradient edits not applied to WebGL Stage object. Signed-off-by: Nivesh Rajbhandari --- js/lib/rdge/materials/material.js | 69 ++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 27 deletions(-) (limited to 'js/lib/rdge/materials/material.js') diff --git a/js/lib/rdge/materials/material.js b/js/lib/rdge/materials/material.js index 65448c0c..1864b84e 100755 --- a/js/lib/rdge/materials/material.js +++ b/js/lib/rdge/materials/material.js @@ -177,6 +177,8 @@ var Material = function GLMaterial( world ) { }; this.validateProperty = function( prop, value ) { + if(prop === "gradient") return true; + var rtnVal = false; try { @@ -240,33 +242,37 @@ var Material = function GLMaterial( world ) { var material = this._materialNode; if (material) technique = material.shaderProgram[this.getTechniqueName()]; - switch (this.getPropertyType(prop)) - { - case "angle": - case "float": - this._propValues[prop] = value; - if (technique) technique[prop].set( [value] ); - break; - - case "file": - this._propValues[prop] = value.slice(); - if (technique) - { - var glTex = new Texture( this.getWorld(), value ); - this._glTextures[prop] = glTex; - glTex.render(); - var tex = glTex.getTexture(); - if (tex) technique[prop].set( tex ); - } - break; - - case "color": - case "vector2d": - case "vector3d": - this._propValues[prop] = value.slice(); - if (technique) technique[prop].set( value ); - break; - } + if(prop === "gradient") { + this.setGradientData(value); + } else { + switch (this.getPropertyType(prop)) + { + case "angle": + case "float": + this._propValues[prop] = value; + if (technique) technique[prop].set( [value] ); + break; + + case "file": + this._propValues[prop] = value.slice(); + if (technique) + { + var glTex = new Texture( this.getWorld(), value ); + this._glTextures[prop] = glTex; + glTex.render(); + var tex = glTex.getTexture(); + if (tex) technique[prop].set( tex ); + } + break; + + case "color": + case "vector2d": + case "vector3d": + this._propValues[prop] = value.slice(); + if (technique) technique[prop].set( value ); + break; + } + } }; this.setShaderValues = function() @@ -398,6 +404,15 @@ var Material = function GLMaterial( world ) { return tex; }; + this.gradientType = null; + + this.getGradientData = function() { + return null; + }; + + this.setGradientData = function() { + // override in linear-gradient-material and radial-gradient-material + }; }; if (typeof exports === "object") { -- cgit v1.2.3