Browse Source

Added center attribute to texture

Tentone 8 years ago
parent
commit
254bc2a73e

+ 1 - 0
examples/webgl_materials_texture_rotation.html

@@ -129,6 +129,7 @@
 
 
 					texture.offset.set( API.offsetX, API.offsetY );
 					texture.offset.set( API.offsetX, API.offsetY );
 					texture.repeat.set( API.repeatX, API.repeatY );
 					texture.repeat.set( API.repeatX, API.repeatY );
+					texture.center.set( API.centerX, API.centerY );
 					texture.rotation = API.rotation; // rotation is around [ 0.5, 0.5 ]
 					texture.rotation = API.rotation; // rotation is around [ 0.5, 0.5 ]
 
 
 				} else {
 				} else {

+ 12 - 8
src/renderers/WebGLRenderer.js

@@ -1992,10 +1992,12 @@ function WebGLRenderer( parameters ) {
 
 
 			if ( uvScaleMap.matrixAutoUpdate === true ) {
 			if ( uvScaleMap.matrixAutoUpdate === true ) {
 
 
-			    var offset = uvScaleMap.offset;
-			    var repeat = uvScaleMap.repeat;
-			    var rotation = uvScaleMap.rotation;
-			    uvScaleMap.matrix.setUvTransform( offset.x, offset.y, repeat.x, repeat.y, rotation, 0.0, 0.0 );
+				var offset = uvScaleMap.offset;
+				var repeat = uvScaleMap.repeat;
+				var rotation = uvScaleMap.rotation;
+				var center = uvScaleMap.center;
+				
+				uvScaleMap.matrix.setUvTransform( offset.x, offset.y, repeat.x, repeat.y, rotation, center.x, center.y );
 
 
 			}
 			}
 
 
@@ -2033,10 +2035,12 @@ function WebGLRenderer( parameters ) {
 
 
 			if ( material.map.matrixAutoUpdate === true ) {
 			if ( material.map.matrixAutoUpdate === true ) {
 
 
-			    var offset = material.map.offset;
-			    var repeat = material.map.repeat;
-			    var rotation = material.map.rotation;
-			    material.map.matrix.setUvTransform( offset.x, offset.y, repeat.x, repeat.y, rotation, 0.0, 0.0 );
+				var offset = material.map.offset;
+				var repeat = material.map.repeat;
+				var rotation = material.map.rotation;
+				var center = material.map.center;
+
+				material.map.matrix.setUvTransform( offset.x, offset.y, repeat.x, repeat.y, rotation, center.x, center.y );
 
 
 			}
 			}
 
 

+ 1 - 0
src/textures/Texture.js

@@ -39,6 +39,7 @@ function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, ty
 
 
 	this.offset = new Vector2( 0, 0 );
 	this.offset = new Vector2( 0, 0 );
 	this.repeat = new Vector2( 1, 1 );
 	this.repeat = new Vector2( 1, 1 );
+	this.center = new Vector2( 0, 0 );
 	this.rotation = 0;
 	this.rotation = 0;
 
 
 	this.matrixAutoUpdate = true;
 	this.matrixAutoUpdate = true;