feat: rework entire project structure

This commit is contained in:
2026-03-23 00:04:04 +01:00
parent 6282951b88
commit 8185757933
26 changed files with 1414 additions and 86 deletions

29
app/three/model.ts Normal file
View File

@@ -0,0 +1,29 @@
import * as THREE from "three";
import { GLTF, GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
export default class Model {
private loader: GLTFLoader;
constructor(loader: GLTFLoader) {
this.loader = loader;
}
public async init(model_url: string, scene: THREE.Scene, isVisible: boolean = true): Promise<THREE.Object3D> {
const MODEL = await this.loadModel(`https://web-bucket.s3.fr-par.scw.cloud/${model_url}`);
MODEL.visible = isVisible;
scene.add(MODEL);
return MODEL;
}
public loadModel(model_url: string): Promise<THREE.Object3D> {
return new Promise((resolve, reject) => {
this.loader.setCrossOrigin('anonymous');
this.loader.load(
model_url,
(gltf: GLTF) => resolve(gltf.scene),
undefined,
reject
);
});
}
}