Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get heights from generated terrain #36

Closed
nrbrttth opened this issue Dec 12, 2023 · 1 comment
Closed

Get heights from generated terrain #36

nrbrttth opened this issue Dec 12, 2023 · 1 comment

Comments

@nrbrttth
Copy link

Hello and thanks for this amazing library!

I want to add a physics collider for Rapier, but I have no idea how could I parse the heights from the generated terrain.
Rapier expects it as described:

"A 3D heightfield collider can be created with ColliderDesc.heightfield(heights, scale) where heights is a matrix indicating the altitude of each subdivision point of that heightfield. The number of rows of that matrix is the number of subdivision along the X axis, and the number of columns is the number of subdivision along the Z axis. The scale argument indicates the size of the rectangle of the X-Z plane."

Have anyone tackled this before?

@IceCreamYou
Copy link
Owner

Hi there, I haven't used Rapier before but for the heights you are probably looking for something like THREE.Terrain.toArray2D(terrainScene.children[0].geometry.attributes.position.array) (where terrainScene.children[0] is your terrain mesh). From context I'm not entirely sure what the scale argument is supposed to be, but it is probably related to the xSize/ySize options you pass to THREE.Terrain().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants