gpt4 book ai didi

javascript - three.js - 如何限制缩放以使对象不会因相机而损坏

转载 作者:数据小太阳 更新时间:2023-10-29 05:49:33 25 4
gpt4 key购买 nike

我正在创建 three.js 应用程序。我已经加载了我的 STL 对象。我使用过“OrbitControls”。当我开始使用鼠标的中间滚动按钮缩放我的对象时,它会在某个点中断。

我的相机和控制代码如下:

camera = new THREE.PerspectiveCamera( 55, window.innerWidth / window.innerHeight, 1, 15 );
//camera.position.set( 3, 0.15, 3 );
// position and point the camera to the center of the scene
camera.position.x = -3;
camera.position.y = 4;
camera.position.z = 5;
camera.lookAt(new THREE.Vector3(0, 0, 0));

controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.damping = 0.2;
//controls.minZoom = 0;
// controls.maxZoom = 1;
//controls .noZoom = true;

controls.addEventListener( 'change', render );

我尝试使用控件 minZoommaxZoom 但它不起作用。

任何人都可以告诉我应该如何限制缩放以便超过某个点我的对象不会损坏?

最佳答案

如果您使用带有 OrbitControlsPerspectiveCamera,您可以像这样限制相机距离:

controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.minDistance = 10;
controls.maxDistance = 50;

查看源代码 OrbitControls.js 了解更多设置。

three.js r.74

关于javascript - three.js - 如何限制缩放以使对象不会因相机而损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35651412/

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