12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- console.warn( "THREE.Wireframe: As part of the transition to ES6 Modules, the files in 'examples/js' have been deprecated in r117 (May 2020) and will be deleted in r124 (December 2020). You can find more information about developing using ES6 Modules in https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules." );
- /**
- * @author WestLangley / http://github.com/WestLangley
- *
- */
- THREE.Wireframe = function ( geometry, material ) {
- THREE.Mesh.call( this );
- this.type = 'Wireframe';
- this.geometry = geometry !== undefined ? geometry : new THREE.LineSegmentsGeometry();
- this.material = material !== undefined ? material : new THREE.LineMaterial( { color: Math.random() * 0xffffff } );
- };
- THREE.Wireframe.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), {
- constructor: THREE.Wireframe,
- isWireframe: true,
- computeLineDistances: ( function () { // for backwards-compatability, but could be a method of LineSegmentsGeometry...
- var start = new THREE.Vector3();
- var end = new THREE.Vector3();
- return function computeLineDistances() {
- var geometry = this.geometry;
- var instanceStart = geometry.attributes.instanceStart;
- var instanceEnd = geometry.attributes.instanceEnd;
- var lineDistances = new Float32Array( 2 * instanceStart.data.count );
- for ( var i = 0, j = 0, l = instanceStart.data.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 );
- }
- var instanceDistanceBuffer = new THREE.InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
- geometry.setAttribute( 'instanceDistanceStart', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
- geometry.setAttribute( 'instanceDistanceEnd', new THREE.InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
- return this;
- };
- }() )
- } );
|