Improve simulation updates using frame versions and enhance player input binding logic
This commit is contained in:
@@ -6731,11 +6731,22 @@ export class RuntimeHost {
|
|||||||
const pointerBinding = getPlayerStartMouseBindingCodeForButton(
|
const pointerBinding = getPlayerStartMouseBindingCodeForButton(
|
||||||
event.button
|
event.button
|
||||||
);
|
);
|
||||||
|
const playerInputBindings = this.resolveRuntimePlayerInputBindings();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
pointerBinding !== null &&
|
pointerBinding !== null &&
|
||||||
this.runtimeScene.playerInputBindings.keyboard.interact ===
|
this.activeRuntimeTargetReference !== null &&
|
||||||
pointerBinding
|
playerInputBindings.keyboard.clearTarget === pointerBinding
|
||||||
|
) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
this.clearActiveRuntimeTarget();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
pointerBinding !== null &&
|
||||||
|
playerInputBindings.keyboard.interact === pointerBinding
|
||||||
) {
|
) {
|
||||||
this.dispatchRuntimeInteract();
|
this.dispatchRuntimeInteract();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,16 +166,32 @@ export function ViewportCanvas({
|
|||||||
|
|
||||||
const initialFrame = editorSimulationController.getFrameSnapshot();
|
const initialFrame = editorSimulationController.getFrameSnapshot();
|
||||||
let currentSceneVersion = initialFrame.sceneVersion;
|
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) => {
|
return editorSimulationController.subscribeFrame((frame) => {
|
||||||
if (frame.sceneVersion !== currentSceneVersion) {
|
if (frame.sceneVersion !== currentSceneVersion) {
|
||||||
currentSceneVersion = frame.sceneVersion;
|
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;
|
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]);
|
}, [editorSimulationController]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user