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.js51
1 files changed, 49 insertions, 2 deletions
diff --git a/js/lib/rdge/materials/radial-gradient-material.js b/js/lib/rdge/materials/radial-gradient-material.js
index ffca1686..6ce28ae4 100755
--- a/js/lib/rdge/materials/radial-gradient-material.js
+++ b/js/lib/rdge/materials/radial-gradient-material.js
@@ -99,9 +99,26 @@ var RadialGradientMaterial = function RadialGradientMaterial() {
99 this.setShaderValues(); 99 this.setShaderValues();
100 }; 100 };
101 101
102 this.fitToPrimitive = function( prim ) 102 this.resetToDefault = function()
103 {
104 this._propValues[this._propNames[0]] = this._defaultColor1.slice(0);
105 this._propValues[this._propNames[1]] = this._defaultColor2.slice(0);
106 this._propValues[this._propNames[2]] = this._defaultColor3.slice(0);
107 this._propValues[this._propNames[3]] = this._defaultColor4.slice(0);
108
109 this._propValues[this._propNames[4]] = this._defaultColorStop1;
110 this._propValues[this._propNames[5]] = this._defaultColorStop2;
111 this._propValues[this._propNames[6]] = this._defaultColorStop3;
112 this._propValues[this._propNames[7]] = this._defaultColorStop4;
113
114 var nProps = this._propNames.length;
115 for (var i=0; i<nProps; i++) {
116 this.setProperty( this._propNames[i], this._propValues[this._propNames[i]] );
117 }
118 };
119
120 this.fitToBounds = function( bounds )
103 { 121 {
104 var bounds = ShapePrimitive.getBounds( prim );
105 if (bounds) 122 if (bounds)
106 { 123 {
107 var dx = Math.abs( bounds[3] - bounds[0] ), 124 var dx = Math.abs( bounds[3] - bounds[0] ),
@@ -133,6 +150,36 @@ var RadialGradientMaterial = function RadialGradientMaterial() {
133 } 150 }
134 }; 151 };
135 152
153 this.fitToPrimitiveArray = function( primArray )
154 {
155 if (!primArray) return;
156 var nPrims = primArray.length;
157 if (nPrims == 0) return;
158 var bounds = ShapePrimitive.getBounds( primArray[0] );
159 for (var i=1; i<nPrims; i++)
160 {
161 var prim = primArray[i];
162 var b2 = ShapePrimitive.getBounds( prim );
163
164 // [xMin, yMin, zMin, xMax, yMax, zMax]
165 if (b2[0] < bounds[0]) bounds[0] = b2[0];
166 if (b2[1] < bounds[1]) bounds[1] = b2[1];
167 if (b2[2] < bounds[2]) bounds[2] = b2[2];
168
169 if (b2[3] > bounds[3]) bounds[3] = b2[3];
170 if (b2[4] > bounds[4]) bounds[4] = b2[4];
171 if (b2[5] > bounds[5]) bounds[5] = b2[5];
172 }
173
174 this.fitToBounds( bounds );
175 };
176
177 this.fitToPrimitive = function( prim )
178 {
179 var bounds = ShapePrimitive.getBounds( prim );
180 this.fitToBounds( bounds );
181 };
182
136 this.customExport = function( jObj ) 183 this.customExport = function( jObj )
137 { 184 {
138 jObj.u_texTransform = this._textureTransform.slice(); 185 jObj.u_texTransform = this._textureTransform.slice();