@math.gl/core 4.0.0 → 4.1.0-alpha.1

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 (147) hide show
  1. package/dist/classes/base/math-array.d.ts +1 -2
  2. package/dist/classes/base/math-array.js +223 -266
  3. package/dist/classes/base/matrix.d.ts +1 -2
  4. package/dist/classes/base/matrix.js +56 -53
  5. package/dist/classes/base/vector.d.ts +1 -2
  6. package/dist/classes/base/vector.js +125 -135
  7. package/dist/classes/euler.d.ts +2 -3
  8. package/dist/classes/euler.js +464 -533
  9. package/dist/classes/matrix3.d.ts +9 -4
  10. package/dist/classes/matrix3.js +191 -190
  11. package/dist/classes/matrix4.d.ts +8 -4
  12. package/dist/classes/matrix4.js +521 -452
  13. package/dist/classes/pose.d.ts +4 -5
  14. package/dist/classes/pose.js +106 -119
  15. package/dist/classes/quaternion.d.ts +1 -2
  16. package/dist/classes/quaternion.js +261 -233
  17. package/dist/classes/spherical-coordinates.d.ts +3 -4
  18. package/dist/classes/spherical-coordinates.js +142 -147
  19. package/dist/classes/vector2.d.ts +6 -5
  20. package/dist/classes/vector2.js +103 -85
  21. package/dist/classes/vector3.d.ts +6 -5
  22. package/dist/classes/vector3.js +129 -136
  23. package/dist/classes/vector4.d.ts +7 -6
  24. package/dist/classes/vector4.js +108 -114
  25. package/dist/gl-matrix/common.d.ts +0 -1
  26. package/dist/gl-matrix/common.js +38 -6
  27. package/dist/gl-matrix/mat3.d.ts +0 -1
  28. package/dist/gl-matrix/mat3.js +699 -425
  29. package/dist/gl-matrix/mat4.d.ts +0 -1
  30. package/dist/gl-matrix/mat4.js +1879 -1339
  31. package/dist/gl-matrix/quat.d.ts +0 -1
  32. package/dist/gl-matrix/quat.js +655 -257
  33. package/dist/gl-matrix/vec2.d.ts +0 -1
  34. package/dist/gl-matrix/vec2.js +529 -212
  35. package/dist/gl-matrix/vec3.d.ts +0 -1
  36. package/dist/gl-matrix/vec3.js +703 -335
  37. package/dist/gl-matrix/vec4.d.ts +0 -1
  38. package/dist/gl-matrix/vec4.js +579 -293
  39. package/dist/gl-matrix/wip/index.d.ts +3 -4
  40. package/dist/gl-matrix/wip/index.js +5 -1
  41. package/dist/gl-matrix/wip/mat2.d.ts +1 -2
  42. package/dist/gl-matrix/wip/mat2.js +336 -157
  43. package/dist/gl-matrix/wip/mat2d.d.ts +0 -1
  44. package/dist/gl-matrix/wip/mat2d.js +380 -202
  45. package/dist/gl-matrix/wip/quat2.d.ts +0 -1
  46. package/dist/gl-matrix/wip/quat2.js +650 -409
  47. package/dist/index.cjs +60 -100
  48. package/dist/index.cjs.map +7 -0
  49. package/dist/index.d.ts +27 -23
  50. package/dist/index.js +25 -16
  51. package/dist/lib/assert.d.ts +0 -1
  52. package/dist/lib/assert.js +6 -4
  53. package/dist/lib/common.d.ts +2 -3
  54. package/dist/lib/common.js +165 -134
  55. package/dist/lib/gl-matrix-extras.d.ts +0 -1
  56. package/dist/lib/gl-matrix-extras.js +42 -36
  57. package/dist/lib/math-utils.d.ts +0 -1
  58. package/dist/lib/math-utils.js +5 -1
  59. package/dist/lib/validators.d.ts +0 -1
  60. package/dist/lib/validators.js +25 -25
  61. package/package.json +5 -6
  62. package/src/classes/base/math-array.ts +4 -1
  63. package/src/classes/base/matrix.ts +4 -1
  64. package/src/classes/base/vector.ts +4 -1
  65. package/src/classes/euler.ts +4 -1
  66. package/src/classes/matrix3.ts +12 -3
  67. package/src/classes/matrix4.ts +11 -3
  68. package/src/classes/pose.ts +4 -1
  69. package/src/classes/quaternion.ts +4 -1
  70. package/src/classes/spherical-coordinates.ts +4 -1
  71. package/src/classes/vector2.ts +11 -4
  72. package/src/classes/vector3.ts +10 -4
  73. package/src/classes/vector4.ts +9 -4
  74. package/src/gl-matrix/wip/index.js +4 -0
  75. package/src/gl-matrix/wip/mat2.js +4 -0
  76. package/src/gl-matrix/wip/mat2d.js +4 -0
  77. package/src/gl-matrix/wip/quat2.ts +4 -0
  78. package/src/index.ts +10 -2
  79. package/src/lib/assert.ts +4 -0
  80. package/src/lib/common.ts +3 -1
  81. package/src/lib/gl-matrix-extras.ts +4 -0
  82. package/src/lib/gl-matrix.d.ts +4 -0
  83. package/src/lib/math-utils.ts +4 -0
  84. package/src/lib/validators.ts +4 -19
  85. package/dist/classes/base/math-array.d.ts.map +0 -1
  86. package/dist/classes/base/math-array.js.map +0 -1
  87. package/dist/classes/base/matrix.d.ts.map +0 -1
  88. package/dist/classes/base/matrix.js.map +0 -1
  89. package/dist/classes/base/vector.d.ts.map +0 -1
  90. package/dist/classes/base/vector.js.map +0 -1
  91. package/dist/classes/euler.d.ts.map +0 -1
  92. package/dist/classes/euler.js.map +0 -1
  93. package/dist/classes/matrix3.d.ts.map +0 -1
  94. package/dist/classes/matrix3.js.map +0 -1
  95. package/dist/classes/matrix4.d.ts.map +0 -1
  96. package/dist/classes/matrix4.js.map +0 -1
  97. package/dist/classes/pose.d.ts.map +0 -1
  98. package/dist/classes/pose.js.map +0 -1
  99. package/dist/classes/quaternion.d.ts.map +0 -1
  100. package/dist/classes/quaternion.js.map +0 -1
  101. package/dist/classes/spherical-coordinates.d.ts.map +0 -1
  102. package/dist/classes/spherical-coordinates.js.map +0 -1
  103. package/dist/classes/vector2.d.ts.map +0 -1
  104. package/dist/classes/vector2.js.map +0 -1
  105. package/dist/classes/vector3.d.ts.map +0 -1
  106. package/dist/classes/vector3.js.map +0 -1
  107. package/dist/classes/vector4.d.ts.map +0 -1
  108. package/dist/classes/vector4.js.map +0 -1
  109. package/dist/gl-matrix/common.d.ts.map +0 -1
  110. package/dist/gl-matrix/common.js.map +0 -1
  111. package/dist/gl-matrix/mat3.d.ts.map +0 -1
  112. package/dist/gl-matrix/mat3.js.map +0 -1
  113. package/dist/gl-matrix/mat4.d.ts.map +0 -1
  114. package/dist/gl-matrix/mat4.js.map +0 -1
  115. package/dist/gl-matrix/quat.d.ts.map +0 -1
  116. package/dist/gl-matrix/quat.js.map +0 -1
  117. package/dist/gl-matrix/vec2.d.ts.map +0 -1
  118. package/dist/gl-matrix/vec2.js.map +0 -1
  119. package/dist/gl-matrix/vec3.d.ts.map +0 -1
  120. package/dist/gl-matrix/vec3.js.map +0 -1
  121. package/dist/gl-matrix/vec4.d.ts.map +0 -1
  122. package/dist/gl-matrix/vec4.js.map +0 -1
  123. package/dist/gl-matrix/wip/index.d.ts.map +0 -1
  124. package/dist/gl-matrix/wip/index.js.map +0 -1
  125. package/dist/gl-matrix/wip/mat2.d.ts.map +0 -1
  126. package/dist/gl-matrix/wip/mat2.js.map +0 -1
  127. package/dist/gl-matrix/wip/mat2d.d.ts.map +0 -1
  128. package/dist/gl-matrix/wip/mat2d.js.map +0 -1
  129. package/dist/gl-matrix/wip/quat2.d.ts.map +0 -1
  130. package/dist/gl-matrix/wip/quat2.js.map +0 -1
  131. package/dist/gl-matrix/wip/types.d.js +0 -2
  132. package/dist/gl-matrix/wip/types.d.js.map +0 -1
  133. package/dist/index.d.ts.map +0 -1
  134. package/dist/index.js.map +0 -1
  135. package/dist/lib/assert.d.ts.map +0 -1
  136. package/dist/lib/assert.js.map +0 -1
  137. package/dist/lib/common.d.ts.map +0 -1
  138. package/dist/lib/common.js.map +0 -1
  139. package/dist/lib/gl-matrix-extras.d.ts.map +0 -1
  140. package/dist/lib/gl-matrix-extras.js.map +0 -1
  141. package/dist/lib/gl-matrix.d.js +0 -2
  142. package/dist/lib/gl-matrix.d.js.map +0 -1
  143. package/dist/lib/math-utils.d.ts.map +0 -1
  144. package/dist/lib/math-utils.js.map +0 -1
  145. package/dist/lib/validators.d.ts.map +0 -1
  146. package/dist/lib/validators.js.map +0 -1
  147. package/src/gl-matrix/wip/types.d.ts +0 -93
