From 065b95bcb256b217df916bea17c9737392e56c7b Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Fri, 30 Aug 2024 16:26:10 +0200 Subject: [PATCH] better camera position when focusing an object (fix #798) --- src/editor/lib/EditorControls.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/editor/lib/EditorControls.js b/src/editor/lib/EditorControls.js index 85c10727..2238ea3a 100644 --- a/src/editor/lib/EditorControls.js +++ b/src/editor/lib/EditorControls.js @@ -79,9 +79,14 @@ THREE.EditorControls = function (_object, domElement) { } object.position.copy( - target.localToWorld(new THREE.Vector3(0, 0, distance * 2)) + target.localToWorld( + new THREE.Vector3(0, center.y + distance * 0.5, distance * 2.5) + ) ); - object.lookAt(target.getWorldPosition(new THREE.Vector3())); + const pos = target.getWorldPosition(new THREE.Vector3()); + pos.y = center.y; + + object.lookAt(pos); scope.dispatchEvent(changeEvent); };