@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.
Files changed (94) hide show
  1. package/README.md +16 -21
  2. package/dist/index.js +16 -15
  3. package/dist/index.js.map +1 -1
  4. package/package.json +2 -2
  5. package/template-vanilla/.prettierignore +6 -0
  6. package/template-vanilla/.prettierrc +10 -0
  7. package/template-vanilla/assets_source/.gitkeep +0 -0
  8. package/template-vanilla/docs/PUBLISHING.md +30 -0
  9. package/template-vanilla/eslint.config.js +126 -0
  10. package/template-vanilla/index.html +17 -0
  11. package/template-vanilla/package-lock.json +3743 -0
  12. package/template-vanilla/package.json +38 -0
  13. package/template-vanilla/public/assets/fonts/LICENSE +13 -0
  14. package/template-vanilla/public/assets/fonts/template.typeface.json +1 -0
  15. package/template-vanilla/public/assets/hdrs/template.hdr +0 -0
  16. package/template-vanilla/public/assets/icons/benjosLogoBlack.svg +5 -0
  17. package/template-vanilla/public/assets/loaders/draco/README.md +32 -0
  18. package/template-vanilla/public/assets/loaders/draco/draco_decoder.js +34 -0
  19. package/template-vanilla/public/assets/loaders/draco/draco_decoder.wasm +0 -0
  20. package/template-vanilla/public/assets/loaders/draco/draco_encoder.js +33 -0
  21. package/template-vanilla/public/assets/loaders/draco/draco_wasm_wrapper.js +117 -0
  22. package/template-vanilla/public/assets/loaders/draco/gltf/draco_decoder.js +33 -0
  23. package/template-vanilla/public/assets/loaders/draco/gltf/draco_decoder.wasm +0 -0
  24. package/template-vanilla/public/assets/loaders/draco/gltf/draco_encoder.js +33 -0
  25. package/template-vanilla/public/assets/loaders/draco/gltf/draco_wasm_wrapper.js +116 -0
  26. package/template-vanilla/public/assets/models/template.glb +0 -0
  27. package/template-vanilla/public/assets/textures/template.jpg +0 -0
  28. package/template-vanilla/readme.md +49 -0
  29. package/template-vanilla/src/experiences/Experience.ts +15 -0
  30. package/template-vanilla/src/experiences/cameras/threes/DebugThreeCameraController.ts +60 -0
  31. package/template-vanilla/src/experiences/cameras/threes/LoaderThreeCameraController.ts +28 -0
  32. package/template-vanilla/src/experiences/cameras/threes/MainThreeCameraController.ts +28 -0
  33. package/template-vanilla/src/experiences/cameras/threes/bases/ThreeCameraControllerBase.ts +109 -0
  34. package/template-vanilla/src/experiences/commands/InitCommand.ts +48 -0
  35. package/template-vanilla/src/experiences/constants/doms/DomEvent.ts +100 -0
  36. package/template-vanilla/src/experiences/constants/doms/KeyboardConstant.ts +250 -0
  37. package/template-vanilla/src/experiences/constants/experiences/AnimationId.ts +3 -0
  38. package/template-vanilla/src/experiences/constants/experiences/AssetId.ts +8 -0
  39. package/template-vanilla/src/experiences/constants/experiences/AssetType.ts +8 -0
  40. package/template-vanilla/src/experiences/constants/experiences/CameraId.ts +7 -0
  41. package/template-vanilla/src/experiences/constants/experiences/CameraType.ts +6 -0
  42. package/template-vanilla/src/experiences/constants/experiences/Object3dId.ts +3 -0
  43. package/template-vanilla/src/experiences/constants/experiences/ViewId.ts +15 -0
  44. package/template-vanilla/src/experiences/engines/htmls/MainHTML.ts +13 -0
  45. package/template-vanilla/src/experiences/engines/threes/MainThree.ts +171 -0
  46. package/template-vanilla/src/experiences/managers/DebugManager.ts +78 -0
  47. package/template-vanilla/src/experiences/managers/KeyboardManager.ts +65 -0
  48. package/template-vanilla/src/experiences/managers/LoaderManager.ts +79 -0
  49. package/template-vanilla/src/experiences/managers/MouseManager.ts +100 -0
  50. package/template-vanilla/src/experiences/managers/ResizeManager.ts +53 -0
  51. package/template-vanilla/src/experiences/managers/TickerManager.ts +86 -0
  52. package/template-vanilla/src/experiences/managers/threes/ThreeAssetsManager.ts +279 -0
  53. package/template-vanilla/src/experiences/managers/threes/ThreeCameraControllerManager.ts +43 -0
  54. package/template-vanilla/src/experiences/managers/threes/ThreeRaycasterManager.ts +23 -0
  55. package/template-vanilla/src/experiences/materials/threes/loaders/LoaderMaterial.ts +48 -0
  56. package/template-vanilla/src/experiences/proxies/ViewProxy.ts +30 -0
  57. package/template-vanilla/src/experiences/proxies/bases/PoolProxyBase.ts +61 -0
  58. package/template-vanilla/src/experiences/renderers/threes/LoaderRenderer.ts +22 -0
  59. package/template-vanilla/src/experiences/renderers/threes/Renderer.ts +74 -0
  60. package/template-vanilla/src/experiences/renderers/threes/bases/WebGLRendererBase.ts +29 -0
  61. package/template-vanilla/src/experiences/shaders/threes/loaders/LoaderFragmentShader.glsl +6 -0
  62. package/template-vanilla/src/experiences/shaders/threes/loaders/LoaderVertexShader.glsl +3 -0
  63. package/template-vanilla/src/experiences/styles/abstracts/_import.scss +5 -0
  64. package/template-vanilla/src/experiences/styles/abstracts/functions.scss +3 -0
  65. package/template-vanilla/src/experiences/styles/abstracts/mixins.scss +0 -0
  66. package/template-vanilla/src/experiences/styles/abstracts/variables.scss +7 -0
  67. package/template-vanilla/src/experiences/styles/commons/fonts.scss +10 -0
  68. package/template-vanilla/src/experiences/styles/commons/main.scss +84 -0
  69. package/template-vanilla/src/experiences/styles/commons/texts.scss +1 -0
  70. package/template-vanilla/src/experiences/styles/style.scss +7 -0
  71. package/template-vanilla/src/experiences/styles/views/loader.scss +72 -0
  72. package/template-vanilla/src/experiences/tools/Action.ts +23 -0
  73. package/template-vanilla/src/experiences/tools/Point.ts +56 -0
  74. package/template-vanilla/src/experiences/types/global.d.ts +9 -0
  75. package/template-vanilla/src/experiences/utils/AssetUtils.ts +6 -0
  76. package/template-vanilla/src/experiences/utils/DomUtils.ts +28 -0
  77. package/template-vanilla/src/experiences/views/bases/ViewBase.ts +25 -0
  78. package/template-vanilla/src/experiences/views/htmls/bases/HTMLViewBase.ts +41 -0
  79. package/template-vanilla/src/experiences/views/htmls/loaders/LoaderHTMLView.ts +34 -0
  80. package/template-vanilla/src/experiences/views/htmls/loaders/components/HTMLTemplateLoader.ts +57 -0
  81. package/template-vanilla/src/experiences/views/threes/bases/ThreeViewBase.ts +26 -0
  82. package/template-vanilla/src/experiences/views/threes/loaders/LoaderThreeView.ts +41 -0
  83. package/template-vanilla/src/experiences/views/threes/loaders/components/ThreeTemplateLoader.ts +52 -0
  84. package/template-vanilla/src/experiences/views/threes/worlds/WorldThreeView.ts +51 -0
  85. package/template-vanilla/src/experiences/views/threes/worlds/components/Environment.ts +77 -0
  86. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateFont.ts +62 -0
  87. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateMesh.ts +65 -0
  88. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/TemplateModel.ts +31 -0
  89. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ActorBase.ts +9 -0
  90. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/AnimatedModelBase.ts +67 -0
  91. package/template-vanilla/src/experiences/views/threes/worlds/components/actors/bases/ModelBase.ts +48 -0
  92. package/template-vanilla/src/main.ts +3 -0
  93. package/template-vanilla/tsconfig.json +24 -0
  94. package/template-vanilla/vite.config.ts +15 -0
