Skip to content

Commit f78867d

Browse files
authored
TSL: Replace Proxy approach with prototypes (#31691)
* remove `Proxy` approach * Update TSLCore.js * Node: Remove`.getSelf()` * Update TSLCore.js
1 parent d40e752 commit f78867d

File tree

11 files changed

+199
-100
lines changed

11 files changed

+199
-100
lines changed

src/nodes/accessors/CubeTextureNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export const cubeTexture = ( value = EmptyTexture, uvNode = null, levelNode = nu
162162
if ( value && value.isCubeTextureNode === true ) {
163163

164164
textureNode = nodeObject( value.clone() );
165-
textureNode.referenceNode = value.getSelf(); // Ensure the reference is set to the original node
165+
textureNode.referenceNode = value; // Ensure the reference is set to the original node
166166

167167
if ( uvNode !== null ) textureNode.uvNode = nodeObject( uvNode );
168168
if ( levelNode !== null ) textureNode.levelNode = nodeObject( levelNode );

src/nodes/accessors/ReferenceBaseNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class ReferenceBaseNode extends Node {
211211
*/
212212
setNodeType( uniformType ) {
213213

214-
const node = uniform( null, uniformType ).getSelf();
214+
const node = uniform( null, uniformType );
215215

216216
if ( this.group !== null ) {
217217

src/nodes/accessors/ReferenceNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class ReferenceNode extends Node {
284284

285285
if ( this.name !== null ) node.setName( this.name );
286286

287-
this.node = node.getSelf();
287+
this.node = node;
288288

289289
}
290290

src/nodes/accessors/TextureNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ class TextureNode extends UniformNode {
667667
*/
668668
getBase() {
669669

670-
return this.referenceNode ? this.referenceNode.getBase() : this.getSelf();
670+
return this.referenceNode ? this.referenceNode.getBase() : this;
671671

672672
}
673673

src/nodes/core/Node.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class Node extends EventDispatcher {
172172
onUpdate( callback, updateType ) {
173173

174174
this.updateType = updateType;
175-
this.update = callback.bind( this.getSelf() );
175+
this.update = callback.bind( this );
176176

177177
return this;
178178

@@ -225,26 +225,12 @@ class Node extends EventDispatcher {
225225
*/
226226
onReference( callback ) {
227227

228-
this.updateReference = callback.bind( this.getSelf() );
228+
this.updateReference = callback.bind( this );
229229

230230
return this;
231231

232232
}
233233

234-
/**
235-
* The `this` reference might point to a Proxy so this method can be used
236-
* to get the reference to the actual node instance.
237-
*
238-
* @return {Node} A reference to the node.
239-
*/
240-
getSelf() {
241-
242-
// Returns non-node object.
243-
244-
return this.self || this;
245-
246-
}
247-
248234
/**
249235
* Nodes might refer to other objects like materials. This method allows to dynamically update the reference
250236
* to such objects based on a given state (e.g. the current node frame or builder).

src/nodes/core/NodeBuilder.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ class NodeBuilder {
729729

730730
if ( updateType !== NodeUpdateType.NONE ) {
731731

732-
this.updateNodes.push( node.getSelf() );
732+
this.updateNodes.push( node );
733733

734734
}
735735

@@ -742,13 +742,13 @@ class NodeBuilder {
742742

743743
if ( updateBeforeType !== NodeUpdateType.NONE ) {
744744

745-
this.updateBeforeNodes.push( node.getSelf() );
745+
this.updateBeforeNodes.push( node );
746746

747747
}
748748

749749
if ( updateAfterType !== NodeUpdateType.NONE ) {
750750

751-
this.updateAfterNodes.push( node.getSelf() );
751+
this.updateAfterNodes.push( node );
752752

753753
}
754754

src/nodes/core/NodeUniform.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class NodeUniform {
4343
*
4444
* @type {UniformNode}
4545
*/
46-
this.node = node.getSelf();
46+
this.node = node;
4747

4848
}
4949

src/nodes/core/NodeUtils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export function getCacheKey( object, force = false ) {
8888
if ( object.isNode === true ) {
8989

9090
values.push( object.id );
91-
object = object.getSelf();
9291

9392
}
9493

@@ -113,7 +112,7 @@ export function getCacheKey( object, force = false ) {
113112
*/
114113
export function* getNodeChildren( node, toJSON = false ) {
115114

116-
for ( const property in node ) {
115+
for ( const property of Object.getOwnPropertyNames( node ) ) {
117116

118117
// Ignore private properties.
119118
if ( property.startsWith( '_' ) === true ) continue;

src/nodes/core/UniformNode.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,11 @@ class UniformNode extends InputNode {
123123

124124
onUpdate( callback, updateType ) {
125125

126-
const self = this.getSelf();
127-
128-
callback = callback.bind( self );
126+
callback = callback.bind( this );
129127

130128
return super.onUpdate( ( frame ) => {
131129

132-
const value = callback( frame, self );
130+
const value = callback( frame, this );
133131

134132
if ( value !== undefined ) {
135133

src/nodes/lighting/LightsNode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class LightsNode extends Node {
159159

160160
for ( const lightNode of this._lightNodes ) {
161161

162-
hash.push( lightNode.getSelf().getHash() );
162+
hash.push( lightNode.getHash() );
163163

164164
}
165165

0 commit comments

Comments
 (0)