{"record":{"id":"dd11bdbea184e14c","repo":"mrdoob/three.js","slug":"three-reflectornode-depth-node-can-only-be-reques","errorCode":null,"errorMessage":"THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ","messagePattern":"THREE\\.ReflectorNode: Depth node can only be requested when the reflector is created with (.+?)\\. ","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/nodes/utils/ReflectorNode.js","lineNumber":132,"sourceCode":"\tget target() {\n\n\t\treturn this._reflectorBaseNode.target;\n\n\t}\n\n\t/**\n\t * Returns a node representing the mirror's depth. That can be used\n\t * to implement more advanced reflection effects like distance attenuation.\n\t *\n\t * @return {Node} The depth node.\n\t */\n\tgetDepthNode() {\n\n\t\tif ( this._depthNode === null ) {\n\n\t\t\tif ( this._reflectorBaseNode.depth !== true ) {\n\n\t\t\t\tthrow new Error( 'THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ' );\n\n\t\t\t}\n\n\t\t\tthis._depthNode = new ReflectorNode( {\n\t\t\t\tdefaultTexture: _defaultRT.depthTexture,\n\t\t\t\treflector: this._reflectorBaseNode\n\t\t\t} );\n\n\t\t}\n\n\t\treturn this._depthNode;\n\n\t}\n\n\tsetup( builder ) {\n\n\t\t// ignore if used in post-processing\n\t\tif ( ! builder.object.isQuadMesh ) this._reflectorBaseNode.build( builder );","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/nodes/utils/ReflectorNode.js#L114-L150","documentation":"Thrown by ReflectorNode.getDepthNode() when depth is requested but the underlying reflector base was not created with `{ depth: true }`. The reflector only allocates a depth render target when depth is enabled at construction; without it there is no depth texture to expose.","triggerScenarios":"Calling `reflectorNode.getDepthNode()` on a reflector created via `new ReflectorNode(...)` or the reflector base without the `depth: true` option.","commonSituations":"Adding a depth-based reflection effect (distance attenuation, soft reflections) to an existing reflector that was created for color-only reflection; forgetting the depth option at setup time.","solutions":["Create the reflector with depth enabled: pass `{ depth: true }` to the reflector base/options at construction.","Recreate the reflector with the depth option if you need depth later (it cannot be toggled post-hoc)."],"exampleFix":"// before\nconst reflector = reflectorNode( { } );\nconst depth = reflector.getDepthNode();\n\n// after\nconst reflector = reflectorNode( { depth: true } );\nconst depth = reflector.getDepthNode();","handlingStrategy":"validation","validationCode":"function assertReflectorDepth( reflector ) {\n  if ( reflector._reflectorBaseNode.depth !== true ) {\n    throw new Error( 'Reflector must be created with { depth: true } to use getDepthNode().' );\n  }\n}","typeGuard":"const reflectorHasDepth = ( reflector ) => reflector._reflectorBaseNode.depth === true;","tryCatchPattern":null,"preventionTips":["Pass { depth: true } when constructing the reflector if depth effects are planned.","Depth cannot be enabled after construction — recreate the reflector if needed.","Gate getDepthNode() behind a depth-enabled check."],"tags":["reflector-node","depth-texture","configuration"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}