@benjos/create-boilerplate 1.3.5 → 1.4.1
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/package.json +1 -1
- package/template-react/package-lock.json +2 -2
- package/template-react/package.json +1 -1
- package/template-react/src/App.css +21 -21
- package/template-react/src/App.tsx +5 -9
- package/template-react/src/index.css +42 -42
- package/template-react/src/main.tsx +8 -8
- package/template-vanilla/index.html +23 -14
- package/template-vanilla/package-lock.json +8 -6
- package/template-vanilla/package.json +2 -2
- package/template-vanilla/src/experiences/Experience.ts +11 -11
- package/template-vanilla/src/experiences/cameras/threes/DebugThreeCameraController.ts +13 -18
- package/template-vanilla/src/experiences/cameras/threes/LoaderThreeCameraController.ts +7 -10
- package/template-vanilla/src/experiences/cameras/threes/MainThreeCameraController.ts +6 -10
- package/template-vanilla/src/experiences/cameras/threes/bases/ThreeCameraControllerBase.ts +20 -39
- package/template-vanilla/src/experiences/commands/InitCommand.ts +30 -33
- package/template-vanilla/src/experiences/engines/htmls/MainHTML.ts +10 -7
- package/template-vanilla/src/experiences/engines/threes/MainThree.ts +8 -168
- package/template-vanilla/src/experiences/engines/threes/app/LoaderThreeApp.ts +39 -0
- package/template-vanilla/src/experiences/engines/threes/app/MainThreeApp.ts +96 -0
- package/template-vanilla/src/experiences/engines/threes/app/bases/ThreeAppBase.ts +92 -0
- package/template-vanilla/src/experiences/managers/DebugManager.ts +31 -33
- package/template-vanilla/src/experiences/managers/LoaderManager.ts +53 -45
- package/template-vanilla/src/experiences/managers/threes/ThreeAssetsManager.ts +94 -109
- package/template-vanilla/src/experiences/managers/threes/ThreeCameraControllerManager.ts +22 -19
- package/template-vanilla/src/experiences/managers/threes/ThreeRaycasterManager.ts +12 -14
- package/template-vanilla/src/experiences/materials/threes/loaders/LoaderMaterial.ts +0 -4
- package/template-vanilla/src/experiences/renderers/threes/LoaderRenderer.ts +0 -4
- package/template-vanilla/src/experiences/renderers/threes/Renderer.ts +5 -9
- package/template-vanilla/src/experiences/renderers/threes/bases/WebGLRendererBase.ts +3 -3
- package/template-vanilla/src/experiences/styles/commons/main.scss +6 -6
- package/template-vanilla/src/experiences/styles/style.scss +1 -1
- package/template-vanilla/src/experiences/styles/views/loader.scss +7 -6
- package/template-vanilla/src/experiences/types/cameraTypes.ts +37 -0
- package/template-vanilla/src/experiences/types/global.d.ts +2 -2
- package/template-vanilla/src/experiences/types/shaders.d.ts +4 -0
- package/template-vanilla/src/experiences/views/htmls/bases/HTMLViewBase.ts +13 -33
- package/template-vanilla/src/experiences/views/htmls/loaders/LoaderHTMLView.ts +27 -18
- package/template-vanilla/src/experiences/views/threes/bases/ThreeViewBase.ts +26 -18
- package/template-vanilla/src/experiences/views/threes/loaders/LoaderThreeView.ts +11 -15
- package/template-vanilla/src/experiences/views/threes/loaders/components/ThreeTemplateLoader.ts +15 -12
- package/template-vanilla/src/experiences/views/threes/worlds/WorldThreeView.ts +9 -17
- package/template-vanilla/src/experiences/views/threes/worlds/components/Environment.ts +14 -18
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateFont.ts +11 -9
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateMesh.ts +11 -9
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateModel.ts +2 -6
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ActorBase.ts +13 -1
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/AnimatedModelBase.ts +5 -9
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ModelBase.ts +18 -4
- package/template-vanilla/src/main.ts +1 -1
- package/template-vanilla/tsconfig.json +17 -0
- package/template-vanilla/src/experiences/constants/experiences/CameraType.ts +0 -6
- package/template-vanilla/src/experiences/managers/KeyboardManager.ts +0 -65
- package/template-vanilla/src/experiences/managers/MouseManager.ts +0 -100
- package/template-vanilla/src/experiences/managers/ResizeManager.ts +0 -53
- package/template-vanilla/src/experiences/managers/TickerManager.ts +0 -86
- package/template-vanilla/src/experiences/proxies/ViewProxy.ts +0 -45
- package/template-vanilla/src/experiences/views/bases/ViewBase.ts +0 -36
- package/template-vanilla/src/experiences/views/htmls/loaders/components/HTMLTemplateLoader.ts +0 -57
- /package/template-vanilla/src/experiences/{constants/experiences/AssetType.ts → types/assetTypes.ts} +0 -0
package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateMesh.ts
CHANGED
|
@@ -4,12 +4,6 @@ import ThreeAssetsManager from '../../../../../managers/threes/ThreeAssetsManage
|
|
|
4
4
|
import ActorBase from './bases/ActorBase';
|
|
5
5
|
|
|
6
6
|
export default class TemplateMesh extends ActorBase {
|
|
7
|
-
declare private _geometry: SphereGeometry;
|
|
8
|
-
declare private _material: MeshStandardMaterial;
|
|
9
|
-
declare private _mesh: Mesh;
|
|
10
|
-
|
|
11
|
-
//#region Constants
|
|
12
|
-
//
|
|
13
7
|
private static readonly _DEFAULT_GEOMETRY_RADIUS = 1;
|
|
14
8
|
private static readonly _DEFAULT_GEOMETRY_WIDTH_SEGMENTS = 64;
|
|
15
9
|
private static readonly _DEFAULT_GEOMETRY_HEIGHT_SEGMENTS = 64;
|
|
@@ -21,8 +15,10 @@ export default class TemplateMesh extends ActorBase {
|
|
|
21
15
|
envMapIntensity: 0,
|
|
22
16
|
};
|
|
23
17
|
private static readonly _MESH_ROTATION_Y = 0.25;
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
|
|
19
|
+
declare private _geometry: SphereGeometry;
|
|
20
|
+
declare private _material: MeshStandardMaterial;
|
|
21
|
+
declare private _mesh: Mesh;
|
|
26
22
|
|
|
27
23
|
constructor() {
|
|
28
24
|
super();
|
|
@@ -41,7 +37,7 @@ export default class TemplateMesh extends ActorBase {
|
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
private _generateMaterial(): void {
|
|
44
|
-
const normalMat = ThreeAssetsManager.
|
|
40
|
+
const normalMat = ThreeAssetsManager.getTexture(AssetId.THREE_TEXTURE_TEMPLATE);
|
|
45
41
|
normalMat.repeat.set(TemplateMesh._DEFAULT_MATERIAL_REPEAT, TemplateMesh._DEFAULT_MATERIAL_REPEAT);
|
|
46
42
|
normalMat.wrapS = normalMat.wrapT = RepeatWrapping;
|
|
47
43
|
|
|
@@ -58,6 +54,12 @@ export default class TemplateMesh extends ActorBase {
|
|
|
58
54
|
this.add(this._mesh);
|
|
59
55
|
}
|
|
60
56
|
|
|
57
|
+
public override dispose(): void {
|
|
58
|
+
super.dispose();
|
|
59
|
+
this._geometry.dispose();
|
|
60
|
+
this._material.dispose();
|
|
61
|
+
}
|
|
62
|
+
|
|
61
63
|
public update(dt: number): void {
|
|
62
64
|
super.update(dt);
|
|
63
65
|
this._mesh.rotation.y += dt * TemplateMesh._MESH_ROTATION_Y;
|
package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateModel.ts
CHANGED
|
@@ -4,12 +4,8 @@ import DebugManager from '../../../../../managers/DebugManager';
|
|
|
4
4
|
import ModelBase from './bases/ModelBase';
|
|
5
5
|
|
|
6
6
|
export default class TemplateModel extends ModelBase {
|
|
7
|
-
//#region Constants
|
|
8
|
-
//
|
|
9
7
|
private static readonly _DEFAULT_POSITION: Vector3 = new Vector3(0, 1, 0);
|
|
10
8
|
private static readonly _ROTATION_Y = 0.25;
|
|
11
|
-
//
|
|
12
|
-
//#endregion
|
|
13
9
|
|
|
14
10
|
constructor() {
|
|
15
11
|
super(AssetId.THREE_GLTF_TEMPLATE, {
|
|
@@ -18,8 +14,8 @@ export default class TemplateModel extends ModelBase {
|
|
|
18
14
|
});
|
|
19
15
|
this.position.copy(TemplateModel._DEFAULT_POSITION);
|
|
20
16
|
|
|
21
|
-
if (DebugManager.
|
|
22
|
-
const templateModelFolder = DebugManager.
|
|
17
|
+
if (DebugManager.isActive) {
|
|
18
|
+
const templateModelFolder = DebugManager.gui.addFolder('Template Model');
|
|
23
19
|
templateModelFolder.add(this.position, 'y', -1, 1, 0.01);
|
|
24
20
|
}
|
|
25
21
|
}
|
package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ActorBase.ts
CHANGED
|
@@ -5,5 +5,17 @@ export default abstract class ActorBase extends Object3D {
|
|
|
5
5
|
super();
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
public
|
|
8
|
+
public init(): void {
|
|
9
|
+
this.reset();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public reset(): void {
|
|
13
|
+
//
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public dispose(): void {
|
|
17
|
+
//
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public update(_dt: number): void { }
|
|
9
21
|
}
|
|
@@ -2,27 +2,23 @@ import { AnimationAction, AnimationMixer } from 'three';
|
|
|
2
2
|
import type { AnimationId } from '../../../../../../constants/experiences/AnimationId';
|
|
3
3
|
import type { AssetId } from '../../../../../../constants/experiences/AssetId';
|
|
4
4
|
import ThreeAssetsManager from '../../../../../../managers/threes/ThreeAssetsManager';
|
|
5
|
-
import ModelBase, { type
|
|
5
|
+
import ModelBase, { type ModelBaseParams } from './ModelBase';
|
|
6
6
|
|
|
7
7
|
export default abstract class AnimatedModelBase extends ModelBase {
|
|
8
|
+
private static readonly _DEFAULT_ANIMATION_FADE_DURATION: number = 1;
|
|
9
|
+
|
|
8
10
|
declare private _mixer: AnimationMixer;
|
|
9
11
|
declare private _actions: AnimationAction[];
|
|
10
12
|
declare private _currentAction: AnimationAction | null;
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
private static readonly _DEFAULT_ANIMATION_FADE_DURATION: number = 1;
|
|
15
|
-
//
|
|
16
|
-
//#endregion
|
|
17
|
-
|
|
18
|
-
constructor(assetId: AssetId, params: IModelBaseParams = {}) {
|
|
14
|
+
constructor(assetId: AssetId, params: ModelBaseParams = {}) {
|
|
19
15
|
super(assetId, params);
|
|
20
16
|
|
|
21
17
|
this._generateAnimations();
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
protected _generateAnimations(): void {
|
|
25
|
-
const animations = ThreeAssetsManager.
|
|
21
|
+
const animations = ThreeAssetsManager.getModel(this._assetId).animations;
|
|
26
22
|
this._mixer = new AnimationMixer(this._model);
|
|
27
23
|
this._actions = [];
|
|
28
24
|
this._currentAction = null;
|
package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ModelBase.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Object3DId } from '../../../../../../constants/experiences/Object3
|
|
|
5
5
|
import ThreeAssetsManager from '../../../../../../managers/threes/ThreeAssetsManager';
|
|
6
6
|
import ActorBase from './ActorBase';
|
|
7
7
|
|
|
8
|
-
export interface
|
|
8
|
+
export interface ModelBaseParams {
|
|
9
9
|
object3DId?: Object3DId;
|
|
10
10
|
castShadow?: boolean;
|
|
11
11
|
receiveShadow?: boolean;
|
|
@@ -13,10 +13,10 @@ export interface IModelBaseParams {
|
|
|
13
13
|
|
|
14
14
|
export default abstract class ModelBase extends ActorBase {
|
|
15
15
|
protected _assetId: AssetId;
|
|
16
|
-
protected _parameters:
|
|
16
|
+
protected _parameters: ModelBaseParams;
|
|
17
17
|
declare protected _model: Group | Object3D | Mesh;
|
|
18
18
|
|
|
19
|
-
constructor(assetId: AssetId, params:
|
|
19
|
+
constructor(assetId: AssetId, params: ModelBaseParams = {}) {
|
|
20
20
|
super();
|
|
21
21
|
this._assetId = assetId;
|
|
22
22
|
this._parameters = params || {};
|
|
@@ -25,7 +25,7 @@ export default abstract class ModelBase extends ActorBase {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
protected _generateModel(): void {
|
|
28
|
-
const originalModel = ThreeAssetsManager.
|
|
28
|
+
const originalModel = ThreeAssetsManager.getModel(this._assetId).scene;
|
|
29
29
|
const model = SkeletonUtils.clone(originalModel);
|
|
30
30
|
|
|
31
31
|
this._model = this._parameters.object3DId
|
|
@@ -42,6 +42,20 @@ export default abstract class ModelBase extends ActorBase {
|
|
|
42
42
|
this.add(this._model);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
public override dispose(): void {
|
|
46
|
+
super.dispose();
|
|
47
|
+
this._model.traverse((child) => {
|
|
48
|
+
if (child instanceof Mesh) {
|
|
49
|
+
child.geometry.dispose();
|
|
50
|
+
if (Array.isArray(child.material)) {
|
|
51
|
+
child.material.forEach((material) => material.dispose());
|
|
52
|
+
} else {
|
|
53
|
+
child.material.dispose();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
45
59
|
public update(dt: number): void {
|
|
46
60
|
super.update(dt);
|
|
47
61
|
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Action } from '@benjos/cookware';
|
|
2
|
-
import { DomEvent } from '@benjos/spices';
|
|
3
|
-
|
|
4
|
-
export class KeyboardManager {
|
|
5
|
-
private static readonly _KeyDownsMap = new Map<string, boolean>();
|
|
6
|
-
private static readonly _CodeDownsMap = new Map<string, boolean>();
|
|
7
|
-
|
|
8
|
-
public static readonly OnKeyDown = new Action<[KeyboardEvent]>();
|
|
9
|
-
public static readonly OnKeyUp = new Action<[KeyboardEvent]>();
|
|
10
|
-
|
|
11
|
-
public static Init(): void {
|
|
12
|
-
KeyboardManager._KeyDownsMap.clear();
|
|
13
|
-
KeyboardManager._CodeDownsMap.clear();
|
|
14
|
-
KeyboardManager._AddCallbacks();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
private static _AddCallbacks(): void {
|
|
18
|
-
KeyboardManager._RemoveCallbacks();
|
|
19
|
-
window.addEventListener(DomEvent.KEY_DOWN, KeyboardManager._OnKeyDown);
|
|
20
|
-
window.addEventListener(DomEvent.KEY_UP, KeyboardManager._OnKeyUp);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private static _RemoveCallbacks(): void {
|
|
24
|
-
window.removeEventListener(DomEvent.KEY_DOWN, KeyboardManager._OnKeyDown);
|
|
25
|
-
window.removeEventListener(DomEvent.KEY_UP, KeyboardManager._OnKeyUp);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
private static readonly _OnKeyDown = (e: KeyboardEvent): void => {
|
|
29
|
-
KeyboardManager._KeyDownsMap.set(e.key, true);
|
|
30
|
-
KeyboardManager._CodeDownsMap.set(e.code, true);
|
|
31
|
-
KeyboardManager.OnKeyDown.execute(e);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
private static readonly _OnKeyUp = (e: KeyboardEvent): void => {
|
|
35
|
-
KeyboardManager.OnKeyUp.execute(e);
|
|
36
|
-
KeyboardManager._KeyDownsMap.set(e.key, false);
|
|
37
|
-
KeyboardManager._CodeDownsMap.set(e.code, false);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
public static IsKeyDown(name: string): boolean {
|
|
41
|
-
if (!KeyboardManager.IsAvailableForControl()) return false;
|
|
42
|
-
if (KeyboardManager._CodeDownsMap.get(name)) return true;
|
|
43
|
-
if (KeyboardManager._KeyDownsMap.get(name)) return true;
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public static IsAnyKeyDown(names: string[]): boolean {
|
|
48
|
-
if (!KeyboardManager.IsAvailableForControl()) return false;
|
|
49
|
-
return names.some((name) => KeyboardManager.IsKeyDown(name));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public static AreAllKeysDown(names: string[]): boolean {
|
|
53
|
-
if (!KeyboardManager.IsAvailableForControl()) return false;
|
|
54
|
-
return names.every((name) => KeyboardManager.IsKeyDown(name));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public static IsAvailableForControl(): boolean {
|
|
58
|
-
const active: HTMLElement = document.activeElement as HTMLElement;
|
|
59
|
-
return !(
|
|
60
|
-
active instanceof HTMLInputElement ||
|
|
61
|
-
active instanceof HTMLTextAreaElement ||
|
|
62
|
-
active?.isContentEditable
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { Action } from '@benjos/cookware';
|
|
2
|
-
import { DomEvent } from '@benjos/spices';
|
|
3
|
-
|
|
4
|
-
export default class MouseManager {
|
|
5
|
-
private static _X = 0;
|
|
6
|
-
private static _Y = 0;
|
|
7
|
-
private static _NormalizedX = 0;
|
|
8
|
-
private static _NormalizedY = 0;
|
|
9
|
-
private static _CentralX = 0;
|
|
10
|
-
private static _CentralY = 0;
|
|
11
|
-
|
|
12
|
-
public static readonly OnMouseDown = new Action();
|
|
13
|
-
public static readonly OnMouseUp = new Action();
|
|
14
|
-
public static readonly OnMouseMove = new Action();
|
|
15
|
-
|
|
16
|
-
public static Init(): void {
|
|
17
|
-
this._AddCallbacks();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private static _AddCallbacks(): void {
|
|
21
|
-
this._RemoveCallbacks();
|
|
22
|
-
window.addEventListener(DomEvent.TOUCH_START, this._OnMouseDown);
|
|
23
|
-
window.addEventListener(DomEvent.TOUCH_END, this._OnMouseUp);
|
|
24
|
-
window.addEventListener(DomEvent.TOUCH_MOVE, this._OnMouseMove);
|
|
25
|
-
window.addEventListener(DomEvent.MOUSE_DOWN, this._OnMouseDown);
|
|
26
|
-
window.addEventListener(DomEvent.MOUSE_UP, this._OnMouseUp);
|
|
27
|
-
window.addEventListener(DomEvent.MOUSE_MOVE, this._OnMouseMove);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
private static _RemoveCallbacks(): void {
|
|
31
|
-
window.removeEventListener(DomEvent.TOUCH_START, this._OnMouseDown);
|
|
32
|
-
window.removeEventListener(DomEvent.TOUCH_END, this._OnMouseUp);
|
|
33
|
-
window.removeEventListener(DomEvent.TOUCH_MOVE, this._OnMouseMove);
|
|
34
|
-
window.removeEventListener(DomEvent.MOUSE_DOWN, this._OnMouseDown);
|
|
35
|
-
window.removeEventListener(DomEvent.MOUSE_UP, this._OnMouseUp);
|
|
36
|
-
window.removeEventListener(DomEvent.MOUSE_MOVE, this._OnMouseMove);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private static readonly _OnMouseDown = (event: MouseEvent | TouchEvent): void => {
|
|
40
|
-
this._OnMouseMove(event);
|
|
41
|
-
this.OnMouseDown.execute();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
private static readonly _OnMouseUp = (_event: MouseEvent | TouchEvent): void => {
|
|
45
|
-
this.OnMouseUp.execute();
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
private static readonly _OnMouseMove = (event: MouseEvent | TouchEvent): void => {
|
|
49
|
-
this._UpdateMousePosition(event);
|
|
50
|
-
this.OnMouseMove.execute();
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
private static _UpdateMousePosition(event: Event): void {
|
|
54
|
-
const { x, y } = this._GetMousePosition(event);
|
|
55
|
-
this._X = x;
|
|
56
|
-
this._Y = y;
|
|
57
|
-
this._NormalizedX = this._X / window.innerWidth;
|
|
58
|
-
this._NormalizedY = 1 - this._Y / window.innerHeight;
|
|
59
|
-
this._CentralX = this._NormalizedX * 2 - 1;
|
|
60
|
-
this._CentralY = this._NormalizedY * 2 - 1;
|
|
61
|
-
this.OnMouseMove.execute();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private static _GetMousePosition(e: Event): { x: number; y: number } {
|
|
65
|
-
if (e instanceof MouseEvent) {
|
|
66
|
-
return { x: e.clientX, y: e.clientY };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (window.TouchEvent && e instanceof TouchEvent) {
|
|
70
|
-
if (e.touches.length > 0) {
|
|
71
|
-
return { x: e.touches[0].clientX, y: e.touches[0].clientY };
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return { x: 0, y: 0 };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
//#region Getters
|
|
79
|
-
//
|
|
80
|
-
public static get X(): number {
|
|
81
|
-
return this._X;
|
|
82
|
-
}
|
|
83
|
-
public static get Y(): number {
|
|
84
|
-
return this._Y;
|
|
85
|
-
}
|
|
86
|
-
public static get NormalizedX(): number {
|
|
87
|
-
return this._NormalizedX;
|
|
88
|
-
}
|
|
89
|
-
public static get NormalizedY(): number {
|
|
90
|
-
return this._NormalizedY;
|
|
91
|
-
}
|
|
92
|
-
public static get CentralX(): number {
|
|
93
|
-
return this._CentralX;
|
|
94
|
-
}
|
|
95
|
-
public static get CentralY(): number {
|
|
96
|
-
return this._CentralY;
|
|
97
|
-
}
|
|
98
|
-
//
|
|
99
|
-
//#endregion
|
|
100
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Action } from '@benjos/cookware';
|
|
2
|
-
import TickerManager from './TickerManager';
|
|
3
|
-
|
|
4
|
-
export class ResizeManager {
|
|
5
|
-
private static _Width: number;
|
|
6
|
-
private static _Height: number;
|
|
7
|
-
private static _PixelRatio: number;
|
|
8
|
-
|
|
9
|
-
public static readonly OnResize = new Action();
|
|
10
|
-
|
|
11
|
-
//#region Constants
|
|
12
|
-
//
|
|
13
|
-
private static readonly _MAX_PIXEL_RATIO: number = 2;
|
|
14
|
-
//
|
|
15
|
-
//#endregion
|
|
16
|
-
|
|
17
|
-
public static Init(): void {
|
|
18
|
-
ResizeManager.Reset();
|
|
19
|
-
ResizeManager._Resize();
|
|
20
|
-
TickerManager.Add(ResizeManager.Update);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public static Reset(): void {
|
|
24
|
-
TickerManager.Remove(ResizeManager.Update);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private static readonly _Resize = (): void => {
|
|
28
|
-
ResizeManager._Width = window.innerWidth;
|
|
29
|
-
ResizeManager._Height = window.innerHeight;
|
|
30
|
-
ResizeManager._PixelRatio = Math.min(window.devicePixelRatio, ResizeManager._MAX_PIXEL_RATIO);
|
|
31
|
-
|
|
32
|
-
ResizeManager.OnResize.execute();
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
public static readonly Update = (_dt: number): void => {
|
|
36
|
-
if (ResizeManager._Width !== window.innerWidth || ResizeManager._Height !== window.innerHeight)
|
|
37
|
-
ResizeManager._Resize();
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
//#region Getters
|
|
41
|
-
//
|
|
42
|
-
public static get Width(): number {
|
|
43
|
-
return ResizeManager._Width;
|
|
44
|
-
}
|
|
45
|
-
public static get Height(): number {
|
|
46
|
-
return ResizeManager._Height;
|
|
47
|
-
}
|
|
48
|
-
public static get PixelRatio(): number {
|
|
49
|
-
return ResizeManager._PixelRatio;
|
|
50
|
-
}
|
|
51
|
-
//
|
|
52
|
-
//#endregion
|
|
53
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
export type Tickable = (dt: number) => void;
|
|
2
|
-
|
|
3
|
-
export default class TickerManager {
|
|
4
|
-
private static _IsRunning = false;
|
|
5
|
-
private static readonly _Tickables = new Set<Tickable>();
|
|
6
|
-
private static _StartTime: number = performance.now();
|
|
7
|
-
private static _CurrentTime: number = TickerManager._StartTime;
|
|
8
|
-
private static _ElapsedTime: number;
|
|
9
|
-
private static _DeltaTime: number;
|
|
10
|
-
|
|
11
|
-
//#region Constants
|
|
12
|
-
//
|
|
13
|
-
private static readonly _TIME_SCALE: number = 0.001;
|
|
14
|
-
private static readonly _MAX_DELTA: number = 0.1;
|
|
15
|
-
//
|
|
16
|
-
//#endregion
|
|
17
|
-
|
|
18
|
-
public static Init(): void {
|
|
19
|
-
TickerManager.Start();
|
|
20
|
-
TickerManager._ElapsedTime = 0;
|
|
21
|
-
TickerManager._DeltaTime = 0.016;
|
|
22
|
-
TickerManager._Update();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public static Start(): void {
|
|
26
|
-
TickerManager.Stop();
|
|
27
|
-
TickerManager._IsRunning = true;
|
|
28
|
-
TickerManager._StartTime = performance.now();
|
|
29
|
-
TickerManager._CurrentTime = TickerManager._StartTime;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public static Stop(): void {
|
|
33
|
-
TickerManager._IsRunning = false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public static Play(): void {
|
|
37
|
-
TickerManager.Pause();
|
|
38
|
-
TickerManager._IsRunning = true;
|
|
39
|
-
TickerManager._CurrentTime = performance.now();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public static Pause(): void {
|
|
43
|
-
TickerManager._IsRunning = false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public static Add(tickable: Tickable): void {
|
|
47
|
-
TickerManager._Tickables.add(tickable);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public static Remove(tickable: Tickable): void {
|
|
51
|
-
TickerManager._Tickables.delete(tickable);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private static readonly _Update = (): void => {
|
|
55
|
-
if (TickerManager._IsRunning) {
|
|
56
|
-
const now = performance.now();
|
|
57
|
-
TickerManager._DeltaTime = Math.min(
|
|
58
|
-
(now - TickerManager._CurrentTime) * TickerManager._TIME_SCALE,
|
|
59
|
-
TickerManager._MAX_DELTA
|
|
60
|
-
);
|
|
61
|
-
TickerManager._ElapsedTime += TickerManager._DeltaTime;
|
|
62
|
-
TickerManager._CurrentTime = now;
|
|
63
|
-
|
|
64
|
-
for (const tickable of TickerManager._Tickables) tickable(TickerManager._DeltaTime);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
requestAnimationFrame(TickerManager._Update);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
//#region Getters
|
|
71
|
-
//
|
|
72
|
-
public static get StartTime(): number {
|
|
73
|
-
return this._StartTime;
|
|
74
|
-
}
|
|
75
|
-
public static get CurrentTime(): number {
|
|
76
|
-
return this._CurrentTime;
|
|
77
|
-
}
|
|
78
|
-
public static get ElapsedTime(): number {
|
|
79
|
-
return this._ElapsedTime;
|
|
80
|
-
}
|
|
81
|
-
public static get DeltaTime(): number {
|
|
82
|
-
return this._DeltaTime;
|
|
83
|
-
}
|
|
84
|
-
//
|
|
85
|
-
//#endregion
|
|
86
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { ViewId } from '../constants/experiences/ViewId';
|
|
2
|
-
import { ViewType } from '../constants/experiences/ViewType';
|
|
3
|
-
import type ViewBase from '../views/bases/ViewBase';
|
|
4
|
-
|
|
5
|
-
type ViewConstructor<T extends ViewBase> = new (id: ViewId) => T;
|
|
6
|
-
|
|
7
|
-
export default class ViewProxy {
|
|
8
|
-
private static _Views = new Map<ViewId, ViewBase>();
|
|
9
|
-
|
|
10
|
-
public static Init(): void {
|
|
11
|
-
//
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
public static Add(viewId: ViewId, ViewClass: ViewConstructor<ViewBase>): void {
|
|
15
|
-
if (ViewProxy._Views.has(viewId)) {
|
|
16
|
-
throw new Error(`ViewProxy: View with id "${viewId}" already exists.`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
ViewProxy._Views.set(viewId, new ViewClass(viewId));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
public static GetById<T extends ViewBase = ViewBase>(viewId: ViewId): T {
|
|
23
|
-
const view = ViewProxy._Views.get(viewId);
|
|
24
|
-
if (!view) throw new Error(`ViewProxy: View with id "${viewId}" not found.`);
|
|
25
|
-
return view as T;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public static Has(viewId: ViewId): boolean {
|
|
29
|
-
return ViewProxy._Views.has(viewId);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public static GetAll<T extends ViewBase>(type?: ViewType): T[] {
|
|
33
|
-
const views: T[] = [];
|
|
34
|
-
|
|
35
|
-
ViewProxy._Views.forEach((view) => {
|
|
36
|
-
if (type && type === view.type) {
|
|
37
|
-
views.push(view as T);
|
|
38
|
-
} else {
|
|
39
|
-
views.push(view as T);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
return views;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { ViewId } from '../../constants/experiences/ViewId';
|
|
2
|
-
import type { ViewType } from '../../constants/experiences/ViewType';
|
|
3
|
-
|
|
4
|
-
export default class ViewBase {
|
|
5
|
-
private readonly _id: ViewId;
|
|
6
|
-
private readonly _type: ViewType;
|
|
7
|
-
protected _isVisible: boolean;
|
|
8
|
-
|
|
9
|
-
constructor(id: ViewId, type: ViewType) {
|
|
10
|
-
this._id = id;
|
|
11
|
-
this._type = type;
|
|
12
|
-
this._isVisible = false;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
protected _show(): void {
|
|
16
|
-
this._isVisible = true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
protected _hide(): void {
|
|
20
|
-
this._isVisible = false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
//#region Getters
|
|
24
|
-
//
|
|
25
|
-
public get id(): ViewId {
|
|
26
|
-
return this._id;
|
|
27
|
-
}
|
|
28
|
-
public get type(): ViewType {
|
|
29
|
-
return this._type;
|
|
30
|
-
}
|
|
31
|
-
public get isVisible(): boolean {
|
|
32
|
-
return this._isVisible;
|
|
33
|
-
}
|
|
34
|
-
//
|
|
35
|
-
//#endregion
|
|
36
|
-
}
|
package/template-vanilla/src/experiences/views/htmls/loaders/components/HTMLTemplateLoader.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import LoaderManager from '../../../../managers/LoaderManager';
|
|
2
|
-
|
|
3
|
-
export default class HTMLTemplateLoader {
|
|
4
|
-
declare private _htmlElement: HTMLDivElement;
|
|
5
|
-
declare private _loadingBar: HTMLDivElement;
|
|
6
|
-
declare private _loadingProgress: HTMLDivElement;
|
|
7
|
-
declare private _loadingNumber: HTMLSpanElement;
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
this._generateElement();
|
|
11
|
-
|
|
12
|
-
LoaderManager.OnProgress.add(this._onProgress);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
private _generateElement(): void {
|
|
16
|
-
const wrapper = document.createElement('div');
|
|
17
|
-
wrapper.innerHTML = `
|
|
18
|
-
<div id="loading-screen" class="loading-screen">
|
|
19
|
-
<div class="loading-progress">
|
|
20
|
-
<span class="loading-number">0</span><span>%</span>
|
|
21
|
-
</div>
|
|
22
|
-
<div class="loading-bar"></div>
|
|
23
|
-
</div>
|
|
24
|
-
`.trim();
|
|
25
|
-
|
|
26
|
-
this._htmlElement = wrapper.querySelector('#loading-screen')!;
|
|
27
|
-
this._loadingProgress = this._htmlElement.querySelector('.loading-progress')!;
|
|
28
|
-
this._loadingNumber = this._loadingProgress.querySelector('.loading-number')!;
|
|
29
|
-
this._loadingBar = this._htmlElement.querySelector('.loading-bar')!;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private readonly _onProgress = (): void => {
|
|
33
|
-
const progress = (LoaderManager.LoadedSize / LoaderManager.TotalSize) * 100;
|
|
34
|
-
this._loadingBar.style.transform = `translateY(-50%) scaleX(${progress / 100})`;
|
|
35
|
-
this._loadingNumber.textContent = Math.round(progress).toString();
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
public show(): void {
|
|
39
|
-
this._loadingNumber.textContent = '0';
|
|
40
|
-
this._loadingBar.style.transform = '';
|
|
41
|
-
this._loadingBar.classList.remove('ended');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public hide(): void {
|
|
45
|
-
this._loadingNumber.textContent = '100';
|
|
46
|
-
this._loadingBar.style.transform = '';
|
|
47
|
-
this._loadingBar.classList.add('ended');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
//#region
|
|
51
|
-
//
|
|
52
|
-
public get htmlElement(): HTMLDivElement {
|
|
53
|
-
return this._htmlElement;
|
|
54
|
-
}
|
|
55
|
-
//
|
|
56
|
-
//#endregion
|
|
57
|
-
}
|
/package/template-vanilla/src/experiences/{constants/experiences/AssetType.ts → types/assetTypes.ts}
RENAMED
|
File without changes
|