@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.
- package/CHANGELOG.md +80 -0
- package/LICENSE +28 -0
- package/README.md +206 -2
- package/dist/camera/camera3.d.ts +17 -0
- package/dist/camera/camera3.d.ts.map +1 -0
- package/dist/camera/camera3.js +2 -0
- package/dist/camera/camera3.js.map +1 -0
- package/dist/camera/look-around-camera.d.ts +110 -0
- package/dist/camera/look-around-camera.d.ts.map +1 -0
- package/dist/camera/look-around-camera.js +220 -0
- package/dist/camera/look-around-camera.js.map +1 -0
- package/dist/camera/orbit-camera.d.ts +102 -0
- package/dist/camera/orbit-camera.d.ts.map +1 -0
- package/dist/camera/orbit-camera.js +252 -0
- package/dist/camera/orbit-camera.js.map +1 -0
- package/dist/dom/_inertia-input.d.ts +35 -0
- package/dist/dom/_inertia-input.d.ts.map +1 -0
- package/dist/dom/_inertia-input.js +121 -0
- package/dist/dom/_inertia-input.js.map +1 -0
- package/dist/dom/bind-look-around-input.d.ts +54 -0
- package/dist/dom/bind-look-around-input.d.ts.map +1 -0
- package/dist/dom/bind-look-around-input.js +111 -0
- package/dist/dom/bind-look-around-input.js.map +1 -0
- package/dist/dom/bind-orbit-input.d.ts +47 -0
- package/dist/dom/bind-orbit-input.d.ts.map +1 -0
- package/dist/dom/bind-orbit-input.js +118 -0
- package/dist/dom/bind-orbit-input.js.map +1 -0
- package/dist/dom/bind-view2-input.d.ts +60 -0
- package/dist/dom/bind-view2-input.d.ts.map +1 -0
- package/dist/dom/bind-view2-input.js +164 -0
- package/dist/dom/bind-view2-input.js.map +1 -0
- package/dist/dom/index.d.ts +4 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +4 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/view2/interpolate-view2-frame.d.ts +13 -0
- package/dist/view2/interpolate-view2-frame.d.ts.map +1 -0
- package/dist/view2/interpolate-view2-frame.js +30 -0
- package/dist/view2/interpolate-view2-frame.js.map +1 -0
- package/dist/view2/view2.d.ts +195 -0
- package/dist/view2/view2.d.ts.map +1 -0
- package/dist/view2/view2.js +445 -0
- package/dist/view2/view2.js.map +1 -0
- package/dist/view3/_projection.d.ts +20 -0
- package/dist/view3/_projection.d.ts.map +1 -0
- package/dist/view3/_projection.js +43 -0
- package/dist/view3/_projection.js.map +1 -0
- package/dist/view3/choose-depth-range.d.ts +25 -0
- package/dist/view3/choose-depth-range.d.ts.map +1 -0
- package/dist/view3/choose-depth-range.js +22 -0
- package/dist/view3/choose-depth-range.js.map +1 -0
- package/dist/view3/view3.d.ts +145 -0
- package/dist/view3/view3.d.ts.map +1 -0
- package/dist/view3/view3.js +306 -0
- package/dist/view3/view3.js.map +1 -0
- package/package.json +76 -3
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { assertFinite, assertNonNegative, assertPositive, clamp, } from "@ac-kit/core";
|
|
2
|
+
import { box2Center, box2Clone, box2IsEmpty, box2IsFinite, box2Set, box2Size, } from "@ac-kit/math-geometry";
|
|
3
|
+
import { affine2Create, affine2Multiply, affine2Orthographic, mat4x4FromAffine2, vec2Create, vec2Of, } from "@ac-kit/math-linear";
|
|
4
|
+
import { angleNormalizeRad } from "@ac-kit/math-scalar";
|
|
5
|
+
const UNLIMITED_ = [0, Number.POSITIVE_INFINITY];
|
|
6
|
+
const OFFSET_ = vec2Create();
|
|
7
|
+
const SIZE_ = vec2Create();
|
|
8
|
+
const CENTER_ = vec2Create();
|
|
9
|
+
const SCREEN_ = affine2Create();
|
|
10
|
+
const CLIP_ = affine2Create();
|
|
11
|
+
/**
|
|
12
|
+
* Writes into `out` the world vector that a screen vector `(x, y)` is when the
|
|
13
|
+
* view's linear part `R(rotation) · diag(scaleX, flip · scaleY)` is inverted.
|
|
14
|
+
*/
|
|
15
|
+
function inverseLinear_(out, x, y, cos, sin, scaleX, scaleY, flip) {
|
|
16
|
+
out[0] = (cos * x + sin * y) / scaleX;
|
|
17
|
+
out[1] = (flip * (cos * y - sin * x)) / scaleY;
|
|
18
|
+
}
|
|
19
|
+
function checkLimits_(name, limits) {
|
|
20
|
+
const [min, max] = limits;
|
|
21
|
+
if (!(min >= 0 && min < Number.POSITIVE_INFINITY && max > 0 && min <= max)) {
|
|
22
|
+
throw new RangeError(`View2: scaleLimits.${name} must be [min, max] with 0 ≤ min ≤ max, max > 0 and min finite, not [${min}, ${max}].`);
|
|
23
|
+
}
|
|
24
|
+
return [min, max];
|
|
25
|
+
}
|
|
26
|
+
function checkScale_(value, name = "scale") {
|
|
27
|
+
assertPositive(value, name);
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
function checkSize_(name, value) {
|
|
31
|
+
assertNonNegative(value, name);
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
function checkBox_(box, what) {
|
|
35
|
+
if (!box2IsFinite(box) || box2IsEmpty(box)) {
|
|
36
|
+
throw new RangeError(`View2: ${what} must be a finite, non-empty box.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A 2D view: which world area a viewport shows. Changes come in screen pixels
|
|
41
|
+
* (pans, zooms and turns about a screen point, as gestures produce them) and
|
|
42
|
+
* are clamped by the scale limits and the bounds after each call. The
|
|
43
|
+
* world-to-screen map is `T(viewport centre) · R(rotation) · S(scale) ·
|
|
44
|
+
* F(yAxis) · T(−center)`. O(1) per call; no allocation after construction
|
|
45
|
+
* except `getFrame`.
|
|
46
|
+
*
|
|
47
|
+
* The state is always finite with positive scales: a call whose result would
|
|
48
|
+
* not be (a non-finite argument, a zoom that overflows) changes nothing.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* const view = new View2({ yAxis: "up", width: 800, height: 600 });
|
|
52
|
+
* view.fit(box2FromXywh(box2Create(), 0, 0, 100, 50), { padding: 24 });
|
|
53
|
+
* view.zoomAbout(2, 400, 300);
|
|
54
|
+
* context.setTransform(
|
|
55
|
+
* ...view.getWorldToScreen(affine2Create(), devicePixelRatio),
|
|
56
|
+
* ); // Canvas 2D
|
|
57
|
+
*/
|
|
58
|
+
export class View2 {
|
|
59
|
+
centerX_;
|
|
60
|
+
centerY_;
|
|
61
|
+
scaleX_;
|
|
62
|
+
scaleY_;
|
|
63
|
+
rotation_;
|
|
64
|
+
cos_;
|
|
65
|
+
sin_;
|
|
66
|
+
width_;
|
|
67
|
+
height_;
|
|
68
|
+
version_ = 0;
|
|
69
|
+
flip_;
|
|
70
|
+
yAxis_;
|
|
71
|
+
limitsX_;
|
|
72
|
+
limitsY_;
|
|
73
|
+
bounds_;
|
|
74
|
+
boundsMode_;
|
|
75
|
+
rotatable_;
|
|
76
|
+
/**
|
|
77
|
+
* @throws {RangeError} For a non-finite or non-positive scale, limits not
|
|
78
|
+
* ordered, a non-finite center, rotation or size, or an empty or non-finite
|
|
79
|
+
* bounds box.
|
|
80
|
+
*/
|
|
81
|
+
constructor(options = {}) {
|
|
82
|
+
const center = options.center ?? [0, 0];
|
|
83
|
+
assertFinite(center[0], "center x");
|
|
84
|
+
assertFinite(center[1], "center y");
|
|
85
|
+
const scale = options.scale ?? 1;
|
|
86
|
+
const scaleX = checkScale_(typeof scale === "number" ? scale : scale[0], "scale x");
|
|
87
|
+
const scaleY = checkScale_(typeof scale === "number" ? scale : scale[1], "scale y");
|
|
88
|
+
const rotation = options.rotation ?? 0;
|
|
89
|
+
assertFinite(rotation, "rotation");
|
|
90
|
+
this.yAxis_ = options.yAxis ?? "up";
|
|
91
|
+
if (this.yAxis_ !== "up" && this.yAxis_ !== "down") {
|
|
92
|
+
throw new RangeError('View2: yAxis must be "up" or "down".');
|
|
93
|
+
}
|
|
94
|
+
this.flip_ = this.yAxis_ === "up" ? -1 : 1;
|
|
95
|
+
this.width_ = checkSize_("width", options.width ?? 0);
|
|
96
|
+
this.height_ = checkSize_("height", options.height ?? 0);
|
|
97
|
+
this.limitsX_ =
|
|
98
|
+
options.scaleLimits?.x === undefined
|
|
99
|
+
? UNLIMITED_
|
|
100
|
+
: checkLimits_("x", options.scaleLimits.x);
|
|
101
|
+
this.limitsY_ =
|
|
102
|
+
options.scaleLimits?.y === undefined
|
|
103
|
+
? UNLIMITED_
|
|
104
|
+
: checkLimits_("y", options.scaleLimits.y);
|
|
105
|
+
if (options.bounds !== undefined) {
|
|
106
|
+
checkBox_(options.bounds, "bounds");
|
|
107
|
+
this.bounds_ = box2Clone(options.bounds);
|
|
108
|
+
}
|
|
109
|
+
this.boundsMode_ = options.boundsMode ?? "center";
|
|
110
|
+
if (this.boundsMode_ !== "center" && this.boundsMode_ !== "inside") {
|
|
111
|
+
throw new RangeError('View2: boundsMode must be "center" or "inside".');
|
|
112
|
+
}
|
|
113
|
+
this.rotatable_ = options.rotatable ?? false;
|
|
114
|
+
this.centerX_ = center[0];
|
|
115
|
+
this.centerY_ = center[1];
|
|
116
|
+
this.scaleX_ = scaleX;
|
|
117
|
+
this.scaleY_ = scaleY;
|
|
118
|
+
this.rotation_ = 0;
|
|
119
|
+
this.cos_ = 1;
|
|
120
|
+
this.sin_ = 0;
|
|
121
|
+
this.apply_(center[0], center[1], scaleX, scaleY, rotation, true);
|
|
122
|
+
this.version_ = 0;
|
|
123
|
+
}
|
|
124
|
+
/** Increases on each change of the frame or the viewport. */
|
|
125
|
+
get version() {
|
|
126
|
+
return this.version_;
|
|
127
|
+
}
|
|
128
|
+
get width() {
|
|
129
|
+
return this.width_;
|
|
130
|
+
}
|
|
131
|
+
get height() {
|
|
132
|
+
return this.height_;
|
|
133
|
+
}
|
|
134
|
+
get rotation() {
|
|
135
|
+
return this.rotation_;
|
|
136
|
+
}
|
|
137
|
+
get yAxis() {
|
|
138
|
+
return this.yAxis_;
|
|
139
|
+
}
|
|
140
|
+
getCenter(out) {
|
|
141
|
+
out[0] = this.centerX_;
|
|
142
|
+
out[1] = this.centerY_;
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
getScale(out) {
|
|
146
|
+
out[0] = this.scaleX_;
|
|
147
|
+
out[1] = this.scaleY_;
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
/** Allocates. */
|
|
151
|
+
getFrame() {
|
|
152
|
+
return {
|
|
153
|
+
center: vec2Of(this.centerX_, this.centerY_),
|
|
154
|
+
scale: vec2Of(this.scaleX_, this.scaleY_),
|
|
155
|
+
rotation: this.rotation_,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Resizes the viewport, keeping the world point at its centre.
|
|
160
|
+
*
|
|
161
|
+
* @throws {RangeError} For a negative or non-finite size.
|
|
162
|
+
*/
|
|
163
|
+
setViewport(width, height) {
|
|
164
|
+
checkSize_("width", width);
|
|
165
|
+
checkSize_("height", height);
|
|
166
|
+
const changed = width !== this.width_ || height !== this.height_;
|
|
167
|
+
this.width_ = width;
|
|
168
|
+
this.height_ = height;
|
|
169
|
+
this.apply_(this.centerX_, this.centerY_, this.scaleX_, this.scaleY_, this.rotation_, changed);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Sets the frame, then applies the scale limits and the bounds.
|
|
173
|
+
*
|
|
174
|
+
* @throws {RangeError} For non-finite values or a non-positive scale.
|
|
175
|
+
*/
|
|
176
|
+
setFrame(frame) {
|
|
177
|
+
checkScale_(frame.scale[0], "frame scale x");
|
|
178
|
+
checkScale_(frame.scale[1], "frame scale y");
|
|
179
|
+
assertFinite(frame.center[0], "frame center x");
|
|
180
|
+
assertFinite(frame.center[1], "frame center y");
|
|
181
|
+
assertFinite(frame.rotation, "frame rotation");
|
|
182
|
+
this.apply_(frame.center[0], frame.center[1], frame.scale[0], frame.scale[1], frame.rotation, false);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Moves the content by screen pixels (right and down positive). A non-finite
|
|
186
|
+
* delta changes nothing.
|
|
187
|
+
*/
|
|
188
|
+
panBy(deltaX, deltaY) {
|
|
189
|
+
inverseLinear_(OFFSET_, -deltaX, -deltaY, this.cos_, this.sin_, this.scaleX_, this.scaleY_, this.flip_);
|
|
190
|
+
this.apply_(this.centerX_ + OFFSET_[0], this.centerY_ + OFFSET_[1], this.scaleX_, this.scaleY_, this.rotation_, false);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Scales both axes by `factor` (> 1 zooms in), keeping screen point (x, y)
|
|
194
|
+
* fixed, and the aspect ratio unless the limits of an axis stop it first. A
|
|
195
|
+
* factor that is not finite and positive, or a non-finite point, changes
|
|
196
|
+
* nothing.
|
|
197
|
+
*/
|
|
198
|
+
zoomAbout(factor, x, y) {
|
|
199
|
+
if (!(factor > 0 && factor < Number.POSITIVE_INFINITY)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const low = Math.max(this.limitsX_[0] / this.scaleX_, this.limitsY_[0] / this.scaleY_);
|
|
203
|
+
const high = Math.min(this.limitsX_[1] / this.scaleX_, this.limitsY_[1] / this.scaleY_);
|
|
204
|
+
this.transformAbout_(low <= high ? clamp(factor, low, high) : factor, low <= high ? clamp(factor, low, high) : factor, 0, x, y);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Per-axis zoom in world axes, keeping (x, y) fixed: a time axis zoomed
|
|
208
|
+
* alone. A factor that is not finite and positive changes nothing.
|
|
209
|
+
*/
|
|
210
|
+
zoomAxesAbout(factorX, factorY, x, y) {
|
|
211
|
+
if (!(factorX > 0 && factorX < Number.POSITIVE_INFINITY) ||
|
|
212
|
+
!(factorY > 0 && factorY < Number.POSITIVE_INFINITY)) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
this.transformAbout_(factorX, factorY, 0, x, y);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Turns the content by `angle` (clockwise on screen) about (x, y); no-op
|
|
219
|
+
* unless `rotatable`.
|
|
220
|
+
*/
|
|
221
|
+
rotateAbout(angle, x, y) {
|
|
222
|
+
if (this.rotatable_) {
|
|
223
|
+
this.transformAbout_(1, 1, angle, x, y);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Shows `box` in the viewport minus padding, keeping the rotation. A flat box
|
|
228
|
+
* (zero width or height) is fitted on its other axis. With the aspect kept
|
|
229
|
+
* the one scale stays inside the intersection of the two axes' limits; where
|
|
230
|
+
* they do not intersect each axis is clamped to its own, and the aspect is
|
|
231
|
+
* given up. With `keepAspect: false` on a view turned near 45° (or a flat
|
|
232
|
+
* box) the two scales cannot both be solved for, and the aspect is kept.
|
|
233
|
+
*
|
|
234
|
+
* @throws {RangeError} For an empty or non-finite box, a box that is a single
|
|
235
|
+
* point, a negative or non-finite padding, a padding that leaves no room in
|
|
236
|
+
* the viewport, or a box too small to scale to it.
|
|
237
|
+
*/
|
|
238
|
+
fit(box, options = {}) {
|
|
239
|
+
checkBox_(box, "the box to fit");
|
|
240
|
+
box2Size(SIZE_, box);
|
|
241
|
+
const boxWidth = SIZE_[0];
|
|
242
|
+
const boxHeight = SIZE_[1];
|
|
243
|
+
if (!(boxWidth > 0 || boxHeight > 0)) {
|
|
244
|
+
throw new RangeError("View2: a single point has no size to fit.");
|
|
245
|
+
}
|
|
246
|
+
const padding = options.padding ?? 0;
|
|
247
|
+
const top = typeof padding === "number" ? padding : padding.top;
|
|
248
|
+
const right = typeof padding === "number" ? padding : padding.right;
|
|
249
|
+
const bottom = typeof padding === "number" ? padding : padding.bottom;
|
|
250
|
+
const left = typeof padding === "number" ? padding : padding.left;
|
|
251
|
+
assertNonNegative(top, "padding top");
|
|
252
|
+
assertNonNegative(right, "padding right");
|
|
253
|
+
assertNonNegative(bottom, "padding bottom");
|
|
254
|
+
assertNonNegative(left, "padding left");
|
|
255
|
+
const room = this.width_ - left - right;
|
|
256
|
+
const roomHeight = this.height_ - top - bottom;
|
|
257
|
+
if (!(room > 0 && roomHeight > 0)) {
|
|
258
|
+
throw new RangeError("View2: the padding leaves no room in the viewport.");
|
|
259
|
+
}
|
|
260
|
+
const absCos = Math.abs(this.cos_);
|
|
261
|
+
const absSin = Math.abs(this.sin_);
|
|
262
|
+
const extentWidth = absCos * boxWidth + absSin * boxHeight;
|
|
263
|
+
const extentHeight = absSin * boxWidth + absCos * boxHeight;
|
|
264
|
+
const common = Math.min(room / extentWidth, roomHeight / extentHeight);
|
|
265
|
+
let scaleX = common;
|
|
266
|
+
let scaleY = common;
|
|
267
|
+
let uniform = true;
|
|
268
|
+
if (options.keepAspect === false) {
|
|
269
|
+
// Solves [|cos|·w, |sin|·h; |sin|·w, |cos|·h] · [sx, sy] = room.
|
|
270
|
+
const determinant = boxWidth * boxHeight * (absCos * absCos - absSin * absSin);
|
|
271
|
+
const solvedX = (room * absCos * boxHeight - roomHeight * absSin * boxHeight) /
|
|
272
|
+
determinant;
|
|
273
|
+
const solvedY = (roomHeight * absCos * boxWidth - room * absSin * boxWidth) /
|
|
274
|
+
determinant;
|
|
275
|
+
if (solvedX > 0 && solvedY > 0 && Number.isFinite(solvedX + solvedY)) {
|
|
276
|
+
scaleX = solvedX;
|
|
277
|
+
scaleY = solvedY;
|
|
278
|
+
uniform = false;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
const low = Math.max(this.limitsX_[0], this.limitsY_[0]);
|
|
282
|
+
const high = Math.min(this.limitsX_[1], this.limitsY_[1]);
|
|
283
|
+
if (uniform && low <= high) {
|
|
284
|
+
scaleX = clamp(common, low, high);
|
|
285
|
+
scaleY = scaleX;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
scaleX = clamp(scaleX, this.limitsX_[0], this.limitsX_[1]);
|
|
289
|
+
scaleY = clamp(scaleY, this.limitsY_[0], this.limitsY_[1]);
|
|
290
|
+
}
|
|
291
|
+
if (!(Number.isFinite(scaleX) && Number.isFinite(scaleY))) {
|
|
292
|
+
throw new RangeError("View2: the box is too small to fit within the scale limits.");
|
|
293
|
+
}
|
|
294
|
+
inverseLinear_(OFFSET_, (left + this.width_ - right) / 2 - this.width_ / 2, (top + this.height_ - bottom) / 2 - this.height_ / 2, this.cos_, this.sin_, scaleX, scaleY, this.flip_);
|
|
295
|
+
box2Center(CENTER_, box);
|
|
296
|
+
this.apply_(CENTER_[0] - OFFSET_[0], CENTER_[1] - OFFSET_[1], scaleX, scaleY, this.rotation_, false);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* World → screen as an affine transform; with `pixelRatio`, → device pixels
|
|
300
|
+
* (a Canvas 2D `setTransform`).
|
|
301
|
+
*/
|
|
302
|
+
getWorldToScreen(out, pixelRatio = 1) {
|
|
303
|
+
const a = this.cos_ * this.scaleX_;
|
|
304
|
+
const b = this.sin_ * this.scaleX_;
|
|
305
|
+
const c = -this.sin_ * this.flip_ * this.scaleY_;
|
|
306
|
+
const d = this.cos_ * this.flip_ * this.scaleY_;
|
|
307
|
+
out[0] = a * pixelRatio;
|
|
308
|
+
out[1] = b * pixelRatio;
|
|
309
|
+
out[2] = c * pixelRatio;
|
|
310
|
+
out[3] = d * pixelRatio;
|
|
311
|
+
out[4] =
|
|
312
|
+
(this.width_ / 2 - (a * this.centerX_ + c * this.centerY_)) * pixelRatio;
|
|
313
|
+
out[5] =
|
|
314
|
+
(this.height_ / 2 - (b * this.centerX_ + d * this.centerY_)) * pixelRatio;
|
|
315
|
+
return out;
|
|
316
|
+
}
|
|
317
|
+
getScreenToWorld(out) {
|
|
318
|
+
const a = this.cos_ / this.scaleX_;
|
|
319
|
+
const c = this.sin_ / this.scaleX_;
|
|
320
|
+
const b = (-this.flip_ * this.sin_) / this.scaleY_;
|
|
321
|
+
const d = (this.flip_ * this.cos_) / this.scaleY_;
|
|
322
|
+
out[0] = a;
|
|
323
|
+
out[1] = b;
|
|
324
|
+
out[2] = c;
|
|
325
|
+
out[3] = d;
|
|
326
|
+
out[4] = this.centerX_ - (a * (this.width_ / 2) + c * (this.height_ / 2));
|
|
327
|
+
out[5] = this.centerY_ - (b * (this.width_ / 2) + d * (this.height_ / 2));
|
|
328
|
+
return out;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* World → clip space ([−1, 1]², y up), for a GPU pass covering the viewport.
|
|
332
|
+
* A viewport with no width or height gives non-finite entries.
|
|
333
|
+
*/
|
|
334
|
+
getWorldToClip(out) {
|
|
335
|
+
affine2Orthographic(CLIP_, 0, this.width_, this.height_, 0);
|
|
336
|
+
return affine2Multiply(out, CLIP_, this.getWorldToScreen(SCREEN_));
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* The same as a `Mat4x4`, for `DrawViewOptions.viewProjection`: x and y as
|
|
340
|
+
* `getWorldToClip`, z mapped to 0, whatever the input z.
|
|
341
|
+
*/
|
|
342
|
+
getViewProjection(out) {
|
|
343
|
+
mat4x4FromAffine2(out, this.getWorldToClip(SCREEN_));
|
|
344
|
+
out[10] = 0;
|
|
345
|
+
return out;
|
|
346
|
+
}
|
|
347
|
+
worldToScreen(out, point) {
|
|
348
|
+
const offsetX = point[0] - this.centerX_;
|
|
349
|
+
const offsetY = point[1] - this.centerY_;
|
|
350
|
+
const scaledX = offsetX * this.scaleX_;
|
|
351
|
+
const scaledY = offsetY * this.flip_ * this.scaleY_;
|
|
352
|
+
out[0] = this.cos_ * scaledX - this.sin_ * scaledY + this.width_ / 2;
|
|
353
|
+
out[1] = this.sin_ * scaledX + this.cos_ * scaledY + this.height_ / 2;
|
|
354
|
+
return out;
|
|
355
|
+
}
|
|
356
|
+
screenToWorld(out, point) {
|
|
357
|
+
inverseLinear_(out, point[0] - this.width_ / 2, point[1] - this.height_ / 2, this.cos_, this.sin_, this.scaleX_, this.scaleY_, this.flip_);
|
|
358
|
+
out[0] += this.centerX_;
|
|
359
|
+
out[1] += this.centerY_;
|
|
360
|
+
return out;
|
|
361
|
+
}
|
|
362
|
+
/** Axis-aligned world bounds of the visible area (rotated views included). */
|
|
363
|
+
getVisibleBounds(out) {
|
|
364
|
+
const halfWidth = this.halfExtentX_(this.scaleX_, this.cos_, this.sin_);
|
|
365
|
+
const halfHeight = this.halfExtentY_(this.scaleY_, this.cos_, this.sin_);
|
|
366
|
+
return box2Set(out, this.centerX_ - halfWidth, this.centerY_ - halfHeight, this.centerX_ + halfWidth, this.centerY_ + halfHeight);
|
|
367
|
+
}
|
|
368
|
+
halfExtentX_(scaleX, cos, sin) {
|
|
369
|
+
return ((Math.abs(cos) * this.width_ + Math.abs(sin) * this.height_) /
|
|
370
|
+
(2 * scaleX));
|
|
371
|
+
}
|
|
372
|
+
halfExtentY_(scaleY, cos, sin) {
|
|
373
|
+
return ((Math.abs(sin) * this.width_ + Math.abs(cos) * this.height_) /
|
|
374
|
+
(2 * scaleY));
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Scales by the factors and turns by `angle` about screen point (x, y), which
|
|
378
|
+
* stays on the same world point.
|
|
379
|
+
*/
|
|
380
|
+
transformAbout_(factorX, factorY, angle, x, y) {
|
|
381
|
+
const screenX = x - this.width_ / 2;
|
|
382
|
+
const screenY = y - this.height_ / 2;
|
|
383
|
+
inverseLinear_(OFFSET_, screenX, screenY, this.cos_, this.sin_, this.scaleX_, this.scaleY_, this.flip_);
|
|
384
|
+
const pointX = this.centerX_ + OFFSET_[0];
|
|
385
|
+
const pointY = this.centerY_ + OFFSET_[1];
|
|
386
|
+
const scaleX = clamp(this.scaleX_ * factorX, this.limitsX_[0], this.limitsX_[1]);
|
|
387
|
+
const scaleY = clamp(this.scaleY_ * factorY, this.limitsY_[0], this.limitsY_[1]);
|
|
388
|
+
const rotation = angleNormalizeRad(this.rotation_ + angle);
|
|
389
|
+
inverseLinear_(OFFSET_, screenX, screenY, Math.cos(rotation), Math.sin(rotation), scaleX, scaleY, this.flip_);
|
|
390
|
+
this.apply_(pointX - OFFSET_[0], pointY - OFFSET_[1], scaleX, scaleY, rotation, false);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Commits a frame after the scale limits and the bounds, unless a value is
|
|
394
|
+
* not finite (the state then stays as it was).
|
|
395
|
+
*/
|
|
396
|
+
apply_(centerX, centerY, scaleX, scaleY, rotation, force) {
|
|
397
|
+
const limitedX = clamp(scaleX, this.limitsX_[0], this.limitsX_[1]);
|
|
398
|
+
const limitedY = clamp(scaleY, this.limitsY_[0], this.limitsY_[1]);
|
|
399
|
+
if (!(limitedX > 0 &&
|
|
400
|
+
limitedY > 0 &&
|
|
401
|
+
Number.isFinite(limitedX + limitedY) &&
|
|
402
|
+
Number.isFinite(centerX + centerY) &&
|
|
403
|
+
Number.isFinite(rotation))) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const turn = angleNormalizeRad(rotation);
|
|
407
|
+
const cos = turn === this.rotation_ ? this.cos_ : Math.cos(turn);
|
|
408
|
+
const sin = turn === this.rotation_ ? this.sin_ : Math.sin(turn);
|
|
409
|
+
let nextX = centerX;
|
|
410
|
+
let nextY = centerY;
|
|
411
|
+
if (this.bounds_ !== undefined) {
|
|
412
|
+
nextX = this.constrain_(centerX, this.bounds_[0], this.bounds_[2], this.halfExtentX_(limitedX, cos, sin));
|
|
413
|
+
nextY = this.constrain_(centerY, this.bounds_[1], this.bounds_[3], this.halfExtentY_(limitedY, cos, sin));
|
|
414
|
+
}
|
|
415
|
+
if (!Number.isFinite(nextX + nextY)) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
const changed = force ||
|
|
419
|
+
nextX !== this.centerX_ ||
|
|
420
|
+
nextY !== this.centerY_ ||
|
|
421
|
+
limitedX !== this.scaleX_ ||
|
|
422
|
+
limitedY !== this.scaleY_ ||
|
|
423
|
+
turn !== this.rotation_;
|
|
424
|
+
this.centerX_ = nextX;
|
|
425
|
+
this.centerY_ = nextY;
|
|
426
|
+
this.scaleX_ = limitedX;
|
|
427
|
+
this.scaleY_ = limitedY;
|
|
428
|
+
this.rotation_ = turn;
|
|
429
|
+
this.cos_ = cos;
|
|
430
|
+
this.sin_ = sin;
|
|
431
|
+
if (changed) {
|
|
432
|
+
this.version_ += 1;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
constrain_(center, minimum, maximum, halfExtent) {
|
|
436
|
+
if (this.boundsMode_ === "center") {
|
|
437
|
+
return clamp(center, minimum, maximum);
|
|
438
|
+
}
|
|
439
|
+
if (2 * halfExtent > maximum - minimum) {
|
|
440
|
+
return (minimum + maximum) / 2;
|
|
441
|
+
}
|
|
442
|
+
return clamp(center, minimum + halfExtent, maximum - halfExtent);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
//# sourceMappingURL=view2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view2.js","sourceRoot":"","sources":["../../src/view2/view2.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,KAAK,GACL,MAAM,cAAc,CAAC;AACtB,OAAO,EAGN,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,OAAO,EACP,QAAQ,GACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAKN,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,MAAM,GACN,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAmExD,MAAM,UAAU,GAA8B,CAAC,CAAC,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAE5E,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,MAAM,KAAK,GAAG,UAAU,EAAE,CAAC;AAC3B,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;AAChC,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;AAE9B;;;GAGG;AACH,SAAS,cAAc,CACtB,GAAS,EACT,CAAS,EACT,CAAS,EACT,GAAW,EACX,GAAW,EACX,MAAc,EACd,MAAc,EACd,IAA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,GAAG,OAAO,EAAE,CAAC;YACxC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;IAClE,CAAC;CACD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type DepthRange, type Mat4x4, type ReadonlyMat4x4 } from "@ac-kit/math-linear";
|
|
2
|
+
import type { Lens3 } from "./view3.js";
|
|
3
|
+
/**
|
|
4
|
+
* Writes the projection of `lens` for a viewport of the given aspect ratio.
|
|
5
|
+
* `cameraFovY` is the camera's own field of view, for a `"camera"` lens.
|
|
6
|
+
*
|
|
7
|
+
* @throws {RangeError} For a lens `mat4x4Perspective` or `mat4x4Orthographic`
|
|
8
|
+
* refuses, a `"camera"` field of view the camera has none of, an orthographic
|
|
9
|
+
* height that is not positive, or an unknown kind; `out` is untouched then.
|
|
10
|
+
*/
|
|
11
|
+
export declare function lensProjection_(out: Mat4x4, lens: Lens3, cameraFovY: number | undefined, aspect: number, depthRange: DepthRange): Mat4x4;
|
|
12
|
+
/** Throws what a `View3` would for `lens`, then gives its world units per pixel. */
|
|
13
|
+
export declare function lensWorldUnitsPerPixel_(lens: Lens3, depth: number, viewportHeight: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* World units one pixel of a viewport `viewportHeight` pixels high spans at
|
|
16
|
+
* `depth` in front of the eye (ignored by an orthographic lens), from the
|
|
17
|
+
* projection's `[5]` entry, which is `1 / tan(fovY / 2)` or `2 / height`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function unitsPerPixel_(lens: Lens3, projection: ReadonlyMat4x4, depth: number, viewportHeight: number): number;
|
|
20
|
+
//# sourceMappingURL=_projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_projection.d.ts","sourceRoot":"","sources":["../../src/view3/_projection.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,cAAc,EAInB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIxC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,KAAK,EACX,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,GACpB,MAAM,CAqCR;AAED,oFAAoF;AACpF,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,GACpB,MAAM,CAGR;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,IAAI,EAAE,KAAK,EACX,UAAU,EAAE,cAAc,EAC1B,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,GACpB,MAAM,CAGR"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { mat4x4Create, mat4x4Orthographic, mat4x4Perspective, } from "@ac-kit/math-linear";
|
|
2
|
+
const CHECK_ = mat4x4Create();
|
|
3
|
+
/**
|
|
4
|
+
* Writes the projection of `lens` for a viewport of the given aspect ratio.
|
|
5
|
+
* `cameraFovY` is the camera's own field of view, for a `"camera"` lens.
|
|
6
|
+
*
|
|
7
|
+
* @throws {RangeError} For a lens `mat4x4Perspective` or `mat4x4Orthographic`
|
|
8
|
+
* refuses, a `"camera"` field of view the camera has none of, an orthographic
|
|
9
|
+
* height that is not positive, or an unknown kind; `out` is untouched then.
|
|
10
|
+
*/
|
|
11
|
+
export function lensProjection_(out, lens, cameraFovY, aspect, depthRange) {
|
|
12
|
+
if (lens.kind === "perspective") {
|
|
13
|
+
const fovY = lens.fovY === "camera" ? cameraFovY : lens.fovY;
|
|
14
|
+
if (typeof fovY !== "number") {
|
|
15
|
+
throw new RangeError('A lens of field of view "camera" needs a camera that has one.');
|
|
16
|
+
}
|
|
17
|
+
return mat4x4Perspective(out, fovY, aspect, lens.near, lens.far, depthRange);
|
|
18
|
+
}
|
|
19
|
+
if (lens.kind === "orthographic") {
|
|
20
|
+
if (!(lens.height > 0 && Number.isFinite(lens.height))) {
|
|
21
|
+
throw new RangeError("An orthographic lens needs a positive, finite height.");
|
|
22
|
+
}
|
|
23
|
+
const halfHeight = lens.height / 2;
|
|
24
|
+
const halfWidth = halfHeight * aspect;
|
|
25
|
+
return mat4x4Orthographic(out, -halfWidth, halfWidth, -halfHeight, halfHeight, lens.near, lens.far, depthRange);
|
|
26
|
+
}
|
|
27
|
+
throw new RangeError("Unknown lens kind.");
|
|
28
|
+
}
|
|
29
|
+
/** Throws what a `View3` would for `lens`, then gives its world units per pixel. */
|
|
30
|
+
export function lensWorldUnitsPerPixel_(lens, depth, viewportHeight) {
|
|
31
|
+
lensProjection_(CHECK_, lens, undefined, 1, "zero-to-one");
|
|
32
|
+
return unitsPerPixel_(lens, CHECK_, depth, viewportHeight);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* World units one pixel of a viewport `viewportHeight` pixels high spans at
|
|
36
|
+
* `depth` in front of the eye (ignored by an orthographic lens), from the
|
|
37
|
+
* projection's `[5]` entry, which is `1 / tan(fovY / 2)` or `2 / height`.
|
|
38
|
+
*/
|
|
39
|
+
export function unitsPerPixel_(lens, projection, depth, viewportHeight) {
|
|
40
|
+
const scale = lens.kind === "perspective" ? depth : 1;
|
|
41
|
+
return (2 * scale) / (projection[5] * viewportHeight);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=_projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_projection.js","sourceRoot":"","sources":["../../src/view3/_projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAI7B,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;A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E,CAAC,EAAE,aAAa,CAAC,CAAC;IAC3D,OAAO,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC7B,IAAW,EACX,UAA0B,EAC1B,KAAa,EACb,cAAsB;IAEtB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DepthRange } from "@ac-kit/math-linear";
|
|
2
|
+
export type DepthRangeSupport = {
|
|
3
|
+
/** `GpuDeviceInfo.nativeDepthZeroToOne`. */
|
|
4
|
+
readonly nativeZeroToOne: boolean;
|
|
5
|
+
/** The depth attachment is `depth32float`. */
|
|
6
|
+
readonly floatDepth: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* `"one-to-zero"` (reversed depth, drawn with a `greater` test and cleared to 0)
|
|
10
|
+
* when both hold and `reversed` is not false — the only case where it gains
|
|
11
|
+
* precision — else `"zero-to-one"`. Only `true` counts as a capability: a
|
|
12
|
+
* missing or non-boolean value is taken as absent.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* chooseDepthRange({ nativeZeroToOne: true, floatDepth: true }); // "one-to-zero"
|
|
16
|
+
* chooseDepthRange({ nativeZeroToOne: true, floatDepth: false }); // "zero-to-one"
|
|
17
|
+
* chooseDepthRange(
|
|
18
|
+
* { nativeZeroToOne: true, floatDepth: true },
|
|
19
|
+
* { reversed: false },
|
|
20
|
+
* ); // "zero-to-one"
|
|
21
|
+
*/
|
|
22
|
+
export declare function chooseDepthRange(support: DepthRangeSupport, options?: {
|
|
23
|
+
readonly reversed?: boolean;
|
|
24
|
+
}): DepthRange;
|
|
25
|
+
//# sourceMappingURL=choose-depth-range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choose-depth-range.d.ts","sourceRoot":"","sources":["../../src/view3/choose-depth-range.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,MAAM,iBAAiB,GAAG;IAC/B,4CAA4C;IAC5C,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GACvC,UAAU,CAMZ"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `"one-to-zero"` (reversed depth, drawn with a `greater` test and cleared to 0)
|
|
3
|
+
* when both hold and `reversed` is not false — the only case where it gains
|
|
4
|
+
* precision — else `"zero-to-one"`. Only `true` counts as a capability: a
|
|
5
|
+
* missing or non-boolean value is taken as absent.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* chooseDepthRange({ nativeZeroToOne: true, floatDepth: true }); // "one-to-zero"
|
|
9
|
+
* chooseDepthRange({ nativeZeroToOne: true, floatDepth: false }); // "zero-to-one"
|
|
10
|
+
* chooseDepthRange(
|
|
11
|
+
* { nativeZeroToOne: true, floatDepth: true },
|
|
12
|
+
* { reversed: false },
|
|
13
|
+
* ); // "zero-to-one"
|
|
14
|
+
*/
|
|
15
|
+
export function chooseDepthRange(support, options) {
|
|
16
|
+
return support.nativeZeroToOne === true &&
|
|
17
|
+
support.floatDepth === true &&
|
|
18
|
+
options?.reversed !== false
|
|
19
|
+
? "one-to-zero"
|
|
20
|
+
: "zero-to-one";
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=choose-depth-range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"choose-depth-range.js","sourceRoot":"","sources":["../../src/view3/choose-depth-range.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAC/B,OAA0B,EAC1B,OAAyC;IAEzC,OAAO,OAAO,CAAC,eAAe,KAAK,IAAI;QACtC,OAAO,CAAC,UAAU,KAAK,IAAI;QAC3B,OAAO,EAAE,QAAQ,KAAK,KAAK;QAC3B,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,aAAa,CAAC;AAClB,CAAC"}
|