BabylonJS/Babylon.js · error
Unsupported Shape Type.
Error message
Unsupported Shape Type.
What it means
HavokPlugin._createShape switches over PhysicsShapeType to build the matching Havok collider. The default branch throws for any shape type the plugin does not implement. Reaching it means the caller supplied a shape type outside the set Havok supports (or a garbage/undefined value).
Source
Thrown at packages/dev/core/src/Physics/v2/Plugins/havokPlugin.ts:1881
}
const scaleX = options.heightFieldSizeX / (options.numHeightFieldSamplesX - 1);
const scaleZ = options.heightFieldSizeZ / (options.numHeightFieldSamplesZ - 1);
shape._pluginData = this._hknp.HP_Shape_CreateHeightField(
options.numHeightFieldSamplesX,
options.numHeightFieldSamplesZ,
[scaleX, 1, scaleZ],
bufferBegin
)[1];
this._hknp._free(bufferBegin);
} else {
throw new Error("Missing required heightfield parameters");
}
}
break;
default:
throw new Error("Unsupported Shape Type.");
break;
}
this._shapes.set(shape._pluginData[0], shape);
}
/**
* Sets the shape filter membership mask of a body
* @param shape - The physics body to set the shape filter membership mask for.
* @param membershipMask - The shape filter membership mask to set.
*/
public setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void {
const collideWith = this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][1];
this._hknp.HP_Shape_SetFilterInfo(shape._pluginData, [membershipMask, collideWith]);
}
/**
* Gets the shape filter membership mask of a body
View on GitHub (pinned to 0592b347b8)
Solutions
- Only use PhysicsShapeType members Havok supports: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER.
- Ensure the value is the imported enum member, not a raw number or string; log it if unsure.
- Reinstall matching @babylonjs/core and @babylonjs/havok versions so enum values line up.
Example fix
// before
const shape = new PhysicsShape({ type: 99 as PhysicsShapeType }, scene);
// after
const shape = new PhysicsShape({ type: PhysicsShapeType.BOX, extents: new Vector3(1, 1, 1) }, scene); Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = [PhysicsShapeType.SPHERE, PhysicsShapeType.BOX, PhysicsShapeType.CAPSULE, PhysicsShapeType.CYLINDER, PhysicsShapeType.CONVEX_HULL, PhysicsShapeType.MESH, PhysicsShapeType.HEIGHTFIELD, PhysicsShapeType.CONTAINER];
if (!SUPPORTED.includes(shapeType)) {
throw new Error(`unsupported shape type for Havok: ${shapeType}`);
} Type guard
function isSupportedShapeType(t: unknown): t is PhysicsShapeType {
return [PhysicsShapeType.SPHERE, PhysicsShapeType.BOX, PhysicsShapeType.CAPSULE, PhysicsShapeType.CYLINDER, PhysicsShapeType.CONVEX_HULL, PhysicsShapeType.MESH, PhysicsShapeType.HEIGHTFIELD, PhysicsShapeType.CONTAINER].includes(t as PhysicsShapeType);
} Prevention
- Only pass imported PhysicsShapeType enum members; avoid numeric literals and casts.
- Keep serialization formats that preserve enum values exactly; validate on load.
- Match @babylonjs/core and @babylonjs/havok versions so enums are consistent.
When it happens
Trigger: Passing an invalid numeric PhysicsShapeType (e.g. a hand-cast number), a type from a mismatched Babylon version, or a legitimately unsupported type into PhysicsShape/PhysicsShapeMesh-style constructors, so _createShape hits default at havokPlugin.ts:1881.
Common situations: Serializing/deserializing scene physics data that loses or corrupts the shape type; typing the shape type as plain number and passing an out-of-range value; using a plugin-specific type constant with the Havok plugin.
Related errors
- Unknown motion type: ${type}
- No mesh provided to create physics shape.
- Missing required heightfield parameters
- Unsupported Constraint Type.
- Unsupported type: ${outputType}
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/5b659fe5edf0d63d.
Report an issue: GitHub.