mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-20 23:25:28 +02:00
wip
This commit is contained in:
BIN
packages/frontend/assets/room/objects/round-rug/round-rug.blend
Normal file
BIN
packages/frontend/assets/room/objects/round-rug/round-rug.blend
Normal file
Binary file not shown.
BIN
packages/frontend/assets/room/objects/round-rug/round-rug.glb
Normal file
BIN
packages/frontend/assets/room/objects/round-rug/round-rug.glb
Normal file
Binary file not shown.
BIN
packages/frontend/assets/room/objects/round-rug/textures/rug.png
Normal file
BIN
packages/frontend/assets/room/objects/round-rug/textures/rug.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Binary file not shown.
Binary file not shown.
@@ -182,6 +182,11 @@ onMounted(() => {
|
|||||||
position: [0, 250, 0],
|
position: [0, 250, 0],
|
||||||
rotation: [0, 0, 0],
|
rotation: [0, 0, 0],
|
||||||
isMainLight: true,
|
isMainLight: true,
|
||||||
|
}, {
|
||||||
|
id: 'w',
|
||||||
|
type: 'round-rug',
|
||||||
|
position: [0, 0, 0],
|
||||||
|
rotation: [0, 0, 0],
|
||||||
}],
|
}],
|
||||||
}, {
|
}, {
|
||||||
canvas: canvas.value!,
|
canvas: canvas.value!,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ type RoomDef = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type ObjectDef = {
|
type ObjectDef = {
|
||||||
placement: 'top' | 'side' | 'bottom';
|
placement: 'top' | 'side' | 'bottom' | 'wall' | 'ceiling' | 'floor';
|
||||||
receiveShadows?: boolean;
|
receiveShadows?: boolean;
|
||||||
castShadows?: 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;
|
||||||
@@ -195,16 +195,16 @@ const OBJECTS = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
aircon: {
|
aircon: {
|
||||||
placement: 'side',
|
placement: 'wall',
|
||||||
},
|
},
|
||||||
'monstera': {
|
'monstera': {
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
},
|
},
|
||||||
'color-box': {
|
'color-box': {
|
||||||
placement: 'top',
|
placement: 'floor',
|
||||||
},
|
},
|
||||||
'steel-rack': {
|
'steel-rack': {
|
||||||
placement: 'top',
|
placement: 'floor',
|
||||||
},
|
},
|
||||||
'plant2': {
|
'plant2': {
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
@@ -216,7 +216,7 @@ const OBJECTS = {
|
|||||||
placement: 'top',
|
placement: 'top',
|
||||||
},
|
},
|
||||||
'bed': {
|
'bed': {
|
||||||
placement: 'top',
|
placement: 'floor',
|
||||||
},
|
},
|
||||||
'aquarium': {
|
'aquarium': {
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
@@ -256,13 +256,13 @@ const OBJECTS = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'desk': {
|
'desk': {
|
||||||
placement: 'top',
|
placement: 'floor',
|
||||||
},
|
},
|
||||||
'chair': {
|
'chair': {
|
||||||
placement: 'top',
|
placement: 'floor',
|
||||||
},
|
},
|
||||||
'chair2': {
|
'chair2': {
|
||||||
placement: 'top',
|
placement: 'floor',
|
||||||
},
|
},
|
||||||
'energy-drink': {
|
'energy-drink': {
|
||||||
placement: 'top',
|
placement: 'top',
|
||||||
@@ -283,7 +283,7 @@ const OBJECTS = {
|
|||||||
placement: 'top',
|
placement: 'top',
|
||||||
},
|
},
|
||||||
'ceiling-fan-light': {
|
'ceiling-fan-light': {
|
||||||
placement: 'bottom',
|
placement: 'ceiling',
|
||||||
receiveShadows: false,
|
receiveShadows: false,
|
||||||
castShadows: false,
|
castShadows: false,
|
||||||
onInit: (room, o, obj) => {
|
onInit: (room, o, obj) => {
|
||||||
@@ -298,6 +298,9 @@ const OBJECTS = {
|
|||||||
room.scene.beginAnimation(rotor, 0, 100, true);
|
room.scene.beginAnimation(rotor, 0, 100, true);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'round-rug': {
|
||||||
|
placement: 'floor',
|
||||||
|
},
|
||||||
} 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 {
|
||||||
@@ -815,7 +818,7 @@ export class RoomEngine {
|
|||||||
if (placement === 'side') {
|
if (placement === 'side') {
|
||||||
// 前方に向かってレイを飛ばす
|
// 前方に向かってレイを飛ばす
|
||||||
const ray = new BABYLON.Ray(this.camera.position, dir, 1000/*cm*/);
|
const ray = new BABYLON.Ray(this.camera.position, dir, 1000/*cm*/);
|
||||||
const hit = this.scene.pickWithRay(ray, (m) => isCollisionTarget(m) && (m.name.startsWith('_COLLISION_WALL_') || m.name.startsWith('_SIDE_')));
|
const hit = this.scene.pickWithRay(ray, (m) => isCollisionTarget(m) && (m.name.startsWith('_ROOM_WALL_') || m.name.startsWith('_SIDE_')));
|
||||||
if (hit != null && hit.pickedPoint != null && hit.pickedMesh != null) {
|
if (hit != null && hit.pickedPoint != null && hit.pickedMesh != null) {
|
||||||
newPos.x = hit.pickedPoint.x;
|
newPos.x = hit.pickedPoint.x;
|
||||||
newPos.y = hit.pickedPoint.y;
|
newPos.y = hit.pickedPoint.y;
|
||||||
@@ -825,19 +828,35 @@ export class RoomEngine {
|
|||||||
newRotation.y = Math.atan2(normalLocal.z, normalLocal.x);
|
newRotation.y = Math.atan2(normalLocal.z, normalLocal.x);
|
||||||
sticky = hit.pickedMesh.metadata?.objectId ?? null;
|
sticky = hit.pickedMesh.metadata?.objectId ?? null;
|
||||||
}
|
}
|
||||||
|
} else if (placement === 'wall') {
|
||||||
|
// 前方に向かってレイを飛ばす
|
||||||
|
const ray = new BABYLON.Ray(this.camera.position, dir, 1000/*cm*/);
|
||||||
|
const hit = this.scene.pickWithRay(ray, (m) => isCollisionTarget(m) && (m.name.startsWith('_ROOM_WALL_')));
|
||||||
|
if (hit != null && hit.pickedPoint != null && hit.pickedMesh != null) {
|
||||||
|
newPos.x = hit.pickedPoint.x;
|
||||||
|
newPos.y = hit.pickedPoint.y;
|
||||||
|
newPos.z = hit.pickedPoint.z;
|
||||||
|
const pickedMeshNormal = hit.getNormal(true, true);
|
||||||
|
const normalLocal = vecToLocal(pickedMeshNormal, hit.pickedMesh);
|
||||||
|
newRotation.y = Math.atan2(normalLocal.z, normalLocal.x);
|
||||||
|
}
|
||||||
} else if (placement === 'bottom') {
|
} else if (placement === 'bottom') {
|
||||||
// 上に向かってレイを飛ばす
|
// 上に向かってレイを飛ばす
|
||||||
const ray = new BABYLON.Ray(grabbing.ghost.position, new BABYLON.Vector3(0, 1, 0), 1000/*cm*/);
|
const ray = new BABYLON.Ray(grabbing.ghost.position, new BABYLON.Vector3(0, 1, 0), 1000/*cm*/);
|
||||||
const hit = this.scene.pickWithRay(ray, (m) => isCollisionTarget(m) && (m.name.startsWith('_COLLISION_CEILING_') || m.name.startsWith('_BOTTOM_')));
|
const hit = this.scene.pickWithRay(ray, (m) => isCollisionTarget(m) && (m.name.startsWith('_ROOM_CEILING_') || m.name.startsWith('_BOTTOM_')));
|
||||||
if (hit != null && hit.pickedPoint != null && hit.pickedMesh != null) {
|
if (hit != null && hit.pickedPoint != null && hit.pickedMesh != null) {
|
||||||
newPos.y = hit.pickedPoint.y;
|
newPos.y = hit.pickedPoint.y;
|
||||||
sticky = hit.pickedMesh.metadata?.objectId ?? null;
|
sticky = hit.pickedMesh.metadata?.objectId ?? null;
|
||||||
}
|
}
|
||||||
if (newPos.y > 250/*cm*/) newPos.y = 250/*cm*/;
|
if (newPos.y > 250/*cm*/) newPos.y = 250/*cm*/;
|
||||||
|
} else if (placement === 'ceiling') {
|
||||||
|
newPos.y = 250/*cm*/;
|
||||||
|
} else if (placement === 'floor') {
|
||||||
|
newPos.y = 0;
|
||||||
} else {
|
} else {
|
||||||
// 下に向かってレイを飛ばす
|
// 下に向かってレイを飛ばす
|
||||||
const ray = new BABYLON.Ray(grabbing.ghost.position, new BABYLON.Vector3(0, -1, 0), 1000/*cm*/);
|
const ray = new BABYLON.Ray(grabbing.ghost.position, new BABYLON.Vector3(0, -1, 0), 1000/*cm*/);
|
||||||
const hit = this.scene.pickWithRay(ray, (m) => isCollisionTarget(m) && (m.name.startsWith('_COLLISION_FLOOR_') || m.name.startsWith('_TOP_')));
|
const hit = this.scene.pickWithRay(ray, (m) => isCollisionTarget(m) && (m.name.startsWith('_ROOM_FLOOR_') || m.name.startsWith('_ROOM_TOP_') || m.name.startsWith('_TOP_')));
|
||||||
if (hit != null && hit.pickedPoint != null && hit.pickedMesh != null) {
|
if (hit != null && hit.pickedPoint != null && hit.pickedMesh != null) {
|
||||||
newPos.y = hit.pickedPoint.y;
|
newPos.y = hit.pickedPoint.y;
|
||||||
sticky = hit.pickedMesh.metadata?.objectId ?? null;
|
sticky = hit.pickedMesh.metadata?.objectId ?? null;
|
||||||
@@ -904,9 +923,8 @@ export class RoomEngine {
|
|||||||
roomObj.meshes[0].scaling = new BABYLON.Vector3(-100, 100, 100);
|
roomObj.meshes[0].scaling = new BABYLON.Vector3(-100, 100, 100);
|
||||||
roomObj.meshes[0].bakeCurrentTransformIntoVertices();
|
roomObj.meshes[0].bakeCurrentTransformIntoVertices();
|
||||||
for (const mesh of roomObj.meshes) {
|
for (const mesh of roomObj.meshes) {
|
||||||
console.log('room mesh:', mesh.name);
|
if (mesh.name.startsWith('_ROOM_WALL_') || mesh.name.startsWith('_ROOM_FLOOR_') || mesh.name.startsWith('_ROOM_CEILING_') || mesh.name.startsWith('_ROOM_TOP_') || mesh.name.startsWith('_ROOM_BOTTOM_') || mesh.name.startsWith('_ROOM_SIDE_')) {
|
||||||
//if (mesh.name === '__root__') continue;
|
mesh.isPickable = false;
|
||||||
if (mesh.name.startsWith('_COLLISION_')) {
|
|
||||||
mesh.receiveShadows = false;
|
mesh.receiveShadows = false;
|
||||||
mesh.isVisible = false;
|
mesh.isVisible = false;
|
||||||
mesh.checkCollisions = true;
|
mesh.checkCollisions = true;
|
||||||
@@ -1050,6 +1068,7 @@ export class RoomEngine {
|
|||||||
mat.transparencyMode = BABYLON.Material.MATERIAL_ALPHABLEND;
|
mat.transparencyMode = BABYLON.Material.MATERIAL_ALPHABLEND;
|
||||||
m.material = mat;
|
m.material = mat;
|
||||||
}
|
}
|
||||||
|
m.checkCollisions = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 子から先に適用していく
|
// 子から先に適用していく
|
||||||
|
|||||||
Reference in New Issue
Block a user