math.vertexFormat.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { Vector3, Vector2 } from "./math.vector.js";
  2. /**
  3. * Contains position and normal vectors for a vertex
  4. */
  5. export class PositionNormalVertex {
  6. /**
  7. * Creates a PositionNormalVertex
  8. * @param position the position of the vertex (defaut: 0,0,0)
  9. * @param normal the normal of the vertex (defaut: 0,1,0)
  10. */
  11. constructor(
  12. /** the position of the vertex (defaut: 0,0,0) */
  13. position = Vector3.Zero(),
  14. /** the normal of the vertex (defaut: 0,1,0) */
  15. normal = Vector3.Up()) {
  16. this.position = position;
  17. this.normal = normal;
  18. }
  19. /**
  20. * Clones the PositionNormalVertex
  21. * @returns the cloned PositionNormalVertex
  22. */
  23. clone() {
  24. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  25. }
  26. }
  27. /**
  28. * Contains position, normal and uv vectors for a vertex
  29. */
  30. export class PositionNormalTextureVertex {
  31. /**
  32. * Creates a PositionNormalTextureVertex
  33. * @param position the position of the vertex (defaut: 0,0,0)
  34. * @param normal the normal of the vertex (defaut: 0,1,0)
  35. * @param uv the uv of the vertex (default: 0,0)
  36. */
  37. constructor(
  38. /** the position of the vertex (defaut: 0,0,0) */
  39. position = Vector3.Zero(),
  40. /** the normal of the vertex (defaut: 0,1,0) */
  41. normal = Vector3.Up(),
  42. /** the uv of the vertex (default: 0,0) */
  43. uv = Vector2.Zero()) {
  44. this.position = position;
  45. this.normal = normal;
  46. this.uv = uv;
  47. }
  48. /**
  49. * Clones the PositionNormalTextureVertex
  50. * @returns the cloned PositionNormalTextureVertex
  51. */
  52. clone() {
  53. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  54. }
  55. }
  56. //# sourceMappingURL=math.vertexFormat.js.map