From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- js/lib/rdge/materials/radial-gradient-material.js | 170 +++++++++++----------- 1 file changed, 85 insertions(+), 85 deletions(-) (limited to 'js/lib/rdge/materials/radial-gradient-material.js') diff --git a/js/lib/rdge/materials/radial-gradient-material.js b/js/lib/rdge/materials/radial-gradient-material.js index 6a5a9e9a..f7e28083 100755 --- a/js/lib/rdge/materials/radial-gradient-material.js +++ b/js/lib/rdge/materials/radial-gradient-material.js @@ -47,17 +47,17 @@ var RadialGradientMaterial = function RadialGradientMaterial() { this._defaultColorStop2 = 0.3; this._defaultColorStop3 = 0.6; this._defaultColorStop4 = 1.0; - // this._defaultColorCount = 4; + // this._defaultColorCount = 4; - this._textureTransform = [1,0,0, 0,1,0, 0,0,1]; + this._textureTransform = [1,0,0, 0,1,0, 0,0,1]; /////////////////////////////////////////////////////////////////////// // Property Accessors /////////////////////////////////////////////////////////////////////// - this.isAnimated = function () { return false; }; - this.getShaderDef = function() { return radialGradientMaterialDef; }; + this.isAnimated = function () { return false; }; + this.getShaderDef = function() { return radialGradientMaterialDef; }; /////////////////////////////////////////////////////////////////////// // Material Property Accessors @@ -95,49 +95,49 @@ var RadialGradientMaterial = function RadialGradientMaterial() { this._materialNode.setShader(this._shader); // set the shader values in the shader - this._shader['default'].u_texTransform.set( this._textureTransform ); + this._shader['default'].u_texTransform.set( this._textureTransform ); this.setShaderValues(); }; - this.fitToPrimitive = function( prim ) - { - var bounds = ShapePrimitive.getBounds( prim ); - if (bounds) - { - var dx = Math.abs( bounds[3] - bounds[0] ), - dy = Math.abs( bounds[4] - bounds[1] ); - if (dy == 0) dy = 1.0; - if (dx == 0) dx = 1.0; - var xScale = 2.0, yScale = 2.0; - if (dx > dy) - yScale *= dy/dx; - else - xScale *= dx/dy; - - // build the matrix - the translation to the origin, the scale, - // and the translation back to the center (hard coded at (0.5, 0.5) for now). - // the matrix is build directly instead of with matrix multiplications - // for efficiency, not to mention that the multiplication function does - // not exist for mat3's. - // the matrix as laid out below looks transposed - order is columnwise. - var xCtr = 0.5, yCtr = 0.5; - this._textureTransform = [ - xScale, 0.0, 0.0, - 0.0, yScale, 0.0, - xCtr*(1-xScale), yCtr*(1 - yScale), 1.0 - ]; - - if (this._shader && this._shader['default']) - this._shader['default'].u_texTransform.set( this._textureTransform ); - - } - }; - - this.customExport = function( jObj ) - { - jObj.u_texTransform = this._textureTransform.slice(); - return jObj; - } + this.fitToPrimitive = function( prim ) + { + var bounds = ShapePrimitive.getBounds( prim ); + if (bounds) + { + var dx = Math.abs( bounds[3] - bounds[0] ), + dy = Math.abs( bounds[4] - bounds[1] ); + if (dy == 0) dy = 1.0; + if (dx == 0) dx = 1.0; + var xScale = 2.0, yScale = 2.0; + if (dx > dy) + yScale *= dy/dx; + else + xScale *= dx/dy; + + // build the matrix - the translation to the origin, the scale, + // and the translation back to the center (hard coded at (0.5, 0.5) for now). + // the matrix is build directly instead of with matrix multiplications + // for efficiency, not to mention that the multiplication function does + // not exist for mat3's. + // the matrix as laid out below looks transposed - order is columnwise. + var xCtr = 0.5, yCtr = 0.5; + this._textureTransform = [ + xScale, 0.0, 0.0, + 0.0, yScale, 0.0, + xCtr*(1-xScale), yCtr*(1 - yScale), 1.0 + ]; + + if (this._shader && this._shader['default']) + this._shader['default'].u_texTransform.set( this._textureTransform ); + + } + }; + + this.customExport = function( jObj ) + { + jObj.u_texTransform = this._textureTransform.slice(); + return jObj; + } }; /////////////////////////////////////////////////////////////////////////////////////// @@ -146,48 +146,48 @@ var RadialGradientMaterial = function RadialGradientMaterial() { // shader spec (can also be loaded from a .JSON file, or constructed at runtime) var radialGradientMaterialDef = { 'shaders': - { - 'defaultVShader': "assets/shaders/radialGradient.vert.glsl", - 'defaultFShader': "assets/shaders/radialGradient.frag.glsl" - }, + { + 'defaultVShader': "assets/shaders/radialGradient.vert.glsl", + 'defaultFShader': "assets/shaders/radialGradient.frag.glsl" + }, 'techniques': - { - 'default': - [ - { - 'vshader': 'defaultVShader', - 'fshader': 'defaultFShader', - // attributes - 'attributes': - { - 'vert': { 'type': 'vec3' }, - 'normal': { 'type': 'vec3' }, - 'texcoord': { 'type': 'vec2' } - }, - // parameters - 'params': - { - 'u_color1': { 'type': 'vec4' }, - 'u_color2': { 'type': 'vec4' }, - 'u_color3': { 'type': 'vec4' }, - 'u_color4': { 'type': 'vec4' }, - 'u_colorStop1': { 'type': 'float' }, - 'u_colorStop2': { 'type': 'float' }, - 'u_colorStop3': { 'type': 'float' }, - 'u_colorStop4': { 'type': 'float' }, - 'u_texTransform': { 'type' : 'mat3' } - //'u_colorCount': {'type' : 'int' } - }, - - // render states - 'states': - { - 'depthEnable': true, - 'offset': [1.0, 0.1] - } - } - ] - } + { + 'default': + [ + { + 'vshader': 'defaultVShader', + 'fshader': 'defaultFShader', + // attributes + 'attributes': + { + 'vert': { 'type': 'vec3' }, + 'normal': { 'type': 'vec3' }, + 'texcoord': { 'type': 'vec2' } + }, + // parameters + 'params': + { + 'u_color1': { 'type': 'vec4' }, + 'u_color2': { 'type': 'vec4' }, + 'u_color3': { 'type': 'vec4' }, + 'u_color4': { 'type': 'vec4' }, + 'u_colorStop1': { 'type': 'float' }, + 'u_colorStop2': { 'type': 'float' }, + 'u_colorStop3': { 'type': 'float' }, + 'u_colorStop4': { 'type': 'float' }, + 'u_texTransform': { 'type' : 'mat3' } + //'u_colorCount': {'type' : 'int' } + }, + + // render states + 'states': + { + 'depthEnable': true, + 'offset': [1.0, 0.1] + } + } + ] + } }; RadialGradientMaterial.prototype = new Material(); -- cgit v1.2.3 From 04343eda8c2f870b0da55cfdc8003c99fe1cc4de Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:53:10 -0700 Subject: Remove trailing spaces --- js/lib/rdge/materials/radial-gradient-material.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/lib/rdge/materials/radial-gradient-material.js') diff --git a/js/lib/rdge/materials/radial-gradient-material.js b/js/lib/rdge/materials/radial-gradient-material.js index f7e28083..ab7cf484 100755 --- a/js/lib/rdge/materials/radial-gradient-material.js +++ b/js/lib/rdge/materials/radial-gradient-material.js @@ -54,7 +54,7 @@ var RadialGradientMaterial = function RadialGradientMaterial() { /////////////////////////////////////////////////////////////////////// // Property Accessors /////////////////////////////////////////////////////////////////////// - + this.isAnimated = function () { return false; }; this.getShaderDef = function() { return radialGradientMaterialDef; }; @@ -126,9 +126,9 @@ var RadialGradientMaterial = function RadialGradientMaterial() { 0.0, yScale, 0.0, xCtr*(1-xScale), yCtr*(1 - yScale), 1.0 ]; - + if (this._shader && this._shader['default']) - this._shader['default'].u_texTransform.set( this._textureTransform ); + this._shader['default'].u_texTransform.set( this._textureTransform ); } }; -- cgit v1.2.3