### PCDLoader - Import and Usage Example Source: https://threejs.org/docs/pages/PCDLoader.html Demonstrates how to import PCDLoader and provides a basic code example for loading a PCD file. ```APIDOC ## Import PCDLoader is an addon, and must be imported explicitly. ```js import { PCDLoader } from 'three/addons/loaders/PCDLoader.js'; ``` ## Code Example ```js const loader = new PCDLoader(); const points = await loader.loadAsync( './models/pcd/binary/Zaghetto.pcd' ); points.geometry.center(); // optional points.geometry.rotateX( Math.PI ); // optional scene.add( points ); ``` ``` -------------------------------- ### Audio Code Example Source: https://threejs.org/docs/pages/Audio.html A practical code example demonstrating how to create and manage a global audio source using THREE.js. ```APIDOC ## Code Example ```javascript // create an AudioListener and add it to the camera const listener = new THREE.AudioListener(); camera.add( listener ); // create a global audio source const sound = new THREE.Audio( listener ); // load a sound and set it as the Audio object's buffer const audioLoader = new THREE.AudioLoader(); audioLoader.load( 'sounds/ambient.ogg', function( buffer ) { sound.setBuffer( buffer ); sound.setLoop( true ); ssound.setVolume( 0.5 ); ssound.play(); }); ``` ``` -------------------------------- ### Initialize and Use AudioAnalyser in JavaScript Source: https://threejs.org/docs/pages/AudioAnalyser.html This example demonstrates how to create an AudioListener, load an audio file, set up an Audio object, and then use the AudioAnalyser to get frequency data. It requires the THREE.js library. ```javascript const listener = new THREE.AudioListener(); camera.add( listener ); const sound = new THREE.Audio( listener ); const audioLoader = new THREE.AudioLoader(); audioLoader.load( 'sounds/ambient.ogg', function( buffer ) { sound.setBuffer( buffer ); sound.setLoop(true); sound.setVolume(0.5); sound.play(); }); const analyser = new THREE.AudioAnalyser( sound, 32 ); const data = analyser.getAverageFrequency(); ``` -------------------------------- ### RectAreaLightHelper Usage Example Source: https://threejs.org/docs/pages/RectAreaLightHelper.html Example demonstrating how to create and use a RectAreaLightHelper. ```APIDOC ## Code Example ```js // Import the helper import { RectAreaLightHelper } from 'three/addons/helpers/RectAreaLightHelper.js'; // Create a light const light = new THREE.RectAreaLight( 0xffffbb, 1.0, 5, 5 ); // Create the helper and add it as a child of the light const helper = new RectAreaLightHelper( light ); light.add( helper ); ``` ``` -------------------------------- ### Basic Render Pipeline Setup in Three.js Source: https://context7_llms Demonstrates the basic setup of a RenderPipeline in Three.js, including creating the pipeline, defining a scene pass, setting the output, and rendering in an animation loop. Requires the 'three/webgpu' and 'three/tsl' modules. ```javascript import * as THREE from 'three/webgpu'; import { pass } from 'three/tsl'; // Create the render pipeline const renderPipeline = new THREE.RenderPipeline( renderer ); // Create a scene pass const scenePass = pass( scene, camera ); // Set the output renderPipeline.outputNode = scenePass; // In the animation loop function animate() { renderPipeline.render(); } ``` -------------------------------- ### Dispatching Custom Events with EventDispatcher in JavaScript Source: https://threejs.org/docs/pages/EventDispatcher.html This example demonstrates how to extend the EventDispatcher class to create a custom object that can dispatch events. It shows how to define a custom event ('start') and how to listen for and react to this event using an anonymous function. ```javascript class Car extends EventDispatcher { start() { this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); } }; // Using events with the custom object const car = new Car(); car.addEventListener( 'start', function ( event ) { alert( event.message ); } ); car.start(); ``` -------------------------------- ### DenoiseNode Setup and Update Methods in JavaScript Source: https://threejs.org/docs/pages/DenoiseNode.html This snippet details the `setup` and `updateBefore` methods of the DenoiseNode. The `setup` method is responsible for generating the TSL code for the effect, while `updateBefore` is called once per frame to update internal uniforms, ensuring the denoising effect remains current. ```javascript // Method to setup the effect's TSL code .setup( builder : NodeBuilder ) : ShaderCallNodeInternal // Method to update internal uniforms once per frame .updateBefore( frame : NodeFrame ) ``` -------------------------------- ### AnalyticLightNode Methods Source: https://threejs.org/docs/pages/AnalyticLightNode.html Documentation for the methods of AnalyticLightNode, including shadow management, vector calculations, and setup procedures. ```APIDOC ## Methods AnalyticLightNode ### Description Methods for managing and configuring analytic light nodes. ### Methods #### disposeShadow() Frees internal resources related to shadows. #### getLightVector( builder : NodeBuilder ) : Node. Returns a node representing a direction vector from the current position to the light's position in view space. **Parameters:** - **builder** (NodeBuilder) - The builder object used for setting up the light. **Returns:** - Node. - The light vector node. #### setup( builder : NodeBuilder ) Configures the current LightingModel and/or invokes respective interface methods. Does not return an output node. **Parameters:** - **builder** (NodeBuilder) - The current node builder. **Overrides:** LightingNode#setup #### setupDirect( builder : NodeBuilder ) : Object | undefined (abstract) Sets up the direct lighting for the analytic light node. **Parameters:** - **builder** (NodeBuilder) - The builder object used for setting up the light. **Returns:** - Object | undefined - The direct light data (color and direction). #### setupDirectRectArea( builder : NodeBuilder ) : Object | undefined (abstract) Sets up the direct rect area lighting for the analytic light node. **Parameters:** - **builder** (NodeBuilder) - The builder object used for setting up the light. **Returns:** - Object | undefined - The direct rect area light data. #### setupShadow( builder : NodeBuilder ) Setups the shadow for this light, incorporating shadows into the lighting computation if the light casts shadows and the build object receives them. **Parameters:** - **builder** (NodeBuilder) - The current node builder. #### setupShadowNode() : ShadowNode Setups the shadow node for this light. Allows concrete light classes to set up different types of shadow nodes. **Returns:** - ShadowNode - The created shadow node. #### update( frame : NodeFrame ) Updates light uniforms per frame. Potentially overwritten in concrete light nodes. **Parameters:** - **frame** (NodeFrame) - A reference to the current node frame. **Overrides:** LightingNode#update ``` -------------------------------- ### RGBShiftNode Methods Source: https://threejs.org/docs/pages/RGBShiftNode.html Documentation for the methods available on an RGBShiftNode instance, focusing on the `setup` method. ```APIDOC ## RGBShiftNode Methods ### .setup( builder : NodeBuilder ) : ShaderCallNodeInternal This method is used to setup the effect's TSL code. **Parameters:** - **builder** (NodeBuilder) - The current node builder. **Overrides:** [TempNode#setup](TempNode.html#setup) ``` -------------------------------- ### Get Methods Source: https://threejs.org/docs/pages/WebGLRenderer.html Methods for retrieving information about the renderer's state and context. ```APIDOC ## Get Methods ### `.getActiveCubeFace()` : `number` Returns the active cube face. **Returns:** The active cube face. ### `.getActiveMipmapLevel()` : `number` Returns the active mipmap level. **Returns:** The active mipmap level. ### `.getClearAlpha()` : `number` Returns the clear alpha. Ranges within `[0,1]`. **Returns:** The clear alpha. ### `.getClearColor( target : Color )` : `Color` Returns the clear color. **Parameters:** - **target** (Color) - The method writes the result in this target object. **Returns:** The clear color. ### `.getContext()` : `WebGL2RenderingContext` Returns the rendering context. **Returns:** The rendering context. ### `.getContextAttributes()` : `WebGLContextAttributes` Returns the rendering context attributes. **Returns:** The rendering context attributes. ``` -------------------------------- ### Line3 Constructor and Properties Source: https://threejs.org/docs/pages/Line3.html Details about the Line3 constructor and its start and end point properties. ```APIDOC ## Line3 An analytical line segment in 3D space represented by a start and end point. ### Constructor #### new Line3( start : Vector3, end : Vector3 ) Constructs a new line segment. **Parameters** - **start** (Vector3) - The starting point of the line segment. Defaults to (0,0,0). - **end** (Vector3) - The ending point of the line segment. Defaults to (0,0,0). ### Properties - **.start** (Vector3) - The starting point of the line segment. - **.end** (Vector3) - The ending point of the line segment. ``` -------------------------------- ### MeshBasicNodeMaterial Methods Source: https://threejs.org/docs/pages/MeshBasicNodeMaterial.html Documentation for the methods available on MeshBasicNodeMaterial, including setupEnvironment, setupLightMap, setupLightingModel, setupNormal, and setupOutgoingLight. ```APIDOC ## Methods ### .setupEnvironment( builder : NodeBuilder ) : BasicEnvironmentNode. #### Description Overwritten since this type of material uses [BasicEnvironmentNode](BasicEnvironmentNode.html) to implement the default environment mapping. #### Parameters - **builder** (NodeBuilder) - The current node builder. #### Returns BasicEnvironmentNode. - The environment node. #### Overrides [NodeMaterial#setupEnvironment](NodeMaterial.html#setupEnvironment) ### .setupLightMap( builder : NodeBuilder ) : BasicLightMapNode. #### Description This method must be overwritten since light maps are evaluated with a special scaling factor for basic materials. #### Parameters - **builder** (NodeBuilder) - The current node builder. #### Returns BasicLightMapNode. - The light map node. #### Overrides [NodeMaterial#setupLightMap](NodeMaterial.html#setupLightMap) ### .setupLightingModel() : BasicLightingModel #### Description Setups the lighting model. #### Returns BasicLightingModel - The lighting model. #### Overrides [NodeMaterial#setupLightingModel](NodeMaterial.html#setupLightingModel) ### .setupNormal() : Node. #### Description Basic materials are not affected by normal and bump maps so we return by default [normalViewGeometry](TSL.html#normalViewGeometry). #### Returns Node. - The normal node. #### Overrides [NodeMaterial#setupNormal](NodeMaterial.html#setupNormal) ### .setupOutgoingLight() : Node. #### Description The material overwrites this method because `lights` is set to `true` but we still want to return the diffuse color as the outgoing light. #### Returns Node. - The outgoing light node. #### Overrides [NodeMaterial#setupOutgoingLight](NodeMaterial.html#setupOutgoingLight) ``` -------------------------------- ### Import TiledLighting Addon Source: https://threejs.org/docs/pages/TiledLighting.html Shows the necessary import statement to use TiledLighting, which is an addon and requires explicit import. Refer to the Three.js installation guide for addon setup. ```javascript import { TiledLighting } from 'three/addons/lighting/TiledLighting.js'; ``` -------------------------------- ### GPUComputationRenderer Initialization and Usage Source: https://threejs.org/docs/pages/GPUComputationRenderer.html Demonstrates the basic setup and usage of GPUComputationRenderer, including adding variables, setting dependencies, initializing, and computing in a frame. ```APIDOC ## GPUComputationRenderer Basic Usage ### Description This example shows how to initialize and use the `GPUComputationRenderer` for performing computations on the GPU. It covers creating textures, adding variables with their respective shaders, setting up dependencies between variables, and executing the computation. ### Method ```javascript // Initialization const gpuCompute = new GPUComputationRenderer( 1024, 1024, renderer ); // Create initial state float textures const pos0 = gpuCompute.createTexture(); const vel0 = gpuCompute.createTexture(); // Fill texture data here... // Add texture variables const velVar = gpuCompute.addVariable( "textureVelocity", fragmentShaderVel, vel0 ); const posVar = gpuCompute.addVariable( "texturePosition", fragmentShaderPos, pos0 ); // Add variable dependencies gpuCompute.setVariableDependencies( velVar, [ velVar, posVar ] ); gpuCompute.setVariableDependencies( posVar, [ velVar, posVar ] ); // Add custom uniforms velVar.material.uniforms.time = { value: 0.0 }; // Check for completeness const error = gpuCompute.init(); if ( error !== null ) { console.error( error ); } // In each frame... // Compute! gpuCompute.compute(); // Update texture uniforms in your visualization materials with the gpu renderer output myMaterial.uniforms.myTexture.value = gpuCompute.getCurrentRenderTarget( posVar ).texture; // Do your rendering renderer.render( myScene, myCamera ); ``` ### Parameters - **sizeX** (number) - The width of the computation grid. - **sizeY** (number) - The height of the computation grid. - **renderer** (WebGLRenderer) - The WebGL renderer instance. ### Request Body N/A for initialization. Shader code is provided via `addVariable`. ### Response #### Success Response (init) - **error** (string | null) - Returns null if initialization is successful, otherwise an error message. #### Response Example (init) ```json null ``` ### Notes - Variable names should be valid GLSL identifiers and avoid collisions with THREE.js built-in identifiers. - A common naming convention is to prefix variable names with `texture`, e.g., `texturePosition`. - The `resolution` uniform (`vec2`) is automatically available in the shaders, representing `sizeX` and `sizeY`. ``` -------------------------------- ### MaxMipLevelNode Usage Example Source: https://threejs.org/docs/pages/MaxMipLevelNode.html Demonstrates how to use the MaxMipLevelNode to get the maximum mipmap level for a texture node. This function is typically used within a Three.js node-based material setup. ```javascript const level = maxMipLevel( textureNode ); ``` -------------------------------- ### FunctionOverloadingNode Methods Source: https://threejs.org/docs/pages/FunctionOverloadingNode.html Documentation for the methods available on the FunctionOverloadingNode class, including getting candidate functions, node types, and setup. ```APIDOC ## FunctionOverloadingNode Methods ### .getCandidateFn( builder : NodeBuilder ) : FunctionNode Returns the candidate function for the current parameters. **Parameters:** * **builder** (NodeBuilder) - The current node builder. **Returns:** The candidate function. ### .getNodeType( builder : NodeBuilder ) : string This method is overwritten since the node type is inferred from the function's return type. **Parameters:** * **builder** (NodeBuilder) - The current node builder. **Overrides:** [Node#getNodeType](Node.html#getNodeType) **Returns:** The node type. ### .setup( builder : NodeBuilder ) : Node Sets up the node for the current parameters. **Parameters:** * **builder** (NodeBuilder) - The current node builder. **Overrides:** [Node#setup](Node.html#setup) **Returns:** The setup node. ``` -------------------------------- ### Import FlyControls in JavaScript Source: https://threejs.org/docs/pages/FlyControls.html This code snippet demonstrates how to import the FlyControls class from the Three.js addons. Ensure you have followed the installation guide for addons. ```javascript import { FlyControls } from 'three/addons/controls/FlyControls.js'; ``` -------------------------------- ### Create and Add PointLightHelper - JavaScript Source: https://threejs.org/docs/pages/PointLightHelper.html This example demonstrates how to create a PointLight, add it to a scene, and then visualize it using a PointLightHelper. The helper is initialized with the PointLight instance and an optional sphere size. ```javascript const pointLight = new THREE.PointLight( 0xff0000, 1, 100 ); pointLight.position.set( 10, 10, 10 ); scene.add( pointLight ); const sphereSize = 1; const pointLightHelper = new THREE.PointLightHelper( pointLight, sphereSize ); scene.add( pointLightHelper ); ``` -------------------------------- ### Import GammaCorrectionShader in JavaScript Source: https://threejs.org/docs/pages/module-GammaCorrectionShader.html This snippet shows how to import the GammaCorrectionShader from the Three.js addons. It is necessary to import addons explicitly as shown in the Three.js installation guide. ```javascript import { GammaCorrectionShader } from 'three/addons/shaders/GammaCorrectionShader.js'; ``` -------------------------------- ### Import ProgressiveLightMap Addon Source: https://threejs.org/docs/pages/ProgressiveLightMap.html This code snippet demonstrates how to import the ProgressiveLightMap addon from the three.js library. It is necessary to explicitly import addons as shown in the installation guide. ```javascript import { ProgressiveLightMap } from 'three/addons/misc/ProgressiveLightMap.js'; ``` -------------------------------- ### Instantiate Points with PointsNodeMaterial Source: https://threejs.org/docs/pages/PointsNodeMaterial.html A basic example of creating a point cloud using Three.js Points geometry and a PointsNodeMaterial. Note that size is not directly controllable with this setup in WebGPU. ```javascript const pointCloud = new THREE.Points( geometry, new THREE.PointsNodeMaterial() ); ``` -------------------------------- ### Initialize and Use GPUComputationRenderer in JavaScript Source: https://threejs.org/docs/pages/GPUComputationRenderer.html Demonstrates the basic workflow of initializing GPUComputationRenderer, adding variables with their shaders and initial textures, setting dependencies, and performing computations. It also shows how to update visualization materials with the computed textures. ```javascript const gpuCompute = new GPUComputationRenderer( 1024, 1024, renderer ); const pos0 = gpuCompute.createTexture(); const vel0 = gpuCompute.createTexture(); // fill texture data... const velVar = gpuCompute.addVariable( "textureVelocity", fragmentShaderVel, vel0 ); const posVar = gpuCompute.addVariable( "texturePosition", fragmentShaderPos, pos0 ); gpuCompute.setVariableDependencies( velVar, [ velVar, posVar ] ); gpuCompute.setVariableDependencies( posVar, [ velVar, posVar ] ); velVar.material.uniforms.time = { value: 0.0 }; const error = gpuCompute.init(); if ( error !== null ) { console.error( error ); } // In each frame... gpuCompute.compute(); myMaterial.uniforms.myTexture.value = gpuCompute.getCurrentRenderTarget( posVar ).texture; renderer.render( myScene, myCamera ); ``` -------------------------------- ### Import BokehShader - JavaScript Source: https://threejs.org/docs/pages/module-BokehShader.html This code snippet demonstrates how to import the BokehShader addon into a Three.js project. It requires explicit import as specified in the Three.js installation guide for addons. ```javascript import { BokehShader } from 'three/addons/shaders/BokehShader.js'; ``` -------------------------------- ### PointLightNode Methods Source: https://threejs.org/docs/pages/PointLightNode.html Documentation for the methods of the PointLightNode class, including `setupShadowNode` and `update`. ```APIDOC ## PointLightNode Methods ### Description Methods available on the PointLightNode. ### Method: setupShadowNode #### Description Overwritten to setup point light specific shadow. #### Method Method #### Endpoint N/A (Instance method) #### Parameters None ### Method: update #### Description Overwritten to updated point light specific uniforms. #### Method Method #### Endpoint N/A (Instance method) #### Parameters - **frame** (NodeFrame) - Required - A reference to the current node frame. ### Request Example ```json { "frame": { "update": true } } ``` ### Response #### Success Response (200) These methods do not return a response body, they perform actions on the node. #### Response Example N/A ``` -------------------------------- ### Import RapierPhysics Addon for Three.js Source: https://threejs.org/docs/pages/RapierPhysics.html Demonstrates how to explicitly import the RapierPhysics addon into a Three.js project. This is a necessary step as outlined in the Three.js installation guide for addons. ```javascript import { RapierPhysics } from 'three/addons/physics/RapierPhysics.js'; ``` -------------------------------- ### Basic Three.js Scene with WebGLRenderer Source: https://context7_llms A complete HTML example setting up a basic Three.js scene using WebGLRenderer. It includes scene, camera, renderer, orbit controls, lighting, a cube mesh, and handles window resizing and an animation loop. ```html Three.js Basic Scene ``` -------------------------------- ### GLSLNodeBuilder - .setupPBO() Source: https://threejs.org/docs/pages/GLSLNodeBuilder.html Sets up the Pixel Buffer Object (PBO) for a given storage buffer node. This is often used for efficient data transfer between CPU and GPU. ```APIDOC ## .setupPBO( storageBufferNode : StorageBufferNode ) ### Description Setups the Pixel Buffer Object (PBO) for the given storage buffer node. This is often used for efficient data transfer between CPU and GPU. ### Method POST ### Endpoint N/A (Class method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **storageBufferNode** (StorageBufferNode) - Required - The storage buffer node for which to setup the PBO. ### Request Example ```json { "storageBufferNode": "" } ``` ### Response #### Success Response (200) No specific response body defined for this method, typically indicates successful setup. #### Response Example ```json { "status": "pbo_setup_complete" } ``` ``` -------------------------------- ### Import Text2D Addon in JavaScript Source: https://threejs.org/docs/pages/module-Text2D.html This snippet shows how to import the Text2D addon from the Three.js library. It is necessary to explicitly import addons as shown in the Three.js installation guide. ```javascript import * as Text2D from 'three/addons/webxr/Text2D.js'; ``` -------------------------------- ### Import WebGPU Addon - JavaScript Source: https://threejs.org/docs/pages/WebGPU.html Imports the WebGPU utility module from the Three.js addons. This is a necessary step before using any of its functionalities. Ensure you have followed the installation guide for addons. ```javascript import WebGPU from 'three/addons/capabilities/WebGPU.js'; ``` -------------------------------- ### ViewHelper Constructor and Usage Source: https://threejs.org/docs/pages/ViewHelper.html Demonstrates how to import and instantiate the ViewHelper class, along with its core properties and methods for rendering and interaction. ```APIDOC ## ViewHelper A special type of helper that visualizes the camera's transformation in a small viewport area as an axes helper. ### Import ```js import { ViewHelper } from 'three/addons/helpers/ViewHelper.js'; ``` ### Constructor #### new ViewHelper( camera : Camera, domElement : HTMLElement ) Constructs a new view helper. **Parameters** - **camera** (Camera) - The camera whose transformation should be visualized. - **domElement** (HTMLElement) - The DOM element that is used to render the view. ### Properties - **.animating** (boolean, readonly) - Whether the helper is currently animating or not. Default is `false`. - **.center** (Vector3) - The helper's center point. - **.isViewHelper** (boolean, readonly) - This flag can be used for type testing. Default is `true`. - **.location** (Object) - Controls the position of the helper in the viewport. Use `top`/`bottom` for vertical positioning and `left`/`right` for horizontal. If `left` is `null`, `right` is used. If `top` is `null`, `bottom` is used. ### Methods #### .dispose() Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app. #### .handleClick( event : PointerEvent ) : boolean This method should be called when a click or pointer event has happened in the app. **Parameters** - **event** (PointerEvent) - The event to process. **Returns** - boolean - Whether an intersection with the helper has been detected or not. #### .render( renderer : WebGLRenderer | WebGPURenderer ) Renders the helper in a separate view in the viewport. Position is controlled by the `location` property. **Parameters** - **renderer** (WebGLRenderer | WebGPURenderer) - The renderer. #### .setLabelStyle( font : string, color : string, radius : number ) Sets the label style. Has no effect when the axes are unlabeled. **Parameters** - **font** (string) - The label font. Default is `'24px Arial'`. - **color** (string) - The label color. Default is `'#000000'`. - **radius** (number) - The label radius. Default is `14`. #### .setLabels( labelX : string | undefined, labelY : string | undefined, labelZ : string | undefined ) Sets labels for each axis. By default, they are unlabeled. **Parameters** - **labelX** (string | undefined) - The label for the x-axis. - **labelY** (string | undefined) - The label for the y-axis. - **labelZ** (string | undefined) - The label for the z-axis. #### .update( delta : number ) Updates the helper. This method should be called in the app's animation loop. **Parameters** - **delta** (number) - The delta time in seconds. ``` -------------------------------- ### Import SAOPass in JavaScript Source: https://threejs.org/docs/pages/SAOPass.html This code snippet demonstrates how to import the SAOPass addon from the three.js library. Ensure you have the addons correctly set up in your project according to the Three.js installation guide. ```javascript import { SAOPass } from 'three/addons/postprocessing/SAOPass.js'; ``` -------------------------------- ### Import PositionalAudioHelper Source: https://threejs.org/docs/pages/PositionalAudioHelper.html Shows the explicit import statement required to use the PositionalAudioHelper addon in your Three.js project. This follows the addon import pattern described in the Three.js installation guide. ```javascript import { PositionalAudioHelper } from 'three/addons/helpers/PositionalAudioHelper.js'; ``` -------------------------------- ### GLSLNodeParser Constructor Source: https://threejs.org/docs/pages/GLSLNodeParser.html Initializes a new instance of the GLSLNodeParser. ```APIDOC ## Constructor GLSLNodeParser ### Description Initializes a new instance of the GLSLNodeParser. ### Method `new()` ### Endpoint N/A ### Parameters None ### Request Example ```javascript const parser = new GLSLNodeParser(); ``` ### Response #### Success Response (200) An instance of GLSLNodeParser. #### Response Example ```json { "instance": "GLSLNodeParser" } ``` ``` -------------------------------- ### Import JoltPhysics Addon Source: https://threejs.org/docs/pages/JoltPhysics.html Demonstrates how to explicitly import the JoltPhysics addon into your three.js project. This is a required step for using the JoltPhysics functionality, as outlined in the three.js installation guide for addons. ```javascript import { JoltPhysics } from 'three/addons/physics/JoltPhysics.js'; ``` -------------------------------- ### Import ImprovedNoise in JavaScript Source: https://threejs.org/docs/pages/ImprovedNoise.html This snippet demonstrates how to import the ImprovedNoise class from the Three.js addons. Ensure you have correctly set up your project for addon imports as per the Three.js installation guide. ```javascript import { ImprovedNoise } from 'three/addons/math/ImprovedNoise.js'; ``` -------------------------------- ### InputNode Constructor and Properties Source: https://threejs.org/docs/pages/InputNode.html Details on how to construct an InputNode and its available properties. ```APIDOC ## InputNode Base class for representing data input nodes. ### Description Represents a node that takes input values, which can be any JavaScript primitive, functions, array buffers, or three.js objects. ### Constructor #### new InputNode( value : any, nodeType : string ) Constructs a new input node. **Parameters:** - **value** (any) - The value of this node. This can be any JS primitive, functions, array buffers or even three.js objects (vector, matrices, colors). - **nodeType** (string) - The node type. If no explicit type is defined, the node tries to derive the type from its value. Defaults to `null`. ### Properties - **.isInputNode** (boolean) - Readonly. Flag for type testing. Defaults to `true`. - **.precision** ('low' | 'medium' | 'high') - The precision of the value in the shader. Defaults to `null`. - **.value** (any) - The value of this node. This can be any JS primitive, functions, array buffers or even three.js objects (vector, matrices, colors). ### Source [src/nodes/core/InputNode.js](https://github.com/mrdoob/three.js/blob/master/src/nodes/core/InputNode.js) ``` -------------------------------- ### Initialize and Configure ShadowMapViewer Source: https://threejs.org/docs/pages/ShadowMapViewer.html Demonstrates how to create an instance of ShadowMapViewer, position it on the screen, set its dimensions, and update it. This is typically done once during initialization. ```javascript const lightShadowMapViewer = new ShadowMapViewer( light ); lightShadowMapViewer.position.x = 10; lightShadowMapViewer.position.y = SCREEN_HEIGHT - ( SHADOW_MAP_HEIGHT / 4 ) - 10; lightShadowMapViewer.size.width = SHADOW_MAP_WIDTH / 4; lightShadowMapViewer.size.height = SHADOW_MAP_HEIGHT / 4; lightShadowMapViewer.update(); ``` -------------------------------- ### Import GTAOShader in JavaScript Source: https://threejs.org/docs/pages/module-GTAOShader.html This code snippet demonstrates how to import the GTAOShader from the Three.js addons. This is a necessary step before utilizing the shader in your Three.js project. Ensure you have followed the addon installation guide. ```javascript import { GTAOShader } from 'three/addons/shaders/GTAOShader.js'; ``` -------------------------------- ### Info Component Constructor Source: https://threejs.org/docs/pages/Info.html Initializes a new info component for tracking rendering statistics. ```APIDOC ## new Info() ### Description Constructs a new info component. ### Method `new` ### Endpoint N/A (Constructor) ### Parameters None ### Request Example ```javascript const info = new Info(); ``` ### Response #### Success Response (Instance) - **info** (Info) - An instance of the Info component. #### Response Example ```javascript // info object is created ``` ``` -------------------------------- ### USDComposer Constructor Source: https://threejs.org/docs/pages/USDComposer.html Initializes a new instance of USDComposer. ```APIDOC ## new USDComposer() ### Description Initializes a new instance of USDComposer. ### Method `new` ### Endpoint N/A ### Parameters None ### Request Example ```javascript const composer = new USDComposer(); ``` ### Response #### Success Response (Instance) - **USDComposer** - An instance of the USDComposer class. #### Response Example ```json { "instance": "USDComposer" } ``` ``` -------------------------------- ### Import XRHandModelFactory - JavaScript Source: https://threejs.org/docs/pages/XRHandModelFactory.html This snippet shows the explicit import statement required to use the XRHandModelFactory addon in your Three.js project. Ensure you have the correct path to the addon file as per the Three.js installation guide. ```javascript import { XRHandModelFactory } from 'three/addons/webxr/XRHandModelFactory.js'; ``` -------------------------------- ### WebGLRenderer Constructor Source: https://threejs.org/docs/pages/WebGLRenderer.html Initializes a new WebGLRenderer instance with optional parameters. ```APIDOC ## Constructor ### new WebGLRenderer( parameters : WebGLRenderer~Options ) Constructs a new WebGL renderer. **parameters** The configuration parameter. ``` -------------------------------- ### Import Lensflare Addon Source: https://threejs.org/docs/pages/Lensflare.html Shows the necessary import statement to use the Lensflare class in your Three.js project. Lensflare is an addon and requires explicit import as per the Three.js installation guide for addons. ```javascript import { Lensflare } from 'three/addons/objects/Lensflare.js'; ``` -------------------------------- ### Import HelixCurve from Three.js Addons Source: https://threejs.org/docs/pages/HelixCurve.html This code snippet demonstrates how to import the HelixCurve class from the Three.js addons. It requires explicit import due to its addon nature, as detailed in the Three.js installation guide. ```javascript import { HelixCurve } from 'three/addons/curves/CurveExtras.js'; ``` -------------------------------- ### LineDashedNodeMaterial Methods Source: https://threejs.org/docs/pages/LineDashedNodeMaterial.html Documentation for the `setupVariants` method of LineDashedNodeMaterial, used for setting up dash-specific node variables. ```APIDOC ## Methods ### .setupVariants( builder : NodeBuilder ) Setups the dash specific node variables. **builder** The current node builder. **Overrides:** [NodeMaterial#setupVariants](NodeMaterial.html#setupVariants) ## Source [src/materials/nodes/LineDashedNodeMaterial.js](https://github.com/mrdoob/three.js/blob/master/src/materials/nodes/LineDashedNodeMaterial.js) ``` -------------------------------- ### IESSpotLight Constructor Source: https://threejs.org/docs/pages/IESSpotLight.html Constructs a new IESSpotLight with specified color, intensity, distance, angle, penumbra, and decay. ```APIDOC ## new IESSpotLight( color, intensity, distance, angle, penumbra, decay ) ### Description Constructs a new IES spot light. This light can only be used with WebGPURenderer. ### Method `new` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **color** (number | Color | string) - The light's color. Default is `0xffffff`. * **intensity** (number) - The light's strength/intensity measured in candela (cd). Default is `1`. * **distance** (number) - Maximum range of the light. `0` means no limit. Default is `0`. * **angle** (number) - Maximum angle of light dispersion from its direction whose upper bound is `Math.PI/2`. Default is `Math.PI/3`. * **penumbra** (number) - Percent of the spotlight cone that is attenuated due to penumbra. Value range is `[0,1]`. Default is `0`. * **decay** (number) - The amount the light dims along the distance of the light. Default is `2`. ### Request Example ```json { "example": "new IESSpotLight(0xff0000, 2, 10, Math.PI/4, 0.5, 1)" } ``` ### Response #### Success Response (200) * **IESSpotLight** (Object) - The newly created IESSpotLight instance. #### Response Example ```json { "example": "// Returns an instance of IESSpotLight" } ``` ``` -------------------------------- ### Setup Multiple Render Targets (MRT) with Three.js TSL Source: https://context7_llms This example shows how to configure Multiple Render Targets (MRT) for a render pass using Three.js TSL. It defines separate outputs for 'output' and 'emissive' and retrieves their respective texture nodes. ```javascript import { pass, mrt, output, emissive } from 'three/tsl'; const scenePass = pass( scene, camera ); // Setup MRT scenePass.setMRT( mrt( { output: output, emissive: emissive } ) ); const outputNode = scenePass.getTextureNode( 'output' ); const emissiveNode = scenePass.getTextureNode( 'emissive' ); ``` -------------------------------- ### BuiltinNode Constructor and Properties Source: https://threejs.org/docs/pages/BuiltinNode.html Details on how to construct a BuiltinNode and its available properties. ```APIDOC ## BuiltinNode The node allows to set values for built-in shader variables. That is required for features like hardware-accelerated vertex clipping. ### Constructor #### new BuiltinNode( name : string ) Constructs a new builtin node. **Parameters** * **name** (string) - The name of the built-in shader variable. ### Properties #### .isBuiltinNode : boolean (readonly) This flag can be used for type testing. Default is `true`. #### .name : string The name of the built-in shader variable. **Overrides:** [Node#name](Node.html#name) ``` -------------------------------- ### CubeTextureLoader Example Source: https://threejs.org/docs/pages/CubeTexture.html Example of how to load a CubeTexture using THREE.CubeTextureLoader. ```APIDOC ## CubeTextureLoader Example ### Description This example demonstrates how to use `THREE.CubeTextureLoader` to load six image files and create a `CubeTexture`. ### Method `loader.load()` ### Endpoint N/A (Client-side code) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```javascript const loader = new THREE.CubeTextureLoader(); loader.setPath( 'textures/cube/pisa/' ); const textureCube = loader.load( [ 'px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png' ] ); const material = new THREE.MeshBasicMaterial( { color: 0xffffff, envMap: textureCube } ); ``` ### Response #### Success Response (200) - **textureCube** (CubeTexture) - The loaded cube texture. #### Response Example ```javascript // textureCube object will be a THREE.CubeTexture instance // Example structure (simplified): { images: [ ImageElement1, ImageElement2, ImageElement3, ImageElement4, ImageElement5, ImageElement6 ], isCubeTexture: true, // ... other properties } ``` ``` -------------------------------- ### Initialize and Create RectAreaLight (JavaScript) Source: https://threejs.org/docs/pages/RectAreaLight.html Initializes necessary libraries and creates a RectAreaLight instance. This code demonstrates setting up the light for both WebGL and WebGPU renderers, defining its color, intensity, dimensions, position, and adding it to the scene. ```javascript RectAreaLightUniformsLib.init(); // only relevant for WebGLRenderer THREE.RectAreaLightNode.setLTC( RectAreaLightTexturesLib.init() ); // only relevant for WebGPURenderer const intensity = 1; const width = 10; const height = 10; const rectLight = new THREE.RectAreaLight( 0xffffff, intensity, width, height ); rectLight.position.set( 5, 5, 0 ); rectLight.lookAt( 0, 0, 0 ); scene.add( rectLight ) ``` -------------------------------- ### Instantiate EXRLoader Source: https://threejs.org/docs/pages/EXRLoader.html Illustrates the constructor for EXRLoader, which optionally accepts a LoadingManager. This allows for custom loading processes and progress tracking. ```javascript const manager = new THREE.LoadingManager(); const loader = new EXRLoader( manager ); ``` -------------------------------- ### BitcastNode Constructor and Properties Source: https://threejs.org/docs/pages/BitcastNode.html Details on how to construct a BitcastNode and its available properties. ```APIDOC ## BitcastNode This node represents an operation that reinterprets the bit representation of a value in one type as a value in another type. ### Constructor ### new BitcastNode( valueNode : Node, conversionType : string, inputType : string ) Constructs a new bitcast node. **Parameters** * **valueNode** (Node) - The value to convert. * **conversionType** (string) - The type to convert to. * **inputType** (string) - The expected input data type of the bitcast operation. Default is `null`. ### Properties * **conversionType** (string) - The type the value will be converted to. * **inputType** (string) - The expected input data type of the bitcast operation. Default is `null`. * **isBitcastNode** (boolean) - This flag can be used for type testing. Default is `true`. * **valueNode** (Node) - The data to bitcast to a new type. ### Source [src/nodes/math/BitcastNode.js](https://github.com/mrdoob/three.js/blob/master/src/nodes/math/BitcastNode.js) ``` -------------------------------- ### FlipNode Constructor Example Source: https://threejs.org/docs/pages/FlipNode.html This example shows how to instantiate a FlipNode. It requires a source node and a string specifying which components (e.g., 'x', 'xy') to flip. ```javascript new FlipNode( sourceNode, components ) ``` -------------------------------- ### Load MaterialX File Asynchronously Source: https://threejs.org/docs/pages/MaterialXLoader.html This code example demonstrates how to instantiate the MaterialXLoader, set a base path for assets, and then asynchronously load a MaterialX file. The loaded materials are then available for use, typically with the WebGPURenderer. ```javascript const loader = new MaterialXLoader().setPath( SAMPLE_PATH ); const materials = await loader.loadAsync( 'standard_surface_brass_tiled.mtlx' ); ``` -------------------------------- ### THREE.Shape Source: https://threejs.org/docs/pages/Shape.html Defines an arbitrary 2D shape plane using paths with optional holes. It can be used with ExtrudeGeometry, ShapeGeometry, to get points, or to get triangulated faces. ```APIDOC ## THREE.Shape ### Description Defines an arbitrary 2D shape plane using paths with optional holes. It can be used with [ExtrudeGeometry](ExtrudeGeometry.html), [ShapeGeometry](ShapeGeometry.html), to get points, or to get triangulated faces. ### Constructor #### new Shape( points : Array. ) Constructs a new shape. **Parameters** * **points** (Array.) - An array of 2D points defining the shape. ### Properties #### .holes : Array. (readonly) Defines the holes in the shape. Hole definitions must use the opposite winding order (CW/CCW) than the outer shape. #### .uuid : string (readonly) The UUID of the shape. ### Methods #### .extractPoints( divisions : number ) : Object Returns an object that holds contour data for the shape and its holes as arrays of 2D points. **Parameters** * **divisions** (number) - The fineness of the result. **Returns:** An object with contour data. #### .getPointsHoles( divisions : number ) : Array.> Returns an array representing each contour of the holes as a list of 2D points. **Parameters** * **divisions** (number) - The fineness of the result. **Returns:** The holes as a series of 2D points. ### Source [src/extras/core/Shape.js](https://github.com/mrdoob/three.js/blob/master/src/extras/core/Shape.js) ``` -------------------------------- ### UniformNode Constructor and Properties Source: https://threejs.org/docs/pages/UniformNode.html Details on how to construct a UniformNode and its available properties. ```APIDOC ## UniformNode Class for representing a uniform. ### Constructor #### new UniformNode( value : any, nodeType : string ) Constructs a new uniform node. **Parameters:** * **value** (any) - The value of this node. Usually a JS primitive or three.js object (vector, matrix, color, texture). * **nodeType** (string) - The node type. If no explicit type is defined, the node tries to derive the type from its value. Default is `null`. ### Properties * **.groupNode** (UniformGroupNode) - The uniform group of this uniform. By default, uniforms are managed per object but they might belong to a shared group which is updated per frame or render call. * **.isUniformNode** (boolean, readonly) - This flag can be used for type testing. Default is `true`. * **.name** (string) - The name or label of the uniform. Default is `''`. Overrides: [InputNode#name](InputNode.html#name). ``` -------------------------------- ### KeyframeTrack Constructor and Properties Source: https://threejs.org/docs/pages/KeyframeTrack.html Details on how to construct a KeyframeTrack and its configurable properties. ```APIDOC ## KeyframeTrack Represents a timed sequence of keyframes, which are composed of lists of times and related values, and which are used to animate a specific property of an object. ### Constructor #### new KeyframeTrack( name : string, times : Array., values : Array.<(number|string|boolean)>, interpolation : InterpolateLinear | InterpolateDiscrete | InterpolateSmooth | InterpolateBezier ) Constructs a new keyframe track. * **name** (string) - The keyframe track's name. * **times** (Array) - A list of keyframe times. * **values** (Array<(number|string|boolean)>) - A list of keyframe values. * **interpolation** (InterpolateLinear | InterpolateDiscrete | InterpolateSmooth | InterpolateBezier) - The interpolation type. ### Properties * **.DefaultInterpolation** (InterpolateLinear | InterpolateDiscrete | InterpolateSmooth | InterpolateBezier) - The default interpolation type of this keyframe track. Default is `InterpolateLinear`. * **.TimeBufferType** (TypedArray | Array) - The time buffer type of this keyframe track. Default is `Float32Array.constructor`. * **.ValueBufferType** (TypedArray | Array) - The value buffer type of this keyframe track. Default is `Float32Array.constructor`. * **.ValueTypeName** (string) - The value type name. Default is `''`. * **.name** (string) - The track's name can refer to morph targets or bones or possibly other values within an animated object. See PropertyBinding#parseTrackName for the forms of strings that can be parsed for property binding. * **.times** (Float32Array) - The keyframe times. * **.values** (Float32Array) - The keyframe values. ```