Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/webgpu_instance_uniform.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@

// Materials

const instanceUniform = nodeObject( new InstanceUniformNode() );
const instanceUniform = new InstanceUniformNode();
const cubeTextureNode = cubeTexture( cTexture );

const material = new THREE.MeshBasicNodeMaterial();
Expand Down
4 changes: 2 additions & 2 deletions src/loaders/nodes/NodeLoader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { nodeObject, float } from '../../nodes/tsl/TSLBase.js';
import { float } from '../../nodes/tsl/TSLBase.js';

import { Loader } from '../Loader.js';
import { FileLoader } from '../../loaders/FileLoader.js';
Expand Down Expand Up @@ -185,7 +185,7 @@ class NodeLoader extends Loader {

}

return nodeObject( new this.nodes[ type ]() );
return new this.nodes[ type ]();

}

Expand Down
3 changes: 1 addition & 2 deletions src/nodes/accessors/BufferNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import UniformNode from '../core/UniformNode.js';
import { nodeObject } from '../tsl/TSLBase.js';

/**
* A special type of uniform node which represents array-like data
Expand Down Expand Up @@ -126,4 +125,4 @@ export default BufferNode;
* @param {number} count - The count of buffer elements.
* @returns {BufferNode}
*/
export const buffer = ( value, type, count ) => nodeObject( new BufferNode( value, type, count ) );
export const buffer = ( value, type, count ) => new BufferNode( value, type, count );
8 changes: 4 additions & 4 deletions src/nodes/accessors/ClippingNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import Node from '../core/Node.js';
import { nodeObject, Fn, bool, float } from '../tsl/TSLBase.js';
import { Fn, bool, float } from '../tsl/TSLBase.js';
import { positionView } from './Position.js';
import { diffuseColor } from '../core/PropertyNode.js';
import { Loop } from '../utils/LoopNode.js';
Expand Down Expand Up @@ -234,7 +234,7 @@ export default ClippingNode;
* @function
* @returns {ClippingNode}
*/
export const clipping = () => nodeObject( new ClippingNode() );
export const clipping = () => new ClippingNode();

/**
* TSL function for setting up alpha to coverage.
Expand All @@ -243,7 +243,7 @@ export const clipping = () => nodeObject( new ClippingNode() );
* @function
* @returns {ClippingNode}
*/
export const clippingAlpha = () => nodeObject( new ClippingNode( ClippingNode.ALPHA_TO_COVERAGE ) );
export const clippingAlpha = () => new ClippingNode( ClippingNode.ALPHA_TO_COVERAGE );

/**
* TSL function for setting up hardware-based clipping.
Expand All @@ -252,4 +252,4 @@ export const clippingAlpha = () => nodeObject( new ClippingNode( ClippingNode.AL
* @function
* @returns {ClippingNode}
*/
export const hardwareClipping = () => nodeObject( new ClippingNode( ClippingNode.HARDWARE ) );
export const hardwareClipping = () => new ClippingNode( ClippingNode.HARDWARE );
3 changes: 1 addition & 2 deletions src/nodes/accessors/MaterialReferenceNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ReferenceNode from './ReferenceNode.js';
import { nodeObject } from '../tsl/TSLBase.js';

