aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/radial-gradient-material.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/rdge/materials/radial-gradient-material.js')
-rwxr-xr-xjs/lib/rdge/materials/radial-gradient-material.js50
1 files changed, 48 insertions, 2 deletions
diff --git a/js/lib/rdge/materials/radial-gradient-material.js b/js/lib/rdge/materials/radial-gradient-material.js
index c9c2536f..a5fc2224 100755
--- a/js/lib/rdge/materials/radial-gradient-material.js
+++ b/js/lib/rdge/materials/radial-gradient-material.js
@@ -75,9 +75,25 @@ var RadialGradientMaterial = function RadialGradientMaterial() {
75 this.setShaderValues(); 75 this.setShaderValues();
76 }; 76 };
77 77
78 this.fitToPrimitive = function( prim ) 78 this.resetToDefault = function()
79 {
80 this._propValues[this._propNames[0]] = this._defaultColor1.slice(0);
81 this._propValues[this._propNames[1]] = this._defaultColor2.slice(0);
82 this._propValues[this._propNames[2]] = this._defaultColor3.slice(0);
83 this._propValues[this._propNames[3]] = this._defaultColor4.slice(0);
84
85 this._propValues[this._propNames[4]] = this._defaultColorStop1;
86 this._propValues[this._propNames[5]] = this._defaultColorStop2;
87 this._propValues[this._propNames[6]] = this._defaultColorStop3;
88 this._propValues[this._propNames[7]] = this._defaultColorStop4;
89
90 var nProps = this._propNames.length;
91 for (var i=0; i<nProps; i++)
92 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
93 };
94
95 this.fitToBounds = function( bounds )
79 { 96 {
80 var bounds = ShapePrimitive.getBounds( prim );
81 if (bounds) 97 if (bounds)
82 { 98 {
83 var dx = Math.abs( bounds[3] - bounds[0] ), 99 var dx = Math.abs( bounds[3] - bounds[0] ),
@@ -107,6 +123,36 @@ var RadialGradientMaterial = function RadialGradientMaterial() {
107 this._shader['default'].u_texTransform.set( this._textureTransform ); 123 this._shader['default'].u_texTransform.set( this._textureTransform );
108 124
109 } 125 }
126 }
127
128 this.fitToPrimitiveArray = function( primArray )
129 {
130 if (!primArray) return;
131 var nPrims = primArray.length;
132 if (nPrims == 0) return;
133 var bounds = ShapePrimitive.getBounds( primArray[0] );
134 for (var i=1; i<nPrims; i++)
135 {
136 var prim = primArray[i];
137 var b2 = ShapePrimitive.getBounds( prim );
138
139 // [xMin, yMin, zMin, xMax, yMax, zMax]
140 if (b2[0] < bounds[0]) bounds[0] = b2[0];
141 if (b2[1] < bounds[1]) bounds[1] = b2[1];
142 if (b2[2] < bounds[2]) bounds[2] = b2[2];
143
144 if (b2[3] > bounds[3]) bounds[3] = b2[3];
145 if (b2[4] > bounds[4]) bounds[4] = b2[4];
146 if (b2[5] > bounds[5]) bounds[5] = b2[5];
147 }
148
149 this.fitToBounds( bounds );
150 };
151
152 this.fitToPrimitive = function( prim )
153 {
154 var bounds = ShapePrimitive.getBounds( prim );
155 this.fitToBounds( bounds );
110 }; 156 };
111 157
112 this.customExport = function( jObj ) 158 this.customExport = function( jObj )