@flighthq/camera 0.5.1-next.731.0ae0aa4 → 0.5.1-next.799.62ef0c7
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/README.md +2 -2
- package/dist/camera2d.d.ts.map +1 -1
- package/dist/camera2d.js +3 -2
- package/dist/camera2d.js.map +1 -1
- package/dist/projection.d.ts +3 -3
- package/dist/projection.d.ts.map +1 -1
- package/dist/projection.js +5 -4
- package/dist/projection.js.map +1 -1
- package/package.json +5 -5
- package/src/projection.test.ts +3 -0
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/camera`. The `@fligh
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/camera@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/camera@0.5.1-next.799.62ef0c7](https://github.com/flighthq/flight/tree/62ef0c74f09f24177aac3695b2487b2d743d4fe6/packages/camera)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/62ef0c74f09f24177aac3695b2487b2d743d4fe6/LICENSE.md)
|
package/dist/camera2d.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera2d.d.ts","sourceRoot":"","sources":["../src/camera2d.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"camera2d.d.ts","sourceRoot":"","sources":["../src/camera2d.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAM1E,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
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { createEntity } from '@flighthq/entity/contract';
|
|
1
2
|
// Allocates a plain-data 2D camera over a `viewportWidth` x `viewportHeight` surface. The camera
|
|
2
3
|
// starts centered on world origin at zoom 1 with no rotation; `options` overrides any of `x`, `y`,
|
|
3
4
|
// `zoom`, `rotation`. This is the only allocating function in the package — every other operation
|
|
4
5
|
// writes into an `out` parameter.
|
|
5
6
|
export function createCamera2D(viewportWidth, viewportHeight, options) {
|
|
6
|
-
return {
|
|
7
|
+
return createEntity({
|
|
7
8
|
rotation: options?.rotation ?? 0,
|
|
8
9
|
viewportHeight,
|
|
9
10
|
viewportWidth,
|
|
10
11
|
x: options?.x ?? 0,
|
|
11
12
|
y: options?.y ?? 0,
|
|
12
13
|
zoom: options?.zoom ?? 1,
|
|
13
|
-
};
|
|
14
|
+
});
|
|
14
15
|
}
|
|
15
16
|
//# sourceMappingURL=camera2d.js.map
|
package/dist/camera2d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera2d.js","sourceRoot":"","sources":["../src/camera2d.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"camera2d.js","sourceRoot":"","sources":["../src/camera2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,iGAAiG;AACjG,mGAAmG;AACnG,kGAAkG;AAClG,kCAAkC;AAClC,MAAM,UAAU,cAAc,CAC5B,aAAqB,EACrB,cAAsB,EACtB,OAAmC;IAEnC,OAAO,YAAY,CAAC;QAClB,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,CAAC;AACL,CAAC"}
|
package/dist/projection.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Matrix4Like } from '@flighthq/types/contract';
|
|
1
|
+
import type { Entity, Matrix4Like } from '@flighthq/types/contract';
|
|
2
2
|
import type { OrthographicProjection, OrthographicProjectionOptions, PerspectiveProjection, PerspectiveProjectionOptions, Projection } from '@flighthq/types/contract';
|
|
3
|
-
export declare function createOrthographicProjection(opts: Readonly<OrthographicProjectionOptions>): OrthographicProjection;
|
|
4
|
-
export declare function createPerspectiveProjection(opts: Readonly<PerspectiveProjectionOptions>): PerspectiveProjection;
|
|
3
|
+
export declare function createOrthographicProjection(opts: Readonly<OrthographicProjectionOptions>): OrthographicProjection & Entity;
|
|
4
|
+
export declare function createPerspectiveProjection(opts: Readonly<PerspectiveProjectionOptions>): PerspectiveProjection & Entity;
|
|
5
5
|
export declare function getOrthographicProjectionTexelSize(projection: Readonly<OrthographicProjection>, pixelWidth: number, pixelHeight: number): number;
|
|
6
6
|
export declare function isOrthographicProjection(projection: Readonly<Projection>): projection is OrthographicProjection;
|
|
7
7
|
export declare function isPerspectiveProjection(projection: Readonly<Projection>): projection is PerspectiveProjection;
|
package/dist/projection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC7B,qBAAqB,EACrB,4BAA4B,EAC5B,UAAU,EACX,MAAM,0BAA0B,CAAC;AAKlC,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,QAAQ,CAAC,6BAA6B,CAAC,GAC5C,sBAAsB,GAAG,MAAM,CAMjC;AAID,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,QAAQ,CAAC,4BAA4B,CAAC,GAC3C,qBAAqB,GAAG,MAAM,CAMhC;AAKD,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,QAAQ,CAAC,sBAAsB,CAAC,EAC5C,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER;AAGD,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,UAAU,IAAI,sBAAsB,CAE/G;AAGD,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,UAAU,IAAI,qBAAqB,CAE7G;AAUD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,EAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,IAAI,CASN"}
|
package/dist/projection.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
+
import { createEntity } from '@flighthq/entity/contract';
|
|
1
2
|
import { setOrthographicMatrix4, setPerspectiveMatrix4 } from '@flighthq/geometry/contract';
|
|
2
3
|
// Builds an orthographic projection descriptor from explicit view-volume half-extents (in
|
|
3
4
|
// view-space units). The full visible width is 2*halfWidth and height 2*halfHeight; the
|
|
4
5
|
// clip-plane distances live on the owning Camera3D, not the projection.
|
|
5
6
|
export function createOrthographicProjection(opts) {
|
|
6
|
-
return {
|
|
7
|
+
return createEntity({
|
|
7
8
|
halfHeight: opts.halfHeight,
|
|
8
9
|
halfWidth: opts.halfWidth,
|
|
9
10
|
kind: 'orthographic',
|
|
10
|
-
};
|
|
11
|
+
});
|
|
11
12
|
}
|
|
12
13
|
// Builds a perspective projection descriptor from a vertical field of view (radians) and a
|
|
13
14
|
// viewport aspect ratio (width / height). The clip-plane distances live on the owning Camera3D.
|
|
14
15
|
export function createPerspectiveProjection(opts) {
|
|
15
|
-
return {
|
|
16
|
+
return createEntity({
|
|
16
17
|
aspect: opts.aspect ?? 1,
|
|
17
18
|
fovY: opts.fovY,
|
|
18
19
|
kind: 'perspective',
|
|
19
|
-
};
|
|
20
|
+
});
|
|
20
21
|
}
|
|
21
22
|
// Returns the larger world-space footprint of one texel across an orthographic projection. Using the
|
|
22
23
|
// larger axis gives receiver offsets one conservative, aspect-independent unit even when the shadow
|
package/dist/projection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAU5F,0FAA0F;AAC1F,wFAAwF;AACxF,wEAAwE;AACxE,MAAM,UAAU,4BAA4B,
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../src/projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAU5F,0FAA0F;AAC1F,wFAAwF;AACxF,wEAAwE;AACxE,MAAM,UAAU,4BAA4B,CAC1C,IAA6C;IAE7C,OAAO,YAAY,CAAC;QAClB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,IAAI,EAAE,cAAc;KACrB,CAAC,CAAC;AACL,CAAC;AAED,2FAA2F;AAC3F,gGAAgG;AAChG,MAAM,UAAU,2BAA2B,CACzC,IAA4C;IAE5C,OAAO,YAAY,CAAC;QAClB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC;QACxB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,aAAa;KACpB,CAAC,CAAC;AACL,CAAC;AAED,qGAAqG;AACrG,oGAAoG;AACpG,sFAA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5.1-next.
|
|
3
|
+
"version": "0.5.1-next.799.62ef0c7",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.5.1-next.
|
|
42
|
-
"@flighthq/geometry": "0.5.1-next.
|
|
43
|
-
"@flighthq/log": "0.5.1-next.
|
|
44
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.799.62ef0c7",
|
|
42
|
+
"@flighthq/geometry": "0.5.1-next.799.62ef0c7",
|
|
43
|
+
"@flighthq/log": "0.5.1-next.799.62ef0c7",
|
|
44
|
+
"@flighthq/types": "0.5.1-next.799.62ef0c7"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"typescript": "^5.3.0"
|
package/src/projection.test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createMatrix4, createPerspectiveMatrix4, setOrthographicMatrix4 } from '@flighthq/geometry/contract';
|
|
2
|
+
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
2
3
|
import type { OrthographicProjection, PerspectiveProjection } from '@flighthq/types/contract';
|
|
3
4
|
|
|
4
5
|
import {
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
describe('createOrthographicProjection', () => {
|
|
14
15
|
it('builds an orthographic descriptor from half-extents', () => {
|
|
15
16
|
const projection = createOrthographicProjection({ halfHeight: 3, halfWidth: 4 });
|
|
17
|
+
expect(EntityRuntimeKey in projection).toBe(true);
|
|
16
18
|
expect(projection.kind).toBe('orthographic');
|
|
17
19
|
expect(projection.halfWidth).toBe(4);
|
|
18
20
|
expect(projection.halfHeight).toBe(3);
|
|
@@ -22,6 +24,7 @@ describe('createOrthographicProjection', () => {
|
|
|
22
24
|
describe('createPerspectiveProjection', () => {
|
|
23
25
|
it('builds a perspective descriptor from fovY and aspect', () => {
|
|
24
26
|
const projection = createPerspectiveProjection({ aspect: 1.5, fovY: Math.PI / 3 });
|
|
27
|
+
expect(EntityRuntimeKey in projection).toBe(true);
|
|
25
28
|
expect(projection.kind).toBe('perspective');
|
|
26
29
|
expect(projection.fovY).toBeCloseTo(Math.PI / 3);
|
|
27
30
|
expect(projection.aspect).toBe(1.5);
|