gimg1
gimg1

Reputation: 1167

Three.js Orbit Controls - Swap Y & Z axis

So I have built a 3D environment that takes in a lot of external data and renders floors, objects etc. Unfortunately due to the format the data is being received I swapped the orientation of the scene so that now z is up (i.e. I swapped the z and y axes, hieght is z rather than y). When i tried to use orbit controls the poles for orbiting are in the incorrect place. Is there anyway to invert these so that the poles are along the z axes rather than the y? I have looked in depth into the OrbitControls code but I could not glean much.

I know this issue does not apply to a broad range of people nor will it be helpful for many but I have come to far in the coding process to revert the y,z values of the objects. Any help would be greatly appreciated.

Thanks

Upvotes: 2

Views: 1055

Answers (1)

Saters
Saters

Reputation: 35

You need to modify all 3 axes, not only y and z. By doing so, you created a non-direct coordinate system, which may cause your problem.

What you have to do is rotating the entire (x, y, z) coordinate system by replacing x by y, y by z and z by x in this.update function, for theta, phi and offset.? values.

[edit] I just noticed it is a year-old question... Maybe it can be useful though.[/edit]

Upvotes: 0

Related Questions