AxesHelper.js 1.0 KB

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