diff --git a/src/App.vue b/src/App.vue index aa9c3a65..529a7d5a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -17,12 +17,7 @@ import { Utility } from "@Modules/utility"; import Log from "@Modules/debugging/log"; // FIXME: Apps - This should be handled properly. -/* eslint-disable-next-line */ -globalThis.useIgloo = window.location.toString().includes("?igloo=1"); -/* eslint-disable-next-line */ -import { IglooCamera } from "./modules/apps/igloo/Igloo.js"; -/* eslint-disable-next-line */ -globalThis.IglooCamera = IglooCamera; +window.useIgloo = window.location.toString().includes("?igloo=1"); export default defineComponent({ name: "App", diff --git a/src/igloo.ts b/src/igloo.ts new file mode 100644 index 00000000..1436aba7 --- /dev/null +++ b/src/igloo.ts @@ -0,0 +1,10 @@ +import type { IglooCamera } from "./modules/apps/igloo/Igloo.js"; + +declare global { + interface Window { + useIgloo: boolean; + IglooCameraInstance: IglooCamera; + } +} + +export {}; diff --git a/src/modules/apps/igloo/Igloo.d.ts b/src/modules/apps/igloo/Igloo.d.ts new file mode 100644 index 00000000..a6f86140 --- /dev/null +++ b/src/modules/apps/igloo/Igloo.d.ts @@ -0,0 +1,10 @@ +import type { Vector3, Scene, TransformNode } from "@babylonjs/core"; + +export class IglooCamera { + canvas: Nullable; + scene: Scene; + constructor(canvas: Nullable, scene: Scene); + follow: (object: TransformNode) => void; + setPosition: (pos: Vector3) => void; + update: () => boolean; +} diff --git a/src/modules/avatar/controller/inputController.ts b/src/modules/avatar/controller/inputController.ts index 764b28d4..fc85da50 100644 --- a/src/modules/avatar/controller/inputController.ts +++ b/src/modules/avatar/controller/inputController.ts @@ -35,6 +35,7 @@ import { VirtualJoystickInput } from "./inputs/virtualJoystickInput"; import { applicationStore, userStore } from "@Stores/index"; import type { SceneController } from "@Modules/scene/controllers"; import { MouseSettingsController } from "@Base/modules/avatar/controller/inputs/mouseSettings"; +import { IglooCamera } from "@Modules/apps/igloo/Igloo.js"; // Custom camera controls. class ArcRotateCameraCustomInput implements ICameraInput { @@ -236,9 +237,8 @@ export class InputController extends ScriptComponent { this._camera.attachControl(this._scene.getEngine().getRenderingCanvas()); // FIXME: Toss this into an app module. - if (globalThis.useIgloo) { - /* eslint-disable-next-line */ - globalThis.IglooCameraInstance = new globalThis.IglooCamera(null, this._scene); + if (window.useIgloo) { + window.IglooCameraInstance = new IglooCamera(null, this._scene); } } } @@ -765,9 +765,8 @@ export class InputController extends ScriptComponent { return; } - if (globalThis.useIgloo) { - /* eslint-disable-next-line */ - globalThis.IglooCameraInstance.setPosition(this._camera.position); + if (window.useIgloo) { + window.IglooCameraInstance.setPosition(this._camera.position); } this._cameraObstacleDetectInfo.elapse += delta;