Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions docs/api/textures/Texture.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,21 @@ <h3>[property:number rotation]</h3>

<h3>[property:Vector2 center]</h3>
<p>
Indicates where the center of rotation is. To rotate around the center point set this value to (0.5, 0.5). Default value is (0.0, 0.0).
The point around which rotation occurs. A value of (0.5, 0.5) corresponds to the center of the texture. Default is (0, 0), the lower left.
</p>

<h3>[property:boolean matrixAutoUpdate]</h3>
<p>
Whether to update the texture's uv-transform [property:Matrix3 matrix] based on the [property:Vector2 offset],
[property:Vector2 repeat], and [property:number rotation] settings. True by default.
Whether to update the texture's uv-transform [page:Texture.matrix .matrix] from the texture properties [page:Texture.offset .offset], [page:Texture.repeat .repeat],
[page:Texture.rotation .rotation], and [page:Texture.center .center]. True by default.
Set this to false if you are specifying the uv-transform matrix directly.
</p>

<h3>[property:Matrix3 matrix]</h3>
<p>
The uv-transform matrix for the texture. Updated by the renderer from the texture properties [property:Vector2 offset], [property:Vector2 repeat],
and [property:number rotation] when the texture's [property:boolean matrixAutoUpdate] property is true.
When [property:boolean matrixAutoUpdate] property is false, this matrix may be set manually.
The uv-transform matrix for the texture. Updated by the renderer from the texture properties [page:Texture.offset .offset], [page:Texture.repeat .repeat],
[page:Texture.rotation .rotation], and [page:Texture.center .center] when the texture's [page:Texture.matrixAutoUpdate .matrixAutoUpdate] property is true.
When [page:Texture.matrixAutoUpdate .matrixAutoUpdate] property is false, this matrix may be set manually.
Default is the identity matrix.
</p>

Expand Down Expand Up @@ -228,6 +228,12 @@ <h2>Methods</h2>

<h3>[page:EventDispatcher EventDispatcher] methods are available on this class.</h3>

<h3>[method:null updateMatrix]()</h3>
<p>
Update the texture's uv-transform [page:Texture.matrix .matrix] from the texture properties [page:Texture.offset .offset], [page:Texture.repeat .repeat],
[page:Texture.rotation .rotation], and [page:Texture.center .center].
</p>

<h3>[method:Texture clone]( [param:Texture texture] )</h3>
<p>
Make copy of the texture. Note this is not a "deep copy", the image is shared.
Expand All @@ -246,7 +252,7 @@ <h3>[method:null dispose]()</h3>

<h3>[method:null transformUv]( uv )</h3>
<p>
Transform the uv based on the value of this texture's [page:Texture.repeat .repeat], [page:Texture.offset .offset],
Transform the uv based on the value of this texture's [page:Texture.offset .offset], [page:Texture.repeat .repeat],
[page:Texture.wrapS .wrapS], [page:Texture.wrapT .wrapT] and [page:Texture.flipY .flipY] properties.
</p>

Expand Down
14 changes: 2 additions & 12 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2050,12 +2050,7 @@ function WebGLRenderer( parameters ) {

if ( uvScaleMap.matrixAutoUpdate === true ) {

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 );
uvScaleMap.updateMatrix();

}

Expand Down Expand Up @@ -2093,12 +2088,7 @@ function WebGLRenderer( parameters ) {

if ( material.map.matrixAutoUpdate === true ) {

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 );
material.map.updateMatrix();

}

Expand Down
6 changes: 6 additions & 0 deletions src/textures/Texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {

isTexture: true,

updateMatrix: function () {

this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );

},

clone: function () {

return new this.constructor().copy( this );
Expand Down