BabylonJS/Babylon.js · error · Error

This node is not meant to be an output node. You may want to

Error message

This node is not meant to be an output node. You may want to explicitly set its target value.

What it means

addOutputNode registers a block as a material output, but only blocks with an explicit target (Vertex and/or Fragment) can serve as output nodes. A block whose target is null has no designated shader stage, so the material cannot know where to emit it and throws.

Source

Thrown at packages/dev/core/src/Materials/Node/nodeMaterial.pure.ts:574

        const index = this._optimizers.indexOf(optimizer);

        if (index === -1) {
            return;
        }

        this._optimizers.splice(index, 1);

        return this;
    }

    /**
     * Add a new block to the list of output nodes
     * @param node defines the node to add
     * @returns the current material
     */
    public addOutputNode(node: NodeMaterialBlock) {
        if (node.target === null) {
            throw new Error("This node is not meant to be an output node. You may want to explicitly set its target value.");
        }

        if ((node.target & NodeMaterialBlockTargets.Vertex) !== 0) {
            this._addVertexOutputNode(node);
        }

        if ((node.target & NodeMaterialBlockTargets.Fragment) !== 0) {
            this._addFragmentOutputNode(node);
        }

        return this;
    }

    /**
     * Remove a block from the list of root nodes
     * @param node defines the node to remove
     * @returns the current material
     */

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Set block.target = NodeMaterialBlockTargets.VertexAndFragment (or Vertex/Fragment) before addOutputNode
  2. Only add blocks as outputs that are output-capable blocks with targets
  3. Use the framework's dedicated output blocks (VertexOutputBlock/FragmentOutputBlock) whose targets are predefined

Example fix

// before
const block = new TransformBlock('t');
material.addOutputNode(block); // target is null
// after
const block = new TransformBlock('t');
block.target = NodeMaterialBlockTargets.Vertex;
material.addOutputNode(block);
Defensive patterns

Strategy: validation

Validate before calling

function safeAddOutput(material: NodeMaterial, node: NodeMaterialBlock) {
  if (node.target === null) node.target = NodeMaterialBlockTargets.VertexAndFragment;
  material.addOutputNode(node);
}

Type guard

const hasTarget = (b: NodeMaterialBlock): b is NodeMaterialBlock & { target: NodeMaterialBlockTargets } => b.target !== null;

Try / catch

try {
  material.addOutputNode(block);
} catch (e) {
  if (e instanceof Error && e.message.includes('not meant to be an output node')) {
    console.error('Block', block.name, 'has no target; set block.target first');
  } else throw e;
}

Prevention

When it happens

Trigger: Calling nodeMaterial.addOutputNode(block) on a freshly constructed block without setting block.target, or on a block whose target is null by default.

Common situations: Building node materials programmatically where the Node Material Editor normally sets target automatically; forgetting target when wiring custom blocks.

Related errors


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