|
@@ -14,13 +14,18 @@ const gltfLoader = new GLTFLoader().setPath("/static/models/");
|
|
const objLoader = new OBJLoader().setPath("/static/models/");
|
|
const objLoader = new OBJLoader().setPath("/static/models/");
|
|
const mtlLoader = new MTLLoader().setPath("/static/models/");
|
|
const mtlLoader = new MTLLoader().setPath("/static/models/");
|
|
|
|
|
|
-const normalized = async (model: Object3D) => {
|
|
|
|
|
|
+const normalized = async (model: Object3D, pub = true) => {
|
|
const parent = new Object3D();
|
|
const parent = new Object3D();
|
|
parent.add(model);
|
|
parent.add(model);
|
|
|
|
|
|
const bbox = new Box3().setFromObject(parent);
|
|
const bbox = new Box3().setFromObject(parent);
|
|
const size = bbox.getSize(new Vector3());
|
|
const size = bbox.getSize(new Vector3());
|
|
- parent.scale.set(1 / size.x, 1 / size.y, 1 / size.z);
|
|
|
|
|
|
+ if (pub) {
|
|
|
|
+ parent.scale.set(1 / size.x, 1 / size.y, 1 / size.z);
|
|
|
|
+ } else {
|
|
|
|
+ const min = Math.max(size.x, size.y, size.z)
|
|
|
|
+ parent.scale.set(1 / min, 1 / min, 1 / min);
|
|
|
|
+ }
|
|
model.traverse((child: any) => {
|
|
model.traverse((child: any) => {
|
|
if (child.isMesh) {
|
|
if (child.isMesh) {
|
|
child.receiveShadow = true;
|
|
child.receiveShadow = true;
|
|
@@ -33,6 +38,7 @@ const normalized = async (model: Object3D) => {
|
|
|
|
|
|
return parent;
|
|
return parent;
|
|
};
|
|
};
|
|
|
|
+
|
|
const resources: Record<string, () => Promise<Object3D>> = {
|
|
const resources: Record<string, () => Promise<Object3D>> = {
|
|
"men_l.svg": async () => {
|
|
"men_l.svg": async () => {
|
|
const gltf = await gltfLoader.loadAsync("door_with_frame/scene.gltf");
|
|
const gltf = await gltfLoader.loadAsync("door_with_frame/scene.gltf");
|
|
@@ -85,6 +91,13 @@ const resources: Record<string, () => Promise<Object3D>> = {
|
|
});
|
|
});
|
|
return await normalized(gltf.scene);
|
|
return await normalized(gltf.scene);
|
|
},
|
|
},
|
|
|
|
+ "DoubleBed.svg": async () => {
|
|
|
|
+ const gltf = await gltfLoader.loadAsync(
|
|
|
|
+ "bed/scene.gltf"
|
|
|
|
+ );
|
|
|
|
+ return await normalized(gltf.scene);
|
|
|
|
+
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
export const getModel = (() => {
|
|
export const getModel = (() => {
|