Buckets:
| import { LineSegments, LineBasicMaterial, BufferAttribute } from 'three'; | |
| /** | |
| * This class displays all Rapier Colliders in outline. | |
| * | |
| * @augments LineSegments | |
| * @three_import import { RapierHelper } from 'three/addons/helpers/RapierHelper.js'; | |
| */ | |
| class RapierHelper extends LineSegments { | |
| /** | |
| * Constructs a new Rapier debug helper. | |
| * | |
| * @param {RAPIER.world} world - The Rapier world to visualize. | |
| */ | |
| constructor( world ) { | |
| super(); | |
| /** | |
| * The Rapier world to visualize. | |
| * | |
| * @type {RAPIER.world} | |
| */ | |
| this.world = world; | |
| this.material = new LineBasicMaterial( { vertexColors: true } ); | |
| this.frustumCulled = false; | |
| } | |
| /** | |
| * Call this in the render loop to update the outlines. | |
| */ | |
| update() { | |
| const { vertices, colors } = this.world.debugRender(); | |
| this.geometry.deleteAttribute( 'position' ); | |
| this.geometry.deleteAttribute( 'color' ); | |
| this.geometry.setAttribute( 'position', new BufferAttribute( vertices, 3 ) ); | |
| this.geometry.setAttribute( 'color', new BufferAttribute( colors, 4 ) ); | |
| } | |
| /** | |
| * Frees the GPU-related resources allocated by this instance. Call this | |
| * method whenever this instance is no longer used in your app. | |
| */ | |
| dispose() { | |
| this.geometry.dispose(); | |
| this.material.dispose(); | |
| } | |
| } | |
| export { RapierHelper }; | |
Xet Storage Details
- Size:
- 1.3 kB
- Xet hash:
- ee8de7be1eeba4d742c0fa2cec42c5bdfb6c5d6a1b750a8a2a084cd6dbc5253d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.