@loaders.gl/tiles 5.0.0-alpha.11 → 5.0.0-alpha.12
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/dist.dev.js +24723 -6715
- package/dist/dist.min.js +22 -3
- package/dist/index.cjs +498 -1970
- package/dist/index.cjs.map +4 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/point-cloud-tile-source-loader-types.d.ts +31 -0
- package/dist/point-cloud-tile-source-loader-types.d.ts.map +1 -0
- package/dist/point-cloud-tile-source-loader-types.js +34 -0
- package/dist/point-cloud-tile-source-loader-types.js.map +1 -0
- package/dist/point-cloud-tile-source-loader.cjs +81 -0
- package/dist/point-cloud-tile-source-loader.cjs.map +7 -0
- package/dist/point-cloud-tile-source-loader.d.ts +27 -0
- package/dist/point-cloud-tile-source-loader.d.ts.map +1 -0
- package/dist/point-cloud-tile-source-loader.js +17 -0
- package/dist/point-cloud-tile-source-loader.js.map +1 -0
- package/dist/point-cloud-tile-source-types.d.ts +15 -0
- package/dist/point-cloud-tile-source-types.d.ts.map +1 -0
- package/dist/point-cloud-tile-source-types.js +5 -0
- package/dist/point-cloud-tile-source-types.js.map +1 -0
- package/dist/point-cloud-tile-source.cjs +105 -0
- package/dist/point-cloud-tile-source.cjs.map +7 -0
- package/dist/point-cloud-tile-source.d.ts +36 -0
- package/dist/point-cloud-tile-source.d.ts.map +1 -0
- package/dist/point-cloud-tile-source.js +84 -0
- package/dist/point-cloud-tile-source.js.map +1 -0
- package/dist/spatial/spatial-coordinate-transformer.d.ts +3 -1
- package/dist/spatial/spatial-coordinate-transformer.d.ts.map +1 -1
- package/dist/spatial/spatial-coordinate-transformer.js +17 -1
- package/dist/spatial/spatial-coordinate-transformer.js.map +1 -1
- package/dist/tileset-2d.d.ts +2 -1
- package/dist/tileset-2d.d.ts.map +1 -1
- package/dist/tileset-2d.js +1 -1
- package/dist/tileset-2d.js.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.d.ts +2 -0
- package/dist/tileset-3d/common/tileset-3d.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.js.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js +0 -3
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js.map +1 -1
- package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/s2-bounding-volume.js +0 -3
- package/dist/tileset-3d/helpers/s2-bounding-volume.js.map +1 -1
- package/package.json +25 -13
- package/src/index.ts +6 -0
- package/src/point-cloud-tile-source-loader-types.ts +53 -0
- package/src/point-cloud-tile-source-loader.ts +32 -0
- package/src/point-cloud-tile-source-types.ts +20 -0
- package/src/point-cloud-tile-source.ts +112 -0
- package/src/spatial/spatial-coordinate-transformer.ts +21 -1
- package/src/tileset-2d.ts +25 -1
- package/src/tileset-3d/common/tileset-3d.ts +2 -0
- package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +0 -3
- package/src/tileset-3d/helpers/s2-bounding-volume.ts +0 -3
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {CoreAPI, SourceLoader} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {PointCloudTileSource} from './point-cloud-tile-source';
|
|
7
|
+
import type {
|
|
8
|
+
PointCloudTileSourceInput,
|
|
9
|
+
PointCloudTileSourceOptions
|
|
10
|
+
} from './point-cloud-tile-source-types';
|
|
11
|
+
|
|
12
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
13
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
14
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
15
|
+
|
|
16
|
+
/** Loads the optional authoring runtime through an explicit package subpath. */
|
|
17
|
+
async function preloadPointCloudTileSource(): Promise<
|
|
18
|
+
typeof import('./point-cloud-tile-source-loader').PointCloudTileSourceLoaderWithParser
|
|
19
|
+
> {
|
|
20
|
+
const {PointCloudTileSourceLoaderWithParser} = await import(
|
|
21
|
+
'@loaders.gl/tiles/point-cloud-tile-source-loader'
|
|
22
|
+
);
|
|
23
|
+
return PointCloudTileSourceLoaderWithParser;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Metadata-only loader for creating an additive point source from decoded Mesh/Arrow input. */
|
|
27
|
+
export const PointCloudTileSourceLoader = {
|
|
28
|
+
dataType: null as unknown as PointCloudTileSource,
|
|
29
|
+
batchType: null as never,
|
|
30
|
+
name: 'PointCloudTiler',
|
|
31
|
+
id: 'point-cloud-tiler',
|
|
32
|
+
module: 'tiles',
|
|
33
|
+
version: VERSION,
|
|
34
|
+
extensions: [],
|
|
35
|
+
mimeTypes: [],
|
|
36
|
+
type: 'point-cloud',
|
|
37
|
+
fromUrl: false,
|
|
38
|
+
fromBlob: false,
|
|
39
|
+
testURL: () => false,
|
|
40
|
+
options: {pointCloudTiler: {}},
|
|
41
|
+
defaultOptions: {pointCloudTiler: {}},
|
|
42
|
+
preload: preloadPointCloudTileSource,
|
|
43
|
+
/** Direct construction requires the runtime rather than this metadata export. */
|
|
44
|
+
createDataSource(
|
|
45
|
+
_input: PointCloudTileSourceInput | string | Blob,
|
|
46
|
+
_options: PointCloudTileSourceOptions = {},
|
|
47
|
+
_coreApi?: CoreAPI
|
|
48
|
+
): PointCloudTileSource {
|
|
49
|
+
throw new Error(
|
|
50
|
+
'PointCloudTileSourceLoader requires preload() or @loaders.gl/tiles/point-cloud-tile-source-loader'
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
} as const satisfies SourceLoader<PointCloudTileSource>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {CoreAPI, SourceLoader} from '@loaders.gl/loader-utils';
|
|
6
|
+
import {PointCloudTileSource} from '@loaders.gl/tiles/point-cloud-tile-source';
|
|
7
|
+
import {PointCloudTileSourceLoader} from './point-cloud-tile-source-loader-types';
|
|
8
|
+
import type {
|
|
9
|
+
PointCloudTileSourceInput,
|
|
10
|
+
PointCloudTileSourceOptions
|
|
11
|
+
} from './point-cloud-tile-source-types';
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
preload: _preload,
|
|
15
|
+
createDataSource: _createDataSource,
|
|
16
|
+
...metadata
|
|
17
|
+
} = PointCloudTileSourceLoader;
|
|
18
|
+
|
|
19
|
+
/** Parser-bearing source factory for decoded point Mesh/Arrow data. */
|
|
20
|
+
export const PointCloudTileSourceLoaderWithParser = {
|
|
21
|
+
...metadata,
|
|
22
|
+
/** Creates a native-coordinate source with deferred child indexing. */
|
|
23
|
+
createDataSource(
|
|
24
|
+
input: PointCloudTileSourceInput | string | Blob,
|
|
25
|
+
options: PointCloudTileSourceOptions = {},
|
|
26
|
+
coreApi?: CoreAPI
|
|
27
|
+
): PointCloudTileSource {
|
|
28
|
+
if (typeof input === 'string' || input instanceof Blob)
|
|
29
|
+
throw new Error('PointCloudTileSourceLoader requires decoded Mesh/Arrow input');
|
|
30
|
+
return new PointCloudTileSource(input, options, coreApi);
|
|
31
|
+
}
|
|
32
|
+
} as const satisfies SourceLoader<PointCloudTileSource>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {DataSourceOptions} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {Mesh, MeshArrowTable} from '@loaders.gl/schema';
|
|
7
|
+
import type {PointCloudTilerOptions} from '@loaders.gl/schema-utils';
|
|
8
|
+
import type {TilesetSpatialReference} from './spatial/spatial-types';
|
|
9
|
+
|
|
10
|
+
/** Decoded points supplied to the dynamic point-cloud source. */
|
|
11
|
+
export type PointCloudTileSourceInput = Mesh | MeshArrowTable;
|
|
12
|
+
|
|
13
|
+
/** Options for native-coordinate, additive dynamic point tiling. */
|
|
14
|
+
export type PointCloudTileSourceOptions = DataSourceOptions & {
|
|
15
|
+
/** Point indexing, output and lifetime controls. No CRS is inferred. */
|
|
16
|
+
pointCloudTiler?: PointCloudTilerOptions & {
|
|
17
|
+
/** Spatial metadata for the input coordinates; retained without reprojection. */
|
|
18
|
+
readonly spatialReference?: TilesetSpatialReference;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {DataSource, type CoreAPI} from '@loaders.gl/loader-utils';
|
|
6
|
+
import {
|
|
7
|
+
PointCloudTiler,
|
|
8
|
+
convertMeshToTable,
|
|
9
|
+
type PointCloudTilerNode
|
|
10
|
+
} from '@loaders.gl/schema-utils';
|
|
11
|
+
import type {
|
|
12
|
+
PointCloudTileContent,
|
|
13
|
+
PointCloudTileHeader,
|
|
14
|
+
PointCloudTilesetSource
|
|
15
|
+
} from './point-cloud/types';
|
|
16
|
+
import type {
|
|
17
|
+
PointCloudTileSourceInput,
|
|
18
|
+
PointCloudTileSourceOptions
|
|
19
|
+
} from './point-cloud-tile-source-types';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Dynamic counterpart to vector table tiling, usable by PointCloudTileset and converter traversal.
|
|
23
|
+
* Each point belongs to one additive node. It retains native coordinates and explicit CRS metadata.
|
|
24
|
+
* Geometry stays in memory; output tiles are gathered on request and are not cached by this source.
|
|
25
|
+
*/
|
|
26
|
+
export class PointCloudTileSource
|
|
27
|
+
extends DataSource<null, PointCloudTileSourceOptions>
|
|
28
|
+
implements PointCloudTilesetSource<null, PointCloudTileSourceOptions>
|
|
29
|
+
{
|
|
30
|
+
/** Resolves after the root is indexed. */
|
|
31
|
+
readonly ready: Promise<void>;
|
|
32
|
+
/** Whether root indexing has completed successfully. */
|
|
33
|
+
isReady = false;
|
|
34
|
+
/** Shared portable index and ownership implementation. */
|
|
35
|
+
private readonly tiler: PointCloudTiler;
|
|
36
|
+
|
|
37
|
+
/** Creates a source from decoded points, without fetching or reprojecting input. */
|
|
38
|
+
constructor(
|
|
39
|
+
input: PointCloudTileSourceInput,
|
|
40
|
+
options: PointCloudTileSourceOptions = {},
|
|
41
|
+
coreApi?: CoreAPI
|
|
42
|
+
) {
|
|
43
|
+
super(null, options, {pointCloudTiler: {}}, coreApi);
|
|
44
|
+
this.tiler = new PointCloudTiler(input, options.pointCloudTiler);
|
|
45
|
+
this.ready = this.tiler.getRootNode().then(() => {
|
|
46
|
+
this.isReady = true;
|
|
47
|
+
});
|
|
48
|
+
this.ready.catch(() => {});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Waits for one shared indexing operation. */
|
|
52
|
+
async initialize(): Promise<void> {
|
|
53
|
+
await this.ready;
|
|
54
|
+
await this.tiler.getRootNode();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Reports exact source count and the additive ownership contract. */
|
|
58
|
+
async getMetadata(): Promise<{pointCount: number; refinement: 'ADD'}> {
|
|
59
|
+
await this.initialize();
|
|
60
|
+
return {pointCount: this.tiler.pointCount, refinement: 'ADD'};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Returns the sampled root and its native bounds. */
|
|
64
|
+
async getRootTile(): Promise<PointCloudTileHeader> {
|
|
65
|
+
return this.createHeader(await this.tiler.getRootNode());
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Discovers only the requested node's immediate children. */
|
|
69
|
+
async getChildren(tile: PointCloudTileHeader): Promise<PointCloudTileHeader[]> {
|
|
70
|
+
return (await this.tiler.getChildNodes(tile.id)).map(node => this.createHeader(node));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Gathers the requested point rows into a fresh Arrow tile, preserving attribute types. */
|
|
74
|
+
async loadTileContent(tile: PointCloudTileHeader): Promise<PointCloudTileContent | null> {
|
|
75
|
+
const mesh = await this.tiler.getTileMesh(tile.id);
|
|
76
|
+
if (!mesh.header!.vertexCount) return null;
|
|
77
|
+
return {
|
|
78
|
+
data: convertMeshToTable(mesh, 'arrow-table'),
|
|
79
|
+
pointCount: mesh.header!.vertexCount,
|
|
80
|
+
cartographicOrigin: [0, 0, 0],
|
|
81
|
+
coordinateSystem: 'cartesian',
|
|
82
|
+
spatialReference: this.options.pointCloudTiler.spatialReference,
|
|
83
|
+
spatialBoundingVolume: this.createHeader(await this.tiler.getNodeMetadata(tile.id))
|
|
84
|
+
.boundingVolume
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Releases the input table, attributes and index; safe to repeat. */
|
|
89
|
+
close(): void {
|
|
90
|
+
this.tiler.close();
|
|
91
|
+
this.isReady = false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Creates a conservative native-coordinate header without renderer projection math. */
|
|
95
|
+
private createHeader(node: PointCloudTilerNode): PointCloudTileHeader {
|
|
96
|
+
const center = node.bounds[0].map((value, axis) => value + (node.bounds[1][axis] - value) / 2);
|
|
97
|
+
const boundingVolume = {
|
|
98
|
+
cartographicBounds: node.bounds.map(corner => [...corner]) as [number[], number[]],
|
|
99
|
+
center,
|
|
100
|
+
radius: Math.hypot(...center.map((value, axis) => node.bounds[1][axis] - value)),
|
|
101
|
+
coordinateFrame: 'cartesian' as const
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
id: node.id,
|
|
105
|
+
level: node.level,
|
|
106
|
+
pointCount: node.pointCount,
|
|
107
|
+
geometricError: node.geometricError,
|
|
108
|
+
boundingVolume,
|
|
109
|
+
spatialBoundingVolume: boundingVolume
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -7,6 +7,7 @@ import {Vector3} from '@math.gl/core';
|
|
|
7
7
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
8
8
|
import type {ReadonlyCRSDefinition} from '@math.gl/crs';
|
|
9
9
|
import type {Projection} from '@math.gl/projection';
|
|
10
|
+
import {ProjectionBuffer} from '@math.gl/projection/bulk';
|
|
10
11
|
import {getGeoidModel, getSpatialProjectionEngine} from './spatial-resource-registry';
|
|
11
12
|
import {
|
|
12
13
|
normalizeCrsIdentifier,
|
|
@@ -35,6 +36,9 @@ export class SpatialCoordinateTransformer {
|
|
|
35
36
|
/** Projection from the source CRS directly to the requested horizontal target CRS. */
|
|
36
37
|
private readonly horizontalProjection?: Projection;
|
|
37
38
|
|
|
39
|
+
/** Reusable packed xyz projection for horizontal-only coordinate batches. */
|
|
40
|
+
private readonly horizontalProjectionBuffer?: ProjectionBuffer;
|
|
41
|
+
|
|
38
42
|
/** Projection from the source CRS to geographic longitude, latitude, and ellipsoidal height. */
|
|
39
43
|
private readonly geographicProjection?: Projection;
|
|
40
44
|
|
|
@@ -83,6 +87,12 @@ export class SpatialCoordinateTransformer {
|
|
|
83
87
|
to: getHorizontalProjectionDefinition(spatialReference.targetCrs),
|
|
84
88
|
enforceAxis: false
|
|
85
89
|
});
|
|
90
|
+
if (!requiresHeightTransformation(spatialReference)) {
|
|
91
|
+
this.horizontalProjectionBuffer = new ProjectionBuffer({
|
|
92
|
+
projection: this.horizontalProjection,
|
|
93
|
+
dimension: 3
|
|
94
|
+
});
|
|
95
|
+
}
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
if (
|
|
@@ -160,12 +170,22 @@ export class SpatialCoordinateTransformer {
|
|
|
160
170
|
return result;
|
|
161
171
|
}
|
|
162
172
|
|
|
163
|
-
/** Transform
|
|
173
|
+
/** Transform packed xyz positions into owned Float64 storage, batching finite horizontal transforms. */
|
|
164
174
|
transformPositions(positions: ArrayLike<number>): Float64Array {
|
|
165
175
|
if (positions.length % 3 !== 0) {
|
|
166
176
|
throw new Error('Packed spatial positions must contain a multiple of three components');
|
|
167
177
|
}
|
|
168
178
|
const transformedPositions = new Float64Array(positions.length);
|
|
179
|
+
if (this.horizontalProjectionBuffer) {
|
|
180
|
+
transformedPositions.set(positions);
|
|
181
|
+
// The bulk API rejects nonfinite ordinates; preserve scalar behavior for those inputs.
|
|
182
|
+
if (transformedPositions.every(Number.isFinite)) {
|
|
183
|
+
return this.horizontalProjectionBuffer.projectFlatTo(
|
|
184
|
+
transformedPositions,
|
|
185
|
+
transformedPositions
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
169
189
|
for (let index = 0; index < positions.length; index += 3) {
|
|
170
190
|
const transformed = this.transformPosition([
|
|
171
191
|
Number(positions[index]),
|
package/src/tileset-2d.ts
CHANGED
|
@@ -2,4 +2,28 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export {
|
|
6
|
+
SharedTile2DHeader,
|
|
7
|
+
Tileset2D,
|
|
8
|
+
STRATEGY_DEFAULT,
|
|
9
|
+
STRATEGY_NEVER,
|
|
10
|
+
STRATEGY_REPLACE
|
|
11
|
+
} from './tileset-2d/index';
|
|
12
|
+
export type {
|
|
13
|
+
Bounds,
|
|
14
|
+
GeoBoundingBox,
|
|
15
|
+
NonGeoBoundingBox,
|
|
16
|
+
TileBoundingBox,
|
|
17
|
+
TileIndex,
|
|
18
|
+
TileLoadProps,
|
|
19
|
+
ZRange,
|
|
20
|
+
Tileset2DAdapter,
|
|
21
|
+
Tileset2DTileContext,
|
|
22
|
+
Tileset2DTraversalContext,
|
|
23
|
+
Tile2DLoadDataProps,
|
|
24
|
+
RefinementStrategy,
|
|
25
|
+
RefinementStrategyFunction,
|
|
26
|
+
Tileset2DBaseProps,
|
|
27
|
+
Tileset2DProps,
|
|
28
|
+
Tile2DListener
|
|
29
|
+
} from './tileset-2d/index';
|
|
@@ -41,6 +41,8 @@ import {
|
|
|
41
41
|
export type {TilesetJSON} from './tileset-source';
|
|
42
42
|
|
|
43
43
|
export type Tileset3DProps = {
|
|
44
|
+
/** Format options forwarded to I3S content requests, including source-coordinate decoding. */
|
|
45
|
+
i3s?: Record<string, unknown>;
|
|
44
46
|
throttleRequests?: boolean;
|
|
45
47
|
maxRequests?: number;
|
|
46
48
|
loadOptions?: LoaderOptions;
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
// Copyright vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {LOD_METRIC_TYPE, TILE_REFINEMENT, TILE_TYPE} from '../../constants';
|
|
6
|
-
// TypeScript's legacy `node` resolution does not inspect package `exports`, but this public
|
|
7
|
-
// subpath is resolved by the package at runtime and avoids loading unrelated DGGS decoders.
|
|
8
|
-
// @ts-expect-error Conditional package subpath exports require a modern module resolver.
|
|
9
6
|
import {getS2DescendantIndex, getS2IndexFromToken, getS2TokenFromIndex} from '@math.gl/dggs/s2';
|
|
10
7
|
import {convertS2BoundingVolumeToOBB, type S2VolumeInfo} from '../helpers/s2-bounding-volume';
|
|
11
8
|
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright vis.gl contributors
|
|
4
4
|
|
|
5
|
-
// TypeScript's legacy `node` resolution does not inspect package `exports`, but this public
|
|
6
|
-
// subpath is resolved by the package at runtime and avoids loading unrelated DGGS decoders.
|
|
7
|
-
// @ts-expect-error Conditional package subpath exports require a modern module resolver.
|
|
8
5
|
import {getS2Bounds} from '@math.gl/dggs/s2';
|
|
9
6
|
import {Ellipsoid, makeOBBFromRegion} from '@math.gl/geospatial';
|
|
10
7
|
|