Hi, I’m working on a project where I’d like a mesh to be laid on a ground depending on the coordinates given. So far so good. But when I go over a ground that has been modified with a function that lets you change the vertices to create either a difference in level or a hole (made using this doc: Babylon.js docs )
and well the modifications made are not taken into account in spite of a ‘mesh.computeWorldMatrix(true)’ and the mesh posed remains in y=0…
to lay a mesh I use this function
getPositionInSphere(sphereRadius, pos_middle_sphere) {
var y = (Math.random() - 0.5) * 2 * sphereRadius;
var radiusAtY = Math.sqrt(Math.pow(sphereRadius, 2) - Math.pow(y, 2));
var theta = Math.random() * 2 * Math.PI;
var x = (radiusAtY * Math.cos(theta))+pos_middle_sphere[0];
var z = (radiusAtY * Math.sin(theta))+pos_middle_sphere[2];
var y = this.meshSupport.getHeightAtCoordinates(x, z);
return new BABYLON.Vector3(x, y, z);
}
EDIT:
to modify the ground I use the doc and I also modify the normals so that I can use it to orientate the mesh so that it is against the ground and not floating