@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,145 @@
|
|
|
1
|
+
import { type Frustum3, type Ray3, type ReadonlyPlane3 } from "@ac-kit/math-geometry";
|
|
2
|
+
import { type DepthRange, type ReadonlyMat4x4, type ReadonlyVec3, type Vec3 } from "@ac-kit/math-linear";
|
|
3
|
+
import type { Camera3 } from "../camera/camera3.js";
|
|
4
|
+
export type Lens3 = {
|
|
5
|
+
readonly kind: "perspective";
|
|
6
|
+
/** Radians in (0, π), or the camera's own (`LookAroundCamera`). */
|
|
7
|
+
readonly fovY: number | "camera";
|
|
8
|
+
readonly near: number;
|
|
9
|
+
/** May be `Infinity`. */
|
|
10
|
+
readonly far: number;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "orthographic";
|
|
13
|
+
/** World units the viewport's height spans. */
|
|
14
|
+
readonly height: number;
|
|
15
|
+
readonly near: number;
|
|
16
|
+
readonly far: number;
|
|
17
|
+
};
|
|
18
|
+
export type View3Options = {
|
|
19
|
+
readonly camera: Camera3;
|
|
20
|
+
readonly lens: Lens3;
|
|
21
|
+
/** `chooseDepthRange(…)` for a `graphics-gpu` device. */
|
|
22
|
+
readonly depthRange: DepthRange;
|
|
23
|
+
/** Screen pixels. Default 0 × 0 until `setViewport`. */
|
|
24
|
+
readonly width?: number;
|
|
25
|
+
readonly height?: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A camera seen through a lens on a viewport: the matrices a renderer needs,
|
|
29
|
+
* and the conversions between world points, screen points and picking rays.
|
|
30
|
+
* Matrices are recomputed lazily when the camera's `version`, the lens, the
|
|
31
|
+
* depth range or the viewport changed; the getters return cached values that
|
|
32
|
+
* the next change overwrites (copy them to keep them). While the viewport has
|
|
33
|
+
* no area the aspect ratio is taken as 1.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const view = new View3({
|
|
37
|
+
* camera,
|
|
38
|
+
* lens: {
|
|
39
|
+
* kind: "perspective",
|
|
40
|
+
* fovY: Math.PI / 3,
|
|
41
|
+
* near: 0.1,
|
|
42
|
+
* far: Infinity,
|
|
43
|
+
* },
|
|
44
|
+
* depthRange: chooseDepthRange({
|
|
45
|
+
* nativeZeroToOne: true,
|
|
46
|
+
* floatDepth: true,
|
|
47
|
+
* }),
|
|
48
|
+
* width: 800,
|
|
49
|
+
* height: 600,
|
|
50
|
+
* });
|
|
51
|
+
* const ray = view.screenToRay(ray3Create(), 400, 300);
|
|
52
|
+
*/
|
|
53
|
+
export declare class View3 {
|
|
54
|
+
readonly camera: Camera3;
|
|
55
|
+
private lens_;
|
|
56
|
+
private depthRange_;
|
|
57
|
+
private width_;
|
|
58
|
+
private height_;
|
|
59
|
+
private aspect_;
|
|
60
|
+
private ownVersion_;
|
|
61
|
+
private readonly viewport_;
|
|
62
|
+
private readonly view_;
|
|
63
|
+
private readonly projection_;
|
|
64
|
+
private readonly viewProjection_;
|
|
65
|
+
private readonly inverseViewProjection_;
|
|
66
|
+
private viewSeen_;
|
|
67
|
+
private projectionSeen_;
|
|
68
|
+
private projectionCameraSeen_;
|
|
69
|
+
private viewProjectionValid_;
|
|
70
|
+
private inverseValid_;
|
|
71
|
+
private rayTransformValid_;
|
|
72
|
+
private readonly viewTranspose_;
|
|
73
|
+
private readonly inverseProjection_;
|
|
74
|
+
/**
|
|
75
|
+
* @throws {RangeError} For a lens `mat4x4Perspective`/`mat4x4Orthographic`
|
|
76
|
+
* would refuse (a `"camera"` field of view the camera has none of
|
|
77
|
+
* included), an unknown depth range, or a negative or non-finite size.
|
|
78
|
+
*/
|
|
79
|
+
constructor(options: View3Options);
|
|
80
|
+
get lens(): Lens3;
|
|
81
|
+
/** @throws {RangeError} As the constructor; nothing changes then. */
|
|
82
|
+
set lens(lens: Lens3);
|
|
83
|
+
get depthRange(): DepthRange;
|
|
84
|
+
/**
|
|
85
|
+
* @throws {RangeError} For an unknown depth range, or one the lens cannot be
|
|
86
|
+
* built in; nothing changes then.
|
|
87
|
+
*/
|
|
88
|
+
set depthRange(range: DepthRange);
|
|
89
|
+
get width(): number;
|
|
90
|
+
get height(): number;
|
|
91
|
+
/**
|
|
92
|
+
* Increases when the camera, the lens, the depth range or the viewport
|
|
93
|
+
* changes.
|
|
94
|
+
*/
|
|
95
|
+
get version(): number;
|
|
96
|
+
/**
|
|
97
|
+
* @throws {RangeError} For a negative or non-finite size, or one the lens
|
|
98
|
+
* cannot be built for; nothing changes then.
|
|
99
|
+
*/
|
|
100
|
+
setViewport(width: number, height: number): void;
|
|
101
|
+
/** World → camera. */
|
|
102
|
+
get view(): ReadonlyMat4x4;
|
|
103
|
+
/** Camera → clip space, in the depth range. */
|
|
104
|
+
get projection(): ReadonlyMat4x4;
|
|
105
|
+
get viewProjection(): ReadonlyMat4x4;
|
|
106
|
+
/** `NaN` throughout when the view-projection is not invertible. */
|
|
107
|
+
get inverseViewProjection(): ReadonlyMat4x4;
|
|
108
|
+
getEye(out: Vec3): Vec3;
|
|
109
|
+
/**
|
|
110
|
+
* [x px, y px, depth in the depth range]; `NaN` throughout for a point on or
|
|
111
|
+
* behind the eye (the eye plane, for an orthographic lens too).
|
|
112
|
+
*/
|
|
113
|
+
worldToScreen(out: Vec3, point: ReadonlyVec3): Vec3;
|
|
114
|
+
/**
|
|
115
|
+
* Bulk, 3 numbers in and out per point (labels, anchors), `NaN` for a point
|
|
116
|
+
* on or behind the eye. O(n).
|
|
117
|
+
*
|
|
118
|
+
* @throws {RangeError} When the arrays differ in length or are not a multiple
|
|
119
|
+
* of 3.
|
|
120
|
+
*/
|
|
121
|
+
worldToScreenArray<T extends Float64Array>(out: T, points: Float64Array): T;
|
|
122
|
+
/**
|
|
123
|
+
* The picking ray through a screen point: unprojected in camera space, then
|
|
124
|
+
* carried to the world by the camera's rigid transform, so a far-off eye
|
|
125
|
+
* costs no precision. `NaN` throughout when the viewport has no area or the
|
|
126
|
+
* projection is singular.
|
|
127
|
+
*/
|
|
128
|
+
screenToRay(out: Ray3, x: number, y: number): Ray3;
|
|
129
|
+
/** Where that ray meets `plane`; false when parallel, behind or not a ray. */
|
|
130
|
+
screenToPlane(out: Vec3, x: number, y: number, plane: ReadonlyPlane3): boolean;
|
|
131
|
+
getFrustum(out: Frustum3): Frustum3;
|
|
132
|
+
/**
|
|
133
|
+
* World units one screen pixel spans at `point`'s depth (billboard sizes,
|
|
134
|
+
* orthographic pans): `NaN` for a point on or behind the eye plane under a
|
|
135
|
+
* perspective lens.
|
|
136
|
+
*/
|
|
137
|
+
worldUnitsPerPixel(point: ReadonlyVec3): number;
|
|
138
|
+
private ensureView_;
|
|
139
|
+
private ensureProjection_;
|
|
140
|
+
private ensureViewProjection_;
|
|
141
|
+
private isBehindEye_;
|
|
142
|
+
private ensureRayTransform_;
|
|
143
|
+
private ensureInverse_;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=view3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view3.d.ts","sourceRoot":"","sources":["../../src/view3/view3.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,IAAI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CAEtB;IAED;;;OAGG;IACH,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAQlD;IAED;;;;;;OAMG;IACH,kBAAkB,CAAC,CAAC,SAAS,YAAY,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,GAAG,CAAC,CA6B1E;IAED;;;;;OAKG;IACH,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAsBjD;IAED,8EAA8E;IAC9E,aAAa,CACZ,GAAG,EAAE,IAAI,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,cAAc,GACnB,OAAO,CAQT;IAED,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAGlC;IAED;;;;OAIG;IACH,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAc9C;IAED,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,iBAAiB;IAuBzB,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,cAAc;CAStB"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { assertNonNegative } from "@ac-kit/core";
|
|
2
|
+
import { frustum3FromMat4x4, ray3At, ray3Create, ray3FromViewport, ray3IntersectPlane3, } from "@ac-kit/math-geometry";
|
|
3
|
+
import { mat4x4Create, mat4x4Invert, mat4x4Multiply, mat4x4Transpose, vec3ArrayProjectToViewport, vec3Create, vec3ProjectToViewport, vec3Set, vec3TransformDirectionMat4x4, viewportOf, } from "@ac-kit/math-linear";
|
|
4
|
+
import { lensProjection_, unitsPerPixel_ } from "./_projection.js";
|
|
5
|
+
const CHECK_ = mat4x4Create();
|
|
6
|
+
const RAY_ = ray3Create();
|
|
7
|
+
const PLANE_RAY_ = ray3Create();
|
|
8
|
+
const POINT_ = vec3Create();
|
|
9
|
+
const DIRECTION_ = vec3Create();
|
|
10
|
+
const EYE_ = vec3Create();
|
|
11
|
+
/**
|
|
12
|
+
* A camera seen through a lens on a viewport: the matrices a renderer needs,
|
|
13
|
+
* and the conversions between world points, screen points and picking rays.
|
|
14
|
+
* Matrices are recomputed lazily when the camera's `version`, the lens, the
|
|
15
|
+
* depth range or the viewport changed; the getters return cached values that
|
|
16
|
+
* the next change overwrites (copy them to keep them). While the viewport has
|
|
17
|
+
* no area the aspect ratio is taken as 1.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const view = new View3({
|
|
21
|
+
* camera,
|
|
22
|
+
* lens: {
|
|
23
|
+
* kind: "perspective",
|
|
24
|
+
* fovY: Math.PI / 3,
|
|
25
|
+
* near: 0.1,
|
|
26
|
+
* far: Infinity,
|
|
27
|
+
* },
|
|
28
|
+
* depthRange: chooseDepthRange({
|
|
29
|
+
* nativeZeroToOne: true,
|
|
30
|
+
* floatDepth: true,
|
|
31
|
+
* }),
|
|
32
|
+
* width: 800,
|
|
33
|
+
* height: 600,
|
|
34
|
+
* });
|
|
35
|
+
* const ray = view.screenToRay(ray3Create(), 400, 300);
|
|
36
|
+
*/
|
|
37
|
+
export class View3 {
|
|
38
|
+
camera;
|
|
39
|
+
lens_;
|
|
40
|
+
depthRange_;
|
|
41
|
+
width_;
|
|
42
|
+
height_;
|
|
43
|
+
aspect_ = 1;
|
|
44
|
+
ownVersion_ = 0;
|
|
45
|
+
viewport_ = viewportOf(0, 0, 0, 0);
|
|
46
|
+
view_ = mat4x4Create();
|
|
47
|
+
projection_ = mat4x4Create();
|
|
48
|
+
viewProjection_ = mat4x4Create();
|
|
49
|
+
inverseViewProjection_ = mat4x4Create();
|
|
50
|
+
viewSeen_ = Number.NaN;
|
|
51
|
+
projectionSeen_ = Number.NaN;
|
|
52
|
+
projectionCameraSeen_ = Number.NaN;
|
|
53
|
+
viewProjectionValid_ = false;
|
|
54
|
+
inverseValid_ = false;
|
|
55
|
+
rayTransformValid_ = false;
|
|
56
|
+
viewTranspose_ = mat4x4Create();
|
|
57
|
+
inverseProjection_ = mat4x4Create();
|
|
58
|
+
/**
|
|
59
|
+
* @throws {RangeError} For a lens `mat4x4Perspective`/`mat4x4Orthographic`
|
|
60
|
+
* would refuse (a `"camera"` field of view the camera has none of
|
|
61
|
+
* included), an unknown depth range, or a negative or non-finite size.
|
|
62
|
+
*/
|
|
63
|
+
constructor(options) {
|
|
64
|
+
this.camera = options.camera;
|
|
65
|
+
this.width_ = checkSize_("width", options.width ?? 0);
|
|
66
|
+
this.height_ = checkSize_("height", options.height ?? 0);
|
|
67
|
+
this.aspect_ = aspectOf_(this.width_, this.height_);
|
|
68
|
+
lensProjection_(CHECK_, options.lens, options.camera.fovY, this.aspect_, options.depthRange);
|
|
69
|
+
this.lens_ = { ...options.lens };
|
|
70
|
+
this.depthRange_ = options.depthRange;
|
|
71
|
+
this.viewport_[2] = this.width_;
|
|
72
|
+
this.viewport_[3] = this.height_;
|
|
73
|
+
}
|
|
74
|
+
get lens() {
|
|
75
|
+
return this.lens_;
|
|
76
|
+
}
|
|
77
|
+
/** @throws {RangeError} As the constructor; nothing changes then. */
|
|
78
|
+
set lens(lens) {
|
|
79
|
+
lensProjection_(CHECK_, lens, this.camera.fovY, this.aspect_, this.depthRange_);
|
|
80
|
+
this.lens_ = { ...lens };
|
|
81
|
+
this.ownVersion_ += 1;
|
|
82
|
+
}
|
|
83
|
+
get depthRange() {
|
|
84
|
+
return this.depthRange_;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @throws {RangeError} For an unknown depth range, or one the lens cannot be
|
|
88
|
+
* built in; nothing changes then.
|
|
89
|
+
*/
|
|
90
|
+
set depthRange(range) {
|
|
91
|
+
lensProjection_(CHECK_, this.lens_, this.camera.fovY, this.aspect_, range);
|
|
92
|
+
this.depthRange_ = range;
|
|
93
|
+
this.ownVersion_ += 1;
|
|
94
|
+
}
|
|
95
|
+
get width() {
|
|
96
|
+
return this.width_;
|
|
97
|
+
}
|
|
98
|
+
get height() {
|
|
99
|
+
return this.height_;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Increases when the camera, the lens, the depth range or the viewport
|
|
103
|
+
* changes.
|
|
104
|
+
*/
|
|
105
|
+
get version() {
|
|
106
|
+
return this.ownVersion_ + this.camera.version;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @throws {RangeError} For a negative or non-finite size, or one the lens
|
|
110
|
+
* cannot be built for; nothing changes then.
|
|
111
|
+
*/
|
|
112
|
+
setViewport(width, height) {
|
|
113
|
+
checkSize_("width", width);
|
|
114
|
+
checkSize_("height", height);
|
|
115
|
+
if (width === this.width_ && height === this.height_) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const aspect = aspectOf_(width, height);
|
|
119
|
+
lensProjection_(CHECK_, this.lens_, this.camera.fovY, aspect, this.depthRange_);
|
|
120
|
+
this.width_ = width;
|
|
121
|
+
this.height_ = height;
|
|
122
|
+
this.aspect_ = aspect;
|
|
123
|
+
this.viewport_[2] = width;
|
|
124
|
+
this.viewport_[3] = height;
|
|
125
|
+
this.ownVersion_ += 1;
|
|
126
|
+
}
|
|
127
|
+
/** World → camera. */
|
|
128
|
+
get view() {
|
|
129
|
+
this.ensureView_();
|
|
130
|
+
return this.view_;
|
|
131
|
+
}
|
|
132
|
+
/** Camera → clip space, in the depth range. */
|
|
133
|
+
get projection() {
|
|
134
|
+
this.ensureProjection_();
|
|
135
|
+
return this.projection_;
|
|
136
|
+
}
|
|
137
|
+
get viewProjection() {
|
|
138
|
+
this.ensureViewProjection_();
|
|
139
|
+
return this.viewProjection_;
|
|
140
|
+
}
|
|
141
|
+
/** `NaN` throughout when the view-projection is not invertible. */
|
|
142
|
+
get inverseViewProjection() {
|
|
143
|
+
this.ensureInverse_();
|
|
144
|
+
return this.inverseViewProjection_;
|
|
145
|
+
}
|
|
146
|
+
getEye(out) {
|
|
147
|
+
return this.camera.getEye(out);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* [x px, y px, depth in the depth range]; `NaN` throughout for a point on or
|
|
151
|
+
* behind the eye (the eye plane, for an orthographic lens too).
|
|
152
|
+
*/
|
|
153
|
+
worldToScreen(out, point) {
|
|
154
|
+
this.ensureViewProjection_();
|
|
155
|
+
const behind = this.isBehindEye_(point[0], point[1], point[2]);
|
|
156
|
+
vec3ProjectToViewport(out, point, this.viewProjection_, this.viewport_);
|
|
157
|
+
if (behind) {
|
|
158
|
+
vec3Set(out, Number.NaN, Number.NaN, Number.NaN);
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Bulk, 3 numbers in and out per point (labels, anchors), `NaN` for a point
|
|
164
|
+
* on or behind the eye. O(n).
|
|
165
|
+
*
|
|
166
|
+
* @throws {RangeError} When the arrays differ in length or are not a multiple
|
|
167
|
+
* of 3.
|
|
168
|
+
*/
|
|
169
|
+
worldToScreenArray(out, points) {
|
|
170
|
+
this.ensureViewProjection_();
|
|
171
|
+
if (this.lens_.kind === "perspective") {
|
|
172
|
+
return vec3ArrayProjectToViewport(out, points, this.viewProjection_, this.viewport_);
|
|
173
|
+
}
|
|
174
|
+
if (points.length % 3 !== 0 || out.length !== points.length) {
|
|
175
|
+
throw new RangeError(`View3.worldToScreenArray: out has ${out.length} numbers for ${points.length} in points, which must be a multiple of 3.`);
|
|
176
|
+
}
|
|
177
|
+
// An orthographic projection never divides by a depth: the eye plane is checked per point.
|
|
178
|
+
for (let index = 0; index < points.length; index += 3) {
|
|
179
|
+
vec3Set(POINT_, points[index], points[index + 1], points[index + 2]);
|
|
180
|
+
this.worldToScreen(POINT_, POINT_);
|
|
181
|
+
out[index] = POINT_[0];
|
|
182
|
+
out[index + 1] = POINT_[1];
|
|
183
|
+
out[index + 2] = POINT_[2];
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The picking ray through a screen point: unprojected in camera space, then
|
|
189
|
+
* carried to the world by the camera's rigid transform, so a far-off eye
|
|
190
|
+
* costs no precision. `NaN` throughout when the viewport has no area or the
|
|
191
|
+
* projection is singular.
|
|
192
|
+
*/
|
|
193
|
+
screenToRay(out, x, y) {
|
|
194
|
+
this.ensureRayTransform_();
|
|
195
|
+
ray3FromViewport(RAY_, x, y, this.inverseProjection_, this.viewport_, this.depthRange_);
|
|
196
|
+
this.camera.getEye(EYE_);
|
|
197
|
+
vec3Set(POINT_, RAY_[0], RAY_[1], RAY_[2]);
|
|
198
|
+
vec3TransformDirectionMat4x4(POINT_, POINT_, this.viewTranspose_);
|
|
199
|
+
vec3Set(DIRECTION_, RAY_[3], RAY_[4], RAY_[5]);
|
|
200
|
+
vec3TransformDirectionMat4x4(DIRECTION_, DIRECTION_, this.viewTranspose_);
|
|
201
|
+
out[0] = EYE_[0] + POINT_[0];
|
|
202
|
+
out[1] = EYE_[1] + POINT_[1];
|
|
203
|
+
out[2] = EYE_[2] + POINT_[2];
|
|
204
|
+
out[3] = DIRECTION_[0];
|
|
205
|
+
out[4] = DIRECTION_[1];
|
|
206
|
+
out[5] = DIRECTION_[2];
|
|
207
|
+
return out;
|
|
208
|
+
}
|
|
209
|
+
/** Where that ray meets `plane`; false when parallel, behind or not a ray. */
|
|
210
|
+
screenToPlane(out, x, y, plane) {
|
|
211
|
+
this.screenToRay(PLANE_RAY_, x, y);
|
|
212
|
+
const distance = ray3IntersectPlane3(PLANE_RAY_, plane);
|
|
213
|
+
if (!Number.isFinite(distance)) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
ray3At(out, PLANE_RAY_, distance);
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
getFrustum(out) {
|
|
220
|
+
this.ensureViewProjection_();
|
|
221
|
+
return frustum3FromMat4x4(out, this.viewProjection_, this.depthRange_);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* World units one screen pixel spans at `point`'s depth (billboard sizes,
|
|
225
|
+
* orthographic pans): `NaN` for a point on or behind the eye plane under a
|
|
226
|
+
* perspective lens.
|
|
227
|
+
*/
|
|
228
|
+
worldUnitsPerPixel(point) {
|
|
229
|
+
this.ensureView_();
|
|
230
|
+
this.ensureProjection_();
|
|
231
|
+
const view = this.view_;
|
|
232
|
+
const depth = -(view[2] * point[0] +
|
|
233
|
+
view[6] * point[1] +
|
|
234
|
+
view[10] * point[2] +
|
|
235
|
+
view[14]);
|
|
236
|
+
if (this.lens_.kind === "perspective" && !(depth > 0)) {
|
|
237
|
+
return Number.NaN;
|
|
238
|
+
}
|
|
239
|
+
return unitsPerPixel_(this.lens_, this.projection_, depth, this.height_);
|
|
240
|
+
}
|
|
241
|
+
ensureView_() {
|
|
242
|
+
const cameraVersion = this.camera.version;
|
|
243
|
+
if (cameraVersion !== this.viewSeen_) {
|
|
244
|
+
this.camera.getView(this.view_);
|
|
245
|
+
this.viewSeen_ = cameraVersion;
|
|
246
|
+
this.viewProjectionValid_ = false;
|
|
247
|
+
this.inverseValid_ = false;
|
|
248
|
+
this.rayTransformValid_ = false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
ensureProjection_() {
|
|
252
|
+
const cameraVersion = this.camera.version;
|
|
253
|
+
if (this.ownVersion_ !== this.projectionSeen_ ||
|
|
254
|
+
(this.lens_.kind === "perspective" &&
|
|
255
|
+
this.lens_.fovY === "camera" &&
|
|
256
|
+
cameraVersion !== this.projectionCameraSeen_)) {
|
|
257
|
+
lensProjection_(this.projection_, this.lens_, this.camera.fovY, this.aspect_, this.depthRange_);
|
|
258
|
+
this.projectionSeen_ = this.ownVersion_;
|
|
259
|
+
this.projectionCameraSeen_ = cameraVersion;
|
|
260
|
+
this.viewProjectionValid_ = false;
|
|
261
|
+
this.inverseValid_ = false;
|
|
262
|
+
this.rayTransformValid_ = false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
ensureViewProjection_() {
|
|
266
|
+
this.ensureView_();
|
|
267
|
+
this.ensureProjection_();
|
|
268
|
+
if (!this.viewProjectionValid_) {
|
|
269
|
+
mat4x4Multiply(this.viewProjection_, this.projection_, this.view_);
|
|
270
|
+
this.viewProjectionValid_ = true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
isBehindEye_(x, y, z) {
|
|
274
|
+
const view = this.view_;
|
|
275
|
+
return (this.lens_.kind === "orthographic" &&
|
|
276
|
+
view[2] * x + view[6] * y + view[10] * z + view[14] >= 0);
|
|
277
|
+
}
|
|
278
|
+
ensureRayTransform_() {
|
|
279
|
+
this.ensureView_();
|
|
280
|
+
this.ensureProjection_();
|
|
281
|
+
if (!this.rayTransformValid_) {
|
|
282
|
+
mat4x4Transpose(this.viewTranspose_, this.view_);
|
|
283
|
+
if (!mat4x4Invert(this.inverseProjection_, this.projection_)) {
|
|
284
|
+
this.inverseProjection_.fill(Number.NaN);
|
|
285
|
+
}
|
|
286
|
+
this.rayTransformValid_ = true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
ensureInverse_() {
|
|
290
|
+
this.ensureViewProjection_();
|
|
291
|
+
if (!this.inverseValid_) {
|
|
292
|
+
if (!mat4x4Invert(this.inverseViewProjection_, this.viewProjection_)) {
|
|
293
|
+
this.inverseViewProjection_.fill(Number.NaN);
|
|
294
|
+
}
|
|
295
|
+
this.inverseValid_ = true;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function aspectOf_(width, height) {
|
|
300
|
+
return width > 0 && height > 0 ? width / height : 1;
|
|
301
|
+
}
|
|
302
|
+
function checkSize_(name, value) {
|
|
303
|
+
assertNonNegative(value, name);
|
|
304
|
+
return value;
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=view3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view3.js","sourceRoot":"","sources":["../../src/view3/view3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iB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;IACF,CAAC;CACD;AAED,SAAS,SAAS,CAAC,KAAa,EAAE,MAAc;IAC/C,OAAO,KAAK,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,KAAa;IAC9C,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC/B,OAAO,KAAK,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ac-kit/graphics-view",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "2D views and 3D cameras with screen ↔ world conversions and picking rays, and their pointer, wheel and keyboard bindings.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"2d-view",
|
|
7
|
+
"camera",
|
|
8
|
+
"graphics",
|
|
9
|
+
"look-around-camera",
|
|
10
|
+
"orbit-camera",
|
|
11
|
+
"picking-ray",
|
|
12
|
+
"zoom-pan"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://anthochamp.pages.grenadine.io/node-essentials/api/graphics-view/",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://git.grenadine.io/anthochamp/node-essentials/issues"
|
|
17
|
+
},
|
|
18
|
+
"license": "BSD-3-Clause",
|
|
19
|
+
"author": "Anthony Champagne <dev@anthonychampagne.fr>",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://git.grenadine.io/anthochamp/node-essentials.git",
|
|
23
|
+
"directory": "packages/graphics-view"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": "./dist/index.js",
|
|
33
|
+
"./dom": "./dist/dom/index.js"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"main": "./dist/index.js",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": "./dist/index.js",
|
|
39
|
+
"./dom": "./dist/dom/index.js"
|
|
40
|
+
},
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"compile": "tsc -p ./tsconfig.build.json -outDir dist",
|
|
45
|
+
"compile:check": "tsc -noEmit -p ./tsconfig.json",
|
|
46
|
+
"clean": "rimraf dist",
|
|
47
|
+
"build": "yarn clean && yarn compile",
|
|
48
|
+
"test": "yarn run -T vitest run",
|
|
49
|
+
"test:browser": "yarn run -T vitest run --config vitest.browser.config.ts",
|
|
50
|
+
"prepack": "yarn build"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@ac-kit/browser": "^0.3.0",
|
|
54
|
+
"@ac-kit/core": "^0.12.0",
|
|
55
|
+
"@ac-kit/math-geometry": "^0.3.0",
|
|
56
|
+
"@ac-kit/math-linear": "^0.3.0",
|
|
57
|
+
"@ac-kit/math-scalar": "^0.3.0",
|
|
58
|
+
"@ac-kit/ui-gesture": "^0.1.0",
|
|
59
|
+
"@types/web": "^0.0.367"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@ac-kit/math-random": "0.4.0",
|
|
63
|
+
"@ac-kit/tsconfig": "0.1.0",
|
|
64
|
+
"@ac-kit/typedoc-config": "0.1.0",
|
|
65
|
+
"@ac-kit/vitest-config": "0.2.0",
|
|
66
|
+
"@typescript/native": "typescript@7.0.2",
|
|
67
|
+
"@vitest/browser-playwright": "5.1.1",
|
|
68
|
+
"happy-dom": "21.0.4",
|
|
69
|
+
"playwright": "1.65.1",
|
|
70
|
+
"rimraf": "6.1.4",
|
|
71
|
+
"typedoc": "0.28.20",
|
|
72
|
+
"typescript": "@typescript/typescript6@6.0.2",
|
|
73
|
+
"vite": "8.4.0",
|
|
74
|
+
"vitest": "5.1.2"
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=24"
|
|
78
|
+
}
|
|
6
79
|
}
|