BabylonJS/Babylon.js · error · Error

GaussianSplattingDebugger.addMesh: mesh must have a Gaussian

Error message

GaussianSplattingDebugger.addMesh: mesh must have a GaussianSplattingMaterial.

What it means

GaussianSplattingDebugger.addMesh throws when the mesh's material is not an instance of GaussianSplattingMaterial. The debugger works by attaching a GaussianSplattingDebugMaterialPlugin to that material, which is only possible on Gaussian splatting materials.

Source

Thrown at packages/dev/core/src/Meshes/GaussianSplatting/gaussianSplattingDebugger.pure.ts:68

    private _shOrder1: boolean = true;
    private _shOrder2: boolean = true;
    private _shOrder3: boolean = true;
    private _shOrder4: boolean = true;

    /**
     * Adds a mesh to the debugger, attaching a debug plugin to its material.
     * The mesh must already have a GaussianSplattingMaterial assigned (i.e., data
     * must have been loaded at least once). Current option values are applied immediately.
     * The mesh is automatically unregistered if it is disposed.
     * @param mesh The mesh to register.
     */
    public addMesh(mesh: GaussianSplattingMeshBase): void {
        if (this._meshes.indexOf(mesh) !== -1) {
            return;
        }
        const mat = mesh.material;
        if (!(mat instanceof GaussianSplattingMaterial)) {
            throw new Error("GaussianSplattingDebugger.addMesh: mesh must have a GaussianSplattingMaterial.");
        }
        const plugin = new GaussianSplattingDebugMaterialPlugin(mat);
        plugin.partCount = (mesh as unknown as { partCount?: number }).partCount ?? 0;
        this._applyAllTo(plugin);
        this._meshes.push(mesh);
        this._plugins.push(plugin);
        this._disposeObservers.push(mesh.onDisposeObservable.add(() => this.removeMesh(mesh))!);
        this._partCountObservers.push(
            mesh.onPartCountChangedObservable.add((count) => {
                plugin.partCount = count;
            })
        );
        this._partRemovedObservers.push(
            mesh.onPartRemovedObservable.add((removedIndex) => {
                plugin.shiftPartOptions(removedIndex);
            })
        );
    }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Only pass GaussianSplattingMesh instances whose `mesh.material instanceof GaussianSplattingMaterial`.
  2. If the material was replaced, restore it: `mesh.material = new GaussianSplattingMaterial("splatMat", scene)`.
  3. Guard with a type check before calling addMesh and skip non-splat meshes.

Example fix

// before
for (const mesh of scene.meshes) {
    debugger.addMesh(mesh as GaussianSplattingMeshBase);
}

// after
for (const mesh of scene.meshes) {
    if (mesh instanceof GaussianSplattingMeshBase && mesh.material instanceof GaussianSplattingMaterial) {
        debugger.addMesh(mesh);
    }
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (mesh.material instanceof GaussianSplattingMaterial) {
    debugger.addMesh(mesh);
}

Type guard

function isDebuggableSplatMesh(mesh: AbstractMesh): mesh is GaussianSplattingMeshBase {
    return mesh.material instanceof GaussianSplattingMaterial;
}

Try / catch

try {
    debugger.addMesh(mesh);
} catch (e) {
    if (e instanceof Error && e.message.includes("GaussianSplattingMaterial")) {
        Logger.Warn(`Skipping ${mesh.name}: not a splat material`);
        return;
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling `debugger.addMesh(mesh)` with a regular Mesh, a GaussianSplattingMesh whose material was replaced (e.g. assigned a StandardMaterial/PBRMaterial), or a mesh created before its splat material was set.

Common situations: Adding arbitrary scene meshes to the debugger in a loop; overwriting `mesh.material` with a shared/custom material; cloning splat meshes and assigning a copied material of the wrong type.

Related errors


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