{"record":{"id":"aae745b09d8acf27","repo":"BabylonJS/Babylon.js","slug":"missing-required-heightfield-parameters","errorCode":null,"errorMessage":"Missing required heightfield parameters","messagePattern":"Missing required heightfield parameters","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Physics/v2/Plugins/havokPlugin.ts","lineNumber":1876,"sourceCode":"                            for (let z = 0; z < options.numHeightFieldSamplesZ; z++) {\r\n                                const hkBufferIndex = z * options.numHeightFieldSamplesX + x;\r\n                                const bjsBufferIndex = (options.numHeightFieldSamplesX - 1 - x) * options.numHeightFieldSamplesZ + z;\r\n                                heightBuffer[hkBufferIndex] = options.heightFieldData[bjsBufferIndex];\r\n                            }\r\n                        }\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","sourceCodeStart":1858,"sourceCodeEnd":1894,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Physics/v2/Plugins/havokPlugin.ts#L1858-L1894","documentation":"A HEIGHTFIELD PhysicsShape requires explicit ground/height data (groundMesh plus heightfield parameters such as dimensions/subdivisions) in the options. When those required parameters are absent, HavokPlugin cannot compute the height sampler for the Havok collider and throws. Heightfields are data-driven shapes and cannot be inferred from arbitrary meshes.","triggerScenarios":"Creating a shape with type PhysicsShapeType.HEIGHTFIELD without options.groundMesh (or without the required heightfield parameters like pointCount/size/scale), hitting the else branch at havokPlugin.ts:1876.","commonSituations":"Passing a regular mesh as ground without the heightfield-specific options; using PhysicsShapeHeightfield with an options object missing minHeight/maxHeight or dimension fields; copy-pasting a MESH shape config and only changing the type.","solutions":["Provide all required heightfield options, including groundMesh, when constructing PhysicsShapeHeightfield / {type: PhysicsShapeType.HEIGHTFIELD}.","Check the PhysicsShapeHeightfield constructor docs for the exact required parameter set and fill each field.","If you just want collision from an arbitrary terrain mesh, use PhysicsShapeType.MESH instead of HEIGHTFIELD."],"exampleFix":"// before\nconst shape = new PhysicsShape({ type: PhysicsShapeType.HEIGHTFIELD }, scene);\n// after\nconst shape = new PhysicsShapeHeightfield(parent, {\n  groundMesh: terrain,\n  pointCount: { x: 64, z: 64 },\n  size: { x: 100, z: 100 },\n  minHeight: 0,\n  maxHeight: 10\n}, scene);","handlingStrategy":"validation","validationCode":"if (!options.groundMesh) {\n  throw new Error(\"HEIGHTFIELD shape requires options.groundMesh and heightfield parameters\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read the PhysicsShapeHeightfield constructor and supply every required option (groundMesh, pointCount, size, minHeight/maxHeight).","Use PhysicsShapeType.MESH instead when you have a generic terrain mesh without heightfield data.","Centralize heightfield shape creation in one helper that validates the full parameter set."],"tags":["physics","havok","heightfield","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}