babylon.math.d.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /// <reference path="../babylon.d.ts" />
  2. declare module BABYLON {
  3. interface RayTriangleIntersection {
  4. hit: boolean;
  5. distance: number;
  6. bu: number;
  7. bv: number;
  8. }
  9. interface IColor3 {
  10. r: number;
  11. g: number;
  12. b: number;
  13. }
  14. interface Size2D
  15. {
  16. width: number;
  17. height: number;
  18. }
  19. interface Sphere {
  20. center: Vector3;
  21. radius: number;
  22. }
  23. class Ray {
  24. origin: Vector3;
  25. direction: Vector3;
  26. constructor(origin: Vector3, direction: Vector3);
  27. intersectsBox(box: BoundingBox): boolean;
  28. intersectsSphere(sphere: Sphere): boolean;
  29. intersectsTriangle(vertex0: Vector3,
  30. vertex1: Vector3,
  31. vertex2: Vector3): RayTriangleIntersection;
  32. static CreateNew(x: number,
  33. y: number,
  34. viewportWidth: number,
  35. viewportHeight: number,
  36. world: Matrix,
  37. view: Matrix,
  38. projection: Matrix): Ray;
  39. }
  40. class Color3 implements IColor3 {
  41. r: number;
  42. g: number;
  43. b: number;
  44. constructor(intialR: number, initialG: number, initialB: number);
  45. equals(otherColor: Color3): boolean;
  46. equals(otherColor: Color4): boolean;
  47. toString(): string;
  48. clone(): Color3;
  49. multiply(otherColor: Color3): Color3;
  50. mutilplyToRef(otherColor: Color3, result: Color3): void;
  51. scale(scale: number): Color3;
  52. scaleToRef(scale: number, result: Color3): void;
  53. copyFrom(source: Color3): void;
  54. copyFromFloats(r: number, g: number, b: number): void;
  55. static FromArray(array: number[]): Color3;
  56. }
  57. class Color4 implements IColor3 {
  58. r: number;
  59. g: number;
  60. b: number;
  61. a: number;
  62. constructor(initialR: number, initialG: number, initialB: number, initialA: number);
  63. addInPlace(right: Color4): void;
  64. add(right: Color4): Color4;
  65. subtract(right: Color4): Color4;
  66. subtractToRef(right: Color4, result: Color4): void;
  67. scale(factor: number): Color4;
  68. scale(factor: number, result: Color4): void;
  69. toString(): string;
  70. clone(): Color4;
  71. static Lerp(left: number, right: number, amount: number): Color4;
  72. static FromArray(array: number[]): Color4;
  73. }
  74. class Vector2 {
  75. x: number;
  76. y: number;
  77. constructor(x: number, y: number);
  78. toString(): string;
  79. add(other: Vector2): Vector2;
  80. subtract(other: Vector2): Vector2;
  81. negate(): Vector2;
  82. scaleInPlace(scale: number): void;
  83. scale(scale: number): Vector2;
  84. equals(other: Vector2): boolean;
  85. length(): number;
  86. lengthSquared(): number;
  87. normalize();
  88. clone(): Vector2;
  89. static Zero(): Vector2;
  90. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  91. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  92. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  93. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  94. static Dot(left: Vector2, right: Vector2): number;
  95. static Normalize(vector: Vector2): Vector2;
  96. static Minimize(left: Vector2, right: Vector2): Vector2;
  97. static Maximize(left: Vector2, right: Vector2): Vector2;
  98. static Transform(vector: Vector2, transformation: number[]): Vector2;
  99. static Distance(value1: Vector2, value2: Vector2): number;
  100. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  101. }
  102. class Vector3 {
  103. x: number;
  104. y: number;
  105. z: number;
  106. constructor(x: number, y: number, z: number);
  107. toString(): string;
  108. addInPlace(otherVector: Vector3): void;
  109. add(other: Vector3): Vector3;
  110. addToRef(otherVector: Vector3, result: Vector3): void;
  111. suntractInPlace(otherVector: Vector3): void;
  112. subtract(other: Vector3): Vector3;
  113. subtractToRef(otherVector: Vector3, result: Vector3): void;
  114. subtractFromFloatsTo(x: number, y: number, z: number): Vector3;
  115. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  116. negate(): Vector3;
  117. scaleInPlace(scale: number): void;
  118. scale(scale: number): Vector3;
  119. scaleToRef(scale: number, result: Vector3): void;
  120. equals(other: Vector3): boolean;
  121. equalsToFloats(x: number, y: number, z: number): boolean;
  122. multiplyInPlace(other: Vector3): void;
  123. multiply(other: Vector3): Vector3;
  124. multiplyToRef(otherVector: Vector3, result: Vector3): void
  125. multiplyByFloats(x: number, y: number, z: number): Vector3;
  126. divide(other: Vector3): Vector3;
  127. divideToRef(otherVector: Vector3, result: Vector3): void;
  128. length(): number;
  129. lengthSquared(): number;
  130. normalize();
  131. clone(): Vector3;
  132. copyFrom(source: Vector3): void;
  133. copyFromFloats(x: number, y: number, z: number): void;
  134. static FromArray(array: number[], offset: number);
  135. static FromArrayToRef(array: number[], offset: number, result: Vector3): void;
  136. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  137. static Zero(): Vector3;
  138. static Up(): Vector3;
  139. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  140. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  141. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  142. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  143. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  144. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  145. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  146. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  147. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  148. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  149. static Dot(left: Vector3, right: Vector3): number;
  150. static Cross(left: Vector3, right: Vector3): Vector3;
  151. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  152. static Normalize(vector: Vector3): Vector3;
  153. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  154. static Unproject(source: Vector3,
  155. viewportWidth: number,
  156. viewportHeight: number,
  157. world: Matrix,
  158. view: Matrix,
  159. projection: Matrix): Vector3;
  160. static Minimize(left: Vector3, right: Vector3): Vector3;
  161. static Maximize(left: Vector3, right: Vector3): Vector3;
  162. static Distance(value1: Vector3, value2: Vector3): number;
  163. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  164. }
  165. class Quaternion {
  166. x: number;
  167. y: number;
  168. z: number;
  169. w: number;
  170. toString(): string;
  171. constructor(x: number, y: number, z: number, w: number);
  172. equals(otherQuaternion: Quaternion): boolean;
  173. clone(): Quaternion;
  174. copyFrom(other: Quaternion): void;
  175. add(other: Quaternion): Quaternion;
  176. scale(factor: number): Quaternion;
  177. multiply(q1: Quaternion): Quaternion;
  178. multiplyToRef(q1: Quaternion, result: Quaternion): void;
  179. length(): number;
  180. normalize(): void;
  181. toEulerAngles(): Vector3;
  182. toRotationMatrix(result: Quaternion): void;
  183. static FromArray(array: number[], offset: number): Quaternion;
  184. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  185. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  186. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  187. }
  188. class Matrix {
  189. m: number[];
  190. constructor();
  191. isIdentity(): boolean;
  192. determinant(): number;
  193. toArray(): number[];
  194. invert(): void;
  195. invertToRef(other: Matrix): void;
  196. setTranslations(vector3: Vector3): void;
  197. multiply(other: Matrix): Matrix;
  198. copyFrom(other: Matrix): void;
  199. multiplyToRef(other: Matrix, result: Matrix): void;
  200. multiplyToArray(other: Matrix, result: number[], offset: number): void;
  201. equals(other: Matrix): boolean;
  202. clone(): Matrix;
  203. static FromArray(array: number[], offset: number): Matrix;
  204. static FromArrayToRef(array: number[], offset: number, result: Matrix): void;
  205. static FromValues(m11: number, m12: number, m13: number, m14: number,
  206. m21: number, m22: number, m23: number, m24: number,
  207. m31: number, m32: number, m33: number, m34: number,
  208. m41: number, m42: number, m43: number, m44: number): Matrix;
  209. static FromValuesToRef(m11: number, m12: number, m13: number, m14: number,
  210. m21: number, m22: number, m23: number, m24: number,
  211. m31: number, m32: number, m33: number, m34: number,
  212. m41: number, m42: number, m43: number, m44: number, result: Matrix): void;
  213. static Identity(): Matrix;
  214. static IdentityToRef(result: Matrix): void;
  215. static Zero(): Matrix;
  216. static RotationX(angle: number): Matrix;
  217. static RotationXToRef(angle: number, result: Matrix): void;
  218. static RotationY(angle: number): Matrix;
  219. static RotationYToRef(angle: number, result: Matrix): void;
  220. static RotationZ(angle: number): Matrix;
  221. static RotationZToRef(angle: number, result: Matrix): void;
  222. static RotationAxis(axis: Vector3, angle: number): Matrix;
  223. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  224. static Scaling(scaleX: number, scaleY: number, scaleZ: number): Matrix;
  225. static ScalingToRef(scaleX: number, scaleY: number, scaleZ: number, result: Matrix): void;
  226. static Translation(x: number, y: number, z: number): Matrix;
  227. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  228. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  229. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  230. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  231. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  232. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  233. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  234. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  235. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix): void;
  236. static AffineTransformation(scaling: number, rotationCenter: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  237. static GetFinalMatrix(viewport: Size2D, world: Matrix, view: Matrix, projection: Matrix): Matrix;
  238. static Transpose(matrix: Matrix): Matrix;
  239. static Reflection(plane: Plane): Matrix;
  240. static ReflectionToRef(plane: Plane, result: Matrix): void;
  241. }
  242. class Plane {
  243. normal: Vector3;
  244. d: number;
  245. constructor(a: number, b: number, c: number, d: number);
  246. normalize(): void;
  247. transform(transformation: Matrix): Plane;
  248. dotCoordinate(point: Vector3): number;
  249. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): void;
  250. isFrontFacingTo(direction: Vector3, epsilon: Vector3): boolean;
  251. signedDistanceTo(point: Vector3): number;
  252. static FromArray(array: number[]): Plane;
  253. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  254. static FromPositionAndNormal(origin: Vector3, normal: Vector2): Plane;
  255. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point): number;
  256. }
  257. class Frustum {
  258. frustrumPlanes: Plane[];
  259. constructor(transform: Matrix);
  260. static GetPlanes(transform: Matrix): Plane[];
  261. }
  262. }