@@ -548,7 +548,7 @@ class TextureNode extends UniformNode {
548548
549549 const textureNode = this . clone ( ) ;
550550 textureNode . uvNode = nodeObject ( uvNode ) ;
551- textureNode . referenceNode = this . getSelf ( ) ;
551+ textureNode . referenceNode = this . getBase ( ) ;
552552
553553 return nodeObject ( textureNode ) ;
554554
@@ -576,7 +576,7 @@ class TextureNode extends UniformNode {
576576
577577 const textureNode = this . clone ( ) ;
578578 textureNode . biasNode = nodeObject ( amountNode ) . mul ( maxMipLevel ( textureNode ) ) ;
579- textureNode . referenceNode = this . getSelf ( ) ;
579+ textureNode . referenceNode = this . getBase ( ) ;
580580
581581 const map = textureNode . value ;
582582
@@ -602,7 +602,7 @@ class TextureNode extends UniformNode {
602602
603603 const textureNode = this . clone ( ) ;
604604 textureNode . levelNode = nodeObject ( levelNode ) ;
605- textureNode . referenceNode = this . getSelf ( ) ;
605+ textureNode . referenceNode = this . getBase ( ) ;
606606
607607 return nodeObject ( textureNode ) ;
608608
@@ -630,12 +630,22 @@ class TextureNode extends UniformNode {
630630
631631 const textureNode = this . clone ( ) ;
632632 textureNode . biasNode = nodeObject ( biasNode ) ;
633- textureNode . referenceNode = this . getSelf ( ) ;
633+ textureNode . referenceNode = this . getBase ( ) ;
634634
635635 return nodeObject ( textureNode ) ;
636636
637637 }
638638
639+ /**
640+ * Returns the base texture of this node.
641+ * @return {TextureNode } The base texture node.
642+ */
643+ getBase ( ) {
644+
645+ return this . referenceNode ? this . referenceNode . getBase ( ) : this . getSelf ( ) ;
646+
647+ }
648+
639649 /**
640650 * Samples the texture by executing a compare operation.
641651 *
@@ -646,7 +656,7 @@ class TextureNode extends UniformNode {
646656
647657 const textureNode = this . clone ( ) ;
648658 textureNode . compareNode = nodeObject ( compareNode ) ;
649- textureNode . referenceNode = this . getSelf ( ) ;
659+ textureNode . referenceNode = this . getBase ( ) ;
650660
651661 return nodeObject ( textureNode ) ;
652662
@@ -663,7 +673,7 @@ class TextureNode extends UniformNode {
663673
664674 const textureNode = this . clone ( ) ;
665675 textureNode . gradNode = [ nodeObject ( gradNodeX ) , nodeObject ( gradNodeY ) ] ;
666- textureNode . referenceNode = this . getSelf ( ) ;
676+ textureNode . referenceNode = this . getBase ( ) ;
667677
668678 return nodeObject ( textureNode ) ;
669679
@@ -679,7 +689,7 @@ class TextureNode extends UniformNode {
679689
680690 const textureNode = this . clone ( ) ;
681691 textureNode . depthNode = nodeObject ( depthNode ) ;
682- textureNode . referenceNode = this . getSelf ( ) ;
692+ textureNode . referenceNode = this . getBase ( ) ;
683693
684694 return nodeObject ( textureNode ) ;
685695
@@ -779,7 +789,7 @@ export const texture = ( value = EmptyTexture, uvNode = null, levelNode = null,
779789 if ( value && value . isTextureNode === true ) {
780790
781791 textureNode = nodeObject ( value . clone ( ) ) ;
782- textureNode . referenceNode = value . getSelf ( ) ; // Ensure the reference is set to the original node
792+ textureNode . referenceNode = value . getBase ( ) ; // Ensure the reference is set to the original node
783793
784794 if ( uvNode !== null ) textureNode . uvNode = nodeObject ( uvNode ) ;
785795 if ( levelNode !== null ) textureNode . levelNode = nodeObject ( levelNode ) ;
0 commit comments