@spacexr/3d-tiles-runtime 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +93 -2
  3. package/dist/chunk-AI6NWGCA.js +316 -0
  4. package/dist/chunk-AI6NWGCA.js.map +1 -0
  5. package/dist/chunk-G7YVZYMR.js +24 -0
  6. package/dist/chunk-G7YVZYMR.js.map +1 -0
  7. package/dist/chunk-PJIVVIOF.js +205 -0
  8. package/dist/chunk-PJIVVIOF.js.map +1 -0
  9. package/dist/chunk-Q2AL6LWU.js +3 -0
  10. package/dist/chunk-Q2AL6LWU.js.map +1 -0
  11. package/dist/chunk-Q35HKP5V.js +249 -0
  12. package/dist/chunk-Q35HKP5V.js.map +1 -0
  13. package/dist/chunk-URZDM4BH.js +488 -0
  14. package/dist/chunk-URZDM4BH.js.map +1 -0
  15. package/dist/implicit/index.d.ts +64 -0
  16. package/dist/implicit/index.js +4 -0
  17. package/dist/implicit/index.js.map +1 -0
  18. package/dist/index-CNnPRQZc.d.ts +350 -0
  19. package/dist/index.d.ts +713 -0
  20. package/dist/index.js +3074 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/metadata/index.d.ts +12 -0
  23. package/dist/metadata/index.js +3 -0
  24. package/dist/metadata/index.js.map +1 -0
  25. package/dist/pipeline/index.d.ts +5 -0
  26. package/dist/pipeline/index.js +3 -0
  27. package/dist/pipeline/index.js.map +1 -0
  28. package/dist/ports/index.d.ts +62 -0
  29. package/dist/ports/index.js +4 -0
  30. package/dist/ports/index.js.map +1 -0
  31. package/dist/resource-DH72MRMN.d.ts +34 -0
  32. package/dist/spatial/index.d.ts +402 -0
  33. package/dist/spatial/index.js +3 -0
  34. package/dist/spatial/index.js.map +1 -0
  35. package/dist/spatial-3IDPbyv4.d.ts +28 -0
  36. package/dist/types-Dn5i8Uqg.d.ts +78 -0
  37. package/dist/types-ri64XfSE.d.ts +237 -0
  38. package/package.json +102 -5
  39. package/src/implicit/availability.ts +55 -0
  40. package/src/implicit/coordinates.ts +193 -0
  41. package/src/implicit/dense-subtree-loader.ts +23 -0
  42. package/src/implicit/index.ts +6 -0
  43. package/src/implicit/standard-subtree-loader.ts +71 -0
  44. package/src/implicit/tile-data-source.ts +120 -0
  45. package/src/implicit/types.ts +156 -0
  46. package/src/index.ts +6 -0
  47. package/src/metadata/index.ts +2 -0
  48. package/src/metadata/metadata-resolver.ts +308 -0
  49. package/src/metadata/types.ts +91 -0
  50. package/src/pipeline/index.ts +4 -0
  51. package/src/pipeline/metadata-store.ts +44 -0
  52. package/src/pipeline/ports.ts +62 -0
  53. package/src/pipeline/states.ts +56 -0
  54. package/src/pipeline/tile-3d.ts +165 -0
  55. package/src/ports/camera.ts +12 -0
  56. package/src/ports/content.ts +71 -0
  57. package/src/ports/glyph.ts +13 -0
  58. package/src/ports/index.ts +32 -0
  59. package/src/ports/resource.ts +54 -0
  60. package/src/ports/spatial.ts +28 -0
  61. package/src/ports/telemetry.ts +44 -0
  62. package/src/runtime/cache.ts +112 -0
  63. package/src/runtime/contracts.ts +77 -0
  64. package/src/runtime/events.ts +57 -0
  65. package/src/runtime/hooks.ts +99 -0
  66. package/src/runtime/index.ts +7 -0
  67. package/src/runtime/instrumentation.ts +163 -0
  68. package/src/runtime/priority-scheduler.ts +88 -0
  69. package/src/runtime/quadtree-balance.ts +215 -0
  70. package/src/runtime/tile-runtime.ts +3508 -0
  71. package/src/spatial/bounding-volumes.ts +159 -0
  72. package/src/spatial/ecef-types.ts +110 -0
  73. package/src/spatial/ecef.ts +196 -0
  74. package/src/spatial/index.ts +6 -0
  75. package/src/spatial/utm-bounds.ts +151 -0
  76. package/src/spatial/utm-types.ts +83 -0
  77. package/src/spatial/vertical-scale.ts +125 -0
  78. package/src/spatial/view-metrics.ts +132 -0
@@ -0,0 +1,12 @@
1
+ import { i as MetadataScopeOrder, d as IMetadataResolutionInput, I as IMetadataSnapshot, f as IResolvedMetadataProperty } from '../types-Dn5i8Uqg.js';
2
+ export { a as IMetadataAncestorInput, b as IMetadataDiagnostic, c as IMetadataDocumentContext, e as IResolvedMetadataEntity, g as IRuntimeFeatureMetadata, M as MetadataDiagnosticSeverity, h as MetadataScopeKind } from '../types-Dn5i8Uqg.js';
3
+ import '@spacexr/3d-tiles-core';
4
+
5
+ declare const DEFAULT_METADATA_SCOPE_ORDER: MetadataScopeOrder;
6
+ declare class MetadataResolver {
7
+ resolve(input: IMetadataResolutionInput): IMetadataSnapshot;
8
+ findBySemantic(snapshot: IMetadataSnapshot, semantic: string, order?: MetadataScopeOrder): IResolvedMetadataProperty | undefined;
9
+ private resolveEntity;
10
+ }
11
+
12
+ export { DEFAULT_METADATA_SCOPE_ORDER, IMetadataResolutionInput, IMetadataSnapshot, IResolvedMetadataProperty, MetadataResolver, MetadataScopeOrder };
@@ -0,0 +1,3 @@
1
+ export { DEFAULT_METADATA_SCOPE_ORDER, MetadataResolver } from '../chunk-Q35HKP5V.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,5 @@
1
+ export { p as IMetadataStore, r as ITile3DInitialization, b as ITileActivationAdapter, s as ITileActivationContext, t as ITileDeactivationContext, c as ITilePresentationAdapter, u as ITilePresentationContext, v as ITilePresentationResource, w as ITileReadinessPort, R as RuntimeMetadataStore, T as Tile3D, B as Tile3DContent } from '../index-CNnPRQZc.js';
2
+ export { C as CameraChangeFlags, M as MetadataHandle, N as NO_METADATA, T as TileContentKind, v as TileMetadataState, w as TilePresentationState, x as TileReadinessState, y as TileRefinementMode, z as TileSelectionState } from '../types-ri64XfSE.js';
3
+ import '../types-Dn5i8Uqg.js';
4
+ import '@spacexr/3d-tiles-core';
5
+ import '@spacexr/tiles';
@@ -0,0 +1,3 @@
1
+ export { CameraChangeFlags, NO_METADATA, RuntimeMetadataStore, Tile3D, Tile3DContent, TileContentKind, TileMetadataState, TilePresentationState, TileReadinessState, TileRefinementMode, TileSelectionState } from '../chunk-PJIVVIOF.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,62 @@
1
+ import { I as IImplicitSubtreeLoader, a as IImplicitTileResolver, b as IImplicitMetadataDecoder } from '../types-ri64XfSE.js';
2
+ import { I as ITileContext, a as ITileContentAdapter, b as ITileActivationAdapter, c as ITilePresentationAdapter } from '../index-CNnPRQZc.js';
3
+ export { C as ContentLoadResult, d as IContentLoadContext, e as IContentPresentationContext } from '../index-CNnPRQZc.js';
4
+ import { I as IMetadataSnapshot } from '../types-Dn5i8Uqg.js';
5
+ import { I as ITilesetLoader, a as IMetadataSchemaLoader, b as IRuntimeUriResolver } from '../resource-DH72MRMN.js';
6
+ export { c as ILoadedTileset, d as IMetadataSchemaLoadRequest, e as ITilesetLoadRequest, S as StandardUriResolver } from '../resource-DH72MRMN.js';
7
+ import { I as ISpatialMetric } from '../spatial-3IDPbyv4.js';
8
+ export { a as IScreenSpaceErrorContext, b as ISpatialDerivationContext } from '../spatial-3IDPbyv4.js';
9
+ import '@spacexr/3d-tiles-core';
10
+ import '@spacexr/tiles';
11
+
12
+ interface IRuntimeSubscription {
13
+ unsubscribe(): void;
14
+ }
15
+ /** Pushes camera placement changes into the runtime. */
16
+ interface ICameraEventSource<TCamera> {
17
+ subscribe(listener: (camera: TCamera) => void): IRuntimeSubscription;
18
+ current?(): TCamera | undefined;
19
+ }
20
+ /** Preferred name for a renderer camera source producing immutable runtime frames. */
21
+ type ICameraFrameSource<TCameraFrame> = ICameraEventSource<TCameraFrame>;
22
+
23
+ interface IGlyphPublicationContext<TSpatial, TContentHandle> extends ITileContext<TSpatial> {
24
+ metadata: readonly IMetadataSnapshot[];
25
+ contentHandles: readonly TContentHandle[];
26
+ }
27
+ /** Publishes labels, anchors, symbols or domain-specific glyphs. */
28
+ interface IGlyphPublisher<TSpatial, TContentHandle, TGlyphHandle> {
29
+ publish(context: IGlyphPublicationContext<TSpatial, TContentHandle>): readonly TGlyphHandle[] | Promise<readonly TGlyphHandle[]>;
30
+ revoke(handles: readonly TGlyphHandle[], context: IGlyphPublicationContext<TSpatial, TContentHandle>): void | Promise<void>;
31
+ }
32
+
33
+ type RuntimeMetricName = "frame" | "frame.duration" | "frame.selected" | "tileset.load" | "subtree.load" | "subtree.load.duration" | "subtree.load.bytes" | "subtree.cache.evict" | "content.load" | "content.load.duration" | "content.load.network-bytes" | "content.error" | "content.cache.evict" | "tile.attach" | "tile.detach" | "tile.refine" | "tile.coarsen" | "tile.refine.attempt" | "tile.coarsen.attempt" | "cut.entered" | "content.cancelled" | "cut.left" | "tile.node.prune" | "cache.sweep.duration" | "cache.content.entries" | "cache.content.cpu-bytes" | "cache.content.gpu-bytes" | "cache.subtree.entries" | "cache.subtree.bytes" | "runtime.error" | "metadata.diagnostic";
34
+ interface IRuntimeMetric {
35
+ name: RuntimeMetricName;
36
+ value: number;
37
+ unit: "count" | "millisecond" | "pixel" | "byte";
38
+ tags?: Readonly<Record<string, string | number | boolean>>;
39
+ }
40
+ /** Receives operational metrics without imposing a monitoring product. */
41
+ interface IRuntimeTelemetry {
42
+ record(metric: IRuntimeMetric): void;
43
+ }
44
+
45
+ interface IRuntimeAdapter<TCamera, TSpatial, TContentHandle, TGlyphHandle> {
46
+ tilesets: ITilesetLoader;
47
+ /** Legacy combined adapter. New integrations should use activation and presentation. */
48
+ content?: ITileContentAdapter<TSpatial, TContentHandle>;
49
+ activation?: ITileActivationAdapter<TSpatial, TContentHandle, TGlyphHandle>;
50
+ presentation?: ITilePresentationAdapter<TSpatial, TContentHandle, TGlyphHandle>;
51
+ spatial: ISpatialMetric<TCamera, TSpatial>;
52
+ camera?: ICameraEventSource<TCamera>;
53
+ glyphs?: IGlyphPublisher<TSpatial, TContentHandle, TGlyphHandle>;
54
+ metadataSchemas?: IMetadataSchemaLoader;
55
+ telemetry?: IRuntimeTelemetry;
56
+ uri?: IRuntimeUriResolver;
57
+ subtrees?: IImplicitSubtreeLoader;
58
+ implicitTiles?: IImplicitTileResolver;
59
+ implicitMetadata?: IImplicitMetadataDecoder;
60
+ }
61
+
62
+ export { type ICameraEventSource, type ICameraFrameSource, type IGlyphPublicationContext, type IGlyphPublisher, IMetadataSchemaLoader, type IRuntimeAdapter, type IRuntimeMetric, type IRuntimeSubscription, type IRuntimeTelemetry, IRuntimeUriResolver, ISpatialMetric, ITileContentAdapter, ITilesetLoader, type RuntimeMetricName };
@@ -0,0 +1,4 @@
1
+ import '../chunk-Q2AL6LWU.js';
2
+ export { StandardUriResolver } from '../chunk-G7YVZYMR.js';
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,34 @@
1
+ import { ITileset, IMetadataSchema } from '@spacexr/3d-tiles-core';
2
+
3
+ interface ITilesetLoadRequest {
4
+ uri: string;
5
+ parentDocumentUri?: string;
6
+ signal: AbortSignal;
7
+ }
8
+ interface ILoadedTileset {
9
+ tileset: ITileset;
10
+ /** Base used to resolve references declared by this document. */
11
+ baseUri?: string;
12
+ }
13
+ interface ITilesetLoader {
14
+ load(request: ITilesetLoadRequest): Promise<ILoadedTileset>;
15
+ }
16
+ interface IMetadataSchemaLoadRequest {
17
+ uri: string;
18
+ documentUri: string;
19
+ signal: AbortSignal;
20
+ }
21
+ interface IMetadataSchemaLoader {
22
+ load(request: IMetadataSchemaLoadRequest): Promise<IMetadataSchema>;
23
+ }
24
+ /** Resolves canonical resource identities, without injecting renderer state. */
25
+ interface IRuntimeUriResolver {
26
+ resolve(reference: string, baseUri: string): string;
27
+ baseOf(uri: string): string;
28
+ }
29
+ declare class StandardUriResolver implements IRuntimeUriResolver {
30
+ resolve(reference: string, baseUri: string): string;
31
+ baseOf(uri: string): string;
32
+ }
33
+
34
+ export { type ITilesetLoader as I, StandardUriResolver as S, type IMetadataSchemaLoader as a, type IRuntimeUriResolver as b, type ILoadedTileset as c, type IMetadataSchemaLoadRequest as d, type ITilesetLoadRequest as e };
@@ -0,0 +1,402 @@
1
+ import { Ellipsoid, IGeodeticCoordinates, GeodeticSystem } from '@spacexr/geodesy';
2
+ import { I as ISpatialMetric, b as ISpatialDerivationContext, a as IScreenSpaceErrorContext } from '../spatial-3IDPbyv4.js';
3
+ import { ICartesian3 } from '@spacexr/geometry';
4
+ import { IUtmProjection, IUtmBoundingVolume, IVerticalExtent } from '@spacexr/3d-tiles-core';
5
+ import { ReferenceSurface } from '@spacexr/tiles';
6
+
7
+ /**
8
+ * Horizontal datum transformation from the datum of a UTM extent to the geodetic system of the spatial metric.
9
+ */
10
+ interface IHorizontalDatumTransformation {
11
+ /** Identification of the transformation, for example `EPSG:1188 NAD83 to WGS 84 (1)`. */
12
+ readonly name: string;
13
+ /**
14
+ * Horizontal accuracy of the transformation in metres.
15
+ * Derived bounds are widened by this distance so that the true position stays inside them.
16
+ */
17
+ readonly accuracy: number;
18
+ /** Source CRS ellipsoid; defaults to the supplied target system ellipsoid. */
19
+ readonly sourceEllipsoid?: Ellipsoid;
20
+ /**
21
+ * Transforms geodetic coordinates in radians, in place, from the source datum to the target system.
22
+ * Omitted for a null transformation, whose whole error is covered by `accuracy`.
23
+ */
24
+ transform?(geodetic: IGeodeticCoordinates): void;
25
+ }
26
+ /**
27
+ * Selects the transformation of a resolved UTM projection.
28
+ * Returns `undefined` when no transformation is known, in which case the extent is not placed.
29
+ */
30
+ type HorizontalDatumResolver = (projection: IUtmProjection) => IHorizontalDatumTransformation | undefined;
31
+ /**
32
+ * Geoid model returning the geoid undulation `N` in metres at a geodetic position in radians,
33
+ * so that ellipsoidal height equals orthometric height plus `N`.
34
+ */
35
+ type GeoidUndulationModel = (latitudeRadians: number, longitudeRadians: number) => number;
36
+ /** Options controlling how UTM extents are placed in ECEF. */
37
+ interface IUtmPlacementOptions {
38
+ /** Datum transformation resolver. Without a resolver, the datum remains unresolved. */
39
+ datumResolver?: HorizontalDatumResolver;
40
+ /** Explicit vertical uncertainty in metres when no geoid model is supplied. */
41
+ geoidUndulationMargin?: number;
42
+ /** Explicit height envelope when the vertical origin is unknown. */
43
+ unknownGroundHeightRange?: readonly [number, number];
44
+ /** Geoid model for orthometric heights. Without it, an explicit geoidUndulationMargin is required. */
45
+ geoidUndulation?: GeoidUndulationModel;
46
+ }
47
+ /**
48
+ * Outcome of placing a UTM extent.
49
+ *
50
+ * - `placed`: bounds were derived.
51
+ * - `unresolved-projection`: the zone and hemisphere could not be determined; no bounds were derived.
52
+ * - `unresolved-datum`: no datum transformation is known for the source datum; no bounds were derived.
53
+ */
54
+ type UtmPlacementStatus = "placed" | "unresolved-projection" | "unresolved-datum";
55
+ /**
56
+ * Origin of the ellipsoidal heights used for the bounds.
57
+ *
58
+ * - `ellipsoid`: values were already ellipsoidal heights.
59
+ * - `geoid`: values were orthometric heights.
60
+ * - `ground-elevation`: values were measured from `groundElevation`, treated as an orthometric height.
61
+ * - `assumed-terrain`: the vertical origin is unknown, so the caller supplied a height envelope.
62
+ */
63
+ type UtmVerticalOrigin = "ellipsoid" | "geoid" | "ground-elevation" | "assumed-terrain";
64
+ /** Explicit report of the conversions and approximations applied to a UTM extent. */
65
+ interface IUtmPlacement {
66
+ status: UtmPlacementStatus;
67
+ /** Resolved zone, hemisphere and datum, when available. */
68
+ projection?: IUtmProjection;
69
+ /** Applied datum transformation, when available. */
70
+ datumTransformation?: Pick<IHorizontalDatumTransformation, "name" | "accuracy">;
71
+ /** Horizontal widening of the bounds in metres. */
72
+ horizontalMargin: number;
73
+ verticalOrigin?: UtmVerticalOrigin;
74
+ /** How orthometric heights were converted, when the vertical origin requires it. */
75
+ geoid?: "model" | "margin";
76
+ /** Vertical widening in metres applied for the geoid margin. `assumed-terrain` extents use `heightRange` instead. */
77
+ verticalMargin: number;
78
+ /** Height interval in metres used for the bounds. With a geoid model, the undulation of each sample is added to it. */
79
+ heightRange?: readonly [number, number];
80
+ }
81
+
82
+ /** Mutable three-dimensional vector, the `ICartesian3` of `@spacexr/geometry`. ECEF values are expressed in metres. */
83
+ type IVector3 = ICartesian3;
84
+ /** Plane equation `ax + by + cz + d = 0`. */
85
+ interface IPlane {
86
+ /** Plane-normal X component. */
87
+ x: number;
88
+ /** Plane-normal Y component. */
89
+ y: number;
90
+ /** Plane-normal Z component. */
91
+ z: number;
92
+ /** Signed plane offset. */
93
+ w: number;
94
+ }
95
+ /** Axis-aligned ECEF bounding box. */
96
+ interface IAxisAlignedBox {
97
+ /** Minimum corner in ECEF metres. */
98
+ min: IVector3;
99
+ /** Maximum corner in ECEF metres. */
100
+ max: IVector3;
101
+ }
102
+ /** Bounding sphere expressed in ECEF metres. */
103
+ interface IBoundingSphere3 {
104
+ /** Sphere centre. */
105
+ center: IVector3;
106
+ /** Sphere radius in metres. */
107
+ radius: number;
108
+ }
109
+ /** Camera state consumed by {@link EcefSpatialMetric}. */
110
+ interface IEcefCameraFrame {
111
+ /** Optional application camera identifier. */
112
+ id?: string;
113
+ /** Camera position in ECEF metres. */
114
+ position: IVector3;
115
+ /** Viewport height in physical pixels. */
116
+ viewportHeight: number;
117
+ /** Vertical field of view in radians. */
118
+ verticalFovRadians?: number;
119
+ /** Precomputed tangent of half the vertical field of view. */
120
+ tanHalfVerticalFov?: number;
121
+ /** Optional unit direction of the view in ECEF, for orientation and scale displays. Selection does not read it. */
122
+ forward?: IVector3;
123
+ /** Optional normalized ECEF frustum planes. */
124
+ frustumPlanes?: readonly IPlane[];
125
+ /** Optional wider ECEF planes around the view: a tile between them and {@link frustumPlanes} is in the periphery. */
126
+ peripheryFrustumPlanes?: readonly IPlane[];
127
+ /** Optional coarse ECEF clipping box. */
128
+ clipBounds?: IAxisAlignedBox;
129
+ /** Optional source timestamp in milliseconds. */
130
+ timestamp?: number;
131
+ }
132
+ /** Derived renderer-neutral spatial state for one runtime tile. */
133
+ interface IEcefSpatialState {
134
+ /** Column-major local-to-ECEF transform. */
135
+ worldTransform: Float64Array;
136
+ /** Optional enclosing ECEF sphere. */
137
+ boundingSphere?: IBoundingSphere3;
138
+ /** Optional enclosing ECEF axis-aligned box. */
139
+ boundingBox?: IAxisAlignedBox;
140
+ /** Lowest and highest heights of the terrain of the tile over the reference surface, in metres, when known. */
141
+ heightRange?: readonly [number, number];
142
+ /** World-space geometric error in metres. */
143
+ geometricError: number;
144
+ /** Report of the conversions and approximations applied, for tiles located by `SPACEXR_bounding_volume_utm`. */
145
+ utmPlacement?: IUtmPlacement;
146
+ /** Point whose height moves the tile with the vertical scale, when the metric has a vertical placement. */
147
+ verticalAnchor?: IVector3;
148
+ /** Origin of the object the tile belongs to; its descendants move with it. */
149
+ verticalObject?: IVector3;
150
+ }
151
+ /** Configuration for the renderer-neutral ECEF spatial metric. */
152
+ interface IEcefSpatialMetricOptions {
153
+ /** Geodetic reference system used by region volumes and horizon culling. Supplied explicitly by the caller. */
154
+ geodeticSystem: GeodeticSystem;
155
+ /** Enables conservative ellipsoid horizon culling. Defaults to `true`. */
156
+ horizonCulling?: boolean;
157
+ /**
158
+ * Test of the horizon.
159
+ *
160
+ * - `plane`, the default: tiles behind the plane of the horizon of the smallest sphere of the ellipsoid. It suits oblate
161
+ * bodies, where that sphere lies below the surface. It culls a summit that still shows above the horizon, and on a
162
+ * sphere what lies deeper below the reference surface than the camera is above it.
163
+ * - `tile-heights`: the horizons of the camera and of the highest point of the tile, from the radius of the body and the
164
+ * heights of the tile. The hiding sphere lies below the lowest terrain measured so far, since a sight line may pass over
165
+ * any basin on its way. For spherical bodies.
166
+ */
167
+ horizon?: "plane" | "tile-heights";
168
+ /** Viewport height fallback in pixels. Defaults to 1080. */
169
+ defaultViewportHeight?: number;
170
+ /** Vertical field-of-view fallback in radians. Defaults to 60 degrees. */
171
+ defaultVerticalFovRadians?: number;
172
+ /** Datum transformation and geoid model used to place `SPACEXR_bounding_volume_utm` extents. */
173
+ utm?: IUtmPlacementOptions;
174
+ /**
175
+ * Moves the bounds of objects with the vertical scale of the scene. Not for terrain tiles, whose volumes already hold
176
+ * their scaled heights.
177
+ */
178
+ vertical?: IVerticalPlacement;
179
+ }
180
+
181
+ /**
182
+ * The vertical exaggeration of a scene. Terrain, picking, tile bounds, the camera and objects read this one value, so
183
+ * that they cannot disagree: changing it changes all of them.
184
+ */
185
+ declare class VerticalScale {
186
+ private current;
187
+ private readonly listeners;
188
+ /** @throws RangeError When the value is negative or not finite. */
189
+ constructor(value?: number);
190
+ get value(): number;
191
+ /** Changes the scale and notifies the listeners when it differs. @throws RangeError When the value is negative or not finite. */
192
+ set(value: number): void;
193
+ /** @returns The function that stops the notifications. */
194
+ subscribe(listener: (value: number) => void): () => void;
195
+ private static checked;
196
+ }
197
+ /** What a height means on a body: the same as for the terrain under the objects. */
198
+ interface IVerticalFrame {
199
+ /** Height of a point in metres, over the surface the heights of the terrain refer to. */
200
+ height(point: Readonly<IVector3>): number;
201
+ /** Unit direction along which that height is measured at a point. */
202
+ up(point: Readonly<IVector3>): IVector3;
203
+ }
204
+ /** Radial heights over a reference surface, as within the pyramid root: `P = (r_ref(d) + h) d`. */
205
+ declare function radialVerticalFrame(reference: Pick<ReferenceSurface, "height">): IVerticalFrame;
206
+ /** Heights along the normal of an ellipsoid, as on the Web Mercator grid. */
207
+ declare function geodeticVerticalFrame(system: GeodeticSystem): IVerticalFrame;
208
+ /** How objects follow the vertical scale of their scene. */
209
+ interface IVerticalPlacement {
210
+ scale: VerticalScale;
211
+ frame: IVerticalFrame;
212
+ }
213
+ /**
214
+ * How far the vertical scale moves an anchor: `h (s - 1)` along its up direction. A point of the terrain at height `h` is
215
+ * moved exactly as far, so an object placed on the terrain stays on it. The object itself is moved, never stretched.
216
+ */
217
+ declare function verticalDisplacement(anchor: Readonly<IVector3> | undefined, placement: IVerticalPlacement): IVector3;
218
+ /**
219
+ * The bounds of a tile under the vertical scale.
220
+ *
221
+ * The first tile with a position, from the root down, is an object: it moves by the height of its origin, and its
222
+ * descendants move with it whatever their transforms, so that an object never comes apart. A tile above any object moves
223
+ * with the centre of its volume. It may hold objects of other heights, whose origins differ from that height by at most its
224
+ * radius: it grows by `r |s - 1|` to keep them inside. The transform stays as it was: children compose from the original
225
+ * placement.
226
+ */
227
+ declare function placeVertically<TState extends IEcefSpatialState>(state: TState, placement: IVerticalPlacement, parent?: Readonly<IEcefSpatialState>): TState;
228
+
229
+ /** Viewport height and field of view used when a camera frame does not give them. */
230
+ interface IProjectionFallback {
231
+ /** Viewport height in physical pixels. */
232
+ viewportHeight: number;
233
+ /** Vertical field of view in radians. */
234
+ verticalFovRadians: number;
235
+ }
236
+ /**
237
+ * Length on the ground covered by one pixel of the viewport, at a distance from the camera, along a direction facing it.
238
+ * It is the factor of the screen-space error: a geometric error `e` at that distance spans `e / metresPerPixel` pixels.
239
+ *
240
+ * @param camera - Camera frame giving the viewport height and the vertical field of view.
241
+ * @param distance - Distance from the camera, in metres.
242
+ * @param fallback - Values used when the frame gives no viewport height or field of view.
243
+ * @returns Metres per pixel, or `NaN` when the field of view is not in (0, PI).
244
+ */
245
+ declare function metresPerPixel(camera: Readonly<IEcefCameraFrame>, distance: number, fallback: Readonly<IProjectionFallback>): number;
246
+ /** Inputs of {@link describeView} known to the renderer or the application rather than the camera frame. */
247
+ interface IViewMetricsOptions {
248
+ /** What a height means on the body: the frame of the terrain heights. */
249
+ vertical: IVerticalFrame;
250
+ /** Values used when the frame gives no viewport height or field of view. */
251
+ fallback: Readonly<IProjectionFallback>;
252
+ /**
253
+ * Height of the drawn terrain below the camera, over the same surface, vertical scale included. Without it the altitude
254
+ * over the ground is unknown and the view centre is sought on the reference surface.
255
+ */
256
+ groundHeight?: number;
257
+ /**
258
+ * Distance from the camera to the point at the centre of the view, when the renderer knows it, such as the radius of an
259
+ * orbiting camera or a depth read. Otherwise the centre ray is intersected with the sphere through the ground below the
260
+ * camera.
261
+ */
262
+ targetDistance?: number;
263
+ }
264
+ /** What a camera sees, for a scale and altitude display. Angles in degrees, lengths in metres. */
265
+ interface IViewMetrics {
266
+ /** Latitude of the camera, along the up direction of the vertical frame: geodetic or planetocentric. */
267
+ latitude: number;
268
+ /** East longitude of the camera, in (-180, 180]. */
269
+ longitude: number;
270
+ /** Height of the camera over the reference surface. */
271
+ height: number;
272
+ /** Height of the camera over the drawn terrain, when its height below the camera is known. */
273
+ altitude?: number;
274
+ /** Direction of the view from north, clockwise, in [0, 360). Undefined when the camera looks straight up or down. */
275
+ heading?: number;
276
+ /** Angle of the view over the horizon: 0 level, -90 straight down. Undefined without a forward direction. */
277
+ pitch?: number;
278
+ /** Distance from the camera to the point at the centre of the view. Undefined when the view misses the body. */
279
+ targetDistance?: number;
280
+ /** Ground length covered by one pixel at the centre of the view; the screen-space error factor there. */
281
+ metresPerPixel?: number;
282
+ }
283
+ /**
284
+ * Position, orientation and scale of a camera over a body, from its renderer-neutral frame.
285
+ *
286
+ * North is the body axis, ECEF +Z, projected on the plane normal to the up direction of the vertical frame. The scale is
287
+ * {@link metresPerPixel} at the distance of the view centre: the same factor the screen-space error divides by.
288
+ */
289
+ declare function describeView(camera: Readonly<IEcefCameraFrame>, options: Readonly<IViewMetricsOptions>): IViewMetrics;
290
+
291
+ /**
292
+ * Renderer-neutral 3D Tiles spatial metric operating in ECEF metres.
293
+ *
294
+ * The class owns 3D Tiles concerns such as transform composition, bounding
295
+ * volume derivation, visibility and screen-space error. Ellipsoid and
296
+ * coordinate-system mathematics are delegated to `@spacexr/geodesy`.
297
+ */
298
+ declare class EcefSpatialMetric implements ISpatialMetric<IEcefCameraFrame, IEcefSpatialState> {
299
+ private readonly system;
300
+ private readonly horizonCulling;
301
+ private readonly horizon;
302
+ /** Lowest terrain measured on any tile so far, over the reference surface, in metres. */
303
+ /** Lowest terrain measured, without the vertical scale, which may change later. */
304
+ private lowestUnscaledHeight;
305
+ private readonly defaultViewportHeight;
306
+ private readonly defaultVerticalFovRadians;
307
+ /** Viewport height and field of view used when a camera frame does not give them. */
308
+ readonly projectionFallback: Readonly<IProjectionFallback>;
309
+ private readonly utmOptions;
310
+ private readonly vertical;
311
+ /**
312
+ * Creates an ECEF spatial metric.
313
+ *
314
+ * @param options - Geodetic system and camera fallbacks.
315
+ */
316
+ constructor(options: IEcefSpatialMetricOptions);
317
+ /** Geodetic reference system used for regions and horizon culling. */
318
+ get geodeticSystem(): GeodeticSystem;
319
+ /**
320
+ * Derives world-space state for a tile.
321
+ *
322
+ * Box and sphere volumes receive the accumulated tile transform. A region
323
+ * is already expressed in the tileset geodetic reference system and is not
324
+ * transformed, as required by 3D Tiles. A `SPACEXR_bounding_volume_utm`
325
+ * extent is likewise absolute: it takes precedence over any standard
326
+ * fallback volume and ignores the tile transform. Its datum
327
+ * transformation, geoid handling and margins are reported in
328
+ * `utmPlacement`. When it cannot be placed, the standard volume is used
329
+ * if present; otherwise the state has no bounds and the tile is never culled.
330
+ *
331
+ * @param context - Source tile and optional parent spatial state.
332
+ * @returns Spatial state expressed in ECEF metres.
333
+ */
334
+ derive(context: ISpatialDerivationContext<IEcefSpatialState>): IEcefSpatialState;
335
+ private deriveUnscaled;
336
+ /**
337
+ * Evaluates coarse clip bounds, conservative horizon culling and frustum planes.
338
+ *
339
+ * @param spatial - Derived tile state.
340
+ * @param camera - Camera expressed in ECEF metres.
341
+ * @returns `true` when the tile may contribute to the current view.
342
+ */
343
+ isVisible(spatial: IEcefSpatialState, camera: IEcefCameraFrame): boolean;
344
+ /**
345
+ * Whether a tile is inside the wider planes around the view, with the same bounds and horizon as {@link isVisible}.
346
+ *
347
+ * @param spatial - Derived tile state.
348
+ * @param camera - Camera expressed in ECEF metres.
349
+ * @returns `true` when the camera has such planes and the tile may lie inside them.
350
+ */
351
+ isInPeriphery(spatial: IEcefSpatialState, camera: IEcefCameraFrame): boolean;
352
+ private isInside;
353
+ /**
354
+ * Computes projected geometric error in physical pixels.
355
+ *
356
+ * Distance is measured from the camera to the enclosing sphere surface,
357
+ * not merely to its centre. This prevents premature refinement changes
358
+ * near large tiles.
359
+ *
360
+ * @param context - Camera, tile and derived spatial state.
361
+ * @returns Screen-space error in physical pixels.
362
+ */
363
+ screenSpaceError(context: IScreenSpaceErrorContext<IEcefCameraFrame, IEcefSpatialState>): number;
364
+ }
365
+
366
+ type EcefBounds = Pick<IEcefSpatialState, "boundingBox" | "boundingSphere">;
367
+
368
+ /** No datum transformation is assumed without an application policy. */
369
+ declare function defaultHorizontalDatumResolver(_projection: IUtmProjection): IHorizontalDatumTransformation | undefined;
370
+ /**
371
+ * Derives the ellipsoidal height interval of a vertical extent without a geoid model.
372
+ *
373
+ * Orthometric and ground-anchored values use the caller-supplied margin. Ground values
374
+ * without `groundElevation` and `LOCAL` values require an explicit height envelope.
375
+ *
376
+ * @param vertical - Vertical extent of a UTM bounding volume.
377
+ * @returns Minimum and maximum ellipsoidal heights in metres.
378
+ */
379
+ declare function ellipsoidalHeightRange(vertical: IVerticalExtent, options: IUtmPlacementOptions): [number, number];
380
+ /** ECEF bounds of a UTM extent together with the report of how they were derived. */
381
+ interface IUtmBounds extends EcefBounds {
382
+ placement: IUtmPlacement;
383
+ }
384
+ /**
385
+ * Derives ECEF bounds from a `SPACEXR_bounding_volume_utm` extent.
386
+ *
387
+ * 1. The zone, hemisphere and datum are resolved from the EPSG code or the explicit zone.
388
+ * 2. The UTM grid is inverted on the ellipsoid of the datum.
389
+ * 3. The datum transformation is applied, and the bounds are widened by its accuracy.
390
+ * 4. Heights are converted to ellipsoidal heights with the geoid model, or widened by a geoid margin.
391
+ * 5. A 3 x 3 grid of the extent at both heights is converted to ECEF with `system`.
392
+ *
393
+ * Every step is reported in `placement`. When the projection or the datum cannot be resolved, no bounds are derived.
394
+ *
395
+ * @param extent - UTM extent.
396
+ * @param system - Geodetic system of the ECEF frame.
397
+ * @param options - Datum resolver and geoid model.
398
+ * @returns ECEF bounds and the placement report.
399
+ */
400
+ declare function boundsFromUtm(extent: IUtmBoundingVolume, system: GeodeticSystem, options?: IUtmPlacementOptions): IUtmBounds;
401
+
402
+ export { EcefSpatialMetric, type GeoidUndulationModel, type HorizontalDatumResolver, type IAxisAlignedBox, type IBoundingSphere3, type IEcefCameraFrame, type IEcefSpatialMetricOptions, type IEcefSpatialState, type IHorizontalDatumTransformation, type IPlane, type IProjectionFallback, type IUtmBounds, type IUtmPlacement, type IUtmPlacementOptions, type IVector3, type IVerticalFrame, type IVerticalPlacement, type IViewMetrics, type IViewMetricsOptions, type UtmPlacementStatus, type UtmVerticalOrigin, VerticalScale, boundsFromUtm, defaultHorizontalDatumResolver, describeView, ellipsoidalHeightRange, geodeticVerticalFrame, metresPerPixel, placeVertically, radialVerticalFrame, verticalDisplacement };
@@ -0,0 +1,3 @@
1
+ export { EcefSpatialMetric, VerticalScale, boundsFromUtm, defaultHorizontalDatumResolver, describeView, ellipsoidalHeightRange, geodeticVerticalFrame, metresPerPixel, placeVertically, radialVerticalFrame, verticalDisplacement } from '../chunk-URZDM4BH.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,28 @@
1
+ import { ITile } from '@spacexr/3d-tiles-core';
2
+
3
+ interface ISpatialDerivationContext<TSpatial> {
4
+ tile: ITile;
5
+ parent?: TSpatial;
6
+ /** Lowest and highest heights of the terrain of the tile over the reference surface, in metres, vertical scale applied, when known. */
7
+ heightRange?: readonly [number, number];
8
+ }
9
+ interface IScreenSpaceErrorContext<TCamera, TSpatial> {
10
+ camera: TCamera;
11
+ spatial: TSpatial;
12
+ tile: ITile;
13
+ depth: number;
14
+ }
15
+ /**
16
+ * Owns coordinate systems, placement, visibility and distance metrics. The
17
+ * traversal never assumes Babylon, Three.js, ECEF or a particular unit.
18
+ */
19
+ interface ISpatialMetric<TCamera, TSpatial> {
20
+ derive(context: ISpatialDerivationContext<TSpatial>): TSpatial;
21
+ /** Whether the tile is in the view of the camera. */
22
+ isVisible(spatial: TSpatial, camera: TCamera): boolean;
23
+ /** Whether the tile, outside the view, is close enough to it to stay active. Without this method, no tile is. */
24
+ isInPeriphery?(spatial: TSpatial, camera: TCamera): boolean;
25
+ screenSpaceError(context: IScreenSpaceErrorContext<TCamera, TSpatial>): number;
26
+ }
27
+
28
+ export type { ISpatialMetric as I, IScreenSpaceErrorContext as a, ISpatialDerivationContext as b };
@@ -0,0 +1,78 @@
1
+ import { IMetadataEntity, IMetadataSchema, ITileset, ITile, IContent, IMetadataClass, IMetadataClassProperty, MetadataValue } from '@spacexr/3d-tiles-core';
2
+
3
+ type MetadataDiagnosticSeverity = "info" | "warning" | "error";
4
+ interface IMetadataDiagnostic {
5
+ code: string;
6
+ severity: MetadataDiagnosticSeverity;
7
+ message: string;
8
+ path: string;
9
+ documentUri: string;
10
+ }
11
+ type MetadataScopeKind = "tileset" | "subtree" | "ancestor-tile" | "tile" | "group" | "content" | "feature";
12
+ interface IRuntimeFeatureMetadata {
13
+ id?: string | number;
14
+ entity: IMetadataEntity;
15
+ schema?: IMetadataSchema;
16
+ sourceUri?: string;
17
+ }
18
+ interface IMetadataDocumentContext {
19
+ uri: string;
20
+ tileset: ITileset;
21
+ schema?: IMetadataSchema;
22
+ schemaUri?: string;
23
+ diagnostics: readonly IMetadataDiagnostic[];
24
+ }
25
+ interface IResolvedMetadataProperty {
26
+ id: string;
27
+ definition?: IMetadataClassProperty;
28
+ semantic?: string;
29
+ rawValue?: MetadataValue;
30
+ value?: MetadataValue;
31
+ fromDefault: boolean;
32
+ isNoData: boolean;
33
+ }
34
+ interface IResolvedMetadataEntity {
35
+ scope: MetadataScopeKind;
36
+ ownerId: string;
37
+ documentUri: string;
38
+ featureId?: string | number;
39
+ entity: IMetadataEntity;
40
+ classId: string;
41
+ classDefinition?: IMetadataClass;
42
+ properties: Readonly<Record<string, IResolvedMetadataProperty>>;
43
+ diagnostics: readonly IMetadataDiagnostic[];
44
+ }
45
+ interface IMetadataAncestorInput {
46
+ id: string;
47
+ tile: ITile;
48
+ document: IMetadataDocumentContext;
49
+ }
50
+ /**
51
+ * Metadata scopes are deliberately kept separate. The 3D Tiles specification
52
+ * does not define implicit inheritance between tileset, group, tile, content
53
+ * and feature metadata.
54
+ */
55
+ interface IMetadataSnapshot {
56
+ document: IMetadataDocumentContext;
57
+ tileId: string;
58
+ tile: ITile;
59
+ content?: IContent;
60
+ scopes: readonly IResolvedMetadataEntity[];
61
+ diagnostics: readonly IMetadataDiagnostic[];
62
+ }
63
+ interface IMetadataResolutionInput {
64
+ document: IMetadataDocumentContext;
65
+ tileId: string;
66
+ tile: ITile;
67
+ ancestors: readonly IMetadataAncestorInput[];
68
+ subtree?: {
69
+ id: string;
70
+ entity: IMetadataEntity;
71
+ documentUri: string;
72
+ };
73
+ content?: IContent;
74
+ features?: readonly IRuntimeFeatureMetadata[];
75
+ }
76
+ type MetadataScopeOrder = readonly MetadataScopeKind[];
77
+
78
+ export type { IMetadataSnapshot as I, MetadataDiagnosticSeverity as M, IMetadataAncestorInput as a, IMetadataDiagnostic as b, IMetadataDocumentContext as c, IMetadataResolutionInput as d, IResolvedMetadataEntity as e, IResolvedMetadataProperty as f, IRuntimeFeatureMetadata as g, MetadataScopeKind as h, MetadataScopeOrder as i };