@ac-kit/graphics-view 0.0.0-stage → 0.1.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/LICENSE +28 -0
  3. package/README.md +206 -2
  4. package/dist/camera/camera3.d.ts +17 -0
  5. package/dist/camera/camera3.d.ts.map +1 -0
  6. package/dist/camera/camera3.js +2 -0
  7. package/dist/camera/camera3.js.map +1 -0
  8. package/dist/camera/look-around-camera.d.ts +110 -0
  9. package/dist/camera/look-around-camera.d.ts.map +1 -0
  10. package/dist/camera/look-around-camera.js +220 -0
  11. package/dist/camera/look-around-camera.js.map +1 -0
  12. package/dist/camera/orbit-camera.d.ts +102 -0
  13. package/dist/camera/orbit-camera.d.ts.map +1 -0
  14. package/dist/camera/orbit-camera.js +252 -0
  15. package/dist/camera/orbit-camera.js.map +1 -0
  16. package/dist/dom/_inertia-input.d.ts +35 -0
  17. package/dist/dom/_inertia-input.d.ts.map +1 -0
  18. package/dist/dom/_inertia-input.js +121 -0
  19. package/dist/dom/_inertia-input.js.map +1 -0
  20. package/dist/dom/bind-look-around-input.d.ts +54 -0
  21. package/dist/dom/bind-look-around-input.d.ts.map +1 -0
  22. package/dist/dom/bind-look-around-input.js +111 -0
  23. package/dist/dom/bind-look-around-input.js.map +1 -0
  24. package/dist/dom/bind-orbit-input.d.ts +47 -0
  25. package/dist/dom/bind-orbit-input.d.ts.map +1 -0
  26. package/dist/dom/bind-orbit-input.js +118 -0
  27. package/dist/dom/bind-orbit-input.js.map +1 -0
  28. package/dist/dom/bind-view2-input.d.ts +60 -0
  29. package/dist/dom/bind-view2-input.d.ts.map +1 -0
  30. package/dist/dom/bind-view2-input.js +164 -0
  31. package/dist/dom/bind-view2-input.js.map +1 -0
  32. package/dist/dom/index.d.ts +4 -0
  33. package/dist/dom/index.d.ts.map +1 -0
  34. package/dist/dom/index.js +4 -0
  35. package/dist/dom/index.js.map +1 -0
  36. package/dist/index.d.ts +8 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +8 -0
  39. package/dist/index.js.map +1 -0
  40. package/dist/view2/interpolate-view2-frame.d.ts +13 -0
  41. package/dist/view2/interpolate-view2-frame.d.ts.map +1 -0
  42. package/dist/view2/interpolate-view2-frame.js +30 -0
  43. package/dist/view2/interpolate-view2-frame.js.map +1 -0
  44. package/dist/view2/view2.d.ts +195 -0
  45. package/dist/view2/view2.d.ts.map +1 -0
  46. package/dist/view2/view2.js +445 -0
  47. package/dist/view2/view2.js.map +1 -0
  48. package/dist/view3/_projection.d.ts +20 -0
  49. package/dist/view3/_projection.d.ts.map +1 -0
  50. package/dist/view3/_projection.js +43 -0
  51. package/dist/view3/_projection.js.map +1 -0
  52. package/dist/view3/choose-depth-range.d.ts +25 -0
  53. package/dist/view3/choose-depth-range.d.ts.map +1 -0
  54. package/dist/view3/choose-depth-range.js +22 -0
  55. package/dist/view3/choose-depth-range.js.map +1 -0
  56. package/dist/view3/view3.d.ts +145 -0
  57. package/dist/view3/view3.d.ts.map +1 -0
  58. package/dist/view3/view3.js +306 -0
  59. package/dist/view3/view3.js.map +1 -0
  60. package/package.json +76 -3
