@loaders.gl/tile-converter 5.0.0-alpha.10 → 5.0.0-alpha.11
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 +33 -0
- package/dist/converter.min.cjs +103 -103
- package/dist/i3s-server/bin/i3s-server.min.cjs +1 -1
- package/dist/index.cjs +651 -547
- package/dist/index.js +641 -537
- package/dist/v5/adapters.cjs +1756 -200
- package/dist/v5/adapters.d.ts +13 -2
- package/dist/v5/adapters.js +1755 -190
- package/dist/v5/browser.cjs +12 -0
- package/dist/v5/browser.d.ts +12 -2
- package/dist/v5/browser.js +19 -1
- package/dist/v5/core.cjs +54 -0
- package/dist/v5/core.js +54 -0
- package/dist/v5/i3s-mesh-conversion.d.ts +10 -4
- package/dist/v5/i3s-mesh-sink.d.ts +25 -0
- package/dist/v5/i3s-mesh-source-features.d.ts +13 -0
- package/dist/v5/i3s-mesh-source-material.d.ts +5 -0
- package/dist/v5/i3s-mesh-source.d.ts +30 -0
- package/dist/v5/index.cjs +10 -0
- package/dist/v5/index.d.ts +10 -2
- package/dist/v5/index.js +17 -1
- package/dist/v5/mesh-conversion.d.ts +11 -2
- package/dist/v5/mesh-features.d.ts +9 -0
- package/dist/v5/mesh-source-texture.d.ts +2 -0
- package/dist/v5/mesh-source.d.ts +8 -1
- package/dist/v5/mesh.d.ts +6 -1
- package/dist/v5/point-cloud-source-encoder.d.ts +4 -7
- package/dist/v5/point-cloud-spatial.d.ts +22 -0
- package/dist/v5/point-cloud-tileset-sink.d.ts +28 -0
- package/dist/v5/point-cloud.d.ts +26 -1
- package/dist/v5/resource-fetcher.d.ts +18 -0
- package/dist/v5/spatial-conversion.d.ts +3 -1
- package/package.json +23 -23
- package/src/v5/adapters.ts +21 -2
- package/src/v5/browser.ts +36 -2
- package/src/v5/i3s-mesh-conversion.ts +58 -18
- package/src/v5/i3s-mesh-sink.ts +351 -0
- package/src/v5/i3s-mesh-source-features.ts +279 -0
- package/src/v5/i3s-mesh-source-material.ts +157 -0
- package/src/v5/i3s-mesh-source.ts +227 -0
- package/src/v5/index.ts +34 -2
- package/src/v5/mesh-conversion.ts +41 -11
- package/src/v5/mesh-draco.ts +47 -3
- package/src/v5/mesh-features.ts +319 -0
- package/src/v5/mesh-source-features.ts +37 -6
- package/src/v5/mesh-source-texture.ts +47 -0
- package/src/v5/mesh-source.ts +83 -21
- package/src/v5/mesh.ts +16 -7
- package/src/v5/point-cloud-conversion.ts +9 -1
- package/src/v5/point-cloud-source-encoder.ts +31 -20
- package/src/v5/point-cloud-spatial.ts +280 -0
- package/src/v5/point-cloud-tileset-sink.ts +234 -0
- package/src/v5/point-cloud.ts +159 -32
- package/src/v5/resource-fetcher.ts +110 -0
- package/src/v5/spatial-conversion.ts +84 -0
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
CreateTilesetSpatialReferenceOptions,
|
|
14
14
|
I3SSpatialBounds,
|
|
15
15
|
I3STransformedPositions,
|
|
16
|
+
I3STransformedGeometry,
|
|
16
17
|
Tiles3DSpatialBoundingVolume,
|
|
17
18
|
TilesetSpatialOptions,
|
|
18
19
|
TilesetSpatialReference
|
|
@@ -44,6 +45,12 @@ export interface I3SConversionSpatialContext {
|
|
|
44
45
|
positions: ArrayLike<number>,
|
|
45
46
|
sourceOrigin: ArrayLike<number>
|
|
46
47
|
): I3STransformedPositions;
|
|
48
|
+
/** Transform absolute conversion geometry without intermediate float32 rounding. */
|
|
49
|
+
transformGeometryAsync(
|
|
50
|
+
positions: ArrayLike<number>,
|
|
51
|
+
normals?: ArrayLike<number>,
|
|
52
|
+
normalReferenceFrame?: string
|
|
53
|
+
): Promise<I3STransformedGeometry>;
|
|
47
54
|
/** Transform absolute I3S positions when terrain or scene sampling is asynchronous. */
|
|
48
55
|
transformPositionsAsync(
|
|
49
56
|
positions: ArrayLike<number>,
|
|
@@ -87,6 +94,13 @@ export function createTiles3DConversionSpatialContext(
|
|
|
87
94
|
throw createSpatialConversionError(spatialReference);
|
|
88
95
|
}
|
|
89
96
|
|
|
97
|
+
if (spatialReference.status !== 'native' && spatialReference.coordinateEpoch !== undefined) {
|
|
98
|
+
throw new TileConversionError(
|
|
99
|
+
'SPATIAL_EPOCH_UNSUPPORTED',
|
|
100
|
+
'Epoch-tagged coordinates require an epoch-aware datum operation before conversion'
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
90
104
|
const transformer =
|
|
91
105
|
spatialReference.status === 'native'
|
|
92
106
|
? undefined
|
|
@@ -131,6 +145,13 @@ export function createI3SConversionSpatialContext(
|
|
|
131
145
|
throw createSpatialConversionError(spatialReference);
|
|
132
146
|
}
|
|
133
147
|
|
|
148
|
+
if (spatialReference.status !== 'native' && spatialReference.coordinateEpoch !== undefined) {
|
|
149
|
+
throw new TileConversionError(
|
|
150
|
+
'SPATIAL_EPOCH_UNSUPPORTED',
|
|
151
|
+
'Epoch-tagged coordinates require an epoch-aware datum operation before conversion'
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
134
155
|
const transformer =
|
|
135
156
|
spatialReference.status === 'native'
|
|
136
157
|
? undefined
|
|
@@ -139,6 +160,44 @@ export function createI3SConversionSpatialContext(
|
|
|
139
160
|
() => new I3SSpatialTransformer(spatialReference, options)
|
|
140
161
|
);
|
|
141
162
|
const outputSpatialReference = transformer ? transformer.spatialReference : spatialReference;
|
|
163
|
+
// I3S vector bases can differ from the coordinate basis even when positions retain their CRS.
|
|
164
|
+
let nativeNormalTransformer: I3SSpatialTransformer | undefined;
|
|
165
|
+
/** Maps native I3S vectors into the writer basis without reprojecting its positions. */
|
|
166
|
+
const transformNativeNormals = (
|
|
167
|
+
normals: ArrayLike<number>,
|
|
168
|
+
positions: ArrayLike<number>,
|
|
169
|
+
normalReferenceFrame?: string
|
|
170
|
+
): Float32Array => {
|
|
171
|
+
if (
|
|
172
|
+
!spatialReference.sourceCrs ||
|
|
173
|
+
['local', 'cartesian'].includes(spatialReference.coordinateFrame)
|
|
174
|
+
) {
|
|
175
|
+
// Unreferenced/native local vectors already use the retained position basis.
|
|
176
|
+
const targetNormals = Float32Array.from(normals);
|
|
177
|
+
for (let index = 0; index < normals.length; index += 3) {
|
|
178
|
+
const length = Math.hypot(normals[index], normals[index + 1], normals[index + 2]);
|
|
179
|
+
if (length) {
|
|
180
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
181
|
+
targetNormals[index + axis] = normals[index + axis] / length;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return targetNormals;
|
|
186
|
+
}
|
|
187
|
+
nativeNormalTransformer ||= createSpatialTransformer(
|
|
188
|
+
spatialReference,
|
|
189
|
+
() =>
|
|
190
|
+
new I3SSpatialTransformer(
|
|
191
|
+
{
|
|
192
|
+
...spatialReference,
|
|
193
|
+
status: 'transformable',
|
|
194
|
+
targetCrs: spatialReference.sourceCrs
|
|
195
|
+
},
|
|
196
|
+
options
|
|
197
|
+
)
|
|
198
|
+
);
|
|
199
|
+
return nativeNormalTransformer.transformNormals(normals, positions, normalReferenceFrame);
|
|
200
|
+
};
|
|
142
201
|
|
|
143
202
|
return {
|
|
144
203
|
spatialReference: outputSpatialReference,
|
|
@@ -146,6 +205,31 @@ export function createI3SConversionSpatialContext(
|
|
|
146
205
|
transformer
|
|
147
206
|
? transformer.transformPositions(positions, sourceOrigin)
|
|
148
207
|
: createNativeI3SPositions(positions, sourceOrigin, spatialReference),
|
|
208
|
+
transformGeometryAsync: async (positions, normals, normalReferenceFrame) => {
|
|
209
|
+
if (transformer)
|
|
210
|
+
return transformer.transformGeometryAsync(positions, normals, normalReferenceFrame);
|
|
211
|
+
const targetPositions = Float64Array.from(positions);
|
|
212
|
+
if (
|
|
213
|
+
targetPositions.length % 3 ||
|
|
214
|
+
targetPositions.some(value => !Number.isFinite(value)) ||
|
|
215
|
+
(normals &&
|
|
216
|
+
(normals.length !== positions.length ||
|
|
217
|
+
Array.from(normals).some(value => !Number.isFinite(value)))) ||
|
|
218
|
+
(normalReferenceFrame !== undefined &&
|
|
219
|
+
!['earth-centered', 'vertex-reference-frame'].includes(normalReferenceFrame))
|
|
220
|
+
) {
|
|
221
|
+
throw new TileConversionError(
|
|
222
|
+
'SPATIAL_INPUT_INVALID',
|
|
223
|
+
'Conversion geometry requires finite matching xyz arrays and a supported I3S vector frame'
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
positions: targetPositions,
|
|
228
|
+
normals: normals
|
|
229
|
+
? transformNativeNormals(normals, positions, normalReferenceFrame)
|
|
230
|
+
: undefined
|
|
231
|
+
};
|
|
232
|
+
},
|
|
149
233
|
transformPositionsAsync: (positions, sourceOrigin) =>
|
|
150
234
|
transformer
|
|
151
235
|
? transformer.transformPositionsAsync(positions, sourceOrigin)
|