Line2.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { LineSegments2 } from '../lines/LineSegments2.js';
  2. import { LineGeometry } from '../lines/LineGeometry.js';
  3. import { LineMaterial } from '../lines/LineMaterial.js';
  4. /**
  5. * A polyline drawn between vertices.
  6. *
  7. * This adds functionality beyond {@link Line}, like arbitrary line width and changing width to
  8. * be in world units.It extends {@link LineSegments2}, simplifying constructing segments from a
  9. * chain of points.
  10. *
  11. * This module can only be used with {@link WebGLRenderer}. When using {@link WebGPURenderer},
  12. * import the class from `lines/webgpu/Line2.js`.
  13. *
  14. * ```js
  15. * const geometry = new LineGeometry();
  16. * geometry.setPositions( positions );
  17. * geometry.setColors( colors );
  18. *
  19. * const material = new LineMaterial( { linewidth: 5, vertexColors: true } };
  20. *
  21. * const line = new Line2( geometry, material );
  22. * scene.add( line );
  23. * ```
  24. *
  25. * @augments LineSegments2
  26. */
  27. class Line2 extends LineSegments2 {
  28. /**
  29. * Constructs a new wide line.
  30. *
  31. * @param {LineGeometry} [geometry] - The line geometry.
  32. * @param {LineMaterial} [material] - The line material.
  33. */
  34. constructor( geometry = new LineGeometry(), material = new LineMaterial( { color: Math.random() * 0xffffff } ) ) {
  35. super( geometry, material );
  36. /**
  37. * This flag can be used for type testing.
  38. *
  39. * @type {boolean}
  40. * @readonly
  41. * @default true
  42. */
  43. this.isLine2 = true;
  44. this.type = 'Line2';
  45. }
  46. }
  47. export { Line2 };
粤ICP备19079148号