@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.
3 lines (2 loc) • 1.77 kB
JavaScript
import{T as e,X as r}from"./index-DFZFpUG-.esm.min.js";function t(r){const t=new Set;let n=0;const o=r._vertexWGSL.replace(/@group\(1\)@binding\((\d+)\)\s*var<uniform>\s*(morphDeltas|morph)\s*:/g,(e,r,o)=>(t.add(Number(r)),n++,`@group(1)@binding(${r}) var<storage, read> ${o}:`));2!==n&&e(326,n);const s=r._meshBGLDescriptor.entries.map(e=>t.has(e.binding)?{...e,buffer:{type:"read-only-storage"}}:e);return{...r,_vertexWGSL:o,_meshBGLDescriptor:{...r._meshBGLDescriptor,entries:s}}}function n(){return{_id:"morph",_vertexBuiltins:[{_name:"vertexIndex",_builtin:"vertex_index",_type:"u32"}],_vertexHelperFunctions:"struct morphUniforms {\ncount: u32,\nvertexCount: u32,\n_p0: u32,\n_p1: u32,\nweights: array<f32>,\n}\nstruct morphDeltasUniforms {\nd: array<f32>,\n}",_vertexBindings:[{_name:"morphDeltas",_type:{_kind:"uniform-buffer"},_visibility:1},{_name:"morph",_type:{_kind:"uniform-buffer"},_visibility:1}],_vertexSlots:{VR:"var morphedPos = position;\nvar morphedNorm = normal;\nfor (var i = 0u; i < morph.count; i = i + 1u) {\n let w = morph.weights[i];\n let b = (i * morph.vertexCount + vertexIndex) * 6u;\n morphedPos = morphedPos + w * vec3<f32>(morphDeltas.d[b], morphDeltas.d[b + 1u], morphDeltas.d[b + 2u]);\n morphedNorm = morphedNorm + w * vec3<f32>(morphDeltas.d[b + 3u], morphDeltas.d[b + 4u], morphDeltas.d[b + 5u]);\n}"},_pc:t}}const o={id:"morph",phase:"vertex",frag:e=>e._meshFeatures&r?n():null,bind(e,t,n){const o=e._mesh;return e._meshFeatures&r&&o?.morphTargets?(t.push({binding:n++,resource:{buffer:o.morphTargets.deltasBuffer}}),o.morphTargets.weightsBuffer&&t.push({binding:n++,resource:{buffer:o.morphTargets.weightsBuffer}}),n):n}};export{n as createMorphFragment,o as pbrExt};
//# sourceMappingURL=morph-fragment-D3jALlPB.esm.min.js.map