From 0eaea73432677f73fe71edfe6e8daf08f4b5412a Mon Sep 17 00:00:00 2001 From: sunag Date: Thu, 26 Dec 2024 16:53:54 -0300 Subject: [PATCH] TextureNode: Improve error message (#30215) --- src/nodes/accessors/TextureNode.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/nodes/accessors/TextureNode.js b/src/nodes/accessors/TextureNode.js index c8d0f2d792e790..9ca3181f807f46 100644 --- a/src/nodes/accessors/TextureNode.js +++ b/src/nodes/accessors/TextureNode.js @@ -316,6 +316,16 @@ class TextureNode extends UniformNode { // + const texture = this.value; + + if ( ! texture || texture.isTexture !== true ) { + + throw new Error( 'THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().' ); + + } + + // + let uvNode = this.uvNode; if ( ( uvNode === null || builder.context.forceUVContext === true ) && builder.context.getUV ) { @@ -426,16 +436,9 @@ class TextureNode extends UniformNode { */ generate( builder, output ) { - const properties = builder.getNodeProperties( this ); - const texture = this.value; - if ( ! texture || texture.isTexture !== true ) { - - throw new Error( 'TextureNode: Need a three.js texture.' ); - - } - + const properties = builder.getNodeProperties( this ); const textureProperty = super.generate( builder, 'property' ); if ( output === 'sampler' ) {