@benjos/create-boilerplate 1.5.1 → 1.5.6

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.
Files changed (147) hide show
  1. package/README.md +0 -4
  2. package/dist/constants.d.ts +8 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/constants.js +18 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/constants.test.d.ts +2 -0
  7. package/dist/constants.test.d.ts.map +1 -0
  8. package/dist/constants.test.js +30 -0
  9. package/dist/constants.test.js.map +1 -0
  10. package/dist/createProject.d.ts +2 -0
  11. package/dist/createProject.d.ts.map +1 -0
  12. package/dist/createProject.js +52 -0
  13. package/dist/createProject.js.map +1 -0
  14. package/dist/createProject.test.d.ts +2 -0
  15. package/dist/createProject.test.d.ts.map +1 -0
  16. package/dist/createProject.test.js +85 -0
  17. package/dist/createProject.test.js.map +1 -0
  18. package/dist/index.js +16 -69
  19. package/dist/index.js.map +1 -1
  20. package/dist/prompts.d.ts +4 -0
  21. package/dist/prompts.d.ts.map +1 -0
  22. package/dist/prompts.js +26 -0
  23. package/dist/prompts.js.map +1 -0
  24. package/dist/prompts.test.d.ts +2 -0
  25. package/dist/prompts.test.d.ts.map +1 -0
  26. package/dist/prompts.test.js +50 -0
  27. package/dist/prompts.test.js.map +1 -0
  28. package/dist/types.d.ts +13 -0
  29. package/dist/types.d.ts.map +1 -0
  30. package/dist/types.js +7 -0
  31. package/dist/types.js.map +1 -0
  32. package/package.json +10 -8
  33. package/template-vanilla/package-lock.json +1000 -1476
  34. package/template-vanilla/package.json +11 -11
  35. package/template-vanilla/src/experiences/Experience.ts +1 -1
  36. package/template-vanilla/src/experiences/constants/experiences/ViewId.ts +2 -7
  37. package/template-vanilla/src/experiences/engines/threes/app/MainThreeApp.ts +8 -5
  38. package/template-vanilla/src/experiences/managers/LoaderManager.ts +4 -5
  39. package/template-vanilla/src/experiences/materials/threes/loaders/LoaderMaterial.ts +8 -5
  40. package/template-vanilla/src/experiences/views/threes/bases/ThreeViewBase.ts +1 -1
  41. package/template-vanilla/src/experiences/views/threes/{worlds/components/actors/bases → bases/components}/ThreeAnimatedModelBase.ts +3 -3
  42. package/template-vanilla/src/experiences/views/threes/{worlds/components/actors/bases → bases/components}/ThreeModelBase.ts +3 -3
  43. package/template-vanilla/src/experiences/views/threes/loaders/components/TemplateLoaderThreeActor.ts +1 -1
  44. package/template-vanilla/src/experiences/views/threes/worlds/World2ThreeView.ts +5 -5
  45. package/template-vanilla/src/experiences/views/threes/worlds/WorldThreeView.ts +5 -5
  46. package/template-vanilla/src/experiences/views/threes/worlds/components/Environment.ts +1 -1
  47. package/template-vanilla/src/experiences/views/threes/worlds/components/{actors/TemplateFont.ts → TemplateFont.ts} +3 -3
  48. package/template-vanilla/src/experiences/views/threes/worlds/components/{actors/TemplateMesh.ts → TemplateMesh.ts} +3 -3
  49. package/template-vanilla/src/experiences/views/threes/worlds/components/{actors/TemplateMesh2.ts → TemplateMesh2.ts} +3 -3
  50. package/template-vanilla/src/experiences/views/threes/worlds/components/{actors/TemplateModel.ts → TemplateModel.ts} +4 -4
  51. package/template-vanilla/tsconfig.json +3 -3
  52. package/template-vue/eslint.config.js +130 -0
  53. package/template-vue/index.html +17 -0
  54. package/{template-react → template-vue}/package-lock.json +1260 -2121
  55. package/template-vue/package.json +43 -0
  56. package/template-vue/readme.md +34 -0
  57. package/template-vue/src/experiences/Experience.ts +27 -0
  58. package/template-vue/src/experiences/cameras/threes/DebugThreeCameraController.ts +55 -0
  59. package/template-vue/src/experiences/cameras/threes/LoaderThreeCameraController.ts +25 -0
  60. package/template-vue/src/experiences/cameras/threes/MainThreeCameraController.ts +24 -0
  61. package/template-vue/src/experiences/cameras/threes/bases/ThreeCameraControllerBase.ts +90 -0
  62. package/template-vue/src/experiences/commands/InitCommand.ts +50 -0
  63. package/template-vue/src/experiences/constants/experiences/AnimationId.ts +3 -0
  64. package/template-vue/src/experiences/constants/experiences/AssetId.ts +8 -0
  65. package/template-vue/src/experiences/constants/experiences/CameraId.ts +7 -0
  66. package/template-vue/src/experiences/constants/experiences/DebugGuiTitle.ts +6 -0
  67. package/template-vue/src/experiences/constants/experiences/Object3dId.ts +3 -0
  68. package/template-vue/src/experiences/constants/experiences/ViewId.ts +11 -0
  69. package/template-vue/src/experiences/constants/experiences/ViewType.ts +6 -0
  70. package/template-vue/src/experiences/engines/threes/MainThree.ts +11 -0
  71. package/template-vue/src/experiences/engines/threes/app/LoaderThreeApp.ts +49 -0
  72. package/template-vue/src/experiences/engines/threes/app/MainThreeApp.ts +112 -0
  73. package/template-vue/src/experiences/engines/threes/app/bases/ThreeAppBase.ts +128 -0
  74. package/template-vue/src/experiences/engines/vues/MainVue.vue +9 -0
  75. package/template-vue/src/experiences/managers/DebugManager.ts +87 -0
  76. package/template-vue/src/experiences/managers/LoaderManager.ts +176 -0
  77. package/template-vue/src/experiences/managers/threes/ThreeAssetsManager.ts +263 -0
  78. package/template-vue/src/experiences/managers/threes/ThreeCameraControllerManager.ts +46 -0
  79. package/template-vue/src/experiences/managers/threes/ThreeRaycasterManager.ts +21 -0
  80. package/template-vue/src/experiences/materials/threes/loaders/LoaderMaterial.ts +47 -0
  81. package/template-vue/src/experiences/renderers/threes/LoaderRenderer.ts +18 -0
  82. package/template-vue/src/experiences/renderers/threes/Renderer.ts +71 -0
  83. package/template-vue/src/experiences/renderers/threes/bases/WebGLRendererBase.ts +29 -0
  84. package/template-vue/src/experiences/shaders/threes/loaders/LoaderFragmentShader.glsl +8 -0
  85. package/template-vue/src/experiences/shaders/threes/loaders/LoaderVertexShader.glsl +3 -0
  86. package/template-vue/src/experiences/styles/abstracts/_import.scss +5 -0
  87. package/template-vue/src/experiences/styles/abstracts/functions.scss +3 -0
  88. package/template-vue/src/experiences/styles/abstracts/variables.scss +7 -0
  89. package/template-vue/src/experiences/styles/commons/fonts.scss +10 -0
  90. package/template-vue/src/experiences/styles/commons/main.scss +59 -0
  91. package/template-vue/src/experiences/styles/commons/texts.scss +1 -0
  92. package/template-vue/src/experiences/styles/style.scss +7 -0
  93. package/template-vue/src/experiences/styles/views/loader.scss +70 -0
  94. package/template-vue/src/experiences/types/assetTypes.ts +8 -0
  95. package/template-vue/src/experiences/types/cameraTypes.ts +37 -0
  96. package/template-vue/src/experiences/types/global.d.ts +9 -0
  97. package/template-vue/src/experiences/types/shaders.d.ts +4 -0
  98. package/template-vue/src/experiences/views/threes/bases/ThreeViewBase.ts +49 -0
  99. package/template-vue/src/experiences/views/threes/bases/components/ThreeActorBase.ts +44 -0
  100. package/template-vue/src/experiences/views/threes/bases/components/ThreeAnimatedModelBase.ts +63 -0
  101. package/template-vue/src/experiences/views/threes/bases/components/ThreeModelBase.ts +48 -0
  102. package/template-vue/src/experiences/views/threes/loaders/LoaderThreeView.ts +28 -0
  103. package/template-vue/src/experiences/views/threes/loaders/components/TemplateLoaderThreeActor.ts +49 -0
  104. package/template-vue/src/experiences/views/threes/worlds/World2ThreeView.ts +35 -0
  105. package/template-vue/src/experiences/views/threes/worlds/WorldThreeView.ts +35 -0
  106. package/template-vue/src/experiences/views/threes/worlds/components/Environment.ts +89 -0
  107. package/template-vue/src/experiences/views/threes/worlds/components/TemplateFont.ts +58 -0
  108. package/template-vue/src/experiences/views/threes/worlds/components/TemplateMesh.ts +65 -0
  109. package/template-vue/src/experiences/views/threes/worlds/components/TemplateMesh2.ts +71 -0
  110. package/template-vue/src/experiences/views/threes/worlds/components/TemplateModel.ts +33 -0
  111. package/template-vue/src/experiences/views/vues/LoaderView.vue +55 -0
  112. package/template-vue/src/main.ts +7 -0
  113. package/template-vue/tsconfig.app.json +8 -0
  114. package/template-vue/tsconfig.json +7 -0
  115. package/template-vue/tsconfig.node.json +16 -0
  116. package/template-vue/vite.config.ts +16 -0
  117. package/template-react/eslint.config.js +0 -23
  118. package/template-react/index.html +0 -17
  119. package/template-react/package.json +0 -46
  120. package/template-react/readme.md +0 -31
  121. package/template-react/src/App.css +0 -42
  122. package/template-react/src/App.tsx +0 -10
  123. package/template-react/src/index.css +0 -68
  124. package/template-react/src/main.tsx +0 -10
  125. package/template-react/tsconfig.app.json +0 -34
  126. package/template-react/tsconfig.json +0 -7
  127. package/template-react/tsconfig.node.json +0 -26
  128. package/template-react/vite.config.ts +0 -29
  129. /package/template-vanilla/src/experiences/views/threes/{worlds/components/actors/bases → bases/components}/ThreeActorBase.ts +0 -0
  130. /package/{template-react → template-vue}/.prettierignore +0 -0
  131. /package/{template-react → template-vue}/.prettierrc +0 -0
  132. /package/{template-react → template-vue}/public/assets/fonts/LICENSE +0 -0
  133. /package/{template-react → template-vue}/public/assets/fonts/template.typeface.json +0 -0
  134. /package/{template-react → template-vue}/public/assets/hdrs/template.hdr +0 -0
  135. /package/{template-react → template-vue}/public/assets/icons/benjosLogoBlack.svg +0 -0
  136. /package/{template-react → template-vue}/public/assets/loaders/draco/README.md +0 -0
  137. /package/{template-react → template-vue}/public/assets/loaders/draco/draco_decoder.js +0 -0
  138. /package/{template-react → template-vue}/public/assets/loaders/draco/draco_decoder.wasm +0 -0
  139. /package/{template-react → template-vue}/public/assets/loaders/draco/draco_encoder.js +0 -0
  140. /package/{template-react → template-vue}/public/assets/loaders/draco/draco_wasm_wrapper.js +0 -0
  141. /package/{template-react → template-vue}/public/assets/loaders/draco/gltf/draco_decoder.js +0 -0
  142. /package/{template-react → template-vue}/public/assets/loaders/draco/gltf/draco_decoder.wasm +0 -0
  143. /package/{template-react → template-vue}/public/assets/loaders/draco/gltf/draco_encoder.js +0 -0
  144. /package/{template-react → template-vue}/public/assets/loaders/draco/gltf/draco_wasm_wrapper.js +0 -0
  145. /package/{template-react → template-vue}/public/assets/models/template.glb +0 -0
  146. /package/{template-react → template-vue}/public/assets/textures/template.jpg +0 -0
  147. /package/{template-react/assets_source/.gitkeep → template-vue/src/experiences/styles/abstracts/mixins.scss} +0 -0
