@quick-threejs/reactive 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +49 -0
- package/dist/src/common/constants/event.constants.d.ts +2 -0
- package/dist/src/common/constants/event.constants.js +23 -0
- package/dist/src/common/constants/event.constants.js.map +1 -0
- package/dist/src/common/enums/camera.enum.d.ts +4 -0
- package/dist/src/common/enums/camera.enum.js +6 -0
- package/dist/src/common/enums/camera.enum.js.map +1 -0
- package/dist/src/common/enums/lifecycle.enum.d.ts +10 -0
- package/dist/src/common/enums/lifecycle.enum.js +13 -0
- package/dist/src/common/enums/lifecycle.enum.js.map +1 -0
- package/dist/src/common/interfaces/canvas.interface.d.ts +6 -0
- package/dist/src/common/interfaces/canvas.interface.js +2 -0
- package/dist/src/common/interfaces/canvas.interface.js.map +1 -0
- package/dist/src/common/interfaces/core.interface.d.ts +11 -0
- package/dist/src/common/interfaces/core.interface.js +2 -0
- package/dist/src/common/interfaces/core.interface.js.map +1 -0
- package/dist/src/common/interfaces/event.interface.d.ts +4 -0
- package/dist/src/common/interfaces/event.interface.js +2 -0
- package/dist/src/common/interfaces/event.interface.js.map +1 -0
- package/dist/src/common/interfaces/module.interface.d.ts +27 -0
- package/dist/src/common/interfaces/module.interface.js +2 -0
- package/dist/src/common/interfaces/module.interface.js.map +1 -0
- package/dist/src/common/interfaces/resource.interface.d.ts +14 -0
- package/dist/src/common/interfaces/resource.interface.js +2 -0
- package/dist/src/common/interfaces/resource.interface.js.map +1 -0
- package/dist/src/common/models/app-proxy-event-handler.model.d.ts +31 -0
- package/dist/src/common/models/app-proxy-event-handler.model.js +31 -0
- package/dist/src/common/models/app-proxy-event-handler.model.js.map +1 -0
- package/dist/src/common/models/proxy-event-handler.model.d.ts +18 -0
- package/dist/src/common/models/proxy-event-handler.model.js +18 -0
- package/dist/src/common/models/proxy-event-handler.model.js.map +1 -0
- package/dist/src/common/models/proxy-event-observables.model.d.ts +19 -0
- package/dist/src/common/models/proxy-event-observables.model.js +18 -0
- package/dist/src/common/models/proxy-event-observables.model.js.map +1 -0
- package/dist/src/common/models/proxy-event-subjects.models.d.ts +18 -0
- package/dist/src/common/models/proxy-event-subjects.models.js +17 -0
- package/dist/src/common/models/proxy-event-subjects.models.js.map +1 -0
- package/dist/src/common/models/register-props.model.d.ts +75 -0
- package/dist/src/common/models/register-props.model.js +74 -0
- package/dist/src/common/models/register-props.model.js.map +1 -0
- package/dist/src/common/models/register-proxy-event-handler.model.d.ts +17 -0
- package/dist/src/common/models/register-proxy-event-handler.model.js +17 -0
- package/dist/src/common/models/register-proxy-event-handler.model.js.map +1 -0
- package/dist/src/common/serializers/object3d.serializer.d.ts +2 -0
- package/dist/src/common/serializers/object3d.serializer.js +16 -0
- package/dist/src/common/serializers/object3d.serializer.js.map +1 -0
- package/dist/src/common/types/object.type.d.ts +25 -0
- package/dist/src/common/types/object.type.js +2 -0
- package/dist/src/common/types/object.type.js.map +1 -0
- package/dist/src/main.d.ts +1 -0
- package/dist/src/main.js +20 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/main.worker.d.ts +2 -0
- package/dist/src/main.worker.js +27 -0
- package/dist/src/main.worker.js.map +1 -0
- package/dist/src/modules/app/app.component.d.ts +7 -0
- package/dist/src/modules/app/app.component.js +18 -0
- package/dist/src/modules/app/app.component.js.map +1 -0
- package/dist/src/modules/app/app.controller.d.ts +10 -0
- package/dist/src/modules/app/app.controller.js +44 -0
- package/dist/src/modules/app/app.controller.js.map +1 -0
- package/dist/src/modules/app/app.module-worker.d.ts +6 -0
- package/dist/src/modules/app/app.module-worker.js +27 -0
- package/dist/src/modules/app/app.module-worker.js.map +1 -0
- package/dist/src/modules/app/app.module.d.ts +32 -0
- package/dist/src/modules/app/app.module.js +125 -0
- package/dist/src/modules/app/app.module.js.map +1 -0
- package/dist/src/modules/app/camera/camera.component.d.ts +18 -0
- package/dist/src/modules/app/camera/camera.component.js +81 -0
- package/dist/src/modules/app/camera/camera.component.js.map +1 -0
- package/dist/src/modules/app/camera/camera.controller.d.ts +10 -0
- package/dist/src/modules/app/camera/camera.controller.js +35 -0
- package/dist/src/modules/app/camera/camera.controller.js.map +1 -0
- package/dist/src/modules/app/camera/camera.module.d.ts +12 -0
- package/dist/src/modules/app/camera/camera.module.js +56 -0
- package/dist/src/modules/app/camera/camera.module.js.map +1 -0
- package/dist/src/modules/app/debug/debug.component.d.ts +28 -0
- package/dist/src/modules/app/debug/debug.component.js +119 -0
- package/dist/src/modules/app/debug/debug.component.js.map +1 -0
- package/dist/src/modules/app/debug/debug.controller.d.ts +6 -0
- package/dist/src/modules/app/debug/debug.controller.js +29 -0
- package/dist/src/modules/app/debug/debug.controller.js.map +1 -0
- package/dist/src/modules/app/debug/debug.module.d.ts +10 -0
- package/dist/src/modules/app/debug/debug.module.js +41 -0
- package/dist/src/modules/app/debug/debug.module.js.map +1 -0
- package/dist/src/modules/app/renderer/renderer.component.d.ts +19 -0
- package/dist/src/modules/app/renderer/renderer.component.js +83 -0
- package/dist/src/modules/app/renderer/renderer.component.js.map +1 -0
- package/dist/src/modules/app/renderer/renderer.controller.d.ts +13 -0
- package/dist/src/modules/app/renderer/renderer.controller.js +42 -0
- package/dist/src/modules/app/renderer/renderer.controller.js.map +1 -0
- package/dist/src/modules/app/renderer/renderer.module.d.ts +11 -0
- package/dist/src/modules/app/renderer/renderer.module.js +40 -0
- package/dist/src/modules/app/renderer/renderer.module.js.map +1 -0
- package/dist/src/modules/app/sizes/sizes.component.d.ts +10 -0
- package/dist/src/modules/app/sizes/sizes.component.js +26 -0
- package/dist/src/modules/app/sizes/sizes.component.js.map +1 -0
- package/dist/src/modules/app/sizes/sizes.controller.d.ts +9 -0
- package/dist/src/modules/app/sizes/sizes.controller.js +35 -0
- package/dist/src/modules/app/sizes/sizes.controller.js.map +1 -0
- package/dist/src/modules/app/sizes/sizes.module.d.ts +11 -0
- package/dist/src/modules/app/sizes/sizes.module.js +41 -0
- package/dist/src/modules/app/sizes/sizes.module.js.map +1 -0
- package/dist/src/modules/app/timer/timer.component.d.ts +8 -0
- package/dist/src/modules/app/timer/timer.component.js +20 -0
- package/dist/src/modules/app/timer/timer.component.js.map +1 -0
- package/dist/src/modules/app/timer/timer.controller.d.ts +15 -0
- package/dist/src/modules/app/timer/timer.controller.js +57 -0
- package/dist/src/modules/app/timer/timer.controller.js.map +1 -0
- package/dist/src/modules/app/timer/timer.module.d.ts +17 -0
- package/dist/src/modules/app/timer/timer.module.js +72 -0
- package/dist/src/modules/app/timer/timer.module.js.map +1 -0
- package/dist/src/modules/app/world/world.component.d.ts +4 -0
- package/dist/src/modules/app/world/world.component.js +16 -0
- package/dist/src/modules/app/world/world.component.js.map +1 -0
- package/dist/src/modules/app/world/world.controller.d.ts +2 -0
- package/dist/src/modules/app/world/world.controller.js +14 -0
- package/dist/src/modules/app/world/world.controller.js.map +1 -0
- package/dist/src/modules/app/world/world.module.d.ts +12 -0
- package/dist/src/modules/app/world/world.module.js +41 -0
- package/dist/src/modules/app/world/world.module.js.map +1 -0
- package/dist/src/modules/loader/loader.component.d.ts +25 -0
- package/dist/src/modules/loader/loader.component.js +68 -0
- package/dist/src/modules/loader/loader.component.js.map +1 -0
- package/dist/src/modules/loader/loader.controller.d.ts +9 -0
- package/dist/src/modules/loader/loader.controller.js +21 -0
- package/dist/src/modules/loader/loader.controller.js.map +1 -0
- package/dist/src/modules/loader/loader.module-worker.d.ts +3 -0
- package/dist/src/modules/loader/loader.module-worker.js +17 -0
- package/dist/src/modules/loader/loader.module-worker.js.map +1 -0
- package/dist/src/modules/loader/loader.module.d.ts +35 -0
- package/dist/src/modules/loader/loader.module.js +120 -0
- package/dist/src/modules/loader/loader.module.js.map +1 -0
- package/dist/src/modules/register/register.component.d.ts +13 -0
- package/dist/src/modules/register/register.component.js +35 -0
- package/dist/src/modules/register/register.component.js.map +1 -0
- package/dist/src/modules/register/register.controller.d.ts +40 -0
- package/dist/src/modules/register/register.controller.js +111 -0
- package/dist/src/modules/register/register.controller.js.map +1 -0
- package/dist/src/modules/register/register.module.d.ts +57 -0
- package/dist/src/modules/register/register.module.js +222 -0
- package/dist/src/modules/register/register.module.js.map +1 -0
- package/dist/vite.config.d.ts +2 -0
- package/dist/vite.config.js +53 -0
- package/dist/vite.config.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Object3D, ObjectLoader } from "three";
|
|
2
|
+
import { deserializeJSON, toSerializedJSON } from "@quick-threejs/utils";
|
|
3
|
+
const objectLoader = new ObjectLoader();
|
|
4
|
+
export const object3DSerializer = {
|
|
5
|
+
deserialize(message, defaultHandler) {
|
|
6
|
+
if (message?.isSerialized)
|
|
7
|
+
return deserializeJSON(message, objectLoader);
|
|
8
|
+
return defaultHandler(message);
|
|
9
|
+
},
|
|
10
|
+
serialize(thing, defaultHandler) {
|
|
11
|
+
if (thing instanceof Object3D)
|
|
12
|
+
return toSerializedJSON(thing);
|
|
13
|
+
return defaultHandler(thing);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=object3d.serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object3d.serializer.js","sourceRoot":"","sources":["../../../../src/common/serializers/object3d.serializer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEzE,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AAExC,MAAM,CAAC,MAAM,kBAAkB,GAA6B;IAC3D,WAAW,CAAC,OAAY,EAAE,cAAc;QACvC,IAAI,OAAO,EAAE,YAAY;YAAE,OAAO,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzE,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,SAAS,CAAC,KAAK,EAAE,cAAc;QAC9B,IAAI,KAAK,YAAY,QAAQ;YAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAE9D,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;CACD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Observable, Subject } from "rxjs";
|
|
2
|
+
import type { PROXY_EVENT_LISTENERS } from "../constants/event.constants";
|
|
3
|
+
/** @description Utility type to exclude properties with the type `never` */
|
|
4
|
+
export type NonNever<T extends object> = {
|
|
5
|
+
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
6
|
+
};
|
|
7
|
+
/** @description Utility type to extract only **methods** of an `object` */
|
|
8
|
+
export type Methods<T extends object> = NonNever<{
|
|
9
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? T[K] : never;
|
|
10
|
+
}>;
|
|
11
|
+
/** @description Utility type to extract only **properties** of an `object` */
|
|
12
|
+
export type Properties<T extends object> = NonNever<{
|
|
13
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? never : T[K];
|
|
14
|
+
}>;
|
|
15
|
+
/** @description */
|
|
16
|
+
export type ProxyEventListenerKeys = (typeof PROXY_EVENT_LISTENERS)[number];
|
|
17
|
+
export type ProxyEventHandlersImplementation = {
|
|
18
|
+
[x in ProxyEventListenerKeys]: (event: Event) => void;
|
|
19
|
+
};
|
|
20
|
+
export type ProxyEventSubjectsImplementation = {
|
|
21
|
+
[x in `${ProxyEventListenerKeys}$$`]: Subject<Event>;
|
|
22
|
+
};
|
|
23
|
+
export type ProxyEventObservablesImplementation = {
|
|
24
|
+
[x in `${ProxyEventListenerKeys}$`]: Observable<Event>;
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.type.js","sourceRoot":"","sources":["../../../../src/common/types/object.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/main.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { register } from "./modules/register/register.module";
|
|
2
|
+
if (process.env.NODE_ENV === "development") {
|
|
3
|
+
register({
|
|
4
|
+
location: new URL("./main.worker.ts", import.meta.url),
|
|
5
|
+
enableDebug: true,
|
|
6
|
+
axesSizes: 5,
|
|
7
|
+
gridSizes: 10,
|
|
8
|
+
withMiniCamera: true,
|
|
9
|
+
onReady: (app) => {
|
|
10
|
+
app
|
|
11
|
+
.gui()
|
|
12
|
+
?.add({ torusX: 0 }, "torusX")
|
|
13
|
+
.step(0.01)
|
|
14
|
+
.onChange((value) => {
|
|
15
|
+
app.worker()?.postMessage({ type: "torus-x-gui-event", value });
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAE9D,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;IAC5C,QAAQ,CAAC;QACR,QAAQ,EAAE,IAAI,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAsB;QAC3E,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,EAAE;QACb,cAAc,EAAE,IAAI;QACpB,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAChB,GAAG;iBACD,GAAG,EAAE;gBACN,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC;iBAC7B,IAAI,CAAC,IAAI,CAAC;iBACV,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE;gBACnB,GAAG,CAAC,MAAM,EAAE,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC;QACL,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Mesh, MeshNormalMaterial, TorusKnotGeometry } from "three";
|
|
2
|
+
import { launchApp } from "./modules/app/app.module-worker";
|
|
3
|
+
if (process.env.NODE_ENV === "development") {
|
|
4
|
+
launchApp({
|
|
5
|
+
onReady: (app) => {
|
|
6
|
+
const torus = new Mesh(new TorusKnotGeometry(), new MeshNormalMaterial());
|
|
7
|
+
self.onmessage = (event) => {
|
|
8
|
+
if (event.data?.type === "torus-x-gui-event") {
|
|
9
|
+
torus.position.x = event.data.value;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
app.world.scene().add(torus);
|
|
13
|
+
app.resize$?.().subscribe((event) => {
|
|
14
|
+
console.log(event.type);
|
|
15
|
+
});
|
|
16
|
+
app.wheel$?.().subscribe((event) => {
|
|
17
|
+
console.log(event.type);
|
|
18
|
+
});
|
|
19
|
+
app.timer.step$().subscribe(() => {
|
|
20
|
+
torus.rotateY(0.1);
|
|
21
|
+
torus.rotateX(0.01);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export { launchApp };
|
|
27
|
+
//# sourceMappingURL=main.worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.worker.js","sourceRoot":"","sources":["../../src/main.worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;IAC5C,SAAS,CAAC;QACT,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAChB,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,iBAAiB,EAAE,EAAE,IAAI,kBAAkB,EAAE,CAAC,CAAC;YAE1E,IAAI,CAAC,SAAS,GAAG,CAAC,KAAmB,EAAE,EAAE;gBACxC,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,KAAK,mBAAmB,EAAE,CAAC;oBAC9C,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;gBACrC,CAAC;YACF,CAAC,CAAC;YAEF,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAE7B,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;gBACnC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;YAEH,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;gBAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;YAEH,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE;gBAChC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBACnB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACJ,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProxyReceiver } from "@quick-threejs/utils";
|
|
2
|
+
import { OffscreenCanvasWithStyle } from "../../common/interfaces/canvas.interface";
|
|
3
|
+
export declare class AppComponent {
|
|
4
|
+
readonly proxyReceiver: ProxyReceiver<Record<string, unknown>>;
|
|
5
|
+
initialized: boolean;
|
|
6
|
+
canvas?: OffscreenCanvasWithStyle;
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { singleton } from "tsyringe";
|
|
8
|
+
import { ProxyReceiver } from "@quick-threejs/utils";
|
|
9
|
+
let AppComponent = class AppComponent {
|
|
10
|
+
proxyReceiver = new ProxyReceiver();
|
|
11
|
+
initialized = false;
|
|
12
|
+
canvas;
|
|
13
|
+
};
|
|
14
|
+
AppComponent = __decorate([
|
|
15
|
+
singleton()
|
|
16
|
+
], AppComponent);
|
|
17
|
+
export { AppComponent };
|
|
18
|
+
//# sourceMappingURL=app.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.component.js","sourceRoot":"","sources":["../../../../src/modules/app/app.component.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAK9C,IAAM,YAAY,GAAlB,MAAM,YAAY;IACR,aAAa,GAAG,IAAI,aAAa,EAA2B,CAAC;IAEtE,WAAW,GAAG,KAAK,CAAC;IACpB,MAAM,CAA4B;CACzC,CAAA;AALY,YAAY;IADxB,SAAS,EAAE;GACC,YAAY,CAKxB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Subject } from "rxjs";
|
|
2
|
+
import { AppComponent } from "./app.component";
|
|
3
|
+
import { ProxyEventHandlersModel } from "../../common/models/proxy-event-handler.model";
|
|
4
|
+
import { AppLifecycleState } from "../../common/enums/lifecycle.enum";
|
|
5
|
+
export declare class AppController extends ProxyEventHandlersModel {
|
|
6
|
+
private readonly component;
|
|
7
|
+
readonly lifecycle$$: Subject<AppLifecycleState>;
|
|
8
|
+
readonly lifecycle$: import("rxjs").Observable<AppLifecycleState>;
|
|
9
|
+
constructor(component: AppComponent);
|
|
10
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { inject, singleton } from "tsyringe";
|
|
14
|
+
import { Subject } from "rxjs";
|
|
15
|
+
import { AppComponent } from "./app.component";
|
|
16
|
+
import { ProxyEventHandlersModel } from "../../common/models/proxy-event-handler.model";
|
|
17
|
+
import { PROXY_EVENT_LISTENERS } from "../../common/constants/event.constants";
|
|
18
|
+
let AppController = class AppController extends ProxyEventHandlersModel {
|
|
19
|
+
component;
|
|
20
|
+
lifecycle$$ = new Subject();
|
|
21
|
+
lifecycle$ = this.lifecycle$$.pipe();
|
|
22
|
+
constructor(component) {
|
|
23
|
+
super();
|
|
24
|
+
this.component = component;
|
|
25
|
+
for (const eventType of PROXY_EVENT_LISTENERS) {
|
|
26
|
+
this[`${eventType}$$`] = new Subject();
|
|
27
|
+
this[`${eventType}$`] = this[`${eventType}$$`].pipe();
|
|
28
|
+
this[eventType] = (event) => {
|
|
29
|
+
this.component.proxyReceiver.handleEvent({
|
|
30
|
+
...event,
|
|
31
|
+
type: event.type || eventType
|
|
32
|
+
});
|
|
33
|
+
this[`${eventType}$$`].next(event);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
AppController = __decorate([
|
|
39
|
+
singleton(),
|
|
40
|
+
__param(0, inject(AppComponent)),
|
|
41
|
+
__metadata("design:paramtypes", [AppComponent])
|
|
42
|
+
], AppController);
|
|
43
|
+
export { AppController };
|
|
44
|
+
//# sourceMappingURL=app.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../../../../src/modules/app/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAExF,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAGxE,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,uBAAuB;IAKjB;IAJxB,WAAW,GAAG,IAAI,OAAO,EAAqB,CAAC;IAC/C,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAErD,YACwC,SAAuB;QAE9D,KAAK,EAAE,CAAC;QAF+B,cAAS,GAAT,SAAS,CAAc;QAI9D,KAAK,MAAM,SAAS,IAAI,qBAAqB,EAAE,CAAC;YAC/C,IAAI,CAAC,GAAG,SAAS,IAAI,CAAC,GAAG,IAAI,OAAO,EAAS,CAAC;YAC9C,IAAI,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YAEtD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAY,EAAE,EAAE;gBAClC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC;oBACxC,GAAG,KAAK;oBACR,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,SAAS;iBAC7B,CAAC,CAAC;gBACH,IAAI,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpC,CAAC,CAAC;QACH,CAAC;IACF,CAAC;CACD,CAAA;AAtBY,aAAa;IADzB,SAAS,EAAE;IAMT,WAAA,MAAM,CAAC,YAAY,CAAC,CAAA;qCAA6B,YAAY;GALnD,aAAa,CAsBzB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExposedWorkerThreadModule } from "@quick-threejs/utils/dist/types/worker.type";
|
|
2
|
+
import { AppModule } from "./app.module";
|
|
3
|
+
import type { LaunchAppProps } from "../../common/interfaces/module.interface";
|
|
4
|
+
import type { Methods } from "../../common/types/object.type";
|
|
5
|
+
export declare const launchApp: (props?: LaunchAppProps) => AppModule;
|
|
6
|
+
export type ExposedAppModule = ExposedWorkerThreadModule<Methods<AppModule>>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { expose, registerSerializer } from "threads/worker";
|
|
2
|
+
import { appModule } from "./app.module";
|
|
3
|
+
import { object3DSerializer } from "../../common/serializers/object3d.serializer";
|
|
4
|
+
import { AppLifecycleState } from "../../common/enums/lifecycle.enum";
|
|
5
|
+
import { PROXY_EVENT_LISTENERS } from "../../common/constants/event.constants";
|
|
6
|
+
registerSerializer(object3DSerializer);
|
|
7
|
+
export const launchApp = (props) => {
|
|
8
|
+
appModule.lifecycle$().subscribe((state) => {
|
|
9
|
+
if (state === AppLifecycleState.INITIALIZED && props?.onReady)
|
|
10
|
+
props.onReady(appModule);
|
|
11
|
+
});
|
|
12
|
+
return appModule;
|
|
13
|
+
};
|
|
14
|
+
const proxyEventHandlers = {};
|
|
15
|
+
const proxyObservables = {};
|
|
16
|
+
PROXY_EVENT_LISTENERS.forEach((key) => {
|
|
17
|
+
proxyEventHandlers[key] = appModule[key]?.bind?.(appModule);
|
|
18
|
+
});
|
|
19
|
+
expose({
|
|
20
|
+
...proxyEventHandlers,
|
|
21
|
+
...proxyObservables,
|
|
22
|
+
init: () => { },
|
|
23
|
+
dispose: appModule.dispose.bind(appModule),
|
|
24
|
+
isInitialized: appModule.isInitialized.bind(appModule),
|
|
25
|
+
lifecycle$: appModule.lifecycle$.bind(appModule)
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=app.module-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.module-worker.js","sourceRoot":"","sources":["../../../../src/modules/app/app.module-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAI5D,OAAO,EAAa,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAO/E,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;AAEvC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAsB,EAAE,EAAE;IACnD,SAAS,CAAC,UAAU,EAAE,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QAC1C,IAAI,KAAK,KAAK,iBAAiB,CAAC,WAAW,IAAI,KAAK,EAAE,OAAO;YAC5D,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAEpB,EAAS,CAAC;AACd,MAAM,gBAAgB,GAElB,EAAS,CAAC;AAEd,qBAAqB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;IACrC,kBAAkB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC;IACN,GAAG,kBAAkB;IACrB,GAAG,gBAAgB;IACnB,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;IACd,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC;IAC1C,aAAa,EAAE,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC;IACtD,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC;CACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import type { WorkerThreadModule } from "@quick-threejs/utils/dist/types/worker.type";
|
|
3
|
+
import { AppController } from "./app.controller";
|
|
4
|
+
import { AppComponent } from "./app.component";
|
|
5
|
+
import { TimerModule } from "./timer/timer.module";
|
|
6
|
+
import { CameraModule } from "./camera/camera.module";
|
|
7
|
+
import { RendererModule } from "./renderer/renderer.module";
|
|
8
|
+
import { SizesModule } from "./sizes/sizes.module";
|
|
9
|
+
import { WorldModule } from "./world/world.module";
|
|
10
|
+
import { DebugModule } from "./debug/debug.module";
|
|
11
|
+
import { AppLifecycleState } from "../../common/enums/lifecycle.enum";
|
|
12
|
+
import { AppProxyEventHandlersModel } from "../../common/models/app-proxy-event-handler.model";
|
|
13
|
+
import type { Module } from "../../common/interfaces/module.interface";
|
|
14
|
+
import type { CoreModuleMessageEventData } from "../../common/interfaces/core.interface";
|
|
15
|
+
export declare class AppModule extends AppProxyEventHandlersModel implements Module, WorkerThreadModule {
|
|
16
|
+
private readonly controller;
|
|
17
|
+
private readonly component;
|
|
18
|
+
readonly timer: TimerModule;
|
|
19
|
+
readonly sizes: SizesModule;
|
|
20
|
+
readonly camera: CameraModule;
|
|
21
|
+
readonly world: WorldModule;
|
|
22
|
+
readonly renderer: RendererModule;
|
|
23
|
+
readonly debug: DebugModule;
|
|
24
|
+
constructor(controller: AppController, component: AppComponent, timer: TimerModule, sizes: SizesModule, camera: CameraModule, world: WorldModule, renderer: RendererModule, debug: DebugModule);
|
|
25
|
+
private _initProxyEvents;
|
|
26
|
+
private _onMessage;
|
|
27
|
+
init(props: CoreModuleMessageEventData): void;
|
|
28
|
+
isInitialized(): boolean;
|
|
29
|
+
dispose(): void;
|
|
30
|
+
lifecycle$(): import("rxjs").Observable<AppLifecycleState>;
|
|
31
|
+
}
|
|
32
|
+
export declare const appModule: AppModule;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import "reflect-metadata";
|
|
14
|
+
import { container, inject, singleton } from "tsyringe";
|
|
15
|
+
import { AppController } from "./app.controller";
|
|
16
|
+
import { AppComponent } from "./app.component";
|
|
17
|
+
import { TimerModule } from "./timer/timer.module";
|
|
18
|
+
import { CameraModule } from "./camera/camera.module";
|
|
19
|
+
import { RendererModule } from "./renderer/renderer.module";
|
|
20
|
+
import { SizesModule } from "./sizes/sizes.module";
|
|
21
|
+
import { WorldModule } from "./world/world.module";
|
|
22
|
+
import { DebugModule } from "./debug/debug.module";
|
|
23
|
+
import { AppLifecycleState } from "../../common/enums/lifecycle.enum";
|
|
24
|
+
import { PROXY_EVENT_LISTENERS } from "../../common/constants/event.constants";
|
|
25
|
+
import { AppProxyEventHandlersModel } from "../../common/models/app-proxy-event-handler.model";
|
|
26
|
+
let AppModule = class AppModule extends AppProxyEventHandlersModel {
|
|
27
|
+
controller;
|
|
28
|
+
component;
|
|
29
|
+
timer;
|
|
30
|
+
sizes;
|
|
31
|
+
camera;
|
|
32
|
+
world;
|
|
33
|
+
renderer;
|
|
34
|
+
debug;
|
|
35
|
+
constructor(controller, component, timer, sizes, camera, world, renderer, debug) {
|
|
36
|
+
super();
|
|
37
|
+
this.controller = controller;
|
|
38
|
+
this.component = component;
|
|
39
|
+
this.timer = timer;
|
|
40
|
+
this.sizes = sizes;
|
|
41
|
+
this.camera = camera;
|
|
42
|
+
this.world = world;
|
|
43
|
+
this.renderer = renderer;
|
|
44
|
+
this.debug = debug;
|
|
45
|
+
this._initProxyEvents();
|
|
46
|
+
self.addEventListener("message", this._onMessage.bind(this));
|
|
47
|
+
}
|
|
48
|
+
_initProxyEvents() {
|
|
49
|
+
PROXY_EVENT_LISTENERS.forEach((key) => {
|
|
50
|
+
this[key] = (event) => {
|
|
51
|
+
this.controller?.[key]?.(event);
|
|
52
|
+
};
|
|
53
|
+
this[`${key}$`] = () => this.controller?.[`${key}$`];
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
_onMessage(event) {
|
|
57
|
+
if (!event.data?.canvas || this.component.initialized)
|
|
58
|
+
return;
|
|
59
|
+
const startTimer = !!event.data?.startTimer;
|
|
60
|
+
const withMiniCamera = !!event.data?.withMiniCamera;
|
|
61
|
+
const fullScreen = !!event.data?.fullScreen;
|
|
62
|
+
this.init({
|
|
63
|
+
...event.data,
|
|
64
|
+
startTimer,
|
|
65
|
+
withMiniCamera,
|
|
66
|
+
fullScreen
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
init(props) {
|
|
70
|
+
if (!props.canvas || this.component.initialized)
|
|
71
|
+
return;
|
|
72
|
+
this.component.initialized = true;
|
|
73
|
+
props.canvas["style"] = {
|
|
74
|
+
width: props.canvas.width + "",
|
|
75
|
+
height: props.canvas.height + ""
|
|
76
|
+
};
|
|
77
|
+
const canvas = props.canvas;
|
|
78
|
+
this.component.canvas = canvas;
|
|
79
|
+
this.sizes.init(canvas);
|
|
80
|
+
this.timer.init(props.startTimer);
|
|
81
|
+
this.camera.init(props.withMiniCamera);
|
|
82
|
+
this.world.init();
|
|
83
|
+
this.renderer.init(canvas);
|
|
84
|
+
this.debug.init(props);
|
|
85
|
+
this.controller.lifecycle$$.next(AppLifecycleState.INITIALIZED);
|
|
86
|
+
}
|
|
87
|
+
isInitialized() {
|
|
88
|
+
return this.component.initialized;
|
|
89
|
+
}
|
|
90
|
+
dispose() {
|
|
91
|
+
this.timer.dispose();
|
|
92
|
+
this.camera.dispose();
|
|
93
|
+
this.renderer.dispose();
|
|
94
|
+
this.sizes.dispose();
|
|
95
|
+
this.world.dispose();
|
|
96
|
+
self.removeEventListener("message", this._onMessage.bind(this));
|
|
97
|
+
this.controller.lifecycle$$.next(AppLifecycleState.DISPOSED);
|
|
98
|
+
this.controller.lifecycle$$.complete();
|
|
99
|
+
}
|
|
100
|
+
lifecycle$() {
|
|
101
|
+
return this.controller.lifecycle$;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
AppModule = __decorate([
|
|
105
|
+
singleton(),
|
|
106
|
+
__param(0, inject(AppController)),
|
|
107
|
+
__param(1, inject(AppComponent)),
|
|
108
|
+
__param(2, inject(TimerModule)),
|
|
109
|
+
__param(3, inject(SizesModule)),
|
|
110
|
+
__param(4, inject(CameraModule)),
|
|
111
|
+
__param(5, inject(WorldModule)),
|
|
112
|
+
__param(6, inject(RendererModule)),
|
|
113
|
+
__param(7, inject(DebugModule)),
|
|
114
|
+
__metadata("design:paramtypes", [AppController,
|
|
115
|
+
AppComponent,
|
|
116
|
+
TimerModule,
|
|
117
|
+
SizesModule,
|
|
118
|
+
CameraModule,
|
|
119
|
+
WorldModule,
|
|
120
|
+
RendererModule,
|
|
121
|
+
DebugModule])
|
|
122
|
+
], AppModule);
|
|
123
|
+
export { AppModule };
|
|
124
|
+
export const appModule = container.resolve(AppModule);
|
|
125
|
+
//# sourceMappingURL=app.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../../../src/modules/app/app.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC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;QACpB,WAAW;GAZ5C,SAAS,CAqFrB;;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Camera, Euler, PerspectiveCamera, Quaternion, Vector3 } from "three";
|
|
2
|
+
import { SizesComponent } from "../sizes/sizes.component";
|
|
3
|
+
import { DefaultCameraType } from "../../../common/enums/camera.enum";
|
|
4
|
+
export declare class CameraComponent {
|
|
5
|
+
private readonly sizesComponent;
|
|
6
|
+
instance?: Camera;
|
|
7
|
+
miniCamera?: PerspectiveCamera;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
constructor(sizesComponent: SizesComponent);
|
|
10
|
+
set aspectRatio(ratio: number);
|
|
11
|
+
set quaternion(quaternion: Quaternion);
|
|
12
|
+
set position(position: Vector3);
|
|
13
|
+
set rotation(rotation: Euler);
|
|
14
|
+
setDefaultCamera(cameraType?: DefaultCameraType): void;
|
|
15
|
+
setMiniCamera(): void;
|
|
16
|
+
removeCamera(): void;
|
|
17
|
+
removeMiniCamera(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { inject, singleton } from "tsyringe";
|
|
14
|
+
import { Camera, OrthographicCamera, PerspectiveCamera } from "three";
|
|
15
|
+
import { SizesComponent } from "../sizes/sizes.component";
|
|
16
|
+
import { DefaultCameraType } from "../../../common/enums/camera.enum";
|
|
17
|
+
let CameraComponent = class CameraComponent {
|
|
18
|
+
sizesComponent;
|
|
19
|
+
instance;
|
|
20
|
+
miniCamera;
|
|
21
|
+
enabled = true;
|
|
22
|
+
constructor(sizesComponent) {
|
|
23
|
+
this.sizesComponent = sizesComponent;
|
|
24
|
+
}
|
|
25
|
+
set aspectRatio(ratio) {
|
|
26
|
+
if (this.instance instanceof PerspectiveCamera)
|
|
27
|
+
this.instance.aspect = ratio;
|
|
28
|
+
if (this.instance instanceof PerspectiveCamera ||
|
|
29
|
+
this.instance instanceof OrthographicCamera)
|
|
30
|
+
this.instance?.updateProjectionMatrix();
|
|
31
|
+
}
|
|
32
|
+
set quaternion(quaternion) {
|
|
33
|
+
this.instance?.quaternion.copy(quaternion);
|
|
34
|
+
}
|
|
35
|
+
set position(position) {
|
|
36
|
+
this.instance?.position.copy(position);
|
|
37
|
+
}
|
|
38
|
+
set rotation(rotation) {
|
|
39
|
+
this.instance?.rotation.copy(rotation);
|
|
40
|
+
}
|
|
41
|
+
setDefaultCamera(cameraType) {
|
|
42
|
+
this.removeCamera();
|
|
43
|
+
if (cameraType === DefaultCameraType.PERSPECTIVE || cameraType === undefined) {
|
|
44
|
+
this.instance = new PerspectiveCamera(70, this.sizesComponent.width / this.sizesComponent.height, 0.0001, 100);
|
|
45
|
+
this.instance.position.z = 8;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (cameraType === DefaultCameraType.ORTHOGRAPHIC) {
|
|
49
|
+
this.instance = new OrthographicCamera((-this.sizesComponent.aspect * this.sizesComponent.frustrum) / 2, (this.sizesComponent.aspect * this.sizesComponent.frustrum) / 2, this.sizesComponent.frustrum / 2, -this.sizesComponent.frustrum / 2, -50, 50);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
setMiniCamera() {
|
|
53
|
+
this.removeMiniCamera();
|
|
54
|
+
this.miniCamera = new PerspectiveCamera(75, this.sizesComponent.width / this.sizesComponent.height, 0.1, 500);
|
|
55
|
+
this.miniCamera.position.z = 10;
|
|
56
|
+
this.miniCamera.position.x = -5;
|
|
57
|
+
}
|
|
58
|
+
removeCamera() {
|
|
59
|
+
if (!(this.instance instanceof Camera))
|
|
60
|
+
return;
|
|
61
|
+
if (this.instance instanceof PerspectiveCamera ||
|
|
62
|
+
this.instance instanceof OrthographicCamera)
|
|
63
|
+
this.instance.clearViewOffset();
|
|
64
|
+
this.instance.clear();
|
|
65
|
+
this.instance = undefined;
|
|
66
|
+
}
|
|
67
|
+
removeMiniCamera() {
|
|
68
|
+
if (!(this.miniCamera instanceof Camera))
|
|
69
|
+
return;
|
|
70
|
+
this.miniCamera.clearViewOffset();
|
|
71
|
+
this.miniCamera.clear();
|
|
72
|
+
this.miniCamera = undefined;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
CameraComponent = __decorate([
|
|
76
|
+
singleton(),
|
|
77
|
+
__param(0, inject(SizesComponent)),
|
|
78
|
+
__metadata("design:paramtypes", [SizesComponent])
|
|
79
|
+
], CameraComponent);
|
|
80
|
+
export { CameraComponent };
|
|
81
|
+
//# sourceMappingURL=camera.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.component.js","sourceRoot":"","sources":["../../../../../src/modules/app/camera/camera.component.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACN,MAAM,EAEN,kBAAkB,EAClB,iBAAiB,EAGjB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,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,CAAC;IAEM,gBAAgB;QACtB,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,YAAY,MAAM,CAAC;YAAE,OAAO;QACjD,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;QAClC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC7B,CAAC;CACD,CAAA;AAxFY,eAAe;IAD3B,SAAS,EAAE;IAOT,WAAA,MAAM,CAAC,cAAc,CAAC,CAAA;qCAAkC,cAAc;GAN5D,eAAe,CAwF3B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { CameraComponent } from "./camera.component";
|
|
3
|
+
import { TimerController } from "../timer/timer.controller";
|
|
4
|
+
import type { StepPayload } from "../../../common/interfaces/event.interface";
|
|
5
|
+
export declare class CameraController {
|
|
6
|
+
private readonly component;
|
|
7
|
+
private readonly timerController;
|
|
8
|
+
step$: Observable<StepPayload>;
|
|
9
|
+
constructor(component: CameraComponent, timerController: TimerController);
|
|
10
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { inject, singleton } from "tsyringe";
|
|
14
|
+
import { filter } from "rxjs";
|
|
15
|
+
import { CameraComponent } from "./camera.component";
|
|
16
|
+
import { TimerController } from "../timer/timer.controller";
|
|
17
|
+
let CameraController = class CameraController {
|
|
18
|
+
component;
|
|
19
|
+
timerController;
|
|
20
|
+
step$;
|
|
21
|
+
constructor(component, timerController) {
|
|
22
|
+
this.component = component;
|
|
23
|
+
this.timerController = timerController;
|
|
24
|
+
this.step$ = this.timerController.step$.pipe(filter(() => this.component.enabled));
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
CameraController = __decorate([
|
|
28
|
+
singleton(),
|
|
29
|
+
__param(0, inject(CameraComponent)),
|
|
30
|
+
__param(1, inject(TimerController)),
|
|
31
|
+
__metadata("design:paramtypes", [CameraComponent,
|
|
32
|
+
TimerController])
|
|
33
|
+
], CameraController);
|
|
34
|
+
export { CameraController };
|
|
35
|
+
//# sourceMappingURL=camera.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera.controller.js","sourceRoot":"","sources":["../../../../../src/modules/app/camera/camera.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAGrD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGe;IACA;IAHpC,KAAK,CAA0B;IACtC,YAC2C,SAA0B,EAC1B,eAAgC;QADhC,cAAS,GAAT,SAAS,CAAiB;QAC1B,oBAAe,GAAf,eAAe,CAAiB;QAE1E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAC3C,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CACpC,CAAC;IACH,CAAC;CACD,CAAA;AAVY,gBAAgB;IAD5B,SAAS,EAAE;IAIT,WAAA,MAAM,CAAC,eAAe,CAAC,CAAA;IACvB,WAAA,MAAM,CAAC,eAAe,CAAC,CAAA;qCAD6B,eAAe;QACT,eAAe;GAJ/D,gBAAgB,CAU5B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CameraComponent } from "./camera.component";
|
|
2
|
+
import { CameraController } from "./camera.controller";
|
|
3
|
+
import { SizesComponent } from "../sizes/sizes.component";
|
|
4
|
+
import type { Module } from "../../../common/interfaces/module.interface";
|
|
5
|
+
export declare class CameraModule implements Module {
|
|
6
|
+
private readonly component;
|
|
7
|
+
private readonly sizesComponent;
|
|
8
|
+
private readonly controller;
|
|
9
|
+
constructor(component: CameraComponent, sizesComponent: SizesComponent, controller: CameraController);
|
|
10
|
+
init(withMiniCamera?: boolean): void;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}
|