mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-05 18:44:09 +02:00
Update engine.ts
This commit is contained in:
@@ -637,17 +637,9 @@ export class RoomEngine {
|
|||||||
|
|
||||||
watch(this.isEditMode, (v) => {
|
watch(this.isEditMode, (v) => {
|
||||||
if (v) {
|
if (v) {
|
||||||
// 選択した後選択解除して再度選択しようとするとエラーになる
|
|
||||||
//this.selectionOutlineLayer = new BABYLON.SelectionOutlineLayer('outliner', this.scene);
|
|
||||||
|
|
||||||
for (const entity of this.objectEntities.values()) {
|
for (const entity of this.objectEntities.values()) {
|
||||||
entity.instance.resetTemporaryState?.();
|
entity.instance.resetTemporaryState?.();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (this.selectionOutlineLayer != null) {
|
|
||||||
this.selectionOutlineLayer.dispose();
|
|
||||||
this.selectionOutlineLayer = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -726,7 +718,7 @@ export class RoomEngine {
|
|||||||
|
|
||||||
public selectObject(objectId: string | null) {
|
public selectObject(objectId: string | null) {
|
||||||
if (this.selected.value != null) {
|
if (this.selected.value != null) {
|
||||||
if (this.selectionOutlineLayer != null) this.selectionOutlineLayer.clearSelection();
|
this.clearHighlight();
|
||||||
this.selected.value.objectEntity.model.bakeMesh();
|
this.selected.value.objectEntity.model.bakeMesh();
|
||||||
this.selected.value = null;
|
this.selected.value = null;
|
||||||
}
|
}
|
||||||
@@ -735,7 +727,7 @@ export class RoomEngine {
|
|||||||
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.isEditMode.value) entity.model.unbakeMesh();
|
||||||
if (this.selectionOutlineLayer != null) this.selectionOutlineLayer.addSelection(entity.rootMesh.getChildMeshes());
|
this.highlightMeshes(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 = {
|
||||||
objectId,
|
objectId,
|
||||||
@@ -1039,10 +1031,7 @@ export class RoomEngine {
|
|||||||
|
|
||||||
const model = new ModelManager(subRoot, loaderResult.meshes.filter(m => m !== subRoot), (meshes) => {
|
const model = new ModelManager(subRoot, loaderResult.meshes.filter(m => m !== subRoot), (meshes) => {
|
||||||
if (this.selected.value?.objectId === args.id) {
|
if (this.selected.value?.objectId === args.id) {
|
||||||
if (this.selectionOutlineLayer != null) {
|
this.highlightMeshes(meshes);
|
||||||
this.selectionOutlineLayer.clearSelection();
|
|
||||||
this.selectionOutlineLayer.addSelection(meshes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const m of meshes) {
|
for (const m of meshes) {
|
||||||
@@ -1102,11 +1091,24 @@ export class RoomEngine {
|
|||||||
return { root, objectInstance };
|
return { root, objectInstance };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private highlightMeshes(meshes: BABYLON.AbstractMesh[]) {
|
||||||
|
this.clearHighlight();
|
||||||
|
this.selectionOutlineLayer = new BABYLON.SelectionOutlineLayer('outliner', this.scene);
|
||||||
|
this.selectionOutlineLayer.addSelection(meshes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private clearHighlight() {
|
||||||
|
if (this.selectionOutlineLayer != null) {
|
||||||
|
this.selectionOutlineLayer.dispose();
|
||||||
|
this.selectionOutlineLayer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public beginSelectedInstalledObjectGrabbing() {
|
public beginSelectedInstalledObjectGrabbing() {
|
||||||
if (this.selected.value == null) return;
|
if (this.selected.value == null) return;
|
||||||
|
|
||||||
const selectedObject = this.selected.value.objectEntity.rootMesh;
|
const selectedObject = this.selected.value.objectEntity.rootMesh;
|
||||||
if (this.selectionOutlineLayer != null) this.selectionOutlineLayer.clearSelection();
|
this.clearHighlight();
|
||||||
|
|
||||||
// 子から先に適用していく
|
// 子から先に適用していく
|
||||||
const setStickyParentRecursively = (mesh: BABYLON.AbstractMesh) => {
|
const setStickyParentRecursively = (mesh: BABYLON.AbstractMesh) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user