1
0

AxisHelper.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { LineSegments } from '../../objects/LineSegments';
  2. import { VertexColors } from '../../constants';
  3. import { LineBasicMaterial } from '../../materials/LineBasicMaterial';
  4. import { BufferAttribute } from '../../core/BufferAttribute';
  5. import { BufferGeometry } from '../../core/BufferGeometry';
  6. /**
  7. * @author sroucheray / http://sroucheray.org/
  8. * @author mrdoob / http://mrdoob.com/
  9. */
  10. function AxisHelper( size ) {
  11. size = size || 1;
  12. var vertices = new Float32Array( [
  13. 0, 0, 0, size, 0, 0,
  14. 0, 0, 0, 0, size, 0,
  15. 0, 0, 0, 0, 0, size
  16. ] );
  17. var colors = new Float32Array( [
  18. 1, 0, 0, 1, 0.6, 0,
  19. 0, 1, 0, 0.6, 1, 0,
  20. 0, 0, 1, 0, 0.6, 1
  21. ] );
  22. var geometry = new BufferGeometry();
  23. geometry.addAttribute( 'position', new BufferAttribute( vertices, 3 ) );
  24. geometry.addAttribute( 'color', new BufferAttribute( colors, 3 ) );
  25. var material = new LineBasicMaterial( { vertexColors: VertexColors } );
  26. LineSegments.call( this, geometry, material );
  27. };
  28. AxisHelper.prototype = Object.create( LineSegments.prototype );
  29. AxisHelper.prototype.constructor = AxisHelper;
  30. export { AxisHelper };
粤ICP备19079148号