/**
* This node is a special type of reference node which is intended
Expand Down Expand Up @@ -82,4 +81,4 @@ export default MaterialReferenceNode;
* When no material is set, the node refers to the material of the current rendered object.
* @returns {MaterialReferenceNode}
*/
export const materialReference = ( name, type, material = null ) => nodeObject( new MaterialReferenceNode( name, type, material ) );
export const materialReference = ( name, type, material = null ) => new MaterialReferenceNode( name, type, material );
6 changes: 3 additions & 3 deletions src/nodes/accessors/ReferenceBaseNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class ReferenceBaseNode extends Node {
*/
element( indexNode ) {

return nodeObject( new ReferenceElementNode( this, nodeObject( indexNode ) ) );
return new ReferenceElementNode( this, nodeObject( indexNode ) );

}

Expand Down Expand Up @@ -340,7 +340,7 @@ export default ReferenceBaseNode;
* @param {Object} object - The object the property belongs to.
* @returns {ReferenceBaseNode}
*/
export const reference = ( name, type, object ) => nodeObject( new ReferenceBaseNode( name, type, object ) );
export const reference = ( name, type, object ) => new ReferenceBaseNode( name, type, object );

/**
* TSL function for creating a reference base node. Use this function if you want need a reference
Expand All @@ -354,4 +354,4 @@ export const reference = ( name, type, object ) => nodeObject( new ReferenceBase
* @param {Object} [object] - An array-like object the property belongs to.
* @returns {ReferenceBaseNode}
*/
export const referenceBuffer = ( name, type, count, object ) => nodeObject( new ReferenceBaseNode( name, type, object, count ) );
export const referenceBuffer = ( name, type, count, object ) => new ReferenceBaseNode( name, type, object, count );
6 changes: 3 additions & 3 deletions src/nodes/accessors/ReferenceNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class ReferenceNode extends Node {
*/
element( indexNode ) {

return nodeObject( new ReferenceElementNode( this, nodeObject( indexNode ) ) );
return new ReferenceElementNode( this, nodeObject( indexNode ) );

}

Expand Down Expand Up @@ -407,7 +407,7 @@ export default ReferenceNode;
* @param {?Object} [object] - The object the property belongs to.
* @returns {ReferenceNode}
*/
export const reference = ( name, type, object ) => nodeObject( new ReferenceNode( name, type, object ) );
export const reference = ( name, type, object ) => new ReferenceNode( name, type, object );

/**
* TSL function for creating a reference node. Use this function if you want need a reference
Expand All @@ -421,4 +421,4 @@ export const reference = ( name, type, object ) => nodeObject( new ReferenceNode
* @param {Object} object - An array-like object the property belongs to.
* @returns {ReferenceNode}
*/
export const referenceBuffer = ( name, type, count, object ) => nodeObject( new ReferenceNode( name, type, object, count ) );
export const referenceBuffer = ( name, type, count, object ) => new ReferenceNode( name, type, object, count );
3 changes: 1 addition & 2 deletions src/nodes/accessors/RendererReferenceNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ReferenceBaseNode from './ReferenceBaseNode.js';
import { nodeObject } from '../tsl/TSLCore.js';
import { renderGroup } from '../core/UniformGroupNode.js';

/**
Expand Down Expand Up @@ -76,4 +75,4 @@ export default RendererReferenceNode;
* the node refers to the renderer of the current state.
* @returns {RendererReferenceNode}
*/
export const rendererReference = ( name, type, renderer = null ) => nodeObject( new RendererReferenceNode( name, type, renderer ) );
export const rendererReference = ( name, type, renderer = null ) => new RendererReferenceNode( name, type, renderer );
2 changes: 1 addition & 1 deletion src/nodes/accessors/SkinningNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export default SkinningNode;
* @param {SkinnedMesh} skinnedMesh - The skinned mesh.
* @returns {SkinningNode}
*/
export const skinning = ( skinnedMesh ) => nodeObject( new SkinningNode( skinnedMesh ) );
export const skinning = ( skinnedMesh ) => new SkinningNode( skinnedMesh );

/**
* TSL function for computing skinning.
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/accessors/StorageBufferNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BufferNode from './BufferNode.js';
import { bufferAttribute } from './BufferAttributeNode.js';
import { nodeObject, varying } from '../tsl/TSLBase.js';
import { varying } from '../tsl/TSLBase.js';
import { storageElement } from '../utils/StorageArrayElementNode.js';
import { NodeAccess } from '../core/constants.js';
import { getTypeFromLength } from '../core/NodeUtils.js';
Expand Down Expand Up @@ -397,7 +397,7 @@ export default StorageBufferNode;
* @param {number} [count=0] - The buffer count.
* @returns {StorageBufferNode}
*/
export const storage = ( value, type = null, count = 0 ) => nodeObject( new StorageBufferNode( value, type, count ) );
export const storage = ( value, type = null, count = 0 ) => new StorageBufferNode( value, type, count );

/**
* @tsl
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/accessors/UniformArrayNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class UniformArrayNode extends BufferNode {
*/
element( indexNode ) {

return nodeObject( new UniformArrayElementNode( this, nodeObject( indexNode ) ) );
return new UniformArrayElementNode( this, nodeObject( indexNode ) );

}

Expand All @@ -345,4 +345,4 @@ export default UniformArrayNode;
* @param {?string} [nodeType] - The data type of the array elements.
* @returns {UniformArrayNode}
*/
export const uniformArray = ( values, nodeType ) => nodeObject( new UniformArrayNode( values, nodeType ) );
export const uniformArray = ( values, nodeType ) => new UniformArrayNode( values, nodeType );
3 changes: 1 addition & 2 deletions src/nodes/accessors/UserDataNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ReferenceNode from './ReferenceNode.js';
import { nodeObject } from '../tsl/TSLBase.js';

/**
* A special type of reference node that allows to link values in
Expand Down Expand Up @@ -74,4 +73,4 @@ export default UserDataNode;
* @param {?Object} userData - A reference to the `userData` object. If not provided, the `userData` property of the 3D object that uses the node material is evaluated.
* @returns {UserDataNode}
*/
export const userData = ( name, inputType, userData ) => nodeObject( new UserDataNode( name, inputType, userData ) );
export const userData = ( name, inputType, userData ) => new UserDataNode( name, inputType, userData );
3 changes: 1 addition & 2 deletions src/nodes/accessors/VertexColorNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import AttributeNode from '../core/AttributeNode.js';
import { nodeObject } from '../tsl/TSLBase.js';
import { Vector4 } from '../../math/Vector4.js';

/**
Expand Down Expand Up @@ -107,4 +106,4 @@ export default VertexColorNode;
* @param {number} [index=0] - The attribute index.
* @returns {VertexColorNode}
*/
export const vertexColor = ( index = 0 ) => nodeObject( new VertexColorNode( index ) );
export const vertexColor = ( index = 0 ) => new VertexColorNode( index );
3 changes: 1 addition & 2 deletions src/nodes/code/FunctionNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import CodeNode from './CodeNode.js';
import { nodeObject } from '../tsl/TSLBase.js';

/**
* This class represents a native shader function. It can be used to implement
Expand Down Expand Up @@ -170,7 +169,7 @@ const nativeFn = ( code, includes = [], language = '' ) => {

}

const functionNode = nodeObject( new FunctionNode( code, includes, language ) );
const functionNode = new FunctionNode( code, includes, language );

const fn = ( ...params ) => functionNode.call( ...params );
fn.functionNode = functionNode;
Expand Down
4 changes: 2 additions & 2 deletions src/nodes/core/AttributeNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Node from './Node.js';
import { nodeObject, varying } from '../tsl/TSLBase.js';
import { varying } from '../tsl/TSLBase.js';
import { warn } from '../../utils.js';

/**
Expand Down Expand Up @@ -165,4 +165,4 @@ export default AttributeNode;
* @param {?string} [nodeType=null] - The node type.
* @returns {AttributeNode}
*/
export const attribute = ( name, nodeType = null ) => nodeObject( new AttributeNode( name, nodeType ) );
export const attribute = ( name, nodeType = null ) => new AttributeNode( name, nodeType );
3 changes: 1 addition & 2 deletions src/nodes/core/ParameterNode.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { nodeObject } from '../tsl/TSLBase.js';
import { error } from '../../utils.js';
import PropertyNode from './PropertyNode.js';

Expand Down Expand Up @@ -91,4 +90,4 @@ export default ParameterNode;
* @param {?string} name - The name of the parameter in the shader.
* @returns {ParameterNode}
*/
export const parameter = ( type, name ) => nodeObject( new ParameterNode( type, name ) );
export const parameter = ( type, name ) => new ParameterNode( type, name );
6 changes: 3 additions & 3 deletions src/nodes/core/PropertyNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Node from './Node.js';
import { nodeImmutable, nodeObject } from '../tsl/TSLCore.js';
import { nodeImmutable } from '../tsl/TSLCore.js';
import { hashString } from './NodeUtils.js';

/**
Expand Down Expand Up @@ -113,7 +113,7 @@ export default PropertyNode;
* @param {?string} [name=null] - The name of the property in the shader.
* @returns {PropertyNode}
*/
export const property = ( type, name ) => nodeObject( new PropertyNode( type, name ) );
export const property = ( type, name ) => new PropertyNode( type, name );

/**
* TSL function for creating a varying property node.
Expand All @@ -124,7 +124,7 @@ export const property = ( type, name ) => nodeObject( new PropertyNode( type, na
* @param {?string} [name=null] - The name of the varying in the shader.
* @returns {PropertyNode}
*/
export const varyingProperty = ( type, name ) => nodeObject( new PropertyNode( type, name, true ) );
export const varyingProperty = ( type, name ) => new PropertyNode( type, name, true );

/**
* TSL object that represents the shader variable `DiffuseColor`.
Expand Down
3 changes: 1 addition & 2 deletions src/nodes/core/StructNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Node from './Node.js';
import StructTypeNode from './StructTypeNode.js';
import { nodeObject } from '../tsl/TSLCore.js';

/**
* StructNode allows to create custom structures with multiple members.
Expand Down Expand Up @@ -108,7 +107,7 @@ export const struct = ( membersLayout, name = null ) => {

}

return nodeObject( new StructNode( structLayout, values ) );
return new StructNode( structLayout, values );

};

Expand Down
4 changes: 2 additions & 2 deletions src/nodes/core/UniformNode.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import InputNode from './InputNode.js';
import { objectGroup } from './UniformGroupNode.js';
import { nodeObject, getConstNodeType } from '../tsl/TSLCore.js';
import { getConstNodeType } from '../tsl/TSLCore.js';
import { getValueFromType } from './NodeUtils.js';
import { warn } from '../../utils.js';

Expand Down Expand Up @@ -253,6 +253,6 @@ export const uniform = ( value, type ) => {

}

return nodeObject( new UniformNode( value, nodeType ) );
return new UniformNode( value, nodeType );

};
12 changes: 6 additions & 6 deletions src/nodes/display/PassNode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TempNode from '../core/TempNode.js';
import { default as TextureNode/*, texture*/ } from '../accessors/TextureNode.js';
import { NodeUpdateType } from '../core/constants.js';
import { nodeObject, context } from '../tsl/TSLBase.js';
import { context } from '../tsl/TSLBase.js';
import { uniform } from '../core/UniformNode.js';
import { viewZToOrthographicDepth, perspectiveDepthToViewZ } from './ViewportDepthNode.js';

Expand Down Expand Up @@ -623,7 +623,7 @@ class PassNode extends TempNode {

if ( textureNode === undefined ) {

textureNode = nodeObject( new PassMultipleTextureNode( this, name ) );
textureNode = new PassMultipleTextureNode( this, name );
textureNode.updateTexture();
this._textureNodes[ name ] = textureNode;

Expand All @@ -647,7 +647,7 @@ class PassNode extends TempNode {

if ( this._textureNodes[ name ] === undefined ) this.getTextureNode( name );

textureNode = nodeObject( new PassMultipleTextureNode( this, name, true ) );
textureNode = new PassMultipleTextureNode( this, name, true );
textureNode.updateTexture();
this._previousTextureNodes[ name ] = textureNode;

Expand Down Expand Up @@ -990,7 +990,7 @@ export default PassNode;
* @param {Object} options - Options for the internal render target.
* @returns {PassNode}
*/
export const pass = ( scene, camera, options ) => nodeObject( new PassNode( PassNode.COLOR, scene, camera, options ) );
export const pass = ( scene, camera, options ) => new PassNode( PassNode.COLOR, scene, camera, options );

/**
* TSL function for creating a pass texture node.
Expand All @@ -1001,7 +1001,7 @@ export const pass = ( scene, camera, options ) => nodeObject( new PassNode( Pass
* @param {Texture} texture - The output texture.
* @returns {PassTextureNode}
*/
export const passTexture = ( pass, texture ) => nodeObject( new PassTextureNode( pass, texture ) );
export const passTexture = ( pass, texture ) => new PassTextureNode( pass, texture );

/**
* TSL function for creating a depth pass node.
Expand All @@ -1013,4 +1013,4 @@ export const passTexture = ( pass, texture ) => nodeObject( new PassTextureNode(
* @param {Object} options - Options for the internal render target.
* @returns {PassNode}
*/
export const depthPass = ( scene, camera, options ) => nodeObject( new PassNode( PassNode.DEPTH, scene, camera, options ) );
export const depthPass = ( scene, camera, options ) => new PassNode( PassNode.DEPTH, scene, camera, options );
3 changes: 1 addition & 2 deletions src/nodes/gpgpu/ComputeBuiltinNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Node from '../core/Node.js';
import { nodeObject } from '../tsl/TSLBase.js';
import { warn } from '../../utils.js';

/**
Expand Down Expand Up @@ -149,7 +148,7 @@ export default ComputeBuiltinNode;
* @param {string} nodeType - The node type.
* @returns {ComputeBuiltinNode}
*/
const computeBuiltin = ( name, nodeType ) => nodeObject( new ComputeBuiltinNode( name, nodeType ) );
const computeBuiltin = ( name, nodeType ) => new ComputeBuiltinNode( name, nodeType );

/**
* Represents the number of workgroups dispatched by the compute shader.
Expand Down
5 changes: 2 additions & 3 deletions src/nodes/gpgpu/WorkgroupInfoNode.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ArrayElementNode from '../utils/ArrayElementNode.js';
import { nodeObject } from '../tsl/TSLCore.js';
import Node from '../core/Node.js';
import { warn } from '../../utils.js';

Expand Down Expand Up @@ -203,7 +202,7 @@ class WorkgroupInfoNode extends Node {
*/
element( indexNode ) {

return nodeObject( new WorkgroupInfoElementNode( this, indexNode ) );
return new WorkgroupInfoElementNode( this, indexNode );

}

Expand All @@ -229,6 +228,6 @@ export default WorkgroupInfoNode;
* @param {number} [count=0] - The number of elements in the buffer.
* @returns {WorkgroupInfoNode}
*/
export const workgroupArray = ( type, count ) => nodeObject( new WorkgroupInfoNode( 'Workgroup', type, count ) );
export const workgroupArray = ( type, count ) => new WorkgroupInfoNode( 'Workgroup', type, count );


Loading