@benjos/create-boilerplate 1.0.1 → 1.3.2

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 (47) hide show
  1. package/README.md +29 -22
  2. package/dist/index.js +20 -17
  3. package/dist/index.js.map +1 -1
  4. package/package.json +4 -3
  5. package/template-react/.prettierignore +6 -0
  6. package/template-react/.prettierrc +10 -0
  7. package/template-react/assets_source/.gitkeep +0 -0
  8. package/template-react/eslint.config.js +23 -0
  9. package/template-react/index.html +17 -0
  10. package/template-react/package-lock.json +4492 -0
  11. package/template-react/package.json +47 -0
  12. package/template-react/public/assets/fonts/LICENSE +13 -0
  13. package/template-react/public/assets/fonts/template.typeface.json +1 -0
  14. package/template-react/public/assets/hdrs/template.hdr +0 -0
  15. package/template-react/public/assets/icons/benjosLogoBlack.svg +5 -0
  16. package/template-react/public/assets/loaders/draco/README.md +32 -0
  17. package/template-react/public/assets/loaders/draco/draco_decoder.js +34 -0
  18. package/template-react/public/assets/loaders/draco/draco_decoder.wasm +0 -0
  19. package/template-react/public/assets/loaders/draco/draco_encoder.js +33 -0
  20. package/template-react/public/assets/loaders/draco/draco_wasm_wrapper.js +117 -0
  21. package/template-react/public/assets/loaders/draco/gltf/draco_decoder.js +33 -0
  22. package/template-react/public/assets/loaders/draco/gltf/draco_decoder.wasm +0 -0
  23. package/template-react/public/assets/loaders/draco/gltf/draco_encoder.js +33 -0
  24. package/template-react/public/assets/loaders/draco/gltf/draco_wasm_wrapper.js +116 -0
  25. package/template-react/public/assets/models/template.glb +0 -0
  26. package/template-react/public/assets/textures/template.jpg +0 -0
  27. package/template-react/readme.md +31 -0
  28. package/template-react/src/App.css +42 -0
  29. package/template-react/src/App.tsx +14 -0
  30. package/template-react/src/index.css +68 -0
  31. package/template-react/src/main.tsx +10 -0
  32. package/template-react/tsconfig.app.json +28 -0
  33. package/template-react/tsconfig.json +7 -0
  34. package/template-react/tsconfig.node.json +26 -0
  35. package/template-react/vite.config.ts +29 -0
  36. package/template-vanilla/eslint.config.js +11 -0
  37. package/template-vanilla/package-lock.json +3739 -3739
  38. package/template-vanilla/package.json +2 -2
  39. package/template-vanilla/readme.md +28 -10
  40. package/template-vanilla/src/experiences/Experience.ts +7 -0
  41. package/template-vanilla/src/experiences/constants/experiences/ViewType.ts +6 -0
  42. package/template-vanilla/src/experiences/proxies/ViewProxy.ts +15 -0
  43. package/template-vanilla/src/experiences/views/bases/ViewBase.ts +14 -3
  44. package/template-vanilla/src/experiences/views/htmls/bases/HTMLViewBase.ts +2 -1
  45. package/template-vanilla/src/experiences/views/threes/bases/ThreeViewBase.ts +2 -1
  46. package/template-vanilla/src/experiences/views/threes/loaders/LoaderThreeView.ts +1 -0
  47. package/template-vanilla/tsconfig.json +0 -24
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "boilerplate",
3
3
  "private": true,
4
- "version": "1.0.22",
4
+ "version": "1.3.2",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -35,4 +35,4 @@
35
35
  "lil-gui": "^0.21.0",
36
36
  "three": "^0.181.2"
37
37
  }
38
- }
38
+ }
@@ -1,13 +1,31 @@
1
- # Introduction
1
+ # 🎨 Three.js Boilerplate
2
2
 
3
- Welcome to this boilerplate for **Three.js projects**.
4
- I’m building this boilerplate for myself, but I’m sharing it so others can use and improve it!
5
- This boilerplate will evolve after each project I create with it. I’ll update the version number in the `package.json` file accordingly.
3
+ Custom boilerplate for Three.js projects with CLI scaffolding.
6
4
 
7
- ## Debug Mode
5
+ ## 🚀 Quick Start
8
6
 
9
- To activate **debug mode**, add `#debug` to your **URL**, like this: `http://localhost:5173/#debug`
10
- Toggle Debug UI : `ShiftLeft + KeyH`
11
- Switch to debug camera: `ShiftLeft + KeyC`
12
- In debug camera `Ctrl + Click` on an object **to center the camera** on it.
13
- Toggle wireframe : `ShiftLeft + KeyW`
7
+ ```bash
8
+ npm i
9
+ npm run dev
10
+ ```
11
+
12
+ ## ✨ Features
13
+
14
+ - Three.js + Vite + TypeScript
15
+ - GLSL shaders support
16
+ - Debug mode with lil-gui
17
+ - Manager-based architecture
18
+ - ESLint + Prettier
19
+
20
+ ## 🐛 Debug Mode
21
+
22
+ Add `#debug` to URL: `http://localhost:5173/#debug`
23
+
24
+ - `Shift + H` → Toggle UI
25
+ - `Shift + C` → Debug Camera
26
+ - `Shift + W` → Wireframe
27
+ - `Ctrl + Click` → Center on object
28
+
29
+ ## 📄 License
30
+
31
+ MIT
@@ -6,7 +6,14 @@ import MainThree from './engines/threes/MainThree';
6
6
  import LoaderManager from './managers/LoaderManager';
7
7
 
