### Setup Varying Node Source: https://tsl-docs.vercel.app/core/varying-node Performs the setup of a varying node with the current node builder. Returns a NodeVarying object. ```typescript setupVarying( builder: NodeBuilder ) ``` -------------------------------- ### LightProbeNode Methods Source: https://tsl-docs.vercel.app/lighting/light-probe-node Documentation for the update and setup methods of the LightProbeNode. ```APIDOC ## Methods ### update - **Description**: Overwritten to update light probe specific uniforms. - **Parameters**: - **frame** (NodeFrame) - Required - The current node frame. ### setup - **Description**: Sets up the node within the builder context. - **Parameters**: - **builder** (any) - Required - The builder instance. ``` -------------------------------- ### SampleNode setup Method Source: https://tsl-docs.vercel.app/utils/sample-node Sets up the SampleNode by sampling with the default UV accessor. This method is part of the Node class. ```typescript ▸setup: () => Node ``` -------------------------------- ### Method: setup(builder) Source: https://tsl-docs.vercel.app/accessors/batch-node Sets up internal buffers and nodes, assigning transformed vertex data to predefined node variables. ```APIDOC ## Method: setup(builder) ### Description Setups the internal buffers and nodes and assigns the transformed vertex data to predefined node variables for accumulation. ### Parameters #### Request Body - **builder** (NodeBuilder) - Required - The node builder instance. ### Response #### Success Response (void) - **Returns** (void) - No return value. ``` -------------------------------- ### AmbientLightNode Methods and Accessors Source: https://tsl-docs.vercel.app/lighting/ambient-light-node Details regarding the type accessor and setup method for AmbientLightNode. ```APIDOC ## Accessors ### type - **Type**: string - **Description**: Returns the type identifier of the node. ## Methods ### setup - **Description**: Configures the node within the provided context. - **Parameters**: - **{ context }** (object) - Required - The context object containing rendering or scene information. - **Returns**: void ``` -------------------------------- ### Compute Builtin Node: numWorkgroups Example Source: https://tsl-docs.vercel.app/gpgpu/compute-builtin-node Demonstrates how to use `numWorkgroups` to set storage buffer elements based on the number of workgroups dispatched. This example shows two ways to specify workgroup size. ```typescript // Run 512 invocations/threads with a workgroup size of 128. const computeFn = Fn(() => { Cannot redeclare block-scoped variable 'computeFn'. (2451) // numWorkgroups.x = 4 storageBuffer.element(0).assign(numWorkgroups.x) })().compute(512, [128]); // Run 512 invocations/threads with the default workgroup size of 64. const computeFn = Fn(() => { Cannot redeclare block-scoped variable 'computeFn'. (2451) // numWorkgroups.x = 8 storageBuffer.element(0).assign(numWorkgroups.x) })().compute(512); export {} ``` -------------------------------- ### Setup Skinning Node Source: https://tsl-docs.vercel.app/accessors/skinning-node Sets up the skinning node by assigning the transformed vertex data to predefined node variables. Requires a NodeBuilder. ```typescript setup(builder: NodeBuilder) => any ``` -------------------------------- ### FlipNode Usage Example Source: https://tsl-docs.vercel.app/nodes Demonstrates how FlipNode is invoked via method chaining on node objects. ```javascript uvNode = uvNode.flipY(); export {} ``` -------------------------------- ### ReflectorNode Constructor and Usage Source: https://tsl-docs.vercel.app/utils/reflector-node This snippet details the constructor for ReflectorNode, its parameters, and provides a basic usage example. ```APIDOC ## ReflectorNode ### Description This node can be used to implement mirror-like flat reflective surfaces. ### Constructor `new ReflectorNode(parameters?)` ### Parameters #### Parameters - **parameters?** ({ target?: Object3D | undefined; resolutionScale?: number | undefined; generateMipmaps?: boolean | undefined; bounces?: boolean | undefined; depth?: boolean | undefined; samples?: number | undefined; defaultTexture?: TextureNode | undefined; reflector?: ReflectorBaseNode | undefined; }) - Optional - Default: `{}` - An object containing parameters for the ReflectorNode. ### Properties - **type** (string) - Readonly - The type of the node. - **target** (Object3D) - Readonly - A reference to the 3D object the reflector is linked to. - **reflector** (ReflectorBaseNode) - Readonly - A reference to the internal reflector node. ### Methods - **getDepthNode()** - Returns a node representing the mirror’s depth. This can be used to implement more advanced reflection effects like distance attenuation. - **setup(builder)** - Sets up the node for the given builder. - **clone()** - Clones the ReflectorNode. - **dispose()** - Frees internal resources. Should be called when the node is no longer in use. ### Request Example ```javascript const groundReflector = reflector(); material.colorNode = groundReflector; const plane = new Mesh( geometry, material ); plane.add( groundReflector.target ); export {} ``` ``` -------------------------------- ### Node Build Lifecycle Methods Source: https://tsl-docs.vercel.app/core/node Methods responsible for the three-stage build process of a node: setup, analyze, and generate. ```APIDOC ## setup ### Description Represents the setup stage which is the first step of the build process. This method is often overwritten in derived modules to prepare the node. ### Parameters - **builder** (NodeBuilder) - Required ### Response - **Returns** (null | Node) ## analyze ### Description Represents the analyze stage which is the second step of the build process. This stage analyzes the node hierarchy and ensures descendent nodes are built. ### Parameters - **builder** (NodeBuilder) - Required - **output** (null | Node) - Optional ## generate ### Description Represents the generate stage which is the third step of the build process. This state builds the output node and returns the resulting shader string. ### Parameters - **builder** (NodeBuilder) - Required - **output** (null | string) - Optional ### Response - **Returns** (null | string) ``` -------------------------------- ### Implement RenderOutputNode in a pipeline Source: https://tsl-docs.vercel.app/display/render-output-node Example showing how to integrate RenderOutputNode into a RenderPipeline. Ensure outputColorTransform is set to false to avoid double processing. ```javascript const postProcessing = new RenderPipeline( renderer ); postProcessing.outputColorTransform = false; const scenePass = pass( scene, camera ); const outputPass = renderOutput( scenePass ); postProcessing.outputNode = outputPass; export {} ``` -------------------------------- ### Node Builder Shader and Build Stage Management Source: https://tsl-docs.vercel.app/nodes Methods for setting and getting the current shader stage and build stage. ```APIDOC ## Node Builder Shader and Build Stage Management ### Description Allows for the management of the current shader stage and build stage within the node builder. ### Methods #### `setShaderStage(shaderStage: null | "vertex" | "fragment" | "compute" | "any")` - **Description**: Sets the current shader stage. - **Parameters**: - **shaderStage** (null | "vertex" | "fragment" | "compute" | "any") - Required - The shader stage to set. - **Returns**: `void` #### `getShaderStage()` - **Description**: Returns the current shader stage. - **Returns**: `null | "vertex" | "fragment" | "compute" | "any"` #### `setBuildStage(buildStage: null | "generate" | "setup" | "analyze")` - **Description**: Sets the current build stage. - **Parameters**: - **buildStage** (null | "generate" | "setup" | "analyze") - Required - The build stage to set. - **Returns**: `void` #### `getBuildStage()` - **Description**: Returns the current build stage. - **Returns**: `null | "generate" | "setup" | "analyze"` ``` -------------------------------- ### Setup Direct Rect Area Light Source: https://tsl-docs.vercel.app/lighting/rect-area-light-node Configures the direct lighting components, returning the necessary nodes and textures for rendering. ```javascript setupDirectRectArea(builder: any) => { lightColor: Node; lightPosition: UniformNode<…>; halfWidth: UniformNode; halfHeight: UniformNode; ltc_1: TextureNode; ltc_2: TextureNode; } ``` -------------------------------- ### Node Build Lifecycle Methods Source: https://tsl-docs.vercel.app/nodes Methods responsible for the multi-stage build process of a node, including setup, analysis, and shader code generation. ```APIDOC ## setup ### Description Represents the setup stage which is the first step of the build process. This method is often overwritten in derived modules to prepare the node which is used as a node’s output/result. ### Parameters #### Path Parameters - **builder** (NodeBuilder) - Required - The node builder instance. ### Response - **Returns** (null | Node) - The prepared node or null. ## analyze ### Description Represents the analyze stage which is the second step of the build process. This stage analyzes the node hierarchy and ensures descendent nodes are built. ### Parameters #### Path Parameters - **builder** (NodeBuilder) - Required - The node builder instance. - **output** (null | Node) - Optional - The output node. ## generate ### Description Represents the generate stage which is the third step of the build process. This state builds the output node and returns the resulting shader string. ### Parameters #### Path Parameters - **builder** (NodeBuilder) - Required - The node builder instance. - **output** (null | string) - Optional - The output string or node. ### Response - **Returns** (null | string) - The generated shader string. ``` -------------------------------- ### Setup MRT Node with Builder Source: https://tsl-docs.vercel.app/core/mrt-node Sets up the MRT node using a provided builder. The return value can be null or a Node, depending on the builder's implementation. ```typescript setup(builder: any) => null | Node ``` -------------------------------- ### CubeTextureNode Methods Source: https://tsl-docs.vercel.app/nodes Provides methods for getting the node type, default UVs, and setting up UVs for cube texture sampling. The `setUpdateMatrix` method is overridden to do nothing as it's ignored for cube textures. ```typescript get type: string ``` ```typescript getInputType() => string ``` ```typescript getDefaultUV() => any ``` ```typescript setUpdateMatrix() => void ``` ```typescript setupUV( builder: NodeBuilder, uvNode: Node ) => Node ``` ```typescript generateUV( builder: NodeBuilder, cubeUV: Node ) => string ``` -------------------------------- ### Create BufferAttributeNode with Float32BufferAttribute Source: https://tsl-docs.vercel.app/accessors/buffer-attribute-node Example of creating a BufferAttributeNode using a Float32BufferAttribute for color data. This approach allows defining attribute data on the node level, unlike earlier versions of three.js. ```javascript const geometry = new THREE.PlaneGeometry(); const positionAttribute = geometry.getAttribute( 'position' ); const colors = []; for ( let i = 0; i < position.count; i ++ ) { colors.push( 1, 0, 0 ); } material.colorNode = bufferAttribute( new THREE.Float32BufferAttribute( colors, 3 ) ); export {} ``` -------------------------------- ### Backward Loop Implementation in TSL Source: https://tsl-docs.vercel.app/utils/loop-node Create loops that iterate in reverse by specifying a start value. The loop will count down from the start value. ```typescript Loop( { start: 10 }, () => {} ); export {} ``` -------------------------------- ### Loop with Start, End, and Type in TSL Source: https://tsl-docs.vercel.app/utils/loop-node Define specific start and end points, data types, and comparison conditions for more controlled looping. The `condition` parameter accepts operators like '<'. ```typescript Loop( { start: int( 0 ), end: int( 10 ), type: 'int', condition: '<' }, ( { i } ) => { } ); export {} ``` -------------------------------- ### SpotLightNode Constructor Source: https://tsl-docs.vercel.app/nodes Initializes a new spot light node. ```javascript new SpotLightNode(light?) ``` -------------------------------- ### Compute Builtin Node: workgroupId Example Source: https://tsl-docs.vercel.app/gpgpu/compute-builtin-node Illustrates the usage of `workgroupId` to conditionally assign values to a storage buffer based on the workgroup's X-coordinate. The example includes comments showing the expected buffer output. ```typescript // Execute 12 compute threads with a workgroup size of 3. const computeFn = Fn( () => { If( workgroupId.x.mod( 2 ).equal( 0 ), () => { storageBuffer.element( instanceIndex ).assign( instanceIndex ); } ).Else( () => { storageBuffer.element( instanceIndex ).assign( 0 ); } ); } )().compute( 12, [ 3 ] ); // workgroupId.x = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3]; // Buffer Output = [0, 1, 2, 0, 0, 0, 6, 7, 8, 0, 0, 0]; export {} ``` -------------------------------- ### InstancedMeshNode Source: https://tsl-docs.vercel.app/nodes A specialized version of InstanceNode for easier setup with InstancedMesh. ```APIDOC ## InstancedMeshNode ### Description Specialized node for easier setup of instanced rendering using InstancedMesh. ### Constructor `new InstancedMeshNode(instancedMesh)` ### Parameters - **instancedMesh** (InstancedMesh) - Required - The instanced mesh object. ``` -------------------------------- ### sample Source: https://tsl-docs.vercel.app/tsl Helper function to create a SampleNode wrapped as a node object. ```APIDOC ## sample ### Description Helper function to create a SampleNode wrapped as a node object. ### Parameters #### Path Parameters - **callback** (Function) - Required - The callback function. - **uv** (any) - Optional - The UV coordinates. Defaults to `null`. ### Returns `SampleNode` - The created SampleNode. ``` -------------------------------- ### Create SampleNode Instance Source: https://tsl-docs.vercel.app/utils/sample-node Instantiates a SampleNode with a callback function and an optional UV node. ```typescript new SampleNode(callback, uvNode?) ``` -------------------------------- ### sinc Source: https://tsl-docs.vercel.app/math/math-utils A phase shifted sinus curve that starts and ends at zero with bouncing behavior. ```APIDOC ## sinc ### Description A phase shifted sinus curve that starts at zero and ends at zero, with bouncing behavior. ### Parameters - **x** (Node) - Required - Input value - **k** (Node) - Required - Frequency/Scale parameter ### Returns - **Node** - The calculated value ``` -------------------------------- ### LightProbeNode Constructor Source: https://tsl-docs.vercel.app/lighting/light-probe-node Documentation for the LightProbeNode constructor and its parameters. ```APIDOC ## Constructor ### Description Constructs a new LightProbeNode instance. ### Parameters - **light** (any) - Optional - The light probe source, defaults to null. ``` -------------------------------- ### Initialize Toon Outline Pass Source: https://tsl-docs.vercel.app/display/toon-outline-pass-node Demonstrates how to integrate the toon outline pass into a render pipeline. ```javascript const postProcessing = new RenderPipeline( renderer ); const scenePass = toonOutlinePass( scene, camera ); postProcessing.outputNode = scenePass; export {} ``` -------------------------------- ### ClippingNode Methods Source: https://tsl-docs.vercel.app/accessors/clipping-node Documentation for the methods available on the ClippingNode, including setup and specialized clipping functions. ```APIDOC ## ClippingNode Methods ### `setup(builder: NodeBuilder) => Node` Setups the node depending on the selected scope. | Parameter | Type | Default Value | |---|---|---| | builder | `NodeBuilder` | — | Returns: `Node` ### `setupAlphaToCoverage(intersectionPlanes: Array<...>, unionPlanes: Array<...>) => Node` Setups alpha to coverage. | Parameter | Type | Default Value | |---|---|---| | intersectionPlanes | `Array` | — | | unionPlanes | `Array` | — | Returns: `Node` ### `setupDefault(intersectionPlanes: Array<...>, unionPlanes: Array<...>) => Node` Setups the default clipping. | Parameter | Type | Default Value | |---|---|---| | intersectionPlanes | `Array` | — | | unionPlanes | `Array` | — | Returns: `Node` ### `setupHardwareClipping(unionPlanes: Array<...>, builder: NodeBuilder) => Node` Setups hardware clipping. | Parameter | Type | Default Value | |---|---|---| | unionPlanes | `Array` | — | | builder | `NodeBuilder` | — | Returns: `Node` Extends: `Node` ``` -------------------------------- ### Create and Use Storage Buffer in Compute Shader Source: https://tsl-docs.vercel.app/accessors/storage-buffer-node Demonstrates a typical workflow: creating a storage buffer, setting up a compute shader to write data into it, and then converting the buffer to an attribute node for rendering. Ensure 'particleCount' is defined and 'THREE' is imported. ```javascript const positionBuffer = instancedArray( particleCount, 'vec3' ); // the storage buffer node const computeInit = Fn( () => { // the compute shader const position = positionBuffer.element( instanceIndex ); // compute position data position.x = 1; position.y = 1; position.z = 1; } )().compute( particleCount ); const particleMaterial = new THREE.SpriteNodeMaterial(); particleMaterial.positionNode = positionBuffer.toAttribute(); renderer.computeAsync( computeInit ); export {} ``` -------------------------------- ### ContextNode Usage Example Source: https://tsl-docs.vercel.app/nodes Use ContextNode to modify the context for node building, such as overwriting getUV(). ```typescript node.context( { getUV: () => customCoord } ); \/\/ or material.contextNode = context( { getUV: () => customCoord } ); \/\/ or renderer.contextNode = context( { getUV: () => customCoord } ); \/\/ or scenePass.contextNode = context( { getUV: () => customCoord } ); export {} ``` -------------------------------- ### InstanceNode Methods Source: https://tsl-docs.vercel.app/accessors/instance-node Methods for setting up, updating, and retrieving instanced vertex data. ```APIDOC ## InstanceNode Methods ### Description Methods for setting up, updating, and retrieving instanced vertex data. ### Methods - **setup(builder: NodeBuilder): void** Setups the internal buffers and nodes and assigns the transformed vertex data to predefined node variables for accumulation. That follows the same patterns like with morph and skinning nodes. - **update(frame: NodeFrame): void** Checks if the internal buffers require an update. - **getPreviousInstancedPosition(builder: NodeBuilder): any** Computes the transformed/instanced vertex position of the previous frame. - **_createInstanceMatrixNode(assignBuffer: boolean, builder: NodeBuilder): Node** Creates a node representing the instance matrix data. ``` -------------------------------- ### SetNode Usage Example Source: https://tsl-docs.vercel.app/utils/set-node Demonstrates applying a set operation to a material property using the setR method. ```javascript materialLine.colorNode = color( 0, 0, 0 ).setR( float( 1 ) ); export {} ``` -------------------------------- ### sample Helper Function Source: https://tsl-docs.vercel.app/utils/sample-node A helper function to create a SampleNode instance, wrapped as a node object. ```APIDOC ## sample Helper Function ### Description Helper function to create a SampleNode wrapped as a node object. ### Parameters - **callback** (Function) - Required - The callback function for the SampleNode. - **uv** (any) - Optional - The UV node, defaults to null. ### Returns SampleNode ``` -------------------------------- ### LightingNode Constructor Source: https://tsl-docs.vercel.app/lighting/lighting-node Provides information on how to construct a new LightingNode instance. ```APIDOC ## LightingNode Constructor ### Description Constructs a new lighting node. ### Method `new LightingNode()` ### Parameters This constructor does not accept any parameters. ### Accessors - **type** (`string`) - Returns the type of the lighting node. ### Properties - **isLightingNode** (`boolean`) - Indicates if the node is a lighting node. (Default: `false` if not specified, but the provided text doesn't specify a default value, so it's omitted here.) ### Extends `Node` ``` -------------------------------- ### AmbientLightNode Constructor Source: https://tsl-docs.vercel.app/lighting/ambient-light-node Details for initializing a new AmbientLightNode instance. ```APIDOC ## Constructor ### Description Constructs a new ambient light node. ### Parameters - **light** (any) - Optional - The light source to be represented by the node. Defaults to null. ### Usage `new AmbientLightNode(light?)` ``` -------------------------------- ### FlipNode Usage Example Source: https://tsl-docs.vercel.app/utils/flip-node Demonstrates how FlipNode is used internally to implement flip methods on node objects. ```typescript uvNode = uvNode.flipY(); export {} ``` -------------------------------- ### Get Texture3DNode Type Source: https://tsl-docs.vercel.app/nodes Returns the type of the node as a string. Overwrites the default implementation to return 'texture3D'. ```typescript getInputType() => string ``` -------------------------------- ### Create SampleNode using Helper Function Source: https://tsl-docs.vercel.app/utils/sample-node A helper function to create a SampleNode instance, wrapped as a node object. It accepts a callback and an optional UV node. ```typescript sample(callback, uv?) ``` -------------------------------- ### Create Sample Node Source: https://tsl-docs.vercel.app/tsl Helper function to create a SampleNode, wrapped as a node object. It takes a callback function and optional UV coordinates. ```typescript sample( callback: Function, uv?: any ) ``` -------------------------------- ### Get Previous Skinned Position Source: https://tsl-docs.vercel.app/accessors/skinning-node Computes the transformed/skinned vertex position of the previous frame. Requires a NodeBuilder. ```typescript getPreviousSkinnedPosition(builder: NodeBuilder) => any ``` -------------------------------- ### PointUVNode Class Source: https://tsl-docs.vercel.app/accessors/point-uv-node Documentation for the PointUVNode constructor and its associated properties and methods. ```APIDOC ## PointUVNode ### Description A node for representing the uv coordinates of points. Can only be used with a WebGL backend. ### Constructor `new PointUVNode()` Constructs a new point uv node. ### Accessors - **type** (string) - Returns the type of the node. ### Properties - **isPointUVNode** (boolean) - Indicates if the object is a PointUVNode. ### Methods - **generate()** (string) - Generates the string representation of the node. ``` -------------------------------- ### Get Default UV for Texture3DNode Source: https://tsl-docs.vercel.app/nodes Returns a default UV node. For 3D textures, this is a three-dimensional UV node. ```typescript getDefaultUV() => any ``` -------------------------------- ### Construct PhongLightingModel Source: https://tsl-docs.vercel.app/nodes Initializes the lighting model used for Phong materials, with an optional specular component. ```javascript new PhongLightingModel(specular?) ``` -------------------------------- ### SpotLightNode Class Source: https://tsl-docs.vercel.app/lighting/spot-light-node Documentation for the SpotLightNode constructor, properties, and methods. ```APIDOC ## Constructor ### new SpotLightNode(light?) #### Parameters - **light** (any) - Optional - The light source to associate with the node. Defaults to null. ## Properties - **coneCosNode** (UniformNode) - Node representing the cone cosine. - **penumbraCosNode** (UniformNode) - Node representing the penumbra cosine. - **cutoffDistanceNode** (UniformNode) - Node representing the cutoff distance. - **decayExponentNode** (UniformNode) - Node representing the decay exponent. ## Methods ### update(frame) Updates spot light specific uniforms. - **frame** (NodeFrame) - Required - The current node frame. ### getSpotAttenuation(builder, angleCosine) Computes the spot attenuation for the given angle. - **builder** (NodeBuilder) - Required - **angleCosine** (Node) - Required ### getLightCoord(builder) - **builder** (any) - Required ### setupDirect(builder) - **builder** (any) - Required #### Returns - **lightColor** (any) - **lightDirection** (any) ``` -------------------------------- ### Get MRT Output Node Source: https://tsl-docs.vercel.app/core/mrt-node Retrieves the specific output node associated with the given name from the MRT node. ```typescript get(name: string) => Node ``` -------------------------------- ### BasicEnvironmentNode Constructor Source: https://tsl-docs.vercel.app/lighting/basic-environment-node Constructs a new BasicEnvironmentNode. It represents a basic model for Image-based lighting (IBL) using environment maps in either equirectangular or cube map format. ```APIDOC ## BasicEnvironmentNode Constructor ### Description Constructs a new basic environment node. Represents a basic model for Image-based lighting (IBL) using environment maps in the equirectangular or cube map format. `BasicEnvironmentNode` is intended for non-PBR materials like MeshBasicNodeMaterial or MeshPhongNodeMaterial. ### Method `new BasicEnvironmentNode(envNode?) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Get Skinned Position Source: https://tsl-docs.vercel.app/accessors/skinning-node Transforms the given vertex position via skinning. Uses boneMatricesNode and positionNode by default. ```typescript getSkinnedPosition(boneMatrices?: Node, position?: Node) => any ``` -------------------------------- ### RenderOutputNode Constructor and Usage Source: https://tsl-docs.vercel.app/display/render-output-node Demonstrates how to use RenderOutputNode to apply tone mapping and color space conversion manually. It also shows how to disable the default automatic color transform. ```APIDOC ## RenderOutputNode Normally, tone mapping and color conversion happens automatically just before outputting a pixel to the default (screen) framebuffer. In certain post processing setups this is too late because some effects such as FXAA require e.g. sRGB input. For such scenarios, `RenderOutputNode` can be used to apply tone mapping and color space conversion at an arbitrary point in the effect chain. When applying tone mapping and color space conversion manually with this node, you have to set RenderPipeline#outputColorTransform to `false`. ```javascript const postProcessing = new RenderPipeline( renderer ); postProcessing.outputColorTransform = false; const scenePass = pass( scene, camera ); const outputPass = renderOutput( scenePass ); postProcessing.outputNode = outputPass; export {} ``` ### Constructor `new RenderOutputNode(colorNode, toneMapping, outputColorSpace)` | Parameter| Type| Default Value ---|---|--- colorNode| `Node`| — toneMapping| `null | number`| — outputColorSpace| `null | string`| — Constructs a new render output node. ### Properties | Property| Type| Default Value ---|---|--- colorNode| `Node`| — _toneMapping| `null | number`| — outputColorSpace| `null | string`| — isRenderOutputNode| `boolean`| — ### Methods - **setToneMapping** - Type: `(value: number) => ToneMappingNode` - Description: Sets the tone mapping type. - Parameters: - **value** (number) - Description: — - Returns: `ToneMappingNode` - **getToneMapping** - Type: `() => number` - Description: Gets the tone mapping type. - Returns: `number` - **setup** - Type: `({ context }: { context: any; }) => Node` - Description: — - Parameters: - **{ context }** ({ context: any; }) - Description: — - Returns: `Node` ### Extends `TempNode` ``` -------------------------------- ### Initialize and Set PassNode Source: https://tsl-docs.vercel.app/display/pass-node Initializes a RenderPipeline and sets a scene pass as its output node. This is a common setup for post-processing effects. ```typescript const postProcessing = new RenderPipeline( renderer ); const scenePass = pass( scene, camera ); postProcessing.outputNode = scenePass; export {} ``` -------------------------------- ### LightingContextNode Constructor Source: https://tsl-docs.vercel.app/lighting/lighting-context-node Initializes a new LightingContextNode with lights node and optional lighting parameters. ```APIDOC ## LightingContextNode Constructor ### Description Constructs a new lighting context node. ### Method `new LightingContextNode(lightsNode, lightingModel?, backdropNode?, backdropAlphaNode?) ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Request Example ```javascript // Example usage (conceptual) const lightsNode = new LightsNode(); const lightingContextNode = new LightingContextNode(lightsNode, { /* lighting model options */ }); ``` ### Response #### Success Response (200) * N/A (Constructor) #### Response Example * N/A (Constructor) ``` -------------------------------- ### Merge MRT Nodes Source: https://tsl-docs.vercel.app/core/mrt-node Merges the outputs of another MRTNode into the current one. This is useful for combining multiple MRT setups. ```typescript merge(mrtNode: MRTNode) => MRTNode ``` -------------------------------- ### InstanceNode Methods Source: https://tsl-docs.vercel.app/nodes Provides methods for setting up internal buffers, updating instance data, and retrieving transformed vertex positions. It also includes a private method for creating the instance matrix node. ```typescript get type: string ``` ```typescript get isStorageMatrix: boolean ``` ```typescript get isStorageColor: boolean ``` ```typescript setup( builder: NodeBuilder ) => void ``` ```typescript update( frame: NodeFrame ) => void ``` ```typescript getPreviousInstancedPosition( builder: NodeBuilder ) => any ``` ```typescript _createInstanceMatrixNode( assignBuffer: boolean, builder: NodeBuilder ) => Node ``` -------------------------------- ### Get Skinned Position Source: https://tsl-docs.vercel.app/nodes Transforms the given vertex position via skinning. Uses boneMatricesNode and positionNode by default if not provided. ```javascript getSkinnedPosition(boneMatrices?: Node, position?: Node<…>) => any ``` -------------------------------- ### SampleNode sample Method Source: https://tsl-docs.vercel.app/utils/sample-node Calls the callback function with the provided UV node. The uv parameter is of type Node. ```typescript ▸sample: (uv: Node<…>) => Node ``` -------------------------------- ### Get Parallax Corrected Normal Source: https://tsl-docs.vercel.app/tsl Computes a parallax corrected normal for box-projected cube mapping. Reference: https://devlog-martinsh.blogspot.com/2011/09/box-projected-cube-environment-mapping.html ```typescript const uvNode = getParallaxCorrectNormal( reflectVector, vec3( 200, 100, 100 ), vec3( 0, - 50, 0 ) ); material.envNode = pmremTexture( renderTarget.texture, uvNode ); export {} ``` -------------------------------- ### Get Code From Node Source: https://tsl-docs.vercel.app/core/node-builder Retrieves an instance of NodeCode for a given code node. This is useful for inspecting or manipulating the generated code. ```typescript getCodeFromNode(node: CodeNode, type: string, shaderStage?: "vertex" | "fragment" | "compute" | "any"): NodeCode ``` -------------------------------- ### BasicLightMapNode Class Reference Source: https://tsl-docs.vercel.app/lighting/basic-light-map-node Documentation for the constructor, properties, and methods of the BasicLightMapNode class. ```APIDOC ## BasicLightMapNode ### Description A specific version of IrradianceNode that is only relevant for MeshBasicNodeMaterial. Since the material is unlit, it requires a special scaling factor for the light map. ### Constructor `new BasicLightMapNode(lightMapNode?)` #### Parameters - **lightMapNode** (any) - Optional - The light map node to be used. Default is null. ### Properties - **lightMapNode** (any) - The light map node associated with this instance. ### Methods - **setup(builder: any)** - Configures the node using the provided builder. Returns void. ### Accessors - **type** (string) - Returns the type of the node. ### Inheritance - **Extends**: LightingNode ``` -------------------------------- ### Get Skinned Normal and Tangent Source: https://tsl-docs.vercel.app/accessors/skinning-node Transforms the given vertex normal and tangent via skinning. Uses boneMatricesNode by default. ```typescript getSkinnedNormalAndTangent(boneMatrices?: Node, normal?: Node, tangent?: Node) => { skinNormal: Node; skinTangent: Node; } ``` -------------------------------- ### InstancedMeshNode Constructor Source: https://tsl-docs.vercel.app/accessors/instanced-mesh-node Documentation for the InstancedMeshNode class constructor. ```APIDOC ## Constructor: new InstancedMeshNode(instancedMesh) ### Description Constructs a new instance of the InstancedMeshNode, which is a specialized version of InstanceNode designed for use with InstancedMesh. ### Parameters #### Constructor Parameters - **instancedMesh** (InstancedMesh) - Required - The InstancedMesh object to be associated with this node. ``` -------------------------------- ### Define and use a custom StructNode Source: https://tsl-docs.vercel.app/core/struct-node Demonstrates defining a struct, creating instances using different styles, and accessing or modifying members. ```javascript // Define a custom struct const BoundingBox = struct( { min: 'vec3', max: 'vec3' } ); // Create a new instance of the struct const bb = BoundingBox( vec3( 0 ), vec3( 1 ) ); // style 1 Cannot redeclare block-scoped variable 'bb'. (2451)const bb = BoundingBox( { min: vec3( 0 ), max: vec3( 1 ) } ); // style 2 Cannot redeclare block-scoped variable 'bb'. (2451) // Access the struct members const min = bb.get( 'min' ); // Assign a new value to a member min.assign( vec3() ); export {} ``` -------------------------------- ### InstanceNode Source: https://tsl-docs.vercel.app/nodes Implements vertex shader logic for rendering 3D objects via instancing. ```APIDOC ## InstanceNode ### Description Implements vertex shader logic for instancing, allowing modification of positions, normals, and colors via instanced data. ### Constructor `new InstanceNode(count, instanceMatrix, instanceColor?)` ### Parameters - **count** (number) - Required - Number of instances. - **instanceMatrix** (any) - Required - Matrix data. - **instanceColor** (any) - Optional - Color data. ### Methods - **setup** (builder: NodeBuilder) => void - Setups internal buffers and nodes. - **update** (frame: NodeFrame) => void - Checks if internal buffers require update. - **getPreviousInstancedPosition** (builder: NodeBuilder) => any - Computes previous frame position. - **_createInstanceMatrixNode** (assignBuffer: boolean, builder: NodeBuilder) => Node - Creates instance matrix node. ``` -------------------------------- ### Get Skinned Normal and Tangent Source: https://tsl-docs.vercel.app/nodes Transforms the given vertex normal and tangent via skinning. Uses boneMatricesNode by default if not provided. ```javascript getSkinnedNormalAndTangent(boneMatrices?: Node, normal?: Node<…>, tangent?: Node<…>) => { skinNormal: Node<…>; skinTangent: Node; } ``` -------------------------------- ### Get Blend Mode for MRT Output Source: https://tsl-docs.vercel.app/core/mrt-node Retrieves the blend mode currently set for a specific named output of the MRT node. ```typescript getBlendMode(name: string) => BlendMode ``` -------------------------------- ### SkinningNode Constructor Source: https://tsl-docs.vercel.app/nodes Initializes a new instance of the SkinningNode class. ```APIDOC ## Constructor ### Description Constructs a new skinning node for a given skinned mesh. ### Parameters - **skinnedMesh** (SkinnedMesh) - Required - The skinned mesh to be associated with this node. ``` -------------------------------- ### getTextureIndex Source: https://tsl-docs.vercel.app/core/mrt-node Retrieves the MRT texture index for a given name. This function is useful for accessing specific texture outputs within an MRT setup. ```APIDOC ## GET /getTextureIndex ### Description Returns the MRT texture index for the given name. ### Method GET ### Endpoint /getTextureIndex ### Parameters #### Query Parameters - **textures** (Array) - Required - The array of textures to search within. - **name** (string) - Required - The name of the texture to find the index for. ### Response #### Success Response (200) - **number** - The index of the texture in the MRT setup. #### Response Example ```json 1 ``` ``` -------------------------------- ### NodeCode Constructor and Properties Source: https://tsl-docs.vercel.app/core/node-code Details on how to construct a NodeCode object and its available properties. ```APIDOC ## NodeCode NodeBuilder is going to create instances of this class during the build process of nodes. They represent user-defined, native shader code portions that are going to be injected by the builder. A dictionary of node codes is maintained in NodeBuilder#codes for this purpose. ### Constructor `new NodeCode(name, type, code?)` #### Parameters - **name** (string) - Required - The name of the code node. - **type** (string) - Required - The type of the code node. - **code?** (string) - Optional - The shader code string. Defaults to an empty string. Constructs a new code node. ### Properties - **name** (string) - The name of the code node. - **type** (string) - The type of the code node. - **code** (string) - The shader code string. ``` -------------------------------- ### CubeTextureNode Class Source: https://tsl-docs.vercel.app/accessors/cube-texture-node The CubeTextureNode class represents a cube texture uniform node. It extends TextureNode and provides methods for UV setup and generation. ```APIDOC ## CubeTextureNode ### Description Represents a cube texture uniform node. It provides functionality to handle cube texture sampling, including UV setup and generation. ### Constructor `new CubeTextureNode(value, uvNode?, levelNode?, biasNode?)` ### Parameters - **value** (CubeTexture) - Required - The cube texture object. - **uvNode** (any) - Optional - The UV node. - **levelNode** (any) - Optional - The level node. - **biasNode** (any) - Optional - The bias node. ### Methods - **getInputType()** (string) - Returns the cube texture type. - **getDefaultUV()** (any) - Returns default UVs based on mapping type. - **setUpdateMatrix()** (void) - Empty implementation for cube textures. - **setupUV(builder, uvNode)** (Node) - Sets up the UV node for correct sampling. - **generateUV(builder, cubeUV)** (string) - Generates the UV code snippet. ``` -------------------------------- ### Node Class Overview Source: https://tsl-docs.vercel.app/core/node Provides an overview of the Node class, including its constructor, properties, and methods. ```APIDOC ## Node Class Base class for all nodes. ### Constructor `new Node(nodeType?)` **Parameters:** - **nodeType?** (`null | string`) - Optional - Default: `null` - The type of the node. Constructs a new node. ### Properties - **nodeType** (`null | string`) - The type of the node. - **updateType** (`string`) - The type of update for the node. - **updateBeforeType** (`string`) - The type of update before the node. - **updateAfterType** (`string`) - The type of update after the node. - **version** (`number`) - The version of the node. - **name** (`string`) - The name of the node. - **global** (`boolean`) - Indicates if the node is global. - **parents** (`boolean`) - Indicates if the node has parents. - **isNode** (`boolean`) - Indicates if the object is a node. - **_beforeNodes** (`any`) - Internal property for before nodes. - **_cacheKey** (`null | number`) - Internal cache key. - **_uuid** (`string`) - Internal UUID of the node. - **_cacheKeyVersion** (`number`) - Internal cache key version. - **id** (`number`) - The ID of the node. - **stackTrace** (`null | string`) - The stack trace of the node. ### Accessors - **get type** (`string`) - Returns the type of the node. - **set needsUpdate** (`boolean`) - Set this property to `true` when the node should be regenerated. - **value** (`boolean`) - The boolean value to set. - **get uuid** (`string`) - The UUID of the node. ### Methods - **onUpdate** (`(callback: Function, updateType: string) => Node`) - Convenient method for defining Node#update. - **Parameters:** - **callback** (`Function`) - The callback function. - **updateType** (`string`) - The type of update. - **Returns:** `Node` - **onFrameUpdate** (`(callback: Function) => Node`) - Convenient method for defining Node#update. Similar to Node#onUpdate, but this method automatically sets the update type to `FRAME`. - **Parameters:** - **callback** (`Function`) - The callback function. - **Returns:** `Node` - **onRenderUpdate** (`(callback: Function) => Node`) - Convenient method for defining Node#update. Similar to Node#onUpdate, but this method automatically sets the update type to `RENDER`. - **Parameters:** - **callback** (`Function`) - The callback function. - **Returns:** `Node` - **onObjectUpdate** (`(callback: Function) => Node`) - Convenient method for defining Node#update. Similar to Node#onUpdate, but this method automatically sets the update type to `OBJECT`. - **Parameters:** - **callback** (`Function`) - The callback function. - **Returns:** `Node` - **onReference** (`(callback: Function) => Node`) - Convenient method for defining Node#updateReference. - **Parameters:** - **callback** (`Function`) - The callback function. - **Returns:** `Node` - **updateReference** (`() => any`) - Nodes might refer to other objects like materials. This method allows to dynamically update the reference to such objects based on a given state (e.g. the current node frame or builder). - **Returns:** `any` - **isGlobal** (`() => boolean`) - By default this method returns the value of the Node#global flag. This method can be overwritten in derived classes if an analytical way is required to determine the global cache referring to the current shader-stage. - **Returns:** `boolean` - **getChildren** (`() => Generator<…>`) - Generator function that can be used to iterate over the child nodes. - **Returns:** `Generator` - **dispose** (`() => void`) - Calling this method dispatches the `dispose` event. This event can be used to register event listeners for clean up tasks. - **Returns:** `void` - **traverse** (`(callback: traverseCallback) => void`) - Callback for Node#traverse. Can be used to traverse through the node’s hierarchy. - **Parameters:** - **callback** (`traverseCallback`) - The callback function. - **Returns:** `void` - **_getChildren** (`(ignores?: Set<…>) => Array<…>`) - Returns the child nodes of this node. - **Parameters:** - **ignores?** (`Set`) - Optional - Default: `new Set()` - A set of nodes to ignore. - **Returns:** `Array` - **getCacheKey** (`(force?: boolean, ignores?: Set<…>) => number`) - Returns the cache key for this node. - **Parameters:** - **force?** (`boolean`) - Optional - Default: `false` - Whether to force cache regeneration. - **ignores?** (`Set`) - Optional - Default: `null` - A set of nodes to ignore. - **Returns:** `number` - **customCacheKey** (`() => number`) - Generate a custom cache key for this node. - **Returns:** `number` - **getScope** (`() => Node`) - Returns the references to this node which is by default `this`. - **Returns:** `Node` - **getHash** (`() => string`) - Returns the hash of the node which is used to identify the node. By default it’s the Node#uuid however derived node classes might have to overwrite this method depending on their implementation. - **Returns:** `string` - **getUpdateType** (`() => { NONE: string; FRAME: string; RENDER: string; OBJECT: string; }`) - Returns the update type of Node#update. - **Returns:** An object with update types: `NONE`, `FRAME`, `RENDER`, `OBJECT`. - **getUpdateBeforeType** (`() => { NONE: string; FRAME: string; RENDER: string; OBJECT: string; }`) - Returns the update type of Node#updateBefore. - **Returns:** An object with update types: `NONE`, `FRAME`, `RENDER`, `OBJECT`. - **getUpdateAfterType** (`() => { NONE: string; FRAME: string; RENDER: string; OBJECT: string; }`) - Returns the update type of Node#updateAfter. - **Returns:** An object with update types: `NONE`, `FRAME`, `RENDER`, `OBJECT`. ``` -------------------------------- ### Accessing Buffer Elements Source: https://tsl-docs.vercel.app/accessors/buffer-node Demonstrates creating a buffer node and accessing a specific element using the element() method. ```javascript const bufferNode = buffer( array, 'mat4', count ); const matrixNode = bufferNode.element( index ); // access a matrix from the buffer export {} ``` -------------------------------- ### Flow Node Source: https://tsl-docs.vercel.app/core/node-builder Executes the node flow starting from a root node to generate the final shader code. This is a core method for the shader compilation process. ```typescript flowNode(node: Node): Object ``` -------------------------------- ### Get Flow Data Source: https://tsl-docs.vercel.app/core/node-builder Retrieves the current flow data based on a provided Node. This can be useful for debugging or analyzing the state of the shader generation process. ```typescript getFlowData(node: Node): Object ``` -------------------------------- ### ModelNode Constructor and Usage Source: https://tsl-docs.vercel.app/accessors/model-node Details on how to construct and use the ModelNode, including its parameters and update method. ```APIDOC ## ModelNode This type of node is a specialized version of `Object3DNode` with larger set of model related metrics. Unlike `Object3DNode`, `ModelNode` extracts the reference to the 3D object from the current node frame state. ### Constructor `new ModelNode(scope)` #### Parameters - **scope** (string) - Required - One of: `"position" | "viewPosition" | "direction" | "scale" | "worldMatrix"` Constructs a new object model node. ### Accessors - **type** (string) - Returns the type of the node. ### Methods `static update(frame: NodeFrame): void` Extracts the model reference from the frame state and then updates the uniform value depending on the scope. #### Parameters - **frame** (NodeFrame) - Required - The node frame state. ### Extends `Object3DNode` ``` -------------------------------- ### Get Attribute and Varying Data Source: https://tsl-docs.vercel.app/accessors/storage-buffer-node Retrieves the associated 'BufferAttributeNode' and 'VaryingNode' for a storage buffer. This is useful for understanding how the buffer data is represented internally for rendering. ```javascript storageBufferNode.getAttributeData() ``` -------------------------------- ### Construct a new LightProbeNode Source: https://tsl-docs.vercel.app/lighting/light-probe-node Instantiates a new light probe node, optionally accepting a light source. ```javascript new LightProbeNode(light?) ``` -------------------------------- ### Flow Stages Node Source: https://tsl-docs.vercel.app/core/node-builder Runs the node flow through all creation steps: 'setup', 'analyze', and 'generate'. This method processes a node completely through the shader compilation pipeline. ```typescript flowStagesNode(node: Node, output?: null | string): Object ```