mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-23 08:44:05 +02:00
wip
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -216,7 +216,7 @@ const data = localStorage.getItem('roomData') != null ? { ...JSON.parse(localSto
|
|||||||
},
|
},
|
||||||
wallE: {
|
wallE: {
|
||||||
material: null,
|
material: null,
|
||||||
color: [0.9, 0.9, 0.9],
|
color: [0.33, 0.34, 0.35],
|
||||||
},
|
},
|
||||||
wallS: {
|
wallS: {
|
||||||
material: null,
|
material: null,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import { reactive, ref, shallowRef, triggerRef, watch } from 'vue';
|
|||||||
import { genId } from '../id.js';
|
import { genId } from '../id.js';
|
||||||
import { deepClone } from '../clone.js';
|
import { deepClone } from '../clone.js';
|
||||||
import { getObjectDef } from './object-defs.js';
|
import { getObjectDef } from './object-defs.js';
|
||||||
import { HorizontalCameraKeyboardMoveInput } from './utility.js';
|
import { HorizontalCameraKeyboardMoveInput, findMaterial } from './utility.js';
|
||||||
import * as sound from '@/utility/sound.js';
|
import * as sound from '@/utility/sound.js';
|
||||||
|
|
||||||
// babylonのドメイン知識は持たない
|
// babylonのドメイン知識は持たない
|
||||||
@@ -758,49 +758,59 @@ export class RoomEngine {
|
|||||||
|
|
||||||
const meshes: BABYLON.Mesh[] = [];
|
const meshes: BABYLON.Mesh[] = [];
|
||||||
|
|
||||||
const floorResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-floor.glb', this.scene);
|
if (this.roomState.heya.type === 'simple') {
|
||||||
floorResult.meshes[0].scaling = floorResult.meshes[0].scaling.scale(WORLD_SCALE);
|
const floorResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-floor.glb', this.scene);
|
||||||
const floorRoot = new BABYLON.Mesh('floor', this.scene);
|
floorResult.meshes[0].scaling = floorResult.meshes[0].scaling.scale(WORLD_SCALE);
|
||||||
floorRoot.addChild(floorResult.meshes[0]);
|
const floorRoot = new BABYLON.Mesh('floor', this.scene);
|
||||||
meshes.push(floorRoot);
|
floorRoot.addChild(floorResult.meshes[0]);
|
||||||
|
meshes.push(floorRoot);
|
||||||
|
|
||||||
const ceilingResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-ceiling.glb', this.scene);
|
const ceilingResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-ceiling.glb', this.scene);
|
||||||
ceilingResult.meshes[0].scaling = ceilingResult.meshes[0].scaling.scale(WORLD_SCALE);
|
ceilingResult.meshes[0].scaling = ceilingResult.meshes[0].scaling.scale(WORLD_SCALE);
|
||||||
const ceilingRoot = new BABYLON.Mesh('ceiling', this.scene);
|
const ceilingRoot = new BABYLON.Mesh('ceiling', this.scene);
|
||||||
ceilingRoot.addChild(ceilingResult.meshes[0]);
|
ceilingRoot.addChild(ceilingResult.meshes[0]);
|
||||||
ceilingRoot.position = new BABYLON.Vector3(0, 250/*cm*/, 0);
|
ceilingRoot.position = new BABYLON.Vector3(0, 250/*cm*/, 0);
|
||||||
meshes.push(ceilingRoot);
|
meshes.push(ceilingRoot);
|
||||||
|
|
||||||
const wallEResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-wall.glb', this.scene);
|
const wallEResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-wall.glb', this.scene);
|
||||||
wallEResult.meshes[0].scaling = wallEResult.meshes[0].scaling.scale(WORLD_SCALE);
|
wallEResult.meshes[0].scaling = wallEResult.meshes[0].scaling.scale(WORLD_SCALE);
|
||||||
const wallERoot = new BABYLON.Mesh('wallE', this.scene);
|
const wallERoot = new BABYLON.Mesh('wallE', this.scene);
|
||||||
wallERoot.addChild(wallEResult.meshes[0]);
|
wallERoot.addChild(wallEResult.meshes[0]);
|
||||||
wallERoot.position = new BABYLON.Vector3(-150/*cm*/, 0, 0);
|
wallERoot.position = new BABYLON.Vector3(-150/*cm*/, 0, 0);
|
||||||
wallERoot.rotation = new BABYLON.Vector3(0, Math.PI, 0);
|
wallERoot.rotation = new BABYLON.Vector3(0, Math.PI, 0);
|
||||||
meshes.push(wallERoot);
|
meshes.push(wallERoot);
|
||||||
|
const wallEMaterial = findMaterial(wallEResult.meshes[0], '__X_WALL__');
|
||||||
|
wallEMaterial.albedoColor = new BABYLON.Color3(...this.roomState.heya.options.wallE.color);
|
||||||
|
|
||||||
const wallWResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-wall.glb', this.scene);
|
const wallWResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-wall.glb', this.scene);
|
||||||
wallWResult.meshes[0].scaling = wallWResult.meshes[0].scaling.scale(WORLD_SCALE);
|
wallWResult.meshes[0].scaling = wallWResult.meshes[0].scaling.scale(WORLD_SCALE);
|
||||||
const wallWRoot = new BABYLON.Mesh('wallW', this.scene);
|
const wallWRoot = new BABYLON.Mesh('wallW', this.scene);
|
||||||
wallWRoot.addChild(wallWResult.meshes[0]);
|
wallWRoot.addChild(wallWResult.meshes[0]);
|
||||||
wallWRoot.position = new BABYLON.Vector3(150/*cm*/, 0, 0);
|
wallWRoot.position = new BABYLON.Vector3(150/*cm*/, 0, 0);
|
||||||
meshes.push(wallWRoot);
|
meshes.push(wallWRoot);
|
||||||
|
const wallWMaterial = findMaterial(wallWResult.meshes[0], '__X_WALL__');
|
||||||
|
wallWMaterial.albedoColor = new BABYLON.Color3(...this.roomState.heya.options.wallW.color);
|
||||||
|
|
||||||
const wallNResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-wall.glb', this.scene);
|
const wallNResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-wall.glb', this.scene);
|
||||||
wallNResult.meshes[0].scaling = wallNResult.meshes[0].scaling.scale(WORLD_SCALE);
|
wallNResult.meshes[0].scaling = wallNResult.meshes[0].scaling.scale(WORLD_SCALE);
|
||||||
const wallNRoot = new BABYLON.Mesh('wallN', this.scene);
|
const wallNRoot = new BABYLON.Mesh('wallN', this.scene);
|
||||||
wallNRoot.addChild(wallNResult.meshes[0]);
|
wallNRoot.addChild(wallNResult.meshes[0]);
|
||||||
wallNRoot.position = new BABYLON.Vector3(0, 0, -150/*cm*/);
|
wallNRoot.position = new BABYLON.Vector3(0, 0, -150/*cm*/);
|
||||||
wallNRoot.rotation = new BABYLON.Vector3(0, Math.PI / 2, 0);
|
wallNRoot.rotation = new BABYLON.Vector3(0, Math.PI / 2, 0);
|
||||||
meshes.push(wallNRoot);
|
meshes.push(wallNRoot);
|
||||||
|
const wallNMaterial = findMaterial(wallNResult.meshes[0], '__X_WALL__');
|
||||||
|
wallNMaterial.albedoColor = new BABYLON.Color3(...this.roomState.heya.options.wallN.color);
|
||||||
|
|
||||||
const wallSResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-wall-demado.glb', this.scene);
|
const wallSResult = await BABYLON.ImportMeshAsync('/client-assets/room/rooms/default/300-wall-demado.glb', this.scene);
|
||||||
wallSResult.meshes[0].scaling = wallSResult.meshes[0].scaling.scale(WORLD_SCALE);
|
wallSResult.meshes[0].scaling = wallSResult.meshes[0].scaling.scale(WORLD_SCALE);
|
||||||
const wallSRoot = new BABYLON.Mesh('wallS', this.scene);
|
const wallSRoot = new BABYLON.Mesh('wallS', this.scene);
|
||||||
wallSRoot.addChild(wallSResult.meshes[0]);
|
wallSRoot.addChild(wallSResult.meshes[0]);
|
||||||
wallSRoot.position = new BABYLON.Vector3(0, 0, 150/*cm*/);
|
wallSRoot.position = new BABYLON.Vector3(0, 0, 150/*cm*/);
|
||||||
wallSRoot.rotation = new BABYLON.Vector3(0, -Math.PI / 2, 0);
|
wallSRoot.rotation = new BABYLON.Vector3(0, -Math.PI / 2, 0);
|
||||||
meshes.push(wallSRoot);
|
meshes.push(wallSRoot);
|
||||||
|
const wallSMaterial = findMaterial(wallSResult.meshes[0], '__X_WALL__');
|
||||||
|
wallSMaterial.albedoColor = new BABYLON.Color3(...this.roomState.heya.options.wallS.color);
|
||||||
|
}
|
||||||
|
|
||||||
for (const mesh of meshes) {
|
for (const mesh of meshes) {
|
||||||
for (const m of mesh.getChildMeshes()) {
|
for (const m of mesh.getChildMeshes()) {
|
||||||
@@ -944,20 +954,7 @@ export class RoomEngine {
|
|||||||
return meshes as BABYLON.Mesh[];
|
return meshes as BABYLON.Mesh[];
|
||||||
},
|
},
|
||||||
findMaterial: (keyword) => {
|
findMaterial: (keyword) => {
|
||||||
for (const m of root.getChildMeshes()) {
|
return findMaterial(root, keyword);
|
||||||
if (m.material == null) continue;
|
|
||||||
if (m.material.name.includes(keyword)) {
|
|
||||||
return m.material as BABYLON.PBRMaterial;
|
|
||||||
} else if ((m.material as BABYLON.MultiMaterial).subMaterials != null) {
|
|
||||||
for (const sm of (m.material as BABYLON.MultiMaterial).subMaterials) {
|
|
||||||
if (sm == null) continue;
|
|
||||||
if (sm.name.includes(keyword)) {
|
|
||||||
return sm as BABYLON.PBRMaterial;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Error(`Material with keyword "${keyword}" not found for object ${args.type} (${args.id})`);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -467,3 +467,20 @@ export function createPlaneUvMapper(mesh: BABYLON.Mesh) {
|
|||||||
mesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
|
mesh.updateVerticesData(BABYLON.VertexBuffer.UVKind, uvs);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function findMaterial(rootMesh: BABYLON.AbstractMesh, keyword: string): BABYLON.PBRMaterial {
|
||||||
|
for (const m of rootMesh.getChildMeshes()) {
|
||||||
|
if (m.material == null) continue;
|
||||||
|
if (m.material.name.includes(keyword)) {
|
||||||
|
return m.material as BABYLON.PBRMaterial;
|
||||||
|
} else if ((m.material as BABYLON.MultiMaterial).subMaterials != null) {
|
||||||
|
for (const sm of (m.material as BABYLON.MultiMaterial).subMaterials) {
|
||||||
|
if (sm == null) continue;
|
||||||
|
if (sm.name.includes(keyword)) {
|
||||||
|
return sm as BABYLON.PBRMaterial;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error(`Material with keyword "${keyword}" not found`);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user