@@ -0,0 +1,46 @@
1
+ import { Action } from '@benjos/cookware';
2
+ import type ThreeCameraControllerBase from '../../cameras/threes/bases/ThreeCameraControllerBase';
3
+ import type { CameraId } from '../../constants/experiences/CameraId';
4
+
5
+ class ThreeCameraControllerManager {
6
+ declare private _threeCameraControllers: Map<CameraId, ThreeCameraControllerBase>;
7
+ declare private _activeThreeCameraController: ThreeCameraControllerBase;
8
+
9
+ public readonly onActiveThreeCameraControllerChange = new Action();
10
+
11
+ public init(): void {
12
+ this._threeCameraControllers = new Map();
13
+ this._threeCameraControllers.clear();
14
+ }
15
+
16
+ public add(threeCameraController: ThreeCameraControllerBase, isActive = false): void {
17
+ this._threeCameraControllers.set(threeCameraController.cameraId, threeCameraController);
18
+ if (isActive) this.setActiveCamera(threeCameraController.cameraId);
19
+ }
20
+
21
+ public get(cameraId: CameraId): ThreeCameraControllerBase {
22
+ const threeCameraController = this._threeCameraControllers.get(cameraId);
23
+ if (!threeCameraController) {
24
+ throw new Error(`CameraControllerManager: No camera found with id ${cameraId}`);
25
+ }
26
+ return threeCameraController;
27
+ }
28
+
29
+ public setActiveCamera(cameraId: CameraId): void {
30
+ const threeCameraController = this.get(cameraId);
31
+ this._activeThreeCameraController?.disable();
32
+ this._activeThreeCameraController = threeCameraController;
33
+ this._activeThreeCameraController.enable();
34
+ this.onActiveThreeCameraControllerChange.execute();
35
+ }
36
+
37
+ //#region Getters
38
+ //
39
+ public get activeThreeCameraController(): ThreeCameraControllerBase {
40
+ return this._activeThreeCameraController;
41
+ }
42
+ //
43
+ //#endregion
44
+ }
45
+
46
+ export default new ThreeCameraControllerManager();
@@ -0,0 +1,21 @@
1
+ import { DomPointerManager } from '@benjos/cookware';
2
+ import { Object3D, Raycaster, Vector2, type Intersection, type Object3DEventMap } from 'three';
3
+ import MainThreeApp from '../../engines/threes/app/MainThreeApp';
4
+
5
+ class ThreeRaycasterManager {
6
+ private readonly _raycaster = new Raycaster();
7
+ private readonly _pointerPosition = new Vector2();
8
+
9
+ public init(): void {
10
+ //
11
+ }
12
+
13
+ public castFromCameraToPointer(objects: Object3D[], recursive = true): Intersection<Object3D<Object3DEventMap>>[] {
14
+ this._pointerPosition.set(DomPointerManager.ndcX, DomPointerManager.ndcY);
15
+ this._raycaster.setFromCamera(this._pointerPosition, MainThreeApp.cameraController.camera);
16
+ const intersects = this._raycaster.intersectObjects(objects, recursive);
17
+ return intersects;
18
+ }
19
+ }
20
+
21
+ export default new ThreeRaycasterManager();
@@ -0,0 +1,47 @@
1
+ import gsap from 'gsap';
2
+ import { Color, ShaderMaterial, Uniform } 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
+ private static readonly _DEFAULT_UNIFORMS_COLOR: number = 0x3f79f3;
8
+ private static readonly _GSAP_DURATION_FADE_IN: number = 0.5;
9
+ private static readonly _GSAP_EASE_FADE_IN: string = 'power2.out';
10
+ private static readonly _GSAP_DURATION_FADE_OUT: number = 1.5;
11
+ private static readonly _GSAP_EASE_FADE_OUT: string = 'power2.in';
12
+
13
+ private _isFirstLoad: boolean = true;
14
+
15
+ constructor() {
16
+ super({
17
+ transparent: true,
18
+ uniforms: {
19
+ uAlpha: new Uniform(1),
20
+ uColor: new Uniform(new Color(LoaderMaterial._DEFAULT_UNIFORMS_COLOR)),
21
+ },
22
+ vertexShader: LoaderVertexShader,
23
+ fragmentShader: LoaderFragmentShader,
24
+ });
25
+ }
26
+
27
+ public async show(): Promise<void> {
28
+ gsap.killTweensOf(this.uniforms.uAlpha);
29
+ this.uniforms.uAlpha.value = this._isFirstLoad ? 1 : 0;
30
+ await gsap.to(this.uniforms.uAlpha, {
31
+ value: 1,
32
+ duration: this._isFirstLoad ? 0 : LoaderMaterial._GSAP_DURATION_FADE_IN,
33
+ ease: LoaderMaterial._GSAP_EASE_FADE_IN,
34
+ });
35
+ this._isFirstLoad = false;
36
+ }
37
+
38
+ public async hide(): Promise<void> {
39
+ gsap.killTweensOf(this.uniforms.uAlpha);
40
+ this.uniforms.uAlpha.value = 1;
41
+ await gsap.to(this.uniforms.uAlpha, {
42
+ value: 0,
43
+ duration: LoaderMaterial._GSAP_DURATION_FADE_OUT,
44
+ ease: LoaderMaterial._GSAP_EASE_FADE_OUT,
45
+ });
46
+ }
47
+ }
@@ -0,0 +1,18 @@
1
+ import { Camera, NoToneMapping, Scene, SRGBColorSpace, type WebGLRendererParameters } from 'three';
2
+ import WebGLRendererBase from './bases/WebGLRendererBase';
3
+
4
+ export default class LoaderRenderer extends WebGLRendererBase {
5
+ private static readonly _DEFAULT_TONE_MAPPING = NoToneMapping;
6
+ private static readonly _DEFAULT_OUTPUT_COLOR_SPACE = SRGBColorSpace;
7
+ private static readonly _DEFAULT_TONE_MAPPING_EXPOSURE = 1;
8
+ private static readonly _DEFAULT_CLEAR_COLOR = 0x000000;
9
+ private static readonly _DEFAULT_CLEAR_ALPHA = 0;
10
+
11
+ constructor(scene: Scene, camera: Camera, parameters: WebGLRendererParameters = {}) {
12
+ super(scene, camera, parameters);
13
+ this.toneMapping = LoaderRenderer._DEFAULT_TONE_MAPPING;
14
+ this.toneMappingExposure = LoaderRenderer._DEFAULT_TONE_MAPPING_EXPOSURE;
15
+ this.outputColorSpace = LoaderRenderer._DEFAULT_OUTPUT_COLOR_SPACE;
16
+ this.setClearColor(LoaderRenderer._DEFAULT_CLEAR_COLOR, LoaderRenderer._DEFAULT_CLEAR_ALPHA);
17
+ }
18
+ }
@@ -0,0 +1,71 @@
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 { DebugGuiTitle } from '../../constants/experiences/DebugGuiTitle';
20
+ import DebugManager from '../../managers/DebugManager';
21
+ import WebGLRendererBase from './bases/WebGLRendererBase';
22
+
23
+ export default class Renderer extends WebGLRendererBase {
24
+ private static readonly _DEFAULT_TONE_MAPPING = CineonToneMapping;
25
+ private static readonly _DEFAULT_OUTPUT_COLOR_SPACE = SRGBColorSpace;
26
+ private static readonly _DEFAULT_SHADOW_MAP_TYPE = PCFSoftShadowMap;
27
+ private static readonly _DEFAULT_TONE_MAPPING_EXPOSURE = 1;
28
+ private static readonly _DEFAULT_CLEAR_COLOR = 0xfafafa;
29
+ private static readonly _DEFAULT_CLEAR_ALPHA = 0;
30
+
31
+ constructor(scene: Scene, camera: Camera, parameters: WebGLRendererParameters = {}) {
32
+ super(scene, camera, parameters);
33
+ this.toneMapping = Renderer._DEFAULT_TONE_MAPPING;
34
+ this.toneMappingExposure = Renderer._DEFAULT_TONE_MAPPING_EXPOSURE;
35
+ this.outputColorSpace = Renderer._DEFAULT_OUTPUT_COLOR_SPACE;
36
+ this.shadowMap.enabled = true;
37
+ this.shadowMap.type = Renderer._DEFAULT_SHADOW_MAP_TYPE;
38
+ this.setClearColor(Renderer._DEFAULT_CLEAR_COLOR, Renderer._DEFAULT_CLEAR_ALPHA);
39
+
40
+ if (DebugManager.isActive) {
41
+ const rendererFolder = DebugManager.getGuiFolder(DebugGuiTitle.THREE_RENDERER)
42
+ rendererFolder
43
+ .add(this, 'toneMapping', {
44
+ NoToneMapping,
45
+ LinearToneMapping,
46
+ ReinhardToneMapping,
47
+ CineonToneMapping,
48
+ ACESFilmicToneMapping,
49
+ CustomToneMapping,
50
+ AgXToneMapping,
51
+ NeutralToneMapping,
52
+ })
53
+ .onChange((value: ToneMapping) => {
54
+ this.toneMapping = value;
55
+ });
56
+ rendererFolder.add(this, 'toneMappingExposure', 0, 10, 0.001);
57
+ rendererFolder
58
+ .add(this, 'outputColorSpace', { SRGBColorSpace, LinearSRGBColorSpace })
59
+ .onChange((value: ColorSpace) => {
60
+ this.outputColorSpace = value;
61
+ });
62
+ }
63
+ }
64
+
65
+ public override update(dt: number): void {
66
+ const isDebug = DebugManager.isActive;
67
+ if (isDebug) DebugManager.beginThreePerf();
68
+ super.update(dt);
69
+ if (isDebug) DebugManager.endThreePerf();
70
+ }
71
+ }
@@ -0,0 +1,29 @@
1
+ import { DomResizeManager } from '@benjos/cookware';
2
+ import { Camera, Scene, WebGLRenderer, type WebGLRendererParameters } from 'three';
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(DomResizeManager.width, DomResizeManager.height);
23
+ this.setPixelRatio(DomResizeManager.pixelRatio);
24
+ }
25
+
26
+ public update(_dt: number): void {
27
+ this.render(this._scene, this._camera);
28
+ }
29
+ }
@@ -0,0 +1,8 @@
1
+ uniform vec3 uColor;
2
+ uniform float uAlpha;
3
+
4
+ void main() {
5
+ gl_FragColor = vec4(uColor, uAlpha);
6
+ #include <tonemapping_fragment>
7
+ #include <colorspace_fragment>
8
+ }
@@ -0,0 +1,3 @@
1
+ void main() {
2
+ gl_Position = vec4(position, 1.0);
3
+ }
@@ -0,0 +1,5 @@
1
+ @forward 'variables';
2
+ @forward 'mixins';
3
+ @forward 'functions';
4
+
5
+ // @use 'path/to/_import.scss' as *;
@@ -0,0 +1,3 @@
1
+ @function getAssetUrl($url) {
2
+ @return url('/assets/#{$url}');
3
+ }
@@ -0,0 +1,7 @@
1
+ $white: #fafafa;
2
+ $whiteAntiFlashs: #ededed;
3
+ $darkGrey: #666666;
4
+ $black: #050505;
5
+ $jet: #333333;
6
+ $silverGrey: #aaaaaa;
7
+ $blue: #3f79f3;
@@ -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,59 @@
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
+ .html-view {
41
+ position: absolute;
42
+ top: 0;
43
+ left: 0;
44
+ width: 100%;
45
+ height: 100%;
46
+ opacity: 0;
47
+ transition: opacity $viewTransition ease;
48
+
49
+ &.show {
50
+ opacity: 1;
51
+ }
52
+ }
53
+ }
54
+
55
+ .lil-gui,
56
+ #three-perf-ui {
57
+ z-index: 999999;
58
+ }
59
+ }
@@ -0,0 +1 @@
1
+ @use '../abstracts/import.scss' as *;
@@ -0,0 +1,7 @@
1
+ @use './abstracts/import.scss' as *;
2
+
3
+ @use './commons/main.scss';
4
+ @use './commons/texts.scss';
5
+ @use './commons/fonts.scss';
6
+
7
+ @use './views/loader.scss';
@@ -0,0 +1,70 @@
1
+ @use '../abstracts/import.scss' as *;
2
+
3
+ $outroFadeOutDuration: 1.5s;
4
+
5
+ body {
6
+
7
+ >#app,
8
+ >#root {
9
+ >#loader {
10
+ .html-view {
11
+ transition: opacity $outroFadeOutDuration ease;
12
+ }
13
+ }
14
+ }
15
+ }
16
+
17
+ #loader {
18
+ z-index: 999999;
19
+
20
+ .loading-screen {
21
+ position: absolute;
22
+ top: 0;
23
+ left: 0;
24
+ width: 100dvw;
25
+ height: 100dvh;
26
+
27
+ .loading-progress {
28
+ z-index: 2;
29
+ position: absolute;
30
+ top: 50%;
31
+ left: 50%;
32
+ transform: translate(-50%, -50%);
33
+ padding-bottom: 2.5rem;
34
+ opacity: 1;
35
+ font-size: 2rem;
36
+ color: $white;
37
+ display: flex;
38
+ align-items: center;
39
+ gap: 0.25rem;
40
+ }
41
+
42
+ .loading-bar {
43
+ z-index: 1;
44
+ width: 100dvw;
45
+ height: 0.25rem;
46
+ position: absolute;
47
+ top: 50%;
48
+ left: 0;
49
+ opacity: 1;
50
+ background-color: $white;
51
+ transform-origin: top left;
52
+ transform: translateY(-50%) scaleX(0);
53
+
54
+ &.ended {
55
+ transform-origin: top right;
56
+ animation: outBar $outroFadeOutDuration cubic-bezier(0.77, 0, 0.175, 1) forwards;
57
+
58
+ @keyframes outBar {
59
+ 0% {
60
+ transform: translateY(-50%) scaleX(1);
61
+ }
62
+
63
+ 100% {
64
+ transform: translateY(-50%) scaleX(0);
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,8 @@
1
+ export const AssetType = {
2
+ TEXTURE: 'TEXTURE',
3
+ HDR: 'HDR',
4
+ MODEL: 'MODEL',
5
+ FONT: 'FONT',
6
+ } as const;
7
+
8
+ export type AssetType = (typeof AssetType)[keyof typeof AssetType];
@@ -0,0 +1,37 @@
1
+ //#region Three
2
+ //
3
+ export const ThreeCameraType = {
4
+ PERSPECTIVE: 'PERSPECTIVE',
5
+ ORTHOGRAPHIC: 'ORTHOGRAPHIC',
6
+ } as const;
7
+
8
+ export type ThreeCameraType = (typeof ThreeCameraType)[keyof typeof ThreeCameraType];
9
+
10
+ interface CameraOptionsBase {
11
+ near?: number;
12
+ far?: number;
13
+ }
14
+
15
+ interface PerspectiveCameraOptions extends CameraOptionsBase {
16
+ type: typeof ThreeCameraType.PERSPECTIVE;
17
+ fov?: number;
18
+ aspect?: number;
19
+ }
20
+
21
+ interface OrthographicCameraOptions extends CameraOptionsBase {
22
+ type: typeof ThreeCameraType.ORTHOGRAPHIC;
23
+ left: number;
24
+ right: number;
25
+ top: number;
26
+ bottom: number;
27
+ }
28
+
29
+ export type ThreeCameraOptions = PerspectiveCameraOptions | OrthographicCameraOptions;
30
+
31
+ export interface ThreeControls {
32
+ enabled: boolean;
33
+ update(delta?: number): void;
34
+ dispose(): void;
35
+ }
36
+ //
37
+ //#endregion
@@ -0,0 +1,9 @@
1
+ import { MainThreeApp } from '../engines/threes/app/MainThreeApp';
2
+
3
+ declare global {
4
+ interface Window {
5
+ mainThreeApp: MainThreeApp;
6
+ }
7
+ }
8
+
9
+ export {};
@@ -0,0 +1,4 @@
1
+ declare module '*.glsl' {
2
+ const value: string;
3
+ export default value;
4
+ }
@@ -0,0 +1,49 @@
1
+ import { Object3D } from 'three';
2
+ import { ViewId } from '../../../constants/experiences/ViewId';
3
+ import type ThreeActorBase from './components/ThreeActorBase';
4
+
5
+ export default abstract class ThreeViewBase extends Object3D {
6
+ private readonly _id: ViewId;
7
+ protected readonly _actors: ThreeActorBase[];
8
+ private _areActorsGenerated = false;
9
+
10
+ constructor(id: ViewId) {
11
+ super();
12
+ this._id = id;
13
+ this._actors = [];
14
+ }
15
+
16
+ public declareAssets(): void {
17
+ //
18
+ }
19
+
20
+ public init(): void {
21
+ if (!this._areActorsGenerated) this._generateActors();
22
+ this.reset();
23
+ for (const actor of this._actors) actor.init();
24
+ }
25
+
26
+ public reset(): void {
27
+ for (const actor of this._actors) actor.reset();
28
+ }
29
+
30
+ protected _generateActors(): void {
31
+ this._areActorsGenerated = true;
32
+ }
33
+
34
+ public dispose(): void {
35
+ for (const actor of this._actors) {
36
+ actor.dispose();
37
+ }
38
+ }
39
+
40
+ public update(_dt: number): void {
41
+ //
42
+ }
43
+
44
+ //#region Getters
45
+ //
46
+ public get viewId(): ViewId { return this._id; }
47
+ //
48
+ //#endregion
49
+ }
@@ -0,0 +1,44 @@
1
+ import { BufferGeometry, Material, Mesh, Object3D, Texture } from 'three';
2
+
3
+ export default abstract class ThreeActorBase extends Object3D {
4
+ constructor() {
5
+ super();
6
+ }
7
+
8
+ public init(): void {
9
+ this.reset();
10
+ }
11
+
12
+ public reset(): void {
13
+ //
14
+ }
15
+
16
+ public dispose(): void {
17
+ const geometries = new Set<BufferGeometry>();
18
+ const materials = new Set<Material>();
19
+ const textures = new Set<Texture>();
20
+
21
+ this.traverse((child) => {
22
+ if (child instanceof Mesh) {
23
+ if (child.geometry instanceof BufferGeometry) geometries.add(child.geometry as BufferGeometry);
24
+
25
+ const mats = Array.isArray(child.material) ? child.material : [child.material];
26
+ mats.forEach((mat) => {
27
+ if (mat instanceof Material) {
28
+ materials.add(mat);
29
+
30
+ Object.values(mat).forEach((value) => {
31
+ if (value instanceof Texture) textures.add(value);
32
+ });
33
+ }
34
+ });
35
+ }
36
+ });
37
+
38
+ textures.forEach((tex) => tex.dispose());
39
+ materials.forEach((mat) => mat.dispose());
40
+ geometries.forEach((geo) => geo.dispose());
41
+ }
42
+
43
+ public update(_dt: number): void { }
44
+ }
@@ -0,0 +1,63 @@
1
+ import { AnimationAction, AnimationMixer } from 'three';
2
+ import type { AnimationId } from '../../../../constants/experiences/AnimationId';
3
+ import type { AssetId } from '../../../../constants/experiences/AssetId';
4
+ import ThreeAssetsManager from '../../../../managers/threes/ThreeAssetsManager';
5
+ import ThreeModelBase, { type ModelBaseParams } from './ThreeModelBase';
6
+
7
+ export default abstract class ThreeAnimatedModelBase extends ThreeModelBase {
8
+ private static readonly _DEFAULT_ANIMATION_FADE_DURATION: number = 1;
9
+
10
+ declare private _mixer: AnimationMixer;
11
+ declare private _actions: AnimationAction[];
12
+ declare private _currentAction: AnimationAction | null;
13
+
14
+ constructor(assetId: AssetId, params: ModelBaseParams = {}) {
15
+ super(assetId, params);
16
+
17
+ this._generateAnimations();
18
+ }
19
+
20
+ protected _generateAnimations(): void {
21
+ const animations = ThreeAssetsManager.getModel(this._assetId).animations;
22
+ this._mixer = new AnimationMixer(this._model);
23
+ this._actions = [];
24
+ this._currentAction = null;
25
+
26
+ for (const clip of animations) {
27
+ const action = this._mixer.clipAction(clip);
28
+ this._addAnimationAction(action);
29
+ }
30
+ }
31
+
32
+ private _addAnimationAction(action: AnimationAction): void {
33
+ this._actions.push(action);
34
+ }
35
+
36
+ protected _playAnimation = (
37
+ animationId: AnimationId,
38
+ fadeDuration: number = ThreeAnimatedModelBase._DEFAULT_ANIMATION_FADE_DURATION
39
+ ): void => {
40
+ if (!this._actions) return;
41
+ const newAction = this._getAnimationAction(animationId);
42
+ const oldAction = this._currentAction ?? null;
43
+
44
+ newAction.reset();
45
+ newAction.play();
46
+ if (oldAction) newAction.crossFadeFrom(oldAction, fadeDuration);
47
+ this._currentAction = newAction;
48
+ };
49
+
50
+ private _getAnimationAction = (animationId: AnimationId): AnimationAction => {
51
+ for (const action of this._actions) {
52
+ if (action.getClip().name === animationId) {
53
+ return action;
54
+ }
55
+ }
56
+ throw new Error(`Animation action not found for animationId: ${animationId}`);
57
+ };
58
+
59
+ public update(dt: number): void {
60
+ super.update(dt);
61
+ if (this._mixer) this._mixer.update(dt);
62
+ }
63
+ }