@vertexvis/viewer 0.18.2-testing.0 → 0.18.2-testing.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 (228) hide show
  1. package/dist/cjs/index-b99cd335.js +126 -1
  2. package/dist/esm/index-fd7d7b68.js +126 -1
  3. package/package.json +7 -7
  4. package/dist/components/_commonjsHelpers.js +0 -41
  5. package/dist/components/_commonjsHelpers.js.map +0 -1
  6. package/dist/components/browser.esm.js +0 -3173
  7. package/dist/components/browser.esm.js.map +0 -1
  8. package/dist/components/bundle.esm.js +0 -2250
  9. package/dist/components/bundle.esm.js.map +0 -1
  10. package/dist/components/bundle.esm2.js +0 -39740
  11. package/dist/components/bundle.esm2.js.map +0 -1
  12. package/dist/components/config.js +0 -81
  13. package/dist/components/config.js.map +0 -1
  14. package/dist/components/controller.js +0 -7627
  15. package/dist/components/controller.js.map +0 -1
  16. package/dist/components/controller2.js +0 -124
  17. package/dist/components/controller2.js.map +0 -1
  18. package/dist/components/controller3.js +0 -111
  19. package/dist/components/controller3.js.map +0 -1
  20. package/dist/components/cursors.js +0 -110
  21. package/dist/components/cursors.js.map +0 -1
  22. package/dist/components/dom.js +0 -43
  23. package/dist/components/dom.js.map +0 -1
  24. package/dist/components/dom2.js +0 -10
  25. package/dist/components/dom2.js.map +0 -1
  26. package/dist/components/elementRectObserver.js +0 -25
  27. package/dist/components/elementRectObserver.js.map +0 -1
  28. package/dist/components/entities.js +0 -179
  29. package/dist/components/entities.js.map +0 -1
  30. package/dist/components/errors.js +0 -80
  31. package/dist/components/errors.js.map +0 -1
  32. package/dist/components/events.js +0 -11
  33. package/dist/components/events.js.map +0 -1
  34. package/dist/components/index.d.ts +0 -26
  35. package/dist/components/index.js +0 -365
  36. package/dist/components/index.js.map +0 -1
  37. package/dist/components/index2.js +0 -63
  38. package/dist/components/index2.js.map +0 -1
  39. package/dist/components/interactions.js +0 -236
  40. package/dist/components/interactions.js.map +0 -1
  41. package/dist/components/mapper.js +0 -9811
  42. package/dist/components/mapper.js.map +0 -1
  43. package/dist/components/markup.js +0 -33
  44. package/dist/components/markup.js.map +0 -1
  45. package/dist/components/model.js +0 -134
  46. package/dist/components/model.js.map +0 -1
  47. package/dist/components/model2.js +0 -157
  48. package/dist/components/model2.js.map +0 -1
  49. package/dist/components/overlays.js +0 -76
  50. package/dist/components/overlays.js.map +0 -1
  51. package/dist/components/png-decoder.js +0 -2405
  52. package/dist/components/png-decoder.js.map +0 -1
  53. package/dist/components/regl-component.js +0 -12582
  54. package/dist/components/regl-component.js.map +0 -1
  55. package/dist/components/results.js +0 -24
  56. package/dist/components/results.js.map +0 -1
  57. package/dist/components/row.js +0 -32
  58. package/dist/components/row.js.map +0 -1
  59. package/dist/components/scene-tree-search.js +0 -146
  60. package/dist/components/scene-tree-search.js.map +0 -1
  61. package/dist/components/scene-tree-table-layout.js +0 -928
  62. package/dist/components/scene-tree-table-layout.js.map +0 -1
  63. package/dist/components/scene-tree-toolbar.js +0 -35
  64. package/dist/components/scene-tree-toolbar.js.map +0 -1
  65. package/dist/components/scene.js +0 -1508
  66. package/dist/components/scene.js.map +0 -1
  67. package/dist/components/stencil.js +0 -25
  68. package/dist/components/stencil.js.map +0 -1
  69. package/dist/components/streamAttributes.js +0 -40833
  70. package/dist/components/streamAttributes.js.map +0 -1
  71. package/dist/components/templates.js +0 -36
  72. package/dist/components/templates.js.map +0 -1
  73. package/dist/components/tslib.es6.js +0 -125
  74. package/dist/components/tslib.es6.js.map +0 -1
  75. package/dist/components/vertex-scene-tree-search.d.ts +0 -11
  76. package/dist/components/vertex-scene-tree-search.js +0 -11
  77. package/dist/components/vertex-scene-tree-search.js.map +0 -1
  78. package/dist/components/vertex-scene-tree-table-cell.d.ts +0 -11
  79. package/dist/components/vertex-scene-tree-table-cell.js +0 -209
  80. package/dist/components/vertex-scene-tree-table-cell.js.map +0 -1
  81. package/dist/components/vertex-scene-tree-table-column.d.ts +0 -11
  82. package/dist/components/vertex-scene-tree-table-column.js +0 -42
  83. package/dist/components/vertex-scene-tree-table-column.js.map +0 -1
  84. package/dist/components/vertex-scene-tree-table-header.d.ts +0 -11
  85. package/dist/components/vertex-scene-tree-table-header.js +0 -38
  86. package/dist/components/vertex-scene-tree-table-header.js.map +0 -1
  87. package/dist/components/vertex-scene-tree-table-layout.d.ts +0 -11
  88. package/dist/components/vertex-scene-tree-table-layout.js +0 -11
  89. package/dist/components/vertex-scene-tree-table-layout.js.map +0 -1
  90. package/dist/components/vertex-scene-tree-table-resize-divider.d.ts +0 -11
  91. package/dist/components/vertex-scene-tree-table-resize-divider.js +0 -57
  92. package/dist/components/vertex-scene-tree-table-resize-divider.js.map +0 -1
  93. package/dist/components/vertex-scene-tree-toolbar-group.d.ts +0 -11
  94. package/dist/components/vertex-scene-tree-toolbar-group.js +0 -38
  95. package/dist/components/vertex-scene-tree-toolbar-group.js.map +0 -1
  96. package/dist/components/vertex-scene-tree-toolbar.d.ts +0 -11
  97. package/dist/components/vertex-scene-tree-toolbar.js +0 -11
  98. package/dist/components/vertex-scene-tree-toolbar.js.map +0 -1
  99. package/dist/components/vertex-scene-tree.d.ts +0 -11
  100. package/dist/components/vertex-scene-tree.js +0 -803
  101. package/dist/components/vertex-scene-tree.js.map +0 -1
  102. package/dist/components/vertex-viewer-box-query-tool.d.ts +0 -11
  103. package/dist/components/vertex-viewer-box-query-tool.js +0 -352
  104. package/dist/components/vertex-viewer-box-query-tool.js.map +0 -1
  105. package/dist/components/vertex-viewer-button.d.ts +0 -11
  106. package/dist/components/vertex-viewer-button.js +0 -11
  107. package/dist/components/vertex-viewer-button.js.map +0 -1
  108. package/dist/components/vertex-viewer-default-toolbar.d.ts +0 -11
  109. package/dist/components/vertex-viewer-default-toolbar.js +0 -99
  110. package/dist/components/vertex-viewer-default-toolbar.js.map +0 -1
  111. package/dist/components/vertex-viewer-dom-element.d.ts +0 -11
  112. package/dist/components/vertex-viewer-dom-element.js +0 -11
  113. package/dist/components/vertex-viewer-dom-element.js.map +0 -1
  114. package/dist/components/vertex-viewer-dom-group.d.ts +0 -11
  115. package/dist/components/vertex-viewer-dom-group.js +0 -11
  116. package/dist/components/vertex-viewer-dom-group.js.map +0 -1
  117. package/dist/components/vertex-viewer-dom-renderer.d.ts +0 -11
  118. package/dist/components/vertex-viewer-dom-renderer.js +0 -11
  119. package/dist/components/vertex-viewer-dom-renderer.js.map +0 -1
  120. package/dist/components/vertex-viewer-hit-result-indicator.d.ts +0 -11
  121. package/dist/components/vertex-viewer-hit-result-indicator.js +0 -335
  122. package/dist/components/vertex-viewer-hit-result-indicator.js.map +0 -1
  123. package/dist/components/vertex-viewer-icon.d.ts +0 -11
  124. package/dist/components/vertex-viewer-icon.js +0 -11
  125. package/dist/components/vertex-viewer-icon.js.map +0 -1
  126. package/dist/components/vertex-viewer-layer.d.ts +0 -11
  127. package/dist/components/vertex-viewer-layer.js +0 -11
  128. package/dist/components/vertex-viewer-layer.js.map +0 -1
  129. package/dist/components/vertex-viewer-markup-arrow.d.ts +0 -11
  130. package/dist/components/vertex-viewer-markup-arrow.js +0 -11
  131. package/dist/components/vertex-viewer-markup-arrow.js.map +0 -1
  132. package/dist/components/vertex-viewer-markup-circle.d.ts +0 -11
  133. package/dist/components/vertex-viewer-markup-circle.js +0 -11
  134. package/dist/components/vertex-viewer-markup-circle.js.map +0 -1
  135. package/dist/components/vertex-viewer-markup-freeform.d.ts +0 -11
  136. package/dist/components/vertex-viewer-markup-freeform.js +0 -11
  137. package/dist/components/vertex-viewer-markup-freeform.js.map +0 -1
  138. package/dist/components/vertex-viewer-markup-tool.d.ts +0 -11
  139. package/dist/components/vertex-viewer-markup-tool.js +0 -257
  140. package/dist/components/vertex-viewer-markup-tool.js.map +0 -1
  141. package/dist/components/vertex-viewer-markup.d.ts +0 -11
  142. package/dist/components/vertex-viewer-markup.js +0 -362
  143. package/dist/components/vertex-viewer-markup.js.map +0 -1
  144. package/dist/components/vertex-viewer-measurement-details.d.ts +0 -11
  145. package/dist/components/vertex-viewer-measurement-details.js +0 -307
  146. package/dist/components/vertex-viewer-measurement-details.js.map +0 -1
  147. package/dist/components/vertex-viewer-measurement-distance.d.ts +0 -11
  148. package/dist/components/vertex-viewer-measurement-distance.js +0 -1067
  149. package/dist/components/vertex-viewer-measurement-distance.js.map +0 -1
  150. package/dist/components/vertex-viewer-measurement-line.d.ts +0 -11
  151. package/dist/components/vertex-viewer-measurement-line.js +0 -11
  152. package/dist/components/vertex-viewer-measurement-line.js.map +0 -1
  153. package/dist/components/vertex-viewer-measurement-overlays.d.ts +0 -11
  154. package/dist/components/vertex-viewer-measurement-overlays.js +0 -11
  155. package/dist/components/vertex-viewer-measurement-overlays.js.map +0 -1
  156. package/dist/components/vertex-viewer-measurement-precise.d.ts +0 -11
  157. package/dist/components/vertex-viewer-measurement-precise.js +0 -362
  158. package/dist/components/vertex-viewer-measurement-precise.js.map +0 -1
  159. package/dist/components/vertex-viewer-pin-group.d.ts +0 -11
  160. package/dist/components/vertex-viewer-pin-group.js +0 -11
  161. package/dist/components/vertex-viewer-pin-group.js.map +0 -1
  162. package/dist/components/vertex-viewer-pin-label-line.d.ts +0 -11
  163. package/dist/components/vertex-viewer-pin-label-line.js +0 -11
  164. package/dist/components/vertex-viewer-pin-label-line.js.map +0 -1
  165. package/dist/components/vertex-viewer-pin-label.d.ts +0 -11
  166. package/dist/components/vertex-viewer-pin-label.js +0 -11
  167. package/dist/components/vertex-viewer-pin-label.js.map +0 -1
  168. package/dist/components/vertex-viewer-pin-tool.d.ts +0 -11
  169. package/dist/components/vertex-viewer-pin-tool.js +0 -430
  170. package/dist/components/vertex-viewer-pin-tool.js.map +0 -1
  171. package/dist/components/vertex-viewer-spinner.d.ts +0 -11
  172. package/dist/components/vertex-viewer-spinner.js +0 -11
  173. package/dist/components/vertex-viewer-spinner.js.map +0 -1
  174. package/dist/components/vertex-viewer-toolbar-group.d.ts +0 -11
  175. package/dist/components/vertex-viewer-toolbar-group.js +0 -11
  176. package/dist/components/vertex-viewer-toolbar-group.js.map +0 -1
  177. package/dist/components/vertex-viewer-toolbar.d.ts +0 -11
  178. package/dist/components/vertex-viewer-toolbar.js +0 -11
  179. package/dist/components/vertex-viewer-toolbar.js.map +0 -1
  180. package/dist/components/vertex-viewer-transform-widget.d.ts +0 -11
  181. package/dist/components/vertex-viewer-transform-widget.js +0 -838
  182. package/dist/components/vertex-viewer-transform-widget.js.map +0 -1
  183. package/dist/components/vertex-viewer-view-cube.d.ts +0 -11
  184. package/dist/components/vertex-viewer-view-cube.js +0 -270
  185. package/dist/components/vertex-viewer-view-cube.js.map +0 -1
  186. package/dist/components/vertex-viewer.d.ts +0 -11
  187. package/dist/components/vertex-viewer.js +0 -3543
  188. package/dist/components/vertex-viewer.js.map +0 -1
  189. package/dist/components/viewer-button.js +0 -35
  190. package/dist/components/viewer-button.js.map +0 -1
  191. package/dist/components/viewer-dom-element.js +0 -250
  192. package/dist/components/viewer-dom-element.js.map +0 -1
  193. package/dist/components/viewer-dom-group.js +0 -214
  194. package/dist/components/viewer-dom-group.js.map +0 -1
  195. package/dist/components/viewer-dom-renderer.js +0 -295
  196. package/dist/components/viewer-dom-renderer.js.map +0 -1
  197. package/dist/components/viewer-icon.js +0 -87
  198. package/dist/components/viewer-icon.js.map +0 -1
  199. package/dist/components/viewer-layer.js +0 -46
  200. package/dist/components/viewer-layer.js.map +0 -1
  201. package/dist/components/viewer-markup-arrow.js +0 -235
  202. package/dist/components/viewer-markup-arrow.js.map +0 -1
  203. package/dist/components/viewer-markup-circle-components.js +0 -42
  204. package/dist/components/viewer-markup-circle-components.js.map +0 -1
  205. package/dist/components/viewer-markup-circle.js +0 -201
  206. package/dist/components/viewer-markup-circle.js.map +0 -1
  207. package/dist/components/viewer-markup-freeform.js +0 -251
  208. package/dist/components/viewer-markup-freeform.js.map +0 -1
  209. package/dist/components/viewer-measurement-line.js +0 -77
  210. package/dist/components/viewer-measurement-line.js.map +0 -1
  211. package/dist/components/viewer-measurement-overlays.js +0 -184
  212. package/dist/components/viewer-measurement-overlays.js.map +0 -1
  213. package/dist/components/viewer-pin-group.js +0 -207
  214. package/dist/components/viewer-pin-group.js.map +0 -1
  215. package/dist/components/viewer-pin-label-line.js +0 -43
  216. package/dist/components/viewer-pin-label-line.js.map +0 -1
  217. package/dist/components/viewer-pin-label.js +0 -427
  218. package/dist/components/viewer-pin-label.js.map +0 -1
  219. package/dist/components/viewer-spinner.js +0 -53
  220. package/dist/components/viewer-spinner.js.map +0 -1
  221. package/dist/components/viewer-toolbar-group.js +0 -42
  222. package/dist/components/viewer-toolbar-group.js.map +0 -1
  223. package/dist/components/viewer-toolbar.js +0 -61
  224. package/dist/components/viewer-toolbar.js.map +0 -1
  225. package/dist/components/viewport.js +0 -188
  226. package/dist/components/viewport.js.map +0 -1
  227. package/dist/components/wrappers_pb.js +0 -1926
  228. package/dist/components/wrappers_pb.js.map +0 -1
