1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-13 17:35:40 +02:00
This commit is contained in:
syuilo
2026-04-03 10:13:43 +09:00
parent b91409f5c6
commit d5a5b04468
2 changed files with 20 additions and 20 deletions

View File

@@ -284,10 +284,10 @@ onMounted(async () => {
if (v == null) {
interacions.value = [];
} else {
interacions.value = Object.entries(v.objectInstance.interactions).map(([interactionId, interactionInfo]) => ({
interacions.value = Object.entries(v.objectEntity.interactions).map(([interactionId, interactionInfo]) => ({
id: interactionId,
label: interactionInfo.label,
isPrimary: v.objectInstance.primaryInteraction === interactionId,
isPrimary: v.objectEntity.primaryInteraction === interactionId,
fn: interactionInfo.fn,
}));
}

View File

@@ -341,8 +341,11 @@ export class RoomEngine {
private birdeyeCamera: BABYLON.ArcRotateCamera;
public intervalIds: number[] = [];
public timeoutIds: number[] = [];
private objectMeshs: Map<string, BABYLON.Mesh> = new Map();
public objectInstances: Map<string, RoomObjectInstance<any>> = new Map();
public objectEntities: Map<string, {
rootMesh: BABYLON.Mesh;
instance: RoomObjectInstance<any>;
model: ModelManager;
}> = new Map();
private grabbingCtx: {
objectId: string;
objectType: string;
@@ -361,7 +364,7 @@ export class RoomEngine {
public selected = shallowRef<{
objectId: string;
objectMesh: BABYLON.Mesh;
objectInstance: RoomObjectInstance<any>;
objectEntity: RoomEngine['objectEntities'] extends Map<string, infer V> ? V : never;
objectState: RoomStateObject<any>;
objectDef: ObjectDef;
} | null>(null);
@@ -610,8 +613,8 @@ export class RoomEngine {
watch(this.isEditMode, (v) => {
if (v) {
for (const obji of this.objectInstances.values()) {
obji.resetTemporaryState?.();
for (const entity of this.objectEntities.values()) {
entity.instance.resetTemporaryState?.();
}
}
});
@@ -703,7 +706,7 @@ export class RoomEngine {
this.selected.value = {
objectId,
objectMesh: mesh,
objectInstance: this.objectInstances.get(objectId)!,
objectEntity: this.objectEntities.get(objectId)!,
objectState: state,
objectDef: getObjectDef(state.type),
};
@@ -1073,8 +1076,7 @@ export class RoomEngine {
model.updated();
this.objectInstances.set(args.id, objectInstance);
this.objectMeshs.set(args.id, root);
this.objectEntities.set(args.id, { instance: objectInstance, rootMesh: root, model });
return { root, objectInstance };
}
@@ -1203,15 +1205,14 @@ export class RoomEngine {
public interact(oid: string) {
const o = this.roomState.installedObjects.find(o => o.id === oid)!;
const mesh = this.objectMeshs.get(o.id)!;
const objDef = getObjectDef(o.type);
const obji = this.objectInstances.get(o.id)!;
const entity = this.objectEntities.get(o.id)!;
if (objDef.isChair) {
this.sitChair(o.id);
} else {
if (obji.primaryInteraction != null) {
obji.interactions[obji.primaryInteraction].fn();
if (entity.instance.primaryInteraction != null) {
entity.instance.interactions[entity.instance.primaryInteraction].fn();
}
}
}
@@ -1379,9 +1380,8 @@ export class RoomEngine {
const objectId = this.selected.value.objectId;
this.objectMeshs.get(objectId)?.dispose();
this.objectMeshs.delete(objectId);
this.objectInstances.delete(objectId);
this.objectEntities.get(objectId)?.rootMesh.dispose();
this.objectEntities.delete(objectId);
this.roomState.installedObjects = this.roomState.installedObjects.filter(o => o.id !== objectId);
this.selected.value = null;
@@ -1407,9 +1407,9 @@ export class RoomEngine {
if (options == null) return;
options[key] = value;
const obji = this.objectInstances.get(objectId);
if (obji == null) return;
obji.onOptionsUpdated?.([key, value]);
const entity = this.objectEntities.get(objectId);
if (entity == null) return;
entity.instance.onOptionsUpdated?.([key, value]);
if (this.selected.value?.objectId === objectId) {
triggerRef(this.selected);