javascript - three.js using controls/PointerLockControls.js - make camera move where it's facing in Z axis? -
i using example code three.js git: https://github.com/mrdoob/three.js/blob/master/examples/js/controls/pointerlockcontrols.js
how can change so, instead of w/s moving on original z axis, camera moves at? so, if up, move up.
i tried reading other questions, can't figure out exact line of code need, i'm new three.js. other examples in git didn't me either, rather confused me further.
well, tried different things, , found simplest answer work. i'm not sure if it's efficient, though.
if (moveforward) camera.translatez(-movespeed * speedmultiplier); if (movebackward) camera.translatez(movespeed * speedmultiplier); if (moveleft) camera.translatex(-movespeed * speedmultiplier); if (moveright) camera.translatex(movespeed * speedmultiplier); if (moveup) camera.translatey(movespeed * speedmultiplier); if (movedown) camera.translatey(-movespeed * speedmultiplier);
i'm using same event boolean variables, instead of "delta" , stuff code, use simplified version. simple translations. [speedmultiplier lets me toggle speed shift key, key event.]
Comments
Post a Comment