AxesHelper.js 901 B

12345678910111213141516171819202122232425262728293031323334353637
  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 = 1 ) {
  7. const vertices = [
  8. 0, 0, 0, size, 0, 0,
  9. 0, 0, 0, 0, size, 0,
  10. 0, 0, 0, 0, 0, size
  11. ];
  12. const colors = [
  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. const geometry = new BufferGeometry();
  18. geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
  19. geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
  20. const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
  21. super( geometry, material );
  22. this.type = 'AxesHelper';
  23. }
  24. }
  25. export { AxesHelper };