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) 948 B
import*as e from"three";import{CoreContextModule as t}from"@vladkrutenyuk/three-kvy-core";import{RapierPhysics as r}from"./RapierPhysics.js";class s extends t{constructor(){super(...arguments),this._enabled=!0}get enabled(){return this._enabled}set enabled(e){const t=this._lines;t&&(t.visible=e),this._enabled=e}useCtx(t){const s=r.findInCtx(t);if(!s)return;const o=new e.LineSegments(new e.BufferGeometry,new e.LineBasicMaterial({color:16777215,vertexColors:!0}));o.frustumCulled=!1,o.visible=this._enabled,t.three.scene.add(o);const i=()=>{const{vertices:t,colors:r}=s.world.debugRender();o.geometry.setAttribute("position",new e.BufferAttribute(t,3)),o.geometry.setAttribute("color",new e.BufferAttribute(r,4)),o.visible=!0};return s.on("stepafter",i),()=>{this._lines=void 0,o.removeFromParent(),o.geometry.dispose(),o.material.dispose(),s.off("stepafter",i)}}}export{s as RapierDebugRenderer}; //# sourceMappingURL=RapierDebugRenderer.js.map