diff --git a/src/editor/lib/EditorControls.js b/src/editor/lib/EditorControls.js index ca6a801d..cf899f2d 100644 --- a/src/editor/lib/EditorControls.js +++ b/src/editor/lib/EditorControls.js @@ -1,4 +1,3 @@ -import debounce from 'lodash-es/debounce'; import { currentOrthoDir } from './cameras'; /** @@ -56,10 +55,6 @@ THREE.EditorControls = function (_object, domElement) { var changeEvent = { type: 'change' }; - this.dispatchChange = debounce(() => { - scope.dispatchEvent(changeEvent); - }, 100); - this.focus = function (target) { if (this.isOrthographic) { return; @@ -101,7 +96,6 @@ THREE.EditorControls = function (_object, domElement) { scope.transitionSpeed = 0.001; scope.transitionProgress = 0; scope.transitioning = true; - // The changeEvent is emitted at the end of the transition below }; function easeInOutQuad(t) { @@ -144,8 +138,8 @@ THREE.EditorControls = function (_object, domElement) { this.transitioning = false; object.position.copy(this.transitionCamPosEnd); object.quaternion.copy(this.transitionCamQuaternionEnd); - scope.dispatchEvent(changeEvent); } + scope.dispatchEvent(changeEvent); } } }; @@ -171,7 +165,7 @@ THREE.EditorControls = function (_object, domElement) { object.position.add(delta); center.add(delta); - scope.dispatchChange(); + scope.dispatchEvent(changeEvent); }; var ratio = 1; @@ -207,7 +201,7 @@ THREE.EditorControls = function (_object, domElement) { object.position.add(delta); } - scope.dispatchChange(); + scope.dispatchEvent(changeEvent); }; this.rotate = function (delta) { @@ -230,7 +224,7 @@ THREE.EditorControls = function (_object, domElement) { object.lookAt(center); - scope.dispatchChange(); + scope.dispatchEvent(changeEvent); }; // mouse @@ -446,7 +440,7 @@ THREE.EditorControls = function (_object, domElement) { object.updateMatrixWorld(); } - scope.dispatchChange(); + scope.dispatchEvent(changeEvent); }; }; diff --git a/src/editor/lib/viewport.js b/src/editor/lib/viewport.js index b8a05101..0c1d503c 100644 --- a/src/editor/lib/viewport.js +++ b/src/editor/lib/viewport.js @@ -212,6 +212,10 @@ export function Viewport(inspector) { controls.rotationSpeed = 0.0035; controls.zoomSpeed = 0.05; controls.setAspectRatio(sceneEl.canvas.width / sceneEl.canvas.height); + controls.addEventListener('change', () => { + transformControls.update(true); // true is updateScale + Events.emit('camerachanged'); + }); sceneEl.addEventListener('newScene', () => { controls.resetZoom(); @@ -282,13 +286,15 @@ export function Viewport(inspector) { object.el.addEventListener('model-loaded', listener); } - transformControls.attach(object); + if (inspector.cursor.isPlaying) { + // Only show transform controls when we are in pointer mode + transformControls.attach(object); + } } }); Events.on('objectfocus', (object) => { controls.focus(object); - transformControls.update(); }); Events.on('geometrychanged', (object) => {