mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-14 06:25:52 +02:00
wip
This commit is contained in:
@@ -284,10 +284,10 @@ onMounted(async () => {
|
|||||||
if (v == null) {
|
if (v == null) {
|
||||||
interacions.value = [];
|
interacions.value = [];
|
||||||
} else {
|
} else {
|
||||||
interacions.value = Object.entries(v.objectInstance.interactions).map(([interactionId, interactionInfo]) => ({
|
interacions.value = Object.entries(v.objectEntity.interactions).map(([interactionId, interactionInfo]) => ({
|
||||||
id: interactionId,
|
id: interactionId,
|
||||||
label: interactionInfo.label,
|
label: interactionInfo.label,
|
||||||
isPrimary: v.objectInstance.primaryInteraction === interactionId,
|
isPrimary: v.objectEntity.primaryInteraction === interactionId,
|
||||||
fn: interactionInfo.fn,
|
fn: interactionInfo.fn,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -341,8 +341,11 @@ export class RoomEngine {
|
|||||||
private birdeyeCamera: BABYLON.ArcRotateCamera;
|
private birdeyeCamera: BABYLON.ArcRotateCamera;
|
||||||
public intervalIds: number[] = [];
|
public intervalIds: number[] = [];
|
||||||
public timeoutIds: number[] = [];
|
public timeoutIds: number[] = [];
|
||||||
private objectMeshs: Map<string, BABYLON.Mesh> = new Map();
|
public objectEntities: Map<string, {
|
||||||
public objectInstances: Map<string, RoomObjectInstance<any>> = new Map();
|
rootMesh: BABYLON.Mesh;
|
||||||
|
instance: RoomObjectInstance<any>;
|
||||||
|
model: ModelManager;
|
||||||
|
}> = new Map();
|
||||||
private grabbingCtx: {
|
private grabbingCtx: {
|
||||||
objectId: string;
|
objectId: string;
|
||||||
objectType: string;
|
objectType: string;
|
||||||
@@ -361,7 +364,7 @@ export class RoomEngine {
|
|||||||
public selected = shallowRef<{
|
public selected = shallowRef<{
|
||||||
objectId: string;
|
objectId: string;
|
||||||
objectMesh: BABYLON.Mesh;
|
objectMesh: BABYLON.Mesh;
|
||||||
objectInstance: RoomObjectInstance<any>;
|
objectEntity: RoomEngine['objectEntities'] extends Map<string, infer V> ? V : never;
|
||||||
objectState: RoomStateObject<any>;
|
objectState: RoomStateObject<any>;
|
||||||
objectDef: ObjectDef;
|
objectDef: ObjectDef;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
@@ -610,8 +613,8 @@ export class RoomEngine {
|
|||||||
|
|
||||||
watch(this.isEditMode, (v) => {
|
watch(this.isEditMode, (v) => {
|
||||||
if (v) {
|
if (v) {
|
||||||
for (const obji of this.objectInstances.values()) {
|
for (const entity of this.objectEntities.values()) {
|
||||||
obji.resetTemporaryState?.();
|
entity.instance.resetTemporaryState?.();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -703,7 +706,7 @@ export class RoomEngine {
|
|||||||
this.selected.value = {
|
this.selected.value = {
|
||||||
objectId,
|
objectId,
|
||||||
objectMesh: mesh,
|
objectMesh: mesh,
|
||||||
objectInstance: this.objectInstances.get(objectId)!,
|
objectEntity: this.objectEntities.get(objectId)!,
|
||||||
objectState: state,
|
objectState: state,
|
||||||
objectDef: getObjectDef(state.type),
|
objectDef: getObjectDef(state.type),
|
||||||
};
|
};
|
||||||
@@ -1073,8 +1076,7 @@ export class RoomEngine {
|
|||||||
|
|
||||||
model.updated();
|
model.updated();
|
||||||
|
|
||||||
this.objectInstances.set(args.id, objectInstance);
|
this.objectEntities.set(args.id, { instance: objectInstance, rootMesh: root, model });
|
||||||
this.objectMeshs.set(args.id, root);
|
|
||||||
|
|
||||||
return { root, objectInstance };
|
return { root, objectInstance };
|
||||||
}
|
}
|
||||||
@@ -1203,15 +1205,14 @@ export class RoomEngine {
|
|||||||
|
|
||||||
public interact(oid: string) {
|
public interact(oid: string) {
|
||||||
const o = this.roomState.installedObjects.find(o => o.id === oid)!;
|
const o = this.roomState.installedObjects.find(o => o.id === oid)!;
|
||||||
const mesh = this.objectMeshs.get(o.id)!;
|
|
||||||
const objDef = getObjectDef(o.type);
|
const objDef = getObjectDef(o.type);
|
||||||
const obji = this.objectInstances.get(o.id)!;
|
const entity = this.objectEntities.get(o.id)!;
|
||||||
|
|
||||||
if (objDef.isChair) {
|
if (objDef.isChair) {
|
||||||
this.sitChair(o.id);
|
this.sitChair(o.id);
|
||||||
} else {
|
} else {
|
||||||
if (obji.primaryInteraction != null) {
|
if (entity.instance.primaryInteraction != null) {
|
||||||
obji.interactions[obji.primaryInteraction].fn();
|
entity.instance.interactions[entity.instance.primaryInteraction].fn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1379,9 +1380,8 @@ export class RoomEngine {
|
|||||||
|
|
||||||
const objectId = this.selected.value.objectId;
|
const objectId = this.selected.value.objectId;
|
||||||
|
|
||||||
this.objectMeshs.get(objectId)?.dispose();
|
this.objectEntities.get(objectId)?.rootMesh.dispose();
|
||||||
this.objectMeshs.delete(objectId);
|
this.objectEntities.delete(objectId);
|
||||||
this.objectInstances.delete(objectId);
|
|
||||||
this.roomState.installedObjects = this.roomState.installedObjects.filter(o => o.id !== objectId);
|
this.roomState.installedObjects = this.roomState.installedObjects.filter(o => o.id !== objectId);
|
||||||
this.selected.value = null;
|
this.selected.value = null;
|
||||||
|
|
||||||
@@ -1407,9 +1407,9 @@ export class RoomEngine {
|
|||||||
if (options == null) return;
|
if (options == null) return;
|
||||||
options[key] = value;
|
options[key] = value;
|
||||||
|
|
||||||
const obji = this.objectInstances.get(objectId);
|
const entity = this.objectEntities.get(objectId);
|
||||||
if (obji == null) return;
|
if (entity == null) return;
|
||||||
obji.onOptionsUpdated?.([key, value]);
|
entity.instance.onOptionsUpdated?.([key, value]);
|
||||||
|
|
||||||
if (this.selected.value?.objectId === objectId) {
|
if (this.selected.value?.objectId === objectId) {
|
||||||
triggerRef(this.selected);
|
triggerRef(this.selected);
|
||||||
|
|||||||
Reference in New Issue
Block a user