@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.
Files changed (60) hide show
  1. package/package.json +1 -1
  2. package/template-react/package-lock.json +2 -2
  3. package/template-react/package.json +1 -1
  4. package/template-react/src/App.css +21 -21
  5. package/template-react/src/App.tsx +5 -9
  6. package/template-react/src/index.css +42 -42
  7. package/template-react/src/main.tsx +8 -8
  8. package/template-vanilla/index.html +23 -14
  9. package/template-vanilla/package-lock.json +8 -6
  10. package/template-vanilla/package.json +2 -2
  11. package/template-vanilla/src/experiences/Experience.ts +11 -11
  12. package/template-vanilla/src/experiences/cameras/threes/DebugThreeCameraController.ts +13 -18
  13. package/template-vanilla/src/experiences/cameras/threes/LoaderThreeCameraController.ts +7 -10
  14. package/template-vanilla/src/experiences/cameras/threes/MainThreeCameraController.ts +6 -10
  15. package/template-vanilla/src/experiences/cameras/threes/bases/ThreeCameraControllerBase.ts +20 -39
  16. package/template-vanilla/src/experiences/commands/InitCommand.ts +30 -33
  17. package/template-vanilla/src/experiences/engines/htmls/MainHTML.ts +10 -7
  18. package/template-vanilla/src/experiences/engines/threes/MainThree.ts +8 -168
  19. package/template-vanilla/src/experiences/engines/threes/app/LoaderThreeApp.ts +39 -0
  20. package/template-vanilla/src/experiences/engines/threes/app/MainThreeApp.ts +96 -0
  21. package/template-vanilla/src/experiences/engines/threes/app/bases/ThreeAppBase.ts +92 -0
  22. package/template-vanilla/src/experiences/managers/DebugManager.ts +31 -33
  23. package/template-vanilla/src/experiences/managers/LoaderManager.ts +53 -45
  24. package/template-vanilla/src/experiences/managers/threes/ThreeAssetsManager.ts +94 -109
  25. package/template-vanilla/src/experiences/managers/threes/ThreeCameraControllerManager.ts +22 -19
  26. package/template-vanilla/src/experiences/managers/threes/ThreeRaycasterManager.ts +12 -14
  27. package/template-vanilla/src/experiences/materials/threes/loaders/LoaderMaterial.ts +0 -4
  28. package/template-vanilla/src/experiences/renderers/threes/LoaderRenderer.ts +0 -4
  29. package/template-vanilla/src/experiences/renderers/threes/Renderer.ts +5 -9
  30. package/template-vanilla/src/experiences/renderers/threes/bases/WebGLRendererBase.ts +3 -3
  31. package/template-vanilla/src/experiences/styles/commons/main.scss +6 -6
  32. package/template-vanilla/src/experiences/styles/style.scss +1 -1
  33. package/template-vanilla/src/experiences/styles/views/loader.scss +7 -6
  34. package/template-vanilla/src/experiences/types/cameraTypes.ts +37 -0
  35. package/template-vanilla/src/experiences/types/global.d.ts +2 -2
  36. package/template-vanilla/src/experiences/types/shaders.d.ts +4 -0
  37. package/template-vanilla/src/experiences/views/htmls/bases/HTMLViewBase.ts +13 -33
  38. package/template-vanilla/src/experiences/views/htmls/loaders/LoaderHTMLView.ts +27 -18
  39. package/template-vanilla/src/experiences/views/threes/bases/ThreeViewBase.ts +26 -18
  40. package/template-vanilla/src/experiences/views/threes/loaders/LoaderThreeView.ts +11 -15
  41. package/template-vanilla/src/experiences/views/threes/loaders/components/ThreeTemplateLoader.ts +15 -12
  42. package/template-vanilla/src/experiences/views/threes/worlds/WorldThreeView.ts +9 -17
  43. package/template-vanilla/src/experiences/views/threes/worlds/components/Environment.ts +14 -18
  44. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateFont.ts +11 -9
  45. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateMesh.ts +11 -9
  46. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateModel.ts +2 -6
  47. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ActorBase.ts +13 -1
  48. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/AnimatedModelBase.ts +5 -9
  49. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ModelBase.ts +18 -4
  50. package/template-vanilla/src/main.ts +1 -1
  51. package/template-vanilla/tsconfig.json +17 -0
  52. package/template-vanilla/src/experiences/constants/experiences/CameraType.ts +0 -6
  53. package/template-vanilla/src/experiences/managers/KeyboardManager.ts +0 -65
  54. package/template-vanilla/src/experiences/managers/MouseManager.ts +0 -100
  55. package/template-vanilla/src/experiences/managers/ResizeManager.ts +0 -53
  56. package/template-vanilla/src/experiences/managers/TickerManager.ts +0 -86
  57. package/template-vanilla/src/experiences/proxies/ViewProxy.ts +0 -45
  58. package/template-vanilla/src/experiences/views/bases/ViewBase.ts +0 -36
  59. package/template-vanilla/src/experiences/views/htmls/loaders/components/HTMLTemplateLoader.ts +0 -57
  60. /package/template-vanilla/src/experiences/{constants/experiences/AssetType.ts → types/assetTypes.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benjos/create-boilerplate",
3
- "version": "1.3.5",
3
+ "version": "1.4.1",
4
4
  "description": "CLI to scaffold Three.js projects with framework support",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "template-react",
3
- "version": "1.3.5",
3
+ "version": "1.4.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "template-react",
9
- "version": "1.3.5",
9
+ "version": "1.4.1",
10
10
  "dependencies": {
11
11
  "@dimforge/rapier3d": "^0.19.3",
12
12
  "gsap": "^3.14.2",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "template-react",
3
3
  "private": true,
4
- "version": "1.3.5",
4
+ "version": "1.4.1",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -1,42 +1,42 @@
1
1
  #root {
2
- max-width: 1280px;
3
- margin: 0 auto;
4
- padding: 2rem;
5
- text-align: center;
2
+ max-width: 1280px;
3
+ margin: 0 auto;
4
+ padding: 2rem;
5
+ text-align: center;
6
6
  }
7
7
 
8
8
  .logo {
9
- height: 6em;
10
- padding: 1.5em;
11
- will-change: filter;
12
- transition: filter 300ms;
9
+ height: 6em;
10
+ padding: 1.5em;
11
+ will-change: filter;
12
+ transition: filter 300ms;
13
13
  }
14
14
  .logo:hover {
15
- filter: drop-shadow(0 0 2em #646cffaa);
15
+ filter: drop-shadow(0 0 2em #646cffaa);
16
16
  }
17
17
  .logo.react:hover {
18
- filter: drop-shadow(0 0 2em #61dafbaa);
18
+ filter: drop-shadow(0 0 2em #61dafbaa);
19
19
  }
20
20
 
21
21
  @keyframes logo-spin {
22
- from {
23
- transform: rotate(0deg);
24
- }
25
- to {
26
- transform: rotate(360deg);
27
- }
22
+ from {
23
+ transform: rotate(0deg);
24
+ }
25
+ to {
26
+ transform: rotate(360deg);
27
+ }
28
28
  }
29
29
 
30
30
  @media (prefers-reduced-motion: no-preference) {
31
- a:nth-of-type(2) .logo {
32
- animation: logo-spin infinite 20s linear;
33
- }
31
+ a:nth-of-type(2) .logo {
32
+ animation: logo-spin infinite 20s linear;
33
+ }
34
34
  }
35
35
 
36
36
  .card {
37
- padding: 2em;
37
+ padding: 2em;
38
38
  }
39
39
 
40
40
  .read-the-docs {
41
- color: #888;
41
+ color: #888;
42
42
  }
@@ -1,14 +1,10 @@
1
- import { useState } from 'react'
2
- import './App.css'
1
+ import { useState } from 'react';
2
+ import './App.css';
3
3
 
4
4
  function App() {
5
- const [count, setCount] = useState(0)
5
+ const [count, setCount] = useState(0);
6
6
 
7
- return (
8
- <>
9
- Hello boilerplate react!
10
- </>
11
- )
7
+ return <>Hello boilerplate react!</>;
12
8
  }
13
9
 
14
- export default App
10
+ export default App;
@@ -1,68 +1,68 @@
1
1
  :root {
2
- font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
3
- line-height: 1.5;
4
- font-weight: 400;
2
+ font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
5
 
6
- color-scheme: light dark;
7
- color: rgba(255, 255, 255, 0.87);
8
- background-color: #242424;
6
+ color-scheme: light dark;
7
+ color: rgba(255, 255, 255, 0.87);
8
+ background-color: #242424;
9
9
 
10
- font-synthesis: none;
11
- text-rendering: optimizeLegibility;
12
- -webkit-font-smoothing: antialiased;
13
- -moz-osx-font-smoothing: grayscale;
10
+ font-synthesis: none;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
14
  }
15
15
 
16
16
  a {
17
- font-weight: 500;
18
- color: #646cff;
19
- text-decoration: inherit;
17
+ font-weight: 500;
18
+ color: #646cff;
19
+ text-decoration: inherit;
20
20
  }
21
21
  a:hover {
22
- color: #535bf2;
22
+ color: #535bf2;
23
23
  }
24
24
 
25
25
  body {
26
- margin: 0;
27
- display: flex;
28
- place-items: center;
29
- min-width: 320px;
30
- min-height: 100vh;
26
+ margin: 0;
27
+ display: flex;
28
+ place-items: center;
29
+ min-width: 320px;
30
+ min-height: 100vh;
31
31
  }
32
32
 
33
33
  h1 {
34
- font-size: 3.2em;
35
- line-height: 1.1;
34
+ font-size: 3.2em;
35
+ line-height: 1.1;
36
36
  }
37
37
 
38
38
  button {
39
- border-radius: 8px;
40
- border: 1px solid transparent;
41
- padding: 0.6em 1.2em;
42
- font-size: 1em;
43
- font-weight: 500;
44
- font-family: inherit;
45
- background-color: #1a1a1a;
46
- cursor: pointer;
47
- transition: border-color 0.25s;
39
+ border-radius: 8px;
40
+ border: 1px solid transparent;
41
+ padding: 0.6em 1.2em;
42
+ font-size: 1em;
43
+ font-weight: 500;
44
+ font-family: inherit;
45
+ background-color: #1a1a1a;
46
+ cursor: pointer;
47
+ transition: border-color 0.25s;
48
48
  }
49
49
  button:hover {
50
- border-color: #646cff;
50
+ border-color: #646cff;
51
51
  }
52
52
  button:focus,
53
53
  button:focus-visible {
54
- outline: 4px auto -webkit-focus-ring-color;
54
+ outline: 4px auto -webkit-focus-ring-color;
55
55
  }
56
56
 
57
57
  @media (prefers-color-scheme: light) {
58
- :root {
59
- color: #213547;
60
- background-color: #ffffff;
61
- }
62
- a:hover {
63
- color: #747bff;
64
- }
65
- button {
66
- background-color: #f9f9f9;
67
- }
58
+ :root {
59
+ color: #213547;
60
+ background-color: #ffffff;
61
+ }
62
+ a:hover {
63
+ color: #747bff;
64
+ }
65
+ button {
66
+ background-color: #f9f9f9;
67
+ }
68
68
  }
@@ -1,10 +1,10 @@
1
- import { StrictMode } from 'react'
2
- import { createRoot } from 'react-dom/client'
3
- import './index.css'
4
- import App from './App.tsx'
1
+ import { StrictMode } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import './index.css';
4
+ import App from './App.tsx';
5
5
 
6
6
  createRoot(document.getElementById('root')!).render(
7
- <StrictMode>
8
- <App />
9
- </StrictMode>,
10
- )
7
+ <StrictMode>
8
+ <App />
9
+ </StrictMode>
10
+ );
@@ -1,17 +1,26 @@
1
1
  <!doctype html>
2
2
  <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="./assets/icons/benjosLogoBlack.svg" />
6
- <meta
7
- name="viewport"
8
- content="width=device-width, initial-scale=1.0, maximum-scale=1, minimum-scale=1, height=device-height, user-scalable=no, viewport-fit=cover, shrink-to-fit=no, minimal-ui"
9
- />
10
- <title>Boilerplate</title>
11
- </head>
12
3
 
13
- <body>
14
- <div id="app"></div>
15
- <script type="module" src="/src/main.ts"></script>
16
- </body>
17
- </html>
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <link rel="icon" type="image/svg+xml" href="./assets/icons/benjosLogoBlack.svg" />
7
+ <meta name="viewport"
8
+ content="width=device-width, initial-scale=1.0, maximum-scale=1, minimum-scale=1, height=device-height, user-scalable=no, viewport-fit=cover, shrink-to-fit=no, minimal-ui" />
9
+ <title>Boilerplate</title>
10
+ </head>
11
+
12
+ <body>
13
+ <div id="app">
14
+ <div id="loader">
15
+ <div id="loading-screen" class="html-view loading-screen">
16
+ <div class="loading-progress">
17
+ <span class="loading-number">0</span><span>%</span>
18
+ </div>
19
+ <div class="loading-bar"></div>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ <script type="module" src="/src/main.ts"></script>
24
+ </body>
25
+
26
+ </html>
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "template-vanilla",
3
- "version": "1.3.5",
3
+ "version": "1.4.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "template-vanilla",
9
- "version": "1.3.5",
9
+ "version": "1.4.1",
10
10
  "dependencies": {
11
- "@benjos/cookware": "^1.0.0",
11
+ "@benjos/cookware": "^1.0.4",
12
12
  "@benjos/spices": "^1.0.1",
13
13
  "@dimforge/rapier3d": "^0.19.3",
14
14
  "gsap": "^3.14.2",
@@ -33,11 +33,12 @@
33
33
  }
34
34
  },
35
35
  "node_modules/@benjos/cookware": {
36
- "version": "1.0.0",
37
- "resolved": "https://registry.npmjs.org/@benjos/cookware/-/cookware-1.0.0.tgz",
38
- "integrity": "sha512-7l0EOcJ9WlaOxWaCkqHXB685u6zJyzjHOqOH87k6UIBpqi+LlJcg4d8qRaLFIJ9bxD74bxox52uAD7bvg2j1fA==",
36
+ "version": "1.0.4",
37
+ "resolved": "https://registry.npmjs.org/@benjos/cookware/-/cookware-1.0.4.tgz",
38
+ "integrity": "sha512-JlhZD6p2mgIbyq4S9syqrPAYkCDuRazA2EEd+WYVlfzo13/2M5awlPaD7kuT+yXdkpWniqQBQyVjD/uFZXxPkA==",
39
39
  "license": "ISC",
40
40
  "peerDependencies": {
41
+ "@benjos/spices": "^1.0.1",
41
42
  "typescript": ">=5.0.0"
42
43
  }
43
44
  },
@@ -46,6 +47,7 @@
46
47
  "resolved": "https://registry.npmjs.org/@benjos/spices/-/spices-1.0.1.tgz",
47
48
  "integrity": "sha512-vAdmCm5xmoG9iaS4S4hHe7eyQTeKOkWIUa6RaXzk3SUW12G5hecgnPnSeBT1CWdR5hk2E0cgNAvvwG45ctpyrQ==",
48
49
  "license": "ISC",
50
+ "peer": true,
49
51
  "peerDependencies": {
50
52
  "typescript": ">=5.0.0"
51
53
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "template-vanilla",
3
3
  "private": true,
4
- "version": "1.3.5",
4
+ "version": "1.4.1",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -28,7 +28,7 @@
28
28
  "vite-plugin-glsl": "^1.5.5"
29
29
  },
30
30
  "dependencies": {
31
- "@benjos/cookware": "^1.0.0",
31
+ "@benjos/cookware": "^1.0.4",
32
32
  "@benjos/spices": "^1.0.1",
33
33
  "@dimforge/rapier3d": "^0.19.3",
34
34
  "gsap": "^3.14.2",
@@ -5,18 +5,18 @@ import MainHTML from './engines/htmls/MainHTML';
5
5
  import MainThree from './engines/threes/MainThree';
6
6
  import LoaderManager from './managers/LoaderManager';
7
7
 
8
- export default class Experience {
9
- private static _isInitialized = false;
8
+ class Experience {
9
+ private _isInitialized: boolean = false;
10
10
 
11
- public static Init(): void {
12
- if (Experience._isInitialized) {
13
- return;
14
- }
15
- Experience._isInitialized = true;
11
+ public init(): void {
12
+ if (this._isInitialized) return;
13
+ this._isInitialized = true;
16
14
 
17
- InitCommand.Init();
18
- MainHTML.Init();
19
- MainThree.Init();
20
- void LoaderManager.LoadAllAssets();
15
+ InitCommand.init();
16
+ MainHTML.init();
17
+ MainThree.init();
18
+ LoaderManager.loadAllAssets();
21
19
  }
22
20
  }
21
+
22
+ export default new Experience();
@@ -1,19 +1,16 @@
1
+ import { DomKeyboardManager, DomPointerManager } from '@benjos/cookware';
1
2
  import { KeyboardConstant } from '@benjos/spices';
2
3
  import { Vector3 } from 'three';
3
4
  import { OrbitControls } from 'three/examples/jsm/Addons.js';
4
5
  import { CameraId } from '../../constants/experiences/CameraId';
5
- import { CameraType } from '../../constants/experiences/CameraType';
6
- import MainThree from '../../engines/threes/MainThree';
7
- import { KeyboardManager } from '../../managers/KeyboardManager';
8
- import MouseManager from '../../managers/MouseManager';
6
+ import MainThreeApp from '../../engines/threes/app/MainThreeApp';
9
7
  import ThreeRaycasterManager from '../../managers/threes/ThreeRaycasterManager';
10
- import ThreeCameraControllerBase, { type IThreeCameraOptions } from './bases/ThreeCameraControllerBase';
8
+ import { ThreeCameraOptions, ThreeCameraType } from '../../types/cameraTypes';
9
+ import ThreeCameraControllerBase from './bases/ThreeCameraControllerBase';
11
10
 
12
11
  export default class DebugThreeCameraController extends ThreeCameraControllerBase<OrbitControls> {
13
- //#region Constants
14
- //
15
- private static readonly _DEBUG_CAMERA_OPTIONS: IThreeCameraOptions = {
16
- type: CameraType.PERSPECTIVE,
12
+ private static readonly _DEBUG_CAMERA_OPTIONS: ThreeCameraOptions = {
13
+ type: ThreeCameraType.PERSPECTIVE,
17
14
  fov: 75,
18
15
  aspect: window.innerWidth / window.innerHeight,
19
16
  near: 0.1,
@@ -22,11 +19,9 @@ export default class DebugThreeCameraController extends ThreeCameraControllerBas
22
19
  private static readonly _DEFAULT_CAMERA_POSITION: Vector3 = new Vector3(0, 1.5, 3);
23
20
  private static readonly _CONTROLS_DAMPING_FACTOR: number = 0.05;
24
21
  private static readonly _CONTROLS_CENTER_KEY: string = KeyboardConstant.CODES.CONTROL_LEFT;
25
- //
26
- //#endregion
27
22
 
28
- constructor(cameraOption: IThreeCameraOptions = DebugThreeCameraController._DEBUG_CAMERA_OPTIONS) {
29
- super(CameraId.THREE_DEBUG, cameraOption);
23
+ constructor() {
24
+ super(CameraId.THREE_DEBUG, DebugThreeCameraController._DEBUG_CAMERA_OPTIONS);
30
25
  this._camera.position.copy(DebugThreeCameraController._DEFAULT_CAMERA_POSITION);
31
26
  this._setControls();
32
27
  this.disable();
@@ -34,23 +29,23 @@ export default class DebugThreeCameraController extends ThreeCameraControllerBas
34
29
 
35
30
  public override enable(): void {
36
31
  super.enable();
37
- MouseManager.OnMouseDown.add(this._onMouseDown);
32
+ DomPointerManager.onPointerDown.add(this._onMouseDown);
38
33
  }
39
34
 
40
35
  public override disable(): void {
41
36
  super.disable();
42
- MouseManager.OnMouseDown.remove(this._onMouseDown);
37
+ DomPointerManager.onPointerDown.remove(this._onMouseDown);
43
38
  }
44
39
 
45
40
  private _setControls(): void {
46
- this._controls = new OrbitControls(this._camera, MainThree.DomElementContainer);
41
+ this._controls = new OrbitControls(this._camera, MainThreeApp.domElementContainer);
47
42
  this._controls.enableDamping = true;
48
43
  this._controls.dampingFactor = DebugThreeCameraController._CONTROLS_DAMPING_FACTOR;
49
44
  }
50
45
 
51
46
  private readonly _onMouseDown = (): void => {
52
- if (KeyboardManager.IsKeyDown(DebugThreeCameraController._CONTROLS_CENTER_KEY)) {
53
- const intersect = ThreeRaycasterManager.CastFromCameraToMouse(MainThree.Scene.children);
47
+ if (DomKeyboardManager.isKeyDown(DebugThreeCameraController._CONTROLS_CENTER_KEY)) {
48
+ const intersect = ThreeRaycasterManager.castFromCameraToPointer(MainThreeApp.scene.children);
54
49
  if (intersect.length > 0) {
55
50
  this._controls.target.copy(intersect[0].point);
56
51
  this._controls.update();
@@ -1,24 +1,21 @@
1
1
  import { Vector3 } from 'three';
2
2
  import { CameraId } from '../../constants/experiences/CameraId';
3
- import { CameraType } from '../../constants/experiences/CameraType';
4
- import ThreeCameraControllerBase, { type IThreeCameraOptions } from './bases/ThreeCameraControllerBase';
3
+ import LoaderThreeApp from '../../engines/threes/app/LoaderThreeApp';
4
+ import { ThreeCameraOptions, ThreeCameraType } from '../../types/cameraTypes';
5
+ import ThreeCameraControllerBase from './bases/ThreeCameraControllerBase';
5
6
 
6
7
  export default class LoaderThreeCameraController extends ThreeCameraControllerBase {
7
- //#region Constants
8
- //
9
- private static readonly _LOADER_CAMERA_OPTIONS: IThreeCameraOptions = {
10
- type: CameraType.PERSPECTIVE,
8
+ private static readonly _LOADER_CAMERA_OPTIONS: ThreeCameraOptions = {
9
+ type: ThreeCameraType.PERSPECTIVE,
11
10
  fov: 75,
12
11
  aspect: window.innerWidth / window.innerHeight,
13
12
  near: 0.1,
14
13
  far: 1,
15
14
  };
16
15
  private static readonly _DEFAULT_CONTAINER_POSITION: Vector3 = new Vector3(0, 0, 0);
17
- //
18
- //#endregion
19
16
 
20
- constructor(cameraOption: IThreeCameraOptions = LoaderThreeCameraController._LOADER_CAMERA_OPTIONS) {
21
- super(CameraId.THREE_LOADER, cameraOption);
17
+ constructor() {
18
+ super(CameraId.THREE_LOADER, LoaderThreeCameraController._LOADER_CAMERA_OPTIONS, LoaderThreeApp.scene);
22
19
  this._container.position.copy(LoaderThreeCameraController._DEFAULT_CONTAINER_POSITION);
23
20
  }
24
21
 
@@ -1,24 +1,20 @@
1
1
  import { Vector3 } from 'three';
2
2
  import { CameraId } from '../../constants/experiences/CameraId';
3
- import { CameraType } from '../../constants/experiences/CameraType';
4
- import ThreeCameraControllerBase, { type IThreeCameraOptions } from './bases/ThreeCameraControllerBase';
3
+ import { ThreeCameraOptions, ThreeCameraType } from '../../types/cameraTypes';
4
+ import ThreeCameraControllerBase from './bases/ThreeCameraControllerBase';
5
5
 
6
6
  export default class MainThreeCameraController extends ThreeCameraControllerBase {
7
- //#region Constants
8
- //
9
- private static readonly _MAIN_CAMERA_OPTIONS: IThreeCameraOptions = {
10
- type: CameraType.PERSPECTIVE,
7
+ private static readonly _MAIN_CAMERA_OPTIONS: ThreeCameraOptions = {
8
+ type: ThreeCameraType.PERSPECTIVE,
11
9
  fov: 75,
12
10
  aspect: window.innerWidth / window.innerHeight,
13
11
  near: 0.1,
14
12
  far: 1000,
15
13
  };
16
14
  private static readonly _DEFAULT_CONTAINER_POSITION: Vector3 = new Vector3(0, 1.5, 3);
17
- //
18
- //#endregion
19
15
 
20
- constructor(cameraOption: IThreeCameraOptions = MainThreeCameraController._MAIN_CAMERA_OPTIONS) {
21
- super(CameraId.THREE_MAIN, cameraOption);
16
+ constructor() {
17
+ super(CameraId.THREE_MAIN, MainThreeCameraController._MAIN_CAMERA_OPTIONS);
22
18
  this._container.position.copy(MainThreeCameraController._DEFAULT_CONTAINER_POSITION);
23
19
  }
24
20
 
@@ -1,48 +1,27 @@
1
- import { Object3D, OrthographicCamera, PerspectiveCamera } from 'three';
1
+ import { DomResizeManager } from '@benjos/cookware';
2
+ import { Object3D, OrthographicCamera, PerspectiveCamera, Scene } from 'three';
2
3
  import type { CameraId } from '../../../constants/experiences/CameraId';
3
- import { CameraType } from '../../../constants/experiences/CameraType';
4
- import MainThree from '../../../engines/threes/MainThree';
5
- import { ResizeManager } from '../../../managers/ResizeManager';
4
+ import MainThreeApp from '../../../engines/threes/app/MainThreeApp';
5
+ import { ThreeCameraOptions, ThreeCameraType, ThreeControls } from '../../../types/cameraTypes';
6
6
 
7
- export interface IThreeCameraOptions {
8
- type: CameraType;
9
- fov?: number;
10
- aspect?: number;
11
- near?: number;
12
- far?: number;
13
- left?: number;
14
- right?: number;
15
- top?: number;
16
- bottom?: number;
17
- }
18
-
19
- export interface IThreeControls {
20
- update(delta?: number): void;
21
- enabled: boolean;
22
- dispose(): void;
23
- }
24
-
25
- export default abstract class ThreeCameraControllerBase<T extends IThreeControls = IThreeControls> extends Object3D {
26
- protected readonly _cameraId: CameraId;
27
- declare protected _camera: PerspectiveCamera | OrthographicCamera;
28
- declare protected _container: Object3D;
29
- declare protected _controls: T;
30
-
31
- //#region Constants
32
- //
33
- private static readonly _DEFAULT_CAMERA_OPTIONS: IThreeCameraOptions = {
34
- type: CameraType.PERSPECTIVE,
7
+ export default abstract class ThreeCameraControllerBase<T extends ThreeControls = ThreeControls> extends Object3D {
8
+ private static readonly _DEFAULT_CAMERA_OPTIONS: ThreeCameraOptions = {
9
+ type: ThreeCameraType.PERSPECTIVE,
35
10
  fov: 75,
36
11
  aspect: window.innerWidth / window.innerHeight,
37
12
  near: 0.1,
38
13
  far: 1000,
39
14
  };
40
- //
41
- //#endregion
15
+
16
+ protected readonly _cameraId: CameraId;
17
+ declare protected _camera: PerspectiveCamera | OrthographicCamera;
18
+ declare protected _container: Object3D;
19
+ declare protected _controls: T;
42
20
 
43
21
  constructor(
44
22
  cameraId: CameraId,
45
- cameraOptions: IThreeCameraOptions = ThreeCameraControllerBase._DEFAULT_CAMERA_OPTIONS
23
+ cameraOptions: ThreeCameraOptions = ThreeCameraControllerBase._DEFAULT_CAMERA_OPTIONS,
24
+ scene: Scene = MainThreeApp.scene
46
25
  ) {
47
26
  super();
48
27
  this._cameraId = cameraId;
@@ -50,7 +29,7 @@ export default abstract class ThreeCameraControllerBase<T extends IThreeControls
50
29
  this._generateContainer();
51
30
  this._generateCamera(cameraOptions);
52
31
 
53
- MainThree.Scene.add(this);
32
+ scene.add(this);
54
33
  }
55
34
 
56
35
  private _generateContainer(): void {
@@ -58,8 +37,8 @@ export default abstract class ThreeCameraControllerBase<T extends IThreeControls
58
37
  this.add(this._container);
59
38
  }
60
39
 
61
- private _generateCamera(cameraOptions: IThreeCameraOptions): void {
62
- if (cameraOptions.type === CameraType.PERSPECTIVE) {
40
+ private _generateCamera(cameraOptions: ThreeCameraOptions): void {
41
+ if (cameraOptions.type === ThreeCameraType.PERSPECTIVE) {
63
42
  this._camera = new PerspectiveCamera(
64
43
  cameraOptions.fov,
65
44
  cameraOptions.aspect,
@@ -88,7 +67,9 @@ export default abstract class ThreeCameraControllerBase<T extends IThreeControls
88
67
  }
89
68
 
90
69
  public resize(): void {
91
- if (this._camera instanceof PerspectiveCamera) this._camera.aspect = ResizeManager.Width / ResizeManager.Height;
70
+ if (this._camera instanceof PerspectiveCamera) {
71
+ this._camera.aspect = DomResizeManager.width / DomResizeManager.height;
72
+ }
92
73
  this._camera.updateProjectionMatrix();
93
74
  }
94
75