Skip to content

Commit

Permalink
Added center attribute to texture
Browse files Browse the repository at this point in the history
  • Loading branch information
tentone committed Aug 27, 2017
1 parent c318c58 commit 254bc2a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/webgl_materials_texture_rotation.html
Expand Up @@ -129,6 +129,7 @@

texture.offset.set( API.offsetX, API.offsetY );
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 ]

} else {
Expand Down
20 changes: 12 additions & 8 deletions src/renderers/WebGLRenderer.js
Expand Up @@ -1992,10 +1992,12 @@ function WebGLRenderer( parameters ) {

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 );

}

Expand Down Expand Up @@ -2033,10 +2035,12 @@ function WebGLRenderer( parameters ) {

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 );

}

Expand Down
1 change: 1 addition & 0 deletions src/textures/Texture.js
Expand Up @@ -39,6 +39,7 @@ function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, ty

this.offset = new Vector2( 0, 0 );
this.repeat = new Vector2( 1, 1 );
this.center = new Vector2( 0, 0 );
this.rotation = 0;

this.matrixAutoUpdate = true;
Expand Down

0 comments on commit 254bc2a

Please sign in to comment.