BabylonJS/Babylon.js · error · Error

${this.constructor.name} "${this.name}": targetTexture and o

Error message

${this.constructor.name} "${this.name}": targetTexture and objectRendererTask are required

What it means

BaseLayerTask.record() (used by highlight/focus/glow layer frame graph tasks) needs both a target texture to render into and a child object renderer task that renders the objects. If either is undefined, recording the task into the frame graph would be invalid, so it throws.

Source

Thrown at packages/dev/core/src/FrameGraph/Tasks/Layers/baseLayerTask.ts:249

        return this._objectRendererForLayerTask.isReady() && this.layer.isLayerReady();
    }

    /**
     * Gets the current class name.
     * @returns the class name
     */
    public override getClassName(): string {
        return "FrameGraphBaseLayerTask";
    }

    /**
     * Records the layer task into the frame graph.
     * @param _skipCreationOfDisabledPasses defines whether disabled passes should be skipped
     * @param additionalComposeBindings defines an optional callback used to bind extra compose resources
     */
    public record(_skipCreationOfDisabledPasses?: boolean, additionalComposeBindings?: (context: FrameGraphRenderContext, effect: Effect) => void) {
        if (this.targetTexture === undefined || this.objectRendererTask === undefined) {
            throw new Error(`${this.constructor.name} "${this.name}": targetTexture and objectRendererTask are required`);
        }

        this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture);

        // Uses the layerTexture or creates a color texture to render the layer to
        let textureSize: {
            width: number;
            height: number;
        };
        let textureCreationOptions: FrameGraphTextureCreationOptions;

        let colorLayerOutput: FrameGraphTextureHandle;

        if (this.layerTexture) {
            colorLayerOutput = this.layerTexture;
            textureCreationOptions = this._frameGraph.textureManager.getTextureCreationOptions(this.layerTexture);
            textureSize = getDimensionsFromTextureSize(textureCreationOptions.size);
            textureCreationOptions.size = textureSize;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Connect a texture (e.g. from a texture input block) to the layer block's targetTexture input
  2. Connect an object renderer block to the layer block's objectRenderer input before build
  3. Skip/disable the layer block if it is intentionally unused

Example fix

// before
layerBlock.build(); // inputs unconnected
// after
layerBlock.targetTexture.connect(textureInputBlock.output);
layerBlock.objectRenderer.connect(objectRendererBlock.output);
layerBlock.build();
Defensive patterns

Strategy: validation

Validate before calling

if (layerTask.targetTexture === undefined || layerTask.objectRendererTask === undefined) {
  throw new Error(`layer '${layerTask.name}' needs targetTexture and objectRendererTask`);
}

Type guard

function layerTaskReady(t) { return t.targetTexture !== undefined && t.objectRendererTask !== undefined; }

Try / catch

try { layerTask.record(); } catch (e) { if (e.message.includes('targetTexture and objectRendererTask are required')) { console.error('Wire layer block inputs before build'); } else { throw e; } }

Prevention

When it happens

Trigger: Calling record()/building the frame graph for a layer task where targetTexture or objectRendererTask was never assigned (e.g. the targetTexture input or objectRenderer input was never connected).

Common situations: Building a graph with a highlight/glow layer block whose target texture input or object renderer input is unconnected; building before the texture handle is set.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/cc619d1896b97c5d. Report an issue: GitHub.