math.vertexFormat.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { Vector3, Vector2 } from './math.vector';
  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. public position: Vector3 = Vector3.Zero(),
  14. /** the normal of the vertex (defaut: 0,1,0) */
  15. public normal: Vector3 = Vector3.Up()
  16. ) {
  17. }
  18. /**
  19. * Clones the PositionNormalVertex
  20. * @returns the cloned PositionNormalVertex
  21. */
  22. public clone(): PositionNormalVertex {
  23. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  24. }
  25. }
  26. /**
  27. * Contains position, normal and uv vectors for a vertex
  28. */
  29. export class PositionNormalTextureVertex {
  30. /**
  31. * Creates a PositionNormalTextureVertex
  32. * @param position the position of the vertex (defaut: 0,0,0)
  33. * @param normal the normal of the vertex (defaut: 0,1,0)
  34. * @param uv the uv of the vertex (default: 0,0)
  35. */
  36. constructor(
  37. /** the position of the vertex (defaut: 0,0,0) */
  38. public position: Vector3 = Vector3.Zero(),
  39. /** the normal of the vertex (defaut: 0,1,0) */
  40. public normal: Vector3 = Vector3.Up(),
  41. /** the uv of the vertex (default: 0,0) */
  42. public uv: Vector2 = Vector2.Zero()
  43. ) {
  44. }
  45. /**
  46. * Clones the PositionNormalTextureVertex
  47. * @returns the cloned PositionNormalTextureVertex
  48. */
  49. public clone(): PositionNormalTextureVertex {
  50. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  51. }
  52. }