{"record":{"id":"86585ba70010cfbd","repo":"BabylonJS/Babylon.js","slug":"gaussiansplattingdebugger-addmesh-mesh-must-have","errorCode":null,"errorMessage":"GaussianSplattingDebugger.addMesh: mesh must have a GaussianSplattingMaterial.","messagePattern":"GaussianSplattingDebugger\\.addMesh: mesh must have a GaussianSplattingMaterial\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Meshes/GaussianSplatting/gaussianSplattingDebugger.pure.ts","lineNumber":68,"sourceCode":"    private _shOrder1: boolean = true;\n    private _shOrder2: boolean = true;\n    private _shOrder3: boolean = true;\n    private _shOrder4: boolean = true;\n\n    /**\n     * Adds a mesh to the debugger, attaching a debug plugin to its material.\n     * The mesh must already have a GaussianSplattingMaterial assigned (i.e., data\n     * must have been loaded at least once). Current option values are applied immediately.\n     * The mesh is automatically unregistered if it is disposed.\n     * @param mesh The mesh to register.\n     */\n    public addMesh(mesh: GaussianSplattingMeshBase): void {\n        if (this._meshes.indexOf(mesh) !== -1) {\n            return;\n        }\n        const mat = mesh.material;\n        if (!(mat instanceof GaussianSplattingMaterial)) {\n            throw new Error(\"GaussianSplattingDebugger.addMesh: mesh must have a GaussianSplattingMaterial.\");\n        }\n        const plugin = new GaussianSplattingDebugMaterialPlugin(mat);\n        plugin.partCount = (mesh as unknown as { partCount?: number }).partCount ?? 0;\n        this._applyAllTo(plugin);\n        this._meshes.push(mesh);\n        this._plugins.push(plugin);\n        this._disposeObservers.push(mesh.onDisposeObservable.add(() => this.removeMesh(mesh))!);\n        this._partCountObservers.push(\n            mesh.onPartCountChangedObservable.add((count) => {\n                plugin.partCount = count;\n            })\n        );\n        this._partRemovedObservers.push(\n            mesh.onPartRemovedObservable.add((removedIndex) => {\n                plugin.shiftPartOptions(removedIndex);\n            })\n        );\n    }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Meshes/GaussianSplatting/gaussianSplattingDebugger.pure.ts#L50-L86","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Only pass GaussianSplattingMesh instances whose `mesh.material instanceof GaussianSplattingMaterial`.","If the material was replaced, restore it: `mesh.material = new GaussianSplattingMaterial(\"splatMat\", scene)`.","Guard with a type check before calling addMesh and skip non-splat meshes."],"exampleFix":"// before\nfor (const mesh of scene.meshes) {\n    debugger.addMesh(mesh as GaussianSplattingMeshBase);\n}\n\n// after\nfor (const mesh of scene.meshes) {\n    if (mesh instanceof GaussianSplattingMeshBase && mesh.material instanceof GaussianSplattingMaterial) {\n        debugger.addMesh(mesh);\n    }\n}","handlingStrategy":"type-guard","validationCode":"if (mesh.material instanceof GaussianSplattingMaterial) {\n    debugger.addMesh(mesh);\n}","typeGuard":"function isDebuggableSplatMesh(mesh: AbstractMesh): mesh is GaussianSplattingMeshBase {\n    return mesh.material instanceof GaussianSplattingMaterial;\n}","tryCatchPattern":"try {\n    debugger.addMesh(mesh);\n} catch (e) {\n    if (e instanceof Error && e.message.includes(\"GaussianSplattingMaterial\")) {\n        Logger.Warn(`Skipping ${mesh.name}: not a splat material`);\n        return;\n    }\n    throw e;\n}","preventionTips":["Only register GaussianSplattingMesh instances with the debugger","Don't overwrite mesh.material on splat meshes with non-splat materials","Filter scene.meshes by material type before bulk addMesh calls"],"tags":["gaussian-splatting","material-type","debugger","validation"],"backgroundTag":"invalid-material-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}