Skip to content

Commit

Permalink
TextureNode: Improve error message (mrdoob#30215)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunag authored Dec 26, 2024
1 parent 688976a commit 0eaea73
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/nodes/accessors/TextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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' ) {
Expand Down

0 comments on commit 0eaea73

Please sign in to comment.