diff --git a/src/runtime-three/runtime-host.ts b/src/runtime-three/runtime-host.ts index 712c9165..81597e05 100644 --- a/src/runtime-three/runtime-host.ts +++ b/src/runtime-three/runtime-host.ts @@ -6731,11 +6731,22 @@ export class RuntimeHost { const pointerBinding = getPlayerStartMouseBindingCodeForButton( event.button ); + const playerInputBindings = this.resolveRuntimePlayerInputBindings(); if ( pointerBinding !== null && - this.runtimeScene.playerInputBindings.keyboard.interact === - pointerBinding + this.activeRuntimeTargetReference !== null && + playerInputBindings.keyboard.clearTarget === pointerBinding + ) { + event.preventDefault(); + event.stopImmediatePropagation(); + this.clearActiveRuntimeTarget(); + return; + } + + if ( + pointerBinding !== null && + playerInputBindings.keyboard.interact === pointerBinding ) { this.dispatchRuntimeInteract(); } diff --git a/src/viewport-three/ViewportCanvas.tsx b/src/viewport-three/ViewportCanvas.tsx index bb76b05a..dea17a91 100644 --- a/src/viewport-three/ViewportCanvas.tsx +++ b/src/viewport-three/ViewportCanvas.tsx @@ -166,16 +166,32 @@ export function ViewportCanvas({ const initialFrame = editorSimulationController.getFrameSnapshot(); let currentSceneVersion = initialFrame.sceneVersion; - host.updateSimulation(initialFrame.runtimeScene, initialFrame.clock); + let currentFrameVersion = initialFrame.frameVersion; + host.updateSimulation(initialFrame.runtimeScene, initialFrame.clock, { + sceneVersion: initialFrame.sceneVersion, + frameVersion: initialFrame.frameVersion + }); return editorSimulationController.subscribeFrame((frame) => { if (frame.sceneVersion !== currentSceneVersion) { currentSceneVersion = frame.sceneVersion; - host.updateSimulation(frame.runtimeScene, frame.clock); + currentFrameVersion = frame.frameVersion; + host.updateSimulation(frame.runtimeScene, frame.clock, { + sceneVersion: frame.sceneVersion, + frameVersion: frame.frameVersion + }); return; } - host.updateSimulationFrame(frame.runtimeScene, frame.clock); + if (frame.frameVersion === currentFrameVersion) { + return; + } + + currentFrameVersion = frame.frameVersion; + host.updateSimulationFrame(frame.runtimeScene, frame.clock, { + sceneVersion: frame.sceneVersion, + frameVersion: frame.frameVersion + }); }); }, [editorSimulationController]);