mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-27 16:34:10 +02:00
TransformNode
This commit is contained in:
@@ -1168,8 +1168,10 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
|||||||
const filePath = def.path != null ? `/client-assets/room/objects/${def.path}.glb` : `/client-assets/room/objects/${camelToKebab(args.type)}/${camelToKebab(args.type)}.glb`;
|
const filePath = def.path != null ? `/client-assets/room/objects/${def.path}.glb` : `/client-assets/room/objects/${camelToKebab(args.type)}/${camelToKebab(args.type)}.glb`;
|
||||||
const loaderResult = await BABYLON.LoadAssetContainerAsync(filePath, this.scene);
|
const loaderResult = await BABYLON.LoadAssetContainerAsync(filePath, this.scene);
|
||||||
|
|
||||||
|
const allMeshes = loaderResult.meshes;
|
||||||
|
|
||||||
// babylonによって自動で追加される右手系変換用ノード
|
// babylonによって自動で追加される右手系変換用ノード
|
||||||
const subRoot = loaderResult.meshes[0] as BABYLON.Mesh;
|
let subRoot = allMeshes[0] as BABYLON.TransformNode;
|
||||||
|
|
||||||
if (BAKE_TRANSFORM) {
|
if (BAKE_TRANSFORM) {
|
||||||
subRoot.scaling = new BABYLON.Vector3(1, 1, 1);
|
subRoot.scaling = new BABYLON.Vector3(1, 1, 1);
|
||||||
@@ -1186,7 +1188,7 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
|||||||
//m.parent = root;
|
//m.parent = root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const m of loaderResult.meshes) {
|
for (const m of allMeshes) {
|
||||||
if (m.name === '__root__') continue;
|
if (m.name === '__root__') continue;
|
||||||
if (m.parent === subRoot) {
|
if (m.parent === subRoot) {
|
||||||
m.setParent(root);
|
m.setParent(root);
|
||||||
@@ -1297,7 +1299,19 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
|||||||
|
|
||||||
subRoot.dispose();
|
subRoot.dispose();
|
||||||
} else {
|
} else {
|
||||||
subRoot.scaling = subRoot.scaling.scale(WORLD_SCALE);// cmをmに
|
// meshじゃなくtransform nodeにしてパフォーマンス向上
|
||||||
|
const _subRoot = new BABYLON.TransformNode('__root__', this.scene);
|
||||||
|
_subRoot.scaling.x = -1;
|
||||||
|
_subRoot.scaling = _subRoot.scaling.scale(WORLD_SCALE);// cmをmに
|
||||||
|
|
||||||
|
for (const m of subRoot.getChildren()) {
|
||||||
|
if (m.parent === subRoot) {
|
||||||
|
m.parent = _subRoot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subRoot.dispose();
|
||||||
|
subRoot = _subRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
def.treatLoaderResult?.(loaderResult);
|
def.treatLoaderResult?.(loaderResult);
|
||||||
@@ -1320,7 +1334,7 @@ export class RoomEngine extends EventEmitter<RoomEngineEvents> {
|
|||||||
root.rotation = args.rotation.clone();
|
root.rotation = args.rotation.clone();
|
||||||
root.metadata = metadata;
|
root.metadata = metadata;
|
||||||
|
|
||||||
const model = new ModelManager(BAKE_TRANSFORM ? root : subRoot, loaderResult.meshes.filter(m => m.name !== subRoot), (meshes) => {
|
const model = new ModelManager(BAKE_TRANSFORM ? root : subRoot, allMeshes.filter(m => m.name !== '__root__'), (meshes) => {
|
||||||
if (this.selected?.objectId === args.id) {
|
if (this.selected?.objectId === args.id) {
|
||||||
this.highlightMeshes(meshes);
|
this.highlightMeshes(meshes);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user