@math.gl/core 3.5.6 → 3.6.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/classes/base/math-array.d.ts +66 -0
  2. package/dist/classes/base/math-array.d.ts.map +1 -0
  3. package/dist/classes/base/math-array.js +216 -0
  4. package/dist/classes/base/matrix.d.ts +14 -0
  5. package/dist/classes/base/matrix.d.ts.map +1 -0
  6. package/dist/classes/base/matrix.js +61 -0
  7. package/dist/classes/base/vector.d.ts +44 -0
  8. package/dist/classes/base/vector.d.ts.map +1 -0
  9. package/dist/classes/base/vector.js +126 -0
  10. package/dist/classes/euler.d.ts +77 -0
  11. package/dist/classes/euler.d.ts.map +1 -0
  12. package/dist/classes/euler.js +485 -0
  13. package/dist/classes/matrix3.d.ts +60 -0
  14. package/dist/classes/matrix3.d.ts.map +1 -0
  15. package/dist/classes/matrix3.js +201 -0
  16. package/dist/classes/matrix4.d.ts +226 -0
  17. package/dist/classes/matrix4.d.ts.map +1 -0
  18. package/dist/classes/matrix4.js +538 -0
  19. package/dist/classes/pose.d.ts +40 -0
  20. package/dist/classes/pose.d.ts.map +1 -0
  21. package/dist/classes/pose.js +109 -0
  22. package/dist/classes/quaternion.d.ts +63 -0
  23. package/dist/classes/quaternion.d.ts.map +1 -0
  24. package/dist/classes/quaternion.js +262 -0
  25. package/dist/classes/spherical-coordinates.d.ts +60 -0
  26. package/dist/classes/spherical-coordinates.d.ts.map +1 -0
  27. package/dist/classes/spherical-coordinates.js +148 -0
  28. package/dist/classes/vector2.d.ts +55 -0
  29. package/dist/classes/vector2.d.ts.map +1 -0
  30. package/dist/classes/vector2.js +111 -0
  31. package/dist/classes/vector3.d.ts +56 -0
  32. package/dist/classes/vector3.d.ts.map +1 -0
  33. package/dist/classes/vector3.js +133 -0
  34. package/dist/classes/vector4.d.ts +41 -0
  35. package/dist/classes/vector4.d.ts.map +1 -0
  36. package/dist/classes/vector4.js +114 -0
  37. package/dist/es5/classes/base/math-array.js +57 -61
  38. package/dist/es5/classes/base/math-array.js.map +1 -1
  39. package/dist/es5/classes/base/matrix.js +0 -14
  40. package/dist/es5/classes/base/matrix.js.map +1 -1
  41. package/dist/es5/classes/base/vector.js +0 -12
  42. package/dist/es5/classes/base/vector.js.map +1 -1
  43. package/dist/es5/classes/euler.js +63 -49
  44. package/dist/es5/classes/euler.js.map +1 -1
  45. package/dist/es5/classes/matrix3.js +60 -33
  46. package/dist/es5/classes/matrix3.js.map +1 -1
  47. package/dist/es5/classes/matrix4.js +167 -164
  48. package/dist/es5/classes/matrix4.js.map +1 -1
  49. package/dist/es5/classes/pose.js +7 -6
  50. package/dist/es5/classes/pose.js.map +1 -1
  51. package/dist/es5/classes/quaternion.js +44 -36
  52. package/dist/es5/classes/quaternion.js.map +1 -1
  53. package/dist/es5/classes/spherical-coordinates.js +12 -8
  54. package/dist/es5/classes/spherical-coordinates.js.map +1 -1
  55. package/dist/es5/classes/vector2.js.map +1 -1
  56. package/dist/es5/classes/vector3.js +7 -2
  57. package/dist/es5/classes/vector3.js.map +1 -1
  58. package/dist/es5/classes/vector4.js +7 -2
  59. package/dist/es5/classes/vector4.js.map +1 -1
  60. package/dist/es5/docs/README.md +0 -0
  61. package/dist/es5/index.js +71 -89
  62. package/dist/es5/index.js.map +1 -1
  63. package/dist/es5/lib/assert.js.map +1 -1
  64. package/dist/es5/lib/common.js +40 -43
  65. package/dist/es5/lib/common.js.map +1 -1
  66. package/dist/es5/lib/gl-matrix-extras.js.map +1 -1
  67. package/dist/es5/lib/gl-matrix.d.js +2 -0
  68. package/dist/es5/lib/gl-matrix.d.js.map +1 -0
  69. package/dist/es5/lib/math-utils.js.map +1 -1
  70. package/dist/es5/lib/validators.js.map +1 -1
  71. package/dist/esm/classes/base/math-array.js +45 -47
  72. package/dist/esm/classes/base/math-array.js.map +1 -1
  73. package/dist/esm/classes/base/matrix.js +0 -11
  74. package/dist/esm/classes/base/matrix.js.map +1 -1
  75. package/dist/esm/classes/base/vector.js +0 -10
  76. package/dist/esm/classes/base/vector.js.map +1 -1
  77. package/dist/esm/classes/euler.js +61 -48
  78. package/dist/esm/classes/euler.js.map +1 -1
  79. package/dist/esm/classes/matrix3.js +55 -33
  80. package/dist/esm/classes/matrix3.js.map +1 -1
  81. package/dist/esm/classes/matrix4.js +156 -136
  82. package/dist/esm/classes/matrix4.js.map +1 -1
  83. package/dist/esm/classes/pose.js +8 -4
  84. package/dist/esm/classes/pose.js.map +1 -1
  85. package/dist/esm/classes/quaternion.js +37 -27
  86. package/dist/esm/classes/quaternion.js.map +1 -1
  87. package/dist/esm/classes/spherical-coordinates.js +15 -5
  88. package/dist/esm/classes/spherical-coordinates.js.map +1 -1
  89. package/dist/esm/classes/vector2.js.map +1 -1
  90. package/dist/esm/classes/vector3.js +7 -2
  91. package/dist/esm/classes/vector3.js.map +1 -1
  92. package/dist/esm/classes/vector4.js +7 -2
  93. package/dist/esm/classes/vector4.js.map +1 -1
  94. package/dist/esm/docs/README.md +0 -0
  95. package/dist/esm/index.js +2 -13
  96. package/dist/esm/index.js.map +1 -1
  97. package/dist/esm/lib/assert.js.map +1 -1
  98. package/dist/esm/lib/common.js +41 -44
  99. package/dist/esm/lib/common.js.map +1 -1
  100. package/dist/esm/lib/gl-matrix-extras.js.map +1 -1
  101. package/dist/esm/lib/gl-matrix.d.js +2 -0
  102. package/dist/esm/lib/gl-matrix.d.js.map +1 -0
  103. package/dist/esm/lib/math-utils.js.map +1 -1
  104. package/dist/esm/lib/validators.js.map +1 -1
  105. package/dist/index.d.ts +17 -0
  106. package/dist/index.d.ts.map +1 -0
  107. package/dist/index.js +24 -0
  108. package/dist/lib/assert.d.ts +2 -0
  109. package/dist/lib/assert.d.ts.map +1 -0
  110. package/dist/lib/assert.js +5 -0
  111. package/dist/lib/common.d.ts +93 -0
  112. package/dist/lib/common.d.ts.map +1 -0
  113. package/dist/lib/common.js +210 -0
  114. package/dist/lib/gl-matrix-extras.d.ts +7 -0
  115. package/dist/lib/gl-matrix-extras.d.ts.map +1 -0
  116. package/dist/lib/gl-matrix-extras.js +49 -0
  117. package/dist/lib/math-utils.d.ts +28 -0
  118. package/dist/lib/math-utils.d.ts.map +1 -0
  119. package/dist/lib/math-utils.js +28 -0
  120. package/dist/lib/validators.d.ts +6 -0
  121. package/dist/lib/validators.d.ts.map +1 -0
  122. package/dist/lib/validators.js +33 -0
  123. package/package.json +5 -4
  124. package/src/classes/base/math-array.ts +265 -0
  125. package/src/classes/base/{matrix.js → matrix.ts} +15 -19
  126. package/src/classes/base/{vector.js → vector.ts} +47 -54
  127. package/src/classes/{euler.js → euler.ts} +121 -221
  128. package/src/classes/matrix3.ts +253 -0
  129. package/src/classes/matrix4.ts +668 -0
  130. package/src/classes/{pose.js → pose.ts} +52 -49
  131. package/src/classes/{quaternion.js → quaternion.ts} +107 -95
  132. package/src/classes/{spherical-coordinates.js → spherical-coordinates.ts} +84 -54
  133. package/src/classes/vector2.ts +127 -0
  134. package/src/classes/{vector3.js → vector3.ts} +43 -55
  135. package/src/classes/{vector4.js → vector4.ts} +44 -48
  136. package/src/docs/README.md +0 -0
  137. package/{dist/esm/index.d.ts → src/index.ts} +32 -34
  138. package/src/lib/{assert.js → assert.ts} +1 -1
  139. package/src/lib/common.ts +304 -0
  140. package/src/lib/{gl-matrix-extras.js → gl-matrix-extras.ts} +26 -5
  141. package/src/lib/gl-matrix.d.ts +266 -0
  142. package/src/lib/{math-utils.js → math-utils.ts} +0 -0
  143. package/src/lib/{validators.js → validators.ts} +10 -6
  144. package/dist/es5/addons/polygon.d.ts +0 -17
  145. package/dist/es5/classes/base/math-array.d.ts +0 -56
  146. package/dist/es5/classes/base/matrix.d.ts +0 -15
  147. package/dist/es5/classes/base/vector.d.ts +0 -45
  148. package/dist/es5/classes/euler.d.ts +0 -92
  149. package/dist/es5/classes/matrix3.d.ts +0 -91
  150. package/dist/es5/classes/matrix4.d.ts +0 -161
  151. package/dist/es5/classes/pose.d.ts +0 -92
  152. package/dist/es5/classes/quaternion.d.ts +0 -107
  153. package/dist/es5/classes/spherical-coordinates.d.ts +0 -87
  154. package/dist/es5/classes/vector2.d.ts +0 -65
  155. package/dist/es5/classes/vector3.d.ts +0 -65
  156. package/dist/es5/classes/vector4.d.ts +0 -34
  157. package/dist/es5/index.d.ts +0 -54
  158. package/dist/es5/lib/common.d.ts +0 -80
  159. package/dist/esm/addons/polygon.d.ts +0 -17
  160. package/dist/esm/classes/base/math-array.d.ts +0 -56
  161. package/dist/esm/classes/base/matrix.d.ts +0 -15
  162. package/dist/esm/classes/base/vector.d.ts +0 -45
  163. package/dist/esm/classes/euler.d.ts +0 -92
  164. package/dist/esm/classes/matrix3.d.ts +0 -91
  165. package/dist/esm/classes/matrix4.d.ts +0 -161
  166. package/dist/esm/classes/pose.d.ts +0 -92
  167. package/dist/esm/classes/quaternion.d.ts +0 -107
  168. package/dist/esm/classes/spherical-coordinates.d.ts +0 -87
  169. package/dist/esm/classes/vector2.d.ts +0 -65
  170. package/dist/esm/classes/vector3.d.ts +0 -65
  171. package/dist/esm/classes/vector4.d.ts +0 -34
  172. package/dist/esm/lib/common.d.ts +0 -80
  173. package/src/addons/polygon.d.ts +0 -17
  174. package/src/classes/base/math-array.d.ts +0 -56
  175. package/src/classes/base/math-array.js +0 -250
  176. package/src/classes/base/matrix.d.ts +0 -15
  177. package/src/classes/base/vector.d.ts +0 -45
  178. package/src/classes/euler.d.ts +0 -92
  179. package/src/classes/matrix3.d.ts +0 -91
  180. package/src/classes/matrix3.js +0 -225
  181. package/src/classes/matrix4.d.ts +0 -161
  182. package/src/classes/matrix4.js +0 -530
  183. package/src/classes/pose.d.ts +0 -92
  184. package/src/classes/quaternion.d.ts +0 -107
  185. package/src/classes/spherical-coordinates.d.ts +0 -87
  186. package/src/classes/vector2.d.ts +0 -65
  187. package/src/classes/vector2.js +0 -122
  188. package/src/classes/vector3.d.ts +0 -65
  189. package/src/classes/vector4.d.ts +0 -34
  190. package/src/index.d.ts +0 -54
  191. package/src/index.js +0 -86
  192. package/src/lib/common.d.ts +0 -80
  193. package/src/lib/common.js +0 -222
