Generate a cannonjs heightfield from glb/gltf terrain created in Blender
- Evenly subdivide the terrain in blender, you have to scale it within Edit Mode while selecting all faces.
- There's currently problems if you lower the side edges of the terrain, it won't correctly read the mesh distance.
- Give it a material
- Export as glb/gltf and upload to Mesh2Heightfield
- Select the correct point distance, best if under 10.
-
Copy the matrix output from the textbox, or from the console:
-
Plug it into your CANNON.Heightfield body as the matrix, use the same point distance as specified on Mesh2Heightfield
-
....
-
Done, though you still might have to adjust the height of the CANNON.Heightfield and the imported THREE.Mesh
npm install
npm run dev
- If the terrain is very big (e.g 1000x1000) it will take some time to generate the heightfield matrix, You can experiment with the point distance input to make it faster.
- The window must be open for the entire duration, otherwise it won't generate.