瀏覽代碼

TextureNode: Introduce `referenceNode` (#27986)

sunag 1 年之前
父節點
當前提交
11e7114243
共有 1 個文件被更改,包括 29 次插入0 次删除
  1. 29 0
      examples/jsm/nodes/accessors/TextureNode.js

+ 29 - 0
examples/jsm/nodes/accessors/TextureNode.js

@@ -25,10 +25,34 @@ class TextureNode extends UniformNode {
 		this.updateMatrix = false;
 		this.updateType = NodeUpdateType.NONE;
 
+		this.referenceNode = null;
+
+		this._value = value;
+
 		this.setUpdateMatrix( uvNode === null );
 
 	}
 
+	set value( value ) {
+
+		if ( this.referenceNode ) {
+
+			this.referenceNode.value = value;
+
+		} else {
+
+			this._value = value;
+
+		}
+
+	}
+
+	get value() {
+
+		return this.referenceNode ? this.referenceNode.value : this._value;
+
+	}
+
 	getUniformHash( /*builder*/ ) {
 
 		return this.value.uuid;
@@ -258,6 +282,7 @@ class TextureNode extends UniformNode {
 
 		const textureNode = this.clone();
 		textureNode.uvNode = uvNode;
+		textureNode.referenceNode = this;
 
 		return nodeObject( textureNode );
 
@@ -267,6 +292,7 @@ class TextureNode extends UniformNode {
 
 		const textureNode = this.clone();
 		textureNode.levelNode = levelNode.mul( maxMipLevel( textureNode ) );
+		textureNode.referenceNode = this;
 
 		return nodeObject( textureNode );
 
@@ -276,6 +302,7 @@ class TextureNode extends UniformNode {
 
 		const textureNode = this.clone();
 		textureNode.levelNode = levelNode;
+		textureNode.referenceNode = this;
 
 		return textureNode;
 
@@ -291,6 +318,7 @@ class TextureNode extends UniformNode {
 
 		const textureNode = this.clone();
 		textureNode.compareNode = nodeObject( compareNode );
+		textureNode.referenceNode = this;
 
 		return nodeObject( textureNode );
 
@@ -300,6 +328,7 @@ class TextureNode extends UniformNode {
 
 		const textureNode = this.clone();
 		textureNode.depthNode = nodeObject( depthNode );
+		textureNode.referenceNode = this;
 
 		return nodeObject( textureNode );