@benjos/create-boilerplate 1.5.0 → 1.5.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.
- package/README.md +6 -5
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/template-react/package-lock.json +2 -2
- package/template-react/package.json +1 -1
- package/template-vanilla/package-lock.json +2 -2
- package/template-vanilla/package.json +1 -1
- package/template-vanilla/readme.md +12 -9
- package/template-vue/.prettierignore +6 -0
- package/template-vue/.prettierrc +10 -0
- package/template-vue/eslint.config.js +130 -0
- package/template-vue/index.html +17 -0
- package/template-vue/package-lock.json +4082 -0
- package/template-vue/package.json +43 -0
- package/template-vue/public/assets/fonts/LICENSE +13 -0
- package/template-vue/public/assets/fonts/template.typeface.json +1 -0
- package/template-vue/public/assets/hdrs/template.hdr +0 -0
- package/template-vue/public/assets/icons/benjosLogoBlack.svg +5 -0
- package/template-vue/public/assets/loaders/draco/README.md +32 -0
- package/template-vue/public/assets/loaders/draco/draco_decoder.js +34 -0
- package/template-vue/public/assets/loaders/draco/draco_decoder.wasm +0 -0
- package/template-vue/public/assets/loaders/draco/draco_encoder.js +33 -0
- package/template-vue/public/assets/loaders/draco/draco_wasm_wrapper.js +117 -0
- package/template-vue/public/assets/loaders/draco/gltf/draco_decoder.js +33 -0
- package/template-vue/public/assets/loaders/draco/gltf/draco_decoder.wasm +0 -0
- package/template-vue/public/assets/loaders/draco/gltf/draco_encoder.js +33 -0
- package/template-vue/public/assets/loaders/draco/gltf/draco_wasm_wrapper.js +116 -0
- package/template-vue/public/assets/models/template.glb +0 -0
- package/template-vue/public/assets/textures/template.jpg +0 -0
- package/template-vue/readme.md +34 -0
- package/template-vue/src/experiences/Experience.ts +27 -0
- package/template-vue/src/experiences/cameras/threes/DebugThreeCameraController.ts +55 -0
- package/template-vue/src/experiences/cameras/threes/LoaderThreeCameraController.ts +25 -0
- package/template-vue/src/experiences/cameras/threes/MainThreeCameraController.ts +24 -0
- package/template-vue/src/experiences/cameras/threes/bases/ThreeCameraControllerBase.ts +90 -0
- package/template-vue/src/experiences/commands/InitCommand.ts +50 -0
- package/template-vue/src/experiences/constants/experiences/AnimationId.ts +3 -0
- package/template-vue/src/experiences/constants/experiences/AssetId.ts +8 -0
- package/template-vue/src/experiences/constants/experiences/CameraId.ts +7 -0
- package/template-vue/src/experiences/constants/experiences/DebugGuiTitle.ts +6 -0
- package/template-vue/src/experiences/constants/experiences/Object3dId.ts +3 -0
- package/template-vue/src/experiences/constants/experiences/ViewId.ts +16 -0
- package/template-vue/src/experiences/constants/experiences/ViewType.ts +6 -0
- package/template-vue/src/experiences/engines/threes/MainThree.ts +11 -0
- package/template-vue/src/experiences/engines/threes/app/LoaderThreeApp.ts +49 -0
- package/template-vue/src/experiences/engines/threes/app/MainThreeApp.ts +109 -0
- package/template-vue/src/experiences/engines/threes/app/bases/ThreeAppBase.ts +128 -0
- package/template-vue/src/experiences/engines/vues/MainVue.vue +9 -0
- package/template-vue/src/experiences/managers/DebugManager.ts +87 -0
- package/template-vue/src/experiences/managers/LoaderManager.ts +177 -0
- package/template-vue/src/experiences/managers/threes/ThreeAssetsManager.ts +263 -0
- package/template-vue/src/experiences/managers/threes/ThreeCameraControllerManager.ts +46 -0
- package/template-vue/src/experiences/managers/threes/ThreeRaycasterManager.ts +21 -0
- package/template-vue/src/experiences/materials/threes/loaders/LoaderMaterial.ts +44 -0
- package/template-vue/src/experiences/renderers/threes/LoaderRenderer.ts +18 -0
- package/template-vue/src/experiences/renderers/threes/Renderer.ts +71 -0
- package/template-vue/src/experiences/renderers/threes/bases/WebGLRendererBase.ts +29 -0
- package/template-vue/src/experiences/shaders/threes/loaders/LoaderFragmentShader.glsl +8 -0
- package/template-vue/src/experiences/shaders/threes/loaders/LoaderVertexShader.glsl +3 -0
- package/template-vue/src/experiences/styles/abstracts/_import.scss +5 -0
- package/template-vue/src/experiences/styles/abstracts/functions.scss +3 -0
- package/template-vue/src/experiences/styles/abstracts/mixins.scss +0 -0
- package/template-vue/src/experiences/styles/abstracts/variables.scss +7 -0
- package/template-vue/src/experiences/styles/commons/fonts.scss +10 -0
- package/template-vue/src/experiences/styles/commons/main.scss +59 -0
- package/template-vue/src/experiences/styles/commons/texts.scss +1 -0
- package/template-vue/src/experiences/styles/style.scss +7 -0
- package/template-vue/src/experiences/styles/views/loader.scss +70 -0
- package/template-vue/src/experiences/types/assetTypes.ts +8 -0
- package/template-vue/src/experiences/types/cameraTypes.ts +37 -0
- package/template-vue/src/experiences/types/global.d.ts +9 -0
- package/template-vue/src/experiences/types/shaders.d.ts +4 -0
- package/template-vue/src/experiences/views/threes/bases/ThreeViewBase.ts +49 -0
- package/template-vue/src/experiences/views/threes/loaders/LoaderThreeView.ts +28 -0
- package/template-vue/src/experiences/views/threes/loaders/components/TemplateLoaderThreeActor.ts +49 -0
- package/template-vue/src/experiences/views/threes/worlds/World2ThreeView.ts +35 -0
- package/template-vue/src/experiences/views/threes/worlds/WorldThreeView.ts +35 -0
- package/template-vue/src/experiences/views/threes/worlds/components/Environment.ts +89 -0
- package/template-vue/src/experiences/views/threes/worlds/components/actors/TemplateFont.ts +58 -0
- package/template-vue/src/experiences/views/threes/worlds/components/actors/TemplateMesh.ts +65 -0
- package/template-vue/src/experiences/views/threes/worlds/components/actors/TemplateMesh2.ts +71 -0
- package/template-vue/src/experiences/views/threes/worlds/components/actors/TemplateModel.ts +33 -0
- package/template-vue/src/experiences/views/threes/worlds/components/actors/bases/ThreeActorBase.ts +44 -0
- package/template-vue/src/experiences/views/threes/worlds/components/actors/bases/ThreeAnimatedModelBase.ts +63 -0
- package/template-vue/src/experiences/views/threes/worlds/components/actors/bases/ThreeModelBase.ts +48 -0
- package/template-vue/src/experiences/views/vues/LoaderView.vue +55 -0
- package/template-vue/src/main.ts +7 -0
- package/template-vue/tsconfig.app.json +14 -0
- package/template-vue/tsconfig.json +7 -0
- package/template-vue/tsconfig.node.json +17 -0
- package/template-vue/vite.config.ts +16 -0
|
@@ -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
|
+
}
|
package/template-vue/src/experiences/views/threes/worlds/components/actors/bases/ThreeModelBase.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Mesh, Object3D, type Group } from 'three';
|
|
2
|
+
import { SkeletonUtils } from 'three/examples/jsm/Addons.js';
|
|
3
|
+
import type { AssetId } from '../../../../../../constants/experiences/AssetId';
|
|
4
|
+
import type { Object3DId } from '../../../../../../constants/experiences/Object3dId';
|
|
5
|
+
import ThreeAssetsManager from '../../../../../../managers/threes/ThreeAssetsManager';
|
|
6
|
+
import ThreeActorBase from './ThreeActorBase';
|
|
7
|
+
|
|
8
|
+
export interface ModelBaseParams {
|
|
9
|
+
object3DId?: Object3DId;
|
|
10
|
+
castShadow?: boolean;
|
|
11
|
+
receiveShadow?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default abstract class ThreeModelBase extends ThreeActorBase {
|
|
15
|
+
protected _assetId: AssetId;
|
|
16
|
+
protected _parameters: ModelBaseParams;
|
|
17
|
+
declare protected _model: Group | Object3D | Mesh;
|
|
18
|
+
|
|
19
|
+
constructor(assetId: AssetId, params: ModelBaseParams = {}) {
|
|
20
|
+
super();
|
|
21
|
+
this._assetId = assetId;
|
|
22
|
+
this._parameters = params || {};
|
|
23
|
+
|
|
24
|
+
this._generateModel();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
protected _generateModel(): void {
|
|
28
|
+
const originalModel = ThreeAssetsManager.getModel(this._assetId).scene;
|
|
29
|
+
const model = SkeletonUtils.clone(originalModel);
|
|
30
|
+
|
|
31
|
+
this._model = this._parameters.object3DId
|
|
32
|
+
? (model.getObjectByName(this._parameters.object3DId) ?? model)
|
|
33
|
+
: model;
|
|
34
|
+
|
|
35
|
+
this._model.traverse((child) => {
|
|
36
|
+
if (child instanceof Mesh) {
|
|
37
|
+
if (this._parameters.castShadow) child.castShadow = true;
|
|
38
|
+
if (this._parameters.receiveShadow) child.receiveShadow = true;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
this.add(this._model);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public update(dt: number): void {
|
|
46
|
+
super.update(dt);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
|
3
|
+
import LoaderManager from '../../managers/LoaderManager';
|
|
4
|
+
|
|
5
|
+
const isVisible = ref(false);
|
|
6
|
+
const isEnded = ref(false);
|
|
7
|
+
const loadingNumber = ref(0);
|
|
8
|
+
const barScaleX = ref(0);
|
|
9
|
+
|
|
10
|
+
const barStyle = computed(() =>
|
|
11
|
+
isEnded.value ? undefined : { transform: `translateY(-50%) scaleX(${barScaleX.value})` }
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const onShow = (): void => {
|
|
15
|
+
loadingNumber.value = 0;
|
|
16
|
+
barScaleX.value = 0;
|
|
17
|
+
isEnded.value = false;
|
|
18
|
+
isVisible.value = true;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const onProgress = (): void => {
|
|
22
|
+
const progress = LoaderManager.progress * 100;
|
|
23
|
+
barScaleX.value = LoaderManager.progress;
|
|
24
|
+
loadingNumber.value = Math.round(progress);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const onHide = (): void => {
|
|
28
|
+
loadingNumber.value = 100;
|
|
29
|
+
barScaleX.value = 1;
|
|
30
|
+
isEnded.value = true;
|
|
31
|
+
isVisible.value = false;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
onMounted(() => {
|
|
35
|
+
LoaderManager.onShow.add(onShow);
|
|
36
|
+
LoaderManager.onProgress.add(onProgress);
|
|
37
|
+
LoaderManager.onHide.add(onHide);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
onUnmounted(() => {
|
|
41
|
+
LoaderManager.onShow.remove(onShow);
|
|
42
|
+
LoaderManager.onProgress.remove(onProgress);
|
|
43
|
+
LoaderManager.onHide.remove(onHide);
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<div id="loading-screen" class="html-view loading-screen" :class="{ show: isVisible }">
|
|
49
|
+
<div class="loading-progress">
|
|
50
|
+
<span class="loading-number">{{ loadingNumber }}</span>
|
|
51
|
+
<span>%</span>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="loading-bar" :class="{ ended: isEnded }" :style="barStyle"></div>
|
|
54
|
+
</div>
|
|
55
|
+
</template>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "ES2020",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"noEmit": true,
|
|
10
|
+
"verbatimModuleSyntax": false,
|
|
11
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo"
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts", "src/**/*.vue"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
+
"target": "ES2023",
|
|
5
|
+
"lib": ["ES2023"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
11
|
+
"verbatimModuleSyntax": true,
|
|
12
|
+
"moduleDetection": "force",
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"strict": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["vite.config.ts"]
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import vue from '@vitejs/plugin-vue';
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import glsl from 'vite-plugin-glsl';
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
base: './',
|
|
7
|
+
server: {
|
|
8
|
+
host: true,
|
|
9
|
+
},
|
|
10
|
+
build: {
|
|
11
|
+
outDir: './dist',
|
|
12
|
+
emptyOutDir: true,
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
},
|
|
15
|
+
plugins: [vue(), glsl()],
|
|
16
|
+
});
|