Skip to content

Commit

Permalink
TSL: Fix texture matrix reference (mrdoob#28801)
Browse files Browse the repository at this point in the history
* fix texture matrix

* optimize reference update

* cleanup
  • Loading branch information
sunag committed Jul 4, 2024
1 parent 913edeb commit a6f87ff
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/nodes/accessors/TextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class TextureNode extends UniformNode {
this.referenceNode = null;

this._value = value;
this._matrixValue = null;

this.setUpdateMatrix( uvNode === null );

Expand Down Expand Up @@ -101,9 +102,10 @@ class TextureNode extends UniformNode {

getTransformedUV( uvNode ) {

const texture = this.value;
if ( this._matrixValue === null ) this._matrixValue = uniform( this.value.matrix );

return this._matrixValue.mul( vec3( uvNode, 1 ) ).xy;

return uniform( texture.matrix ).mul( vec3( uvNode, 1 ) ).xy;

}

Expand Down Expand Up @@ -399,6 +401,9 @@ class TextureNode extends UniformNode {
update() {

const texture = this.value;
const matrixTexture = this._matrixValue;

if ( matrixTexture !== null ) matrixTexture.value = texture.matrix;

if ( texture.matrixAutoUpdate === true ) {

Expand Down

0 comments on commit a6f87ff

Please sign in to comment.