Binary-Dash

Vec3

Jul 14th, 2020
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. namespace Vec3 {
  2. /**
  3. * Represents a vector in 3D space
  4. */
  5. declare class Vec3 {
  6. constructor(x: number, y: number, z: number);
  7.  
  8. x: number;
  9. y: number;
  10. z: number;
  11.  
  12. set(x: number, y: number, z: number): this;
  13.  
  14. update(other: Vec3): this;
  15.  
  16. floored(): Vec3;
  17.  
  18. floor(): this;
  19.  
  20. offset(dx: number, dy: number, dz: number): Vec3;
  21.  
  22. translate(dx: number, dy: number, dz: number): this;
  23.  
  24. add(other: Vec3): this;
  25.  
  26. subtract(other: Vec3): this;
  27.  
  28. plus(other: Vec3): Vec3;
  29.  
  30. minus(other: Vec3): Vec3;
  31.  
  32. scaled(scalar: number): Vec3;
  33.  
  34. abs(): Vec3;
  35.  
  36. volume(): number;
  37.  
  38. modulus(other: Vec3): Vec3;
  39.  
  40. distanceTo(other: Vec3): number;
  41.  
  42. equals(other: Vec3): boolean;
  43.  
  44. toString(): string;
  45.  
  46. clone(): Vec3;
  47.  
  48. min(other: Vec3): Vec3;
  49.  
  50. max(other: Vec3): Vec3;
  51.  
  52. dot(other: Vec3): number;
  53.  
  54. cross(other: Vec3): Vec3;
  55.  
  56. norm(): number;
  57.  
  58. unit(): Vec3;
  59.  
  60. normalize(): Vec3;
  61.  
  62. scale(scalar): this;
  63.  
  64. xyDistanceTo(other: Vec3): number;
  65.  
  66. xzDistanceTo(other: Vec3): number;
  67.  
  68. yzDistanceTo(other: Vec3): number;
  69.  
  70. innerProduct(other: Vec3): number;
  71.  
  72. manhattanDistanceTo(other: Vec3): number;
  73.  
  74. toArray(): Array<number>;
  75. }
  76.  
  77. }
  78.  
  79. /**
  80. * Creates a vector at 0, 0, 0
  81. */
  82. declare function Vec3(): Vec3.Vec3;
  83. /**
  84. * Creates a vector from a string in the format "(x, y, z)"
  85. */
  86. declare function Vec3(str: string): Vec3.Vec3;
  87. /**
  88. * Creates a vector from the given x, y, and z values
  89. */
  90. declare function Vec3(x: number | number, y: number | number, z: number | number): Vec3.Vec3;
  91. /**
  92. * Creates a vector from the values in the given array as [x, y, z]
  93. */
  94. declare function Vec3(point: [number | number, number | number, number | number]): Vec3.Vec3;
  95. /**
  96. * Creates a vector by taking the x, y, z values from an object
  97. */
  98. declare function Vec3(point: { x: string | number, y: string | number, z: string | number }): Vec3.Vec3;
  99.  
  100.  
  101. export = Vec3;
Advertisement
Add Comment
Please, Sign In to add comment