AxesHelper.js 918 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { LineSegments } from '../objects/LineSegments.js';
  2. import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
  3. import { Float32BufferAttribute } from '../core/BufferAttribute.js';
  4. import { BufferGeometry } from '../core/BufferGeometry.js';
  5. class AxesHelper extends LineSegments {
  6. constructor( size ) {
  7. size = size || 1;
  8. const vertices = [
  9. 0, 0, 0, size, 0, 0,
  10. 0, 0, 0, 0, size, 0,
  11. 0, 0, 0, 0, 0, size
  12. ];
  13. const colors = [
  14. 1, 0, 0, 1, 0.6, 0,
  15. 0, 1, 0, 0.6, 1, 0,
  16. 0, 0, 1, 0, 0.6, 1
  17. ];
  18. const geometry = new BufferGeometry();
  19. geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
  20. geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
  21. const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
  22. super( geometry, material );
  23. this.type = 'AxesHelper';
  24. }
  25. }
  26. export { AxesHelper };