@babylonjs/viewer
Version:
The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.
30 lines (27 loc) • 1.25 kB
JavaScript
import { aj as resolveAccessor, F as F32 } from './index-By0tcgYN.esm.js';
const feature = {
id: "_morph",
async applyMesh(meshData, mesh, ctx) {
const primitive = meshData._primitive;
const targets = primitive.targets;
if (!targets || targets.length === 0) {
return;
}
const { _json: json, _binChunk: binChunk } = ctx;
const morphTargets = [];
for (const target of targets) {
const posAcc = target.POSITION !== void 0 ? resolveAccessor(json, binChunk, target.POSITION) : null;
const normAcc = target.NORMAL !== void 0 ? resolveAccessor(json, binChunk, target.NORMAL) : null;
morphTargets.push({
positions: posAcc ? posAcc._data : new F32(meshData._vertexCount * 3),
normals: normAcc ? normAcc._data : null
});
}
const parentMesh = json.meshes[json.nodes[meshData._nodeIndex].mesh];
const morphWeights = parentMesh.weights ?? new Array(targets.length).fill(0);
const { createMorphTargets } = await import('./create-morph-targets-DN5cvIg1.esm.js');
mesh.morphTargets = createMorphTargets(ctx._engine, morphTargets, meshData._vertexCount, morphWeights);
}
};
export { feature as default };
//# sourceMappingURL=gltf-feature-morph-B2-qmXTu.esm.js.map