diff --git a/examples/jsm/nodes/accessors/CubeTextureNode.js b/examples/jsm/nodes/accessors/CubeTextureNode.js index 3715111b5c44f9..264d4178acd580 100644 --- a/examples/jsm/nodes/accessors/CubeTextureNode.js +++ b/examples/jsm/nodes/accessors/CubeTextureNode.js @@ -26,6 +26,8 @@ class CubeTextureNode extends TextureNode { } + setUpdateMatrix( /*updateMatrix*/ ) { } // Ignore .updateMatrix for CubeTextureNode + generate( builder, output ) { const { uvNode, levelNode } = builder.getNodeProperties( this ); diff --git a/examples/jsm/nodes/accessors/TextureNode.js b/examples/jsm/nodes/accessors/TextureNode.js index 0861014dcb6920..adf586819243c9 100644 --- a/examples/jsm/nodes/accessors/TextureNode.js +++ b/examples/jsm/nodes/accessors/TextureNode.js @@ -20,9 +20,10 @@ class TextureNode extends UniformNode { this.levelNode = levelNode; this.compareNode = compareNode; - this.updateMatrix = uvNode === null; + this.updateMatrix = false; + this.updateType = NodeUpdateType.NONE; - this.setUpdateMatrix( this.updateMatrix ); + this.setUpdateMatrix( uvNode === null ); } @@ -46,13 +47,17 @@ class TextureNode extends UniformNode { } - getDefaultUV( uvNode = null ) { + getDefaultUV() { - const texture = this.value; + return uv( this.value.channel ); + + } - if ( uvNode === null ) uvNode = uv( texture.channel ); + getTextureMatrix( uvNode ) { + + const texture = this.value; - return uniform( texture.matrix ).mul( vec3( uvNode, 1 ) ); + return uniform( texture.matrix ).mul( vec3( uvNode, 1 ) ).xy; } @@ -68,7 +73,6 @@ class TextureNode extends UniformNode { construct( builder ) { const properties = builder.getNodeProperties( this ); - const texture = this.value; // @@ -80,13 +84,11 @@ class TextureNode extends UniformNode { } - if ( this.updateMatrix ) { - - uvNode = this.getDefaultUV( uvNode ); + if ( ! uvNode ) uvNode = this.getDefaultUV(); - } else if ( ! uvNode ) { + if ( this.updateMatrix ) { - uvNode = uv( texture.channel ); + uvNode = this.getTextureMatrix( uvNode ); }