@benjos/create-boilerplate 1.4.1 → 1.5.0
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/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/template-react/package-lock.json +3 -18
- package/template-react/package.json +1 -1
- package/template-vanilla/eslint.config.js +5 -11
- package/template-vanilla/index.html +18 -20
- package/template-vanilla/package-lock.json +3 -13
- package/template-vanilla/package.json +1 -1
- package/template-vanilla/src/experiences/Experience.ts +10 -3
- package/template-vanilla/src/experiences/commands/InitCommand.ts +4 -4
- package/template-vanilla/src/experiences/constants/experiences/DebugGuiTitle.ts +6 -0
- package/template-vanilla/src/experiences/constants/experiences/ViewId.ts +2 -1
- package/template-vanilla/src/experiences/engines/threes/MainThree.ts +2 -2
- package/template-vanilla/src/experiences/engines/threes/app/LoaderThreeApp.ts +13 -3
- package/template-vanilla/src/experiences/engines/threes/app/MainThreeApp.ts +18 -5
- package/template-vanilla/src/experiences/engines/threes/app/bases/ThreeAppBase.ts +43 -7
- package/template-vanilla/src/experiences/managers/DebugManager.ts +11 -0
- package/template-vanilla/src/experiences/managers/LoaderManager.ts +97 -7
- package/template-vanilla/src/experiences/materials/threes/loaders/LoaderMaterial.ts +4 -4
- package/template-vanilla/src/experiences/renderers/threes/LoaderRenderer.ts +2 -2
- package/template-vanilla/src/experiences/renderers/threes/Renderer.ts +2 -1
- package/template-vanilla/src/experiences/shaders/threes/loaders/LoaderFragmentShader.glsl +2 -0
- package/template-vanilla/src/experiences/styles/commons/main.scss +5 -30
- package/template-vanilla/src/experiences/styles/style.scss +1 -1
- package/template-vanilla/src/experiences/styles/views/loader.scss +1 -4
- package/template-vanilla/src/experiences/types/global.d.ts +1 -2
- package/template-vanilla/src/experiences/views/htmls/bases/HTMLViewBase.ts +0 -3
- package/template-vanilla/src/experiences/views/htmls/loaders/LoaderHTMLView.ts +7 -8
- package/template-vanilla/src/experiences/views/threes/bases/ThreeViewBase.ts +20 -6
- package/template-vanilla/src/experiences/views/threes/loaders/LoaderThreeView.ts +9 -19
- package/template-vanilla/src/experiences/views/threes/loaders/components/{ThreeTemplateLoader.ts → TemplateLoaderThreeActor.ts} +6 -12
- package/template-vanilla/src/experiences/views/threes/worlds/World2ThreeView.ts +35 -0
- package/template-vanilla/src/experiences/views/threes/worlds/WorldThreeView.ts +12 -20
- package/template-vanilla/src/experiences/views/threes/worlds/components/Environment.ts +20 -4
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateFont.ts +2 -8
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateMesh.ts +4 -6
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateMesh2.ts +71 -0
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateModel.ts +9 -3
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ThreeActorBase.ts +44 -0
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/{AnimatedModelBase.ts → ThreeAnimatedModelBase.ts} +3 -3
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/{ModelBase.ts → ThreeModelBase.ts} +2 -16
- package/template-vanilla/tsconfig.json +3 -8
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ActorBase.ts +0 -21
|
@@ -2,6 +2,7 @@ import { DomKeyboardManager } from '@benjos/cookware';
|
|
|
2
2
|
import { KeyboardConstant } from '@benjos/spices';
|
|
3
3
|
import GUI from 'lil-gui';
|
|
4
4
|
import { ThreePerf } from 'three-perf';
|
|
5
|
+
import { DebugGuiTitle } from '../constants/experiences/DebugGuiTitle';
|
|
5
6
|
import MainThreeApp from '../engines/threes/app/MainThreeApp';
|
|
6
7
|
|
|
7
8
|
class DebugManager {
|
|
@@ -45,6 +46,16 @@ class DebugManager {
|
|
|
45
46
|
});
|
|
46
47
|
};
|
|
47
48
|
|
|
49
|
+
private _addGuiFolder(title: DebugGuiTitle): GUI {
|
|
50
|
+
return this._gui.addFolder(title);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public getGuiFolder(title: DebugGuiTitle): GUI {
|
|
54
|
+
let gui = this._gui.folders.find(gui => gui._title === title);
|
|
55
|
+
if (!gui) gui = this._addGuiFolder(title);
|
|
56
|
+
return gui;
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
public beginThreePerf(): void {
|
|
49
60
|
if (!this._threePerf) this._initThreePerf();
|
|
50
61
|
this._threePerf.begin();
|
|
@@ -1,27 +1,47 @@
|
|
|
1
|
-
import { Action } from '@benjos/cookware';
|
|
1
|
+
import { Action, TickerManager } from '@benjos/cookware';
|
|
2
2
|
import ThreeAssetsManager from './threes/ThreeAssetsManager';
|
|
3
3
|
|
|
4
4
|
class LoaderManager {
|
|
5
|
+
private static readonly _MIN_LOAD_DURATION: number = 0.5;
|
|
6
|
+
|
|
5
7
|
private _totalSize = 0;
|
|
6
8
|
private _loadedSize = 0;
|
|
9
|
+
private _progress = 0;
|
|
10
|
+
private _isTransitioning = false;
|
|
11
|
+
private _elapsed = 0;
|
|
12
|
+
private _hasAssetsToLoad = false;
|
|
13
|
+
private _assetsFinished = false;
|
|
14
|
+
private _transitionResolve: (() => void) | null = null;
|
|
15
|
+
private _showTransition: (() => Promise<void>) | null = null;
|
|
16
|
+
private _hideTransition: (() => Promise<void>) | null = null;
|
|
7
17
|
|
|
8
18
|
public readonly onBeginLoad = new Action();
|
|
9
19
|
public readonly onProgress = new Action();
|
|
10
20
|
public readonly onFinishLoad = new Action();
|
|
21
|
+
public readonly onShow = new Action();
|
|
22
|
+
public readonly onHide = new Action();
|
|
11
23
|
|
|
12
24
|
public init(): void {
|
|
13
25
|
this._addCallbacks();
|
|
14
26
|
}
|
|
15
27
|
|
|
28
|
+
public setShowTransition(callback: () => Promise<void>): void {
|
|
29
|
+
this._showTransition = callback;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public setHideTransition(callback: () => Promise<void>): void {
|
|
33
|
+
this._hideTransition = callback;
|
|
34
|
+
}
|
|
35
|
+
|
|
16
36
|
private _addCallbacks(): void {
|
|
17
37
|
this._removeCallbacks();
|
|
18
38
|
ThreeAssetsManager.onLoad.add(this._onLoad);
|
|
19
|
-
ThreeAssetsManager.onProgress.add(this.
|
|
39
|
+
ThreeAssetsManager.onProgress.add(this._onAssetProgress);
|
|
20
40
|
}
|
|
21
41
|
|
|
22
42
|
private _removeCallbacks(): void {
|
|
23
43
|
ThreeAssetsManager.onLoad.remove(this._onLoad);
|
|
24
|
-
ThreeAssetsManager.onProgress.remove(this.
|
|
44
|
+
ThreeAssetsManager.onProgress.remove(this._onAssetProgress);
|
|
25
45
|
}
|
|
26
46
|
|
|
27
47
|
private _beginLoad = (): void => {
|
|
@@ -34,9 +54,75 @@ class LoaderManager {
|
|
|
34
54
|
this.onFinishLoad.execute();
|
|
35
55
|
};
|
|
36
56
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.
|
|
57
|
+
private async _showLoader(): Promise<void> {
|
|
58
|
+
this.onShow.execute();
|
|
59
|
+
if (this._showTransition) await this._showTransition();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private async _hideLoader(): Promise<void> {
|
|
63
|
+
this.onHide.execute();
|
|
64
|
+
if (this._hideTransition) await this._hideTransition();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private readonly _onAssetsFinish = (): void => {
|
|
68
|
+
this._assetsFinished = true;
|
|
69
|
+
this.onFinishLoad.remove(this._onAssetsFinish);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
private readonly _onTransitionTick = (dt: number): void => {
|
|
73
|
+
this._elapsed += dt;
|
|
74
|
+
const timerProgress = Math.min(this._elapsed / LoaderManager._MIN_LOAD_DURATION, 1);
|
|
75
|
+
|
|
76
|
+
let assetProgress = 1;
|
|
77
|
+
if (this._hasAssetsToLoad && !this._assetsFinished) {
|
|
78
|
+
assetProgress = this._totalSize > 0 ? Math.min(this._loadedSize / this._totalSize, 1) : 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this._progress = Math.min(timerProgress, assetProgress);
|
|
82
|
+
this.onProgress.execute();
|
|
83
|
+
|
|
84
|
+
if (timerProgress >= 1 && this._assetsFinished) {
|
|
85
|
+
this._progress = 1;
|
|
86
|
+
this.onProgress.execute();
|
|
87
|
+
TickerManager.remove(this._onTransitionTick);
|
|
88
|
+
if (this._transitionResolve) this._transitionResolve();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
public async loadAssetsWithTransition(onReady?: () => void | Promise<void>): Promise<void> {
|
|
93
|
+
const isNested = this._isTransitioning;
|
|
94
|
+
if (!isNested) {
|
|
95
|
+
this._isTransitioning = true;
|
|
96
|
+
await this._showLoader();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
this._hasAssetsToLoad = !this._checkIsFinished();
|
|
100
|
+
|
|
101
|
+
if (this._hasAssetsToLoad || !isNested) {
|
|
102
|
+
this._progress = 0;
|
|
103
|
+
this._elapsed = 0;
|
|
104
|
+
this._assetsFinished = !this._hasAssetsToLoad;
|
|
105
|
+
this.onProgress.execute();
|
|
106
|
+
|
|
107
|
+
if (this._hasAssetsToLoad) {
|
|
108
|
+
this.onFinishLoad.add(this._onAssetsFinish);
|
|
109
|
+
this._beginLoad();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
await new Promise<void>((resolve) => {
|
|
113
|
+
this._transitionResolve = resolve;
|
|
114
|
+
TickerManager.add(this._onTransitionTick);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
this._transitionResolve = null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (onReady) await onReady();
|
|
121
|
+
|
|
122
|
+
if (!isNested) {
|
|
123
|
+
this._isTransitioning = false;
|
|
124
|
+
await this._hideLoader();
|
|
125
|
+
}
|
|
40
126
|
}
|
|
41
127
|
|
|
42
128
|
private _onLoad = (): void => {
|
|
@@ -49,8 +135,9 @@ class LoaderManager {
|
|
|
49
135
|
return true;
|
|
50
136
|
};
|
|
51
137
|
|
|
52
|
-
private
|
|
138
|
+
private _onAssetProgress = (): void => {
|
|
53
139
|
this._refreshSizes();
|
|
140
|
+
this._progress = this._totalSize > 0 ? Math.min(this._loadedSize / this._totalSize, 1) : 0;
|
|
54
141
|
this.onProgress.execute();
|
|
55
142
|
};
|
|
56
143
|
|
|
@@ -74,6 +161,9 @@ class LoaderManager {
|
|
|
74
161
|
public get isLoaded(): boolean {
|
|
75
162
|
return this._checkIsFinished();
|
|
76
163
|
}
|
|
164
|
+
public get progress(): number {
|
|
165
|
+
return this._progress;
|
|
166
|
+
}
|
|
77
167
|
public get totalSize(): number {
|
|
78
168
|
return this._totalSize;
|
|
79
169
|
}
|
|
@@ -23,19 +23,19 @@ export default class LoaderMaterial extends ShaderMaterial {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
public show(): void {
|
|
26
|
+
public async show(): Promise<void> {
|
|
27
27
|
gsap.killTweensOf(this.uniforms.uAlpha);
|
|
28
|
-
gsap.to(this.uniforms.uAlpha, {
|
|
28
|
+
await gsap.to(this.uniforms.uAlpha, {
|
|
29
29
|
value: 1,
|
|
30
30
|
duration: LoaderMaterial._GSAP_DURATION_FADE_IN,
|
|
31
31
|
ease: LoaderMaterial._GSAP_EASE_FADE_IN,
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
public hide(): void {
|
|
35
|
+
public async hide(): Promise<void> {
|
|
36
36
|
gsap.killTweensOf(this.uniforms.uAlpha);
|
|
37
37
|
this.uniforms.uAlpha.value = 1;
|
|
38
|
-
gsap.to(this.uniforms.uAlpha, {
|
|
38
|
+
await gsap.to(this.uniforms.uAlpha, {
|
|
39
39
|
value: 0,
|
|
40
40
|
duration: LoaderMaterial._GSAP_DURATION_FADE_OUT,
|
|
41
41
|
ease: LoaderMaterial._GSAP_EASE_FADE_OUT,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Camera,
|
|
1
|
+
import { Camera, NoToneMapping, Scene, SRGBColorSpace, type WebGLRendererParameters } from 'three';
|
|
2
2
|
import WebGLRendererBase from './bases/WebGLRendererBase';
|
|
3
3
|
|
|
4
4
|
export default class LoaderRenderer extends WebGLRendererBase {
|
|
5
5
|
private static readonly _DEFAULT_TONE_MAPPING = NoToneMapping;
|
|
6
|
-
private static readonly _DEFAULT_OUTPUT_COLOR_SPACE =
|
|
6
|
+
private static readonly _DEFAULT_OUTPUT_COLOR_SPACE = SRGBColorSpace;
|
|
7
7
|
private static readonly _DEFAULT_TONE_MAPPING_EXPOSURE = 1;
|
|
8
8
|
private static readonly _DEFAULT_CLEAR_COLOR = 0x000000;
|
|
9
9
|
private static readonly _DEFAULT_CLEAR_ALPHA = 0;
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
type ToneMapping,
|
|
17
17
|
type WebGLRendererParameters,
|
|
18
18
|
} from 'three';
|
|
19
|
+
import { DebugGuiTitle } from '../../constants/experiences/DebugGuiTitle';
|
|
19
20
|
import DebugManager from '../../managers/DebugManager';
|
|
20
21
|
import WebGLRendererBase from './bases/WebGLRendererBase';
|
|
21
22
|
|
|
@@ -37,7 +38,7 @@ export default class Renderer extends WebGLRendererBase {
|
|
|
37
38
|
this.setClearColor(Renderer._DEFAULT_CLEAR_COLOR, Renderer._DEFAULT_CLEAR_ALPHA);
|
|
38
39
|
|
|
39
40
|
if (DebugManager.isActive) {
|
|
40
|
-
const rendererFolder = DebugManager.
|
|
41
|
+
const rendererFolder = DebugManager.getGuiFolder(DebugGuiTitle.THREE_RENDERER)
|
|
41
42
|
rendererFolder
|
|
42
43
|
.add(this, 'toneMapping', {
|
|
43
44
|
NoToneMapping,
|
|
@@ -16,13 +16,13 @@ body {
|
|
|
16
16
|
padding: 0;
|
|
17
17
|
overflow: hidden;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
> #app,
|
|
20
|
+
> #root {
|
|
21
21
|
position: relative;
|
|
22
22
|
width: 100%;
|
|
23
23
|
height: 100%;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
> #loader {
|
|
26
26
|
position: absolute;
|
|
27
27
|
top: 0;
|
|
28
28
|
left: 0;
|
|
@@ -44,35 +44,10 @@ body {
|
|
|
44
44
|
width: 100%;
|
|
45
45
|
height: 100%;
|
|
46
46
|
opacity: 0;
|
|
47
|
+
transition: opacity $viewTransition ease;
|
|
47
48
|
|
|
48
49
|
&.show {
|
|
49
|
-
opacity: 0;
|
|
50
|
-
animation: showView $viewTransition ease forwards;
|
|
51
|
-
|
|
52
|
-
@keyframes showView {
|
|
53
|
-
0% {
|
|
54
|
-
opacity: 0;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
100% {
|
|
58
|
-
opacity: 1;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&.hidden {
|
|
64
50
|
opacity: 1;
|
|
65
|
-
animation: hideView $viewTransition ease forwards;
|
|
66
|
-
|
|
67
|
-
@keyframes hideView {
|
|
68
|
-
0% {
|
|
69
|
-
opacity: 1;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
100% {
|
|
73
|
-
opacity: 0;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
51
|
}
|
|
77
52
|
}
|
|
78
53
|
}
|
|
@@ -81,4 +56,4 @@ body {
|
|
|
81
56
|
#three-perf-ui {
|
|
82
57
|
z-index: 999999;
|
|
83
58
|
}
|
|
84
|
-
}
|
|
59
|
+
}
|
|
@@ -8,9 +8,7 @@ body {
|
|
|
8
8
|
>#root {
|
|
9
9
|
>#loader {
|
|
10
10
|
.html-view {
|
|
11
|
-
|
|
12
|
-
animation-duration: $outroFadeOutDuration;
|
|
13
|
-
}
|
|
11
|
+
transition: opacity $outroFadeOutDuration ease;
|
|
14
12
|
}
|
|
15
13
|
}
|
|
16
14
|
}
|
|
@@ -39,7 +37,6 @@ body {
|
|
|
39
37
|
display: flex;
|
|
40
38
|
align-items: center;
|
|
41
39
|
gap: 0.25rem;
|
|
42
|
-
color: $white;
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
.loading-bar {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
export default abstract class HTMLViewBase {
|
|
3
2
|
declare protected _htmlElement: HTMLDivElement;
|
|
4
3
|
|
|
@@ -12,11 +11,9 @@ export default abstract class HTMLViewBase {
|
|
|
12
11
|
|
|
13
12
|
public show(): void {
|
|
14
13
|
this._htmlElement.classList.add('show');
|
|
15
|
-
this._htmlElement.classList.remove('hidden');
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
public hide(): void {
|
|
19
|
-
this._htmlElement.classList.add('hidden');
|
|
20
17
|
this._htmlElement.classList.remove('show');
|
|
21
18
|
}
|
|
22
19
|
}
|
|
@@ -9,9 +9,9 @@ export default class LoaderHTMLView extends HTMLViewBase {
|
|
|
9
9
|
|
|
10
10
|
constructor() {
|
|
11
11
|
super();
|
|
12
|
-
LoaderManager.onBeginLoad.add(this._onBeginLoad);
|
|
13
12
|
LoaderManager.onProgress.add(this._onProgress);
|
|
14
|
-
LoaderManager.
|
|
13
|
+
LoaderManager.onShow.add(this._onShow);
|
|
14
|
+
LoaderManager.onHide.add(this._onHide);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
protected override _getElement(): void {
|
|
@@ -21,20 +21,19 @@ export default class LoaderHTMLView extends HTMLViewBase {
|
|
|
21
21
|
this._loadingBar = this._htmlElement.querySelector('.loading-bar')!;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
private readonly
|
|
24
|
+
private readonly _onShow = (): void => {
|
|
25
25
|
this._loadingNumber.textContent = '0';
|
|
26
26
|
this._loadingBar.style.transform = '';
|
|
27
27
|
this._loadingBar.classList.remove('ended');
|
|
28
28
|
this.show();
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this._loadingBar.style.transform = `translateY(-50%) scaleX(${progress / 100})`;
|
|
30
|
+
private readonly _onProgress = (): void => {
|
|
31
|
+
const progress = LoaderManager.progress * 100;
|
|
32
|
+
this._loadingBar.style.transform = `translateY(-50%) scaleX(${LoaderManager.progress})`;
|
|
34
33
|
this._loadingNumber.textContent = Math.round(progress).toString();
|
|
35
34
|
};
|
|
36
35
|
|
|
37
|
-
private readonly
|
|
36
|
+
private readonly _onHide = (): void => {
|
|
38
37
|
this._loadingNumber.textContent = '100';
|
|
39
38
|
this._loadingBar.style.transform = '';
|
|
40
39
|
this._loadingBar.classList.add('ended');
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
|
-
import
|
|
2
|
+
import { ViewId } from '../../../constants/experiences/ViewId';
|
|
3
|
+
import ThreeActorBase from '../worlds/components/actors/bases/ThreeActorBase';
|
|
3
4
|
|
|
4
5
|
export default abstract class ThreeViewBase extends Object3D {
|
|
5
|
-
|
|
6
|
+
private readonly _id: ViewId;
|
|
7
|
+
protected readonly _actors: ThreeActorBase[];
|
|
8
|
+
private _areActorsGenerated = false;
|
|
6
9
|
|
|
7
|
-
constructor() {
|
|
10
|
+
constructor(id: ViewId) {
|
|
8
11
|
super();
|
|
9
|
-
|
|
12
|
+
this._id = id;
|
|
10
13
|
this._actors = [];
|
|
11
14
|
}
|
|
12
15
|
|
|
16
|
+
public declareAssets(): void {
|
|
17
|
+
//
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
public init(): void {
|
|
21
|
+
if (!this._areActorsGenerated) this._generateActors();
|
|
14
22
|
this.reset();
|
|
15
23
|
for (const actor of this._actors) actor.init();
|
|
16
24
|
}
|
|
@@ -20,7 +28,7 @@ export default abstract class ThreeViewBase extends Object3D {
|
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
protected _generateActors(): void {
|
|
23
|
-
|
|
31
|
+
this._areActorsGenerated = true;
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
public dispose(): void {
|
|
@@ -29,7 +37,13 @@ export default abstract class ThreeViewBase extends Object3D {
|
|
|
29
37
|
}
|
|
30
38
|
}
|
|
31
39
|
|
|
32
|
-
public update(
|
|
40
|
+
public update(_dt: number): void {
|
|
33
41
|
//
|
|
34
42
|
}
|
|
43
|
+
|
|
44
|
+
//#region Getters
|
|
45
|
+
//
|
|
46
|
+
public get viewId(): ViewId { return this._id; }
|
|
47
|
+
//
|
|
48
|
+
//#endregion
|
|
35
49
|
}
|
|
@@ -1,38 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ViewId } from '../../../constants/experiences/ViewId';
|
|
2
2
|
import ThreeViewBase from '../bases/ThreeViewBase';
|
|
3
|
-
import
|
|
3
|
+
import TemplateLoaderThreeActor from './components/TemplateLoaderThreeActor';
|
|
4
4
|
|
|
5
5
|
export default class LoaderThreeView extends ThreeViewBase {
|
|
6
|
-
declare private _threeLoader:
|
|
6
|
+
declare private _threeLoader: TemplateLoaderThreeActor;
|
|
7
7
|
|
|
8
8
|
constructor() {
|
|
9
|
-
super();
|
|
9
|
+
super(ViewId.THREE_LOADER);
|
|
10
10
|
this._generateActors();
|
|
11
|
-
LoaderManager.onBeginLoad.add(this._onBeginLoad);
|
|
12
|
-
LoaderManager.onFinishLoad.add(this._onFinishLoad);
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
protected override _generateActors(): void {
|
|
16
14
|
super._generateActors();
|
|
17
|
-
this._threeLoader = new
|
|
15
|
+
this._threeLoader = new TemplateLoaderThreeActor();
|
|
18
16
|
this._actors.push(this._threeLoader);
|
|
19
17
|
|
|
20
18
|
for (const actor of this._actors) this.add(actor);
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
this._threeLoader.material.show();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
protected _hide(): void {
|
|
28
|
-
this._threeLoader.material.hide();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
private readonly _onBeginLoad = (): void => {
|
|
32
|
-
this._show();
|
|
21
|
+
public readonly show = (): Promise<void> => {
|
|
22
|
+
return this._threeLoader.material.show();
|
|
33
23
|
};
|
|
34
24
|
|
|
35
|
-
|
|
36
|
-
this.
|
|
25
|
+
public readonly hide = (): Promise<void> => {
|
|
26
|
+
return this._threeLoader.material.hide();
|
|
37
27
|
};
|
|
38
28
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Mesh, PlaneGeometry } from 'three';
|
|
2
2
|
import LoaderMaterial from '../../../../materials/threes/loaders/LoaderMaterial';
|
|
3
|
-
import
|
|
3
|
+
import ThreeActorBase from '../../worlds/components/actors/bases/ThreeActorBase';
|
|
4
4
|
|
|
5
|
-
export default class
|
|
5
|
+
export default class TemplateLoaderThreeActor extends ThreeActorBase {
|
|
6
6
|
private static readonly _DEFAULT_SIZE_WIDTH: number = 2;
|
|
7
7
|
private static readonly _DEFAULT_SIZE_HEIGHT: number = 2;
|
|
8
8
|
private static readonly _DEFAULT_SEGMENTS_WIDTH: number = 1;
|
|
@@ -24,10 +24,10 @@ export default class ThreeTemplateLoader extends ActorBase {
|
|
|
24
24
|
|
|
25
25
|
private _generateGeometry(): void {
|
|
26
26
|
this._geometry = new PlaneGeometry(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
TemplateLoaderThreeActor._DEFAULT_SIZE_WIDTH,
|
|
28
|
+
TemplateLoaderThreeActor._DEFAULT_SIZE_HEIGHT,
|
|
29
|
+
TemplateLoaderThreeActor._DEFAULT_SEGMENTS_WIDTH,
|
|
30
|
+
TemplateLoaderThreeActor._DEFAULT_SEGMENTS_HEIGHT
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -39,12 +39,6 @@ export default class ThreeTemplateLoader extends ActorBase {
|
|
|
39
39
|
this._mesh = new Mesh(this._geometry, this._material);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
public override dispose(): void {
|
|
43
|
-
super.dispose();
|
|
44
|
-
this._geometry.dispose();
|
|
45
|
-
this._material.dispose();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
42
|
//#region Getters
|
|
49
43
|
//
|
|
50
44
|
public get material(): LoaderMaterial {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DebugGuiTitle } from '../../../constants/experiences/DebugGuiTitle';
|
|
2
|
+
import { ViewId } from '../../../constants/experiences/ViewId';
|
|
3
|
+
import MainThreeApp from '../../../engines/threes/app/MainThreeApp';
|
|
4
|
+
import DebugManager from '../../../managers/DebugManager';
|
|
5
|
+
import ThreeViewBase from '../bases/ThreeViewBase';
|
|
6
|
+
import Environment from './components/Environment';
|
|
7
|
+
import TemplateFont from './components/actors/TemplateFont';
|
|
8
|
+
import TemplateMesh2 from './components/actors/TemplateMesh2';
|
|
9
|
+
import TemplateModel from './components/actors/TemplateModel';
|
|
10
|
+
|
|
11
|
+
export default class World2ThreeView extends ThreeViewBase {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(ViewId.THREE_VIEW_WORLD_2);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
protected override _generateActors(): void {
|
|
17
|
+
super._generateActors();
|
|
18
|
+
|
|
19
|
+
if (DebugManager.isActive) {
|
|
20
|
+
const viewsDebug = DebugManager.getGuiFolder(DebugGuiTitle.THREE_VIEWS)
|
|
21
|
+
viewsDebug.add({ switchToWorld2ThreeView: () => MainThreeApp.setCurrentView(ViewId.THREE_VIEW_WORLD_2) }, 'switchToWorld2ThreeView').name('SWITCH WORLD_2_VIEW');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this._actors.push(new Environment());
|
|
25
|
+
this._actors.push(new TemplateMesh2());
|
|
26
|
+
this._actors.push(new TemplateModel());
|
|
27
|
+
this._actors.push(new TemplateFont());
|
|
28
|
+
|
|
29
|
+
for (const actor of this._actors) this.add(actor);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public override update(dt: number): void {
|
|
33
|
+
for (const actor of this._actors) actor.update(dt);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DebugGuiTitle } from '../../../constants/experiences/DebugGuiTitle';
|
|
2
|
+
import { ViewId } from '../../../constants/experiences/ViewId';
|
|
3
|
+
import MainThreeApp from '../../../engines/threes/app/MainThreeApp';
|
|
4
|
+
import DebugManager from '../../../managers/DebugManager';
|
|
2
5
|
import ThreeViewBase from '../bases/ThreeViewBase';
|
|
3
6
|
import Environment from './components/Environment';
|
|
4
7
|
import TemplateFont from './components/actors/TemplateFont';
|
|
@@ -6,27 +9,19 @@ import TemplateMesh from './components/actors/TemplateMesh';
|
|
|
6
9
|
import TemplateModel from './components/actors/TemplateModel';
|
|
7
10
|
|
|
8
11
|
export default class WorldThreeView extends ThreeViewBase {
|
|
9
|
-
declare private _environment: Environment;
|
|
10
|
-
|
|
11
12
|
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
LoaderManager.onFinishLoad.add(this._onFinishLoad);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
private readonly _onFinishLoad = (): void => {
|
|
17
|
-
this._generateEnvironment();
|
|
18
|
-
this._generateActors();
|
|
19
|
-
LoaderManager.onFinishLoad.remove(this._onFinishLoad);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
private _generateEnvironment(): void {
|
|
23
|
-
this._environment = new Environment();
|
|
24
|
-
|
|
25
|
-
this.add(this._environment);
|
|
13
|
+
super(ViewId.THREE_VIEW_WORLD_1);
|
|
26
14
|
}
|
|
27
15
|
|
|
28
16
|
protected override _generateActors(): void {
|
|
29
17
|
super._generateActors();
|
|
18
|
+
|
|
19
|
+
if (DebugManager.isActive) {
|
|
20
|
+
const viewsDebug = DebugManager.getGuiFolder(DebugGuiTitle.THREE_VIEWS)
|
|
21
|
+
viewsDebug.add({ switchToWorldThreeView: () => MainThreeApp.setCurrentView(ViewId.THREE_VIEW_WORLD_1) }, 'switchToWorldThreeView').name('SWITCH WORLD_1_VIEW');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this._actors.push(new Environment());
|
|
30
25
|
this._actors.push(new TemplateMesh());
|
|
31
26
|
this._actors.push(new TemplateModel());
|
|
32
27
|
this._actors.push(new TemplateFont());
|
|
@@ -35,9 +30,6 @@ export default class WorldThreeView extends ThreeViewBase {
|
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
public override update(dt: number): void {
|
|
38
|
-
if (!this._environment) return;
|
|
39
|
-
|
|
40
|
-
this._environment.update(dt);
|
|
41
33
|
for (const actor of this._actors) actor.update(dt);
|
|
42
34
|
}
|
|
43
35
|
}
|