简体   繁体   中英

same rotations in WebGL

I'd like to rotate a plane the same way as the camera rotates (that it looks like it doesn't move at all)

my animate() function for the camera:

camera.position.x = Math.sin(t/1500)*200;
    camera.position.y = 250;
    camera.position.z = Math.cos(t/1500)*200; 

And the plane (done with CubeGeometry):

var plane = new THREE.Mesh(
    new THREE.CubeGeometry(100, 1, 50),
    new THREE.MeshBasicMaterial({color: 0xFF00FF}));
    plane.position.y = 115;
    plane.position.z = 25;

Which parameters does the plane need that it looks like standing still?

Thanks :)

Hope that including the below code may help you. As the camera rotates, the plane will also rotate to look towards the camera.

plane.lookAt( camera.position );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM