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.

44 lines (40 loc) 1.34 kB
import { au as mat4Determinant3 } from './index-DMbDahsc.esm.js'; function buildPrimitiveState(topo, indexU32) { const prim = { topology: topo === 1 ? "point-list" : topo === 2 ? "line-list" : topo === 3 ? "line-strip" : "triangle-strip" }; if (topo < 4) { prim.cullMode = "none"; } if (topo > 2) { prim.stripIndexFormat = indexU32 ? "uint32" : "uint16"; } return prim; } const MSH_REVERSE_WINDING = 1 << 11; const MSH_TOPOLOGY_SHIFT = 12; const MSH_INDEX_U32 = 1 << 15; const feature = { id: "_primitive", async applyMesh(meshData, mesh) { const mode = meshData._primitive?.mode; const topo = mode === 0 ? 1 : mode & 1 ? mode + 3 >> 1 : void 0; const mirrored = mat4Determinant3(meshData._worldMatrix) > 0; let features = topo ? topo << MSH_TOPOLOGY_SHIFT | (topo > 2 && mesh._gpu.indexFormat === "uint32" ? MSH_INDEX_U32 : 0) : 0; if (mirrored) { features |= MSH_REVERSE_WINDING; } if (topo || mirrored) { const prim = topo ? buildPrimitiveState(topo, mesh._gpu.indexFormat === "uint32") : {}; if (mirrored) { prim.frontFace = "cw"; } mesh._primitive = prim; } if (features) { mesh._primitiveFeatures = features; } } }; export { feature as default }; //# sourceMappingURL=gltf-feature-primitive-_T6tuILC.esm.js.map