mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 23:08:44 +08:00
Fix the problem that camera will be freezed when moving forward (#2404)
* fix camera freezed when moving forward * simplify code --------- Co-authored-by: Matthew Tancik <matt@lumalabs.ai>
This commit is contained in:
1 parent
d947f6e485
commit
9625ab713c
1 file changed
+17
-14
@@ -133,6 +133,21 @@ export function get_scene_tree() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function translateForward(distance) {
|
||||||
|
const to = camera_controls.getTarget().add(
|
||||||
|
camera_controls.getTarget()
|
||||||
|
.sub(camera_controls.getPosition())
|
||||||
|
.normalize()
|
||||||
|
.multiplyScalar(distance)
|
||||||
|
);
|
||||||
|
camera_controls.moveTo(
|
||||||
|
to.x,
|
||||||
|
to.y,
|
||||||
|
to.z,
|
||||||
|
{enableTransition:true}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function translate() {
|
function translate() {
|
||||||
if (keyMap.KeyD === true) {
|
if (keyMap.KeyD === true) {
|
||||||
camera_controls.truck(moveSpeed, 0, {enableTransition:true});
|
camera_controls.truck(moveSpeed, 0, {enableTransition:true});
|
||||||
@@ -141,22 +156,10 @@ export function get_scene_tree() {
|
|||||||
camera_controls.truck(-moveSpeed, 0, {enableTransition:true});
|
camera_controls.truck(-moveSpeed, 0, {enableTransition:true});
|
||||||
}
|
}
|
||||||
if (keyMap.KeyW === true) {
|
if (keyMap.KeyW === true) {
|
||||||
const curPos = camera_controls.getPosition();
|
translateForward(moveSpeed);
|
||||||
const newTar = camera_controls.getTarget();
|
|
||||||
const newDiff = newTar
|
|
||||||
.sub(curPos)
|
|
||||||
.normalize()
|
|
||||||
.multiplyScalar(curPos.length());
|
|
||||||
camera_controls.setTarget(
|
|
||||||
curPos.x + newDiff.x,
|
|
||||||
curPos.y + newDiff.y,
|
|
||||||
curPos.z + newDiff.z,
|
|
||||||
{enableTransition:true}
|
|
||||||
);
|
|
||||||
camera_controls.dolly(moveSpeed, {enableTransition:true});
|
|
||||||
}
|
}
|
||||||
if (keyMap.KeyS === true) {
|
if (keyMap.KeyS === true) {
|
||||||
camera_controls.dolly(-moveSpeed, {enableTransition:true});
|
translateForward(-moveSpeed);
|
||||||
}
|
}
|
||||||
if (keyMap.KeyQ === true) {
|
if (keyMap.KeyQ === true) {
|
||||||
camera_controls.truck(0, moveSpeed, {enableTransition:true});
|
camera_controls.truck(0, moveSpeed, {enableTransition:true});
|
||||||
|
|||||||
Reference in new issue
Block a user