@@ -1,2250 +0,0 @@
1
- /*!
2
- * Copyright (c) 2023 Vertex Software LLC. All rights reserved.
3
- */
4
- import { c as __assign, b as __spreadArray } from './tslib.es6.js';
5
-
6
- /**
7
- * Clamps the given value between `min` and `max`.
8
- *
9
- * @param value The value to clamp.
10
- * @param min The min possible value.
11
- * @param max The max possible value.
12
- * @returns `value` or a value clamped to `min` or `max`.
13
- */
14
- function clamp(value, min, max) {
15
- return Math.max(min, Math.min(max, value));
16
- }
17
- /**
18
- * Linear interpolates a value between `a` and `b` by `t`. If `t` is 0, then the
19
- * result will be `a`. If `t` is 1, then the result will be `b`. `t` will be
20
- * clamped to a value between 0 and 1.
21
- *
22
- * @param a The start value.
23
- * @param b The end value.
24
- * @param t The interpolation value between 0 and 1.
25
- * @returns The interpolated value between `a` and `b`.
26
- */
27
- function lerp$2(a, b, t) {
28
- t = clamp(t, 0, 1);
29
- return t * (b - a) + a;
30
- }
31
-
32
- /**
33
- * Returns a new `Point` with the given horizontal and vertical position.
34
- */
35
- function create$c(x, y) {
36
- if (x === void 0) { x = 0; }
37
- if (y === void 0) { y = 0; }
38
- return { x: x, y: y };
39
- }
40
- /**
41
- * Converts a polar coordinate (length and angle) into a Cartesian coordinate.
42
- */
43
- function polar(length, radians) {
44
- var x = Math.cos(radians) * length;
45
- var y = Math.sin(radians) * length;
46
- return create$c(x, y);
47
- }
48
- /**
49
- * Returns the distance between two points.
50
- */
51
- function distance$2(a, b) {
52
- var delta = subtract$1(a, b);
53
- return Math.sqrt(delta.x * delta.x + delta.y * delta.y);
54
- }
55
- /**
56
- * Returns a new `Point` where `b` is subtracted from `a`.
57
- */
58
- function subtract$1(a, b) {
59
- return { x: a.x - b.x, y: a.y - b.y };
60
- }
61
- /**
62
- * Returns a new `Point` where `b` is added to `a`.
63
- */
64
- function add$1(a, b) {
65
- return { x: a.x + b.x, y: a.y + b.y };
66
- }
67
- /**
68
- * Returns `true` if the `x` and `y` positions of `a` and `b` are equal.
69
- */
70
- function isEqual$3(a, b) {
71
- return a.x === b.x && a.y === b.y;
72
- }
73
- /**
74
- * Performs a linear interpolation between `a` and `b` and returns the result.
75
- * The value of `t` is clamped between `[0, 1]`.
76
- *
77
- * @param a The start value.
78
- * @param b The end value.
79
- * @param t A value between 0 and 1.
80
- * @returns A point between `a` and `b`.
81
- */
82
- function lerp$1(a, b, t) {
83
- return {
84
- x: lerp$2(a.x, b.x, t),
85
- y: lerp$2(a.y, b.y, t),
86
- };
87
- }
88
- /**
89
- * Returns a new `Point` where `x` and `y` are inverted.
90
- */
91
- function negate$1(pt) {
92
- return create$c(-pt.x, -pt.y);
93
- }
94
- /**
95
- * Returns a new `Point` where `x` and `y` are multiplied by the given scale
96
- * factors.
97
- */
98
- function scale$4(pt, scaleX, scaleY) {
99
- return {
100
- x: pt.x * scaleX,
101
- y: pt.y * scaleY,
102
- };
103
- }
104
- /**
105
- * Parses a JSON string representation of a Point and returns an object.
106
- *
107
- * @param json A JSON string, either in the form `[x,y]` or `{"x": 0, "y": 0}`
108
- * @returns A parsed Point.
109
- */
110
- function fromJson$4(json) {
111
- var obj = JSON.parse(json);
112
- if (Array.isArray(obj)) {
113
- var x = obj[0], y = obj[1];
114
- return create$c(x, y);
115
- }
116
- else {
117
- var x = obj.x, y = obj.y;
118
- return create$c(x, y);
119
- }
120
- }
121
-
122
- var point = /*#__PURE__*/Object.freeze({
123
- __proto__: null,
124
- create: create$c,
125
- polar: polar,
126
- distance: distance$2,
127
- subtract: subtract$1,
128
- add: add$1,
129
- isEqual: isEqual$3,
130
- lerp: lerp$1,
131
- negate: negate$1,
132
- scale: scale$4,
133
- fromJson: fromJson$4
134
- });
135
-
136
- /**
137
- * Returns an `Angle` between two points, in radians.
138
- *
139
- * @param a The starting point.
140
- * @param b The ending point.
141
- * @returns An angle in radians.
142
- */
143
- function fromPoints$1(a, b) {
144
- var delta = subtract$1(b, a);
145
- var theta = Math.atan2(delta.y, delta.x);
146
- return theta;
147
- }
148
- /**
149
- * Returns an `Angle` between two points, in degrees.
150
- *
151
- * An angle of 0 represents an upward vector, and increases in a clockwise
152
- * direction.
153
- *
154
- * @deprecated Use {@link fromPoints} instead.
155
- */
156
- function fromPointsInDegrees(a, b) {
157
- var delta = subtract$1(b, a);
158
- var theta = Math.atan2(delta.y, delta.x);
159
- return normalize$1(toDegrees(theta) - 270);
160
- }
161
- /**
162
- * Normalizes the given angle, in degrees, to a number between 0 and 359.
163
- */
164
- function normalize$1(degrees) {
165
- return (degrees + 3600) % 360;
166
- }
167
- /**
168
- * Converts the given radians to degrees.
169
- */
170
- function toDegrees(radians) {
171
- return radians * (180 / Math.PI);
172
- }
173
- /**
174
- * Converts the given degrees to radians.
175
- */
176
- function toRadians(degrees) {
177
- return degrees * (Math.PI / 180);
178
- }
179
-
180
- var angle = /*#__PURE__*/Object.freeze({
181
- __proto__: null,
182
- fromPoints: fromPoints$1,
183
- fromPointsInDegrees: fromPointsInDegrees,
184
- normalize: normalize$1,
185
- toDegrees: toDegrees,
186
- toRadians: toRadians
187
- });
188
-
189
- /**
190
- * Creates a 4x4 matrix from a set of row-major components.
191
- */
192
- function fromValues(
193
- /* eslint-disable prettier/prettier */
194
- m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
195
- /* eslint-disable prettier/prettier */
196
- return [
197
- m11, m21, m31, m41,
198
- m12, m22, m32, m42,
199
- m13, m23, m33, m43,
200
- m14, m24, m34, m44,
201
- ];
202
- /* eslint-enable prettier/prettier */
203
- }
204
- /**
205
- * Creates a `Matrix4` from an object representation.
206
- */
207
- function fromObject(obj) {
208
- /* eslint-disable prettier/prettier */
209
- return fromValues(obj.m11, obj.m12, obj.m13, obj.m14, obj.m21, obj.m22, obj.m23, obj.m24, obj.m31, obj.m32, obj.m33, obj.m34, obj.m41, obj.m42, obj.m43, obj.m44);
210
- /* eslint-enable prettier/prettier */
211
- }
212
- /**
213
- * Returns a new [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix).
214
- */
215
- function makeIdentity() {
216
- return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
217
- }
218
- /**
219
- * Returns a matrix with all values as 0.
220
- */
221
- function makeZero() {
222
- return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
223
- }
224
- /**
225
- * Creates a translation matrix.
226
- *
227
- * ```
228
- * 1, 0, 0, 0,
229
- * 0, 1, 0, 0,
230
- * 0, 0, 1, 0,
231
- * x, y, z, 1
232
- * ```
233
- *
234
- * @param translation A vector representing the translation components.
235
- * @returns A translation matrix.
236
- */
237
- function makeTranslation(translation) {
238
- var x = translation.x, y = translation.y, z = translation.z;
239
- /* eslint-disable prettier/prettier */
240
- return [
241
- 1, 0, 0, 0,
242
- 0, 1, 0, 0,
243
- 0, 0, 1, 0,
244
- x, y, z, 1,
245
- ];
246
- /* eslint-enable prettier/prettier */
247
- }
248
- /**
249
- * Creates a rotation matrix.
250
- *
251
- * ```
252
- * 1-2y²-2z², 2xy-2zw, 2xz+2yw, 0,
253
- * 2xy+2zw, 1-2x²-2z², 2yz-2xw, 0,
254
- * 2xz-2yw, 2yz+2xw, 1-2x²-2y², 0,
255
- * 0, 0, 0, 1,
256
- * ```
257
- *
258
- * @param rotation A quaternion representing the rotation.
259
- * @see https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion
260
- * @returns A rotation matrix.
261
- */
262
- function makeRotation(rotation) {
263
- var x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
264
- var x2 = x + x, y2 = y + y, z2 = z + z;
265
- var xx = x * x2, xy = x * y2, xz = x * z2;
266
- var yy = y * y2, yz = y * z2, zz = z * z2;
267
- var wx = w * x2, wy = w * y2, wz = w * z2;
268
- /* eslint-disable prettier/prettier */
269
- return [
270
- 1 - (yy + zz), xy + wz, xz - wy, 0,
271
- xy - wz, 1 - (xx + zz), yz + wx, 0,
272
- xz + wy, yz - wx, 1 - (xx + yy), 0,
273
- 0, 0, 0, 1
274
- ];
275
- /* eslint-enable prettier/prettier */
276
- }
277
- /**
278
- * Creates a scale matrix.
279
- *
280
- * ```
281
- * x, 0, 0, 0,
282
- * 0, y, 0, 0,
283
- * 0, 0, z, 0,
284
- * 0, 0, 0, 1
285
- * ```
286
- *
287
- * @param scale A vector representing the different scale components.
288
- * @returns A scale matrix.
289
- */
290
- function makeScale(scale) {
291
- var x = scale.x, y = scale.y, z = scale.z;
292
- /* eslint-disable prettier/prettier */
293
- return [
294
- x, 0, 0, 0,
295
- 0, y, 0, 0,
296
- 0, 0, z, 0,
297
- 0, 0, 0, 1,
298
- ];
299
- /* eslint-enable prettier/prettier */
300
- }
301
- /**
302
- * Creates a matrix that has translation, rotation and scale applied to it.
303
- *
304
- * @param translation The translation applied to the matrix.
305
- * @param rotation The rotation applied to the matrix.
306
- * @param scale The scale applied to the matrix.
307
- * @returns A transformed matrix.
308
- */
309
- function makeTRS(translation, rotation, scale) {
310
- var t = makeTranslation(translation);
311
- var r = makeRotation(rotation);
312
- var s = makeScale(scale);
313
- return multiply$2(multiply$2(t, r), s);
314
- }
315
- /**
316
- * Returns a matrix that has the basis components (upper left 3x3 matrix) set to
317
- * the following x, y, and z axis.
318
- *
319
- * ```
320
- * x.x y.x z.x 0
321
- * x.y y.y z.y 0
322
- * x.z y.z z.z 0
323
- * 0 0 0 0
324
- * ```
325
- *
326
- * @param x The x axis to set.
327
- * @param y The y axis to set.
328
- * @param z The z axis to set.
329
- * @returns A matrix with its basis components populated.
330
- */
331
- function makeBasis(x, y, z) {
332
- /* eslint-disable prettier/prettier */
333
- return [
334
- x.x, x.y, x.z, 0,
335
- y.x, y.y, y.z, 0,
336
- z.x, z.y, z.z, 0,
337
- 0, 0, 0, 1
338
- ];
339
- /* eslint-enable prettier/prettier */
340
- }
341
- /**
342
- * Creates a rotation matrix that is rotated around a given axis by the given
343
- * angle.
344
- *
345
- * @param axis The axis of rotation.
346
- * @param radians The angle of rotation.
347
- * @returns A rotation matrix.
348
- */
349
- function makeRotationAxis(axis, radians) {
350
- var c = Math.cos(radians);
351
- var s = Math.sin(radians);
352
- var t = 1 - c;
353
- var x = axis.x, y = axis.y, z = axis.z;
354
- var tx = t * x;
355
- var ty = t * y;
356
- /* eslint-disable prettier/prettier */
357
- return [
358
- tx * x + c, tx * y + s * z, tx * z - s * y, 0,
359
- tx * y - s * z, ty * y + c, ty * z + s * x, 0,
360
- tx * z + s * y, ty * z - s * x, t * z * z + c, 0,
361
- 0, 0, 0, 1
362
- ];
363
- /* eslint-enable prettier/prettier */
364
- }
365
- /**
366
- * Creates a matrix used for [perspective
367
- * projections](https://en.wikipedia.org/wiki/3D_projection#Perspective_projection).
368
- *
369
- * The viewing volume is frustum-shaped and defined by the six parameters. Left,
370
- * right, top, and bottom specify coordinates in the near clipping plane where
371
- * the frustum edges intersect it, and the near and far parameters define the
372
- * forward distances of the view volume. The resulting volume can be vertically
373
- * and horizontally asymmetrical around the center of the near plane.
374
- *
375
- * @param left The left coordinate at the near plane.
376
- * @param right The right coordinate at the near plane.
377
- * @param top The top coordinate at the near plane.
378
- * @param bottom The bottom coordinate at the near plane.
379
- * @param near The near distance.
380
- * @param far The far distance.
381
- * @returns A matrix representing a view frustum.
382
- */
383
- function makeFrustum(left, right, top, bottom, near, far) {
384
- var x = (2 * near) / (right - left);
385
- var y = (2 * near) / (top - bottom);
386
- var a = (right + left) / (right - left);
387
- var b = (top + bottom) / (top - bottom);
388
- var c = -(far + near) / (far - near);
389
- var d = (-2 * far * near) / (far - near);
390
- /* eslint-disable prettier/prettier */
391
- return [
392
- x, 0, 0, 0,
393
- 0, y, 0, 0,
394
- a, b, c, -1,
395
- 0, 0, d, 0
396
- ];
397
- /* eslint-enable prettier/prettier */
398
- }
399
- /**
400
- * Creates a perspective projection matrix.
401
- *
402
- * Related to: gluPerspective. The viewing volume is frustum-shaped amd defined
403
- * by the four parameters. The fovy and aspect ratio are used to compute the
404
- * positions of the left, right, top, and bottom sides of the viewing volume in
405
- * the zNear plane. The fovy is the y field-of-view, the angle made by the top
406
- * and bottom sides of frustum if they were to intersect. The aspect ratio is
407
- * the width of the frustum divided by its height. Note that the resulting
408
- * volume is both vertically and horizontally symmetrical around the center of
409
- * the near plane.
410
- *
411
- * @param near The near Z value.
412
- * @param far The far Z value.
413
- * @param fovY The field of view.
414
- * @param aspect The aspect ratio.
415
- * @returns A matrix.
416
- */
417
- function makePerspective(near, far, fovY, aspect) {
418
- var ymax = near * Math.tan(toRadians(fovY / 2.0));
419
- var xmax = ymax * aspect;
420
- var left = -xmax;
421
- var right = xmax;
422
- var top = ymax;
423
- var bottom = -ymax;
424
- return makeFrustum(left, right, top, bottom, near, far);
425
- }
426
- /**
427
- * Creates an orthographic projection matrix.
428
- *
429
- * Related to: gluOrtho. The viewing volume is cube-shaped and defined by
430
- * the six parameters. The left and right values represent the coordinates of
431
- * the vertical clipping planes, top and bottom values represent the coordinates
432
- * of the horizontal clipping planes, and near and far values represent the
433
- * coordinates of the depth clipping planes.
434
- *
435
- * @param left The coordinate of the left horizontal clipping plane.
436
- * @param right The coordinate of the right horizontal clipping plane.
437
- * @param bottom The coordinate of the bottom vertical clipping plane.
438
- * @param top The coordinate of the top vertical clipping plane.
439
- * @param near The coordinate of the near depth clipping plane.
440
- * @param far The coordinate of the far depth clipping plane.
441
- * @returns A matrix.
442
- */
443
- function makeOrthographic(left, right, bottom, top, near, far) {
444
- var w = 1.0 / (right - left);
445
- var h = 1.0 / (top - bottom);
446
- var d = 1.0 / (far - near);
447
- var x = (right + left) * w;
448
- var y = (top + bottom) * h;
449
- var z = (far + near) * d;
450
- /* eslint-disable prettier/prettier */
451
- return [
452
- 2 * w, 0, 0, -x,
453
- 0, 2 * h, 0, -y,
454
- 0, 0, -2 * d, -z,
455
- 0, 0, 0, 1
456
- ];
457
- /* eslint-enable prettier/prettier */
458
- }
459
- /**
460
- * Matrix becomes a combination of an inverse translation and rotation.
461
- *
462
- * Related to: gluLookAt. This creates the inverse of makeLookAtMatrix. The
463
- * matrix will be an opposite translation from the 'eye' position, and it will
464
- * rotate things in the opposite direction of the eye-to-center orientation.
465
- * This is definitely confusing, but the main reason to use this transform is to
466
- * set up a view matrix for a camera that's looking at a certain point. To
467
- * achieve the effect of moving the camera somewhere and rotating it so that it
468
- * points at something, the rest of the world is moved in the opposite direction
469
- * and rotated in the opposite way around the camera. This way, you get the same
470
- * effect as moving the actual camera, but all the projection math can still be
471
- * done with the camera positioned at the origin (which makes it way simpler).
472
- *
473
- * @param position The position of the object.
474
- * @param lookAt The point which the object is looking at.
475
- * @param up The direction which the object considers up.
476
- * @returns A matrix.
477
- */
478
- function makeLookAtView(position, lookAt, up) {
479
- var z = normalize(subtract(position, lookAt));
480
- var x = normalize(cross(up, z));
481
- var y = cross(z, x);
482
- var dotX = -dot$1(x, position);
483
- var dotY = -dot$1(y, position);
484
- var dotZ = -dot$1(z, position);
485
- /* eslint-disable prettier/prettier */
486
- return [
487
- x.x, y.x, z.x, 0,
488
- x.y, y.y, z.y, 0,
489
- x.z, y.z, z.z, 0,
490
- dotX, dotY, dotZ, 1,
491
- ];
492
- /* eslint-enable prettier/prettier */
493
- }
494
- /**
495
- * Matrix becomes a combination of translation and rotation.
496
- *
497
- * Matrix becomes a combination of a translation to the position of 'eye' and a
498
- * rotation matrix which orients an object to point towards 'center' along its
499
- * z-axis. Use this function if you want an object to look at a point from
500
- * another point in space.
501
- *
502
- * @param position The position of the object.
503
- * @param lookAt The point which the object is looking at.
504
- * @param up The direction which the object considers up.
505
- * @returns A matrix.
506
- */
507
- function makeLookAt(position, lookAt, up) {
508
- var z = normalize(subtract(position, lookAt));
509
- var x = normalize(cross(up, z));
510
- var y = cross(z, x);
511
- /* eslint-disable prettier/prettier */
512
- return [
513
- x.x, x.y, x.z, 0,
514
- y.x, y.y, y.z, 0,
515
- z.x, z.y, z.z, 0,
516
- position.x, position.y, position.z, 1
517
- ];
518
- /* eslint-enable prettier/prettier */
519
- }
520
- /**
521
- * Returns the inverse of the given matrix. If the determinate of the matrix is
522
- * zero, then a zero matrix is returned.
523
- */
524
- function invert(matrix) {
525
- var a00 = matrix[0], a01 = matrix[1], a02 = matrix[2], a03 = matrix[3];
526
- var a10 = matrix[4], a11 = matrix[5], a12 = matrix[6], a13 = matrix[7];
527
- var a20 = matrix[8], a21 = matrix[9], a22 = matrix[10], a23 = matrix[11];
528
- var a30 = matrix[12], a31 = matrix[13], a32 = matrix[14], a33 = matrix[15];
529
- var b00 = a00 * a11 - a01 * a10;
530
- var b01 = a00 * a12 - a02 * a10;
531
- var b02 = a00 * a13 - a03 * a10;
532
- var b03 = a01 * a12 - a02 * a11;
533
- var b04 = a01 * a13 - a03 * a11;
534
- var b05 = a02 * a13 - a03 * a12;
535
- var b06 = a20 * a31 - a21 * a30;
536
- var b07 = a20 * a32 - a22 * a30;
537
- var b08 = a20 * a33 - a23 * a30;
538
- var b09 = a21 * a32 - a22 * a31;
539
- var b10 = a21 * a33 - a23 * a31;
540
- var b11 = a22 * a33 - a23 * a32;
541
- // Calculate the determinant
542
- var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
543
- if (!det) {
544
- return makeZero();
545
- }
546
- det = 1.0 / det;
547
- return [
548
- (a11 * b11 - a12 * b10 + a13 * b09) * det,
549
- (a02 * b10 - a01 * b11 - a03 * b09) * det,
550
- (a31 * b05 - a32 * b04 + a33 * b03) * det,
551
- (a22 * b04 - a21 * b05 - a23 * b03) * det,
552
- (a12 * b08 - a10 * b11 - a13 * b07) * det,
553
- (a00 * b11 - a02 * b08 + a03 * b07) * det,
554
- (a32 * b02 - a30 * b05 - a33 * b01) * det,
555
- (a20 * b05 - a22 * b02 + a23 * b01) * det,
556
- (a10 * b10 - a11 * b08 + a13 * b06) * det,
557
- (a01 * b08 - a00 * b10 - a03 * b06) * det,
558
- (a30 * b04 - a31 * b02 + a33 * b00) * det,
559
- (a21 * b02 - a20 * b04 - a23 * b00) * det,
560
- (a11 * b07 - a10 * b09 - a12 * b06) * det,
561
- (a00 * b09 - a01 * b07 + a02 * b06) * det,
562
- (a31 * b01 - a30 * b03 - a32 * b00) * det,
563
- (a20 * b03 - a21 * b01 + a22 * b00) * det,
564
- ];
565
- }
566
- /**
567
- * Returns a rotation matrix looking from position towards target and oriented
568
- * by an up vector.
569
- *
570
- * @param m The matrix to transform.
571
- * @param position The point from which to look at target.
572
- * @param target The point to look at.
573
- * @param up The orientation.
574
- * @returns A rotation matrix.
575
- */
576
- function lookAt(m, position, target, up) {
577
- var z = subtract(position, target);
578
- if (magnitudeSquared(z) === 0) {
579
- z = __assign(__assign({}, z), { z: 1 });
580
- }
581
- z = normalize(z);
582
- var x = cross(up, z);
583
- if (magnitudeSquared(x) === 0) {
584
- if (Math.abs(up.z) === 1) {
585
- z = __assign(__assign({}, z), { x: z.x + 0.0001 });
586
- }
587
- else {
588
- z = __assign(__assign({}, z), { z: z.z + 0.0001 });
589
- }
590
- z = normalize(z);
591
- x = cross(up, z);
592
- }
593
- x = normalize(x);
594
- var y = cross(z, x);
595
- var res = __spreadArray([], m, true);
596
- /* eslint-disable prettier/prettier */
597
- res[0] = x.x;
598
- res[4] = y.x;
599
- res[8] = z.x;
600
- res[1] = x.y;
601
- res[5] = y.y;
602
- res[9] = z.y;
603
- res[2] = x.z;
604
- res[6] = y.z;
605
- res[10] = z.z;
606
- /* eslint-enable prettier/prettier */
607
- return res;
608
- }
609
- /**
610
- * Returns a post-multiplied matrix.
611
- */
612
- function multiply$2(a, b) {
613
- var ae = a;
614
- var be = b;
615
- var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
616
- var a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
617
- var a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
618
- var a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
619
- var b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
620
- var b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
621
- var b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
622
- var b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
623
- var mat = makeIdentity();
624
- mat[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
625
- mat[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
626
- mat[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
627
- mat[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
628
- mat[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
629
- mat[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
630
- mat[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
631
- mat[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
632
- mat[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
633
- mat[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
634
- mat[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
635
- mat[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
636
- mat[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
637
- mat[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
638
- mat[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
639
- mat[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
640
- return mat;
641
- }
642
- /**
643
- * Returns the [transpose](https://en.wikipedia.org/wiki/Transpose) of the given
644
- * matrix.
645
- */
646
- function transpose(matrix) {
647
- /* eslint-disable prettier/prettier */
648
- return [
649
- matrix[0], matrix[4], matrix[8], matrix[12],
650
- matrix[1], matrix[5], matrix[9], matrix[13],
651
- matrix[2], matrix[6], matrix[10], matrix[14],
652
- matrix[3], matrix[7], matrix[11], matrix[15],
653
- ];
654
- /* eslint-enable prettier/prettier */
655
- }
656
- /**
657
- * Multiplies the columns of a matrix by the given vector.
658
- */
659
- function scale$3(matrix, scale) {
660
- var x = scale.x, y = scale.y, z = scale.z;
661
- var m = __spreadArray([], matrix, true);
662
- /* eslint-disable prettier/prettier */
663
- m[0] *= x;
664
- m[4] *= y;
665
- m[8] *= z;
666
- m[1] *= x;
667
- m[5] *= y;
668
- m[9] *= z;
669
- m[2] *= x;
670
- m[6] *= y;
671
- m[10] *= z;
672
- m[3] *= x;
673
- m[7] *= y;
674
- m[11] *= z;
675
- /* eslint-enable prettier/prettier */
676
- return m;
677
- }
678
- function position(matrix, other) {
679
- var m = __spreadArray([], matrix, true);
680
- m[12] = other[12];
681
- m[13] = other[13];
682
- m[14] = other[14];
683
- return m;
684
- }
685
- /**
686
- * Returns an object representation of a `Matrix4`.
687
- */
688
- function toObject(m) {
689
- /* eslint-disable prettier/prettier */
690
- return {
691
- m11: m[0], m12: m[4], m13: m[8], m14: m[12],
692
- m21: m[1], m22: m[5], m23: m[9], m24: m[13],
693
- m31: m[2], m32: m[6], m33: m[10], m34: m[14],
694
- m41: m[3], m42: m[7], m43: m[11], m44: m[15],
695
- };
696
- /* eslint-enable prettier/prettier */
697
- }
698
- /**
699
- * A type guard to check if `obj` is of type `Matrix4`.
700
- */
701
- function isType$2(obj) {
702
- return Array.isArray(obj) && obj.length === 16;
703
- }
704
-
705
- var matrix4 = /*#__PURE__*/Object.freeze({
706
- __proto__: null,
707
- fromValues: fromValues,
708
- fromObject: fromObject,
709
- makeIdentity: makeIdentity,
710
- makeZero: makeZero,
711
- makeTranslation: makeTranslation,
712
- makeRotation: makeRotation,
713
- makeScale: makeScale,
714
- makeTRS: makeTRS,
715
- makeBasis: makeBasis,
716
- makeRotationAxis: makeRotationAxis,
717
- makeFrustum: makeFrustum,
718
- makePerspective: makePerspective,
719
- makeOrthographic: makeOrthographic,
720
- makeLookAtView: makeLookAtView,
721
- makeLookAt: makeLookAt,
722
- invert: invert,
723
- lookAt: lookAt,
724
- multiply: multiply$2,
725
- transpose: transpose,
726
- scale: scale$3,
727
- position: position,
728
- toObject: toObject,
729
- isType: isType$2
730
- });
731
-
732
- function create$b() {
733
- var _a, _b, _c, _d, _e, _f;
734
- var args = [];
735
- for (var _i = 0; _i < arguments.length; _i++) {
736
- args[_i] = arguments[_i];
737
- }
738
- if (args.length === 1) {
739
- return {
740
- x: (_a = args[0].x) !== null && _a !== void 0 ? _a : 0,
741
- y: (_b = args[0].y) !== null && _b !== void 0 ? _b : 0,
742
- z: (_c = args[0].z) !== null && _c !== void 0 ? _c : 0,
743
- };
744
- }
745
- else if (args.length === 3) {
746
- return {
747
- x: (_d = args[0]) !== null && _d !== void 0 ? _d : 0,
748
- y: (_e = args[1]) !== null && _e !== void 0 ? _e : 0,
749
- z: (_f = args[2]) !== null && _f !== void 0 ? _f : 0,
750
- };
751
- }
752
- return {
753
- x: 0,
754
- y: 0,
755
- z: 0,
756
- };
757
- }
758
- /* eslint-enable @typescript-eslint/no-explicit-any */
759
- /* eslint-enable padding-line-between-statements */
760
- /**
761
- * Checks if each component of the given vector is populated with a numeric
762
- * component. A component is invalid if it contains a non-finite or NaN value.
763
- */
764
- function isValid(_a) {
765
- var x = _a.x, y = _a.y, z = _a.z;
766
- return [x, y, z].every(function (v) { return isFinite(v) && !isNaN(v); });
767
- }
768
- /**
769
- * Returns a vector representing the scale elements of `matrix`.
770
- */
771
- function fromMatrixScale(matrix) {
772
- var m = toObject(matrix);
773
- return {
774
- x: Math.hypot(m.m11, m.m21, m.m31),
775
- y: Math.hypot(m.m12, m.m22, m.m32),
776
- z: Math.hypot(m.m13, m.m23, m.m33),
777
- };
778
- }
779
- /**
780
- * Returns a vector representing the position elements of `matrix`.
781
- */
782
- function fromMatrixPosition(matrix) {
783
- var m = toObject(matrix);
784
- return { x: m.m14, y: m.m24, z: m.m34 };
785
- }
786
- /**
787
- * Parses a JSON string representation of a Vector3 and returns an object.
788
- *
789
- * @param json A JSON string, either in the form `[x,y,z]` or `{"x": 0, "y": 0, "z": 0}`
790
- * @returns A parsed Vector3.
791
- */
792
- function fromJson$3(json) {
793
- var obj = JSON.parse(json);
794
- if (Array.isArray(obj)) {
795
- var x = obj[0], y = obj[1], z = obj[2];
796
- return create$b(x, y, z);
797
- }
798
- else {
799
- var x = obj.x, y = obj.y, z = obj.z;
800
- return create$b(x, y, z);
801
- }
802
- }
803
- /**
804
- * Creates a `Vector3` from an array. Pass `offset` to read values from the
805
- * starting index.
806
- *
807
- * @see #toArray()
808
- * @see #create()
809
- */
810
- function fromArray(nums, offset) {
811
- if (offset === void 0) { offset = 0; }
812
- var x = nums[offset];
813
- var y = nums[offset + 1];
814
- var z = nums[offset + 2];
815
- return create$b(x, y, z);
816
- }
817
- /**
818
- * Converts a Vector3 to an array where the values of the vector will be
819
- * represented as [x, y, z];
820
- *
821
- * @see #fromArray()
822
- * @see #create()
823
- */
824
- function toArray(_a) {
825
- var x = _a.x, y = _a.y, z = _a.z;
826
- return [x, y, z];
827
- }
828
- /**
829
- * Returns a directional vector on the positive x axis, Vector3(1, 0, 0).
830
- */
831
- function right() {
832
- return create$b(1, 0, 0);
833
- }
834
- /**
835
- * Returns a directional vector on the positive y axis, Vector3(0, 1, 0).
836
- */
837
- function up() {
838
- return create$b(0, 1, 0);
839
- }
840
- /**
841
- * Returns a directional vector on the positive z axis, Vector3(0, 0, -1).
842
- */
843
- function forward() {
844
- return create$b(0, 0, -1);
845
- }
846
- /**
847
- * Returns a directional vector on the negative x axis, Vector3(-1, 0, 0).
848
- */
849
- function left() {
850
- return create$b(-1, 0, 0);
851
- }
852
- /**
853
- * Returns a directional vector on the negative y axis, Vector3(0, -1, 0).
854
- */
855
- function down() {
856
- return create$b(0, -1, 0);
857
- }
858
- /**
859
- * Returns a directional vector on the negative z axis, Vector3(0, 0, 1).
860
- */
861
- function back() {
862
- return create$b(0, 0, 1);
863
- }
864
- /**
865
- * Returns a vector at the origin, Vector3(0, 0, 0).
866
- */
867
- function origin() {
868
- return create$b(0, 0, 0);
869
- }
870
- /**
871
- * Returns a vector with that will have a magnitude of 1.
872
- */
873
- function normalize(vector) {
874
- var length = magnitude(vector);
875
- return { x: vector.x / length, y: vector.y / length, z: vector.z / length };
876
- }
877
- /**
878
- * Returns the straight-line length from (0, 0, 0) to the given vector.
879
- */
880
- function magnitude(vector) {
881
- return Math.sqrt(magnitudeSquared(vector));
882
- }
883
- /**
884
- * Returns the straight-line length from (0, 0, 0) to the given vector).
885
- *
886
- * When comparing lengths of vectors, you should use this function as it's
887
- * slightly more efficient to calculate.
888
- */
889
- function magnitudeSquared(vector) {
890
- return vector.x * vector.x + vector.y * vector.y + vector.z * vector.z;
891
- }
892
- /**
893
- * Returns a vector that is the cross product of two vectors.
894
- *
895
- * The cross product of two vectors results in a third vector which is
896
- * perpendicular to the two input vectors. The result's magnitude is equal to
897
- * the magnitudes of the two inputs multiplied together and then multiplied by
898
- * the sine of the angle between the inputs. You can determine the direction of
899
- * the result vector using the "left hand rule".
900
- */
901
- function cross(a, b) {
902
- return {
903
- x: a.y * b.z - a.z * b.y,
904
- y: a.z * b.x - a.x * b.z,
905
- z: a.x * b.y - a.y * b.x,
906
- };
907
- }
908
- /**
909
- * Returns a vector that is the sum of two vectors.
910
- */
911
- function add(a) {
912
- var vectors = [];
913
- for (var _i = 1; _i < arguments.length; _i++) {
914
- vectors[_i - 1] = arguments[_i];
915
- }
916
- return vectors.reduce(function (res, next) {
917
- return { x: res.x + next.x, y: res.y + next.y, z: res.z + next.z };
918
- }, a);
919
- }
920
- /**
921
- * Returns a vector that is the difference between two vectors.
922
- */
923
- function subtract(a) {
924
- var vectors = [];
925
- for (var _i = 1; _i < arguments.length; _i++) {
926
- vectors[_i - 1] = arguments[_i];
927
- }
928
- return vectors.reduce(function (res, next) {
929
- return { x: res.x - next.x, y: res.y - next.y, z: res.z - next.z };
930
- }, a);
931
- }
932
- /**
933
- * Returns a vector that where each component of `b` is multiplied with `a`.
934
- */
935
- function multiply$1(a, b) {
936
- return { x: a.x * b.x, y: a.y * b.y, z: a.z * b.z };
937
- }
938
- /**
939
- * Returns a vector where each value of a vector is multiplied by the `scalar`.
940
- */
941
- function scale$2(scalar, vector) {
942
- return { x: vector.x * scalar, y: vector.y * scalar, z: vector.z * scalar };
943
- }
944
- /**
945
- * Returns a value representing the dot product of two vectors.
946
- *
947
- * The dot product is a float value equal to the magnitudes of the two vectors
948
- * multiplied together and then multiplied by the cosine of the angle between
949
- * them.
950
- */
951
- function dot$1(a, b) {
952
- return a.x * b.x + a.y * b.y + a.z * b.z;
953
- }
954
- /**
955
- * Returns the angle, in radians, between two vectors.
956
- *
957
- * The angle returned is the unsigned angle between the two vectors. This means
958
- * the smaller of the two possible angles between the two vectors is used. The
959
- * result is never greater than 180 degrees.
960
- */
961
- function angleTo(a, b) {
962
- var theta = dot$1(a, b) / (magnitude(a) * magnitude(b));
963
- // Clamp to avoid numerical problems.
964
- return Math.acos(theta);
965
- }
966
- /**
967
- * Performs a projection of a `vector` onto `onNormal`.
968
- *
969
- * A projection is represented as the nearest point along a normal to a vector,
970
- * which constructs a triangle from the origin, to the vector, to the projected
971
- * point.
972
- *
973
- * ```
974
- * Vector --> * * <-- Projected
975
- * \
976
- * \ | <-- Normal
977
- * \|
978
- * * <-- Origin
979
- * ```
980
- */
981
- function project(vector, onNormal) {
982
- return scale$2(dot$1(onNormal, vector) / magnitude(onNormal), onNormal);
983
- }
984
- /**
985
- * Returns a vector that is rotated about an origin point.
986
- *
987
- * @param angle The angle to rotate, in radians.
988
- * @param point The origin point to rotate around.
989
- * @param axisDirection The direction used to compute the axis.
990
- * @param axisPosition The point of the axis.
991
- */
992
- function rotateAboutAxis(angle, point, axisDirection, axisPosition) {
993
- if (angle !== 0) {
994
- var x = point.x, y = point.y, z = point.z;
995
- var a = axisPosition.x, b = axisPosition.y, c = axisPosition.z;
996
- var u = axisDirection.x, v = axisDirection.y, w = axisDirection.z;
997
- var newX = (a * (v * v + w * w) - u * (b * v + c * w - u * x - v * y - w * z)) *
998
- (1 - Math.cos(angle)) +
999
- x * Math.cos(angle) +
1000
- (-c * v + b * w - w * y + v * z) * Math.sin(angle);
1001
- var newY = (b * (u * u + w * w) - v * (a * u + c * w - u * x - v * y - w * z)) *
1002
- (1 - Math.cos(angle)) +
1003
- y * Math.cos(angle) +
1004
- (c * u - a * w + w * x - u * z) * Math.sin(angle);
1005
- var newZ = (c * (u * u + v * v) - w * (a * u + b * v - u * x - v * y - w * z)) *
1006
- (1 - Math.cos(angle)) +
1007
- z * Math.cos(angle) +
1008
- (-b * u + a * v - v * x + u * y) * Math.sin(angle);
1009
- return { x: newX, y: newY, z: newZ };
1010
- }
1011
- else {
1012
- return point;
1013
- }
1014
- }
1015
- /**
1016
- * Returns a vector that is multiplied with a matrix.
1017
- */
1018
- function transformMatrix$1(vector, m) {
1019
- var x = vector.x, y = vector.y, z = vector.z;
1020
- var w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);
1021
- return {
1022
- x: (m[0] * x + m[4] * y + m[8] * z + m[12]) * w,
1023
- y: (m[1] * x + m[5] * y + m[9] * z + m[13]) * w,
1024
- z: (m[2] * x + m[6] * y + m[10] * z + m[14]) * w,
1025
- };
1026
- }
1027
- /**
1028
- * Euclidean distance between two vectors
1029
- */
1030
- function distance$1(a, b) {
1031
- return Math.sqrt(distanceSquared$1(a, b));
1032
- }
1033
- /**
1034
- * Returns the squared distance between two vectors. If you're just comparing
1035
- * distances, this is slightly more efficient than `distanceTo`.
1036
- */
1037
- function distanceSquared$1(a, b) {
1038
- var _a = subtract(a, b), dx = _a.x, dy = _a.y, dz = _a.z;
1039
- return dx * dx + dy * dy + dz * dz;
1040
- }
1041
- /**
1042
- * Returns `true` if two vectors have the same values.
1043
- */
1044
- function isEqual$2(a, b) {
1045
- return a.x === b.x && a.y === b.y && a.z === b.z;
1046
- }
1047
- /**
1048
- * Returns a vector that contains the largest components of `a` and `b`.
1049
- */
1050
- function max(a, b) {
1051
- return create$b(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z));
1052
- }
1053
- /**
1054
- * Returns a vector that contains the smallest components of `a` and `b`.
1055
- */
1056
- function min(a, b) {
1057
- return create$b(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z));
1058
- }
1059
- /**
1060
- * Returns a vector that each of its component negated.
1061
- */
1062
- function negate(vector) {
1063
- return { x: -vector.x, y: -vector.y, z: -vector.z };
1064
- }
1065
- /**
1066
- * Performs a linear interpolation between `a` and `b` and returns the result.
1067
- * The value of `t` is clamped between `[0, 1]`.
1068
- *
1069
- * @param a The start value.
1070
- * @param b The end value.
1071
- * @param t A value between 0 and 1.
1072
- * @returns A point between `a` and `b`.
1073
- */
1074
- function lerp(a, b, t) {
1075
- return {
1076
- x: lerp$2(a.x, b.x, t),
1077
- y: lerp$2(a.y, b.y, t),
1078
- z: lerp$2(a.z, b.z, t),
1079
- };
1080
- }
1081
- /**
1082
- * Maps a normalized device coordinate (NDC) space to world space coordinates.
1083
- *
1084
- * @param ndc A point in normalized device coordinates.
1085
- * @param worldMatrix A camera's world matrix.
1086
- * @param projectionMatrixInverse A camera's inverse projection matrix.
1087
- * @returns A point in world space coordinates.
1088
- */
1089
- function transformNdcToWorldSpace(ndc, worldMatrix, projectionMatrixInverse) {
1090
- return transformMatrix$1(transformMatrix$1(ndc, projectionMatrixInverse), worldMatrix);
1091
- }
1092
-
1093
- var vector3 = /*#__PURE__*/Object.freeze({
1094
- __proto__: null,
1095
- create: create$b,
1096
- isValid: isValid,
1097
- fromMatrixScale: fromMatrixScale,
1098
- fromMatrixPosition: fromMatrixPosition,
1099
- fromJson: fromJson$3,
1100
- fromArray: fromArray,
1101
- toArray: toArray,
1102
- right: right,
1103
- up: up,
1104
- forward: forward,
1105
- left: left,
1106
- down: down,
1107
- back: back,
1108
- origin: origin,
1109
- normalize: normalize,
1110
- magnitude: magnitude,
1111
- magnitudeSquared: magnitudeSquared,
1112
- cross: cross,
1113
- add: add,
1114
- subtract: subtract,
1115
- multiply: multiply$1,
1116
- scale: scale$2,
1117
- dot: dot$1,
1118
- angleTo: angleTo,
1119
- project: project,
1120
- rotateAboutAxis: rotateAboutAxis,
1121
- transformMatrix: transformMatrix$1,
1122
- distance: distance$1,
1123
- distanceSquared: distanceSquared$1,
1124
- isEqual: isEqual$2,
1125
- max: max,
1126
- min: min,
1127
- negate: negate,
1128
- lerp: lerp,
1129
- transformNdcToWorldSpace: transformNdcToWorldSpace
1130
- });
1131
-
1132
- /**
1133
- * Returns a `BoundingBox` with the given min and max points.
1134
- */
1135
- var create$a = function (min, max) {
1136
- return { min: min, max: max };
1137
- };
1138
- /**
1139
- * Construct a minimal bounding box for a set of vectors, such that all vectors
1140
- * are contained by the bounding box.
1141
- */
1142
- var fromVectors = function (vectors) {
1143
- return union.apply(void 0, vectors.map(function (v) { return create$a(v, v); }));
1144
- };
1145
- /**
1146
- * Returns the center point of the given `BoundingBox`.
1147
- */
1148
- var center$3 = function (boundingBox) {
1149
- return scale$2(0.5, add(boundingBox.min, boundingBox.max));
1150
- };
1151
- /**
1152
- * Returns the diagonal vector between the `min` and `max` vectors of the
1153
- * given `BoundingBox`.
1154
- */
1155
- var diagonal = function (boundingBox) {
1156
- return subtract(boundingBox.max, boundingBox.min);
1157
- };
1158
- /**
1159
- * Returns a floating-point spatial error tolerance based on the extents of the box.
1160
- */
1161
- var epsilon = function (boundingBox) {
1162
- return (Math.max(Math.max(magnitude(boundingBox.max), magnitude(boundingBox.min)), magnitude(diagonal(boundingBox))) * 1e-6);
1163
- };
1164
- function union(box) {
1165
- var rest = [];
1166
- for (var _i = 1; _i < arguments.length; _i++) {
1167
- rest[_i - 1] = arguments[_i];
1168
- }
1169
- var boxes = __spreadArray([box], rest, true);
1170
- return boxes.reduce(function (a, b) {
1171
- return create$a(min(a.min, b.min), max(a.max, b.max));
1172
- });
1173
- }
1174
- /* eslint-enable padding-line-between-statements */
1175
-
1176
- var boundingBox = /*#__PURE__*/Object.freeze({
1177
- __proto__: null,
1178
- create: create$a,
1179
- fromVectors: fromVectors,
1180
- center: center$3,
1181
- diagonal: diagonal,
1182
- epsilon: epsilon,
1183
- union: union
1184
- });
1185
-
1186
- /**
1187
- * Returns a `BoundingSphere` that encompasses the provided `BoundingBox`.
1188
- */
1189
- var create$9 = function (boundingBox$1) {
1190
- var boundingBoxCenter = center$3(boundingBox$1);
1191
- var centerToBoundingPlane = subtract(boundingBox$1.max, boundingBoxCenter);
1192
- var radius = magnitude(centerToBoundingPlane);
1193
- var length = Math.max(radius, magnitude(boundingBoxCenter));
1194
- var epsilon = length === 0 ? 1.0 : length * 1e-6;
1195
- return { center: boundingBoxCenter, radius: radius, epsilon: epsilon };
1196
- };
1197
-
1198
- var boundingSphere = /*#__PURE__*/Object.freeze({
1199
- __proto__: null,
1200
- create: create$9
1201
- });
1202
-
1203
- /**
1204
- * Returns a new `Rectangle` with the given position and size.
1205
- */
1206
- function create$8(x, y, width, height) {
1207
- return { x: x, y: y, width: width, height: height };
1208
- }
1209
- /**
1210
- * Returns a new `Rectangle` at the origin point and given size.
1211
- */
1212
- function fromDimensions(dimensions) {
1213
- return create$8(0, 0, dimensions.width, dimensions.height);
1214
- }
1215
- /**
1216
- * Returns a new `Rectangle` with the given position and size.
1217
- */
1218
- function fromPointAndDimensions(point, dimensions) {
1219
- return create$8(point.x, point.y, dimensions.width, dimensions.height);
1220
- }
1221
- /**
1222
- * Returns a new `Rectangle` with the given top-left and bottom-right positions.
1223
- * The returned rectangle will always returns a positive width and height.
1224
- */
1225
- function fromPoints(topLeftPt, bottomRightPt) {
1226
- var minX = Math.min(topLeftPt.x, bottomRightPt.x);
1227
- var minY = Math.min(topLeftPt.y, bottomRightPt.y);
1228
- var maxX = Math.max(topLeftPt.x, bottomRightPt.x);
1229
- var maxY = Math.max(topLeftPt.y, bottomRightPt.y);
1230
- return create$8(minX, minY, maxX - minX, maxY - minY);
1231
- }
1232
- /**
1233
- * Returns a rectangle where the longest length of `rect` will be equal to the
1234
- * shortest length of `to`. The shortest length of `rect` will be proportionally
1235
- * scaled to match the aspect ratio of `rect`. The returned rectangle will be
1236
- * centered within `to`.
1237
- *
1238
- * @see {@link cropFit}
1239
- */
1240
- function containFit$1(to, rect) {
1241
- var scale = Math.min(to.width / rect.width, to.height / rect.height);
1242
- var dimensions$1 = proportionalScale(scale, rect);
1243
- var position = subtract$1(center$2(to), center$1(dimensions$1));
1244
- return fromPointAndDimensions(position, dimensions$1);
1245
- }
1246
- /**
1247
- * Returns a rectangle where the shortest length of `rect` will be equal to the
1248
- * longest length of `to`. The longest length of `rect` will be proportionally
1249
- * scaled to match the aspect ratio of `rect`. The returned rectangle will be
1250
- * centered within `to`.
1251
- *
1252
- * @see {@link containFit}
1253
- */
1254
- function cropFit$1(to, rect) {
1255
- var scale = Math.max(to.width / rect.width, to.height / rect.height);
1256
- var dimensions$1 = proportionalScale(scale, rect);
1257
- var position = subtract$1(center$2(to), center$1(dimensions$1));
1258
- return fromPointAndDimensions(position, dimensions$1);
1259
- }
1260
- /**
1261
- * Returns a rectangle where each side of `rect` will be reduced proportionally
1262
- * to have an area less than or equal to the provided `to` value. The returned
1263
- * rectangle will be centered within the original bounds of `rect`.
1264
- *
1265
- * @param to - the maximum area this rectangle can have
1266
- * @param rect - the rectangle to scale to fit the specified area
1267
- */
1268
- function scaleFit$1(to, rect) {
1269
- var scale = Math.min(Math.sqrt(to / area$1(rect)), 1);
1270
- var dimensions$1 = floor(proportionalScale(scale, rect));
1271
- var position = subtract$1(center$2(rect), center$1(dimensions$1));
1272
- return fromPointAndDimensions(position, dimensions$1);
1273
- }
1274
- /**
1275
- * Returns a rectangle where the position and dimensions are scaled by the given
1276
- * factors. If `scaleY` is omitted, then the position and dimensions are scaled
1277
- * uniformly by `scaleOrScaleX`.
1278
- *
1279
- * @param rect The rectangle to scale.
1280
- * @param scaleOrScaleX The uniform scale factor, or the horizontal scale
1281
- * factor.
1282
- * @param scaleY The vertical scale factor.
1283
- * @returns A scaled rectangle.
1284
- */
1285
- function scale$1(rect, scaleOrScaleX, scaleY) {
1286
- if (scaleY == null) {
1287
- return scale$1(rect, scaleOrScaleX, scaleOrScaleX);
1288
- }
1289
- else {
1290
- var x = rect.x, y = rect.y, width = rect.width, height = rect.height;
1291
- var scaleX = scaleOrScaleX;
1292
- return create$8(x * scaleX, y * scaleY, width * scaleX, height * scaleY);
1293
- }
1294
- }
1295
- /**
1296
- * Returns true if two rectangles are equal in position and size.
1297
- */
1298
- function isEqual$1(a, b) {
1299
- return isEqual$3(a, b) && isEqual(a, b);
1300
- }
1301
- /**
1302
- * Returns a rectangle that has its position shifted by a given offset. The
1303
- * size of the rectangle is unchanged.
1304
- */
1305
- function offset(delta, rect) {
1306
- return fromPointAndDimensions(add$1(topLeft(rect), delta), rect);
1307
- }
1308
- /**
1309
- * Returns the area of the rectangle.
1310
- */
1311
- function area$1(rect) {
1312
- return rect.width * rect.height;
1313
- }
1314
- /**
1315
- * Returns the center point of the rectangle.
1316
- */
1317
- function center$2(rect) {
1318
- return { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 };
1319
- }
1320
- /**
1321
- * Returns the top-left position of the rectangle, as a point.
1322
- */
1323
- function topLeft(rect) {
1324
- return create$c(rect.x, rect.y);
1325
- }
1326
- /**
1327
- * Returns the bottom-right position of the rectangle, as a point.
1328
- */
1329
- function bottomRight(rect) {
1330
- return create$c(rect.x + rect.width, rect.y + rect.height);
1331
- }
1332
- /**
1333
- * Returns `true` if the given rectangle has a portrait aspect ratio.
1334
- */
1335
- function isPortrait(rect) {
1336
- return rect.width < rect.height;
1337
- }
1338
- /**
1339
- * Returns `true` if the given rectangle has a landscape aspect ratio.
1340
- */
1341
- function isLandscape(rect) {
1342
- return rect.width > rect.height;
1343
- }
1344
- /**
1345
- * Returns `true` if the given rectangle has a square aspect ratio.
1346
- */
1347
- function isSquare(rect) {
1348
- return rect.width === rect.height;
1349
- }
1350
- /**
1351
- * Pads a rectangle by the given amount, maintaining the center position.
1352
- *
1353
- * @param rect The rectangle to apply padding to.
1354
- * @param padding The padding to add.
1355
- */
1356
- function pad(rect, padding) {
1357
- return create$8(rect.x - padding, rect.y - padding, rect.width + padding * 2, rect.height + padding * 2);
1358
- }
1359
- /**
1360
- * Returns `true` if the given rectangle contains all the given `points`.
1361
- *
1362
- * @param rect The rectangle to check against.
1363
- * @param points The points to check.
1364
- */
1365
- function containsPoints(rect) {
1366
- var points = [];
1367
- for (var _i = 1; _i < arguments.length; _i++) {
1368
- points[_i - 1] = arguments[_i];
1369
- }
1370
- return points.every(function (point) {
1371
- return (rect.x <= point.x &&
1372
- rect.x + rect.width >= point.x &&
1373
- rect.y <= point.y &&
1374
- rect.y + rect.height >= point.y);
1375
- });
1376
- }
1377
- /**
1378
- * Parses a JSON string representation of a Rectangle and returns an object.
1379
- *
1380
- * @param json A JSON string, either in the form `[x,y,width,height]` or `{"x": 0, "y": 0, "width": 10, "height": 10}`
1381
- * @returns A parsed Point.
1382
- */
1383
- function fromJson$2(json) {
1384
- var obj = JSON.parse(json);
1385
- if (Array.isArray(obj)) {
1386
- var x = obj[0], y = obj[1], width = obj[2], height = obj[3];
1387
- return create$8(x, y, width, height);
1388
- }
1389
- else {
1390
- var x = obj.x, y = obj.y, width = obj.width, height = obj.height;
1391
- return create$8(x, y, width, height);
1392
- }
1393
- }
1394
-
1395
- var rectangle = /*#__PURE__*/Object.freeze({
1396
- __proto__: null,
1397
- create: create$8,
1398
- fromDimensions: fromDimensions,
1399
- fromPointAndDimensions: fromPointAndDimensions,
1400
- fromPoints: fromPoints,
1401
- containFit: containFit$1,
1402
- cropFit: cropFit$1,
1403
- scaleFit: scaleFit$1,
1404
- scale: scale$1,
1405
- isEqual: isEqual$1,
1406
- offset: offset,
1407
- area: area$1,
1408
- center: center$2,
1409
- topLeft: topLeft,
1410
- bottomRight: bottomRight,
1411
- isPortrait: isPortrait,
1412
- isLandscape: isLandscape,
1413
- isSquare: isSquare,
1414
- pad: pad,
1415
- containsPoints: containsPoints,
1416
- fromJson: fromJson$2
1417
- });
1418
-
1419
- /**
1420
- * Returns a `Dimensions` with the given width and height.
1421
- *
1422
- */
1423
- var create$7 = function (width, height) {
1424
- return { width: width, height: height };
1425
- };
1426
- /**
1427
- * Returns a `Dimensions` with the same width and height.
1428
- */
1429
- var square = function (size) {
1430
- return create$7(size, size);
1431
- };
1432
- /**
1433
- * Returns `true` if two dimensions have the same width and height. Otherwise
1434
- * `false`.
1435
- */
1436
- var isEqual = function (a, b) {
1437
- return a.width === b.width && a.height === b.height;
1438
- };
1439
- /**
1440
- * Returns a scaled dimensions, where the width is scaled by `scaleX` and height
1441
- * is scaled by `scaleY`.
1442
- */
1443
- var scale = function (scaleX, scaleY, dimensions) {
1444
- return {
1445
- width: dimensions.width * scaleX,
1446
- height: dimensions.height * scaleY,
1447
- };
1448
- };
1449
- /**
1450
- * Returns a dimension where each length is scaled by `scaleFactor`.
1451
- */
1452
- var proportionalScale = function (scaleFactor, dimensions) {
1453
- return scale(scaleFactor, scaleFactor, dimensions);
1454
- };
1455
- /**
1456
- * Returns a `Dimensions` where the lengths of `dimensions` are trimmed to fit
1457
- * into `to`.
1458
- */
1459
- var trim = function (to, dimensions) {
1460
- return {
1461
- width: Math.min(to.width, dimensions.width),
1462
- height: Math.min(to.height, dimensions.height),
1463
- };
1464
- };
1465
- /**
1466
- * Returns a `Dimensions` where the longest length of `dimensions` will be equal
1467
- * to the shortest length of `to`. The shortest length of `dimensions` will be
1468
- * proportionally scaled to match the aspect ratio of `dimensions`.
1469
- *
1470
- * @see #cropFit()
1471
- */
1472
- var containFit = function (to, dimensions) {
1473
- var _a = containFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
1474
- return { width: width, height: height };
1475
- };
1476
- /**
1477
- * Returns a `Dimensions` where the shortest length of `dimensions` will be
1478
- * equal to the longest length of `to`. The longest length of `dimensions` will
1479
- * be proportionally scaled to match the aspect ratio of `dimensions`.
1480
- *
1481
- * @see #containFit()
1482
- */
1483
- var cropFit = function (to, dimensions) {
1484
- var _a = cropFit$1(toRectangle(to), toRectangle(dimensions)), width = _a.width, height = _a.height;
1485
- return { width: width, height: height };
1486
- };
1487
- /**
1488
- * Returns a `Dimensions` where each side of `dimensions` will be reduced proportionally
1489
- * to have an area less than or equal to the provided `to` value. The returned
1490
- * dimensions will be centered within the original bounds of `dimensions`.
1491
- *
1492
- * @param to - the maximum area this dimensions can have
1493
- * @param dimensions - the dimensions to scale to fit the specified area
1494
- */
1495
- var scaleFit = function (to, dimensions) {
1496
- var _a = scaleFit$1(to, toRectangle(dimensions)), width = _a.width, height = _a.height;
1497
- return { width: width, height: height };
1498
- };
1499
- /**
1500
- * Returns a `Dimensions` with each length rounded.
1501
- */
1502
- var round = function (dimensions) {
1503
- return {
1504
- width: Math.round(dimensions.width),
1505
- height: Math.round(dimensions.height),
1506
- };
1507
- };
1508
- /**
1509
- * Returns a `Dimensions` with each length rounded down.
1510
- */
1511
- var floor = function (dimensions) {
1512
- return {
1513
- width: Math.floor(dimensions.width),
1514
- height: Math.floor(dimensions.height),
1515
- };
1516
- };
1517
- /**
1518
- * Returns the center point of the given `dimensions`.
1519
- */
1520
- var center$1 = function (dimensions) {
1521
- return { x: dimensions.width / 2, y: dimensions.height / 2 };
1522
- };
1523
- /**
1524
- * Returns the aspect ratio of the given `dimensions`, as defined by width over
1525
- * height.
1526
- */
1527
- var aspectRatio = function (_a) {
1528
- var width = _a.width, height = _a.height;
1529
- return width / height;
1530
- };
1531
- /**
1532
- * Returns the area of the given `dimensions`.
1533
- */
1534
- var area = function (_a) {
1535
- var width = _a.width, height = _a.height;
1536
- return width * height;
1537
- };
1538
- /**
1539
- * Returns a `Dimensions` fitted to the provided aspect ratio.
1540
- *
1541
- * @param ratio - Aspect ratio to fit the provided Dimensions to
1542
- * @param dimensions - Dimensions to fit to the specified ratio
1543
- */
1544
- var fitToRatio = function (ratio, dimensions) {
1545
- if (dimensions.width >= dimensions.height * ratio) {
1546
- return create$7(dimensions.height * ratio, dimensions.height);
1547
- }
1548
- return create$7(dimensions.width, dimensions.width / ratio);
1549
- };
1550
- /**
1551
- * Converts a dimension to a rectangle, with an optional position.
1552
- */
1553
- function toRectangle(dimensions, position) {
1554
- if (position === void 0) { position = create$c(); }
1555
- return fromPointAndDimensions(position, dimensions);
1556
- }
1557
-
1558
- var dimensions = /*#__PURE__*/Object.freeze({
1559
- __proto__: null,
1560
- create: create$7,
1561
- square: square,
1562
- isEqual: isEqual,
1563
- scale: scale,
1564
- proportionalScale: proportionalScale,
1565
- trim: trim,
1566
- containFit: containFit,
1567
- cropFit: cropFit,
1568
- scaleFit: scaleFit,
1569
- round: round,
1570
- floor: floor,
1571
- center: center$1,
1572
- aspectRatio: aspectRatio,
1573
- area: area,
1574
- fitToRatio: fitToRatio,
1575
- toRectangle: toRectangle
1576
- });
1577
-
1578
- /**
1579
- * Creates a new euler angle where each axis of rotation is defined by an angle,
1580
- * in radians. If no value is given, then `{x: 0, y: 0, z: 0, order: 'xyz'}` is
1581
- * returned.
1582
- *
1583
- * @param value The values to populate the euler angle with.
1584
- * @returns A euler angle.
1585
- */
1586
- function create$6(value) {
1587
- var _a, _b, _c, _d;
1588
- if (value === void 0) { value = {}; }
1589
- return {
1590
- x: (_a = value.x) !== null && _a !== void 0 ? _a : 0,
1591
- y: (_b = value.y) !== null && _b !== void 0 ? _b : 0,
1592
- z: (_c = value.z) !== null && _c !== void 0 ? _c : 0,
1593
- order: (_d = value.order) !== null && _d !== void 0 ? _d : 'xyz',
1594
- };
1595
- }
1596
- /**
1597
- * Creates a new euler angle where each axis of rotation is defined by an angle,
1598
- * in degrees. If no value is given, then `{x: 0, y: 0, z: 0, order: 'xyz'}` is
1599
- * returned.
1600
- *
1601
- * @param value The values to populate the euler angle with.
1602
- * @returns A euler angle.
1603
- */
1604
- function fromDegrees(value) {
1605
- if (value === void 0) { value = {}; }
1606
- var _a = value.x, x = _a === void 0 ? 0 : _a, _b = value.y, y = _b === void 0 ? 0 : _b, _c = value.z, z = _c === void 0 ? 0 : _c, order = value.order;
1607
- return create$6({
1608
- x: toRadians(x),
1609
- y: toRadians(y),
1610
- z: toRadians(z),
1611
- order: order,
1612
- });
1613
- }
1614
- /**
1615
- * Creates a euler angle from the rotation components of a 4x4 matrix. The
1616
- * rotation components are represented by the upper 3x3 of the matrix.
1617
- *
1618
- * @param matrix A pure rotation matrix, unscaled.
1619
- * @param order The order that the rotations are applied.
1620
- */
1621
- function fromRotationMatrix(matrix, order) {
1622
- if (order === void 0) { order = 'xyz'; }
1623
- var m = toObject(matrix);
1624
- var x = 0, y = 0, z = 0;
1625
- if (order === 'xyz') {
1626
- y = Math.asin(clamp(m.m13, -1, 1));
1627
- if (Math.abs(m.m13) < 0.9999999) {
1628
- x = Math.atan2(-m.m23, m.m33);
1629
- z = Math.atan2(-m.m12, m.m11);
1630
- }
1631
- else {
1632
- x = Math.atan2(m.m32, m.m22);
1633
- z = 0;
1634
- }
1635
- }
1636
- else if (order === 'yxz') {
1637
- x = Math.asin(-clamp(m.m23, -1, 1));
1638
- if (Math.abs(m.m23) < 0.9999999) {
1639
- y = Math.atan2(m.m13, m.m33);
1640
- z = Math.atan2(m.m21, m.m22);
1641
- }
1642
- else {
1643
- y = Math.atan2(-m.m31, m.m11);
1644
- z = 0;
1645
- }
1646
- }
1647
- else if (order === 'zxy') {
1648
- x = Math.asin(clamp(m.m32, -1, 1));
1649
- if (Math.abs(m.m32) < 0.9999999) {
1650
- y = Math.atan2(-m.m31, m.m33);
1651
- z = Math.atan2(-m.m12, m.m22);
1652
- }
1653
- else {
1654
- y = 0;
1655
- z = Math.atan2(m.m21, m.m11);
1656
- }
1657
- }
1658
- else if (order === 'zyx') {
1659
- y = Math.asin(-clamp(m.m31, -1, 1));
1660
- if (Math.abs(m.m31) < 0.9999999) {
1661
- x = Math.atan2(m.m32, m.m33);
1662
- z = Math.atan2(m.m21, m.m11);
1663
- }
1664
- else {
1665
- x = 0;
1666
- z = Math.atan2(-m.m12, m.m22);
1667
- }
1668
- }
1669
- else if (order === 'yzx') {
1670
- z = Math.asin(clamp(m.m21, -1, 1));
1671
- if (Math.abs(m.m21) < 0.9999999) {
1672
- x = Math.atan2(-m.m23, m.m22);
1673
- y = Math.atan2(-m.m31, m.m11);
1674
- }
1675
- else {
1676
- x = 0;
1677
- y = Math.atan2(m.m13, m.m33);
1678
- }
1679
- }
1680
- else if (order === 'xzy') {
1681
- z = Math.asin(-clamp(m.m12, -1, 1));
1682
- if (Math.abs(m.m12) < 0.9999999) {
1683
- x = Math.atan2(m.m32, m.m22);
1684
- y = Math.atan2(m.m13, m.m11);
1685
- }
1686
- else {
1687
- x = Math.atan2(-m.m23, m.m33);
1688
- y = 0;
1689
- }
1690
- }
1691
- return { x: x, y: y, z: z, order: order };
1692
- }
1693
- /**
1694
- * Returns a euler angle that was decoded from a JSON string. Supports either
1695
- * extracting values from an array `[x, y, z, order]` or object `{x, y, z,
1696
- * order}`.
1697
- *
1698
- * @param json A JSON object.
1699
- * @returns A euler angle.
1700
- */
1701
- function fromJson$1(json) {
1702
- var obj = JSON.parse(json);
1703
- if (Array.isArray(obj)) {
1704
- var x = obj[0], y = obj[1], z = obj[2], _a = obj[3], order = _a === void 0 ? 'xyz' : _a;
1705
- return { x: x, y: y, z: z, order: order };
1706
- }
1707
- else {
1708
- var x = obj.x, y = obj.y, z = obj.z, _b = obj.order, order = _b === void 0 ? 'xyz' : _b;
1709
- return { x: x, y: y, z: z, order: order };
1710
- }
1711
- }
1712
- /**
1713
- * Type guard that checks if the given type is a Euler.
1714
- */
1715
- function isType$1(obj) {
1716
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1717
- var o = obj;
1718
- return (o != null &&
1719
- o.hasOwnProperty('x') &&
1720
- o.hasOwnProperty('y') &&
1721
- o.hasOwnProperty('z') &&
1722
- o.hasOwnProperty('order'));
1723
- }
1724
-
1725
- var euler = /*#__PURE__*/Object.freeze({
1726
- __proto__: null,
1727
- create: create$6,
1728
- fromDegrees: fromDegrees,
1729
- fromRotationMatrix: fromRotationMatrix,
1730
- fromJson: fromJson$1,
1731
- isType: isType$1
1732
- });
1733
-
1734
- /**
1735
- * Creates a new `Line3`. If unspecified, the start and end values of the line
1736
- * will be at origin.
1737
- *
1738
- * @param values The values to assign to the line.
1739
- */
1740
- function create$5(values) {
1741
- var _a, _b;
1742
- if (values === void 0) { values = {}; }
1743
- return {
1744
- start: (_a = values.start) !== null && _a !== void 0 ? _a : origin(),
1745
- end: (_b = values.end) !== null && _b !== void 0 ? _b : origin(),
1746
- };
1747
- }
1748
- /**
1749
- * Returns the point that is halfway between start and end.
1750
- */
1751
- function center(line) {
1752
- return lerp(line.start, line.end, 0.5);
1753
- }
1754
- /**
1755
- * Returns a line where the start and end points are transformed with the given
1756
- * matrix.
1757
- *
1758
- * @param line The line to transform.
1759
- * @param matrix The matrix to apply.
1760
- * @returns A transformed line.
1761
- */
1762
- function transformMatrix(line, matrix) {
1763
- var start = transformMatrix$1(line.start, matrix);
1764
- var end = transformMatrix$1(line.end, matrix);
1765
- return { start: start, end: end };
1766
- }
1767
- /**
1768
- * Euclidean distance between the start and end points of the line.
1769
- */
1770
- function distance(line) {
1771
- return distance$1(line.start, line.end);
1772
- }
1773
- /**
1774
- * Returns the squared distance between a line's start and end point. If you're
1775
- * just comparing distances, this is slightly more efficient than `distanceTo`.
1776
- */
1777
- function distanceSquared(line) {
1778
- return distanceSquared$1(line.start, line.end);
1779
- }
1780
- /**
1781
- * Returns a vector describing the direction of the line from start to end.
1782
- */
1783
- function direction(line) {
1784
- return subtract(line.end, line.start);
1785
- }
1786
-
1787
- var line3 = /*#__PURE__*/Object.freeze({
1788
- __proto__: null,
1789
- create: create$5,
1790
- center: center,
1791
- transformMatrix: transformMatrix,
1792
- distance: distance,
1793
- distanceSquared: distanceSquared,
1794
- direction: direction
1795
- });
1796
-
1797
- /**
1798
- * Creates a new matrix. If arguments are undefined, returns an identity matrix.
1799
- */
1800
- var create$4 = function (a, b, c, d, tx, ty) {
1801
- if (a === void 0) { a = 1; }
1802
- if (b === void 0) { b = 0; }
1803
- if (c === void 0) { c = 0; }
1804
- if (d === void 0) { d = 1; }
1805
- if (tx === void 0) { tx = 0; }
1806
- if (ty === void 0) { ty = 0; }
1807
- return { a: a, b: b, c: c, d: d, tx: tx, ty: ty };
1808
- };
1809
- /**
1810
- * Returns an identity matrix.
1811
- */
1812
- var identity = function () {
1813
- return create$4();
1814
- };
1815
- /**
1816
- * Creates a matrix that is translated by the given `tx` and `ty` values.
1817
- */
1818
- var translation = function (tx, ty) {
1819
- return translate(tx, ty, identity());
1820
- };
1821
- /**
1822
- * Creates a matrix that is rotated by the given degrees.
1823
- */
1824
- var rotation = function (degrees) {
1825
- return rotate(degrees, identity());
1826
- };
1827
- /**
1828
- * Rotates the given matrix by the given degrees.
1829
- */
1830
- var rotate = function (degrees, matrix) {
1831
- var radians = toRadians(degrees);
1832
- var cos = Math.cos(radians);
1833
- var sin = Math.sin(radians);
1834
- var a = matrix.a * cos + matrix.c * sin;
1835
- var b = matrix.b * cos + matrix.d * sin;
1836
- var c = matrix.a * -sin + matrix.c * cos;
1837
- var d = matrix.b * -sin + matrix.d * cos;
1838
- return create$4(a, b, c, d, matrix.tx, matrix.ty);
1839
- };
1840
- /**
1841
- * Translates the given matrix along the horizontal and vertical axis by the
1842
- * given `dx` and `dy` delta values.
1843
- */
1844
- var translate = function (dx, dy, matrix) {
1845
- var newTx = matrix.a * dx + matrix.c * dy + matrix.tx;
1846
- var newTy = matrix.b * dx + matrix.d * dy + matrix.ty;
1847
- return create$4(matrix.a, matrix.b, matrix.c, matrix.d, newTx, newTy);
1848
- };
1849
- /**
1850
- * Returns the result of applying a geometric transformation of a matrix on the
1851
- * given point.
1852
- */
1853
- var transformPoint = function (matrix, pt) {
1854
- var x = matrix.a * pt.x + matrix.c * pt.y + matrix.tx;
1855
- var y = matrix.b * pt.x + matrix.d * pt.y + matrix.ty;
1856
- return create$c(x, y);
1857
- };
1858
-
1859
- var matrix = /*#__PURE__*/Object.freeze({
1860
- __proto__: null,
1861
- create: create$4,
1862
- identity: identity,
1863
- translation: translation,
1864
- rotation: rotation,
1865
- rotate: rotate,
1866
- translate: translate,
1867
- transformPoint: transformPoint
1868
- });
1869
-
1870
- function create$3() {
1871
- var args = [];
1872
- for (var _i = 0; _i < arguments.length; _i++) {
1873
- args[_i] = arguments[_i];
1874
- }
1875
- if (args.length === 2) {
1876
- return {
1877
- a: args[0].x,
1878
- b: args[0].y,
1879
- c: args[1].x,
1880
- d: args[1].y,
1881
- };
1882
- }
1883
- else if (args.length === 4) {
1884
- return {
1885
- a: args[0],
1886
- b: args[1],
1887
- c: args[2],
1888
- d: args[3],
1889
- };
1890
- }
1891
- return {
1892
- a: 0,
1893
- b: 0,
1894
- c: 0,
1895
- d: 0,
1896
- };
1897
- }
1898
- /**
1899
- * Returns the determinant of the provided matrix.
1900
- */
1901
- function determinant(matrix) {
1902
- return matrix.a * matrix.d - matrix.b * matrix.c;
1903
- }
1904
- /**
1905
- * Returns the dot product of the two vectors represented in this matrix.
1906
- */
1907
- function dot(matrix) {
1908
- return matrix.a * matrix.c + matrix.b * matrix.d;
1909
- }
1910
-
1911
- var matrix2 = /*#__PURE__*/Object.freeze({
1912
- __proto__: null,
1913
- create: create$3,
1914
- determinant: determinant,
1915
- dot: dot
1916
- });
1917
-
1918
- /**
1919
- * Creates a new plane. Defaults to a normal of `[0,0,0]` and constant of `0`.
1920
- *
1921
- * @param values Values to assign to the plane.
1922
- * @returns A new plane.
1923
- */
1924
- function create$2(values) {
1925
- if (values === void 0) { values = {}; }
1926
- return __assign({ normal: origin(), constant: 0 }, values);
1927
- }
1928
- /**
1929
- * Creates a plane from a normal and an arbitrary point on a plane.
1930
- *
1931
- * @param normal A normal.
1932
- * @param point A point on the plane.
1933
- * @returns A new plane.
1934
- */
1935
- function fromNormalAndCoplanarPoint(normal, point) {
1936
- var constant = -dot$1(point, normal);
1937
- return create$2({ normal: normal, constant: constant });
1938
- }
1939
- /**
1940
- * Returns the perpendicular distance from the plane to the given point.
1941
- *
1942
- * @param plane The plane.
1943
- * @param point The point to calculate distance from `plane`.
1944
- * @returns A distance.
1945
- */
1946
- function distanceToPoint(plane, point) {
1947
- return dot$1(plane.normal, point) + plane.constant;
1948
- }
1949
- /**
1950
- * Returns the point where the line intersects with this plane. If the line does
1951
- * not intersect, then `undefined` is returned. If the line is on the plane,
1952
- * then the starting point of the line is returned.
1953
- *
1954
- * @param plane The plane to intersect.
1955
- * @param line The line to intersect.
1956
- * @returns An intersecting point on the plane and line.
1957
- */
1958
- function intersectLine(plane, line) {
1959
- var direction$1 = direction(line);
1960
- var denominator = dot$1(plane.normal, direction$1);
1961
- if (denominator === 0) {
1962
- if (distanceToPoint(plane, line.start) === 0) {
1963
- return line.start;
1964
- }
1965
- else {
1966
- return undefined;
1967
- }
1968
- }
1969
- var t = -(dot$1(line.start, plane.normal) + plane.constant) / denominator;
1970
- if (t < 0 || t > 1) {
1971
- return undefined;
1972
- }
1973
- else {
1974
- return add(scale$2(t, direction$1), line.start);
1975
- }
1976
- }
1977
- /**
1978
- * Project's the given `point` onto the given `plane`.
1979
- *
1980
- * @param plane The plane to project onto.
1981
- * @param point The point to project.
1982
- * @returns The projected point.
1983
- */
1984
- function projectPoint(plane, point) {
1985
- var d = distanceToPoint(plane, point);
1986
- return add(point, scale$2(-d, plane.normal));
1987
- }
1988
-
1989
- var plane = /*#__PURE__*/Object.freeze({
1990
- __proto__: null,
1991
- create: create$2,
1992
- fromNormalAndCoplanarPoint: fromNormalAndCoplanarPoint,
1993
- distanceToPoint: distanceToPoint,
1994
- intersectLine: intersectLine,
1995
- projectPoint: projectPoint
1996
- });
1997
-
1998
- /**
1999
- * Returns a new quaternion. If `value` is undefined, then `{x: 0, y: 0, z: 0,
2000
- * w: 1}` is returned.
2001
- */
2002
- function create$1(value) {
2003
- if (value === void 0) { value = {}; }
2004
- return __assign({ x: 0, y: 0, z: 0, w: 1 }, value);
2005
- }
2006
- /**
2007
- * Parses a JSON string representation of a `Quaternion`.
2008
- *
2009
- * @param json A JSON string either in the form of `[x, y, z, w]` or `{"x": 0, "y": 0, "z": 0, "w": 0}`.
2010
- * @returns A parsed `Quaternion`.
2011
- */
2012
- function fromJson(json) {
2013
- var obj = JSON.parse(json);
2014
- if (Array.isArray(obj)) {
2015
- var x = obj[0], y = obj[1], z = obj[2], w = obj[3];
2016
- return create$1({ x: x, y: y, z: z, w: w });
2017
- }
2018
- else {
2019
- return create$1(obj);
2020
- }
2021
- }
2022
- /**
2023
- * Creates a `Quaternion` that is rotated the given radians around an axis.
2024
- *
2025
- * @param axis The axis to rotate around.
2026
- * @param radians The rotation, in radians.
2027
- * @returns A rotated quaternion.
2028
- */
2029
- function fromAxisAngle(axis, radians) {
2030
- var halfAngle = radians / 2;
2031
- var s = Math.sin(halfAngle);
2032
- var x = axis.x * s;
2033
- var y = axis.y * s;
2034
- var z = axis.z * s;
2035
- var w = Math.cos(halfAngle);
2036
- return { x: x, y: y, z: z, w: w };
2037
- }
2038
- /**
2039
- * Returns a quaternion using the upper 3x3 of a pure rotation matrix
2040
- * (unscaled).
2041
- */
2042
- function fromMatrixRotation(matrix) {
2043
- var m = toObject(matrix);
2044
- var scale = fromMatrixScale(matrix);
2045
- var is1 = 1 / scale.x;
2046
- var is2 = 1 / scale.y;
2047
- var is3 = 1 / scale.z;
2048
- var sm11 = m.m11 * is1;
2049
- var sm12 = m.m21 * is2;
2050
- var sm13 = m.m31 * is3;
2051
- var sm21 = m.m12 * is1;
2052
- var sm22 = m.m22 * is2;
2053
- var sm23 = m.m32 * is3;
2054
- var sm31 = m.m13 * is1;
2055
- var sm32 = m.m23 * is2;
2056
- var sm33 = m.m33 * is3;
2057
- var trace = sm11 + sm22 + sm33;
2058
- if (trace > 0) {
2059
- var s = Math.sqrt(trace + 1.0) * 2;
2060
- return {
2061
- x: (sm23 - sm32) / s,
2062
- y: (sm31 - sm13) / s,
2063
- z: (sm12 - sm21) / s,
2064
- w: 0.25 * s,
2065
- };
2066
- }
2067
- else if (sm11 > sm22 && sm11 > sm33) {
2068
- var s = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;
2069
- return {
2070
- x: 0.25 * s,
2071
- y: (sm12 + sm21) / s,
2072
- z: (sm31 + sm13) / s,
2073
- w: (sm23 - sm32) / s,
2074
- };
2075
- }
2076
- else if (sm22 > sm33) {
2077
- var s = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;
2078
- return {
2079
- x: (sm12 + sm21) / s,
2080
- y: 0.25 * s,
2081
- z: (sm23 + sm32) / s,
2082
- w: (sm31 - sm13) / s,
2083
- };
2084
- }
2085
- else {
2086
- var s = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;
2087
- return {
2088
- x: (sm31 + sm13) / s,
2089
- y: (sm23 + sm32) / s,
2090
- z: 0.25 * s,
2091
- w: (sm12 - sm21) / s,
2092
- };
2093
- }
2094
- }
2095
- function fromEuler(euler) {
2096
- var ex = euler.x, ey = euler.y, ez = euler.z, order = euler.order;
2097
- var c1 = Math.cos(ex / 2);
2098
- var c2 = Math.cos(ey / 2);
2099
- var c3 = Math.cos(ez / 2);
2100
- var s1 = Math.sin(ex / 2);
2101
- var s2 = Math.sin(ey / 2);
2102
- var s3 = Math.sin(ez / 2);
2103
- var x = 0, y = 0, z = 0, w = 0;
2104
- switch (order) {
2105
- case 'xyz':
2106
- x = s1 * c2 * c3 + c1 * s2 * s3;
2107
- y = c1 * s2 * c3 - s1 * c2 * s3;
2108
- z = c1 * c2 * s3 + s1 * s2 * c3;
2109
- w = c1 * c2 * c3 - s1 * s2 * s3;
2110
- break;
2111
- case 'yxz':
2112
- x = s1 * c2 * c3 + c1 * s2 * s3;
2113
- y = c1 * s2 * c3 - s1 * c2 * s3;
2114
- z = c1 * c2 * s3 - s1 * s2 * c3;
2115
- w = c1 * c2 * c3 + s1 * s2 * s3;
2116
- break;
2117
- case 'zxy':
2118
- x = s1 * c2 * c3 - c1 * s2 * s3;
2119
- y = c1 * s2 * c3 + s1 * c2 * s3;
2120
- z = c1 * c2 * s3 + s1 * s2 * c3;
2121
- w = c1 * c2 * c3 - s1 * s2 * s3;
2122
- break;
2123
- case 'zyx':
2124
- x = s1 * c2 * c3 - c1 * s2 * s3;
2125
- y = c1 * s2 * c3 + s1 * c2 * s3;
2126
- z = c1 * c2 * s3 - s1 * s2 * c3;
2127
- w = c1 * c2 * c3 + s1 * s2 * s3;
2128
- break;
2129
- case 'yzx':
2130
- x = s1 * c2 * c3 + c1 * s2 * s3;
2131
- y = c1 * s2 * c3 + s1 * c2 * s3;
2132
- z = c1 * c2 * s3 - s1 * s2 * c3;
2133
- w = c1 * c2 * c3 - s1 * s2 * s3;
2134
- break;
2135
- case 'xzy':
2136
- x = s1 * c2 * c3 - c1 * s2 * s3;
2137
- y = c1 * s2 * c3 - s1 * c2 * s3;
2138
- z = c1 * c2 * s3 + s1 * s2 * c3;
2139
- w = c1 * c2 * c3 + s1 * s2 * s3;
2140
- break;
2141
- }
2142
- return { x: x, y: y, z: z, w: w };
2143
- }
2144
- /**
2145
- * Multiplies `a` x `b` and returns a new quaternion with the result.
2146
- */
2147
- function multiply(a, b) {
2148
- // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
2149
- return {
2150
- x: a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y,
2151
- y: a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z,
2152
- z: a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x,
2153
- w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z,
2154
- };
2155
- }
2156
- /**
2157
- * Type guard that checks if the given type is a Quaternion.
2158
- */
2159
- function isType(obj) {
2160
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2161
- var o = obj;
2162
- return (o != null &&
2163
- o.hasOwnProperty('x') &&
2164
- o.hasOwnProperty('y') &&
2165
- o.hasOwnProperty('z') &&
2166
- o.hasOwnProperty('w'));
2167
- }
2168
-
2169
- var quaternion = /*#__PURE__*/Object.freeze({
2170
- __proto__: null,
2171
- create: create$1,
2172
- fromJson: fromJson,
2173
- fromAxisAngle: fromAxisAngle,
2174
- fromMatrixRotation: fromMatrixRotation,
2175
- fromEuler: fromEuler,
2176
- multiply: multiply,
2177
- isType: isType
2178
- });
2179
-
2180
- /**
2181
- * Creates a new ray with the given values, or using default values if none are
2182
- * provided. The direction defaults to `{x: 0, y: 0, z: -1}` if undefined.
2183
- *
2184
- * @param value The values of the ray.
2185
- * @returns A new ray.
2186
- */
2187
- function create(value) {
2188
- var _a, _b;
2189
- if (value === void 0) { value = {}; }
2190
- return {
2191
- origin: (_a = value.origin) !== null && _a !== void 0 ? _a : origin(),
2192
- direction: (_b = value.direction) !== null && _b !== void 0 ? _b : forward(),
2193
- };
2194
- }
2195
- /**
2196
- * Returns a point at the given distance along this ray.
2197
- *
2198
- * @param ray The ray to get the point on.
2199
- * @param distance A distance from origin along the ray's direction.
2200
- * @returns A point on the ray.
2201
- */
2202
- function at(ray, distance) {
2203
- return add(scale$2(distance, ray.direction), ray.origin);
2204
- }
2205
- /**
2206
- * Computes the distance of the `ray`s origin to the given `plane`. Returns a
2207
- * distance of 0 if the ray is coplanar and returns `undefined` if the ray does
2208
- * not intersect with the plane.
2209
- *
2210
- * @param ray The ray to get the distance for.
2211
- * @param plane The plane to compute the distance to.
2212
- * @returns The distance to the plane, or `undefined` if it cannot be computed.
2213
- */
2214
- function distanceToPlane(ray, plane$1) {
2215
- var d = dot$1(plane$1.normal, ray.direction);
2216
- if (d === 0) {
2217
- // Ray is on plane.
2218
- return distanceToPoint(plane$1, ray.origin) === 0 ? 0 : undefined;
2219
- }
2220
- else {
2221
- var t = -(dot$1(ray.origin, plane$1.normal) + plane$1.constant) / d;
2222
- // Checks if ray intersects plane.
2223
- return t >= 0 ? t : undefined;
2224
- }
2225
- }
2226
- /**
2227
- * Computes the intersection point of the given `ray` to the given `plane`. If
2228
- * the ray does not intersect with the plane, then `undefined` is returned.
2229
- *
2230
- * @param ray The ray to intersect.
2231
- * @param plane The plane to intersect with.
2232
- * @returns The intersection point, or `undefined` if the ray does not
2233
- * intersect.
2234
- */
2235
- function intersectPlane(ray, plane) {
2236
- var t = distanceToPlane(ray, plane);
2237
- return t != null ? at(ray, t) : undefined;
2238
- }
2239
-
2240
- var ray = /*#__PURE__*/Object.freeze({
2241
- __proto__: null,
2242
- create: create,
2243
- at: at,
2244
- distanceToPlane: distanceToPlane,
2245
- intersectPlane: intersectPlane
2246
- });
2247
-
2248
- export { boundingSphere as a, boundingBox as b, angle as c, dimensions as d, rectangle as e, plane as f, clamp as g, matrix2 as h, euler as i, matrix as j, line3 as l, matrix4 as m, point as p, quaternion as q, ray as r, vector3 as v };
2249
-
2250
- //# sourceMappingURL=bundle.esm.js.map