Add tests and update navigation controller deactivation logic
This commit is contained in:
@@ -3,6 +3,7 @@ import { Vector3 } from "three";
|
||||
import type { Vec3 } from "../core/vector";
|
||||
|
||||
import type {
|
||||
NavigationControllerDeactivateOptions,
|
||||
NavigationController,
|
||||
RuntimeControllerContext
|
||||
} from "./navigation-controller";
|
||||
@@ -83,7 +84,11 @@ export class OrbitVisitorNavigationController implements NavigationController {
|
||||
this.updateCameraTransform();
|
||||
}
|
||||
|
||||
deactivate(ctx: RuntimeControllerContext): void {
|
||||
deactivate(
|
||||
ctx: RuntimeControllerContext,
|
||||
_options: NavigationControllerDeactivateOptions = {}
|
||||
): void {
|
||||
void _options;
|
||||
ctx.domElement.removeEventListener("pointerdown", this.handlePointerDown);
|
||||
ctx.domElement.removeEventListener("wheel", this.handleWheel);
|
||||
ctx.domElement.removeEventListener("contextmenu", this.handleContextMenu);
|
||||
|
||||
@@ -342,11 +342,17 @@ export class RuntimeHost {
|
||||
|
||||
loadScene(runtimeScene: RuntimeSceneDefinition) {
|
||||
const requestId = ++this.collisionWorldRequestId;
|
||||
const preservePointerLockDuringLoad =
|
||||
this.activeController === this.firstPersonController &&
|
||||
this.desiredNavigationMode === "firstPerson" &&
|
||||
document.pointerLockElement === this.domElement;
|
||||
|
||||
this.sceneReady = false;
|
||||
this.runtimeScene = runtimeScene;
|
||||
this.currentWorld = runtimeScene.world;
|
||||
this.activeController?.deactivate(this.controllerContext);
|
||||
this.activeController?.deactivate(this.controllerContext, {
|
||||
releasePointerLock: !preservePointerLockDuringLoad
|
||||
});
|
||||
this.activeController = null;
|
||||
this.firstPersonController.resetSceneState();
|
||||
this.orbitVisitorController.resetSceneState();
|
||||
|
||||
Reference in New Issue
Block a user