mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-06-25 17:10:43 +00:00
morph
This commit is contained in:
parent
924c517bb5
commit
8d3a5a6503
2 changed files with 19 additions and 8 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue