UNPKG

@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.

47 lines (44 loc) 1.61 kB
import { i as TU, ai as U32, d as createMappedBuffer, B as BU } from './index-By0tcgYN.esm.js'; function createSkeleton(engine, joints, weights, boneCount, boneData, joints1, weights1) { const device = engine._device; const texWidth = boneCount * 4; const boneTexture = device.createTexture({ size: [texWidth, 1], format: "rgba32float", usage: TU.TEXTURE_BINDING | TU.COPY_DST }); device.queue.writeTexture({ texture: boneTexture }, boneData.buffer, { bytesPerRow: texWidth * 16 }, { width: texWidth, height: 1 }); const joints32 = new U32(joints.length); for (let i = 0; i < joints.length; i++) { joints32[i] = joints[i]; } const jointsBuffer = createMappedBuffer(engine, joints32, BU.VERTEX); const weightsBuffer = createMappedBuffer(engine, weights, BU.VERTEX); let joints1Buffer = null; let weights1Buffer = null; if (joints1 && weights1) { const joints132 = new U32(joints1.length); for (let i = 0; i < joints1.length; i++) { joints132[i] = joints1[i]; } joints1Buffer = createMappedBuffer(engine, joints132, BU.VERTEX); weights1Buffer = createMappedBuffer(engine, weights1, BU.VERTEX); } const skinBuffers = { jointsBuffer, weightsBuffer, joints1Buffer, weights1Buffer }; return { boneTexture, boneCount, jointsBuffer, weightsBuffer, joints, weights, boneMatrices: boneData, joints1Buffer, weights1Buffer, joints1: joints1 ?? null, weights1: weights1 ?? null, _skinBuffers: skinBuffers }; } export { createSkeleton }; //# sourceMappingURL=create-skeleton-CVW5z17x.esm.js.map