AxisHelper.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * @author sroucheray / http://sroucheray.org/
  3. * @author mrdoob / http://mrdoob.com/
  4. */
  5. import { LineSegments } from '../objects/LineSegments.js';
  6. import { VertexColors } from '../constants.js';
  7. import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
  8. import { Float32BufferAttribute } from '../core/BufferAttribute.js';
  9. import { BufferGeometry } from '../core/BufferGeometry.js';
  10. function AxisHelper( size ) {
  11. size = size || 1;
  12. var vertices = [
  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 = [
  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 Float32BufferAttribute( vertices, 3 ) );
  24. geometry.addAttribute( 'color', new Float32BufferAttribute( 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 };