@@ -1,155 +1,150 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ // Copyright (c) 2017 Uber Technologies, Inc.
2
5
  import { Vector3 } from "./vector3.js";
3
6
  import { formatValue, equals, config } from "../lib/common.js";
4
7
  import { degrees, radians, clamp } from "../lib/common.js";
8
+ // @ts-ignore gl-matrix types...
5
9
  import * as vec3 from "../gl-matrix/vec3.js";
10
+ // TODO - import epsilon
6
11
  const EPSILON = 0.000001;
7
12
  const EARTH_RADIUS_METERS = 6371000;
13
+ /**
14
+ * The poles (phi) are at the positive and negative y axis.
15
+ * The equator starts at positive z.
16
+ * @link https://en.wikipedia.org/wiki/Spherical_coordinate_system
17
+ */
8
18
  export class SphericalCoordinates {
9
- constructor({
10
- phi = 0,
11
- theta = 0,
12
- radius = 1,
13
- bearing,
14
- pitch,
15
- altitude,
16
- radiusScale = EARTH_RADIUS_METERS
17
- } = {}) {
18
- _defineProperty(this, "phi", void 0);
19
-
20
- _defineProperty(this, "theta", void 0);
21
-
22
- _defineProperty(this, "radius", void 0);
23
-
24
- _defineProperty(this, "radiusScale", void 0);
25
-
26
- this.phi = phi;
27
- this.theta = theta;
28
- this.radius = radius || altitude || 1;
29
- this.radiusScale = radiusScale || 1;
30
-
31
- if (bearing !== undefined) {
32
- this.bearing = bearing;
33
- }
34
-
35
- if (pitch !== undefined) {
36
- this.pitch = pitch;
37
- }
38
-
39
- this.check();
40
- }
41
-
42
- toString() {
43
- return this.formatString(config);
44
- }
45
-
46
- formatString({
47
- printTypes = false
48
- }) {
49
- const f = formatValue;
50
- return "".concat(printTypes ? 'Spherical' : '', "[rho:").concat(f(this.radius), ",theta:").concat(f(this.theta), ",phi:").concat(f(this.phi), "]");
51
- }
52
-
53
- equals(other) {
54
- return equals(this.radius, other.radius) && equals(this.theta, other.theta) && equals(this.phi, other.phi);
55
- }
56
-
57
- exactEquals(other) {
58
- return this.radius === other.radius && this.theta === other.theta && this.phi === other.phi;
59
- }
60
-
61
- get bearing() {
62
- return 180 - degrees(this.phi);
63
- }
64
-
65
- set bearing(v) {
66
- this.phi = Math.PI - radians(v);
67
- }
68
-
69
- get pitch() {
70
- return degrees(this.theta);
71
- }
72
-
73
- set pitch(v) {
74
- this.theta = radians(v);
75
- }
76
-
77
- get longitude() {
78
- return degrees(this.phi);
79
- }
80
-
81
- get latitude() {
82
- return degrees(this.theta);
83
- }
84
-
85
- get lng() {
86
- return degrees(this.phi);
87
- }
88
-
89
- get lat() {
90
- return degrees(this.theta);
91
- }
92
-
93
- get z() {
94
- return (this.radius - 1) * this.radiusScale;
95
- }
96
-
97
- set(radius, phi, theta) {
98
- this.radius = radius;
99
- this.phi = phi;
100
- this.theta = theta;
101
- return this.check();
102
- }
103
-
104
- clone() {
105
- return new SphericalCoordinates().copy(this);
106
- }
107
-
108
- copy(other) {
109
- this.radius = other.radius;
110
- this.phi = other.phi;
111
- this.theta = other.theta;
112
- return this.check();
113
- }
114
-
115
- fromLngLatZ([lng, lat, z]) {
116
- this.radius = 1 + z / this.radiusScale;
117
- this.phi = radians(lat);
118
- this.theta = radians(lng);
119
- return this.check();
120
- }
121
-
122
- fromVector3(v) {
123
- this.radius = vec3.length(v);
124
-
125
- if (this.radius > 0) {
126
- this.theta = Math.atan2(v[0], v[1]);
127
- this.phi = Math.acos(clamp(v[2] / this.radius, -1, 1));
128
- }
129
-
130
- return this.check();
131
- }
132
-
133
- toVector3() {
134
- return new Vector3(0, 0, this.radius).rotateX({
135
- radians: this.theta
136
- }).rotateZ({
137
- radians: this.phi
138
- });
139
- }
140
-
141
- makeSafe() {
142
- this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));
143
- return this;
144
- }
145
-
146
- check() {
147
- if (!Number.isFinite(this.phi) || !Number.isFinite(this.theta) || !(this.radius > 0)) {
148
- throw new Error('SphericalCoordinates: some fields set to invalid numbers');
149
- }
150
-
151
- return this;
152
- }
153
-
19
+ // bearing: number;
20
+ // pitch: number;
21
+ // altitude: number;
22
+ // lnglatZ coordinates
23
+ // longitude: number;
24
+ // latitude: number;
25
+ // lng: number;
26
+ // lat: number;
27
+ // z: number;
28
+ /**
29
+ * Creates a new SphericalCoordinates object
30
+ * @param options
31
+ * @param [options.phi] =0 - rotation around X (latitude)
32
+ * @param [options.theta] =0 - rotation around Y (longitude)
33
+ * @param [options.radius] =1 - Distance from center
34
+ * @param [options.bearing]
35
+ * @param [options.pitch]
36
+ * @param [options.altitude]
37
+ * @param [options.radiusScale] =1
38
+ */
39
+ // eslint-disable-next-line complexity
40
+ constructor({ phi = 0, theta = 0, radius = 1, bearing, pitch, altitude, radiusScale = EARTH_RADIUS_METERS } = {}) {
41
+ this.phi = phi;
42
+ this.theta = theta;
43
+ // TODO - silently accepts illegal 0
44
+ this.radius = radius || altitude || 1; // radial distance from center
45
+ this.radiusScale = radiusScale || 1; // Used by lngLatZ
46
+ if (bearing !== undefined) {
47
+ this.bearing = bearing; // up / down towards top and bottom pole
48
+ }
49
+ if (pitch !== undefined) {
50
+ this.pitch = pitch; // around the equator of the sphere
51
+ }
52
+ this.check();
53
+ }
54
+ toString() {
55
+ return this.formatString(config);
56
+ }
57
+ formatString({ printTypes = false }) {
58
+ const f = formatValue;
59
+ return `${printTypes ? 'Spherical' : ''}\
60
+ [rho:${f(this.radius)},theta:${f(this.theta)},phi:${f(this.phi)}]`;
61
+ }
62
+ equals(other) {
63
+ return (equals(this.radius, other.radius) &&
64
+ equals(this.theta, other.theta) &&
65
+ equals(this.phi, other.phi));
66
+ }
67
+ exactEquals(other) {
68
+ return this.radius === other.radius && this.theta === other.theta && this.phi === other.phi;
69
+ }
70
+ /* eslint-disable brace-style */
71
+ // Cartographic (bearing 0 north, pitch 0 look from above)
72
+ get bearing() {
73
+ return 180 - degrees(this.phi);
74
+ }
75
+ set bearing(v) {
76
+ this.phi = Math.PI - radians(v);
77
+ }
78
+ get pitch() {
79
+ return degrees(this.theta);
80
+ }
81
+ set pitch(v) {
82
+ this.theta = radians(v);
83
+ }
84
+ // get pitch() { return 90 - degrees(this.phi); }
85
+ // set pitch(v) { this.phi = radians(v) + Math.PI / 2; }
86
+ // get altitude() { return this.radius - 1; } // relative altitude
87
+ // lnglatZ coordinates
88
+ get longitude() {
89
+ return degrees(this.phi);
90
+ }
91
+ get latitude() {
92
+ return degrees(this.theta);
93
+ }
94
+ get lng() {
95
+ return degrees(this.phi);
96
+ }
97
+ get lat() {
98
+ return degrees(this.theta);
99
+ }
100
+ get z() {
101
+ return (this.radius - 1) * this.radiusScale;
102
+ }
103
+ /* eslint-enable brace-style */
104
+ set(radius, phi, theta) {
105
+ this.radius = radius;
106
+ this.phi = phi;
107
+ this.theta = theta;
108
+ return this.check();
109
+ }
110
+ clone() {
111
+ return new SphericalCoordinates().copy(this);
112
+ }
113
+ copy(other) {
114
+ this.radius = other.radius;
115
+ this.phi = other.phi;
116
+ this.theta = other.theta;
117
+ return this.check();
118
+ }
119
+ fromLngLatZ([lng, lat, z]) {
120
+ this.radius = 1 + z / this.radiusScale;
121
+ this.phi = radians(lat);
122
+ this.theta = radians(lng);
123
+ return this.check();
124
+ }
125
+ fromVector3(v) {
126
+ this.radius = vec3.length(v);
127
+ if (this.radius > 0) {
128
+ this.theta = Math.atan2(v[0], v[1]); // equator angle around y-up axis
129
+ this.phi = Math.acos(clamp(v[2] / this.radius, -1, 1)); // polar angle
130
+ }
131
+ return this.check();
132
+ }
133
+ toVector3() {
134
+ return new Vector3(0, 0, this.radius)
135
+ .rotateX({ radians: this.theta })
136
+ .rotateZ({ radians: this.phi });
137
+ }
138
+ // restrict phi to be betwee EPS and PI-EPS
139
+ makeSafe() {
140
+ this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));
141
+ return this;
142
+ }
143
+ check() {
144
+ // this.makeSafe();
145
+ if (!Number.isFinite(this.phi) || !Number.isFinite(this.theta) || !(this.radius > 0)) {
146
+ throw new Error('SphericalCoordinates: some fields set to invalid numbers');
147
+ }
148
+ return this;
149
+ }
154
150
  }
