问题
I am making a first-person, multiplayer game using Three.js where players' opponents are represented on their screens as airplanes. I need to be able to orient the airplane on the screen of person B in the same direction as the camera of person A so that when person A moves forward, the airplane on the other person's screen moves forward AND faces forward, rather than drifting forward while facing backwards or sideways. I need transmit the orientation information as a JSON object. I tried transmitting the rotation property of the camera and setting the rotation property of the airplane based on that at the other end, but for some reason the airplane does all sorts of strange twists and flips and doesn't face the direction it should. What is the best way to set the orientation of an Object3D so that it faces same direction as the camera on another device?
回答1:
Camera and Object3D have a method named lookAt that rotates them to face the given direction. WARN: you should calculate the direction, it means:
(position you want to look at - position of your object).normalize();
来源:https://stackoverflow.com/questions/39379671/orient-objects-in-same-direction-across-devices