mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-13 22:15:41 +02:00
morph
This commit is contained in:
@@ -50,6 +50,7 @@ export const randomBooks = defineObject({
|
||||
placement: 'top',
|
||||
hasCollisions: false,
|
||||
hasTexture: true,
|
||||
canPreMeshesMerging: false,
|
||||
createInstance: ({ options, model, scene, id }) => {
|
||||
const bodyMesh = model.findMesh('__X_BODY__');
|
||||
const tex = new BABYLON.Texture('/client-assets/room/objects/random-books/texture.png', scene, {
|
||||
@@ -57,6 +58,7 @@ export const randomBooks = defineObject({
|
||||
samplingMode: BABYLON.Texture.NEAREST_SAMPLINGMODE,
|
||||
});
|
||||
bodyMesh.material.albedoTexture = tex;
|
||||
bodyMesh.isVisible = false;
|
||||
|
||||
const TEXTURE_DIVISION = 8;
|
||||
let bookMeshes: BABYLON.Mesh[] = [];
|
||||
@@ -127,8 +129,6 @@ export const randomBooks = defineObject({
|
||||
}
|
||||
}
|
||||
|
||||
bodyMesh.isVisible = false;
|
||||
|
||||
model.updated();
|
||||
};
|
||||
|
||||
|
||||
@@ -269,11 +269,18 @@ export class ModelManager {
|
||||
_toMerge.push(fixedMesh);
|
||||
}
|
||||
|
||||
let hasMorphTarget = false;
|
||||
|
||||
const toMerge = [] as BABYLON.Mesh[];
|
||||
for (const mesh of _toMerge) {
|
||||
const newMesh = mesh.name.endsWith('_realized') ? mesh : mesh.clone(mesh.name + '_bakeMerged', null, true);
|
||||
newMesh.makeGeometryUnique();
|
||||
applyMorphTargetsToMesh(newMesh);
|
||||
if (newMesh.morphTargetManager != null && newMesh.morphTargetManager.numTargets > 0) {
|
||||
hasMorphTarget = true;
|
||||
applyMorphTargetsToMesh(newMesh);
|
||||
newMesh.morphTargetManager?.dispose();
|
||||
newMesh.morphTargetManager = null;
|
||||
}
|
||||
if (newMesh.parent === this.root) {
|
||||
newMesh.parent = null;
|
||||
} else {
|
||||
@@ -306,11 +313,15 @@ export class ModelManager {
|
||||
|
||||
const merged = BABYLON.Mesh.MergeMeshes(toMerge, true, false, undefined, false, true);
|
||||
merged.parent = this.root;
|
||||
merged.morphTargetManager?.dispose();
|
||||
merged.morphTargetManager = null;
|
||||
|
||||
merged.material.freeze();
|
||||
if (merged.material instanceof BABYLON.MultiMaterial) {
|
||||
for (const subMat of merged.material.subMaterials) {
|
||||
(subMat as BABYLON.PBRMaterial).freeze();
|
||||
if (!hasMorphTarget) { // https://forum.babylonjs.com/t/is-it-intentional-that-morph-targets-do-not-work-on-meshes-with-frozen-materials/63252
|
||||
merged.material.freeze();
|
||||
if (merged.material instanceof BABYLON.MultiMaterial) {
|
||||
for (const subMat of merged.material.subMaterials) {
|
||||
(subMat as BABYLON.PBRMaterial).freeze();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user