@flighthq/camera 0.2.1-next.423.3350e53 → 0.2.1-next.448.afbdd31
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/dist/basis.d.ts +5 -5
- package/dist/basis.d.ts.map +1 -1
- package/dist/basis.js +4 -4
- package/dist/basis.js.map +1 -1
- package/dist/camera.d.ts +10 -9
- package/dist/camera.d.ts.map +1 -1
- package/dist/camera.js +24 -10
- package/dist/camera.js.map +1 -1
- package/dist/camera2d.d.ts +3 -0
- package/dist/camera2d.d.ts.map +1 -0
- package/dist/camera2d.js +15 -0
- package/dist/camera2d.js.map +1 -0
- package/dist/culling.d.ts +5 -5
- package/dist/culling.d.ts.map +1 -1
- package/dist/culling.js +10 -10
- package/dist/culling.js.map +1 -1
- package/dist/depth.d.ts +3 -3
- package/dist/depth.d.ts.map +1 -1
- package/dist/depth.js +4 -4
- package/dist/depth.js.map +1 -1
- package/dist/frustumCorners.d.ts +2 -2
- package/dist/frustumCorners.d.ts.map +1 -1
- package/dist/frustumCorners.js +3 -3
- package/dist/frustumCorners.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/intersection.d.ts +3 -3
- package/dist/intersection.d.ts.map +1 -1
- package/dist/intersection.js +6 -6
- package/dist/intersection.js.map +1 -1
- package/dist/parallax.d.ts +3 -0
- package/dist/parallax.d.ts.map +1 -0
- package/dist/parallax.js +23 -0
- package/dist/parallax.js.map +1 -0
- package/dist/picking.d.ts +3 -3
- package/dist/picking.d.ts.map +1 -1
- package/dist/picking.js +5 -5
- package/dist/picking.js.map +1 -1
- package/dist/projection.js +3 -3
- package/dist/projection.js.map +1 -1
- package/dist/projection2d.d.ts +4 -0
- package/dist/projection2d.d.ts.map +1 -0
- package/dist/projection2d.js +17 -0
- package/dist/projection2d.js.map +1 -0
- package/dist/shadowCamera.d.ts +2 -2
- package/dist/shadowCamera.d.ts.map +1 -1
- package/dist/shadowCamera.js +4 -4
- package/dist/shadowCamera.js.map +1 -1
- package/dist/viewMatrix.d.ts +3 -0
- package/dist/viewMatrix.d.ts.map +1 -0
- package/dist/viewMatrix.js +19 -0
- package/dist/viewMatrix.js.map +1 -0
- package/dist/visibleBounds.d.ts +3 -0
- package/dist/visibleBounds.d.ts.map +1 -0
- package/dist/visibleBounds.js +16 -0
- package/dist/visibleBounds.js.map +1 -0
- package/dist/zoom.d.ts +3 -0
- package/dist/zoom.d.ts.map +1 -0
- package/dist/zoom.js +19 -0
- package/dist/zoom.js.map +1 -0
- package/package.json +5 -5
- package/src/basis.test.ts +19 -19
- package/src/camera.test.ts +62 -42
- package/src/camera2d.test.ts +23 -0
- package/src/culling.test.ts +21 -16
- package/src/depth.test.ts +14 -14
- package/src/frustumCorners.test.ts +9 -9
- package/src/intersection.test.ts +17 -17
- package/src/parallax.test.ts +31 -0
- package/src/picking.test.ts +20 -20
- package/src/projection2d.test.ts +58 -0
- package/src/shadowCamera.test.ts +7 -7
- package/src/viewMatrix.test.ts +48 -0
- package/src/visibleBounds.test.ts +54 -0
- package/src/zoom.test.ts +39 -0
package/dist/basis.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
1
|
+
import type { Camera3D, Vector3Like } from '@flighthq/types';
|
|
2
|
+
export declare function getCamera3DForward(out: Vector3Like, camera: Readonly<Camera3D>): void;
|
|
3
|
+
export declare function getCamera3DPosition(out: Vector3Like, camera: Readonly<Camera3D>): void;
|
|
4
|
+
export declare function getCamera3DRight(out: Vector3Like, camera: Readonly<Camera3D>): void;
|
|
5
|
+
export declare function getCamera3DUp(out: Vector3Like, camera: Readonly<Camera3D>): void;
|
|
6
6
|
//# sourceMappingURL=basis.d.ts.map
|
package/dist/basis.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basis.d.ts","sourceRoot":"","sources":["../src/basis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"basis.d.ts","sourceRoot":"","sources":["../src/basis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAO7D,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CAOrF;AAWD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CA2BtF;AAMD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CAKnF;AAMD,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG,IAAI,CAKhF"}
|
package/dist/basis.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// from the eye toward the target; it is the negated third row of the view matrix.
|
|
4
4
|
//
|
|
5
5
|
// Safe when `out` aliases any field of the camera.
|
|
6
|
-
export function
|
|
6
|
+
export function getCamera3DForward(out, camera) {
|
|
7
7
|
const m = camera.view.m;
|
|
8
8
|
// Row 2 of the view matrix is the negated forward direction in world space.
|
|
9
9
|
// Negate to get the true forward (eye→target).
|
|
@@ -20,7 +20,7 @@ export function getCameraForward(out, camera) {
|
|
|
20
20
|
// (setGlMeshCameraPosition) should delegate here rather than recomputing it inline.
|
|
21
21
|
//
|
|
22
22
|
// Safe when `out` aliases any field of the camera.
|
|
23
|
-
export function
|
|
23
|
+
export function getCamera3DPosition(out, camera) {
|
|
24
24
|
const m = camera.view.m;
|
|
25
25
|
// Column-major storage: element(row, col) = m[row + 4*col].
|
|
26
26
|
// The 3×3 rotation block R^T (transposed) has rows:
|
|
@@ -44,7 +44,7 @@ export function getCameraPosition(out, camera) {
|
|
|
44
44
|
// matrix and writes it into `out`. It is the first row of the view matrix.
|
|
45
45
|
//
|
|
46
46
|
// Safe when `out` aliases any field of the camera.
|
|
47
|
-
export function
|
|
47
|
+
export function getCamera3DRight(out, camera) {
|
|
48
48
|
const m = camera.view.m;
|
|
49
49
|
out.x = m[0];
|
|
50
50
|
out.y = m[4];
|
|
@@ -54,7 +54,7 @@ export function getCameraRight(out, camera) {
|
|
|
54
54
|
// matrix and writes it into `out`. It is the second row of the view matrix.
|
|
55
55
|
//
|
|
56
56
|
// Safe when `out` aliases any field of the camera.
|
|
57
|
-
export function
|
|
57
|
+
export function getCamera3DUp(out, camera) {
|
|
58
58
|
const m = camera.view.m;
|
|
59
59
|
out.x = m[1];
|
|
60
60
|
out.y = m[5];
|
package/dist/basis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basis.js","sourceRoot":"","sources":["../src/basis.ts"],"names":[],"mappings":"AAEA,6FAA6F;AAC7F,4FAA4F;AAC5F,kFAAkF;AAClF,EAAE;AACF,mDAAmD;AACnD,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"basis.js","sourceRoot":"","sources":["../src/basis.ts"],"names":[],"mappings":"AAEA,6FAA6F;AAC7F,4FAA4F;AAC5F,kFAAkF;AAClF,EAAE;AACF,mDAAmD;AACnD,MAAM,UAAU,kBAAkB,CAAC,GAAgB,EAAE,MAA0B;IAC7E,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACxB,4EAA4E;IAC5E,+CAA+C;IAC/C,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACd,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACd,GAAG,CAAC,CAAC,GAAG,CAAC,CAA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AG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,2FAA2F;AAC3F,2EAA2E;AAC3E,EAAE;AACF,mDAAmD;AACnD,MAAM,UAAU,gBAAgB,CAAC,GAAgB,EAAE,MAA0B;IAC3E,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACxB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACb,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACb,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACf,CAAC;AAED,wFAAwF;AACxF,4EAA4E;AAC5E,EAAE;AACF,mDAAmD;AACnD,MAAM,UAAU,aAAa,CAAC,GAAgB,EAAE,MAA0B;IACxE,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACxB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACb,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACb,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACf,CAAC"}
|
package/dist/camera.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export
|
|
1
|
+
import type { Camera3D, Matrix4Like, Projection, Vector3Like } from '@flighthq/types';
|
|
2
|
+
export declare function createCamera3D(opts: Readonly<Camera3DOptions>): Camera3D;
|
|
3
|
+
export declare function getCamera3DInverseViewProjectionMatrix4(out: Matrix4Like, camera: Readonly<Camera3D>, aspect: number): boolean;
|
|
4
|
+
export declare function getCamera3DViewProjectionMatrix4(out: Matrix4Like, camera: Readonly<Camera3D>, aspect: number): void;
|
|
5
|
+
export declare function setCamera3DAspect(camera: Camera3D, aspect: number): void;
|
|
6
|
+
export declare function setCamera3DJitter(camera: Camera3D, x: number, y: number): void;
|
|
7
|
+
export declare function setCamera3DViewMatrix4FromLookAt(camera: Camera3D, eye: Readonly<Vector3Like>, target: Readonly<Vector3Like>, up: Readonly<Vector3Like>): void;
|
|
8
|
+
export declare function setCamera3DViewMatrix4FromMatrix4(camera: Camera3D, view: Readonly<Matrix4Like>): void;
|
|
9
|
+
export declare function updateCamera3DInverseViewProjection(camera: Camera3D, aspect: number): boolean;
|
|
10
|
+
export interface Camera3DOptions {
|
|
10
11
|
far: number;
|
|
11
12
|
near: number;
|
|
12
13
|
projection: Projection;
|
package/dist/camera.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAUtF,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,QAAQ,CASxE;AAUD,wBAAgB,uCAAuC,CACrD,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC1B,MAAM,EAAE,MAAM,GACb,OAAO,CAGT;AAQD,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAGnH;AAQD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAOxE;AAID,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAG9E;AAOD,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,QAAQ,EAChB,GAAG,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC1B,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC7B,EAAE,EAAE,QAAQ,CAAC,WAAW,CAAC,GACxB,IAAI,CAEN;AAID,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAErG;AAQD,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAO7F;AAGD,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;CACxB"}
|
package/dist/camera.js
CHANGED
|
@@ -7,7 +7,7 @@ import { setProjectionMatrix4 } from './projection';
|
|
|
7
7
|
// `inverseViewProjection` (consumed by TAA / velocity / fog / depth-of-field, initialized to
|
|
8
8
|
// identity). The view matrix is canonical: the camera has no separate Transform3D — a Matrix4 is
|
|
9
9
|
// the only world->view representation.
|
|
10
|
-
export function
|
|
10
|
+
export function createCamera3D(opts) {
|
|
11
11
|
return createEntity({
|
|
12
12
|
far: opts.far,
|
|
13
13
|
inverseViewProjection: createMatrix4(),
|
|
@@ -24,9 +24,9 @@ export function createCamera(opts) {
|
|
|
24
24
|
//
|
|
25
25
|
// Reads camera fields into a scratch matrix before writing `out`, so it is safe even if `out`
|
|
26
26
|
// aliases the camera's own `inverseViewProjection` or `view`. Use
|
|
27
|
-
// `
|
|
28
|
-
export function
|
|
29
|
-
|
|
27
|
+
// `updateCamera3DInverseViewProjection` instead to safely update the cached field.
|
|
28
|
+
export function getCamera3DInverseViewProjectionMatrix4(out, camera, aspect) {
|
|
29
|
+
getCamera3DViewProjectionMatrix4(__scratchViewProjection, camera, aspect);
|
|
30
30
|
return inverseMatrix4(out, __scratchViewProjection);
|
|
31
31
|
}
|
|
32
32
|
// Writes the camera's view-projection matrix (projection × view) into `out`. `aspect` is the
|
|
@@ -35,13 +35,27 @@ export function getCameraInverseViewProjectionMatrix4(out, camera, aspect) {
|
|
|
35
35
|
//
|
|
36
36
|
// Reads camera fields into a scratch matrix before writing `out`, so it is safe even if `out`
|
|
37
37
|
// aliases the camera's own `view`.
|
|
38
|
-
export function
|
|
38
|
+
export function getCamera3DViewProjectionMatrix4(out, camera, aspect) {
|
|
39
39
|
setProjectionMatrix4(__scratchProjection, camera.projection, aspect, camera.near, camera.far);
|
|
40
40
|
multiplyMatrix4(out, __scratchProjection, camera.view);
|
|
41
41
|
}
|
|
42
|
+
// Sets the viewport aspect ratio (width / height) on the camera's projection, in place. For a
|
|
43
|
+
// perspective projection this writes `aspect` directly; for an orthographic projection it widens
|
|
44
|
+
// the view volume to match — keeping `halfHeight` and setting `halfWidth = halfHeight * aspect`,
|
|
45
|
+
// so the vertical extent is preserved as the viewport resizes. The authored counterpart to the
|
|
46
|
+
// `aspect` argument `getCamera3DViewProjectionMatrix4` takes: set it once on resize rather than
|
|
47
|
+
// reaching into `camera.projection` with a cast.
|
|
48
|
+
export function setCamera3DAspect(camera, aspect) {
|
|
49
|
+
const projection = camera.projection;
|
|
50
|
+
if (projection.kind === 'perspective') {
|
|
51
|
+
projection.aspect = aspect;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
projection.halfWidth = projection.halfHeight * aspect;
|
|
55
|
+
}
|
|
42
56
|
// Sets the camera's per-frame sub-pixel jitter offset (in NDC), in place. TAA reads this when
|
|
43
57
|
// building the jittered projection matrix.
|
|
44
|
-
export function
|
|
58
|
+
export function setCamera3DJitter(camera, x, y) {
|
|
45
59
|
camera.jitter.x = x;
|
|
46
60
|
camera.jitter.y = y;
|
|
47
61
|
}
|
|
@@ -50,12 +64,12 @@ export function setCameraJitter(camera, x, y) {
|
|
|
50
64
|
// explicit world transform.
|
|
51
65
|
//
|
|
52
66
|
// Reads all vector inputs before writing, so it is safe when the vectors alias one another.
|
|
53
|
-
export function
|
|
67
|
+
export function setCamera3DViewMatrix4FromLookAt(camera, eye, target, up) {
|
|
54
68
|
setMatrix4LookAt(camera.view, eye, target, up);
|
|
55
69
|
}
|
|
56
70
|
// Copies a precomputed world->view matrix into the camera in place. Use this when the view matrix
|
|
57
71
|
// is derived elsewhere (for example, the inverse of a scene node's world transform).
|
|
58
|
-
export function
|
|
72
|
+
export function setCamera3DViewMatrix4FromMatrix4(camera, view) {
|
|
59
73
|
camera.view.m.set(view.m);
|
|
60
74
|
}
|
|
61
75
|
// Recomputes and stores the inverse view-projection into camera.inverseViewProjection for the
|
|
@@ -64,9 +78,9 @@ export function setCameraViewMatrix4FromMatrix4(camera, view) {
|
|
|
64
78
|
//
|
|
65
79
|
// Call this once per frame after setting the view matrix and before any effects that read
|
|
66
80
|
// camera.inverseViewProjection (TAA, velocity, fog, depth-of-field).
|
|
67
|
-
export function
|
|
81
|
+
export function updateCamera3DInverseViewProjection(camera, aspect) {
|
|
68
82
|
// Write into a scratch first so the cache is never clobbered with NaN on failure.
|
|
69
|
-
const ok =
|
|
83
|
+
const ok = getCamera3DInverseViewProjectionMatrix4(__scratchInverse, camera, aspect);
|
|
70
84
|
if (ok) {
|
|
71
85
|
camera.inverseViewProjection.m.set(__scratchInverse.m);
|
|
72
86
|
}
|
package/dist/camera.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,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AAC,MAAgB,EAAE,IAA2B;IAC7F,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED,8FAA8F;AAC9F,gGAAgG;AAChG,gEAAgE;AAChE,EAAE;AACF,0FAA0F;AAC1F,qEAAqE;AACrE,MAAM,UAAU,mCAAmC,CAAC,MAAgB,EAAE,MAAc;IAClF,kFAAkF;IAClF,MAAM,EAAE,GAAG,uCAAuC,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrF,IAAI,EAAE,EAAE,CAAC;QACP,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AASD,2FAA2F;AAC3F,MAAM,gBAAgB,GAAG,aAAa,EAAE,CAAC;AACzC,MAAM,mBAAmB,GAAG,aAAa,EAAE,CAAC;AAC5C,MAAM,uBAAuB,GAAG,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera2d.d.ts","sourceRoot":"","sources":["../src/camera2d.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMjE,wBAAgB,cAAc,CAC5B,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,GAClC,QAAQ,CASV"}
|
package/dist/camera2d.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Allocates a plain-data 2D camera over a `viewportWidth` x `viewportHeight` surface. The camera
|
|
2
|
+
// starts centered on world origin at zoom 1 with no rotation; `options` overrides any of `x`, `y`,
|
|
3
|
+
// `zoom`, `rotation`. This is the only allocating function in the package — every other operation
|
|
4
|
+
// writes into an `out` parameter.
|
|
5
|
+
export function createCamera2D(viewportWidth, viewportHeight, options) {
|
|
6
|
+
return {
|
|
7
|
+
rotation: options?.rotation ?? 0,
|
|
8
|
+
viewportHeight,
|
|
9
|
+
viewportWidth,
|
|
10
|
+
x: options?.x ?? 0,
|
|
11
|
+
y: options?.y ?? 0,
|
|
12
|
+
zoom: options?.zoom ?? 1,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=camera2d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camera2d.js","sourceRoot":"","sources":["../src/camera2d.ts"],"names":[],"mappings":"AAEA,iGAAiG;AACjG,mGAAmG;AACnG,kGAAkG;AAClG,kCAAkC;AAClC,MAAM,UAAU,cAAc,CAC5B,aAAqB,EACrB,cAAsB,EACtB,OAAmC;IAEnC,OAAO;QACL,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,CAAC;QAChC,cAAc;QACd,aAAa;QACb,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC;QAClB,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC;QAClB,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC;KACzB,CAAC;AACJ,CAAC"}
|
package/dist/culling.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { AabbLike, BoundingSphereLike,
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
1
|
+
import type { AabbLike, BoundingSphereLike, Camera3D, FrustumLike, Vector3Like } from '@flighthq/types';
|
|
2
|
+
export declare function getCamera3DFrustum(out: FrustumLike, camera: Readonly<Camera3D>, aspect: number): void;
|
|
3
|
+
export declare function isBoxInCamera3DFrustum(camera: Readonly<Camera3D>, aabb: Readonly<AabbLike>, aspect: number): boolean;
|
|
4
|
+
export declare function isPointInCamera3DFrustum(camera: Readonly<Camera3D>, point: Readonly<Vector3Like>, aspect: number): boolean;
|
|
5
|
+
export declare function isSphereInCamera3DFrustum(camera: Readonly<Camera3D>, sphere: Readonly<BoundingSphereLike>, aspect: number): boolean;
|
|
6
6
|
//# sourceMappingURL=culling.d.ts.map
|
package/dist/culling.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"culling.d.ts","sourceRoot":"","sources":["../src/culling.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"culling.d.ts","sourceRoot":"","sources":["../src/culling.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAYxG,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAGrG;AAOD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAGpH;AAID,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC1B,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC5B,MAAM,EAAE,MAAM,GACb,OAAO,CAGT;AAID,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC1B,MAAM,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACpC,MAAM,EAAE,MAAM,GACb,OAAO,CAGT"}
|
package/dist/culling.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { createFrustum, createMatrix4, isFrustumContainingPoint, isFrustumIntersectingAabb, isFrustumIntersectingSphere, setFrustumFromMatrix4, } from '@flighthq/geometry';
|
|
2
|
-
import {
|
|
2
|
+
import { getCamera3DViewProjectionMatrix4 } from './camera';
|
|
3
3
|
// Extracts the six clip planes of the camera's view frustum into `out` and returns true.
|
|
4
4
|
// The planes are normalized with inward-pointing normals (the convention used by geometry's
|
|
5
5
|
// isFrustumContainingPoint / isFrustumIntersectingAabb / isFrustumIntersectingSphere).
|
|
6
6
|
// `aspect` is viewport width / height.
|
|
7
7
|
//
|
|
8
8
|
// Use this when you need the raw planes (e.g. to cache the frustum for a frame). For one-shot
|
|
9
|
-
// culling queries prefer the
|
|
9
|
+
// culling queries prefer the isBoxInCamera3DFrustum / isSphereInCamera3DFrustum / isPointInCamera3DFrustum
|
|
10
10
|
// helpers which reuse a single scratch frustum.
|
|
11
|
-
export function
|
|
12
|
-
|
|
11
|
+
export function getCamera3DFrustum(out, camera, aspect) {
|
|
12
|
+
getCamera3DViewProjectionMatrix4(__scratchViewProjection, camera, aspect);
|
|
13
13
|
setFrustumFromMatrix4(out, __scratchViewProjection);
|
|
14
14
|
}
|
|
15
15
|
// Returns true when an axis-aligned bounding box intersects or is contained by the camera
|
|
@@ -17,20 +17,20 @@ export function getCameraFrustum(out, camera, aspect) {
|
|
|
17
17
|
//
|
|
18
18
|
// Uses the same conservative positive-vertex test as geometry's isFrustumIntersectingAabb:
|
|
19
19
|
// may report false positives for boxes straddling a frustum corner, never false negatives.
|
|
20
|
-
export function
|
|
21
|
-
|
|
20
|
+
export function isBoxInCamera3DFrustum(camera, aabb, aspect) {
|
|
21
|
+
getCamera3DFrustum(__scratchFrustum, camera, aspect);
|
|
22
22
|
return isFrustumIntersectingAabb(__scratchFrustum, aabb);
|
|
23
23
|
}
|
|
24
24
|
// Returns true when a world-space point lies inside the camera frustum.
|
|
25
25
|
// `aspect` is viewport width / height.
|
|
26
|
-
export function
|
|
27
|
-
|
|
26
|
+
export function isPointInCamera3DFrustum(camera, point, aspect) {
|
|
27
|
+
getCamera3DFrustum(__scratchFrustum, camera, aspect);
|
|
28
28
|
return isFrustumContainingPoint(__scratchFrustum, point);
|
|
29
29
|
}
|
|
30
30
|
// Returns true when a bounding sphere intersects or is contained by the camera frustum.
|
|
31
31
|
// An empty sphere (negative radius) always returns false. `aspect` is viewport width / height.
|
|
32
|
-
export function
|
|
33
|
-
|
|
32
|
+
export function isSphereInCamera3DFrustum(camera, sphere, aspect) {
|
|
33
|
+
getCamera3DFrustum(__scratchFrustum, camera, aspect);
|
|
34
34
|
return isFrustumIntersectingSphere(__scratchFrustum, sphere);
|
|
35
35
|
}
|
|
36
36
|
// Scratch objects reused across calls. Single-threaded; not re-entrant.
|
package/dist/culling.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"culling.js","sourceRoot":"","sources":["../src/culling.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"culling.js","sourceRoot":"","sources":["../src/culling.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,aAAa,EACb,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAE5D,yFAAyF;AACzF,4FAA4F;AAC5F,uFAAuF;AACvF,uCAAuC;AACvC,EAAE;AACF,8FAA8F;AAC9F,2GAA2G;AAC3G,gDAAgD;AAChD,MAAM,UAAU,kBAAkB,CAAC,GAAgB,EAAE,MAA0B,EAAE,MAAc;IAC7F,gCAAgC,CAAC,uBAAuB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1E,qBAAqB,CAAC,GAAG,EAAE,uBAAuB,CAAC,CAAC;AACtD,CAAC;AAED,0FAA0F;AAC1F,6FAA6F;AAC7F,EAAE;AACF,2FAA2F;AAC3F,2FAA2F;AAC3F,MAAM,UAAU,sBAAsB,CAAC,MAA0B,EAAE,IAAwB,EAAE,MAAc;IACzG,kBAAkB,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,yBAAyB,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC;AAED,wEAAwE;AACxE,uCAAuC;AACvC,MAAM,UAAU,wBAAwB,CACtC,MAA0B,EAC1B,KAA4B,EAC5B,MAAc;IAEd,kBAAkB,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,wBAAwB,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,wFAAwF;AACxF,+FAA+F;AAC/F,MAAM,UAAU,yBAAyB,CACvC,MAA0B,EAC1B,MAAoC,EACpC,MAAc;IAEd,kBAAkB,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,OAAO,2BAA2B,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAC/D,CAAC;AAED,wEAAwE;AACxE,MAAM,uBAAuB,GAAG,aAAa,EAAE,CAAC;AAChD,MAAM,gBAAgB,GAAG,aAAa,EAAE,CAAC"}
|
package/dist/depth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
1
|
+
import type { Camera3D } from '@flighthq/types';
|
|
2
|
+
export declare function getCamera3DLinearDepth(camera: Readonly<Camera3D>, ndcZ: number): number;
|
|
3
|
+
export declare function getCamera3DViewSpaceZ(camera: Readonly<Camera3D>, ndcZ: number): number;
|
|
4
4
|
//# sourceMappingURL=depth.d.ts.map
|
package/dist/depth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depth.d.ts","sourceRoot":"","sources":["../src/depth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"depth.d.ts","sourceRoot":"","sources":["../src/depth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAchD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAiBvF;AAOD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtF"}
|
package/dist/depth.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// mathematically — no explicit clamp is applied; callers should supply valid NDC depths.
|
|
11
11
|
//
|
|
12
12
|
// Returns 0 when `near` equals `far` (degenerate clip range).
|
|
13
|
-
export function
|
|
13
|
+
export function getCamera3DLinearDepth(camera, ndcZ) {
|
|
14
14
|
const near = camera.near;
|
|
15
15
|
const far = camera.far;
|
|
16
16
|
const range = far - near;
|
|
@@ -29,11 +29,11 @@ export function getCameraLinearDepth(camera, ndcZ) {
|
|
|
29
29
|
return (2 * far * near) / denominator;
|
|
30
30
|
}
|
|
31
31
|
// Converts a raw NDC depth value (ndcZ ∈ [-1, 1]) to a positive linear depth in [near, far] —
|
|
32
|
-
// the distance along the camera's view axis. This is the unsigned version of
|
|
32
|
+
// the distance along the camera's view axis. This is the unsigned version of getCamera3DLinearDepth,
|
|
33
33
|
// useful for fog and SSAO where a positive scalar distance is needed rather than a signed Z.
|
|
34
34
|
//
|
|
35
35
|
// Returns 0 when `near` equals `far` (degenerate clip range).
|
|
36
|
-
export function
|
|
37
|
-
return -
|
|
36
|
+
export function getCamera3DViewSpaceZ(camera, ndcZ) {
|
|
37
|
+
return -getCamera3DLinearDepth(camera, ndcZ);
|
|
38
38
|
}
|
|
39
39
|
//# sourceMappingURL=depth.js.map
|
package/dist/depth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depth.js","sourceRoot":"","sources":["../src/depth.ts"],"names":[],"mappings":"AAEA,gGAAgG;AAChG,kGAAkG;AAClG,oGAAoG;AACpG,EAAE;AACF,mGAAmG;AACnG,iGAAiG;AACjG,+DAA+D;AAC/D,EAAE;AACF,+FAA+F;AAC/F,yFAAyF;AACzF,EAAE;AACF,8DAA8D;AAC9D,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"depth.js","sourceRoot":"","sources":["../src/depth.ts"],"names":[],"mappings":"AAEA,gGAAgG;AAChG,kGAAkG;AAClG,oGAAoG;AACpG,EAAE;AACF,mGAAmG;AACnG,iGAAiG;AACjG,+DAA+D;AAC/D,EAAE;AACF,+FAA+F;AAC/F,yFAAyF;AACzF,EAAE;AACF,8DAA8D;AAC9D,MAAM,UAAU,sBAAsB,CAAC,MAA0B,EAAE,IAAY;IAC7E,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC;IACvB,MAAM,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC;IACzB,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,+EAA+E;IAC/E,8CAA8C;IAC9C,mFAAmF;IACnF,qBAAqB;IACrB,sEAAsE;IACtE,MAAM,WAAW,GAAG,IAAI,GAAG,KAAK,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IAChD,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,WAAW,CAAC;AACxC,CAAC;AAED,8FAA8F;AAC9F,qGAAqG;AACrG,6FAA6F;AAC7F,EAAE;AACF,8DAA8D;AAC9D,MAAM,UAAU,qBAAqB,CAAC,MAA0B,EAAE,IAAY;IAC5E,OAAO,CAAC,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC"}
|
package/dist/frustumCorners.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
1
|
+
import type { Camera3D, Vector3Like } from '@flighthq/types';
|
|
2
|
+
export declare function getCamera3DFrustumCorners(out: [Vector3Like, Vector3Like, Vector3Like, Vector3Like, Vector3Like, Vector3Like, Vector3Like, Vector3Like], camera: Readonly<Camera3D>, aspect: number): boolean;
|
|
3
3
|
//# sourceMappingURL=frustumCorners.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frustumCorners.d.ts","sourceRoot":"","sources":["../src/frustumCorners.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"frustumCorners.d.ts","sourceRoot":"","sources":["../src/frustumCorners.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAoB7D,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,EAC7G,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC1B,MAAM,EAAE,MAAM,GACb,OAAO,CAyCT"}
|
package/dist/frustumCorners.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createMatrix4, inverseMatrix4 } from '@flighthq/geometry';
|
|
2
|
-
import {
|
|
2
|
+
import { getCamera3DViewProjectionMatrix4 } from './camera';
|
|
3
3
|
// Writes the 8 world-space corners of the camera frustum into `out` (a length-8 array of
|
|
4
4
|
// Vector3Like) and returns true. Returns false (leaving `out` untouched) when the
|
|
5
5
|
// view-projection is non-invertible. `aspect` is viewport width / height.
|
|
@@ -16,8 +16,8 @@ import { getCameraViewProjectionMatrix4 } from './camera';
|
|
|
16
16
|
//
|
|
17
17
|
// Needed for cascaded shadow maps, debug draw, and tight bounds fitting.
|
|
18
18
|
// Reads all inputs before writing any `out` element, so it is alias-safe.
|
|
19
|
-
export function
|
|
20
|
-
|
|
19
|
+
export function getCamera3DFrustumCorners(out, camera, aspect) {
|
|
20
|
+
getCamera3DViewProjectionMatrix4(__scratchViewProjection, camera, aspect);
|
|
21
21
|
if (!inverseMatrix4(__scratchInverseVP, __scratchViewProjection)) {
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frustumCorners.js","sourceRoot":"","sources":["../src/frustumCorners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"frustumCorners.js","sourceRoot":"","sources":["../src/frustumCorners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAE5D,yFAAyF;AACzF,kFAAkF;AAClF,0EAA0E;AAC1E,EAAE;AACF,6DAA6D;AAC7D,qCAAqC;AACrC,sCAAsC;AACtC,kCAAkC;AAClC,mCAAmC;AACnC,oCAAoC;AACpC,qCAAqC;AACrC,iCAAiC;AACjC,kCAAkC;AAClC,EAAE;AACF,yEAAyE;AACzE,0EAA0E;AAC1E,MAAM,UAAU,yBAAyB,CACvC,GAA6G,EAC7G,MAA0B,EAC1B,MAAc;IAEd,gCAAgC,CAAC,uBAAuB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1E,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,EAAE,CAAC;QACjE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,CAAC,GAAG,kBAAkB,CAAC,CAA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C,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACpD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACtD,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;YACb,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;YACpB,EAAE,IAAI,IAAI,CAAC;YACX,EAAE,IAAI,IAAI,CAAC;YACX,EAAE,IAAI,IAAI,CAAC;QACb,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,+BAA+B;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,wEAAwE;AACxE,MAAM,uBAAuB,GAAG,aAAa,EAAE,CAAC;AAChD,MAAM,kBAAkB,GAAG,aAAa,EAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
export * from './basis';
|
|
2
2
|
export * from './camera';
|
|
3
|
+
export * from './camera2d';
|
|
3
4
|
export * from './culling';
|
|
4
5
|
export * from './depth';
|
|
5
6
|
export * from './frustumCorners';
|
|
6
7
|
export * from './intersection';
|
|
8
|
+
export * from './parallax';
|
|
7
9
|
export * from './picking';
|
|
8
10
|
export * from './projection';
|
|
11
|
+
export * from './projection2d';
|
|
9
12
|
export * from './shadowCamera';
|
|
13
|
+
export * from './viewMatrix';
|
|
14
|
+
export * from './visibleBounds';
|
|
15
|
+
export * from './zoom';
|
|
10
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
export * from './basis';
|
|
2
2
|
export * from './camera';
|
|
3
|
+
export * from './camera2d';
|
|
3
4
|
export * from './culling';
|
|
4
5
|
export * from './depth';
|
|
5
6
|
export * from './frustumCorners';
|
|
6
7
|
export * from './intersection';
|
|
8
|
+
export * from './parallax';
|
|
7
9
|
export * from './picking';
|
|
8
10
|
export * from './projection';
|
|
11
|
+
export * from './projection2d';
|
|
9
12
|
export * from './shadowCamera';
|
|
13
|
+
export * from './viewMatrix';
|
|
14
|
+
export * from './visibleBounds';
|
|
15
|
+
export * from './zoom';
|
|
10
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC"}
|
package/dist/intersection.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BoundingSphereLike,
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
1
|
+
import type { BoundingSphereLike, Camera3D, PlaneLike, Ray3DLike, Vector3Like } from '@flighthq/types';
|
|
2
|
+
export declare function getCamera3DRayThroughBoundingSphere(out: Ray3DLike, camera: Readonly<Camera3D>, sphere: Readonly<BoundingSphereLike>, aspect: number): boolean;
|
|
3
|
+
export declare function intersectCamera3DRayWithPlane(out: Vector3Like, ray: Readonly<Ray3DLike>, plane: Readonly<PlaneLike>): boolean;
|
|
4
4
|
//# sourceMappingURL=intersection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intersection.d.ts","sourceRoot":"","sources":["../src/intersection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"intersection.d.ts","sourceRoot":"","sources":["../src/intersection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAiBvG,wBAAgB,mCAAmC,CACjD,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC1B,MAAM,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EACpC,MAAM,EAAE,MAAM,GACb,OAAO,CAUT;AAgBD,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,QAAQ,CAAC,SAAS,CAAC,EACxB,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,GACzB,OAAO,CA0BT"}
|
package/dist/intersection.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getCamera3DScreenToWorldRay, getCamera3DWorldToScreen } from './picking';
|
|
2
2
|
// Returns the world-space ray from the camera through the center of a bounding sphere, writing
|
|
3
3
|
// the result into `out` and returning true. The ray is suitable for picking and hover-highlight
|
|
4
4
|
// queries: it passes through the screen-space projection of the sphere center, and represents
|
|
@@ -12,16 +12,16 @@ import { getCameraScreenToWorldRay, getCameraWorldToScreen } from './picking';
|
|
|
12
12
|
// The ray direction is normalized. `aspect` is viewport width / height.
|
|
13
13
|
//
|
|
14
14
|
// Reads all inputs before writing `out`, so it is alias-safe.
|
|
15
|
-
export function
|
|
15
|
+
export function getCamera3DRayThroughBoundingSphere(out, camera, sphere, aspect) {
|
|
16
16
|
if (sphere.radius < 0) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
19
|
// Project sphere center to NDC.
|
|
20
|
-
if (!
|
|
20
|
+
if (!getCamera3DWorldToScreen(__scratchNdc, camera, sphere.center, aspect)) {
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
// Unproject those NDC coords back to a world-space ray.
|
|
24
|
-
return
|
|
24
|
+
return getCamera3DScreenToWorldRay(out, camera, __scratchNdc.x, __scratchNdc.y, aspect);
|
|
25
25
|
}
|
|
26
26
|
// Computes the intersection of a ray with an infinite plane, writing the hit point into `out`
|
|
27
27
|
// and returning true. Returns false when:
|
|
@@ -33,11 +33,11 @@ export function getCameraRayThroughBoundingSphere(out, camera, sphere, aspect) {
|
|
|
33
33
|
// does not need to be unit length. The ray direction does not need to be unit length either.
|
|
34
34
|
//
|
|
35
35
|
// This is not specific to a camera but lives here as an ergonomic companion to
|
|
36
|
-
// `
|
|
36
|
+
// `getCamera3DScreenToWorldRay`: cast a ray from mouse position, intersect with a ground plane,
|
|
37
37
|
// and you have world-space mouse drag.
|
|
38
38
|
//
|
|
39
39
|
// Reads all inputs before writing `out`, so it is alias-safe.
|
|
40
|
-
export function
|
|
40
|
+
export function intersectCamera3DRayWithPlane(out, ray, plane) {
|
|
41
41
|
const dx = ray.direction.x;
|
|
42
42
|
const dy = ray.direction.y;
|
|
43
43
|
const dz = ray.direction.z;
|
package/dist/intersection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intersection.js","sourceRoot":"","sources":["../src/intersection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
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","sources":["../src/parallax.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAkB7D,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAI3G"}
|
package/dist/parallax.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createMatrix } from '@flighthq/geometry';
|
|
2
|
+
import { getCamera2DViewMatrix } from './viewMatrix';
|
|
3
|
+
// Writes the screen-space scroll offset for a parallax layer at depth `factor` into `out`.
|
|
4
|
+
//
|
|
5
|
+
// Convention: the offset is the camera's own screen-space translation (the view matrix translation
|
|
6
|
+
// minus the viewport center — i.e. `-L * cameraPosition`, where `L` is the zoom+rotation linear part)
|
|
7
|
+
// scaled by `factor`. A layer whose content is drawn relative to the viewport center adds this offset
|
|
8
|
+
// to scroll with the camera:
|
|
9
|
+
//
|
|
10
|
+
// factor 0 -> (0, 0): the layer is screen-locked (a fixed HUD / far background).
|
|
11
|
+
// factor 1 -> the camera's full screen translation: the layer is world-locked, moving exactly
|
|
12
|
+
// like the main scene.
|
|
13
|
+
// factor 0.5 -> half the camera translation: the layer drifts at half speed (a mid background).
|
|
14
|
+
//
|
|
15
|
+
// Accounts for zoom and rotation through the view matrix, so a rotated/zoomed camera yields the
|
|
16
|
+
// correctly transformed offset.
|
|
17
|
+
export function getCamera2DParallaxPoint(camera, factor, out) {
|
|
18
|
+
getCamera2DViewMatrix(camera, scratchMatrix);
|
|
19
|
+
out.x = (scratchMatrix.tx - camera.viewportWidth * 0.5) * factor;
|
|
20
|
+
out.y = (scratchMatrix.ty - camera.viewportHeight * 0.5) * factor;
|
|
21
|
+
}
|
|
22
|
+
const scratchMatrix = createMatrix();
|
|
23
|
+
//# sourceMappingURL=parallax.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallax.js","sourceRoot":"","sources":["../src/parallax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,2FAA2F;AAC3F,EAAE;AACF,mGAAmG;AACnG,sGAAsG;AACtG,sGAAsG;AACtG,6BAA6B;AAC7B,EAAE;AACF,qFAAqF;AACrF,kGAAkG;AAClG,uCAAuC;AACvC,kGAAkG;AAClG,EAAE;AACF,gGAAgG;AAChG,gCAAgC;AAChC,MAAM,UAAU,wBAAwB,CAAC,MAA0B,EAAE,MAAc,EAAE,GAAgB;IACnG,qBAAqB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC7C,GAAG,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,GAAG,MAAM,CAAC,aAAa,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC;IACjE,GAAG,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,GAAG,MAAM,CAAC,cAAc,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC;AACpE,CAAC;AAED,MAAM,aAAa,GAAG,YAAY,EAAE,CAAC"}
|
package/dist/picking.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
1
|
+
import type { Camera3D, Ray3DLike, Vector3Like } from '@flighthq/types';
|
|
2
|
+
export declare function getCamera3DScreenToWorldRay(out: Ray3DLike, camera: Readonly<Camera3D>, ndcX: number, ndcY: number, aspect: number): boolean;
|
|
3
|
+
export declare function getCamera3DWorldToScreen(out: Vector3Like, camera: Readonly<Camera3D>, worldPoint: Readonly<Vector3Like>, aspect: number): boolean;
|
|
4
4
|
//# sourceMappingURL=picking.d.ts.map
|
package/dist/picking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picking.d.ts","sourceRoot":"","sources":["../src/picking.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"picking.d.ts","sourceRoot":"","sources":["../src/picking.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAcxE,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CA8CT;AAUD,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,WAAW,EAChB,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAC1B,UAAU,EAAE,QAAQ,CAAC,WAAW,CAAC,EACjC,MAAM,EAAE,MAAM,GACb,OAAO,CAkBT"}
|