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