mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-06 02:54:09 +02:00
Update engine.ts
This commit is contained in:
@@ -188,13 +188,14 @@ class ModelManager {
|
||||
}
|
||||
|
||||
public bakeMesh() {
|
||||
try {
|
||||
for (const m of this.bakedMeshes) {
|
||||
m.dispose();
|
||||
}
|
||||
this.bakedMeshes = [];
|
||||
|
||||
const childMeshes = this.root.getChildMeshes().filter(m => !this.bakeExcludeMeshes.some(x => x === m) && m.isVisible && !m.name.includes('__TOP__') && !m.name.includes('__SIDE__') && !m.name.includes('__COLLISION__'));
|
||||
const excludeMeshes = [...this.bakeExcludeMeshes, ...this.root.getChildMeshes().filter(m => m.name.includes('__TOP__') || m.name.includes('__SIDE__') || m.name.includes('__COLLISION__'))];
|
||||
|
||||
const childMeshes = this.root.getChildMeshes().filter(m => !excludeMeshes.some(x => x === m) && m.isVisible);
|
||||
|
||||
const _toMerge = [] as BABYLON.Mesh[];
|
||||
for (const mesh of childMeshes) {
|
||||
@@ -253,10 +254,7 @@ class ModelManager {
|
||||
|
||||
this.bakedMeshes = [merged];
|
||||
|
||||
this.bakedCallback?.([...this.bakedMeshes, ...this.bakeExcludeMeshes]);
|
||||
} catch (err) {
|
||||
console.error('Failed to bake mesh for object', this.root.metadata?.objectType, err);
|
||||
}
|
||||
this.bakedCallback?.([...this.bakedMeshes, ...excludeMeshes]);
|
||||
}
|
||||
|
||||
public unbakeMesh() {
|
||||
@@ -631,17 +629,12 @@ export class RoomEngine {
|
||||
|
||||
for (const entity of this.objectEntities.values()) {
|
||||
entity.instance.resetTemporaryState?.();
|
||||
entity.model.unbakeMesh();
|
||||
}
|
||||
} else {
|
||||
if (this.selectionOutlineLayer != null) {
|
||||
this.selectionOutlineLayer.dispose();
|
||||
this.selectionOutlineLayer = null;
|
||||
}
|
||||
|
||||
for (const entity of this.objectEntities.values()) {
|
||||
entity.model.bakeMesh();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -720,6 +713,7 @@ export class RoomEngine {
|
||||
|
||||
public selectObject(objectId: string | null) {
|
||||
if (this.selected.value != null) {
|
||||
this.selected.value.objectEntity.model.bakeMesh();
|
||||
if (this.selectionOutlineLayer != null) this.selectionOutlineLayer.clearSelection();
|
||||
this.selected.value = null;
|
||||
}
|
||||
@@ -727,6 +721,7 @@ export class RoomEngine {
|
||||
if (objectId != null) {
|
||||
const entity = this.objectEntities.get(objectId);
|
||||
if (entity != null) {
|
||||
if (this.isEditMode.value) entity.model.unbakeMesh();
|
||||
if (this.selectionOutlineLayer != null) this.selectionOutlineLayer.addSelection(entity.rootMesh.getChildMeshes());
|
||||
const state = this.roomState.installedObjects.find(o => o.id === objectId)!;
|
||||
this.selected.value = {
|
||||
|
||||
Reference in New Issue
Block a user