@@ -0,0 +1,220 @@
1
+ import { assertFinite, assertPositive, clamp, } from "@ac-kit/core";
2
+ import { horizontalCoordsCreate, horizontalFromVec3Enu, vec3EnuFromHorizontal, } from "@ac-kit/math-geometry";
3
+ import { mat3x3SetRows, mat4x4ViewFromBasis, vec3Copy, vec3Create, vec3IsFinite, vec3Negate, vec3Set, } from "@ac-kit/math-linear";
4
+ import { angleWrapRad } from "@ac-kit/math-scalar";
5
+ const HALF_PI_ = Math.PI / 2;
6
+ const DEFAULT_FOV_LIMITS_ = [
7
+ Math.PI / 180,
8
+ (2 * Math.PI) / 3,
9
+ ];
10
+ const FORWARD_ = vec3Create();
11
+ const RIGHT_ = vec3Create();
12
+ const UP_ = vec3Create();
13
+ const BACK_ = vec3Create();
14
+ const HORIZONTAL_ = horizontalCoordsCreate();
15
+ /**
16
+ * Writes the east-north-up vector `(east, north, up)` as a world vector: as it
17
+ * is for Z up, `(east, up, −north)` for Y up.
18
+ */
19
+ function setWorld_(out, up, east, north, upward) {
20
+ if (up === "z") {
21
+ vec3Set(out, east, north, upward);
22
+ }
23
+ else {
24
+ vec3Set(out, east, upward, -north);
25
+ }
26
+ }
27
+ /**
28
+ * Looking around from a fixed eye: a sky dome, a first-person view, an
29
+ * azimuthal sky chart. Yaw and pitch, no roll; zoom changes the field of view.
30
+ * The axes are built from the angles, so straight up and straight down are
31
+ * exact (the yaw still turns the view there) and the camera's up never flips.
32
+ *
33
+ * @example
34
+ * const camera = new LookAroundCamera({ yaw: Math.PI / 2, pitch: 0.2 });
35
+ * camera.rotate(0.01, 0);
36
+ * camera.zoom(1.5);
37
+ * const view = camera.getView(mat4x4Create());
38
+ */
39
+ export class LookAroundCamera {
40
+ up_;
41
+ eye_ = vec3Create();
42
+ minPitch_;
43
+ maxPitch_;
44
+ minFov_;
45
+ maxFov_;
46
+ yaw_;
47
+ pitch_;
48
+ fovY_;
49
+ version_ = 0;
50
+ /**
51
+ * @throws {RangeError} For limits out of order or out of range (pitch within
52
+ * [−π/2, π/2], field of view within (0, π)), or a non-finite eye, yaw,
53
+ * pitch or field of view.
54
+ */
55
+ constructor(options = {}) {
56
+ this.up_ = options.up ?? "z";
57
+ if (this.up_ !== "y" && this.up_ !== "z") {
58
+ throw new RangeError('LookAroundCamera: up must be "y" or "z".');
59
+ }
60
+ const eye = options.eye ?? vec3Create();
61
+ if (!vec3IsFinite(eye)) {
62
+ throw new RangeError("LookAroundCamera: the eye must be finite.");
63
+ }
64
+ vec3Copy(this.eye_, eye);
65
+ const [minPitch, maxPitch] = options.pitchLimits ?? [-HALF_PI_, HALF_PI_];
66
+ if (!(minPitch >= -HALF_PI_ && maxPitch >= minPitch && maxPitch <= HALF_PI_)) {
67
+ throw new RangeError(`LookAroundCamera: pitchLimits must be [min, max] within [−π/2, π/2], not [${minPitch}, ${maxPitch}].`);
68
+ }
69
+ const [minFov, maxFov] = options.fovLimits ?? DEFAULT_FOV_LIMITS_;
70
+ if (!(minFov > 0 && maxFov >= minFov && maxFov < Math.PI)) {
71
+ throw new RangeError(`LookAroundCamera: fovLimits must be [min, max] within (0, π), not [${minFov}, ${maxFov}].`);
72
+ }
73
+ this.minPitch_ = minPitch;
74
+ this.maxPitch_ = maxPitch;
75
+ this.minFov_ = minFov;
76
+ this.maxFov_ = maxFov;
77
+ const yaw = options.yaw ?? 0;
78
+ const pitch = options.pitch ?? 0;
79
+ const fovY = options.fovY ?? Math.PI / 3;
80
+ if (!Number.isFinite(yaw) ||
81
+ !Number.isFinite(pitch) ||
82
+ !Number.isFinite(fovY)) {
83
+ throw new RangeError("LookAroundCamera: yaw, pitch and fovY must be finite.");
84
+ }
85
+ this.yaw_ = angleWrapRad(yaw);
86
+ this.pitch_ = clamp(pitch, minPitch, maxPitch);
87
+ this.fovY_ = clamp(fovY, minFov, maxFov);
88
+ }
89
+ /** Increases on each change of the orientation or the field of view. */
90
+ get version() {
91
+ return this.version_;
92
+ }
93
+ get fovY() {
94
+ return this.fovY_;
95
+ }
96
+ /** Radians in [0, 2π). */
97
+ get yaw() {
98
+ return this.yaw_;
99
+ }
100
+ get pitch() {
101
+ return this.pitch_;
102
+ }
103
+ getEye(out) {
104
+ return vec3Copy(out, this.eye_);
105
+ }
106
+ /** World → camera: right-handed, looking down −Z, the up axis up. */
107
+ getView(out) {
108
+ this.axes_();
109
+ return mat4x4ViewFromBasis(out, RIGHT_, UP_, BACK_, this.eye_);
110
+ }
111
+ /** Unit view direction. */
112
+ getDirection(out) {
113
+ this.axes_();
114
+ return vec3Copy(out, FORWARD_);
115
+ }
116
+ /**
117
+ * Adds radians; the yaw is wrapped to [0, 2π) and the pitch clamped.
118
+ *
119
+ * @throws {RangeError} For non-finite input.
120
+ */
121
+ rotate(yaw, pitch) {
122
+ assertFinite(yaw, "yaw");
123
+ assertFinite(pitch, "pitch");
124
+ this.commit_(angleWrapRad(this.yaw_ + angleWrapRad(yaw)), clamp(this.pitch_ + pitch, this.minPitch_, this.maxPitch_), this.fovY_);
125
+ }
126
+ /** @throws {RangeError} For a non-finite yaw or pitch. */
127
+ setOrientation(yaw, pitch) {
128
+ assertFinite(yaw, "yaw");
129
+ assertFinite(pitch, "pitch");
130
+ this.commit_(angleWrapRad(yaw), clamp(pitch, this.minPitch_, this.maxPitch_), this.fovY_);
131
+ }
132
+ /**
133
+ * Turns toward `direction` (need not be unit, at any magnitude).
134
+ *
135
+ * @throws {RangeError} For a zero or non-finite direction.
136
+ */
137
+ lookToward(direction) {
138
+ const largest = Math.max(Math.abs(direction[0]), Math.abs(direction[1]), Math.abs(direction[2]));
139
+ if (!(largest > 0 && Number.isFinite(largest))) {
140
+ throw new RangeError("LookAroundCamera: the direction must be finite and not zero.");
141
+ }
142
+ const x = direction[0] / largest;
143
+ const y = direction[1] / largest;
144
+ const z = direction[2] / largest;
145
+ if (this.up_ === "z") {
146
+ vec3Set(FORWARD_, x, y, z);
147
+ }
148
+ else {
149
+ vec3Set(FORWARD_, x, -z, y);
150
+ }
151
+ horizontalFromVec3Enu(HORIZONTAL_, FORWARD_);
152
+ this.commit_(HORIZONTAL_[0], clamp(HORIZONTAL_[1], this.minPitch_, this.maxPitch_), this.fovY_);
153
+ }
154
+ /**
155
+ * Divides the field of view by `factor` (> 1 zooms in), clamped.
156
+ *
157
+ * @throws {RangeError} Unless positive and finite.
158
+ */
159
+ zoom(factor) {
160
+ assertPositive(factor, "zoom factor");
161
+ this.commit_(this.yaw_, this.pitch_, clamp(this.fovY_ / factor, this.minFov_, this.maxFov_));
162
+ }
163
+ /**
164
+ * The rotation `math-map-projection`'s azimuthal kernels take: the view
165
+ * direction to +X, the camera's left to +Y and up to +Z. A sky seen from
166
+ * inside is then mirrored in x on screen (`DrawSphereProjection.mirror`).
167
+ */
168
+ getProjectionRotation(out) {
169
+ this.axes_();
170
+ vec3Negate(RIGHT_, RIGHT_);
171
+ return mat3x3SetRows(out, FORWARD_[0], FORWARD_[1], FORWARD_[2], RIGHT_[0], RIGHT_[1], RIGHT_[2], UP_[0], UP_[1], UP_[2]);
172
+ }
173
+ /**
174
+ * Screen pixels per projection-plane unit so that the field of view spans
175
+ * `viewportHeight` through a projection whose plane distance from the centre
176
+ * at angular distance `angle` is `radius(angle)` — one of
177
+ * math-map-projection's `…Radius` functions (`stereographicRadius`), or
178
+ * `Math.tan` for a perspective (gnomonic) view: `(viewportHeight / 2) /
179
+ * radius(fovY / 2)`. Taking the function, not a projection name, keeps this
180
+ * package free of math-map-projection. O(1).
181
+ *
182
+ * @throws {RangeError} When `viewportHeight` is not positive and finite, or
183
+ * `radius(fovY / 2)` is not finite and positive (half the field at or
184
+ * beyond the projection's domain).
185
+ */
186
+ projectionScale(radius, viewportHeight) {
187
+ const planeRadius = radius(this.fovY_ / 2);
188
+ if (!(planeRadius > 0 && Number.isFinite(planeRadius))) {
189
+ throw new RangeError(`LookAroundCamera: the projection's radius at half the field of view (${this.fovY_ / 2}) is ${planeRadius}, not finite and positive.`);
190
+ }
191
+ if (!(viewportHeight > 0 && Number.isFinite(viewportHeight))) {
192
+ throw new RangeError(`LookAroundCamera: the viewport height must be positive and finite, not ${viewportHeight}.`);
193
+ }
194
+ return viewportHeight / 2 / planeRadius;
195
+ }
196
+ /** Writes the forward, right, up and back axes in the world frame. */
197
+ axes_() {
198
+ const sinYaw = Math.sin(this.yaw_);
199
+ const cosYaw = Math.cos(this.yaw_);
200
+ const sinPitch = Math.sin(this.pitch_);
201
+ const cosPitch = Math.cos(this.pitch_);
202
+ HORIZONTAL_[0] = this.yaw_;
203
+ HORIZONTAL_[1] = this.pitch_;
204
+ HORIZONTAL_[2] = 1;
205
+ vec3EnuFromHorizontal(BACK_, HORIZONTAL_);
206
+ setWorld_(FORWARD_, this.up_, BACK_[0], BACK_[1], BACK_[2]);
207
+ setWorld_(RIGHT_, this.up_, cosYaw, -sinYaw, 0);
208
+ setWorld_(UP_, this.up_, -sinYaw * sinPitch, -cosYaw * sinPitch, cosPitch);
209
+ vec3Negate(BACK_, FORWARD_);
210
+ }
211
+ commit_(yaw, pitch, fovY) {
212
+ if (yaw !== this.yaw_ || pitch !== this.pitch_ || fovY !== this.fovY_) {
213
+ this.yaw_ = yaw;
214
+ this.pitch_ = pitch;
215
+ this.fovY_ = fovY;
216
+ this.version_ += 1;
217
+ }
218
+ }
219
+ }
220
+ //# sourceMappingURL=look-around-camera.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"look-around-camera.js","sourceRoot":"","sources":["../../src/camera/look-around-camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EACZ,cAAc,EACd,KAAK,GACL,MAAM,cAAc,CAAC;AACtB,OAAO,EAEN,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAKN,aAAa,EACb,mBAAmB,EACnB,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,UAAU,EACV,OAAO,GACP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA2BnD,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7B,MAAM,mBAAmB,GAA8B;IACtD,IAAI,CAAC,EAAE,GAAG,GAAG;IACb,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC;CACjB,CAAC;AAEF,MAAM,QAAQ,GAAG,UAAU,EAAE,CAAC;AAC9B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;AAC5B,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;AACzB,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;AAC3B,MAAM,WAAW,GAAqB,sBAAsB,EAAE,CAAC;AAE/D;;;GAGG;AACH,SAAS,SAAS,CACjB,GAAS,EACT,EAAY,EACZ,IAAY,EACZ,KAAa,EACb,MAAc;I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,KAAa,EAAE,IAAY;QACvD,IAAI,GAAG,KAAK,IAAI,CAAC,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;YACvE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;YAChB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACpB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACpB,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,102 @@
1
+ import { type ReadonlySphere3 } from "@ac-kit/math-geometry";
2
+ import { type Mat4x4, type ReadonlyVec3, type Vec3 } from "@ac-kit/math-linear";
3
+ import type { Lens3 } from "../view3/view3.js";
4
+ import type { Camera3, CameraUp } from "./camera3.js";
5
+ export type OrbitCameraOptions = {
6
+ readonly target: ReadonlyVec3;
7
+ readonly eye: ReadonlyVec3;
8
+ /** Default `"y"` (heliotrope); `"z"` for charts and geography. */
9
+ readonly up?: CameraUp;
10
+ readonly distance: readonly [min: number, max: number];
11
+ /** Radians from the up axis, within (0, π). */
12
+ readonly inclination: readonly [min: number, max: number];
13
+ /** The target is kept inside this sphere. Default: unbounded. */
14
+ readonly targetBounds?: ReadonlySphere3;
15
+ };
16
+ /**
17
+ * A camera orbiting a target: azimuth and inclination about the up axis, a
18
+ * distance, and a target that pans. Azimuth is wrapped to [0, 2π) (Y up:
19
+ * `atan2(z, x)`; Z up: from +X toward +Y); inclination and distance are
20
+ * clamped; frames outside the bounds are clamped, never refused.
21
+ *
22
+ * The inclination never reaches a pole (its bounds lie within (0, π)), where
23
+ * the azimuth would stop meaning anything; the view matrix is built from the
24
+ * angles, so it is exact however close to a pole the bounds allow, and the
25
+ * camera's up never flips.
26
+ *
27
+ * @example
28
+ * const camera = new OrbitCamera({
29
+ * target: [0, 0, 0],
30
+ * eye: [0, 5, 10],
31
+ * distance: [1, 50],
32
+ * inclination: [0.1, Math.PI / 2],
33
+ * });
34
+ * camera.rotate(0.1, -0.05);
35
+ * camera.dolly(0.9);
36
+ * const view = camera.getView(mat4x4Create());
37
+ */
38
+ export declare class OrbitCamera implements Camera3 {
39
+ private readonly up_;
40
+ private readonly minDistance_;
41
+ private readonly maxDistance_;
42
+ private readonly minInclination_;
43
+ private readonly maxInclination_;
44
+ private readonly targetCenter_;
45
+ private targetRadius_;
46
+ private readonly target_;
47
+ private azimuth_;
48
+ private inclination_;
49
+ private distance_;
50
+ private version_;
51
+ /**
52
+ * @throws {RangeError} For bounds out of order or outside their ranges (NaN
53
+ * included), a non-finite target or eye, an eye on the target, or an an
54
+ * inclination bound on a pole (0 or π).
55
+ */
56
+ constructor(options: OrbitCameraOptions);
57
+ /** Increases on each change of the frame. */
58
+ get version(): number;
59
+ get fovY(): undefined;
60
+ get up(): CameraUp;
61
+ get azimuth(): number;
62
+ get inclination(): number;
63
+ get distance(): number;
64
+ getTarget(out: Vec3): Vec3;
65
+ getEye(out: Vec3): Vec3;
66
+ /** World → camera: right-handed, looking down −Z, the up axis up. */
67
+ getView(out: Mat4x4): Mat4x4;
68
+ /**
69
+ * Reframes with the constructor's validation and clamping; nothing changes
70
+ * when it throws.
71
+ *
72
+ * @throws {RangeError} For a non-finite target or eye, or an eye on the
73
+ * target.
74
+ */
75
+ setFrame(target: ReadonlyVec3, eye: ReadonlyVec3): void;
76
+ /**
77
+ * Adds radians; the azimuth is wrapped and the inclination clamped.
78
+ *
79
+ * @throws {RangeError} For non-finite input.
80
+ */
81
+ rotate(azimuth: number, inclination: number): void;
82
+ /**
83
+ * Multiplies the distance (< 1 moves closer), clamped to the bounds.
84
+ *
85
+ * @throws {RangeError} Unless positive and finite.
86
+ */
87
+ dolly(factor: number): void;
88
+ /**
89
+ * Drags the scene by screen pixels (right and down positive) at the target's
90
+ * depth, for a viewport `viewportHeight` pixels high seen through `lens`; the
91
+ * target stays inside its bounds. A pan whose result is not finite (a huge
92
+ * delta over a tiny viewport) changes nothing.
93
+ *
94
+ * @throws {RangeError} For non-finite deltas, a non-positive or non-finite
95
+ * height, or a lens `View3` would refuse (a `"camera"` field of view
96
+ * included: an orbit camera has none).
97
+ */
98
+ pan(deltaX: number, deltaY: number, viewportHeight: number, lens: Lens3): void;
99
+ private boundTarget_;
100
+ private commit_;
101
+ }
102
+ //# sourceMappingURL=orbit-camera.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orbit-camera.d.ts","sourceRoot":"","sources":["../../src/camera/orbit-camera.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,eAAe,EAIpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,IAAI,EAUT,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAAG;IAChC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAC3B,kEAAkE;IAClE,QAAQ,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IACvD,+CAA+C;IAC/C,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC1D,iEAAiE;IACjE,QAAQ,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC;CACxC,CAAC;AA2CF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAY,YAAW,OAAO;IAC1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAW;IAC/B,OAAO,CAAC,QAAQ,CAAC,Y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GACT,IAAI,CAyBN;IAED,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,OAAO;CAqBf"}
@@ -0,0 +1,252 @@
1
+ import { assertFinite, assertPositive, clamp } from "@ac-kit/core";
2
+ import { sphericalCoordsCreate, sphericalFromVec3YUp, sphericalFromVec3ZUp, } from "@ac-kit/math-geometry";
3
+ import { mat4x4ViewFromBasis, vec3AddScaled, vec3Copy, vec3Create, vec3IsFinite, vec3LengthScaled, vec3NormalizeScaled, vec3Set, vec3Subtract, } from "@ac-kit/math-linear";
4
+ import { angleWrapRad } from "@ac-kit/math-scalar";
5
+ import { lensWorldUnitsPerPixel_ } from "../view3/_projection.js";
6
+ const RIGHT_ = vec3Create();
7
+ const VERTICAL_ = vec3Create();
8
+ const BACK_ = vec3Create();
9
+ const OFFSET_ = vec3Create();
10
+ const NEXT_TARGET_ = vec3Create();
11
+ const EYE_ = vec3Create();
12
+ const SPHERICAL_ = sphericalCoordsCreate();
13
+ /**
14
+ * Writes the camera's axes for an azimuth and an inclination, exact at every
15
+ * inclination (a pole included): the camera's right, its up (always on the up
16
+ * axis's side) and the unit vector from the target to the eye.
17
+ */
18
+ function axes_(up, azimuth, inclination) {
19
+ const sinAzimuth = Math.sin(azimuth);
20
+ const cosAzimuth = Math.cos(azimuth);
21
+ const sinInclination = Math.sin(inclination);
22
+ const cosInclination = Math.cos(inclination);
23
+ if (up === "y") {
24
+ BACK_[0] = sinInclination * cosAzimuth;
25
+ BACK_[1] = cosInclination;
26
+ BACK_[2] = sinInclination * sinAzimuth;
27
+ RIGHT_[0] = sinAzimuth;
28
+ RIGHT_[1] = 0;
29
+ RIGHT_[2] = -cosAzimuth;
30
+ VERTICAL_[0] = -cosInclination * cosAzimuth;
31
+ VERTICAL_[1] = sinInclination;
32
+ VERTICAL_[2] = -cosInclination * sinAzimuth;
33
+ }
34
+ else {
35
+ BACK_[0] = sinInclination * cosAzimuth;
36
+ BACK_[1] = sinInclination * sinAzimuth;
37
+ BACK_[2] = cosInclination;
38
+ RIGHT_[0] = -sinAzimuth;
39
+ RIGHT_[1] = cosAzimuth;
40
+ RIGHT_[2] = 0;
41
+ VERTICAL_[0] = -cosInclination * cosAzimuth;
42
+ VERTICAL_[1] = -cosInclination * sinAzimuth;
43
+ VERTICAL_[2] = sinInclination;
44
+ }
45
+ }
46
+ /**
47
+ * A camera orbiting a target: azimuth and inclination about the up axis, a
48
+ * distance, and a target that pans. Azimuth is wrapped to [0, 2π) (Y up:
49
+ * `atan2(z, x)`; Z up: from +X toward +Y); inclination and distance are
50
+ * clamped; frames outside the bounds are clamped, never refused.
51
+ *
52
+ * The inclination never reaches a pole (its bounds lie within (0, π)), where
53
+ * the azimuth would stop meaning anything; the view matrix is built from the
54
+ * angles, so it is exact however close to a pole the bounds allow, and the
55
+ * camera's up never flips.
56
+ *
57
+ * @example
58
+ * const camera = new OrbitCamera({
59
+ * target: [0, 0, 0],
60
+ * eye: [0, 5, 10],
61
+ * distance: [1, 50],
62
+ * inclination: [0.1, Math.PI / 2],
63
+ * });
64
+ * camera.rotate(0.1, -0.05);
65
+ * camera.dolly(0.9);
66
+ * const view = camera.getView(mat4x4Create());
67
+ */
68
+ export class OrbitCamera {
69
+ up_;
70
+ minDistance_;
71
+ maxDistance_;
72
+ minInclination_;
73
+ maxInclination_;
74
+ targetCenter_ = vec3Create();
75
+ targetRadius_;
76
+ target_ = vec3Create();
77
+ azimuth_ = 0;
78
+ inclination_ = 0;
79
+ distance_ = 0;
80
+ version_ = 0;
81
+ /**
82
+ * @throws {RangeError} For bounds out of order or outside their ranges (NaN
83
+ * included), a non-finite target or eye, an eye on the target, or an an
84
+ * inclination bound on a pole (0 or π).
85
+ */
86
+ constructor(options) {
87
+ const { distance, inclination, targetBounds } = options;
88
+ this.up_ = options.up ?? "y";
89
+ if (this.up_ !== "y" && this.up_ !== "z") {
90
+ throw new RangeError('OrbitCamera: up must be "y" or "z".');
91
+ }
92
+ if (!(distance[0] > 0 &&
93
+ distance[1] >= distance[0] &&
94
+ Number.isFinite(distance[1]))) {
95
+ throw new RangeError(`OrbitCamera: distance must be [min, max] with 0 < min ≤ max < ∞, not [${distance[0]}, ${distance[1]}].`);
96
+ }
97
+ if (!(inclination[0] > 0 &&
98
+ inclination[1] >= inclination[0] &&
99
+ inclination[1] < Math.PI)) {
100
+ throw new RangeError(`OrbitCamera: inclination must be [min, max] within (0, π), not [${inclination[0]}, ${inclination[1]}].`);
101
+ }
102
+ this.minDistance_ = distance[0];
103
+ this.maxDistance_ = distance[1];
104
+ this.minInclination_ = inclination[0];
105
+ this.maxInclination_ = inclination[1];
106
+ if (targetBounds !== undefined) {
107
+ if (!(Number.isFinite(targetBounds[0]) &&
108
+ Number.isFinite(targetBounds[1]) &&
109
+ Number.isFinite(targetBounds[2]) &&
110
+ targetBounds[3] >= 0 &&
111
+ Number.isFinite(targetBounds[3]))) {
112
+ throw new RangeError("OrbitCamera: targetBounds must be a finite sphere with a radius of at least 0.");
113
+ }
114
+ vec3Set(this.targetCenter_, targetBounds[0], targetBounds[1], targetBounds[2]);
115
+ this.targetRadius_ = targetBounds[3];
116
+ }
117
+ this.setFrame(options.target, options.eye);
118
+ this.version_ = 0;
119
+ }
120
+ /** Increases on each change of the frame. */
121
+ get version() {
122
+ return this.version_;
123
+ }
124
+ get fovY() {
125
+ return undefined;
126
+ }
127
+ get up() {
128
+ return this.up_;
129
+ }
130
+ get azimuth() {
131
+ return this.azimuth_;
132
+ }
133
+ get inclination() {
134
+ return this.inclination_;
135
+ }
136
+ get distance() {
137
+ return this.distance_;
138
+ }
139
+ getTarget(out) {
140
+ return vec3Copy(out, this.target_);
141
+ }
142
+ getEye(out) {
143
+ axes_(this.up_, this.azimuth_, this.inclination_);
144
+ return vec3AddScaled(out, this.target_, BACK_, this.distance_);
145
+ }
146
+ /** World → camera: right-handed, looking down −Z, the up axis up. */
147
+ getView(out) {
148
+ axes_(this.up_, this.azimuth_, this.inclination_);
149
+ vec3AddScaled(EYE_, this.target_, BACK_, this.distance_);
150
+ return mat4x4ViewFromBasis(out, RIGHT_, VERTICAL_, BACK_, EYE_);
151
+ }
152
+ /**
153
+ * Reframes with the constructor's validation and clamping; nothing changes
154
+ * when it throws.
155
+ *
156
+ * @throws {RangeError} For a non-finite target or eye, or an eye on the
157
+ * target.
158
+ */
159
+ setFrame(target, eye) {
160
+ if (!vec3IsFinite(target) || !vec3IsFinite(eye)) {
161
+ throw new RangeError("OrbitCamera: target and eye must be finite.");
162
+ }
163
+ vec3Subtract(OFFSET_, eye, target);
164
+ const radius = vec3LengthScaled(OFFSET_);
165
+ if (!(radius > 0 && Number.isFinite(radius))) {
166
+ throw new RangeError("OrbitCamera: eye and target must have a finite, non-zero separation.");
167
+ }
168
+ vec3NormalizeScaled(OFFSET_, OFFSET_);
169
+ if (this.up_ === "y") {
170
+ sphericalFromVec3YUp(SPHERICAL_, OFFSET_);
171
+ }
172
+ else {
173
+ sphericalFromVec3ZUp(SPHERICAL_, OFFSET_);
174
+ }
175
+ this.boundTarget_(NEXT_TARGET_, target);
176
+ this.commit_(NEXT_TARGET_, angleWrapRad(SPHERICAL_[1]), clamp(SPHERICAL_[2], this.minInclination_, this.maxInclination_), clamp(radius, this.minDistance_, this.maxDistance_));
177
+ }
178
+ /**
179
+ * Adds radians; the azimuth is wrapped and the inclination clamped.
180
+ *
181
+ * @throws {RangeError} For non-finite input.
182
+ */
183
+ rotate(azimuth, inclination) {
184
+ assertFinite(azimuth, "azimuth");
185
+ assertFinite(inclination, "inclination");
186
+ this.commit_(this.target_, angleWrapRad(this.azimuth_ + angleWrapRad(azimuth)), clamp(this.inclination_ + inclination, this.minInclination_, this.maxInclination_), this.distance_);
187
+ }
188
+ /**
189
+ * Multiplies the distance (< 1 moves closer), clamped to the bounds.
190
+ *
191
+ * @throws {RangeError} Unless positive and finite.
192
+ */
193
+ dolly(factor) {
194
+ assertPositive(factor, "dolly factor");
195
+ this.commit_(this.target_, this.azimuth_, this.inclination_, clamp(this.distance_ * factor, this.minDistance_, this.maxDistance_));
196
+ }
197
+ /**
198
+ * Drags the scene by screen pixels (right and down positive) at the target's
199
+ * depth, for a viewport `viewportHeight` pixels high seen through `lens`; the
200
+ * target stays inside its bounds. A pan whose result is not finite (a huge
201
+ * delta over a tiny viewport) changes nothing.
202
+ *
203
+ * @throws {RangeError} For non-finite deltas, a non-positive or non-finite
204
+ * height, or a lens `View3` would refuse (a `"camera"` field of view
205
+ * included: an orbit camera has none).
206
+ */
207
+ pan(deltaX, deltaY, viewportHeight, lens) {
208
+ assertFinite(deltaX, "deltaX");
209
+ assertFinite(deltaY, "deltaY");
210
+ assertPositive(viewportHeight, "viewportHeight");
211
+ const perPixel = lensWorldUnitsPerPixel_(lens, this.distance_, viewportHeight);
212
+ axes_(this.up_, this.azimuth_, this.inclination_);
213
+ vec3AddScaled(NEXT_TARGET_, this.target_, RIGHT_, -deltaX * perPixel);
214
+ vec3AddScaled(NEXT_TARGET_, NEXT_TARGET_, VERTICAL_, deltaY * perPixel);
215
+ if (!vec3IsFinite(NEXT_TARGET_)) {
216
+ return;
217
+ }
218
+ this.boundTarget_(NEXT_TARGET_, NEXT_TARGET_);
219
+ if (!vec3IsFinite(NEXT_TARGET_)) {
220
+ return;
221
+ }
222
+ this.commit_(NEXT_TARGET_, this.azimuth_, this.inclination_, this.distance_);
223
+ }
224
+ boundTarget_(out, target) {
225
+ vec3Copy(out, target);
226
+ const radius = this.targetRadius_;
227
+ if (radius === undefined) {
228
+ return out;
229
+ }
230
+ vec3Subtract(OFFSET_, target, this.targetCenter_);
231
+ const distance = vec3LengthScaled(OFFSET_);
232
+ if (distance > radius) {
233
+ vec3AddScaled(out, this.targetCenter_, OFFSET_, radius / distance);
234
+ }
235
+ return out;
236
+ }
237
+ commit_(target, azimuth, inclination, distance) {
238
+ if (target[0] !== this.target_[0] ||
239
+ target[1] !== this.target_[1] ||
240
+ target[2] !== this.target_[2] ||
241
+ azimuth !== this.azimuth_ ||
242
+ inclination !== this.inclination_ ||
243
+ distance !== this.distance_) {
244
+ vec3Copy(this.target_, target);
245
+ this.azimuth_ = azimuth;
246
+ this.inclination_ = inclination;
247
+ this.distance_ = distance;
248
+ this.version_ += 1;
249
+ }
250
+ }
251
+ }
252
+ //# sourceMappingURL=orbit-camera.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orbit-camera.js","sourceRoot":"","sources":["../../src/camera/orbit-camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAEN,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAIN,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,YAAY,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAgBlE,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;AAC5B,MAAM,SAAS,GAAG,UAAU,EAAE,CAAC;AAC/B,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;AAC3B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,MAAM,YAAY,GAAG,UAAU,EAAE,CAAC;AAClC,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;AAC1B,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAC;AAE3C;;;;GAIG;AACH,SAAS,KAAK,CAAC,EAAY,EAAE,OAAe,EAAE,WAAmB;IAChE,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IA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AAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC;QAClC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,GAAG,CAAC;QACZ,CAAC;QACD,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,QAAQ,GAAG,MAAM,EAAE,CAAC;YACvB,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC;QACpE,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAEO,OAAO,CACd,MAAoB,EACpB,OAAe,EACf,WAAmB,EACnB,QAAgB;QAEhB,IACC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC7B,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC7B,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC7B,OAAO,KAAK,IAAI,CAAC,QAAQ;YACzB,WAAW,KAAK,IAAI,CAAC,YAAY;YACjC,QAAQ,KAAK,IAAI,CAAC,SAAS,EAC1B,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YACxB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;YAChC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;YAC1B,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACpB,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,35 @@
1
+ import { type AnimationFrames } from "@ac-kit/browser";
2
+ import type { CallableNoArgs, Callable } from "@ac-kit/core";
3
+ import { type InertiaOptions, type TransformUpdate } from "@ac-kit/ui-gesture";
4
+ import type { GestureElement } from "@ac-kit/ui-gesture/dom";
5
+ export type InertiaInputOptions_ = {
6
+ readonly inertia: boolean | InertiaOptions | undefined;
7
+ readonly frames: AnimationFrames | undefined;
8
+ /** The axes the pan moves along; the release velocity is cut to them. */
9
+ readonly axes?: {
10
+ readonly x: boolean;
11
+ readonly y: boolean;
12
+ };
13
+ /** Moves the view by screen pixels. */
14
+ readonly pan: Callable<[deltaX: number, deltaY: number]>;
15
+ readonly onChange: CallableNoArgs;
16
+ /** Ends the inertia, and removes its listeners, when it aborts. */
17
+ readonly signal: AbortSignal;
18
+ };
19
+ /** What a pan binding does with a released pan, when inertia is on. */
20
+ export type InertiaInput_ = {
21
+ /** Feeds every update of the transform gesture. */
22
+ track(update: TransformUpdate): void;
23
+ /** Ends an inertia under way: a wheel, a key, a tap. */
24
+ stop(): void;
25
+ };
26
+ /**
27
+ * Continues a released one-pointer pan by exponential decay on animation
28
+ * frames, unless the person prefers reduced motion (followed while bound). A
29
+ * press, `stop()` or the signal ends it. `undefined` when inertia is off.
30
+ *
31
+ * @throws {RangeError} For unusable inertia options.
32
+ * @throws {TypeError} When there are no frames to run on.
33
+ */
34
+ export declare function bindInertia_(element: GestureElement, options: InertiaInputOptions_): InertiaInput_ | undefined;
35
+ //# sourceMappingURL=_inertia-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_inertia-input.d.ts","sourceRoot":"","sources":["../../src/dom/_inertia-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,MAAM,oBAAoB,GAAG;IACl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