Question

I add a new THREE.PlaneGeometry() to my scene and it appears at [0,0,0] upright in the XY plane with its normal facing along the +Z axis. I then issue plane.rotation.x = -Math.PI/2 to lay the plane down so that its normal is now facing UP.

The problem I am experiencing is that now the plane's +Y axis is directed along the global -Z axis.

Since the plane is representing terrain, I want to be able to adjust the height of vertices to simulate height above sea level (altitude). Thus what I want to be able to write in code is something like this:

plane.geometry.vertices[i].y = 3;

...but what that does is simply move the vertex -3 units along the Z axis leaving the plane as flat as a tack.

I can write an abstraction function to map the coordinates for me, but I would prefer not to do that as it adds code and hinders direct access to the data structure (which is nice whilst experimenting).

Is there some way of permanently changing the plane's coordinate system so that it matches the global coordinate system? Such that plane.geometry.vertices[i].y++ would, in fact, result in a bump in the terrain?

Cheers.

Was it helpful?

Solution

Instead of rotating the mesh, apply a rotation to the geometry itself before you create the mesh.

geometry.applyMatrix( new THREE.Matrix4().makeRotationX( - Math.PI / 2 ) );

three.js r.58

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top