@@ -0,0 +1,100 @@
1
+ export const DomEvent = {
2
+ // Mouse Events
3
+ CLICK: 'click',
4
+ DOUBLE_CLICK: 'dblclick',
5
+ MOUSE_DOWN: 'mousedown',
6
+ MOUSE_UP: 'mouseup',
7
+ MOUSE_MOVE: 'mousemove',
8
+ MOUSE_ENTER: 'mouseenter',
9
+ MOUSE_LEAVE: 'mouseleave',
10
+ MOUSE_WHEEL: 'wheel',
11
+ CONTEXT_MENU: 'contextmenu',
12
+
13
+ // Pointer Events
14
+ POINTER_DOWN: 'pointerdown',
15
+ POINTER_MOVE: 'pointermove',
16
+ POINTER_UP: 'pointerup',
17
+ POINTER_ENTER: 'pointerenter',
18
+ POINTER_LEAVE: 'pointerleave',
19
+ POINTER_CANCEL: 'pointercancel',
20
+
21
+ // Touch Events
22
+ TOUCH_START: 'touchstart',
23
+ TOUCH_MOVE: 'touchmove',
24
+ TOUCH_END: 'touchend',
25
+ TOUCH_CANCEL: 'touchcancel',
26
+
27
+ // Keyboard Events
28
+ KEY_DOWN: 'keydown',
29
+ KEY_UP: 'keyup',
30
+ KEY_PRESS: 'keypress',
31
+
32
+ // Focus Events
33
+ FOCUS: 'focus',
34
+ BLUR: 'blur',
35
+ FOCUS_IN: 'focusin',
36
+ FOCUS_OUT: 'focusout',
37
+
38
+ // Form Events
39
+ CHANGE: 'change',
40
+ INPUT: 'input',
41
+ SUBMIT: 'submit',
42
+ RESET: 'reset',
43
+
44
+ // Document Events
45
+ FULLSCREEN_CHANGE: 'fullscreenchange',
46
+ FULLSCREEN_ERROR: 'fullscreenerror',
47
+ VISIBILITY_CHANGE: 'visibilitychange',
48
+
49
+ // Window Events
50
+ DOM_CONTENT_LOADED: 'DOMContentLoaded',
51
+ READY_STATE_CHANGE: 'readystatechange',
52
+ ERROR: 'error',
53
+ LOAD: 'load',
54
+ UNLOAD: 'unload',
55
+ BEFORE_UNLOAD: 'beforeunload',
56
+ RESIZE: 'resize',
57
+ SCROLL: 'scroll',
58
+
59
+ // Clipboard Events
60
+ CUT: 'cut',
61
+ COPY: 'copy',
62
+ PASTE: 'paste',
63
+
64
+ // Drag and Drop Events
65
+ DRAG: 'drag',
66
+ DRAG_START: 'dragstart',
67
+ DRAG_END: 'dragend',
68
+ DRAG_ENTER: 'dragenter',
69
+ DRAG_LEAVE: 'dragleave',
70
+ DRAG_OVER: 'dragover',
71
+ DROP: 'drop',
72
+
73
+ // Media Events
74
+ PLAY: 'play',
75
+ PAUSE: 'pause',
76
+ ENDED: 'ended',
77
+ CAN_PLAY: 'canplay',
78
+ TIME_UPDATE: 'timeupdate',
79
+
80
+ // Animation Events
81
+ ANIMATION_START: 'animationstart',
82
+ ANIMATION_END: 'animationend',
83
+ ANIMATION_ITERATION: 'animationiteration',
84
+
85
+ // Transition Events
86
+ TRANSITION_START: 'transitionstart',
87
+ TRANSITION_END: 'transitionend',
88
+ TRANSITION_CANCEL: 'transitioncancel',
89
+
90
+ // Other Events
91
+ BEFORE_PRINT: 'beforeprint',
92
+ AFTER_PRINT: 'afterprint',
93
+ HASH_CHANGE: 'hashchange',
94
+ POP_STATE: 'popstate',
95
+ STORAGE: 'storage',
96
+ ONLINE: 'online',
97
+ OFFLINE: 'offline',
98
+ } as const;
99
+
100
+ export type DomEvent = (typeof DomEvent)[keyof typeof DomEvent];
@@ -0,0 +1,250 @@
1
+ export const KeyboardConstant = {
2
+ Keys: {
3
+ Backspace: 'Backspace',
4
+ Tab: 'Tab',
5
+ Enter: 'Enter',
6
+ Shift: 'Shift',
7
+ Control: 'Control',
8
+ Alt: 'Alt',
9
+ Pause: 'Pause',
10
+ CapsLock: 'CapsLock',
11
+ Escape: 'Escape',
12
+ Space: '',
13
+ PageUp: 'PageUp',
14
+ PageDown: 'PageDown',
15
+ End: 'End',
16
+ Home: 'Home',
17
+ ArrowLeft: 'ArrowLeft',
18
+ ArrowUp: 'ArrowUp',
19
+ ArrowRight: 'ArrowRight',
20
+ ArrowDown: 'ArrowDown',
21
+ PrintScreen: 'PrintScreen',
22
+ Insert: 'Insert',
23
+ Delete: 'Delete',
24
+ Digit0: '0',
25
+ Digit1: '1',
26
+ Digit2: '2',
27
+ Digit3: '3',
28
+ Digit4: '4',
29
+ Digit5: '5',
30
+ Digit6: '6',
31
+ Digit7: '7',
32
+ Digit8: '8',
33
+ Digit9: '9',
34
+ A: 'A',
35
+ B: 'B',
36
+ C: 'C',
37
+ D: 'D',
38
+ E: 'E',
39
+ F: 'F',
40
+ G: 'G',
41
+ H: 'H',
42
+ I: 'I',
43
+ J: 'J',
44
+ K: 'K',
45
+ L: 'L',
46
+ M: 'M',
47
+ N: 'N',
48
+ O: 'O',
49
+ P: 'P',
50
+ Q: 'Q',
51
+ R: 'R',
52
+ S: 'S',
53
+ T: 'T',
54
+ U: 'U',
55
+ V: 'V',
56
+ W: 'W',
57
+ X: 'X',
58
+ Y: 'Y',
59
+ Z: 'Z',
60
+ a: 'a',
61
+ b: 'b',
62
+ c: 'c',
63
+ d: 'd',
64
+ e: 'e',
65
+ f: 'f',
66
+ g: 'g',
67
+ h: 'h',
68
+ i: 'i',
69
+ j: 'j',
70
+ k: 'k',
71
+ l: 'l',
72
+ m: 'm',
73
+ n: 'n',
74
+ o: 'o',
75
+ p: 'p',
76
+ q: 'q',
77
+ r: 'r',
78
+ s: 's',
79
+ t: 't',
80
+ u: 'u',
81
+ v: 'v',
82
+ w: 'w',
83
+ x: 'x',
84
+ y: 'y',
85
+ z: 'z',
86
+ Meta: 'Meta',
87
+ ContextMenu: 'ContextMenu',
88
+ AudioVolumeMute: 'AudioVolumeMute',
89
+ AudioVolumeDown: 'AudioVolumeDown',
90
+ AudioVolumeUp: 'AudioVolumeUp',
91
+ F1: 'F1',
92
+ F2: 'F2',
93
+ F3: 'F3',
94
+ F4: 'F4',
95
+ F5: 'F5',
96
+ F6: 'F6',
97
+ F7: 'F7',
98
+ F8: 'F8',
99
+ F9: 'F9',
100
+ F10: 'F10',
101
+ F11: 'F11',
102
+ F12: 'F12',
103
+ NumLock: 'NumLock',
104
+ ScrollLock: 'ScrollLock',
105
+ Semicolon: ';',
106
+ Equal: ':',
107
+ Comma: ',',
108
+ Minus: '-',
109
+ Period: '.',
110
+ Slash: '/',
111
+ Backquote: '`',
112
+ BracketLeft: '[',
113
+ Backslash: '\\',
114
+ BracketRight: ']',
115
+ Quote: "'",
116
+ Tilde: '~',
117
+ Exclamation: '!',
118
+ At: '@',
119
+ Sharp: '#',
120
+ Dollar: '$',
121
+ Percent: '%',
122
+ Caret: '^',
123
+ Ampersand: '&',
124
+ Asterisk: '*',
125
+ ParenthesisLeft: '(',
126
+ ParenthesisRight: ')',
127
+ Underscore: '_',
128
+ Plus: '+',
129
+ OpenBrace: '{',
130
+ CloseBrace: '}',
131
+ Pipe: '|',
132
+ Colon: ':',
133
+ Quote2: '"',
134
+ AngleBracketLeft: '<',
135
+ AngleBracketRight: '>',
136
+ QuestionMark: '?',
137
+ },
138
+
139
+ Codes: {
140
+ Backspace: 'Backspace',
141
+ Tab: 'Tab',
142
+ Enter: 'Enter',
143
+ ShiftLeft: 'ShiftLeft',
144
+ ShiftRight: 'ShiftRight',
145
+ ControlLeft: 'ControlLeft',
146
+ ControlRight: 'ControlRight',
147
+ AltLeft: 'AltLeft',
148
+ AltRight: 'AltRight',
149
+ Pause: 'Pause',
150
+ CapsLock: 'CapsLock',
151
+ Escape: 'Escape',
152
+ Space: 'Space',
153
+ PageUp: 'PageUp',
154
+ PageDown: 'PageDown',
155
+ End: 'End',
156
+ Home: 'Home',
157
+ ArrowLeft: 'ArrowLeft',
158
+ ArrowUp: 'ArrowUp',
159
+ ArrowRight: 'ArrowRight',
160
+ ArrowDown: 'ArrowDown',
161
+ PrintScreen: 'PrintScreen',
162
+ Insert: 'Insert',
163
+ Delete: 'Delete',
164
+ Digit0: 'Digit0',
165
+ Digit1: 'Digit1',
166
+ Digit2: 'Digit2',
167
+ Digit3: 'Digit3',
168
+ Digit4: 'Digit4',
169
+ Digit5: 'Digit5',
170
+ Digit6: 'Digit6',
171
+ Digit7: 'Digit7',
172
+ Digit8: 'Digit8',
173
+ Digit9: 'Digit9',
174
+ AudioVolumeMute: 'AudioVolumeMute',
175
+ AudioVolumeDown: 'AudioVolumeDown',
176
+ AudioVolumeUp: 'AudioVolumeUp',
177
+ KeyA: 'KeyA',
178
+ KeyB: 'KeyB',
179
+ KeyC: 'KeyC',
180
+ KeyD: 'KeyD',
181
+ KeyE: 'KeyE',
182
+ KeyF: 'KeyF',
183
+ KeyG: 'KeyG',
184
+ KeyH: 'KeyH',
185
+ KeyI: 'KeyI',
186
+ KeyJ: 'KeyJ',
187
+ KeyK: 'KeyK',
188
+ KeyL: 'KeyL',
189
+ KeyM: 'KeyM',
190
+ KeyN: 'KeyN',
191
+ KeyO: 'KeyO',
192
+ KeyP: 'KeyP',
193
+ KeyQ: 'KeyQ',
194
+ KeyR: 'KeyR',
195
+ KeyS: 'KeyS',
196
+ KeyT: 'KeyT',
197
+ KeyU: 'KeyU',
198
+ KeyV: 'KeyV',
199
+ KeyW: 'KeyW',
200
+ KeyX: 'KeyX',
201
+ KeyY: 'KeyY',
202
+ KeyZ: 'KeyZ',
203
+ MetaLeft: 'MetaLeft',
204
+ MetaRight: 'MetaRight',
205
+ ContextMenu: 'ContextMenu',
206
+ Numpad0: 'Numpad0',
207
+ Numpad1: 'Numpad1',
208
+ Numpad2: 'Numpad2',
209
+ Numpad3: 'Numpad3',
210
+ Numpad4: 'Numpad4',
211
+ Numpad5: 'Numpad5',
212
+ Numpad6: 'Numpad6',
213
+ Numpad7: 'Numpad7',
214
+ Numpad8: 'Numpad8',
215
+ Numpad9: 'Numpad9',
216
+ NumpadMultiply: 'NumpadMultiply',
217
+ NumpadAdd: 'NumpadAdd',
218
+ NumpadSubtract: 'NumpadSubtract',
219
+ NumpadDecimal: 'NumpadDecimal',
220
+ NumpadDivide: 'NumpadDivide',
221
+ NumpadEnter: 'NumpadEnter',
222
+ F1: 'F1',
223
+ F2: 'F2',
224
+ F3: 'F3',
225
+ F4: 'F4',
226
+ F5: 'F5',
227
+ F6: 'F6',
228
+ F7: 'F7',
229
+ F8: 'F8',
230
+ F9: 'F9',
231
+ F10: 'F10',
232
+ F11: 'F11',
233
+ F12: 'F12',
234
+ NumLock: 'NumLock',
235
+ ScrollLock: 'ScrollLock',
236
+ Semicolon: 'Semicolon',
237
+ Equal: 'Equal',
238
+ Comma: 'Comma',
239
+ Minus: 'Minus',
240
+ Period: 'Period',
241
+ Slash: 'Slash',
242
+ Backquote: 'Backquote',
243
+ BracketLeft: 'BracketLeft',
244
+ Backslash: 'Backslash',
245
+ BracketRight: 'BracketRight',
246
+ Quote: 'Quote',
247
+ },
248
+ } as const;
249
+
250
+ export type KeyboardConstant = (typeof KeyboardConstant)[keyof typeof KeyboardConstant];
@@ -0,0 +1,3 @@
1
+ export const AnimationId = {} as const;
2
+
3
+ export type AnimationId = (typeof AnimationId)[keyof typeof AnimationId];
@@ -0,0 +1,8 @@
1
+ export const AssetId = {
2
+ THREE_TEXTURE_TEMPLATE: 'THREE_TEXTURE_TEMPLATE',
3
+ THREE_HDR_TEMPLATE: 'THREE_HDR_TEMPLATE',
4
+ THREE_GLTF_TEMPLATE: 'THREE_GLTF_TEMPLATE',
5
+ THREE_FONT_TEMPLATE: 'THREE_FONT_TEMPLATE',
6
+ } as const;
7
+
8
+ export type AssetId = (typeof AssetId)[keyof typeof AssetId];
@@ -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,7 @@
1
+ export const CameraId = {
2
+ THREE_DEBUG: 'THREE_DEBUG',
3
+ THREE_MAIN: 'THREE_MAIN',
4
+ THREE_LOADER: 'THREE_LOADER',
5
+ } as const;
6
+
7
+ export type CameraId = (typeof CameraId)[keyof typeof CameraId];
@@ -0,0 +1,6 @@
1
+ export const CameraType = {
2
+ PERSPECTIVE: 'PERSPECTIVE',
3
+ ORTHOGRAPHIC: 'ORTHOGRAPHIC',
4
+ } as const;
5
+
6
+ export type CameraType = (typeof CameraType)[keyof typeof CameraType];
@@ -0,0 +1,3 @@
1
+ export const Object3DId = {} as const;
2
+
3
+ export type Object3DId = (typeof Object3DId)[keyof typeof Object3DId];
@@ -0,0 +1,15 @@
1
+ const HTMLViewId = {
2
+ HTML_LOADER: 'HTML_LOADER',
3
+ } as const;
4
+
5
+ const ThreeViewId = {
6
+ THREE_LOADER: 'THREE_LOADER',
7
+ THREE_WORLD: 'THREE_WORLD',
8
+ } as const;
9
+
10
+ export const ViewId = {
11
+ ...HTMLViewId,
12
+ ...ThreeViewId,
13
+ } as const;
14
+
15
+ export type ViewId = (typeof ViewId)[keyof typeof ViewId];
@@ -0,0 +1,13 @@
1
+ import { ViewId } from '../../constants/experiences/ViewId';
2
+ import ViewProxy from '../../proxies/ViewProxy';
3
+ import LoaderHTMLView from '../../views/htmls/loaders/LoaderHTMLView';
4
+
5
+ export default class MainHTML {
6
+ public static Init(): void {
7
+ MainHTML._GenerateViews();
8
+ }
9
+
10
+ private static _GenerateViews(): void {
11
+ ViewProxy.Add(ViewId.HTML_LOADER, LoaderHTMLView);
12
+ }
13
+ }
@@ -0,0 +1,171 @@
1
+ import { MeshStandardMaterial, Scene } from 'three';
2
+ import type ThreeCameraControllerBase from '../../cameras/threes/bases/ThreeCameraControllerBase';
3
+ import DebugThreeCameraController from '../../cameras/threes/DebugThreeCameraController';
4
+ import LoaderThreeCameraController from '../../cameras/threes/LoaderThreeCameraController';
5
+ import MainThreeCameraController from '../../cameras/threes/MainThreeCameraController';
6
+ import { KeyboardConstant } from '../../constants/doms/KeyboardConstant';
7
+ import { CameraId } from '../../constants/experiences/CameraId';
8
+ import { ViewId } from '../../constants/experiences/ViewId';
9
+ import DebugManager from '../../managers/DebugManager';
10
+ import { KeyboardManager } from '../../managers/KeyboardManager';
11
+ import { ResizeManager } from '../../managers/ResizeManager';
12
+ import ThreeCameraControllerManager from '../../managers/threes/ThreeCameraControllerManager';
13
+ import TickerManager from '../../managers/TickerManager';
14
+ import ViewProxy from '../../proxies/ViewProxy';
15
+ import WebGLRendererBase from '../../renderers/threes/bases/WebGLRendererBase';
16
+ import LoaderRenderer from '../../renderers/threes/LoaderRenderer';
17
+ import Renderer from '../../renderers/threes/Renderer';
18
+ import DomUtils from '../../utils/DomUtils';
19
+ import LoaderThreeView from '../../views/threes/loaders/LoaderThreeView';
20
+ import WorldThreeView from '../../views/threes/worlds/WorldThreeView';
21
+
22
+ export default class MainThree {
23
+ private static _DomElementContainer: HTMLElement;
24
+ private static _LoaderDomElementContainer: HTMLElement;
25
+ private static _Scene: Scene;
26
+ private static _LoaderScene: Scene;
27
+ private static _CameraController: ThreeCameraControllerBase;
28
+ private static _Renderer: Renderer;
29
+ private static _LoaderRenderer: WebGLRendererBase;
30
+ private static _DebugWireframeMaterial: MeshStandardMaterial;
31
+
32
+ //#region Constants
33
+ //
34
+ private static readonly _DEBUG_WIREFRAME_MATERIAL_COLOR: number = 0x3f79f3;
35
+ private static readonly _TOGGLE_SWITCH_TO_DEBUG_CAMERA_KEYS: string[] = [
36
+ KeyboardConstant.Codes.ShiftLeft,
37
+ KeyboardConstant.Codes.KeyC,
38
+ ];
39
+ private static readonly _TOGGLE_WIREFRAME_KEYS: string[] = [
40
+ KeyboardConstant.Codes.ShiftLeft,
41
+ KeyboardConstant.Codes.KeyW,
42
+ ];
43
+ //
44
+ //#endregion
45
+
46
+ public static Init(): void {
47
+ TickerManager.Add(MainThree.Update);
48
+
49
+ MainThree._DomElementContainer = DomUtils.GetApp();
50
+ MainThree._LoaderDomElementContainer = DomUtils.GetLoader();
51
+
52
+ MainThree._GenerateScenes();
53
+ MainThree._GenerateCameras();
54
+ MainThree._GenerateRenderers();
55
+
56
+ MainThree._OnResize();
57
+ ResizeManager.OnResize.add(MainThree._OnResize);
58
+
59
+ MainThree._GenerateViews();
60
+
61
+ if (DebugManager.IsActive) {
62
+ window.experience = MainThree;
63
+ KeyboardManager.OnKeyUp.add(MainThree._OnKeyUp);
64
+ }
65
+ }
66
+
67
+ private static _GenerateScenes(): void {
68
+ MainThree._Scene = new Scene();
69
+ MainThree._LoaderScene = new Scene();
70
+
71
+ if (DebugManager.IsActive) {
72
+ MainThree._DebugWireframeMaterial = new MeshStandardMaterial({
73
+ wireframe: true,
74
+ color: MainThree._DEBUG_WIREFRAME_MATERIAL_COLOR,
75
+ });
76
+ }
77
+ }
78
+
79
+ private static _GenerateViews(): void {
80
+ ViewProxy.Add(ViewId.THREE_LOADER, LoaderThreeView);
81
+ ViewProxy.Add(ViewId.THREE_WORLD, WorldThreeView);
82
+ }
83
+
84
+ private static _GenerateCameras(): void {
85
+ ThreeCameraControllerManager.Add(new MainThreeCameraController(), true);
86
+ ThreeCameraControllerManager.Add(new LoaderThreeCameraController());
87
+ MainThree._CameraController = ThreeCameraControllerManager.Get(CameraId.THREE_MAIN);
88
+
89
+ if (DebugManager.IsActive) {
90
+ ThreeCameraControllerManager.Add(new DebugThreeCameraController());
91
+ }
92
+
93
+ ThreeCameraControllerManager.OnActiveThreeCameraControllerChange.add(MainThree._OnActiveCameraControllerChange);
94
+ }
95
+
96
+ private static _GenerateRenderers(): void {
97
+ MainThree._Renderer = new Renderer(MainThree.Scene, MainThree._CameraController.camera, { antialias: true });
98
+ MainThree._DomElementContainer.appendChild(MainThree._Renderer.domElement);
99
+
100
+ MainThree._LoaderRenderer = new LoaderRenderer(
101
+ MainThree.LoaderScene,
102
+ ThreeCameraControllerManager.Get(CameraId.THREE_LOADER).camera
103
+ );
104
+ MainThree._LoaderDomElementContainer.appendChild(MainThree._LoaderRenderer.domElement);
105
+ }
106
+
107
+ private static _OnActiveCameraControllerChange = (): void => {
108
+ MainThree._CameraController = ThreeCameraControllerManager.ActiveThreeCameraController;
109
+ MainThree._Renderer.setCamera(MainThree._CameraController.camera);
110
+ MainThree._OnResize();
111
+ };
112
+
113
+ private static readonly _OnKeyUp = (_e: KeyboardEvent): void => {
114
+ if (DebugManager.IsActive) {
115
+ if (KeyboardManager.AreAllKeysDown(MainThree._TOGGLE_SWITCH_TO_DEBUG_CAMERA_KEYS)) {
116
+ ThreeCameraControllerManager.SetActiveCamera(
117
+ MainThree._CameraController.cameraId === CameraId.THREE_MAIN
118
+ ? CameraId.THREE_DEBUG
119
+ : CameraId.THREE_MAIN
120
+ );
121
+ } else if (KeyboardManager.AreAllKeysDown(MainThree._TOGGLE_WIREFRAME_KEYS)) {
122
+ if (MainThree._Scene.overrideMaterial === null) {
123
+ MainThree._Scene.overrideMaterial = MainThree._DebugWireframeMaterial;
124
+ MainThree._LoaderScene.overrideMaterial = MainThree._DebugWireframeMaterial;
125
+ } else {
126
+ MainThree._Scene.overrideMaterial = null;
127
+ MainThree._LoaderScene.overrideMaterial = null;
128
+ }
129
+ }
130
+ }
131
+ };
132
+
133
+ private static _OnResize = (): void => {
134
+ MainThree._Renderer.domElement.width = window.innerWidth;
135
+ MainThree._Renderer.domElement.height = window.innerHeight;
136
+
137
+ MainThree._LoaderRenderer.domElement.width = window.innerWidth;
138
+ MainThree._LoaderRenderer.domElement.height = window.innerHeight;
139
+
140
+ MainThree._CameraController.resize();
141
+ MainThree._Renderer.resize();
142
+ MainThree._LoaderRenderer.resize();
143
+ };
144
+
145
+ public static Update = (dt: number): void => {
146
+ MainThree._CameraController.update(dt);
147
+ if (ViewProxy.Has(ViewId.THREE_WORLD)) ViewProxy.GetById<WorldThreeView>(ViewId.THREE_WORLD).update(dt);
148
+ MainThree._Renderer.update(dt);
149
+ MainThree._LoaderRenderer.update(dt);
150
+ };
151
+
152
+ //#region Getters
153
+ //
154
+ public static get DomElementContainer(): HTMLElement {
155
+ return this._DomElementContainer;
156
+ }
157
+ public static get Scene(): Scene {
158
+ return this._Scene;
159
+ }
160
+ public static get LoaderScene(): Scene {
161
+ return this._LoaderScene;
162
+ }
163
+ public static get Renderer(): WebGLRendererBase {
164
+ return this._Renderer;
165
+ }
166
+ public static get CameraController(): ThreeCameraControllerBase {
167
+ return this._CameraController;
168
+ }
169
+ //
170
+ //#endregion
171
+ }
@@ -0,0 +1,78 @@
1
+ import GUI from 'lil-gui';
2
+ import { ThreePerf } from 'three-perf';
3
+ import { KeyboardConstant } from '../constants/doms/KeyboardConstant';
4
+ import MainThree from '../engines/threes/MainThree';
5
+ import { KeyboardManager } from './KeyboardManager';
6
+
7
+ export default class DebugManager {
8
+ private static _Gui: GUI;
9
+ private static _ThreePerf: ThreePerf;
10
+
11
+ //#region Constants
12
+ //
13
+ private static readonly _IS_ACTIVE_STRING: string = '#debug';
14
+ private static readonly _GUI_WIDTH: number = 300;
15
+ private static readonly _GUI_TITLE: string = 'Debug Panel';
16
+ private static readonly _THREE_PERF_ANCHOR_X: 'left' | 'right' = 'left';
17
+ private static readonly _THREE_PERF_ANCHOR_Y: 'top' | 'bottom' = 'bottom';
18
+ private static readonly _TOGGLE_HIDDEN_KEYS: string[] = [
19
+ KeyboardConstant.Codes.ShiftLeft,
20
+ KeyboardConstant.Codes.KeyH,
21
+ ];
22
+ //
23
+ //#endregion
24
+
25
+ public static Init(): void {
26
+ if (DebugManager.IsActive) {
27
+ DebugManager._InitGui();
28
+ }
29
+ }
30
+
31
+ private static _InitGui(): void {
32
+ DebugManager._Gui = new GUI({
33
+ width: DebugManager._GUI_WIDTH,
34
+ title: DebugManager._GUI_TITLE,
35
+ closeFolders: true,
36
+ });
37
+ DebugManager._Gui.close();
38
+ KeyboardManager.OnKeyUp.remove(DebugManager._OnKeyUp);
39
+ KeyboardManager.OnKeyUp.add(DebugManager._OnKeyUp);
40
+ }
41
+
42
+ private static _InitThreePerf = (): void => {
43
+ DebugManager._ThreePerf = new ThreePerf({
44
+ anchorX: DebugManager._THREE_PERF_ANCHOR_X,
45
+ anchorY: DebugManager._THREE_PERF_ANCHOR_Y,
46
+ domElement: document.body,
47
+ renderer: MainThree.Renderer,
48
+ showGraph: false,
49
+ });
50
+ };
51
+
52
+ public static BeginThreePerf(): void {
53
+ if (!DebugManager._ThreePerf) DebugManager._InitThreePerf();
54
+ DebugManager._ThreePerf.begin();
55
+ }
56
+
57
+ public static EndThreePerf(): void {
58
+ DebugManager._ThreePerf.end();
59
+ }
60
+
61
+ private static readonly _OnKeyUp = (_e: KeyboardEvent): void => {
62
+ if (KeyboardManager.AreAllKeysDown(DebugManager._TOGGLE_HIDDEN_KEYS)) {
63
+ DebugManager._Gui.show(DebugManager._Gui._hidden);
64
+ DebugManager._ThreePerf.visible = !DebugManager._ThreePerf.visible;
65
+ }
66
+ };
67
+
68
+ //#region Getters
69
+ //
70
+ public static get IsActive(): boolean {
71
+ return window.location.hash === DebugManager._IS_ACTIVE_STRING;
72
+ }
73
+ public static get Gui(): GUI {
74
+ return DebugManager._Gui;
75
+ }
76
+ //
77
+ //#endregion
78
+ }