UNPKG

@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) 679 B
import{Collider as t}from"../Collider.js";class e extends t{constructor(t){super(t,[o])}useCtx(t){const e=this.object;return e.isMesh?(this._params=r(e),super.useCtx(t)):(console.error("TrimeshCollider can be applied only for Mesh"),()=>{})}}const o="convexHull";function r(t){const e=t.geometry.clone();e.applyMatrix4(t.matrixWorld);const r=e.getAttribute("position");if(!r)throw new Error("Mesh geometry has no position attribute");const s=new Float32Array(3*r.count);for(let t=0;t<r.count;t++)s[3*t+0]=r.getX(t),s[3*t+1]=r.getY(t),s[3*t+2]=r.getZ(t);return[o,s]}export{e as ConvexMeshCollider,r as createConvexColliderFromMesh}; //# sourceMappingURL=ConvexMeshCollider.js.map