@@ -1,92 +0,0 @@
1
- // Copyright (c) 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- import Matrix4 from './matrix4';
21
- import Vector3 from './vector3';
22
- import Euler from './euler';
23
-
24
- type PoseOptions = {
25
- position?: number[];
26
- orientation?: number[];
27
- x?: number;
28
- y?: number;
29
- z?: number;
30
- roll?: number;
31
- pitch?: number;
32
- yaw?: number;
33
- };
34
-
35
- export default class Pose {
36
- /**
37
- * A pose contains both rotation and rotations.
38
- * Note that every single pose defines its own coordinate system
39
- * (with the position of the pose in the origin, and zero rotations).
40
- * These "pose relative" coordinate will be centered on the defining
41
- * pose's position and with with the defining pose's orientation
42
- * aligned with axis.
43
- * @param {Object} options
44
- * @param {Number[]} [options.position]
45
- * @param {Number[]} [options.orientation]
46
- * @param {Number} [options.x]
47
- * @param {Number} [options.y]
48
- * @param {Number} [options.z]
49
- * @param {Number} [options.roll]
50
- * @param {Number} [options.pitch]
51
- * @param {Number} [options.yaw]
52
- */
53
- constructor(options?: PoseOptions);
54
-
55
- x: number;
56
- y: number;
57
- z: number;
58
- roll: number;
59
- pitch: number;
60
- yaw: number;
61
-
62
- getPosition(): Vector3;
63
- getOrientation(): Euler;
64
-
65
- equals(pose: Pose): boolean;
66
- exactEquals(pose: Pose): boolean;
67
-
68
- /**
69
- * Returns a 4x4 matrix that transforms a coordinates (in the same
70
- * coordinate system as this pose) into the "pose-relative" coordinate
71
- * system defined by this pose.
72
- * The pose relative coordinates with have origin in the position of this
73
- * pose, and axis will be aligned with the rotation of this pose.
74
- */
75
- getTransformationMatrix(): Matrix4;
76
-
77
- /**
78
- * Given a second pose that represent the same object in a second coordinate
79
- * system, this method returns a 4x4 matrix that transforms coordinates in the
80
- * second coordinate system into the coordinate system of this pose.
81
- */
82
- getTransformationMatrixFromPose(pose: Pose): Matrix4;
83
-
84
- /**
85
- * Given a second pose that represent the same object in a second coordinate
86
- * system, this method returns a 4x4 matrix that transforms coordinates in the
87
- * coordinate system of this pose into the coordinate system of the second pose.
88
- *
89
- * Note: This method returns the inverse of `this.getTransformationMatrixFromPose(pose)`
90
- */
91
- getTransformationMatrixToPose(pose: Pose): Matrix4;
92
- }
@@ -1,107 +0,0 @@
1
- import MathArray from './base/math-array';
2
-
3
- export default class Quaternion extends MathArray<Quaternion> {
4
- // Getters/setters
5
- ELEMENTS: number;
6
-
7
- x: number;
8
- y: number;
9
- z: number;
10
- w: number;
11
-
12
- /** Creates a new identity quaternion: `w^2 + x^2 + y^2 + z^2 = 1` */
13
- constructor();
14
- constructor(q: Quaternion);
15
- constructor(q: readonly number[]);
16
- constructor(x: number, y: number, z: number, w: number);
17
-
18
- copy(array: readonly number[]): Quaternion;
19
-
20
- set(x: number, y: number, z: number, w: number): Quaternion;
21
-
22
- /**
23
- * Creates a quaternion from the given 3x3 rotation matrix.
24
- *
25
- * - The resultant quaternion is not normalized, so you should
26
- * be sure to renormalize the quaternion yourself where necessary.
27
- */
28
- fromMatrix3(m: readonly number[]): Quaternion;
29
-
30
- fromAxisRotation(axis, rad): Quaternion;
31
-
32
- /** Set a quat to the identity quaternion */
33
- identity(): Quaternion;
34
-
35
- // Set the components of a quaternion to the given values
36
- // set(i, j, k, l) {
37
- // quat.set(this, i, j, k, l);
38
- // return this.check();
39
- // }
40
-
41
- /** Sets a quaternion from the given angle and rotation axis, then returns it. */
42
- setAxisAngle(axis, rad): Quaternion;
43
-
44
- /** Calculates the length of a quaternion */
45
- len(): number;
46
-
47
- /** Calculates the squared length of a quaternion */
48
- lengthSquared(): number;
49
-
50
- /** Calculates the dot product of two quaternions */
51
- dot(a: readonly number[]): number;
52
-
53
- rotationTo(vectorA, vectorB): Quaternion;
54
-
55
- /** Adds two quaternions */
56
- add(a: readonly number[]): Quaternion;
57
-
58
- /**
59
- * Calculates the W component of a quat from the X, Y, and Z components.
60
- * Any existing W component will be ignored.
61
- */
62
- calculateW(): Quaternion;
63
-
64
- /**
65
- * Calculates the conjugate of a quat If the quaternion is normalized,
66
- * this function is faster than quat.inverse and produces the same result.
67
- */
68
- conjugate(): Quaternion;
69
-
70
- /** Calculates the inverse of this quaternion */
71
- invert(): Quaternion;
72
-
73
- /** Performs a linear interpolation between two quaternions */
74
- lerp(a, b, t): Quaternion;
75
-
76
- /** Multiplies two quaternions */
77
- multiplyRight(a, b): Quaternion;
78
- /** Multiplies two quaternions */
79
- multiplyLeft(a, b): Quaternion;
80
-
81
- /** Normalize a quaternion */
82
- normalize(): Quaternion;
83
-
84
- // MODIFIERS
85
-
86
- /** Rotates a quaternion by the given angle about the X axis */
87
- rotateX(radians: number): Quaternion;
88
- /** Rotates a quaternion by the given angle about the Y axis */
89
- rotateY(radians: number): Quaternion;
90
- /** Rotates a quaternion by the given angle about the Z axis */
91
- rotateZ(radians: number): Quaternion;
92
-
93
- /** Scales a quaternion by a scalar number */
94
- scale(b: number): Quaternion;
95
-
96
- /** Performs a spherical linear interpolation between two quaternions */
97
- slerp(start: readonly number[], target: readonly number[], ratio: number): Quaternion;
98
- slerp(args: {start: readonly number[]; target: readonly number[]; ratio: number}): Quaternion;
99
-
100
- transformVector4(vector, result?);
101
-
102
- // THREE.js Math API compatibility
103
- lengthSq(): Quaternion;
104
- setFromAxisAngle(axis, rad): Quaternion;
105
- premultiply(a, b): Quaternion;
106
- multiply(a, b): Quaternion;
107
- }
@@ -1,87 +0,0 @@
1
- // Copyright (c) 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
-
21
- // Adaptation of THREE.js Spherical class, under MIT license
22
- import Vector3 from './vector3';
23
-
24
- type SphericalCoordinatesOptions = {
25
- phi?: number;
26
- theta?: number;
27
- radius?: number;
28
- bearing?: number;
29
- pitch?: number;
30
- altitude?: number;
31
- radiusScale?: number;
32
- };
33
-
34
- type FormatOptions = {
35
- printTypes?: boolean;
36
- };
37
-
38
- /**
39
- * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system
40
- * The poles (phi) are at the positive and negative y axis.
41
- * The equator starts at positive z.
42
- */
43
- export default class SphericalCoordinates {
44
- // Todo [rho, theta, phi] ?
45
-
46
- // Cartographic (bearing 0 north, pitch 0 look from above)
47
- bearing: number;
48
- pitch: number;
49
- altitude: number;
50
-
51
- // lnglatZ coordinates
52
- longitude: number;
53
- latitude: number;
54
- lng: number;
55
- lat: number;
56
- z: number;
57
-
58
- /**
59
- * @param {Object} options
60
- * @param {Number} [options.phi] =0 - rotation around X (latitude)
61
- * @param {Number} [options.theta] =0 - rotation around Y (longitude)
62
- * @param {Number} [options.radius] =1 - Distance from center
63
- * @param {Number} [options.bearing]
64
- * @param {Number} [options.pitch]
65
- * @param {Number} [options.altitude]
66
- * @param {Number} [options.radiusScale] =1
67
- */
68
- constructor(options?: SphericalCoordinatesOptions);
69
-
70
- fromLngLatZ(lngLatZ: number[]): SphericalCoordinates;
71
- fromVector3(v: number[]): SphericalCoordinates;
72
-
73
- clone(): SphericalCoordinates;
74
- copy(other: SphericalCoordinates): SphericalCoordinates;
75
- set(radius: number, phi: number, theta: number): SphericalCoordinates;
76
-
77
- equals(other: SphericalCoordinates): boolean;
78
- exactEquals(other: SphericalCoordinates): boolean;
79
-
80
- toString(): string;
81
- formatString(options?: FormatOptions): string;
82
- toVector3(): Vector3;
83
-
84
- // restrict phi to be betwee EPS and PI-EPS
85
- makeSafe(): SphericalCoordinates;
86
- check(): SphericalCoordinates;
87
- }
@@ -1,65 +0,0 @@
1
- // Copyright (c) 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
-
21
- import Vector from './base/vector';
22
-
23
- /* Two-element vector class */
24
- export default class Vector2 extends Vector<Vector2> {
25
- static ZERO: number[];
26
- get ELEMENTS(): number;
27
-
28
- constructor();
29
- constructor(array: readonly number[]);
30
- constructor(x: number, y: number);
31
-
32
- set(x: number, y: number): Vector2;
33
-
34
- copy(array: readonly number[]): Vector2;
35
-
36
- fromObject(object): Vector2;
37
- // {
38
- // if (config.debug) {
39
- // checkNumber(object.x);
40
- // checkNumber(object.y);
41
- // }
42
- // this[0] = object.x;
43
- // this[1] = object.y;
44
- // return this.check();
45
- // }
46
-
47
- toObject(object: object): object;
48
-
49
- // x,y inherited from Vector
50
-
51
- horizontalAngle(): number;
52
-
53
- verticalAngle(): number;
54
-
55
- // Transforms
56
- transform(matrix4: readonly number[]): Vector2;
57
- // transforms as point (4th component is implicitly 1)
58
- transformAsPoint(matrix4: readonly number[]): Vector2;
59
- // transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
60
- transformAsVector(matrix4: readonly number[]): Vector2;
61
-
62
- transformByMatrix3(matrix3: readonly number[]): Vector2;
63
- transformByMatrix2x3(matrix2x3: readonly number[]): Vector2;
64
- transformByMatrix2(matrix2: readonly number[]): Vector2;
65
- }
@@ -1,122 +0,0 @@
1
- // Copyright (c) 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
-
21
- import Vector from './base/vector';
22
- import {config, isArray} from '../lib/common';
23
- import {checkNumber} from '../lib/validators';
24
-
25
- // @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.
26
- import * as vec2 from 'gl-matrix/vec2';
27
- // eslint-disable-next-line camelcase
28
- import {vec2_transformMat4AsVector} from '../lib/gl-matrix-extras';
29
-
30
- export default class Vector2 extends Vector {
31
- // Creates a new, empty vec2
32
- constructor(x = 0, y = 0) {
33
- // PERF NOTE: initialize elements as double precision numbers
34
- super(2); // -0, -0);
35
- if (isArray(x) && arguments.length === 1) {
36
- this.copy(x);
37
- } else {
38
- if (config.debug) {
39
- checkNumber(x);
40
- checkNumber(y);
41
- }
42
- this[0] = x;
43
- this[1] = y;
44
- }
45
- }
46
-
47
- set(x, y) {
48
- this[0] = x;
49
- this[1] = y;
50
- return this.check();
51
- }
52
-
53
- copy(array) {
54
- this[0] = array[0];
55
- this[1] = array[1];
56
- return this.check();
57
- }
58
-
59
- fromObject(object) {
60
- if (config.debug) {
61
- checkNumber(object.x);
62
- checkNumber(object.y);
63
- }
64
- this[0] = object.x;
65
- this[1] = object.y;
66
- return this.check();
67
- }
68
-
69
- toObject(object) {
70
- object.x = this[0];
71
- object.y = this[1];
72
- return object;
73
- }
74
-
75
- // Getters/setters
76
- get ELEMENTS() {
77
- return 2;
78
- }
79
-
80
- // x,y inherited from Vector
81
-
82
- horizontalAngle() {
83
- return Math.atan2(this.y, this.x);
84
- }
85
-
86
- verticalAngle() {
87
- return Math.atan2(this.x, this.y);
88
- }
89
-
90
- // Transforms
91
-
92
- transform(matrix4) {
93
- return this.transformAsPoint(matrix4);
94
- }
95
-
96
- // transforms as point (4th component is implicitly 1)
97
- transformAsPoint(matrix4) {
98
- vec2.transformMat4(this, this, matrix4);
99
- return this.check();
100
- }
101
-
102
- // transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
103
- transformAsVector(matrix4) {
104
- vec2_transformMat4AsVector(this, this, matrix4);
105
- return this.check();
106
- }
107
-
108
- transformByMatrix3(matrix3) {
109
- vec2.transformMat3(this, this, matrix3);
110
- return this.check();
111
- }
112
-
113
- transformByMatrix2x3(matrix2x3) {
114
- vec2.transformMat2d(this, this, matrix2x3);
115
- return this.check();
116
- }
117
-
118
- transformByMatrix2(matrix2) {
119
- vec2.transformMat2(this, this, matrix2);
120
- return this.check();
121
- }
122
- }
@@ -1,65 +0,0 @@
1
- // Copyright (c) 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
-
21
- import Vector from './base/vector';
22
-
23
- /** Three-element vector class */
24
- export default class Vector3 extends Vector<Vector3> {
25
- static readonly ZERO: Vector3;
26
- get ELEMENTS(): number;
27
-
28
- constructor();
29
- constructor(array: readonly number[]);
30
- constructor(x: number, y: number, z: number);
31
-
32
- set(x: number, y: number, z: number);
33
-
34
- copy(array: readonly number[]);
35
-
36
- fromObject(object);
37
- toObject(object);
38
-
39
- // x,y inherited from Vector
40
-
41
- z: number;
42
-
43
- // ACCESSORS
44
- angle(vector: readonly number[]): number;
45
-
46
- // MODIFIERS
47
- cross(vector: readonly number[]): Vector3;
48
-
49
- rotateX(args: {radians: number; origin?: readonly number[]}): Vector3;
50
- rotateY(args: {radians: number; origin?: readonly number[]}): Vector3;
51
- rotateZ(args: {radians: number; origin?: readonly number[]}): Vector3;
52
-
53
- // Transforms
54
-
55
- // transforms as point (4th component is implicitly 1)
56
- transform(matrix4: readonly number[]): Vector3;
57
- // transforms as point (4th component is implicitly 1)
58
- transformAsPoint(matrix4: readonly number[]): Vector3;
59
- // transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
60
- transformAsVector(matrix4: readonly number[]): Vector3;
61
-
62
- transformByMatrix3(matrix3: readonly number[]): Vector3;
63
- transformByMatrix2(matrix2: readonly number[]): Vector3;
64
- transformByQuaternion(quaternion: readonly number[]): Vector3;
65
- }
@@ -1,34 +0,0 @@
1
- import Vector from './base/vector';
2
-
3
- /** Four-element vector class */
4
- export default class Vector4 extends Vector<Vector4> {
5
- static ZERO: number[];
6
- get ELEMENTS(): number;
7
-
8
- /** construct a new Vector4 initialize to [0, 0, 0, 0] */
9
- constructor();
10
- /** construct a new Vector4 initialize to ...x, y, z, w */
11
- constructor(x: number, y: number, z: number, w: number);
12
- /** construct a new Vector4 initialize to array [x, y, z, w] */
13
- constructor(array: readonly number[]);
14
-
15
- set(x, y, z, w);
16
-
17
- copy(array);
18
-
19
- fromObject(object);
20
-
21
- toObject(object);
22
-
23
- // x,y inherited from Vector
24
- z: number;
25
- w: number;
26
-
27
- transform(matrix4: readonly number[]): Vector4;
28
- transformByMatrix3(matrix3: readonly number[]): Vector4;
29
- transformByMatrix2(matrix2: readonly number[]): Vector4;
30
- transformByQuaternion(quaternion: readonly number[]): Vector4;
31
-
32
- // three.js compatibility
33
- applyMatrix4(m: readonly number[]): Vector4;
34
- }
package/src/index.d.ts DELETED
@@ -1,54 +0,0 @@
1
- // lib
2
- export * from './lib/common';
3
-
4
- // classes
5
- export {default as Vector2} from './classes/vector2';
6
- export {default as Vector3} from './classes/vector3';
7
- export {default as Vector4} from './classes/vector4';
8
- export {default as Matrix3} from './classes/matrix3';
9
- export {default as Matrix4} from './classes/matrix4';
10
- export {default as Quaternion} from './classes/quaternion';
11
-
12
- // extras
13
-
14
- // export {checkNumber} from './lib/validators';
15
- export function assert(condition: boolean, message?: string): void;
16
-
17
- // experimental
18
- export {default as SphericalCoordinates} from './classes/spherical-coordinates';
19
- export {default as Pose} from './classes/pose';
20
- export {default as Euler} from './classes/euler';
21
-
22
- export const _MathUtils: {
23
- EPSILON1: number;
24
- EPSILON2: number;
25
- EPSILON3: number;
26
- EPSILON4: number;
27
- EPSILON5: number;
28
- EPSILON6: number;
29
- EPSILON7: number;
30
- EPSILON8: number;
31
- EPSILON9: number;
32
- EPSILON10: number;
33
- EPSILON11: number;
34
- EPSILON12: number;
35
- EPSILON13: number;
36
- EPSILON14: number;
37
- EPSILON15: number;
38
- EPSILON16: number;
39
- EPSILON17: number;
40
- EPSILON18: number;
41
- EPSILON19: number;
42
- EPSILON20: number;
43
-
44
- PI_OVER_TWO: number;
45
- PI_OVER_FOUR: number;
46
- PI_OVER_SIX: number;
47
-
48
- TWO_PI: number;
49
- };
50
-
51
- // DEPRECATED
52
- export {default as _SphericalCoordinates} from './classes/spherical-coordinates';
53
- export {default as _Pose} from './classes/pose';
54
- export {default as _Euler} from './classes/euler';