Buckets:
ktongue/docker_container / simsite /frontend /node_modules /three /examples /jsm /lines /Wireframe.js
| import { | |
| InstancedInterleavedBuffer, | |
| InterleavedBufferAttribute, | |
| Mesh, | |
| Vector3 | |
| } from 'three'; | |
| import { LineSegmentsGeometry } from '../lines/LineSegmentsGeometry.js'; | |
| import { LineMaterial } from '../lines/LineMaterial.js'; | |
| const _start = new Vector3(); | |
| const _end = new Vector3(); | |
| class Wireframe extends Mesh { | |
| constructor( geometry = new LineSegmentsGeometry(), material = new LineMaterial( { color: Math.random() * 0xffffff } ) ) { | |
| super( geometry, material ); | |
| this.isWireframe = true; | |
| this.type = 'Wireframe'; | |
| } | |
| // for backwards-compatibility, but could be a method of LineSegmentsGeometry... | |
| computeLineDistances() { | |
| const geometry = this.geometry; | |
| const instanceStart = geometry.attributes.instanceStart; | |
| const instanceEnd = geometry.attributes.instanceEnd; | |
| const lineDistances = new Float32Array( 2 * instanceStart.count ); | |
| for ( let i = 0, j = 0, l = instanceStart.count; i < l; i ++, j += 2 ) { | |
| _start.fromBufferAttribute( instanceStart, i ); | |
| _end.fromBufferAttribute( instanceEnd, i ); | |
| lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ]; | |
| lineDistances[ j + 1 ] = lineDistances[ j ] + _start.distanceTo( _end ); | |
| } | |
| const instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1 | |
| geometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0 | |
| geometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1 | |
| return this; | |
| } | |
| } | |
| export { Wireframe }; | |
Xet Storage Details
- Size:
- 1.58 kB
- Xet hash:
- d9b66db49e35b2ded4e9395c6693525aa8c7706baefa23086da2aa197c93e212
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.