最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cannot get the FirstPersonControls in three.js working - Stack Overflow

programmeradmin3浏览0评论

i'm trying this:

controls = new THREE.FirstPersonControls(camera);

controls.movementSpeed = 1000; controls.lookSpeed = 0.125; controls.lookVertical = true;

it didn't work, From here i found out that i need to update the control with time delta:

var clock = new THREE.Clock();

controls.update( clock.getDelta() );

but I get undefined is not a function error for THREE.Clock()

can you please point me to working demo/tutorial with FirstPersonControls, or just tell me whats wrong?

Thanks!!

i'm trying this:

controls = new THREE.FirstPersonControls(camera);

controls.movementSpeed = 1000; controls.lookSpeed = 0.125; controls.lookVertical = true;

it didn't work, From here i found out that i need to update the control with time delta:

var clock = new THREE.Clock();

controls.update( clock.getDelta() );

but I get undefined is not a function error for THREE.Clock()

can you please point me to working demo/tutorial with FirstPersonControls, or just tell me whats wrong?

Thanks!!

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Nov 9, 2011 at 10:59 Sergej PopovSergej Popov 3,0216 gold badges37 silver badges54 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 8

Have you tried simply calling controls.update(); (withough passing a delta) ?

I've just tried using the class by copying a bit of code from the misc_sound.html example. So in init():

controls = new THREE.FirstPersonControls( camera );

                controls.movementSpeed = 70;
                controls.lookSpeed = 0.05;
                controls.noFly = true;
                controls.lookVertical = false;

and in render():

controls.update();

Update

As Todd points out, in newer versions, a delta time argument needs to be supplied:

controls.update(delta);

Please note that in R49, this api now requires the 'delta' on the update call. The delta needs to be the millisecond displacement since last update, which should be passed out through the requestAnimationFrame callback.

http://paulirish./2011/requestanimationframe-for-smart-animating/

发布评论

评论列表(0)

  1. 暂无评论