I have played a bit with your PG, here are my findings => I think those comments are more directed to @jerome who wrote the dynamic terrain class.
In this PG, you will see that the box does follow correctly the terrain (use only the cursor keys, don’t rotate with the mouse, else you may “unstick” the box from the terrain).
Now, uncomment line 101 and comment 102: it does not work anymore.
The difference is that in this latter case I don’t pass the
mapSizeZ values, so they are computed by
getHeightFromMap => the computation gives
2625. However, the
CreateMapFromHeightMapToRef method is called with
2640 for both values (120 * 22 = 2640), that’s why I tried to override the call by passing 2640, which seems to work.
However, even in this case, I can see some problems:
- if you uncomment line 36 to set the starting position of the camera outside the initial 2640x2640 area, the y value is off => it follows the terrain but with a little lag (probably by 2640-2625=15 units)
- (comment again line 36) if you comment line 43 and uncomment line 44, you will see the box is off => it seems that if the starting position of the camera is not (0,0,0) when calling the terrain constructor, the elevation computation is not ok
- reload the PG (to have a working config). If line 35 you replace the starting position by
new BABYLON.Vector3(7, 15, 32); you will see the box is too high: