{"record":{"id":"5b659fe5edf0d63d","repo":"BabylonJS/Babylon.js","slug":"unsupported-shape-type","errorCode":null,"errorMessage":"Unsupported Shape Type.","messagePattern":"Unsupported Shape Type\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Physics/v2/Plugins/havokPlugin.ts","lineNumber":1881,"sourceCode":"                        }\r\n\r\n                        const scaleX = options.heightFieldSizeX / (options.numHeightFieldSamplesX - 1);\r\n                        const scaleZ = options.heightFieldSizeZ / (options.numHeightFieldSamplesZ - 1);\r\n                        shape._pluginData = this._hknp.HP_Shape_CreateHeightField(\r\n                            options.numHeightFieldSamplesX,\r\n                            options.numHeightFieldSamplesZ,\r\n                            [scaleX, 1, scaleZ],\r\n                            bufferBegin\r\n                        )[1];\r\n\r\n                        this._hknp._free(bufferBegin);\r\n                    } else {\r\n                        throw new Error(\"Missing required heightfield parameters\");\r\n                    }\r\n                }\r\n                break;\r\n            default:\r\n                throw new Error(\"Unsupported Shape Type.\");\r\n                break;\r\n        }\r\n\r\n        this._shapes.set(shape._pluginData[0], shape);\r\n    }\r\n\r\n    /**\r\n     * Sets the shape filter membership mask of a body\r\n     * @param shape - The physics body to set the shape filter membership mask for.\r\n     * @param membershipMask - The shape filter membership mask to set.\r\n     */\r\n    public setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void {\r\n        const collideWith = this._hknp.HP_Shape_GetFilterInfo(shape._pluginData)[1][1];\r\n        this._hknp.HP_Shape_SetFilterInfo(shape._pluginData, [membershipMask, collideWith]);\r\n    }\r\n\r\n    /**\r\n     * Gets the shape filter membership mask of a body\r","sourceCodeStart":1863,"sourceCodeEnd":1899,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Physics/v2/Plugins/havokPlugin.ts#L1863-L1899","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst shape = new PhysicsShape({ type: 99 as PhysicsShapeType }, scene);\n// after\nconst shape = new PhysicsShape({ type: PhysicsShapeType.BOX, extents: new Vector3(1, 1, 1) }, scene);","handlingStrategy":"validation","validationCode":"const SUPPORTED = [PhysicsShapeType.SPHERE, PhysicsShapeType.BOX, PhysicsShapeType.CAPSULE, PhysicsShapeType.CYLINDER, PhysicsShapeType.CONVEX_HULL, PhysicsShapeType.MESH, PhysicsShapeType.HEIGHTFIELD, PhysicsShapeType.CONTAINER];\nif (!SUPPORTED.includes(shapeType)) {\n  throw new Error(`unsupported shape type for Havok: ${shapeType}`);\n}","typeGuard":"function isSupportedShapeType(t: unknown): t is PhysicsShapeType {\n  return [PhysicsShapeType.SPHERE, PhysicsShapeType.BOX, PhysicsShapeType.CAPSULE, PhysicsShapeType.CYLINDER, PhysicsShapeType.CONVEX_HULL, PhysicsShapeType.MESH, PhysicsShapeType.HEIGHTFIELD, PhysicsShapeType.CONTAINER].includes(t as PhysicsShapeType);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["physics","havok","shape-type","enum"],"backgroundTag":"unsupported-shape-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}