Skip to content

Commit

Permalink
better camera position when focusing an object (fix #798)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentfretin committed Aug 30, 2024
1 parent 9971d6b commit 065b95b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/editor/lib/EditorControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down

0 comments on commit 065b95b

Please sign in to comment.