8
8
  export default class Experience {
9
+ private static _isInitialized = false;
10
+
9
11
  public static Init(): void {
12
+ if (Experience._isInitialized) {
13
+ return;
14
+ }
15
+ Experience._isInitialized = true;
16
+
10
17
  InitCommand.Init();
11
18
  MainHTML.Init();
12
19
  MainThree.Init();
@@ -0,0 +1,6 @@
1
+ export const ViewType = {
2
+ HTML: 'HTML',
3
+ THREE: 'THREE',
4
+ } as const;
5
+
6
+ export type ViewType = (typeof ViewType)[keyof typeof ViewType];
@@ -1,4 +1,5 @@
1
1
  import type { ViewId } from '../constants/experiences/ViewId';
2
+ import { ViewType } from '../constants/experiences/ViewType';
2
3
  import type ViewBase from '../views/bases/ViewBase';
3
4
 
4
5
  type ViewConstructor<T extends ViewBase> = new (id: ViewId) => T;
@@ -27,4 +28,18 @@ export default class ViewProxy {
27
28
  public static Has(viewId: ViewId): boolean {
28
29
  return ViewProxy._Views.has(viewId);
29
30
  }
31
+
32
+ public static GetAll<T extends ViewBase>(type?: ViewType): T[] {
33
+ const views: T[] = [];
34
+
35
+ ViewProxy._Views.forEach((view) => {
36
+ if (type && type === view.type) {
37
+ views.push(view as T);
38
+ } else {
39
+ views.push(view as T);
40
+ }
41
+ });
42
+
43
+ return views;
44
+ }
30
45
  }
@@ -1,18 +1,23 @@
1
1
  import type { ViewId } from '../../constants/experiences/ViewId';
2
+ import type { ViewType } from '../../constants/experiences/ViewType';
2
3
 
3
4
  export default class ViewBase {
4
5
  private readonly _id: ViewId;
6
+ private readonly _type: ViewType;
7
+ protected _isVisible: boolean;
5
8
 
6
- constructor(id: ViewId) {
9
+ constructor(id: ViewId, type: ViewType) {
7
10
  this._id = id;
11
+ this._type = type;
12
+ this._isVisible = false;
8
13
  }
9
14
 
10
15
  protected _show(): void {
11
- //
16
+ this._isVisible = true;
12
17
  }
13
18
 
14
19
  protected _hide(): void {
15
- //
20
+ this._isVisible = false;
16
21
  }
17
22
 
18
23
  //#region Getters
@@ -20,6 +25,12 @@ export default class ViewBase {
20
25
  public get id(): ViewId {
21
26
  return this._id;
22
27
  }
28
+ public get type(): ViewType {
29
+ return this._type;
30
+ }
31
+ public get isVisible(): boolean {
32
+ return this._isVisible;
33
+ }
23
34
  //
24
35
  //#endregion
25
36
  }
@@ -1,5 +1,6 @@
1
1
  import { DomEvent } from '../../../constants/doms/DomEvent';
2
2
  import type { ViewId } from '../../../constants/experiences/ViewId';
3
+ import { ViewType } from '../../../constants/experiences/ViewType';
3
4
  import DomUtils from '../../../utils/DomUtils';
4
5
  import ViewBase from '../../bases/ViewBase';
5
6
 
@@ -8,7 +9,7 @@ export default abstract class HTMLViewBase extends ViewBase {
8
9
  protected readonly _htmlContainer: HTMLDivElement;
9
10
 
10
11
  constructor(id: ViewId, parentElement: HTMLElement = DomUtils.GetApp()) {
11
- super(id);
12
+ super(id, ViewType.HTML);
12
13
  this._parentElement = parentElement;
13
14
  this._htmlContainer = document.createElement('div');
14
15
  this._htmlContainer.classList.add('view-html-container');
@@ -1,5 +1,6 @@
1
1
  import { Object3D, Scene } from 'three';
2
2
  import type { ViewId } from '../../../constants/experiences/ViewId';
3
+ import { ViewType } from '../../../constants/experiences/ViewType';
3
4
  import MainThree from '../../../engines/threes/MainThree';
4
5
  import ViewBase from '../../bases/ViewBase';
5
6
 
@@ -8,7 +9,7 @@ export default abstract class ThreeViewBase extends ViewBase {
8
9
  protected _container: Object3D;
9
10
 
10
11
  constructor(id: ViewId, scene: Scene = MainThree.Scene) {
11
- super(id);
12
+ super(id, ViewType.THREE);
12
13
 
13
14
  this._scene = scene;
14
15
  this._container = new Object3D();
@@ -10,6 +10,7 @@ export default class LoaderThreeView extends ThreeViewBase {
10
10
  constructor(id: ViewId) {
11
11
  super(id, MainThree.LoaderScene);
12
12
 
13
+ this._isVisible = true;
13
14
  this._generateLoader();
14
15
 
15
16
  LoaderManager.OnBeginLoad.add(this._onBeginLoad);
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "useDefineForClassFields": true,
5
- "module": "ESNext",
6
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
- "types": ["vite/client", "vite-plugin-glsl/ext"],
8
- "skipLibCheck": true,
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "verbatimModuleSyntax": true,
13
- "moduleDetection": "force",
14
- "noEmit": true,
15
- /* Linting */
16
- "strict": true,
17
- // "noUnusedLocals": true,
18
- // "noUnusedParameters": true,
19
- "erasableSyntaxOnly": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "noUncheckedSideEffectImports": true
22
- },
23
- "include": ["src", "src/**/*.ts", "src/**/*.d.ts"]
24
- }