In three.js Y axis represent up and down and Z axis represent forward and backward. But I want Z axis to represent up and down and Y axis to forward and backward. Here is a image showing what I want:
I want to change the entire coordinate system in such a way that, if I rotate a mesh around y axis, it follows the new coordinate system not the traditional one.
Now, I have searched stack overflow and found this link:
Is there any way I can make three.js to work like Z up coordinate system?
Objects in three. js exist in a three-dimensional space with x, y, and z axes. Your view of those points is determined by the camera, which also exists in three-dimensional space. This allows a bunch of stuff like zooming past 3D objects, or rotating around them, that we don't need for this 2D visualization.
Three. JS is a cross-browser JavaScript library/API which is used to create and animate 3D computer graphics to display in a web browser. It's one type of a single JavaScript file and includes features like effects, scenes, cameras, lights, sky, materials, meshes, shades, animations, and 3D objects.
You can set the up vector of the camera using
camera.up.set(0,0,1);
Then, it will work like you expect.
The answer above works in simple case, but if you wish for example to use the editor, you better set before doing anything
THREE.Object3D.DefaultUp = new THREE.Vector3(0,0,1);
So any new object will also use this convention. Using the previous answer, I struggled in the editor on on all the implications around the controls, saving the objects etc...
Please note that if you use a grid you still have to rotate it so that it covers XY plane instead of XZ
var grid = new THREE.GridHelper( 30, 30, 0x444444, 0x888888 ); grid.rotateX(Math.PI / 2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With