2
0

AxisHelper.js 860 B

123456789101112131415161718192021222324252627282930313233
  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 vertices = new Float32Array( [
  8. 0, 0, 0, size, 0, 0,
  9. 0, 0, 0, 0, size, 0,
  10. 0, 0, 0, 0, 0, size
  11. ] );
  12. var colors = new Float32Array( [
  13. 1, 0, 0, 1, 0.6, 0,
  14. 0, 1, 0, 0.6, 1, 0,
  15. 0, 0, 1, 0, 0.6, 1
  16. ] );
  17. var geometry = new THREE.BufferGeometry();
  18. geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
  19. geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) );
  20. var material = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } );
  21. THREE.Line.call( this, geometry, material, THREE.LinePieces );
  22. };
  23. THREE.AxisHelper.prototype = Object.create( THREE.Line.prototype );
  24. THREE.AxisHelper.prototype.constructor = THREE.AxisHelper;