gpt4 book ai didi

Three js a just rotation camera with a correct position [SOLVED](三个js一个位置正确的旋转相机[已解决])

转载 作者:bug小助手 更新时间:2023-10-28 13:48:41 28 4
gpt4 key购买 nike



This my code return image is :

这是我的代码返回图像:


const box = new THREE.Box3().setFromObject(model);
const size = box.getSize(new THREE.Vector3()).length();
const center = box.getCenter(new THREE.Vector3());

camera.near = size / 100;
camera.far = size \* 100;
camera.updateProjectionMatrix();

camera.position.copy(center);
camera.position.x += size / 0.2;
camera.position.y += size / 2;
camera.position.z += size / 100;
camera.rotation.z += Math.PI/2
// camera.up.set(0, 0, 1)
// camera.rotation.set(Math.PI / -2, 0, 0)
camera.lookAt(center);

my problem is a in camera rotation, i cannot handle with a my dream potition, i want like this image i change camera.up.set cannot solve this problem, can you help me with a correct code?

我的问题是在相机旋转中,我不能处理我梦想的位置,我想像这样的图像我改变相机。设置不能解决这个问题,你能帮我一个正确的代码吗?


更多回答
优秀答案推荐

After

之后


camera.position.copy(center);

try with

试一试


camera.position.y += size / 0.2;
camera.lookAt(center);

If it is not the desided position, try with z in place of y.

如果它不是所需的位置,请尝试用z代替y。


I think you are using orbit controls to get the desired image: if neither of above works, you can add console.log(camera.position) in your render loop (or, better, in a function called when you click on the renderer.DOMElement), move the camera in the desired position, and then take note of the x, y and z value of the desired position.

我认为您正在使用环绕控制来获得所需的图像:如果以上两种方法都不起作用,则可以在渲染循环中(或者,更好的做法是,在单击渲染器时调用的函数中)添加sole.log(camera.position),将摄影机移动到所需位置,然后记下所需位置的x、y和z值。


更多回答

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com