来自 ThreeJS 的 OrbitControls 中的惯性 [英] Inertia in OrbitControls from ThreeJS

查看:32
本文介绍了来自 ThreeJS 的 OrbitControls 中的惯性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 THREE.OrbitControls 来旋转我的对象.但是我想为相机旋转添加一些内在(如果有人停止移动鼠标,相机会在一段时间后停止).我怎样才能做到这一点?

I am using THREE.OrbitControls for rotating my objects. However I would like to add some innertia for camera rotation (if someone stops moving mouse, camera stops after a while). How can I accomplish that?

推荐答案

这是在 OrbitControls.js 中添加惯性的一种非常简单的方法:

Here is a very simple way to add inertia in OrbitControls.js:

在更新函数的末尾(当前第 271-272 行),您将看到以下两个变量设置为零:

At the end of the update function (Lines 271-272 currently) you will see the following two variables set to zero:

thetaDelta = 0;
phiDelta = 0;

更改此设置,使其不会立即变为零,而是随着时间的推移而变小:

Change this so that instead of immediately going to zero, they just get smaller over time:

thetaDelta /= 1.5;
phiDelta /= 1.5;

就是这样!

这篇关于来自 ThreeJS 的 OrbitControls 中的惯性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