@benjos/create-boilerplate 1.0.0 → 1.0.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/README.md +16 -21
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/template-vanilla/.prettierignore +6 -0
- package/template-vanilla/.prettierrc +10 -0
- package/template-vanilla/assets_source/.gitkeep +0 -0
- package/template-vanilla/docs/PUBLISHING.md +30 -0
- package/template-vanilla/eslint.config.js +126 -0
- package/template-vanilla/index.html +17 -0
- package/template-vanilla/package-lock.json +3743 -0
- package/template-vanilla/package.json +38 -0
- package/template-vanilla/public/assets/fonts/LICENSE +13 -0
- package/template-vanilla/public/assets/fonts/template.typeface.json +1 -0
- package/template-vanilla/public/assets/hdrs/template.hdr +0 -0
- package/template-vanilla/public/assets/icons/benjosLogoBlack.svg +5 -0
- package/template-vanilla/public/assets/loaders/draco/README.md +32 -0
- package/template-vanilla/public/assets/loaders/draco/draco_decoder.js +34 -0
- package/template-vanilla/public/assets/loaders/draco/draco_decoder.wasm +0 -0
- package/template-vanilla/public/assets/loaders/draco/draco_encoder.js +33 -0
- package/template-vanilla/public/assets/loaders/draco/draco_wasm_wrapper.js +117 -0
- package/template-vanilla/public/assets/loaders/draco/gltf/draco_decoder.js +33 -0
- package/template-vanilla/public/assets/loaders/draco/gltf/draco_decoder.wasm +0 -0
- package/template-vanilla/public/assets/loaders/draco/gltf/draco_encoder.js +33 -0
- package/template-vanilla/public/assets/loaders/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/template-vanilla/public/assets/models/template.glb +0 -0
- package/template-vanilla/public/assets/textures/template.jpg +0 -0
- package/template-vanilla/readme.md +49 -0
- package/template-vanilla/src/experiences/Experience.ts +15 -0
- package/template-vanilla/src/experiences/cameras/threes/DebugThreeCameraController.ts +60 -0
- package/template-vanilla/src/experiences/cameras/threes/LoaderThreeCameraController.ts +28 -0
- package/template-vanilla/src/experiences/cameras/threes/MainThreeCameraController.ts +28 -0
- package/template-vanilla/src/experiences/cameras/threes/bases/ThreeCameraControllerBase.ts +109 -0
- package/template-vanilla/src/experiences/commands/InitCommand.ts +48 -0
- package/template-vanilla/src/experiences/constants/doms/DomEvent.ts +100 -0
- package/template-vanilla/src/experiences/constants/doms/KeyboardConstant.ts +250 -0
- package/template-vanilla/src/experiences/constants/experiences/AnimationId.ts +3 -0
- package/template-vanilla/src/experiences/constants/experiences/AssetId.ts +8 -0
- package/template-vanilla/src/experiences/constants/experiences/AssetType.ts +8 -0
- package/template-vanilla/src/experiences/constants/experiences/CameraId.ts +7 -0
- package/template-vanilla/src/experiences/constants/experiences/CameraType.ts +6 -0
- package/template-vanilla/src/experiences/constants/experiences/Object3dId.ts +3 -0
- package/template-vanilla/src/experiences/constants/experiences/ViewId.ts +15 -0
- package/template-vanilla/src/experiences/engines/htmls/MainHTML.ts +13 -0
- package/template-vanilla/src/experiences/engines/threes/MainThree.ts +171 -0
- package/template-vanilla/src/experiences/managers/DebugManager.ts +78 -0
- package/template-vanilla/src/experiences/managers/KeyboardManager.ts +65 -0
- package/template-vanilla/src/experiences/managers/LoaderManager.ts +79 -0
- package/template-vanilla/src/experiences/managers/MouseManager.ts +100 -0
- package/template-vanilla/src/experiences/managers/ResizeManager.ts +53 -0
- package/template-vanilla/src/experiences/managers/TickerManager.ts +86 -0
- package/template-vanilla/src/experiences/managers/threes/ThreeAssetsManager.ts +279 -0
- package/template-vanilla/src/experiences/managers/threes/ThreeCameraControllerManager.ts +43 -0
- package/template-vanilla/src/experiences/managers/threes/ThreeRaycasterManager.ts +23 -0
- package/template-vanilla/src/experiences/materials/threes/loaders/LoaderMaterial.ts +48 -0
- package/template-vanilla/src/experiences/proxies/ViewProxy.ts +30 -0
- package/template-vanilla/src/experiences/proxies/bases/PoolProxyBase.ts +61 -0
- package/template-vanilla/src/experiences/renderers/threes/LoaderRenderer.ts +22 -0
- package/template-vanilla/src/experiences/renderers/threes/Renderer.ts +74 -0
- package/template-vanilla/src/experiences/renderers/threes/bases/WebGLRendererBase.ts +29 -0
- package/template-vanilla/src/experiences/shaders/threes/loaders/LoaderFragmentShader.glsl +6 -0
- package/template-vanilla/src/experiences/shaders/threes/loaders/LoaderVertexShader.glsl +3 -0
- package/template-vanilla/src/experiences/styles/abstracts/_import.scss +5 -0
- package/template-vanilla/src/experiences/styles/abstracts/functions.scss +3 -0
- package/template-vanilla/src/experiences/styles/abstracts/mixins.scss +0 -0
- package/template-vanilla/src/experiences/styles/abstracts/variables.scss +7 -0
- package/template-vanilla/src/experiences/styles/commons/fonts.scss +10 -0
- package/template-vanilla/src/experiences/styles/commons/main.scss +84 -0
- package/template-vanilla/src/experiences/styles/commons/texts.scss +1 -0
- package/template-vanilla/src/experiences/styles/style.scss +7 -0
- package/template-vanilla/src/experiences/styles/views/loader.scss +72 -0
- package/template-vanilla/src/experiences/tools/Action.ts +23 -0
- package/template-vanilla/src/experiences/tools/Point.ts +56 -0
- package/template-vanilla/src/experiences/types/global.d.ts +9 -0
- package/template-vanilla/src/experiences/utils/AssetUtils.ts +6 -0
- package/template-vanilla/src/experiences/utils/DomUtils.ts +28 -0
- package/template-vanilla/src/experiences/views/bases/ViewBase.ts +25 -0
- package/template-vanilla/src/experiences/views/htmls/bases/HTMLViewBase.ts +41 -0
- package/template-vanilla/src/experiences/views/htmls/loaders/LoaderHTMLView.ts +34 -0
- package/template-vanilla/src/experiences/views/htmls/loaders/components/HTMLTemplateLoader.ts +57 -0
- package/template-vanilla/src/experiences/views/threes/bases/ThreeViewBase.ts +26 -0
- package/template-vanilla/src/experiences/views/threes/loaders/LoaderThreeView.ts +41 -0
- package/template-vanilla/src/experiences/views/threes/loaders/components/ThreeTemplateLoader.ts +52 -0
- package/template-vanilla/src/experiences/views/threes/worlds/WorldThreeView.ts +51 -0
- package/template-vanilla/src/experiences/views/threes/worlds/components/Environment.ts +77 -0
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateFont.ts +62 -0
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateMesh.ts +65 -0
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateModel.ts +31 -0
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ActorBase.ts +9 -0
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/AnimatedModelBase.ts +67 -0
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ModelBase.ts +48 -0
- package/template-vanilla/src/main.ts +3 -0
- package/template-vanilla/tsconfig.json +24 -0
- package/template-vanilla/vite.config.ts +15 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type ThreeCameraControllerBase from '../../cameras/threes/bases/ThreeCameraControllerBase';
|
|
2
|
+
import type { CameraId } from '../../constants/experiences/CameraId';
|
|
3
|
+
import Action from '../../tools/Action';
|
|
4
|
+
|
|
5
|
+
export default class ThreeCameraControllerManager {
|
|
6
|
+
private static readonly _ThreeCameraControllers = new Map<CameraId, ThreeCameraControllerBase>();
|
|
7
|
+
private static _ActiveThreeCameraController: ThreeCameraControllerBase;
|
|
8
|
+
|
|
9
|
+
public static readonly OnActiveThreeCameraControllerChange = new Action();
|
|
10
|
+
|
|
11
|
+
public static Init(): void {
|
|
12
|
+
ThreeCameraControllerManager._ThreeCameraControllers.clear();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public static Add(threeCameraController: ThreeCameraControllerBase, isActive = false): void {
|
|
16
|
+
ThreeCameraControllerManager._ThreeCameraControllers.set(threeCameraController.cameraId, threeCameraController);
|
|
17
|
+
if (isActive) ThreeCameraControllerManager.SetActiveCamera(threeCameraController.cameraId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public static Get(cameraId: CameraId): ThreeCameraControllerBase {
|
|
21
|
+
const threeCameraController = ThreeCameraControllerManager._ThreeCameraControllers.get(cameraId);
|
|
22
|
+
if (!threeCameraController) {
|
|
23
|
+
throw new Error(`CameraControllerManager: No camera found with id ${cameraId}`);
|
|
24
|
+
}
|
|
25
|
+
return threeCameraController;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static SetActiveCamera(cameraId: CameraId): void {
|
|
29
|
+
const threeCameraController = ThreeCameraControllerManager.Get(cameraId);
|
|
30
|
+
ThreeCameraControllerManager._ActiveThreeCameraController?.disable();
|
|
31
|
+
ThreeCameraControllerManager._ActiveThreeCameraController = threeCameraController;
|
|
32
|
+
ThreeCameraControllerManager._ActiveThreeCameraController.enable();
|
|
33
|
+
ThreeCameraControllerManager.OnActiveThreeCameraControllerChange.execute();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#region Getters
|
|
37
|
+
//
|
|
38
|
+
public static get ActiveThreeCameraController(): ThreeCameraControllerBase {
|
|
39
|
+
return ThreeCameraControllerManager._ActiveThreeCameraController;
|
|
40
|
+
}
|
|
41
|
+
//
|
|
42
|
+
//#endregion
|
|
43
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Object3D, Raycaster, Vector2, type Intersection, type Object3DEventMap } from 'three';
|
|
2
|
+
import MainThree from '../../engines/threes/MainThree';
|
|
3
|
+
import MouseManager from '../MouseManager';
|
|
4
|
+
|
|
5
|
+
export default class ThreeRaycasterManager {
|
|
6
|
+
private static readonly _Raycaster = new Raycaster();
|
|
7
|
+
|
|
8
|
+
public static Init(): void {
|
|
9
|
+
//
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public static CastFromCameraToMouse(
|
|
13
|
+
objects: Object3D[],
|
|
14
|
+
recursive = true
|
|
15
|
+
): Intersection<Object3D<Object3DEventMap>>[] {
|
|
16
|
+
ThreeRaycasterManager._Raycaster.setFromCamera(
|
|
17
|
+
new Vector2(MouseManager.CentralX, MouseManager.CentralY),
|
|
18
|
+
MainThree.CameraController.camera
|
|
19
|
+
);
|
|
20
|
+
const intersects = ThreeRaycasterManager._Raycaster.intersectObjects(objects, recursive);
|
|
21
|
+
return intersects;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import gsap from 'gsap';
|
|
2
|
+
import { Color, ShaderMaterial } from 'three';
|
|
3
|
+
import LoaderFragmentShader from '../../../shaders/threes/loaders/LoaderFragmentShader.glsl';
|
|
4
|
+
import LoaderVertexShader from '../../../shaders/threes/loaders/LoaderVertexShader.glsl';
|
|
5
|
+
|
|
6
|
+
export default class LoaderMaterial extends ShaderMaterial {
|
|
7
|
+
//#region Constants
|
|
8
|
+
//
|
|
9
|
+
private static readonly _DEFAULT_UNIFORMS_ALPHA: number = 1;
|
|
10
|
+
private static readonly _DEFAULT_UNIFORMS_COLOR: number = 0x3f79f3;
|
|
11
|
+
private static readonly _GSAP_DURATION_FADE_IN: number = 0.5;
|
|
12
|
+
private static readonly _GSAP_EASE_FADE_IN: string = 'power2.out';
|
|
13
|
+
private static readonly _GSAP_DURATION_FADE_OUT: number = 1.5;
|
|
14
|
+
private static readonly _GSAP_EASE_FADE_OUT: string = 'power2.in';
|
|
15
|
+
//
|
|
16
|
+
//#endregion
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super({
|
|
20
|
+
transparent: true,
|
|
21
|
+
uniforms: {
|
|
22
|
+
uAlpha: { value: LoaderMaterial._DEFAULT_UNIFORMS_ALPHA },
|
|
23
|
+
uColor: { value: new Color(LoaderMaterial._DEFAULT_UNIFORMS_COLOR) },
|
|
24
|
+
},
|
|
25
|
+
vertexShader: LoaderVertexShader,
|
|
26
|
+
fragmentShader: LoaderFragmentShader,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public show(): void {
|
|
31
|
+
gsap.killTweensOf(this.uniforms.uAlpha);
|
|
32
|
+
gsap.to(this.uniforms.uAlpha, {
|
|
33
|
+
value: 1,
|
|
34
|
+
duration: LoaderMaterial._GSAP_DURATION_FADE_IN,
|
|
35
|
+
ease: LoaderMaterial._GSAP_EASE_FADE_IN,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public hide(): void {
|
|
40
|
+
gsap.killTweensOf(this.uniforms.uAlpha);
|
|
41
|
+
this.uniforms.uAlpha.value = 1;
|
|
42
|
+
gsap.to(this.uniforms.uAlpha, {
|
|
43
|
+
value: 0,
|
|
44
|
+
duration: LoaderMaterial._GSAP_DURATION_FADE_OUT,
|
|
45
|
+
ease: LoaderMaterial._GSAP_EASE_FADE_OUT,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ViewId } from '../constants/experiences/ViewId';
|
|
2
|
+
import type ViewBase from '../views/bases/ViewBase';
|
|
3
|
+
|
|
4
|
+
type ViewConstructor<T extends ViewBase> = new (id: ViewId) => T;
|
|
5
|
+
|
|
6
|
+
export default class ViewProxy {
|
|
7
|
+
private static _Views = new Map<ViewId, ViewBase>();
|
|
8
|
+
|
|
9
|
+
public static Init(): void {
|
|
10
|
+
//
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public static Add(viewId: ViewId, ViewClass: ViewConstructor<ViewBase>): void {
|
|
14
|
+
if (ViewProxy._Views.has(viewId)) {
|
|
15
|
+
throw new Error(`ViewProxy: View with id "${viewId}" already exists.`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
ViewProxy._Views.set(viewId, new ViewClass(viewId));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static GetById<T extends ViewBase = ViewBase>(viewId: ViewId): T {
|
|
22
|
+
const view = ViewProxy._Views.get(viewId);
|
|
23
|
+
if (!view) throw new Error(`ViewProxy: View with id "${viewId}" not found.`);
|
|
24
|
+
return view as T;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public static Has(viewId: ViewId): boolean {
|
|
28
|
+
return ViewProxy._Views.has(viewId);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
type Constructor<T> = new () => T;
|
|
2
|
+
|
|
3
|
+
export default abstract class PoolProxyBase<T = unknown> {
|
|
4
|
+
protected readonly _pool: Set<T> = new Set<T>();
|
|
5
|
+
private readonly _ctor: Constructor<T>;
|
|
6
|
+
|
|
7
|
+
//#region Constants
|
|
8
|
+
//
|
|
9
|
+
private static readonly _DEFAULT_INITIAL_SIZE: number = 0;
|
|
10
|
+
//
|
|
11
|
+
//#endregion
|
|
12
|
+
|
|
13
|
+
constructor(ctor: Constructor<T>, initialSize: number = PoolProxyBase._DEFAULT_INITIAL_SIZE) {
|
|
14
|
+
this._ctor = ctor;
|
|
15
|
+
this._prepopulate(initialSize);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private _prepopulate(number: number): void {
|
|
19
|
+
for (let i = 0; i < number; i++) {
|
|
20
|
+
this._pool.add(new this._ctor());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public get(): T {
|
|
25
|
+
if (this._pool.size > 0) {
|
|
26
|
+
const o = this._pool.values().next().value!;
|
|
27
|
+
this._pool.delete(o);
|
|
28
|
+
return o;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return new this._ctor();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public release(o: T): void {
|
|
35
|
+
this._pool.add(o);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#region TEMPLATE USAGE
|
|
40
|
+
//
|
|
41
|
+
// class TemplatePoolProxy extends PoolProxyBase<TemplateObject> {
|
|
42
|
+
// constructor() {
|
|
43
|
+
// super(TemplateObject);
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
// public override get(): TemplateObject {
|
|
47
|
+
// const o = super.get();
|
|
48
|
+
// // Do any additional initialization here if necessary
|
|
49
|
+
// return o;
|
|
50
|
+
// }
|
|
51
|
+
|
|
52
|
+
// public override release(o: TemplateObject): void {
|
|
53
|
+
// // Do any additional cleanup here if necessary
|
|
54
|
+
// super.release(o);
|
|
55
|
+
// }
|
|
56
|
+
// }
|
|
57
|
+
|
|
58
|
+
// const instance = new TemplatePoolProxy();
|
|
59
|
+
// export { instance as TemplatePoolProxy };
|
|
60
|
+
//
|
|
61
|
+
//#endregion
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Camera, LinearSRGBColorSpace, NoToneMapping, Scene, type WebGLRendererParameters } from 'three';
|
|
2
|
+
import WebGLRendererBase from './bases/WebGLRendererBase';
|
|
3
|
+
|
|
4
|
+
export default class LoaderRenderer extends WebGLRendererBase {
|
|
5
|
+
//#region Constants
|
|
6
|
+
//
|
|
7
|
+
private static readonly _DEFAULT_TONE_MAPPING = NoToneMapping;
|
|
8
|
+
private static readonly _DEFAULT_OUTPUT_COLOR_SPACE = LinearSRGBColorSpace;
|
|
9
|
+
private static readonly _DEFAULT_TONE_MAPPING_EXPOSURE = 1;
|
|
10
|
+
private static readonly _DEFAULT_CLEAR_COLOR = 0x000000;
|
|
11
|
+
private static readonly _DEFAULT_CLEAR_ALPHA = 0;
|
|
12
|
+
//
|
|
13
|
+
//#endregion
|
|
14
|
+
|
|
15
|
+
constructor(scene: Scene, camera: Camera, parameters: WebGLRendererParameters = {}) {
|
|
16
|
+
super(scene, camera, parameters);
|
|
17
|
+
this.toneMapping = LoaderRenderer._DEFAULT_TONE_MAPPING;
|
|
18
|
+
this.toneMappingExposure = LoaderRenderer._DEFAULT_TONE_MAPPING_EXPOSURE;
|
|
19
|
+
this.outputColorSpace = LoaderRenderer._DEFAULT_OUTPUT_COLOR_SPACE;
|
|
20
|
+
this.setClearColor(LoaderRenderer._DEFAULT_CLEAR_COLOR, LoaderRenderer._DEFAULT_CLEAR_ALPHA);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACESFilmicToneMapping,
|
|
3
|
+
AgXToneMapping,
|
|
4
|
+
Camera,
|
|
5
|
+
CineonToneMapping,
|
|
6
|
+
CustomToneMapping,
|
|
7
|
+
LinearSRGBColorSpace,
|
|
8
|
+
LinearToneMapping,
|
|
9
|
+
NeutralToneMapping,
|
|
10
|
+
NoToneMapping,
|
|
11
|
+
PCFSoftShadowMap,
|
|
12
|
+
ReinhardToneMapping,
|
|
13
|
+
Scene,
|
|
14
|
+
SRGBColorSpace,
|
|
15
|
+
type ColorSpace,
|
|
16
|
+
type ToneMapping,
|
|
17
|
+
type WebGLRendererParameters,
|
|
18
|
+
} from 'three';
|
|
19
|
+
import DebugManager from '../../managers/DebugManager';
|
|
20
|
+
import WebGLRendererBase from './bases/WebGLRendererBase';
|
|
21
|
+
|
|
22
|
+
export default class Renderer extends WebGLRendererBase {
|
|
23
|
+
//#region Constants
|
|
24
|
+
//
|
|
25
|
+
private static readonly _DEFAULT_TONE_MAPPING = CineonToneMapping;
|
|
26
|
+
private static readonly _DEFAULT_OUTPUT_COLOR_SPACE = SRGBColorSpace;
|
|
27
|
+
private static readonly _DEFAULT_SHADOW_MAP_TYPE = PCFSoftShadowMap;
|
|
28
|
+
private static readonly _DEFAULT_TONE_MAPPING_EXPOSURE = 1;
|
|
29
|
+
private static readonly _DEFAULT_CLEAR_COLOR = 0xfafafa;
|
|
30
|
+
private static readonly _DEFAULT_CLEAR_ALPHA = 0;
|
|
31
|
+
//
|
|
32
|
+
//#endregion
|
|
33
|
+
|
|
34
|
+
constructor(scene: Scene, camera: Camera, parameters: WebGLRendererParameters = {}) {
|
|
35
|
+
super(scene, camera, parameters);
|
|
36
|
+
this.toneMapping = Renderer._DEFAULT_TONE_MAPPING;
|
|
37
|
+
this.toneMappingExposure = Renderer._DEFAULT_TONE_MAPPING_EXPOSURE;
|
|
38
|
+
this.outputColorSpace = Renderer._DEFAULT_OUTPUT_COLOR_SPACE;
|
|
39
|
+
this.shadowMap.enabled = true;
|
|
40
|
+
this.shadowMap.type = Renderer._DEFAULT_SHADOW_MAP_TYPE;
|
|
41
|
+
this.setClearColor(Renderer._DEFAULT_CLEAR_COLOR, Renderer._DEFAULT_CLEAR_ALPHA);
|
|
42
|
+
|
|
43
|
+
if (DebugManager.IsActive) {
|
|
44
|
+
const rendererFolder = DebugManager.Gui.addFolder('Renderer');
|
|
45
|
+
rendererFolder
|
|
46
|
+
.add(this, 'toneMapping', {
|
|
47
|
+
NoToneMapping,
|
|
48
|
+
LinearToneMapping,
|
|
49
|
+
ReinhardToneMapping,
|
|
50
|
+
CineonToneMapping,
|
|
51
|
+
ACESFilmicToneMapping,
|
|
52
|
+
CustomToneMapping,
|
|
53
|
+
AgXToneMapping,
|
|
54
|
+
NeutralToneMapping,
|
|
55
|
+
})
|
|
56
|
+
.onChange((value: ToneMapping) => {
|
|
57
|
+
this.toneMapping = value;
|
|
58
|
+
});
|
|
59
|
+
rendererFolder.add(this, 'toneMappingExposure', 0, 10, 0.001);
|
|
60
|
+
rendererFolder
|
|
61
|
+
.add(this, 'outputColorSpace', { SRGBColorSpace, LinearSRGBColorSpace })
|
|
62
|
+
.onChange((value: ColorSpace) => {
|
|
63
|
+
this.outputColorSpace = value;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public override update(dt: number): void {
|
|
69
|
+
const isDebug = DebugManager.IsActive;
|
|
70
|
+
if (isDebug) DebugManager.BeginThreePerf();
|
|
71
|
+
super.update(dt);
|
|
72
|
+
if (isDebug) DebugManager.EndThreePerf();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Camera, Scene, WebGLRenderer, type WebGLRendererParameters } from 'three';
|
|
2
|
+
import { ResizeManager } from '../../../managers/ResizeManager';
|
|
3
|
+
|
|
4
|
+
export default abstract class WebGLRendererBase extends WebGLRenderer {
|
|
5
|
+
private readonly _scene: Scene;
|
|
6
|
+
private _camera: Camera;
|
|
7
|
+
|
|
8
|
+
constructor(scene: Scene, camera: Camera, parameters: WebGLRendererParameters = {}) {
|
|
9
|
+
super(parameters);
|
|
10
|
+
|
|
11
|
+
this._scene = scene;
|
|
12
|
+
this._camera = camera;
|
|
13
|
+
|
|
14
|
+
this.resize();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public setCamera(camera: Camera): void {
|
|
18
|
+
this._camera = camera;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public resize(): void {
|
|
22
|
+
this.setSize(ResizeManager.Width, ResizeManager.Height);
|
|
23
|
+
this.setPixelRatio(ResizeManager.PixelRatio);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public update(_dt: number): void {
|
|
27
|
+
this.render(this._scene, this._camera);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
@use '../abstracts/import.scss' as *;
|
|
2
|
+
|
|
3
|
+
// @font-face {
|
|
4
|
+
// font-family: 'din-condensed';
|
|
5
|
+
// src: getAssetUrl('fonts/din_bold_c.woff') format('woff'),
|
|
6
|
+
// getAssetUrl('fonts/din_bold_c.woff2') format('woff2');
|
|
7
|
+
// font-weight: bold;
|
|
8
|
+
// font-style: normal;
|
|
9
|
+
// font-display: swap;
|
|
10
|
+
// }
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
@use '../abstracts/import.scss' as *;
|
|
2
|
+
|
|
3
|
+
$viewTransition: 0.5s;
|
|
4
|
+
|
|
5
|
+
* {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
user-select: none;
|
|
8
|
+
overscroll-behavior: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
body {
|
|
12
|
+
position: relative;
|
|
13
|
+
width: 100dvw;
|
|
14
|
+
height: 100dvh;
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
|
|
19
|
+
> #app,
|
|
20
|
+
> #root {
|
|
21
|
+
position: relative;
|
|
22
|
+
width: 100%;
|
|
23
|
+
height: 100%;
|
|
24
|
+
|
|
25
|
+
> #loader {
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: 0;
|
|
28
|
+
left: 0;
|
|
29
|
+
width: 100%;
|
|
30
|
+
height: 100%;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
canvas,
|
|
35
|
+
#webgl {
|
|
36
|
+
width: 100%;
|
|
37
|
+
height: 100%;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.view-html-container {
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: 0;
|
|
43
|
+
left: 0;
|
|
44
|
+
width: 100%;
|
|
45
|
+
height: 100%;
|
|
46
|
+
opacity: 0;
|
|
47
|
+
|
|
48
|
+
&.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
|
+
&.hide {
|
|
64
|
+
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
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.lil-gui,
|
|
81
|
+
#three-perf-ui {
|
|
82
|
+
z-index: 999999;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@use '../abstracts/import.scss' as *;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
@use '../abstracts/import.scss' as *;
|
|
2
|
+
|
|
3
|
+
$outroFadeOutDuration: 1.5s;
|
|
4
|
+
|
|
5
|
+
body {
|
|
6
|
+
> #app,
|
|
7
|
+
> #root {
|
|
8
|
+
> #loader {
|
|
9
|
+
.view-html-container {
|
|
10
|
+
&.hide {
|
|
11
|
+
animation-duration: $outroFadeOutDuration;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#loader {
|
|
19
|
+
z-index: 999999;
|
|
20
|
+
|
|
21
|
+
.loading-screen {
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 0;
|
|
24
|
+
left: 0;
|
|
25
|
+
width: 100dvw;
|
|
26
|
+
height: 100dvh;
|
|
27
|
+
|
|
28
|
+
.loading-progress {
|
|
29
|
+
z-index: 2;
|
|
30
|
+
position: absolute;
|
|
31
|
+
top: 50%;
|
|
32
|
+
left: 50%;
|
|
33
|
+
transform: translate(-50%, -50%);
|
|
34
|
+
padding-bottom: 2.5rem;
|
|
35
|
+
opacity: 1;
|
|
36
|
+
font-size: 2rem;
|
|
37
|
+
color: $white;
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
gap: 0.25rem;
|
|
41
|
+
color: $white;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.loading-bar {
|
|
45
|
+
z-index: 1;
|
|
46
|
+
width: 100dvw;
|
|
47
|
+
height: 0.25rem;
|
|
48
|
+
position: absolute;
|
|
49
|
+
top: 50%;
|
|
50
|
+
left: 0;
|
|
51
|
+
opacity: 1;
|
|
52
|
+
background-color: $white;
|
|
53
|
+
transform-origin: top left;
|
|
54
|
+
transform: translateY(-50%) scaleX(0);
|
|
55
|
+
|
|
56
|
+
&.ended {
|
|
57
|
+
transform-origin: top right;
|
|
58
|
+
animation: outBar $outroFadeOutDuration cubic-bezier(0.77, 0, 0.175, 1) forwards;
|
|
59
|
+
|
|
60
|
+
@keyframes outBar {
|
|
61
|
+
0% {
|
|
62
|
+
transform: translateY(-50%) scaleX(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
100% {
|
|
66
|
+
transform: translateY(-50%) scaleX(0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type Listener<TParams extends unknown[]> = (...params: TParams) => unknown;
|
|
2
|
+
|
|
3
|
+
export default class Action<T extends unknown[] = []> {
|
|
4
|
+
private _listeners = new Set<Listener<T>>();
|
|
5
|
+
|
|
6
|
+
public add(listener: Listener<T>): void {
|
|
7
|
+
this._listeners.add(listener);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public remove(listener: Listener<T>): void {
|
|
11
|
+
this._listeners.delete(listener);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public removeAll(): void {
|
|
15
|
+
this._listeners.clear();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public execute(...params: T): void {
|
|
19
|
+
for (const listener of this._listeners) {
|
|
20
|
+
listener(...params);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export default class Point {
|
|
2
|
+
private _x: number;
|
|
3
|
+
private _y: number;
|
|
4
|
+
private _z: number;
|
|
5
|
+
|
|
6
|
+
constructor(x = 0, y = 0, z = 0) {
|
|
7
|
+
this._x = x;
|
|
8
|
+
this._y = y;
|
|
9
|
+
this._z = z;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public set(x: number, y: number, z: number = this._z): void {
|
|
13
|
+
this._x = x;
|
|
14
|
+
this._y = y;
|
|
15
|
+
this._z = z;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public clear(): void {
|
|
19
|
+
this._x = 0;
|
|
20
|
+
this._y = 0;
|
|
21
|
+
this._z = 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public copy(p: Point): void {
|
|
25
|
+
this._x = p.x;
|
|
26
|
+
this._y = p.y;
|
|
27
|
+
this._z = p.z;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public clone(): Point {
|
|
31
|
+
return new Point(this._x, this._y, this._z);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#region getter setter
|
|
35
|
+
//
|
|
36
|
+
public get x(): number {
|
|
37
|
+
return this._x;
|
|
38
|
+
}
|
|
39
|
+
public set x(x: number) {
|
|
40
|
+
this._x = x;
|
|
41
|
+
}
|
|
42
|
+
public get y(): number {
|
|
43
|
+
return this._y;
|
|
44
|
+
}
|
|
45
|
+
public set y(y: number) {
|
|
46
|
+
this._y = y;
|
|
47
|
+
}
|
|
48
|
+
public get z(): number {
|
|
49
|
+
return this._z;
|
|
50
|
+
}
|
|
51
|
+
public set z(z: number) {
|
|
52
|
+
this._z = z;
|
|
53
|
+
}
|
|
54
|
+
//
|
|
55
|
+
//#endregion
|
|
56
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default class DomUtils {
|
|
2
|
+
public static GetApp(): HTMLDivElement {
|
|
3
|
+
const app = (document.querySelector('#app') ?? document.querySelector('#root'))!;
|
|
4
|
+
|
|
5
|
+
if (!app) {
|
|
6
|
+
const newApp = document.createElement('div');
|
|
7
|
+
newApp.id = 'app';
|
|
8
|
+
document.body.appendChild(newApp);
|
|
9
|
+
return newApp;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return app as HTMLDivElement;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public static GetLoader(): HTMLDivElement {
|
|
16
|
+
const loader = document.querySelector('#loader')!;
|
|
17
|
+
|
|
18
|
+
if (!loader) {
|
|
19
|
+
const app = DomUtils.GetApp();
|
|
20
|
+
const newLoader = document.createElement('div');
|
|
21
|
+
newLoader.id = 'loader';
|
|
22
|
+
app.appendChild(newLoader);
|
|
23
|
+
return newLoader;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return loader as HTMLDivElement;
|
|
27
|
+
}
|
|
28
|
+
}
|