155
- //# sourceMappingURL=spherical-coordinates.js.map
@@ -1,8 +1,10 @@
1
- import { Vector } from './base/vector';
2
- import { NumericArray } from '@math.gl/types';
1
+ import { NumericArray, NumberArray2 } from '@math.gl/types';
2
+ import { Vector } from "./base/vector.js";
3
+ /** Helper type that captures array length for a 2 element vector */
4
+ export type Vector2Like = Vector2 | NumberArray2;
3
5
  /**
4
- * Two-element vector class.
5
- * Subclass of Array<number>
6
+ * Two-element vector class with common linear algebra operations.
7
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
6
8
  */
7
9
  export declare class Vector2 extends Vector {
8
10
  constructor(x?: number | Readonly<NumericArray>, y?: number);
@@ -52,4 +54,3 @@ export declare class Vector2 extends Vector {
52
54
  transformByMatrix2x3(matrix2x3: Readonly<NumericArray>): this;
53
55
  transformByMatrix2(matrix2: Readonly<NumericArray>): this;
54
56
  }
55
- //# sourceMappingURL=vector2.d.ts.map
@@ -1,94 +1,112 @@
1
+ // math.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ // Copyright (c) 2017 Uber Technologies, Inc.
1
5
  import { Vector } from "./base/vector.js";
2
6
  import { config, isArray } from "../lib/common.js";
3
7
  import { checkNumber } from "../lib/validators.js";
4
8
  import { transformMat4 as vec2_transformMat4, transformMat3 as vec2_transformMat3, transformMat2d as vec2_transformMat2d, transformMat2 as vec2_transformMat2 } from "../gl-matrix/vec2.js";
5
9
  import { vec2_transformMat4AsVector } from "../lib/gl-matrix-extras.js";
10
+ /**
11
+ * Two-element vector class with common linear algebra operations.
12
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
13
+ */
6
14
  export class Vector2 extends Vector {
7
- constructor(x = 0, y = 0) {
8
- super(2);
9
-
10
- if (isArray(x) && arguments.length === 1) {
11
- this.copy(x);
12
- } else {
13
- if (config.debug) {
14
- checkNumber(x);
15
- checkNumber(y);
16
- }
17
-
18
- this[0] = x;
19
- this[1] = y;
15
+ // Creates a new, empty vec2
16
+ constructor(x = 0, y = 0) {
17
+ // PERF NOTE: initialize elements as double precision numbers
18
+ super(2); // -0, -0);
19
+ if (isArray(x) && arguments.length === 1) {
20
+ this.copy(x);
21
+ }
22
+ else {
23
+ if (config.debug) {
24
+ checkNumber(x);
25
+ checkNumber(y);
26
+ }
27
+ this[0] = x;
28
+ this[1] = y;
29
+ }
20
30
  }
21
- }
22
-
23
- set(x, y) {
24
- this[0] = x;
25
- this[1] = y;
26
- return this.check();
27
- }
28
-
29
- copy(array) {
30
- this[0] = array[0];
31
- this[1] = array[1];
32
- return this.check();
33
- }
34
-
35
- fromObject(object) {
36
- if (config.debug) {
37
- checkNumber(object.x);
38
- checkNumber(object.y);
31
+ set(x, y) {
32
+ this[0] = x;
33
+ this[1] = y;
34
+ return this.check();
35
+ }
36
+ copy(array) {
37
+ this[0] = array[0];
38
+ this[1] = array[1];
39
+ return this.check();
40
+ }
41
+ fromObject(object) {
42
+ if (config.debug) {
43
+ checkNumber(object.x);
44
+ checkNumber(object.y);
45
+ }
46
+ this[0] = object.x;
47
+ this[1] = object.y;
48
+ return this.check();
49
+ }
50
+ toObject(object) {
51
+ object.x = this[0];
52
+ object.y = this[1];
53
+ return object;
54
+ }
55
+ // Getters/setters
56
+ get ELEMENTS() {
57
+ return 2;
58
+ }
59
+ /**
60
+ * Returns angle from x axis
61
+ * @returns
62
+ */
63
+ horizontalAngle() {
64
+ return Math.atan2(this.y, this.x);
65
+ }
66
+ /**
67
+ * Returns angle from y axis
68
+ * @returns
69
+ */
70
+ verticalAngle() {
71
+ return Math.atan2(this.x, this.y);
72
+ }
73
+ // Transforms
74
+ /**
75
+ * Transforms as point
76
+ * @param matrix4
77
+ * @returns
78
+ */
79
+ transform(matrix4) {
80
+ return this.transformAsPoint(matrix4);
81
+ }
82
+ /**
83
+ * transforms as point (4th component is implicitly 1)
84
+ * @param matrix4
85
+ * @returns
86
+ */
87
+ transformAsPoint(matrix4) {
88
+ vec2_transformMat4(this, this, matrix4);
89
+ return this.check();
90
+ }
91
+ /**
92
+ * transforms as vector (4th component is implicitly 0, ignores translation. slightly faster)
93
+ * @param matrix4
94
+ * @returns
95
+ */
96
+ transformAsVector(matrix4) {
97
+ vec2_transformMat4AsVector(this, this, matrix4);
98
+ return this.check();
99
+ }
100
+ transformByMatrix3(matrix3) {
101
+ vec2_transformMat3(this, this, matrix3);
102
+ return this.check();
103
+ }
104
+ transformByMatrix2x3(matrix2x3) {
105
+ vec2_transformMat2d(this, this, matrix2x3);
106
+ return this.check();
107
+ }
108
+ transformByMatrix2(matrix2) {
109
+ vec2_transformMat2(this, this, matrix2);
110
+ return this.check();
39
111
  }
40
-
41
- this[0] = object.x;
42
- this[1] = object.y;
43
- return this.check();
44
- }
45
-
46
- toObject(object) {
47
- object.x = this[0];
48
- object.y = this[1];
49
- return object;
50
- }
51
-
52
- get ELEMENTS() {
53
- return 2;
54
- }
55
-
56
- horizontalAngle() {
57
- return Math.atan2(this.y, this.x);
58
- }
59
-
60
- verticalAngle() {
61
- return Math.atan2(this.x, this.y);
62
- }
63
-
64
- transform(matrix4) {
65
- return this.transformAsPoint(matrix4);
66
- }
67
-
68
- transformAsPoint(matrix4) {
69
- vec2_transformMat4(this, this, matrix4);
70
- return this.check();
71
- }
72
-
73
- transformAsVector(matrix4) {
74
- vec2_transformMat4AsVector(this, this, matrix4);
75
- return this.check();
76
- }
77
-
78
- transformByMatrix3(matrix3) {
79
- vec2_transformMat3(this, this, matrix3);
80
- return this.check();
81
- }
82
-
83
- transformByMatrix2x3(matrix2x3) {
84
- vec2_transformMat2d(this, this, matrix2x3);
85
- return this.check();
86
- }
87
-
88
- transformByMatrix2(matrix2) {
89
- vec2_transformMat2(this, this, matrix2);
90
- return this.check();
91
- }
92
-
93
112
  }
94
- //# sourceMappingURL=vector2.js.map
@@ -1,8 +1,10 @@
1
- import { NumericArray } from '@math.gl/types';
2
- import { Vector } from './base/vector';
1
+ import { NumericArray, NumberArray3 } from '@math.gl/types';
2
+ import { Vector } from "./base/vector.js";
3
+ /** Helper type that captures array length for a 3 element vector */
4
+ export type Vector3Like = Vector3 | NumberArray3;
3
5
  /**
4
- * Three-element vector class.
5
- * Subclass of Array<number>
6
+ * Three-element vector class with common linear algebra operations.
7
+ * Subclass of Array<number> meaning that it is highly compatible with other libraries
6
8
  */
7
9
  export declare class Vector3 extends Vector {
8
10
  static get ZERO(): Vector3;
@@ -53,4 +55,3 @@ export declare class Vector3 extends Vector {
53
55
  transformByMatrix2(matrix2: Readonly<NumericArray>): this;
54
56
  transformByQuaternion(quaternion: Readonly<NumericArray>): this;
55
57
  }
56
- //# sourceMappingURL=vector3.d.ts.map