Browse Source

TextureNode: Improve error message (#30215)

sunag 1 year ago
parent
commit
0eaea73432
1 changed files with 11 additions and 8 deletions
  1. 11 8
      src/nodes/accessors/TextureNode.js

+ 11 - 8
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' ) {

粤ICP备19079148号