BabylonJS/Babylon.js · error · Error

Unsupported Splat mode

Error message

Unsupported Splat mode

What it means

Thrown by handlePLY when the SPLAT loader encounters a mode value that is not one of the supported Mode enum values. The mode controls how the PLY/SPLAT data is interpreted (points, mesh, splat), and any unrecognized mode falls into the default branch. This usually means an invalid or typo'd Mode value was passed.

Source

Thrown at packages/dev/loaders/src/SPLAT/splatFileLoader.pure.ts:374

                                await pointcloud.buildMeshAsync().then((mesh) => {
                                    babylonMeshesArray.push(mesh);
                                });
                            } else {
                                pointcloud.dispose();
                            }
                        }
                        break;
                    case Mode.Mesh:
                        {
                            if (parsedPLY.faces) {
                                babylonMeshesArray.push(SPLATFileLoader._BuildMesh(scene, parsedPLY));
                            } else {
                                throw new Error("PLY mesh doesn't contain face informations.");
                            }
                        }
                        break;
                    default:
                        throw new Error("Unsupported Splat mode");
                }
                scene._blockEntityCollection = false;
                this.applyAutoCameraLimits(SPLATFileLoader._ExtractSafeOrbitLimits(parsedPLY), scene);
                resolve(babylonMeshesArray);
            });
        };

        // Check for gzip (before SPZ V4) and NGSP (SPZ V4+) magic bytes to detect SPZ format
        const isGZipped = u8[0] === 0x1f && u8[1] === 0x8b;
        const isNGSP = u8[0] === 0x4e && u8[1] === 0x47 && u8[2] === 0x53 && u8[3] === 0x50;
        if (!isGZipped && !isNGSP) {
            return new Promise((resolve) => {
                handlePLY(resolve);
            });
        }

        const applyParsedSPZ = (parsedSPZ: IParsedSplat, resolve: (meshes: typeof babylonMeshesArray) => void) => {
            scene._blockEntityCollection = !!this._assetContainer;

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Use only members of the exported Mode enum (e.g. Mode.Mesh, Mode.Point, Mode.Splat)
  2. Check for typos or case mistakes in the mode value
  3. Verify against the Babylon.js version in use that the Mode member still exists
  4. Pass the enum member, not a raw number from external config

Example fix

// before
const loader = new SPLATFileLoader("mesh" as any);
// after
const loader = new SPLATFileLoader(Mode.Mesh);
Defensive patterns

Strategy: type-guard

Validate before calling

const SUPPORTED = new Set(Object.values(Mode));
if (!SUPPORTED.has(mode)) throw new Error(`Unsupported SPLAT mode: ${mode}`);

Type guard

function isSplatMode(m: unknown): m is Mode {
  return typeof m === 'number' && Object.values(Mode).includes(m as Mode);
}

Try / catch

try {
  await loader.loadAsync(url);
} catch (e) {
  if (e instanceof Error && e.message === "Unsupported Splat mode") {
    console.error(`Invalid mode value; use Mode enum members, got:`, mode);
  } else throw e;
}

Prevention

When it happens

Trigger: Constructing SPLATFileLoader with a mode value not in the Mode enum, or passing a numeric/cast value that hits the switch's default branch in handlePLY.

Common situations: Typo like Mode.mesh instead of Mode.Mesh; passing a raw number from config; upgrading Babylon.js where a Mode member was renamed or removed.

Related errors


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