@benjos/create-boilerplate 1.3.5 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template-react/package-lock.json +2 -2
- package/template-react/package.json +1 -1
- package/template-react/src/App.css +21 -21
- package/template-react/src/App.tsx +5 -9
- package/template-react/src/index.css +42 -42
- package/template-react/src/main.tsx +8 -8
- package/template-vanilla/index.html +23 -14
- package/template-vanilla/package-lock.json +8 -6
- package/template-vanilla/package.json +2 -2
- package/template-vanilla/src/experiences/Experience.ts +11 -11
- package/template-vanilla/src/experiences/cameras/threes/DebugThreeCameraController.ts +13 -18
- package/template-vanilla/src/experiences/cameras/threes/LoaderThreeCameraController.ts +7 -10
- package/template-vanilla/src/experiences/cameras/threes/MainThreeCameraController.ts +6 -10
- package/template-vanilla/src/experiences/cameras/threes/bases/ThreeCameraControllerBase.ts +20 -39
- package/template-vanilla/src/experiences/commands/InitCommand.ts +30 -33
- package/template-vanilla/src/experiences/engines/htmls/MainHTML.ts +10 -7
- package/template-vanilla/src/experiences/engines/threes/MainThree.ts +8 -168
- package/template-vanilla/src/experiences/engines/threes/app/LoaderThreeApp.ts +39 -0
- package/template-vanilla/src/experiences/engines/threes/app/MainThreeApp.ts +96 -0
- package/template-vanilla/src/experiences/engines/threes/app/bases/ThreeAppBase.ts +92 -0
- package/template-vanilla/src/experiences/managers/DebugManager.ts +31 -33
- package/template-vanilla/src/experiences/managers/LoaderManager.ts +53 -45
- package/template-vanilla/src/experiences/managers/threes/ThreeAssetsManager.ts +94 -109
- package/template-vanilla/src/experiences/managers/threes/ThreeCameraControllerManager.ts +22 -19
- package/template-vanilla/src/experiences/managers/threes/ThreeRaycasterManager.ts +12 -14
- package/template-vanilla/src/experiences/materials/threes/loaders/LoaderMaterial.ts +0 -4
- package/template-vanilla/src/experiences/renderers/threes/LoaderRenderer.ts +0 -4
- package/template-vanilla/src/experiences/renderers/threes/Renderer.ts +5 -9
- package/template-vanilla/src/experiences/renderers/threes/bases/WebGLRendererBase.ts +3 -3
- package/template-vanilla/src/experiences/styles/commons/main.scss +6 -6
- package/template-vanilla/src/experiences/styles/style.scss +1 -1
- package/template-vanilla/src/experiences/styles/views/loader.scss +7 -6
- package/template-vanilla/src/experiences/types/cameraTypes.ts +37 -0
- package/template-vanilla/src/experiences/types/global.d.ts +2 -2
- package/template-vanilla/src/experiences/types/shaders.d.ts +4 -0
- package/template-vanilla/src/experiences/views/htmls/bases/HTMLViewBase.ts +13 -33
- package/template-vanilla/src/experiences/views/htmls/loaders/LoaderHTMLView.ts +27 -18
- package/template-vanilla/src/experiences/views/threes/bases/ThreeViewBase.ts +26 -18
- package/template-vanilla/src/experiences/views/threes/loaders/LoaderThreeView.ts +11 -15
- package/template-vanilla/src/experiences/views/threes/loaders/components/ThreeTemplateLoader.ts +15 -12
- package/template-vanilla/src/experiences/views/threes/worlds/WorldThreeView.ts +9 -17
- package/template-vanilla/src/experiences/views/threes/worlds/components/Environment.ts +14 -18
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateFont.ts +11 -9
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateMesh.ts +11 -9
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateModel.ts +2 -6
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ActorBase.ts +13 -1
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/AnimatedModelBase.ts +5 -9
- package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ModelBase.ts +18 -4
- package/template-vanilla/src/main.ts +1 -1
- package/template-vanilla/tsconfig.json +17 -0
- package/template-vanilla/src/experiences/constants/experiences/CameraType.ts +0 -6
- package/template-vanilla/src/experiences/managers/KeyboardManager.ts +0 -65
- package/template-vanilla/src/experiences/managers/MouseManager.ts +0 -100
- package/template-vanilla/src/experiences/managers/ResizeManager.ts +0 -53
- package/template-vanilla/src/experiences/managers/TickerManager.ts +0 -86
- package/template-vanilla/src/experiences/proxies/ViewProxy.ts +0 -45
- package/template-vanilla/src/experiences/views/bases/ViewBase.ts +0 -36
- package/template-vanilla/src/experiences/views/htmls/loaders/components/HTMLTemplateLoader.ts +0 -57
- /package/template-vanilla/src/experiences/{constants/experiences/AssetType.ts → types/assetTypes.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "template-react",
|
|
3
|
-
"version": "1.
|
|
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.
|
|
9
|
+
"version": "1.4.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@dimforge/rapier3d": "^0.19.3",
|
|
12
12
|
"gsap": "^3.14.2",
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
#root {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
max-width: 1280px;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
padding: 2rem;
|
|
5
|
+
text-align: center;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.logo {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
height: 6em;
|
|
10
|
+
padding: 1.5em;
|
|
11
|
+
will-change: filter;
|
|
12
|
+
transition: filter 300ms;
|
|
13
13
|
}
|
|
14
14
|
.logo:hover {
|
|
15
|
-
|
|
15
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
16
16
|
}
|
|
17
17
|
.logo.react:hover {
|
|
18
|
-
|
|
18
|
+
filter: drop-shadow(0 0 2em #61dafbaa);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
@keyframes logo-spin {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
a:nth-of-type(2) .logo {
|
|
32
|
+
animation: logo-spin infinite 20s linear;
|
|
33
|
+
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
.card {
|
|
37
|
-
|
|
37
|
+
padding: 2em;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
.read-the-docs {
|
|
41
|
-
|
|
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
|
-
|
|
5
|
+
const [count, setCount] = useState(0);
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
line-height: 1.5;
|
|
4
|
+
font-weight: 400;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
|
8
|
+
background-color: #242424;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
font-weight: 500;
|
|
18
|
+
color: #646cff;
|
|
19
|
+
text-decoration: inherit;
|
|
20
20
|
}
|
|
21
21
|
a:hover {
|
|
22
|
-
|
|
22
|
+
color: #535bf2;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
body {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
35
|
-
|
|
34
|
+
font-size: 3.2em;
|
|
35
|
+
line-height: 1.1;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
button {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
50
|
+
border-color: #646cff;
|
|
51
51
|
}
|
|
52
52
|
button:focus,
|
|
53
53
|
button:focus-visible {
|
|
54
|
-
|
|
54
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
@media (prefers-color-scheme: light) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
"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.
|
|
9
|
+
"version": "1.4.1",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@benjos/cookware": "^1.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.
|
|
37
|
-
"resolved": "https://registry.npmjs.org/@benjos/cookware/-/cookware-1.0.
|
|
38
|
-
"integrity": "sha512-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
9
|
-
private
|
|
8
|
+
class Experience {
|
|
9
|
+
private _isInitialized: boolean = false;
|
|
10
10
|
|
|
11
|
-
public
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
Experience._isInitialized = true;
|
|
11
|
+
public init(): void {
|
|
12
|
+
if (this._isInitialized) return;
|
|
13
|
+
this._isInitialized = true;
|
|
16
14
|
|
|
17
|
-
InitCommand.
|
|
18
|
-
MainHTML.
|
|
19
|
-
MainThree.
|
|
20
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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(
|
|
29
|
-
super(CameraId.THREE_DEBUG,
|
|
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
|
-
|
|
32
|
+
DomPointerManager.onPointerDown.add(this._onMouseDown);
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
public override disable(): void {
|
|
41
36
|
super.disable();
|
|
42
|
-
|
|
37
|
+
DomPointerManager.onPointerDown.remove(this._onMouseDown);
|
|
43
38
|
}
|
|
44
39
|
|
|
45
40
|
private _setControls(): void {
|
|
46
|
-
this._controls = new OrbitControls(this._camera,
|
|
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 (
|
|
53
|
-
const intersect = ThreeRaycasterManager.
|
|
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
|
|
4
|
-
import
|
|
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
|
-
|
|
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(
|
|
21
|
-
super(CameraId.THREE_LOADER,
|
|
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 {
|
|
4
|
-
import 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
|
-
|
|
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(
|
|
21
|
-
super(CameraId.THREE_MAIN,
|
|
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 {
|
|
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
|
|
4
|
-
import
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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:
|
|
62
|
-
if (cameraOptions.type ===
|
|
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)
|
|
70
|
+
if (this._camera instanceof PerspectiveCamera) {
|
|
71
|
+
this._camera.aspect = DomResizeManager.width / DomResizeManager.height;
|
|
72
|
+
}
|
|
92
73
|
this._camera.updateProjectionMatrix();
|
|
93
74
|
}
|
|
94
75
|
|