AxisHelper.js 857 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * @author sroucheray / http://sroucheray.org/
  3. * @author mrdoob / http://mrdoob.com/
  4. */
  5. THREE.AxisHelper = function ( size ) {
  6. size = size || 1;
  7. var geometry = new THREE.BufferGeometry();
  8. geometry.addAttribute( 'position', new THREE.Float32Attribute( 6 * 3, 3 ) );
  9. geometry.addAttribute( 'color', new THREE.Float32Attribute( 6 * 3, 3 ) );
  10. var positions = geometry.attributes.position.array;
  11. var colors = geometry.attributes.color.array;
  12. positions[3] = positions[10] = positions[17] = size;
  13. colors[0] = colors[3] = colors[7] = colors[10] = colors[14] = colors[17] = 1;
  14. colors[4] = colors[9] = colors[16] = 2 / 3;
  15. var material = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } );
  16. THREE.Line.call( this, geometry, material, THREE.LinePieces );
  17. };
  18. THREE.AxisHelper.prototype = Object.create( THREE.Line.prototype );
粤ICP备19079148号