@ac-kit/math-linear 0.2.1 → 0.4.0
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.
- package/CHANGELOG.md +337 -0
- package/README.md +232 -16
- package/dist/_brand.d.ts +14 -0
- package/dist/_brand.d.ts.map +1 -0
- package/dist/_brand.js +2 -0
- package/dist/_brand.js.map +1 -0
- package/dist/_invert.d.ts +214 -0
- package/dist/_invert.d.ts.map +1 -0
- package/dist/_invert.js +884 -0
- package/dist/_invert.js.map +1 -0
- package/dist/_slerp.d.ts +29 -0
- package/dist/_slerp.d.ts.map +1 -1
- package/dist/_slerp.js +103 -0
- package/dist/_slerp.js.map +1 -1
- package/dist/_strided-range.d.ts +23 -0
- package/dist/_strided-range.d.ts.map +1 -0
- package/dist/_strided-range.js +75 -0
- package/dist/_strided-range.js.map +1 -0
- package/dist/_trs.d.ts +38 -0
- package/dist/_trs.d.ts.map +1 -0
- package/dist/_trs.js +132 -0
- package/dist/_trs.js.map +1 -0
- package/dist/affine2-array.d.ts +53 -0
- package/dist/affine2-array.d.ts.map +1 -0
- package/dist/affine2-array.js +107 -0
- package/dist/affine2-array.js.map +1 -0
- package/dist/affine2-componentwise.d.ts +28 -0
- package/dist/affine2-componentwise.d.ts.map +1 -0
- package/dist/affine2-componentwise.js +66 -0
- package/dist/affine2-componentwise.js.map +1 -0
- package/dist/affine2.d.ts +156 -0
- package/dist/affine2.d.ts.map +1 -0
- package/dist/affine2.js +437 -0
- package/dist/affine2.js.map +1 -0
- package/dist/affine3-array.d.ts +53 -0
- package/dist/affine3-array.d.ts.map +1 -0
- package/dist/affine3-array.js +137 -0
- package/dist/affine3-array.js.map +1 -0
- package/dist/affine3-componentwise.d.ts +32 -0
- package/dist/affine3-componentwise.d.ts.map +1 -0
- package/dist/affine3-componentwise.js +100 -0
- package/dist/affine3-componentwise.js.map +1 -0
- package/dist/affine3.d.ts +205 -0
- package/dist/affine3.d.ts.map +1 -0
- package/dist/affine3.js +792 -0
- package/dist/affine3.js.map +1 -0
- package/dist/checked/index.d.ts +35 -0
- package/dist/checked/index.d.ts.map +1 -0
- package/dist/checked/index.js +58 -0
- package/dist/checked/index.js.map +1 -0
- package/dist/euler.d.ts +65 -0
- package/dist/euler.d.ts.map +1 -0
- package/dist/euler.js +217 -0
- package/dist/euler.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/dist/kl-activations.d.ts.map +1 -1
- package/dist/kl-activations.js +4 -3
- package/dist/kl-activations.js.map +1 -1
- package/dist/mat2x2-array.d.ts +36 -0
- package/dist/mat2x2-array.d.ts.map +1 -0
- package/dist/mat2x2-array.js +71 -0
- package/dist/mat2x2-array.js.map +1 -0
- package/dist/mat2x2-componentwise.d.ts +86 -0
- package/dist/mat2x2-componentwise.d.ts.map +1 -0
- package/dist/mat2x2-componentwise.js +199 -0
- package/dist/mat2x2-componentwise.js.map +1 -0
- package/dist/mat2x2.d.ts +79 -25
- package/dist/mat2x2.d.ts.map +1 -1
- package/dist/mat2x2.js +192 -93
- package/dist/mat2x2.js.map +1 -1
- package/dist/mat3x3-array.d.ts +36 -0
- package/dist/mat3x3-array.d.ts.map +1 -0
- package/dist/mat3x3-array.js +91 -0
- package/dist/mat3x3-array.js.map +1 -0
- package/dist/mat3x3-componentwise.d.ts +86 -0
- package/dist/mat3x3-componentwise.d.ts.map +1 -0
- package/dist/mat3x3-componentwise.js +299 -0
- package/dist/mat3x3-componentwise.js.map +1 -0
- package/dist/mat3x3.d.ts +153 -48
- package/dist/mat3x3.d.ts.map +1 -1
- package/dist/mat3x3.js +470 -192
- package/dist/mat3x3.js.map +1 -1
- package/dist/mat4x4-array.d.ts +46 -0
- package/dist/mat4x4-array.d.ts.map +1 -0
- package/dist/mat4x4-array.js +133 -0
- package/dist/mat4x4-array.js.map +1 -0
- package/dist/mat4x4-componentwise.d.ts +87 -0
- package/dist/mat4x4-componentwise.d.ts.map +1 -0
- package/dist/mat4x4-componentwise.js +434 -0
- package/dist/mat4x4-componentwise.js.map +1 -0
- package/dist/mat4x4.d.ts +221 -67
- package/dist/mat4x4.d.ts.map +1 -1
- package/dist/mat4x4.js +972 -334
- package/dist/mat4x4.js.map +1 -1
- package/dist/projection.d.ts +113 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +418 -0
- package/dist/projection.js.map +1 -0
- package/dist/quaternion-array.d.ts +47 -0
- package/dist/quaternion-array.d.ts.map +1 -0
- package/dist/quaternion-array.js +86 -0
- package/dist/quaternion-array.js.map +1 -0
- package/dist/quaternion.d.ts +106 -22
- package/dist/quaternion.d.ts.map +1 -1
- package/dist/quaternion.js +253 -182
- package/dist/quaternion.js.map +1 -1
- package/dist/transform.d.ts +220 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +412 -0
- package/dist/transform.js.map +1 -0
- package/dist/tridiagonal.d.ts +52 -0
- package/dist/tridiagonal.d.ts.map +1 -0
- package/dist/tridiagonal.js +90 -0
- package/dist/tridiagonal.js.map +1 -0
- package/dist/upload.d.ts +55 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +129 -0
- package/dist/upload.js.map +1 -0
- package/dist/vec2-array-componentwise.d.ts +207 -0
- package/dist/vec2-array-componentwise.d.ts.map +1 -0
- package/dist/vec2-array-componentwise.js +472 -0
- package/dist/vec2-array-componentwise.js.map +1 -0
- package/dist/vec2-array.d.ts +53 -0
- package/dist/vec2-array.d.ts.map +1 -0
- package/dist/vec2-array.js +123 -0
- package/dist/vec2-array.js.map +1 -0
- package/dist/vec2-componentwise.d.ts +311 -0
- package/dist/vec2-componentwise.d.ts.map +1 -0
- package/dist/vec2-componentwise.js +542 -0
- package/dist/vec2-componentwise.js.map +1 -0
- package/dist/vec2.d.ts +97 -82
- package/dist/vec2.d.ts.map +1 -1
- package/dist/vec2.js +121 -216
- package/dist/vec2.js.map +1 -1
- package/dist/vec3-array-componentwise.d.ts +207 -0
- package/dist/vec3-array-componentwise.d.ts.map +1 -0
- package/dist/vec3-array-componentwise.js +510 -0
- package/dist/vec3-array-componentwise.js.map +1 -0
- package/dist/vec3-array.d.ts +102 -0
- package/dist/vec3-array.d.ts.map +1 -0
- package/dist/vec3-array.js +299 -0
- package/dist/vec3-array.js.map +1 -0
- package/dist/vec3-componentwise.d.ts +310 -0
- package/dist/vec3-componentwise.d.ts.map +1 -0
- package/dist/vec3-componentwise.js +594 -0
- package/dist/vec3-componentwise.js.map +1 -0
- package/dist/vec3.d.ts +177 -87
- package/dist/vec3.d.ts.map +1 -1
- package/dist/vec3.js +391 -272
- package/dist/vec3.js.map +1 -1
- package/dist/vec4-array-componentwise.d.ts +198 -0
- package/dist/vec4-array-componentwise.d.ts.map +1 -0
- package/dist/vec4-array-componentwise.js +521 -0
- package/dist/vec4-array-componentwise.js.map +1 -0
- package/dist/vec4-array.d.ts +12 -0
- package/dist/vec4-array.d.ts.map +1 -0
- package/dist/vec4-array.js +43 -0
- package/dist/vec4-array.js.map +1 -0
- package/dist/vec4-componentwise.d.ts +299 -0
- package/dist/vec4-componentwise.d.ts.map +1 -0
- package/dist/vec4-componentwise.js +637 -0
- package/dist/vec4-componentwise.js.map +1 -0
- package/dist/vec4.d.ts +59 -53
- package/dist/vec4.d.ts.map +1 -1
- package/dist/vec4.js +74 -249
- package/dist/vec4.js.map +1 -1
- package/dist/view-basis.d.ts +15 -0
- package/dist/view-basis.d.ts.map +1 -0
- package/dist/view-basis.js +29 -0
- package/dist/view-basis.js.map +1 -0
- package/dist/viewport.d.ts +114 -0
- package/dist/viewport.d.ts.map +1 -0
- package/dist/viewport.js +250 -0
- package/dist/viewport.js.map +1 -0
- package/package.json +19 -9
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { describeValue } from "@ac-kit/core";
|
|
2
|
+
import { vec3AddScaled, vec3Copy, vec3Create, vec3Dot, vec3Length, vec3NormalizeScaled, vec3Subtract, } from "./vec3-componentwise.js";
|
|
3
|
+
import { vec3Cross } from "./vec3.js";
|
|
4
|
+
/** Scratch for the view builders: one call at a time, no callback inside it. */
|
|
5
|
+
const BACK_ = vec3Create();
|
|
6
|
+
const RIGHT_ = vec3Create();
|
|
7
|
+
const VERTICAL_ = vec3Create();
|
|
8
|
+
const UP_ = vec3Create();
|
|
9
|
+
/**
|
|
10
|
+
* The sine of the angle between `up` and the view direction at or below which
|
|
11
|
+
* the camera builders take them as parallel (and throw), where the cross
|
|
12
|
+
* product that fixes the `right` axis is rounding noise.
|
|
13
|
+
*
|
|
14
|
+
* Both vectors are unit after normalising, each component carrying at most
|
|
15
|
+
* about `2ε` (a division, a square root and a product); the cross product of
|
|
16
|
+
* the rounded vectors then differs from that of the exact directions by at most
|
|
17
|
+
* `4ε` per component, and computing it adds at most `2ε`. Anything of length up
|
|
18
|
+
* to about `6ε` can be that error alone, so its direction means nothing; `16ε`
|
|
19
|
+
* (`3.6e-15`) is that bound with a margin of two and a half. Above it the axis
|
|
20
|
+
* is the cross product of the inputs as given, to within `6ε / sin θ` in
|
|
21
|
+
* direction, which the re-orthogonalisation keeps from becoming a skewed
|
|
22
|
+
* basis.
|
|
23
|
+
*
|
|
24
|
+
* Not a tolerance, and deliberately not configurable.
|
|
25
|
+
*/
|
|
26
|
+
const PARALLEL_MIN_SINE_ = 16 * Number.EPSILON;
|
|
27
|
+
/**
|
|
28
|
+
* The perspective entry `m[10]`, which maps the view depth to the clip depth:
|
|
29
|
+
* the near plane to the first value of the range and the far plane to the
|
|
30
|
+
* second. `far` may be `Infinity`.
|
|
31
|
+
*
|
|
32
|
+
* @throws {RangeError} For a `depthRange` that is none of the three.
|
|
33
|
+
*/
|
|
34
|
+
function perspectiveDepthScale_(near, far, depthRange) {
|
|
35
|
+
switch (depthRange) {
|
|
36
|
+
case "negative-one-to-one":
|
|
37
|
+
// −(1 + 2·near/(far − near)), the form that is exact at far = ∞.
|
|
38
|
+
return -(1 + 2 * (near / (far - near)));
|
|
39
|
+
case "zero-to-one":
|
|
40
|
+
return far === Infinity ? -1 : -(far / (far - near));
|
|
41
|
+
case "one-to-zero":
|
|
42
|
+
return near / (far - near);
|
|
43
|
+
default:
|
|
44
|
+
throw new RangeError(`Unknown depth range: ${describeValue(depthRange)}.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The perspective entry `m[14]`, given the scale `m[10]` of
|
|
49
|
+
* {@link perspectiveDepthScale_}.
|
|
50
|
+
*/
|
|
51
|
+
function perspectiveDepthOffset_(near, far, depthRange, scale) {
|
|
52
|
+
switch (depthRange) {
|
|
53
|
+
case "negative-one-to-one":
|
|
54
|
+
return -near * (1 - scale);
|
|
55
|
+
case "zero-to-one":
|
|
56
|
+
return near * scale;
|
|
57
|
+
case "one-to-zero":
|
|
58
|
+
return far === Infinity ? near : near * (far / (far - near));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Writes into `out` the perspective projection of a right-handed camera space
|
|
63
|
+
* (forward is −Z) to clip space: the near plane maps to the first depth of
|
|
64
|
+
* `depthRange` and the far plane to the second, after the divide by `w`. `fovY`
|
|
65
|
+
* is the vertical field of view in radians and `aspect` the width over the
|
|
66
|
+
* height. `far` may be `Infinity`, an infinite far plane, in every range.
|
|
67
|
+
*
|
|
68
|
+
* Called once per frame or on a resize, so it validates and throws; `out` is
|
|
69
|
+
* left untouched when it does. Right for `near` and `far` up to about `1e307`
|
|
70
|
+
* (the depth offset `near·(1 − scale)` of the OpenGL range overflows beyond).
|
|
71
|
+
*
|
|
72
|
+
* @throws {RangeError} Unless `0 < fovY < π`, `aspect` is finite and positive,
|
|
73
|
+
* `0 < near < far` (`far` may be infinite), the coefficients are
|
|
74
|
+
* representable (an aspect of `1e-320` is not), and `depthRange` is one of
|
|
75
|
+
* the three.
|
|
76
|
+
*/
|
|
77
|
+
export function mat4x4Perspective(out, fovY, aspect, near, far, depthRange) {
|
|
78
|
+
if (!(fovY > 0 && fovY < Math.PI && aspect > 0 && near > 0 && far > near) ||
|
|
79
|
+
!Number.isFinite(aspect)) {
|
|
80
|
+
throw new RangeError("Invalid perspective frustum.");
|
|
81
|
+
}
|
|
82
|
+
const verticalScale = 1 / Math.tan(fovY / 2);
|
|
83
|
+
const horizontalScale = verticalScale / aspect;
|
|
84
|
+
const depthScale = perspectiveDepthScale_(near, far, depthRange);
|
|
85
|
+
const depthOffset = perspectiveDepthOffset_(near, far, depthRange, depthScale);
|
|
86
|
+
if (!(horizontalScale > 0) ||
|
|
87
|
+
!Number.isFinite(verticalScale) ||
|
|
88
|
+
!Number.isFinite(horizontalScale) ||
|
|
89
|
+
!Number.isFinite(depthScale) ||
|
|
90
|
+
!Number.isFinite(depthOffset)) {
|
|
91
|
+
throw new RangeError("Perspective coefficients are not representable.");
|
|
92
|
+
}
|
|
93
|
+
out[0] = horizontalScale;
|
|
94
|
+
out[1] = 0;
|
|
95
|
+
out[2] = 0;
|
|
96
|
+
out[3] = 0;
|
|
97
|
+
out[4] = 0;
|
|
98
|
+
out[5] = verticalScale;
|
|
99
|
+
out[6] = 0;
|
|
100
|
+
out[7] = 0;
|
|
101
|
+
out[8] = 0;
|
|
102
|
+
out[9] = 0;
|
|
103
|
+
out[10] = depthScale;
|
|
104
|
+
out[11] = -1;
|
|
105
|
+
out[12] = 0;
|
|
106
|
+
out[13] = 0;
|
|
107
|
+
out[14] = depthOffset;
|
|
108
|
+
out[15] = 0;
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Writes into `out` the off-axis perspective projection whose near plane is the
|
|
113
|
+
* rectangle `[left, right] × [bottom, top]` at the distance `near` (tiles of a
|
|
114
|
+
* large image, stereo pairs, an AR view): the same as {@link mat4x4Perspective}
|
|
115
|
+
* for a symmetric rectangle. `far` may be `Infinity`. `out` is left untouched
|
|
116
|
+
* when it throws. Right for bounds up to about `1e307` (`right − left` and `top
|
|
117
|
+
* − bottom` must not overflow).
|
|
118
|
+
*
|
|
119
|
+
* @throws {RangeError} Unless every argument but `far` is finite, `left ≠
|
|
120
|
+
* right`, `bottom ≠ top`, `0 < near < far` (`far` may be infinite), the
|
|
121
|
+
* coefficients are representable (a scale that underflows to `0`, as `near =
|
|
122
|
+
* 5e-324` over bounds of `±1e100`, would project every point to the middle of
|
|
123
|
+
* the screen, and throws) and `depthRange` is one of the three.
|
|
124
|
+
*/
|
|
125
|
+
export function mat4x4Frustum(out, left, right, bottom, top, near, far, depthRange) {
|
|
126
|
+
if (!(Number.isFinite(left) &&
|
|
127
|
+
Number.isFinite(right) &&
|
|
128
|
+
Number.isFinite(bottom) &&
|
|
129
|
+
Number.isFinite(top) &&
|
|
130
|
+
left !== right &&
|
|
131
|
+
bottom !== top &&
|
|
132
|
+
near > 0 &&
|
|
133
|
+
far > near &&
|
|
134
|
+
Number.isFinite(near))) {
|
|
135
|
+
throw new RangeError("Invalid frustum.");
|
|
136
|
+
}
|
|
137
|
+
const width = right - left;
|
|
138
|
+
const height = top - bottom;
|
|
139
|
+
const scaleX = (2 * near) / width;
|
|
140
|
+
const scaleY = (2 * near) / height;
|
|
141
|
+
const shiftX = (right + left) / width;
|
|
142
|
+
const shiftY = (top + bottom) / height;
|
|
143
|
+
const depthScale = perspectiveDepthScale_(near, far, depthRange);
|
|
144
|
+
const depthOffset = perspectiveDepthOffset_(near, far, depthRange, depthScale);
|
|
145
|
+
if (!Number.isFinite(width) ||
|
|
146
|
+
!Number.isFinite(height) ||
|
|
147
|
+
!Number.isFinite(scaleX) ||
|
|
148
|
+
!Number.isFinite(scaleY) ||
|
|
149
|
+
scaleX === 0 ||
|
|
150
|
+
scaleY === 0 ||
|
|
151
|
+
!Number.isFinite(shiftX) ||
|
|
152
|
+
!Number.isFinite(shiftY) ||
|
|
153
|
+
!Number.isFinite(depthScale) ||
|
|
154
|
+
!Number.isFinite(depthOffset)) {
|
|
155
|
+
throw new RangeError("Frustum coefficients are not representable.");
|
|
156
|
+
}
|
|
157
|
+
out[0] = scaleX;
|
|
158
|
+
out[1] = 0;
|
|
159
|
+
out[2] = 0;
|
|
160
|
+
out[3] = 0;
|
|
161
|
+
out[4] = 0;
|
|
162
|
+
out[5] = scaleY;
|
|
163
|
+
out[6] = 0;
|
|
164
|
+
out[7] = 0;
|
|
165
|
+
out[8] = shiftX;
|
|
166
|
+
out[9] = shiftY;
|
|
167
|
+
out[10] = depthScale;
|
|
168
|
+
out[11] = -1;
|
|
169
|
+
out[12] = 0;
|
|
170
|
+
out[13] = 0;
|
|
171
|
+
out[14] = depthOffset;
|
|
172
|
+
out[15] = 0;
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Writes into `out` the orthographic projection of the box `[left, right] ×
|
|
177
|
+
* [bottom, top] × [−near, −far]` of a right-handed camera space (forward is −Z)
|
|
178
|
+
* to clip space, the near plane at the first depth of `depthRange` and the far
|
|
179
|
+
* plane at the second. `near` may exceed `far` (a flipped depth), and either
|
|
180
|
+
* may be negative (a box that surrounds the camera). `far` must be finite: an
|
|
181
|
+
* orthographic depth has no limit at infinity. `out` is left untouched when it
|
|
182
|
+
* throws. Right for bounds up to about `1e307` (`right − left`, `top − bottom`
|
|
183
|
+
* and `far − near` must not overflow).
|
|
184
|
+
*
|
|
185
|
+
* @throws {RangeError} Unless every argument is finite (`far` included), `left
|
|
186
|
+
* ≠ right`, `bottom ≠ top`, `near ≠ far`, the coefficients are representable
|
|
187
|
+
* and `depthRange` is one of the three.
|
|
188
|
+
*/
|
|
189
|
+
export function mat4x4Orthographic(out, left, right, bottom, top, near, far, depthRange) {
|
|
190
|
+
if (!(Number.isFinite(left) &&
|
|
191
|
+
Number.isFinite(right) &&
|
|
192
|
+
Number.isFinite(bottom) &&
|
|
193
|
+
Number.isFinite(top) &&
|
|
194
|
+
Number.isFinite(near) &&
|
|
195
|
+
Number.isFinite(far) &&
|
|
196
|
+
left !== right &&
|
|
197
|
+
bottom !== top &&
|
|
198
|
+
near !== far)) {
|
|
199
|
+
throw new RangeError("Invalid orthographic box.");
|
|
200
|
+
}
|
|
201
|
+
const width = right - left;
|
|
202
|
+
const height = top - bottom;
|
|
203
|
+
const depth = far - near;
|
|
204
|
+
let depthScale;
|
|
205
|
+
let depthOffset;
|
|
206
|
+
switch (depthRange) {
|
|
207
|
+
case "negative-one-to-one":
|
|
208
|
+
depthScale = -2 / depth;
|
|
209
|
+
depthOffset = -(far + near) / depth;
|
|
210
|
+
break;
|
|
211
|
+
case "zero-to-one":
|
|
212
|
+
depthScale = 1 / -depth;
|
|
213
|
+
depthOffset = near / -depth;
|
|
214
|
+
break;
|
|
215
|
+
case "one-to-zero":
|
|
216
|
+
depthScale = 1 / depth;
|
|
217
|
+
depthOffset = far / depth;
|
|
218
|
+
break;
|
|
219
|
+
default:
|
|
220
|
+
throw new RangeError(`Unknown depth range: ${describeValue(depthRange)}.`);
|
|
221
|
+
}
|
|
222
|
+
const scaleX = 2 / width;
|
|
223
|
+
const scaleY = 2 / height;
|
|
224
|
+
const shiftX = -(right + left) / width;
|
|
225
|
+
const shiftY = -(top + bottom) / height;
|
|
226
|
+
if (!Number.isFinite(width) ||
|
|
227
|
+
!Number.isFinite(height) ||
|
|
228
|
+
!Number.isFinite(depth) ||
|
|
229
|
+
!Number.isFinite(scaleX) ||
|
|
230
|
+
!Number.isFinite(scaleY) ||
|
|
231
|
+
!Number.isFinite(shiftX) ||
|
|
232
|
+
!Number.isFinite(shiftY) ||
|
|
233
|
+
!Number.isFinite(depthScale) ||
|
|
234
|
+
!Number.isFinite(depthOffset)) {
|
|
235
|
+
throw new RangeError("Orthographic coefficients are not representable.");
|
|
236
|
+
}
|
|
237
|
+
out[0] = scaleX;
|
|
238
|
+
out[1] = 0;
|
|
239
|
+
out[2] = 0;
|
|
240
|
+
out[3] = 0;
|
|
241
|
+
out[4] = 0;
|
|
242
|
+
out[5] = scaleY;
|
|
243
|
+
out[6] = 0;
|
|
244
|
+
out[7] = 0;
|
|
245
|
+
out[8] = 0;
|
|
246
|
+
out[9] = 0;
|
|
247
|
+
out[10] = depthScale;
|
|
248
|
+
out[11] = 0;
|
|
249
|
+
out[12] = shiftX;
|
|
250
|
+
out[13] = shiftY;
|
|
251
|
+
out[14] = depthOffset;
|
|
252
|
+
out[15] = 1;
|
|
253
|
+
return out;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Normalises `axis` in place at any magnitude, once it is known to have a
|
|
257
|
+
* direction.
|
|
258
|
+
*
|
|
259
|
+
* @throws {RangeError} When `axis` is zero, infinite or not a number.
|
|
260
|
+
*/
|
|
261
|
+
function unitViewAxis_(axis) {
|
|
262
|
+
const largest = Math.max(Math.abs(axis[0]), Math.abs(axis[1]), Math.abs(axis[2]));
|
|
263
|
+
if (!(largest > 0) || !Number.isFinite(largest)) {
|
|
264
|
+
throw new RangeError("View axes must be finite and non-degenerate.");
|
|
265
|
+
}
|
|
266
|
+
vec3NormalizeScaled(axis, axis);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Fills the camera axes `BACK_`, `RIGHT_` and `VERTICAL_` for a camera at `eye`
|
|
270
|
+
* looking at `target`, `up` setting the roll: `back` from `target` to `eye`,
|
|
271
|
+
* `right` perpendicular to `up` and `back`, `vertical` completing the
|
|
272
|
+
* right-handed basis (`right × vertical = back`). Every axis is normalised in
|
|
273
|
+
* the scaled form, so eye–target distances of `1e200` or `1e−200` neither
|
|
274
|
+
* overflow nor underflow, and the basis is orthonormal to the last bit: the
|
|
275
|
+
* `right` axis, a cross product of two rounded unit vectors, is stripped of the
|
|
276
|
+
* component along `back` that the rounding leaves (it grows as `ε / sin θ` for
|
|
277
|
+
* an angle θ between `up` and the view direction) before `vertical` is built.
|
|
278
|
+
*
|
|
279
|
+
* @throws {RangeError} When eye and target coincide or are not finite, or `up`
|
|
280
|
+
* is zero, not finite or parallel to the view direction to within
|
|
281
|
+
* {@link PARALLEL_MIN_SINE_}.
|
|
282
|
+
*/
|
|
283
|
+
function cameraAxes_(eye, target, up) {
|
|
284
|
+
vec3Subtract(BACK_, eye, target);
|
|
285
|
+
unitViewAxis_(BACK_);
|
|
286
|
+
vec3Copy(UP_, up);
|
|
287
|
+
unitViewAxis_(UP_);
|
|
288
|
+
vec3Cross(RIGHT_, UP_, BACK_);
|
|
289
|
+
if (!(vec3Length(RIGHT_) > PARALLEL_MIN_SINE_)) {
|
|
290
|
+
throw new RangeError("View axes must be finite and non-degenerate.");
|
|
291
|
+
}
|
|
292
|
+
unitViewAxis_(RIGHT_);
|
|
293
|
+
vec3AddScaled(RIGHT_, RIGHT_, BACK_, -vec3Dot(RIGHT_, BACK_));
|
|
294
|
+
vec3NormalizeScaled(RIGHT_, RIGHT_);
|
|
295
|
+
vec3Cross(VERTICAL_, BACK_, RIGHT_);
|
|
296
|
+
vec3NormalizeScaled(VERTICAL_, VERTICAL_);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* The clip depth `d = scale · t + offset` of each range, `t` running from 0 at
|
|
300
|
+
* the near plane to 1 at the far plane; all four numbers are small powers of
|
|
301
|
+
* two or their sums, so every product below is exact.
|
|
302
|
+
*/
|
|
303
|
+
const DEPTH_SCALE_ = {
|
|
304
|
+
"zero-to-one": 1,
|
|
305
|
+
"negative-one-to-one": 2,
|
|
306
|
+
"one-to-zero": -1,
|
|
307
|
+
};
|
|
308
|
+
const DEPTH_OFFSET_ = {
|
|
309
|
+
"zero-to-one": 0,
|
|
310
|
+
"negative-one-to-one": -1,
|
|
311
|
+
"one-to-zero": 1,
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Writes into `out` the projection `matrix` re-expressed for another depth
|
|
315
|
+
* range: the same `x`, `y` and `w` rows, and a depth row that maps the near and
|
|
316
|
+
* far planes of `from` to those of `to` (`z' = a·z + b·w`, with `a` and `b` in
|
|
317
|
+
* {−1, −½, ½, 1, 2} and their offsets). A GL-style projection
|
|
318
|
+
* (`"negative-one-to-one"`, as gl-matrix's `perspectiveNO` or three.js on WebGL
|
|
319
|
+
* give) then draws under WebGPU's `"zero-to-one"` clip depth, and a forward one
|
|
320
|
+
* turns reversed. Converting there and back returns the matrix to within one
|
|
321
|
+
* rounding of each depth-row element; the same range copies it. `out` may be
|
|
322
|
+
* `matrix`.
|
|
323
|
+
*
|
|
324
|
+
* @throws {RangeError} When `from` or `to` is not one of the three ranges;
|
|
325
|
+
* `out` is then left untouched.
|
|
326
|
+
*/
|
|
327
|
+
export function mat4x4ConvertDepthRange(out, matrix, from, to) {
|
|
328
|
+
if (!Object.hasOwn(DEPTH_SCALE_, from) || !Object.hasOwn(DEPTH_SCALE_, to)) {
|
|
329
|
+
throw new RangeError(`Unknown depth range: ${describeValue(Object.hasOwn(DEPTH_SCALE_, from) ? to : from)}.`);
|
|
330
|
+
}
|
|
331
|
+
// d' = toScale · (d − fromOffset) / fromScale + toOffset, applied to z / w
|
|
332
|
+
const zScale = DEPTH_SCALE_[to] / DEPTH_SCALE_[from];
|
|
333
|
+
const wScale = DEPTH_OFFSET_[to] - zScale * DEPTH_OFFSET_[from];
|
|
334
|
+
for (let column = 0; column < 4; column++) {
|
|
335
|
+
const at = column * 4;
|
|
336
|
+
const x = matrix[at];
|
|
337
|
+
const y = matrix[at + 1];
|
|
338
|
+
const z = matrix[at + 2];
|
|
339
|
+
const w = matrix[at + 3];
|
|
340
|
+
out[at] = x;
|
|
341
|
+
out[at + 1] = y;
|
|
342
|
+
out[at + 2] = zScale * z + wScale * w;
|
|
343
|
+
out[at + 3] = w;
|
|
344
|
+
}
|
|
345
|
+
return out;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Writes into `out` the view matrix of a camera at `eye` looking at `target`:
|
|
349
|
+
* world to camera space, right-handed, forward along −Z, `up` setting the roll
|
|
350
|
+
* (it need not be unit length). The axes are normalised in the scaled form
|
|
351
|
+
* (S12), so huge or tiny eye–target distances neither overflow nor underflow,
|
|
352
|
+
* and the rotation is orthonormal to the last bit whatever the angle between
|
|
353
|
+
* `up` and the view direction. `out` is left untouched when it throws.
|
|
354
|
+
*
|
|
355
|
+
* Right for coordinates up to about `1e307`: a larger one overflows `eye −
|
|
356
|
+
* target` or the translation (the dot products of the axes with `eye`), and
|
|
357
|
+
* throws.
|
|
358
|
+
*
|
|
359
|
+
* @throws {RangeError} When eye and target coincide or are not finite, `up` is
|
|
360
|
+
* zero, not finite or parallel to the view direction (within `3.6e-15` rad,
|
|
361
|
+
* where the cross product that fixes the roll is rounding noise), or a result
|
|
362
|
+
* is not finite (an eye or target beyond about `1e307` from the origin).
|
|
363
|
+
*/
|
|
364
|
+
export function mat4x4LookAt(out, eye, target, up) {
|
|
365
|
+
cameraAxes_(eye, target, up);
|
|
366
|
+
const rightOffset = -vec3Dot(RIGHT_, eye);
|
|
367
|
+
const verticalOffset = -vec3Dot(VERTICAL_, eye);
|
|
368
|
+
const backOffset = -vec3Dot(BACK_, eye);
|
|
369
|
+
if (!Number.isFinite(rightOffset) ||
|
|
370
|
+
!Number.isFinite(verticalOffset) ||
|
|
371
|
+
!Number.isFinite(backOffset)) {
|
|
372
|
+
throw new RangeError("View translation must be finite.");
|
|
373
|
+
}
|
|
374
|
+
out[0] = RIGHT_[0];
|
|
375
|
+
out[1] = VERTICAL_[0];
|
|
376
|
+
out[2] = BACK_[0];
|
|
377
|
+
out[3] = 0;
|
|
378
|
+
out[4] = RIGHT_[1];
|
|
379
|
+
out[5] = VERTICAL_[1];
|
|
380
|
+
out[6] = BACK_[1];
|
|
381
|
+
out[7] = 0;
|
|
382
|
+
out[8] = RIGHT_[2];
|
|
383
|
+
out[9] = VERTICAL_[2];
|
|
384
|
+
out[10] = BACK_[2];
|
|
385
|
+
out[11] = 0;
|
|
386
|
+
out[12] = rightOffset;
|
|
387
|
+
out[13] = verticalOffset;
|
|
388
|
+
out[14] = backOffset;
|
|
389
|
+
out[15] = 1;
|
|
390
|
+
return out;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Writes into `out` the world transform of a camera, or of any object that
|
|
394
|
+
* looks at something, placed at `eye` with its −Z axis toward `target` and `up`
|
|
395
|
+
* setting the roll: the affine inverse of {@link mat4x4LookAt}, to the rounding
|
|
396
|
+
* of a product (its rotation is the transpose of the view's, bit for bit).
|
|
397
|
+
* `out` is left untouched when it throws. Right for coordinates up to about
|
|
398
|
+
* `1e307`.
|
|
399
|
+
*
|
|
400
|
+
* @throws {RangeError} As {@link mat4x4LookAt}.
|
|
401
|
+
*/
|
|
402
|
+
export function affine3TargetTo(out, eye, target, up) {
|
|
403
|
+
cameraAxes_(eye, target, up);
|
|
404
|
+
out[0] = RIGHT_[0];
|
|
405
|
+
out[1] = RIGHT_[1];
|
|
406
|
+
out[2] = RIGHT_[2];
|
|
407
|
+
out[3] = VERTICAL_[0];
|
|
408
|
+
out[4] = VERTICAL_[1];
|
|
409
|
+
out[5] = VERTICAL_[2];
|
|
410
|
+
out[6] = BACK_[0];
|
|
411
|
+
out[7] = BACK_[1];
|
|
412
|
+
out[8] = BACK_[2];
|
|
413
|
+
out[9] = eye[0];
|
|
414
|
+
out[10] = eye[1];
|
|
415
|
+
out[11] = eye[2];
|
|
416
|
+
return out;
|
|
417
|
+
}
|
|
418
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,OAAO,EACN,aAAa,EACb,QAAQ,EACR,UAAU,EACV,OAAO,EACP,UAAU,EACV,mBAAmB,EACnB,YAAY,GACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAgC,SAAS,EAAE,MAAM,WAAW,CAAC;AAqBpE,gFAAgF;AAChF,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;AAC3B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;AAC5B,MAAM,SAAS,GAAG,UAAU,EAAE,CAAC;AAC/B,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;AAEz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AE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACjB,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACjB,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ReadonlyQuaternion, Quaternion } from "@ac-kit/math-complex";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a buffer for `count` quaternion elements: a zero-filled
|
|
4
|
+
* `Float64Array` of `count × 4` numbers, element `i` at `[i·4, i·4 + 4)`, a
|
|
5
|
+
* zero element being the all-zero quaternion (use {@link quaternionStore} with
|
|
6
|
+
* the identity to fill it with identities). Allocates.
|
|
7
|
+
*
|
|
8
|
+
* @throws {RangeError} When `count` is not a non-negative safe integer or
|
|
9
|
+
* `count × 4` is not a valid typed array length.
|
|
10
|
+
*/
|
|
11
|
+
export declare function quaternionArrayCreate(count: number): Float64Array<ArrayBuffer>;
|
|
12
|
+
/**
|
|
13
|
+
* Writes element `index` of `array`, the numbers at `[index·4, index·4 + 4)`,
|
|
14
|
+
* into `out`. Each component is written as `+array[i]`, so an index past the
|
|
15
|
+
* end of `array` gives `NaN`, never `undefined`: the quaternion stays clean
|
|
16
|
+
* whatever the caller does. Checking the index is the job of the checked
|
|
17
|
+
* layer.
|
|
18
|
+
*
|
|
19
|
+
* The quaternion is copied: it is never a view of `array`. O(1).
|
|
20
|
+
*/
|
|
21
|
+
export declare function quaternionLoad(out: Quaternion, array: Float64Array, index: number): Quaternion;
|
|
22
|
+
/**
|
|
23
|
+
* Writes `value` into `array` as element `index`, at `[index·4, index·4 + 4)`.
|
|
24
|
+
* An element past the end of `array` writes nothing, as a typed array drops an
|
|
25
|
+
* out-of-range write. O(1).
|
|
26
|
+
*/
|
|
27
|
+
export declare function quaternionStore(array: Float64Array, index: number, value: ReadonlyQuaternion): void;
|
|
28
|
+
/**
|
|
29
|
+
* Like {@link quaternionLoad} for interleaved data: element `index` starts at
|
|
30
|
+
* `offset + index·stride`, both counted in numbers, and its 4 components follow
|
|
31
|
+
* one another. An index past the end gives `NaN` components. O(1).
|
|
32
|
+
*/
|
|
33
|
+
export declare function quaternionLoadStrided(out: Quaternion, array: Float64Array, offset: number, stride: number, index: number): Quaternion;
|
|
34
|
+
/**
|
|
35
|
+
* Like {@link quaternionStore} for interleaved data: element `index` starts at
|
|
36
|
+
* `offset + index·stride`, both counted in numbers. A component past the end of
|
|
37
|
+
* `array` writes nothing. O(1).
|
|
38
|
+
*/
|
|
39
|
+
export declare function quaternionStoreStrided(array: Float64Array, offset: number, stride: number, index: number, value: ReadonlyQuaternion): void;
|
|
40
|
+
/**
|
|
41
|
+
* Whether every number of `array` is finite: the check for a buffer of
|
|
42
|
+
* quaternion elements read from untrusted data or about to be uploaded. The
|
|
43
|
+
* length is not required to be a multiple of 4 (see `assertFiniteBuffer` for
|
|
44
|
+
* that). O(n).
|
|
45
|
+
*/
|
|
46
|
+
export declare function quaternionArrayIsFinite(array: Float64Array): boolean;
|
|
47
|
+
//# sourceMappingURL=quaternion-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quaternion-array.d.ts","sourceRoot":"","sources":["../src/quaternion-array.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE3E;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,GACX,YAAY,CAAC,WAAW,CAAC,CAG3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC7B,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,GACX,UAAU,CAQZ;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,kBAAkB,GACvB,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,UAAU,CAQZ;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,kBAAkB,GACvB,IAAI,CAMN;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAOpE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Generated from scripts/templates/value-array.liquid by scripts/generate-componentwise.ts. Do not edit.
|
|
2
|
+
import { assertInteger } from "@ac-kit/core";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a buffer for `count` quaternion elements: a zero-filled
|
|
5
|
+
* `Float64Array` of `count × 4` numbers, element `i` at `[i·4, i·4 + 4)`, a
|
|
6
|
+
* zero element being the all-zero quaternion (use {@link quaternionStore} with
|
|
7
|
+
* the identity to fill it with identities). Allocates.
|
|
8
|
+
*
|
|
9
|
+
* @throws {RangeError} When `count` is not a non-negative safe integer or
|
|
10
|
+
* `count × 4` is not a valid typed array length.
|
|
11
|
+
*/
|
|
12
|
+
export function quaternionArrayCreate(count) {
|
|
13
|
+
assertInteger(count, "quaternionArrayCreate: count", 0);
|
|
14
|
+
return new Float64Array(count * 4);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Writes element `index` of `array`, the numbers at `[index·4, index·4 + 4)`,
|
|
18
|
+
* into `out`. Each component is written as `+array[i]`, so an index past the
|
|
19
|
+
* end of `array` gives `NaN`, never `undefined`: the quaternion stays clean
|
|
20
|
+
* whatever the caller does. Checking the index is the job of the checked
|
|
21
|
+
* layer.
|
|
22
|
+
*
|
|
23
|
+
* The quaternion is copied: it is never a view of `array`. O(1).
|
|
24
|
+
*/
|
|
25
|
+
export function quaternionLoad(out, array, index) {
|
|
26
|
+
const base = index * 4;
|
|
27
|
+
// The `!` is for the compiler: past the end `+undefined` is `NaN`.
|
|
28
|
+
out[0] = +array[base];
|
|
29
|
+
out[1] = +array[base + 1];
|
|
30
|
+
out[2] = +array[base + 2];
|
|
31
|
+
out[3] = +array[base + 3];
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Writes `value` into `array` as element `index`, at `[index·4, index·4 + 4)`.
|
|
36
|
+
* An element past the end of `array` writes nothing, as a typed array drops an
|
|
37
|
+
* out-of-range write. O(1).
|
|
38
|
+
*/
|
|
39
|
+
export function quaternionStore(array, index, value) {
|
|
40
|
+
const base = index * 4;
|
|
41
|
+
array[base] = value[0];
|
|
42
|
+
array[base + 1] = value[1];
|
|
43
|
+
array[base + 2] = value[2];
|
|
44
|
+
array[base + 3] = value[3];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Like {@link quaternionLoad} for interleaved data: element `index` starts at
|
|
48
|
+
* `offset + index·stride`, both counted in numbers, and its 4 components follow
|
|
49
|
+
* one another. An index past the end gives `NaN` components. O(1).
|
|
50
|
+
*/
|
|
51
|
+
export function quaternionLoadStrided(out, array, offset, stride, index) {
|
|
52
|
+
const base = offset + index * stride;
|
|
53
|
+
// The `!` is for the compiler: past the end `+undefined` is `NaN`.
|
|
54
|
+
out[0] = +array[base];
|
|
55
|
+
out[1] = +array[base + 1];
|
|
56
|
+
out[2] = +array[base + 2];
|
|
57
|
+
out[3] = +array[base + 3];
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Like {@link quaternionStore} for interleaved data: element `index` starts at
|
|
62
|
+
* `offset + index·stride`, both counted in numbers. A component past the end of
|
|
63
|
+
* `array` writes nothing. O(1).
|
|
64
|
+
*/
|
|
65
|
+
export function quaternionStoreStrided(array, offset, stride, index, value) {
|
|
66
|
+
const base = offset + index * stride;
|
|
67
|
+
array[base] = value[0];
|
|
68
|
+
array[base + 1] = value[1];
|
|
69
|
+
array[base + 2] = value[2];
|
|
70
|
+
array[base + 3] = value[3];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether every number of `array` is finite: the check for a buffer of
|
|
74
|
+
* quaternion elements read from untrusted data or about to be uploaded. The
|
|
75
|
+
* length is not required to be a multiple of 4 (see `assertFiniteBuffer` for
|
|
76
|
+
* that). O(n).
|
|
77
|
+
*/
|
|
78
|
+
export function quaternionArrayIsFinite(array) {
|
|
79
|
+
for (let index = 0; index < array.length; index++) {
|
|
80
|
+
if (!Number.isFinite(array[index])) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=quaternion-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quaternion-array.js","sourceRoot":"","sources":["../src/quaternion-array.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAEzG,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACpC,KAAa;IAEb,aAAa,CAAC,KAAK,EAAE,8BAA8B,EAAE,CAAC,CAAC,CAAC;IACxD,OAAO,IAAI,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC7B,GAAe,EACf,KAAmB,EACnB,KAAa;IAEb,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;IACvB,mEAAmE;IACnE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC;IACvB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,C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