Merge pull request #206 from storytold/feature/focus-editor

added focus.
This commit is contained in:
ArEnSc authored and GitHub committed 2024-04-23 14:47:30 -04:00
commit 2a9d9d3de1
1 file changed
+10
+10
View File
@@ -332,6 +332,7 @@ class Editor {
// OnClick and MouseMove events.
window.addEventListener("mousemove", this.onMouseMove.bind(this), false);
window.addEventListener("click", this.onMouseClick.bind(this), false);
window.addEventListener("keydown", this.onkeydown.bind(this), false);
// Base control and debug stuff remove debug in prod.
if (this.control == undefined) {
return;
@@ -1325,6 +1326,15 @@ class Editor {
}
}
onkeydown(event: any) {
if (event.key === 'f' && this.selected && this.orbitControls) {
this.orbitControls.target.copy(this.selected.position);
this.orbitControls.maxDistance = 4;
this.orbitControls.update();
this.orbitControls.maxDistance = 999;
}
}
// Sets new mouse location usually used in raycasts.
onMouseMove(event: any) {
const rect = this.canvReference.getBoundingClientRect();