three.js Knowledge Patch
When to load this skill
Load this skill when a task involves:
- upgrading a three.js application or addon;
- choosing between WebGLRenderer and WebGPURenderer APIs;
- migrating TSL, NodeMaterial, shader-node, or compute code;
- diagnosing changed lighting, blending, shadows, depth, or color output;
- updating loaders, exporters, decoder paths, or packaged assets;
- maintaining post-processing, controls, XR, physics, or editor integrations.
Start with the quick reference below for migration hazards. Open the matching
topic reference before editing code; the references retain API details,
behavior changes, defaults, and batch attribution.
Reference index
| Reference |
Topics |
| Core, animation, and geometry |
Object and scene behavior, animation, serialization, geometry, math, timing |
| Materials, lighting, and textures |
Materials, PBR, lights, shadows, texture behavior, color and blending |
| TSL and node APIs |
TSL migrations, NodeMaterial, shader helpers, node events, compute and transpilation |
| Renderers, GPU backends, and XR |
WebGL, WebGPU, render targets, MRT, GPU resources, depth, WebXR |
| Loaders, exporters, and assets |
Asset formats, loading, export, serialization, codecs, package layout |
| Addons, controls, and post-processing |
Effects, controls, post-processing, browser addons, physics, inspector, editor |
Breaking changes and removals
Audit these before attempting an upgrade:
- Replace
InstancedPointsNodeMaterial with PointsNodeMaterial.
- Replace
RGBELoader with HDRLoader; RGBMLoader is removed.
- Replace
Clock with core Timer; update imports from the former addon path.
- Remove uses of
LightProbe.fromJSON().
- Replace legacy
LuminanceFormat and LuminanceAlphaFormat.
- Replace
PeppersGhostEffect, AnamorphicNode, and TiledLighting.
- Replace
MeshPostProcessingMaterial.
- Stop using removed
Line2NodeMaterial.lineWidth.
- Replace
Line2NodeMaterial.useColor with .vertexColors.
- Replace the scriptable node and
ScriptableNodeResources.
- Replace
VOXMesh and VOXData3DTexture construction with their function APIs.
- Do not use
WebGLCubeRenderTarget with WebGPURenderer; use
CubeRenderTarget.
- Stop depending on
renderAsync(), computeAsync(), or removed
waitForGPU().
- Stop expecting
FileLoader.load() or ImageBitmapLoader.load() to return
a value; use onLoad.
- Replace
DRACOExporter.parse() with parseAsync().
- Stop passing width and height to
SMAAPass and HalftonePass.
- Stop passing
flipVertical to LUTImageLoader; set loader.flip = true.
- Stop resolving example fonts, DRACO exporter encoders, or the LottieLoader
and TTFLoader libraries from bundled package copies.
Deprecations to remove from new code
AnimationClip.parseAnimation()
MeshGouraudMaterial
LottieLoader
premultipliedGaussianBlur()
SkyMesh.isSky; use isSkyMesh
VTKLoader
LWOLoader
Matrix3.scale(), .rotate(), and .translate()
DRACOLoader.setDecoderConfig()
SVGLoader.createShapes(); use shapePath.toShapes()
KTX2Loader.detectSupportAsync(); initialize the renderer, then call
detectSupport()
USDZLoader; use USDLoader
PCFSoftShadowMap; use PCFShadowMap
Final API names
Use final names rather than intermediate or historical spellings.
| Replace |
With |
NodeBuilder.monitor |
NodeBuilder.observer |
timeStampQuerySet |
timestampQuerySet |
varying() |
toVarying() |
vertexStage() |
toVertexStage() |
premult() |
premultiplyAlpha() |
label() |
setName() |
TriplanarTexturesNode |
triplanarTextures() |
EquirectUVNode |
equirectUV() |
MatcapUVNode |
matcapUV |
DFGApprox |
DFGLUT |
directionToFaceDirection |
negateOnBackSide |
PI2 |
TWO_PI |
directionToColor() |
packNormalToRGB() |
colorToDirection() |
unpackRGBToNormal() |
HemisphereLightNode.normalView |
normalWorld |
WebGPU getColorBufferType() |
getOutputBufferType() |
WebGPU Nodes |
NodeManager |
WebGPU RenderPipeline |
RenderObjectPipeline |
WebGPU PostProcessing |
RenderPipeline |
AnaglyphEffect.screenDistance |
planeDistance |
PassNode.setResolution() |
setResolutionScale() |
PassNode.getResolution() |
getResolutionScale() |
WaterMesh.resolution |
resolutionScale |
reverseDepthBuffer constructor option |
reversedDepthBuffer |
USE_REVERSEDEPTHBUF |
USE_REVERSED_DEPTH_BUFFER |
USE_LOGDEPTHBUF |
USE_LOGARITHMIC_DEPTH_BUFFER |
ColorManagement.fromWorkingColorSpace() |
workingToColorSpace() |
ColorManagement.toWorkingColorSpace() |
colorSpaceToWorking() |
ParametricGeometries |
ParametricFunctions |
The renderer shadow transmission switch is
shadowMap.transmitted; do not use the interim color or colored names.
Renderer and backend migration
Initialize asynchronous renderers explicitly:
const renderer = await new THREE.WebGPURenderer(parameters).init();
After initialization, use the synchronous renderer surface unless a specific
API is documented as asynchronous. compileAsync() is genuinely non-blocking.
For backend-sensitive code:
WebGPURenderer can negotiate compatibility mode and upgrade to core mode.
- Antialiasing is disabled if compatibility mode remains active.
- Render targets cannot be resized during XR rendering.
- A zero
object.count suppresses a WebGPU draw.
- Render bundles support transparent objects, MRT, and instanced meshes.
- MRT supports per-attachment blending and material output nodes.
- WebGL MRT supports pixel readback, 2D array textures, and MSAA through the
WebGL backend used by WebGPURenderer.
- Use
initRenderTarget() when explicit WebGPU target initialization is
required.
- Use
renderer.state.pixelStorei() for raw WebGL pixel-store changes.
For reversed depth, use the final constructor and shader identifiers in the
table above. Viewport-depth view-Z helpers and ReversedDepthFuncs also support
reversed depth.
For a premultiplied-alpha WebGPU canvas, use an opaque Scene.background or
opaque renderer.setClearColor() unless HTML-background compositing is
required.
TSL and NodeMaterial migration
Apply these rules before debugging generated shader code:
assign() performs toVar() automatically.
- Use
positionGeometry, not positionLocal, when material.positionNode
needs vertices before internal transforms such as skinning.
- Geometry must provide tangents when the node graph needs them; TSL no longer
creates tangent attributes automatically.
- Geometry without normals is forced to flat shading.
DebugNode callbacks receive raw data.
- The earlier
debug() callback form changed to ( builder, code ).
AfterImageNode.damp is a Node<float>; pass a node constant or uniform.
SpriteNodeMaterial.transparent defaults to true.
SpriteNodeMaterial.sizeAttenuation applies only to perspective cameras.
NodeMaterial honors premultipliedAlpha, supports compute(), and exposes
masking controls.
bufferAttribute() accepts mat3 and mat4.
uniform() accepts booleans.
- Texture nodes support
load(), offsets, 3D reads, storage reads and writes,
and gather operations.
Open the TSL reference for control-flow, event, layout, scope, bit operation,
transpiler, compute-kernel, and helper additions.
Asset pipeline migration
ImageUtils.getDataURL() accepts an optional output MIME type; without an
override, do not assume it preserves the source format.
- Loader cache keys are loader-specific, and
Cache no longer stores Blob
values.
Loader.abort() is the common cancellation entry point.
GLTFLoader no longer detects WebP or AVIF support for the application.
DRACOLoader and KTX2Loader use relative file URLs by default.
- Decoder URLs for glTF use are exported.
FBXLoader converts +Z-up assets to +Y-up; remove duplicate corrective
rotations.
- EXR output is linear-sRGB and supports expanded compression and multipart
forms.
GLTFExporter preserves animation metadata and supports animations spanning
multiple scenes.
MaterialLoader.registerMaterial() and Material.fromJSON() support custom
material deserialization.
RenderTarget.clone() creates independent texture resources.
Visual-output changes to review
Create comparison renders when an upgrade touches:
- corrected blending formulas;
- GGX VNDF PMREM sampling;
- direct-light multi-scattering energy compensation;
- rough-reflection mixing and the WebGL DFG LUT;
- intermediate-metalness, iridescence, or sheen energy conservation;
- shadow filtering and alpha-to-coverage;
- environment or background rotation;
RoomEnvironment-generated PMREMs;
- Neutral tone mapping in editor projects;
- GTAO radius and scale;
- additive SSR compositing and its optional denoiser;
- the rebuilt depth-of-field and temporal-AA nodes.
Safe upgrade workflow
- Search imports, constructors, direct property access, and shader defines for
the removed and renamed surfaces above.
- Open every reference matching the application’s renderer, node system,
post-processing stack, and asset formats.
- Update renderer initialization and loader callbacks before chasing runtime
errors.
- Rebuild TSL graphs around final helper names and position semantics.
- Confirm required normals, tangents, update ranges, and storage-backed
attributes on geometry.
- Revalidate serialized assets, material copies, pivots, and render-target
cloning.
- Compare WebGL and WebGPU output where both backends are supported.
- Capture visual regressions in blending, PBR, shadows, depth, post-processing,
and color-space handling.
1---2name: threejs-knowledge-patch-23description: three.js4license: MIT5---678# three.js Knowledge Patch910## When to load this skill1112Load this skill when a task involves:1314- upgrading a three.js application or addon;15- choosing between WebGLRenderer and WebGPURenderer APIs;16- migrating TSL, NodeMaterial, shader-node, or compute code;17- diagnosing changed lighting, blending, shadows, depth, or color output;18- updating loaders, exporters, decoder paths, or packaged assets;19- maintaining post-processing, controls, XR, physics, or editor integrations.2021Start with the quick reference below for migration hazards. Open the matching22topic reference before editing code; the references retain API details,23behavior changes, defaults, and batch attribution.2425## Reference index2627| Reference | Topics |28| --- | --- |29| [Core, animation, and geometry](references/core-animation-and-geometry.md) | Object and scene behavior, animation, serialization, geometry, math, timing |30| [Materials, lighting, and textures](references/materials-lighting-and-textures.md) | Materials, PBR, lights, shadows, texture behavior, color and blending |31| [TSL and node APIs](references/tsl-and-node-apis.md) | TSL migrations, NodeMaterial, shader helpers, node events, compute and transpilation |32| [Renderers, GPU backends, and XR](references/renderers-gpu-and-xr.md) | WebGL, WebGPU, render targets, MRT, GPU resources, depth, WebXR |33| [Loaders, exporters, and assets](references/loaders-exporters-and-assets.md) | Asset formats, loading, export, serialization, codecs, package layout |34| [Addons, controls, and post-processing](references/addons-controls-and-post-processing.md) | Effects, controls, post-processing, browser addons, physics, inspector, editor |3536## Breaking changes and removals3738Audit these before attempting an upgrade:3940- Replace `InstancedPointsNodeMaterial` with `PointsNodeMaterial`.41- Replace `RGBELoader` with `HDRLoader`; `RGBMLoader` is removed.42- Replace `Clock` with core `Timer`; update imports from the former addon path.43- Remove uses of `LightProbe.fromJSON()`.44- Replace legacy `LuminanceFormat` and `LuminanceAlphaFormat`.45- Replace `PeppersGhostEffect`, `AnamorphicNode`, and `TiledLighting`.46- Replace `MeshPostProcessingMaterial`.47- Stop using removed `Line2NodeMaterial.lineWidth`.48- Replace `Line2NodeMaterial.useColor` with `.vertexColors`.49- Replace the scriptable node and `ScriptableNodeResources`.50- Replace `VOXMesh` and `VOXData3DTexture` construction with their function APIs.51- Do not use `WebGLCubeRenderTarget` with `WebGPURenderer`; use52 `CubeRenderTarget`.53- Stop depending on `renderAsync()`, `computeAsync()`, or removed54 `waitForGPU()`.55- Stop expecting `FileLoader.load()` or `ImageBitmapLoader.load()` to return56 a value; use `onLoad`.57- Replace `DRACOExporter.parse()` with `parseAsync()`.58- Stop passing width and height to `SMAAPass` and `HalftonePass`.59- Stop passing `flipVertical` to `LUTImageLoader`; set `loader.flip = true`.60- Stop resolving example fonts, DRACO exporter encoders, or the LottieLoader61 and TTFLoader libraries from bundled package copies.6263## Deprecations to remove from new code6465- `AnimationClip.parseAnimation()`66- `MeshGouraudMaterial`67- `LottieLoader`68- `premultipliedGaussianBlur()`69- `SkyMesh.isSky`; use `isSkyMesh`70- `VTKLoader`71- `LWOLoader`72- `Matrix3.scale()`, `.rotate()`, and `.translate()`73- `DRACOLoader.setDecoderConfig()`74- `SVGLoader.createShapes()`; use `shapePath.toShapes()`75- `KTX2Loader.detectSupportAsync()`; initialize the renderer, then call76 `detectSupport()`77- `USDZLoader`; use `USDLoader`78- `PCFSoftShadowMap`; use `PCFShadowMap`7980## Final API names8182Use final names rather than intermediate or historical spellings.8384| Replace | With |85| --- | --- |86| `NodeBuilder.monitor` | `NodeBuilder.observer` |87| `timeStampQuerySet` | `timestampQuerySet` |88| `varying()` | `toVarying()` |89| `vertexStage()` | `toVertexStage()` |90| `premult()` | `premultiplyAlpha()` |91| `label()` | `setName()` |92| `TriplanarTexturesNode` | `triplanarTextures()` |93| `EquirectUVNode` | `equirectUV()` |94| `MatcapUVNode` | `matcapUV` |95| `DFGApprox` | `DFGLUT` |96| `directionToFaceDirection` | `negateOnBackSide` |97| `PI2` | `TWO_PI` |98| `directionToColor()` | `packNormalToRGB()` |99| `colorToDirection()` | `unpackRGBToNormal()` |100| `HemisphereLightNode.normalView` | `normalWorld` |101| WebGPU `getColorBufferType()` | `getOutputBufferType()` |102| WebGPU `Nodes` | `NodeManager` |103| WebGPU `RenderPipeline` | `RenderObjectPipeline` |104| WebGPU `PostProcessing` | `RenderPipeline` |105| `AnaglyphEffect.screenDistance` | `planeDistance` |106| `PassNode.setResolution()` | `setResolutionScale()` |107| `PassNode.getResolution()` | `getResolutionScale()` |108| `WaterMesh.resolution` | `resolutionScale` |109| `reverseDepthBuffer` constructor option | `reversedDepthBuffer` |110| `USE_REVERSEDEPTHBUF` | `USE_REVERSED_DEPTH_BUFFER` |111| `USE_LOGDEPTHBUF` | `USE_LOGARITHMIC_DEPTH_BUFFER` |112| `ColorManagement.fromWorkingColorSpace()` | `workingToColorSpace()` |113| `ColorManagement.toWorkingColorSpace()` | `colorSpaceToWorking()` |114| `ParametricGeometries` | `ParametricFunctions` |115116The renderer shadow transmission switch is117`shadowMap.transmitted`; do not use the interim `color` or `colored` names.118119## Renderer and backend migration120121Initialize asynchronous renderers explicitly:122123```js124const renderer = await new THREE.WebGPURenderer(parameters).init();125```126127After initialization, use the synchronous renderer surface unless a specific128API is documented as asynchronous. `compileAsync()` is genuinely non-blocking.129130For backend-sensitive code:131132- `WebGPURenderer` can negotiate compatibility mode and upgrade to core mode.133- Antialiasing is disabled if compatibility mode remains active.134- Render targets cannot be resized during XR rendering.135- A zero `object.count` suppresses a WebGPU draw.136- Render bundles support transparent objects, MRT, and instanced meshes.137- MRT supports per-attachment blending and material output nodes.138- WebGL MRT supports pixel readback, 2D array textures, and MSAA through the139 WebGL backend used by WebGPURenderer.140- Use `initRenderTarget()` when explicit WebGPU target initialization is141 required.142- Use `renderer.state.pixelStorei()` for raw WebGL pixel-store changes.143144For reversed depth, use the final constructor and shader identifiers in the145table above. Viewport-depth view-Z helpers and `ReversedDepthFuncs` also support146reversed depth.147148For a premultiplied-alpha WebGPU canvas, use an opaque `Scene.background` or149opaque `renderer.setClearColor()` unless HTML-background compositing is150required.151152## TSL and NodeMaterial migration153154Apply these rules before debugging generated shader code:155156- `assign()` performs `toVar()` automatically.157- Use `positionGeometry`, not `positionLocal`, when `material.positionNode`158 needs vertices before internal transforms such as skinning.159- Geometry must provide tangents when the node graph needs them; TSL no longer160 creates tangent attributes automatically.161- Geometry without normals is forced to flat shading.162- `DebugNode` callbacks receive raw data.163- The earlier `debug()` callback form changed to `( builder, code )`.164- `AfterImageNode.damp` is a `Node<float>`; pass a node constant or uniform.165- `SpriteNodeMaterial.transparent` defaults to `true`.166- `SpriteNodeMaterial.sizeAttenuation` applies only to perspective cameras.167- `NodeMaterial` honors `premultipliedAlpha`, supports `compute()`, and exposes168 masking controls.169- `bufferAttribute()` accepts `mat3` and `mat4`.170- `uniform()` accepts booleans.171- Texture nodes support `load()`, offsets, 3D reads, storage reads and writes,172 and gather operations.173174Open the TSL reference for control-flow, event, layout, scope, bit operation,175transpiler, compute-kernel, and helper additions.176177## Asset pipeline migration178179- `ImageUtils.getDataURL()` accepts an optional output MIME type; without an180 override, do not assume it preserves the source format.181- Loader cache keys are loader-specific, and `Cache` no longer stores `Blob`182 values.183- `Loader.abort()` is the common cancellation entry point.184- `GLTFLoader` no longer detects WebP or AVIF support for the application.185- `DRACOLoader` and `KTX2Loader` use relative file URLs by default.186- Decoder URLs for glTF use are exported.187- `FBXLoader` converts +Z-up assets to +Y-up; remove duplicate corrective188 rotations.189- EXR output is linear-sRGB and supports expanded compression and multipart190 forms.191- `GLTFExporter` preserves animation metadata and supports animations spanning192 multiple scenes.193- `MaterialLoader.registerMaterial()` and `Material.fromJSON()` support custom194 material deserialization.195- `RenderTarget.clone()` creates independent texture resources.196197## Visual-output changes to review198199Create comparison renders when an upgrade touches:200201- corrected blending formulas;202- GGX VNDF PMREM sampling;203- direct-light multi-scattering energy compensation;204- rough-reflection mixing and the WebGL DFG LUT;205- intermediate-metalness, iridescence, or sheen energy conservation;206- shadow filtering and alpha-to-coverage;207- environment or background rotation;208- `RoomEnvironment`-generated PMREMs;209- Neutral tone mapping in editor projects;210- GTAO radius and scale;211- additive SSR compositing and its optional denoiser;212- the rebuilt depth-of-field and temporal-AA nodes.213214## Safe upgrade workflow2152161. Search imports, constructors, direct property access, and shader defines for217 the removed and renamed surfaces above.2182. Open every reference matching the application’s renderer, node system,219 post-processing stack, and asset formats.2203. Update renderer initialization and loader callbacks before chasing runtime221 errors.2224. Rebuild TSL graphs around final helper names and position semantics.2235. Confirm required normals, tangents, update ranges, and storage-backed224 attributes on geometry.2256. Revalidate serialized assets, material copies, pivots, and render-target226 cloning.2277. Compare WebGL and WebGPU output where both backends are supported.2288. Capture visual regressions in blending, PBR, shadows, depth, post-processing,229 and color-space handling.