@vladkrutenyuk/three-kvy-core
Version:
Everything you need to create any-complexity 3D apps with Three.js. Empower Three.js with a modular, lifecycle-managed context that seamlessly propagates through objects via reusable features providing structured logic.
3 lines (2 loc) • 751 B
JavaScript
import{Collider as t}from"../Collider.js";class e extends t{constructor(t){super(t,[r])}useCtx(t){const e=this.object;return e.isMesh?(this._params=o(e),super.useCtx(t)):(console.error("TrimeshCollider can be applied only for Mesh"),()=>{})}}const r="trimesh";function o(t){const e=t.geometry.clone();e.applyMatrix4(t.matrixWorld);const o=e.getAttribute("position"),s=e.index;if(!o||!s)throw new Error("Geometry must have position and index attributes to create trimesh");const n=new Float32Array(3*o.count);for(let t=0;t<o.count;t++)n[3*t+0]=o.getX(t),n[3*t+1]=o.getY(t),n[3*t+2]=o.getZ(t);const i=new Uint32Array(s.array);return[r,n,i]}export{e as TrimeshCollider,o as createTrimeshColliderArgsFromMesh};
//# sourceMappingURL=TrimeshCollider.js.map