AxesHelper.js 993 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. function AxesHelper( size ) {
  6. size = 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. LineSegments.call( this, geometry, material );
  22. this.type = 'AxesHelper';
  23. }
  24. AxesHelper.prototype = Object.create( LineSegments.prototype );
  25. AxesHelper.prototype.constructor = AxesHelper;
  26. export { AxesHelper };
粤ICP备19079148号