mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-21 14:35:29 +02:00
wip
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -171,6 +171,11 @@ onMounted(() => {
|
|||||||
type: 'bed',
|
type: 'bed',
|
||||||
position: [-30, 0, -100],
|
position: [-30, 0, -100],
|
||||||
rotation: [0, 0, 0],
|
rotation: [0, 0, 0],
|
||||||
|
}, {
|
||||||
|
id: 'v',
|
||||||
|
type: 'ceiling-fan-light',
|
||||||
|
position: [0, 250, 0],
|
||||||
|
rotation: [0, 0, 0],
|
||||||
}],
|
}],
|
||||||
}, {
|
}, {
|
||||||
canvas: canvas.value!,
|
canvas: canvas.value!,
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ type RoomDef = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type ObjectDef = {
|
type ObjectDef = {
|
||||||
placement: 'top' | 'side';
|
placement: 'top' | 'side' | 'bottom';
|
||||||
|
receiveShadows?: boolean;
|
||||||
|
castShadows?: boolean;
|
||||||
onInit?: (room: RoomEngine, o: RoomDef['objects'][0], obj: BABYLON.ISceneLoaderAsyncResult) => void;
|
onInit?: (room: RoomEngine, o: RoomDef['objects'][0], obj: BABYLON.ISceneLoaderAsyncResult) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -251,10 +253,16 @@ const OBJECTS = {
|
|||||||
ps.start();
|
ps.start();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
desk: {
|
'desk': {
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
},
|
},
|
||||||
chair: {
|
'chair': {
|
||||||
|
placement: 'top',
|
||||||
|
},
|
||||||
|
'chair2': {
|
||||||
|
placement: 'top',
|
||||||
|
},
|
||||||
|
'energy-drink': {
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
},
|
},
|
||||||
'banknote': {
|
'banknote': {
|
||||||
@@ -269,6 +277,26 @@ const OBJECTS = {
|
|||||||
'monitor': {
|
'monitor': {
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
},
|
},
|
||||||
|
'keyboard': {
|
||||||
|
placement: 'top',
|
||||||
|
},
|
||||||
|
'ceiling-fan-light': {
|
||||||
|
placement: 'bottom',
|
||||||
|
receiveShadows: false,
|
||||||
|
castShadows: false,
|
||||||
|
onInit: (room, o, obj) => {
|
||||||
|
const rotor = obj.meshes[0].getChildMeshes().find(m => m.name === 'Rotor') as BABYLON.Mesh;
|
||||||
|
rotor.rotationQuaternion = null;
|
||||||
|
console.log(obj.meshes, obj.meshes[0].getChildMeshes().map(x => x.name), rotor, rotor.getChildMeshes());
|
||||||
|
const anim = new BABYLON.Animation('', 'rotation.y', 60, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
|
||||||
|
anim.setKeys([
|
||||||
|
{ frame: 0, value: 0 },
|
||||||
|
{ frame: 100, value: Math.PI * 2 },
|
||||||
|
]);
|
||||||
|
rotor.animations = [anim];
|
||||||
|
room.scene.beginAnimation(rotor, 0, 100, true);
|
||||||
|
},
|
||||||
|
},
|
||||||
} as Record<string, ObjectDef>;
|
} as Record<string, ObjectDef>;
|
||||||
|
|
||||||
function vecToLocal(vector: BABYLON.Vector3, mesh: BABYLON.Mesh): BABYLON.Vector3 {
|
function vecToLocal(vector: BABYLON.Vector3, mesh: BABYLON.Mesh): BABYLON.Vector3 {
|
||||||
@@ -445,7 +473,7 @@ export class RoomEngine {
|
|||||||
this.envMapIndoor = BABYLON.CubeTexture.CreateFromPrefilteredData('/client-assets/room/indoor.env', this.scene);
|
this.envMapIndoor = BABYLON.CubeTexture.CreateFromPrefilteredData('/client-assets/room/indoor.env', this.scene);
|
||||||
this.envMapIndoor.boundingBoxSize = new BABYLON.Vector3(500/*cm*/, 300/*cm*/, 500/*cm*/);
|
this.envMapIndoor.boundingBoxSize = new BABYLON.Vector3(500/*cm*/, 300/*cm*/, 500/*cm*/);
|
||||||
|
|
||||||
this.envMapOutdoor = BABYLON.CubeTexture.CreateFromPrefilteredData(this.time === 2 ? '/client-assets/room/outdoor-night.env' : '/client-assets/room/outdoor-dayw.env', this.scene);
|
this.envMapOutdoor = BABYLON.CubeTexture.CreateFromPrefilteredData(this.time === 2 ? '/client-assets/room/outdoor-night.env' : '/client-assets/room/outdoor-day.env', this.scene);
|
||||||
this.envMapOutdoor.level = this.time === 0 ? 0.5 : this.time === 1 ? 0.3 : 0.1;
|
this.envMapOutdoor.level = this.time === 0 ? 0.5 : this.time === 1 ? 0.3 : 0.1;
|
||||||
|
|
||||||
if (this.enableReflectionProbe) {
|
if (this.enableReflectionProbe) {
|
||||||
@@ -855,6 +883,8 @@ export class RoomEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async loadObject(o: RoomDef['objects'][0]) {
|
private async loadObject(o: RoomDef['objects'][0]) {
|
||||||
|
const def = OBJECTS[o.type];
|
||||||
|
|
||||||
const obj = await BABYLON.ImportMeshAsync(`/client-assets/room/objects/${o.type}/${o.type}.glb`, this.scene);
|
const obj = await BABYLON.ImportMeshAsync(`/client-assets/room/objects/${o.type}/${o.type}.glb`, this.scene);
|
||||||
obj.meshes[0].scaling = new BABYLON.Vector3(-100, 100, 100);
|
obj.meshes[0].scaling = new BABYLON.Vector3(-100, 100, 100);
|
||||||
obj.meshes[0].bakeCurrentTransformIntoVertices();
|
obj.meshes[0].bakeCurrentTransformIntoVertices();
|
||||||
@@ -889,9 +919,11 @@ export class RoomEngine {
|
|||||||
mesh.isVisible = false;
|
mesh.isVisible = false;
|
||||||
} else {
|
} else {
|
||||||
//if (mesh.name === '__root__') continue;
|
//if (mesh.name === '__root__') continue;
|
||||||
mesh.receiveShadows = true;
|
if (def.receiveShadows !== false) mesh.receiveShadows = true;
|
||||||
this.shadowGenerator1.addShadowCaster(mesh);
|
if (def.castShadows !== false) {
|
||||||
this.shadowGenerator2.addShadowCaster(mesh);
|
this.shadowGenerator1.addShadowCaster(mesh);
|
||||||
|
this.shadowGenerator2.addShadowCaster(mesh);
|
||||||
|
}
|
||||||
|
|
||||||
mesh.renderOutline = false;
|
mesh.renderOutline = false;
|
||||||
mesh.outlineWidth = 0.003;
|
mesh.outlineWidth = 0.003;
|
||||||
|
|||||||
Reference in New Issue
Block a user