@loaders.gl/tile-converter 5.0.0-alpha.6 → 5.0.0-alpha.8

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 (96) hide show
  1. package/README.md +155 -0
  2. package/dist/converter.min.cjs +194 -194
  3. package/dist/i3s-server/bin/i3s-server.min.cjs +84 -84
  4. package/dist/index.cjs +35865 -0
  5. package/dist/index.js +35837 -0
  6. package/dist/v5/browser-sink.d.ts +37 -0
  7. package/dist/v5/browser-source.d.ts +38 -0
  8. package/dist/v5/browser-tileset-source.d.ts +70 -0
  9. package/dist/v5/browser.cjs +1962 -0
  10. package/dist/v5/browser.d.ts +18 -0
  11. package/dist/v5/browser.js +1927 -0
  12. package/dist/v5/conversion-api.d.ts +122 -0
  13. package/dist/v5/feature-arrow.d.ts +36 -0
  14. package/dist/v5/index.cjs +3975 -0
  15. package/dist/v5/index.d.ts +18 -0
  16. package/dist/v5/index.js +3928 -0
  17. package/dist/v5/point-cloud-conversion.d.ts +31 -0
  18. package/dist/v5/point-cloud-source-encoder.d.ts +49 -0
  19. package/dist/v5/point-cloud-source.d.ts +25 -0
  20. package/dist/v5/point-cloud.d.ts +24 -0
  21. package/dist/v5/resource-manifest.d.ts +58 -0
  22. package/dist/v5/spatial-conversion.d.ts +59 -0
  23. package/dist/v5/tileset-source.d.ts +21 -0
  24. package/package.json +41 -26
  25. package/src/common/README.md +5 -0
  26. package/src/index.ts +1 -2
  27. package/src/{3d-tiles-converter → v4/3d-tiles-converter}/3d-tiles-converter.ts +13 -2
  28. package/src/v4/3d-tiles-converter/helpers/validate-i3s-spatial-reference.ts +124 -0
  29. package/src/{deps-installer → v4/deps-installer}/deps-installer.ts +10 -7
  30. package/src/v4/i3s-converter/helpers/encode-string-attribute.ts +23 -0
  31. package/src/{i3s-converter → v4/i3s-converter}/helpers/geometry-converter.ts +15 -42
  32. package/src/{i3s-converter → v4/i3s-converter}/helpers/gltf-attributes.ts +5 -4
  33. package/src/{i3s-converter → v4/i3s-converter}/helpers/load-3d-tiles.ts +5 -9
  34. package/src/{i3s-converter → v4/i3s-converter}/i3s-converter.ts +6 -7
  35. package/src/{i3s-server → v4/i3s-server}/README.md +2 -2
  36. package/src/{i3s-server → v4/i3s-server}/routes/slpk-router.ts +1 -0
  37. package/src/v4/index.ts +2 -0
  38. package/src/v5/browser-sink.ts +129 -0
  39. package/src/v5/browser-source.ts +155 -0
  40. package/src/v5/browser-tileset-source.ts +328 -0
  41. package/src/v5/browser.ts +54 -0
  42. package/src/v5/conversion-api.ts +287 -0
  43. package/src/v5/feature-arrow.ts +427 -0
  44. package/src/v5/index.ts +47 -0
  45. package/src/v5/point-cloud-conversion.ts +80 -0
  46. package/src/v5/point-cloud-source-encoder.ts +102 -0
  47. package/src/v5/point-cloud-source.ts +84 -0
  48. package/src/v5/point-cloud.ts +271 -0
  49. package/src/v5/resource-manifest.ts +213 -0
  50. package/src/v5/spatial-conversion.ts +305 -0
  51. package/src/v5/tileset-source.ts +54 -0
  52. /package/src/{3d-tiles-converter → v4/3d-tiles-converter}/helpers/3d-tiles-content-converter.ts +0 -0
  53. /package/src/{3d-tiles-converter → v4/3d-tiles-converter}/helpers/i3s-obb-to-3d-tiles-obb.ts +0 -0
  54. /package/src/{3d-tiles-converter → v4/3d-tiles-converter}/helpers/load-i3s.ts +0 -0
  55. /package/src/{3d-tiles-converter → v4/3d-tiles-converter}/helpers/texture-atlas.ts +0 -0
  56. /package/src/{3d-tiles-converter → v4/3d-tiles-converter}/json-templates/tileset.ts +0 -0
  57. /package/src/{constants.ts → v4/constants.ts} +0 -0
  58. /package/src/{converter-cli.ts → v4/converter-cli.ts} +0 -0
  59. /package/src/{i3s-converter → v4/i3s-converter}/helpers/attribute-metadata-info.ts +0 -0
  60. /package/src/{i3s-converter → v4/i3s-converter}/helpers/batch-ids-extensions.ts +0 -0
  61. /package/src/{i3s-converter → v4/i3s-converter}/helpers/coordinate-converter.ts +0 -0
  62. /package/src/{i3s-converter → v4/i3s-converter}/helpers/create-scene-server-path.ts +0 -0
  63. /package/src/{i3s-converter → v4/i3s-converter}/helpers/feature-attributes.ts +0 -0
  64. /package/src/{i3s-converter → v4/i3s-converter}/helpers/geometry-attributes.ts +0 -0
  65. /package/src/{i3s-converter → v4/i3s-converter}/helpers/node-debug.ts +0 -0
  66. /package/src/{i3s-converter → v4/i3s-converter}/helpers/node-index-document.ts +0 -0
  67. /package/src/{i3s-converter → v4/i3s-converter}/helpers/node-pages.ts +0 -0
  68. /package/src/{i3s-converter → v4/i3s-converter}/helpers/preprocess-3d-tiles.ts +0 -0
  69. /package/src/{i3s-converter → v4/i3s-converter}/helpers/progress.ts +0 -0
  70. /package/src/{i3s-converter → v4/i3s-converter}/helpers/tileset-traversal.ts +0 -0
  71. /package/src/{i3s-converter → v4/i3s-converter}/json-templates/geometry-definitions.ts +0 -0
  72. /package/src/{i3s-converter → v4/i3s-converter}/json-templates/layers.ts +0 -0
  73. /package/src/{i3s-converter → v4/i3s-converter}/json-templates/metadata.ts +0 -0
  74. /package/src/{i3s-converter → v4/i3s-converter}/json-templates/node.ts +0 -0
  75. /package/src/{i3s-converter → v4/i3s-converter}/json-templates/scene-server.ts +0 -0
  76. /package/src/{i3s-converter → v4/i3s-converter}/json-templates/shared-resources.ts +0 -0
  77. /package/src/{i3s-converter → v4/i3s-converter}/json-templates/store.ts +0 -0
  78. /package/src/{i3s-converter → v4/i3s-converter}/types.ts +0 -0
  79. /package/src/{i3s-server → v4/i3s-server}/app.ts +0 -0
  80. /package/src/{i3s-server → v4/i3s-server}/bin/www.ts +0 -0
  81. /package/src/{i3s-server → v4/i3s-server}/certs/cert.pem +0 -0
  82. /package/src/{i3s-server → v4/i3s-server}/certs/key.pem +0 -0
  83. /package/src/{i3s-server → v4/i3s-server}/controllers/slpk-controller.ts +0 -0
  84. /package/src/{i3s-server → v4/i3s-server}/utils/create-scene-server.ts +0 -0
  85. /package/src/{i3s-server → v4/i3s-server}/utils/server-utils.ts +0 -0
  86. /package/src/{lib → v4/lib}/json-schemas/conversion-dump-json-schema.ts +0 -0
  87. /package/src/{lib → v4/lib}/utils/cli-utils.ts +0 -0
  88. /package/src/{lib → v4/lib}/utils/compress-util.ts +0 -0
  89. /package/src/{lib → v4/lib}/utils/conversion-dump.ts +0 -0
  90. /package/src/{lib → v4/lib}/utils/file-utils.ts +0 -0
  91. /package/src/{lib → v4/lib}/utils/geometry-utils.ts +0 -0
  92. /package/src/{lib → v4/lib}/utils/lod-conversion-utils.ts +0 -0
  93. /package/src/{lib → v4/lib}/utils/queue.ts +0 -0
  94. /package/src/{lib → v4/lib}/utils/statistic-utils.ts +0 -0
  95. /package/src/{lib → v4/lib}/utils/write-queue.ts +0 -0
  96. /package/src/{pgm-loader.ts → v4/pgm-loader.ts} +0 -0
package/README.md CHANGED
@@ -6,6 +6,161 @@ This module contains command line scripts and JavaScript APIs for converting bet
6
6
 
7
7
  For documentation please visit the [website](https://loaders.gl).
8
8
 
9
+ ## Source layout
10
+
11
+ The original converter implementation lives in `src/v4`, and the newer conversion APIs live in
12
+ `src/v5`. The package root remains the compatibility entrypoint for the original converter. Shared
13
+ implementation belongs in `src/common` only when it is intentionally used by multiple versions.
14
+
15
+ ## V5 source-backed mesh traversal
16
+
17
+ `createTilesetConversionSource(tileset)` adapts an initializing or initialized `Tileset3D` backed
18
+ by `Tiles3DSource`, `I3SSource`, or a compatible archive source to the v5 conversion core. Inspection
19
+ returns normalized source metadata after initialization. Reading delegates to shared
20
+ camera-independent traversal and yields one placement with all its ordered decoded content entries,
21
+ including empty placements. A codec can inspect each content's payload, feature descriptors and
22
+ bounds together with the tile's placement transform.
23
+
24
+ ```ts
25
+ import {createTilesetConversionSource, convertTileset} from '@loaders.gl/tile-converter/v5';
26
+
27
+ const report = await convertTileset({
28
+ source: createTilesetConversionSource(tileset, {unloadContent: true}),
29
+ codec: meshCodec,
30
+ sink: outputSink,
31
+ measureInputBytes: measureDecodedTileBytes,
32
+ measureOutputBytes: measureEncodedResourceBytes,
33
+ maxInputResourceBytes: 16 * 1024 * 1024,
34
+ signal: abortController.signal
35
+ });
36
+ ```
37
+
38
+ Writes are awaited by the core before traversal advances. The example uses a runtime dedicated to
39
+ conversion and enables `unloadContent` to release newly loaded payloads after their codec and writes
40
+ finish. Cleanup also runs when iteration closes on failure or cancellation, including rejection by
41
+ the input-size gate. Consume payloads before advancing; codecs and sinks must not retain them after
42
+ their work completes. Preloaded payloads are retained. Omit the option to keep all loaded content
43
+ attached, as before. Applications still own tileset destruction and source/archive lifetimes.
44
+
45
+ This adapter does not bound aggregate input memory, apply CRS transforms, or supply a mesh codec
46
+ or output packaging. Inspection observes
47
+ cancellation before and after initialization; initialization and in-flight content reads retain the
48
+ underlying source's cancellation behavior.
49
+
50
+ `maxInputResourceBytes` limits one decoded input placement before the codec runs. The example
51
+ allows up to 16 MiB as measured by the application's `measureInputBytes` callback, which must return
52
+ a nonnegative safe integer and account for all decoded contents in the placement. Equality is
53
+ allowed; zero permits only empty inputs. Omit the limit or use `Infinity` for no limit. Oversized
54
+ inputs throw `INPUT_RESOURCE_TOO_LARGE`, close source iteration, and abort the destination.
55
+ This check runs after the source read, so decoding allocations and retained source content still
56
+ require source-level controls. `convertPointCloudSource` accepts the same option for decoded tiles.
57
+
58
+ ## V5 spatial conversion
59
+
60
+ The `@loaders.gl/tile-converter/v5` entrypoint can reuse the CRS and elevation operations from
61
+ `@loaders.gl/tiles` when preparing conversion resources. Discover source metadata with
62
+ `get3DTilesSpatialReference` or `getI3SSpatialReference`, then create the matching conversion
63
+ context with an explicit target CRS or height reference when transformation is required. The
64
+ context provides double-precision positions, transformed normals and conservative bounds, plus the
65
+ spatial reference that belongs in output metadata. Required geoid grids and terrain or scene
66
+ providers are passed by the application; the conversion core does not guess a CRS or fetch spatial
67
+ resources implicitly.
68
+
69
+ ```ts
70
+ import {createI3SConversionSpatialContext} from '@loaders.gl/tile-converter/v5';
71
+ import {getI3SSpatialReference} from '@loaders.gl/tiles';
72
+
73
+ const spatial = createI3SConversionSpatialContext(
74
+ getI3SSpatialReference(layerMetadata),
75
+ {targetCrs: 'EPSG:3857'}
76
+ );
77
+ const transformed = spatial.transformPositions(positions, nodeOrigin);
78
+ ```
79
+
80
+ ## V5 feature attributes
81
+
82
+ `convertFeatureAttributesToArrowBatches` writes decoded feature attributes using an explicit Arrow
83
+ schema. The schema owns property types, nested list/struct mappings, enum representations, and the
84
+ feature ID type. IDs may be strings or exact integer values (`bigint` for values outside JavaScript's
85
+ safe integer range). Unknown properties fail instead of disappearing. Supply a binary
86
+ `rawMetadataField` to retain the original encoded metadata alongside interpreted values. Pass each
87
+ source metadata class separately so its name remains attached to the batch schema.
88
+
89
+ ```ts
90
+ import {convertFeatureAttributesToArrowBatches} from '@loaders.gl/tile-converter/v5';
91
+
92
+ const batches = convertFeatureAttributesToArrowBatches(features, {
93
+ schema: {
94
+ fields: [
95
+ {name: 'feature_id', type: 'int64', nullable: false},
96
+ {name: 'name', type: 'utf8', nullable: true}
97
+ ],
98
+ metadata: {}
99
+ },
100
+ batchSize: 65536
101
+ });
102
+ ```
103
+
104
+ ## V5 restartable output sinks
105
+
106
+ `createManifestBackedTileConversionSink` resumes matching resources using caller-provided IDs and
107
+ fingerprints. Applications provide an atomic manifest store and an idempotent resource sink, keeping
108
+ filesystem and archive choices outside the conversion API.
109
+
110
+ ## V5 point-cloud sources
111
+
112
+ `traversePointCloudSource` walks an I3S Point Cloud, COPC, or compatible source independently of a
113
+ render camera. It yields each reachable tile's header and decoded Mesh Arrow content in
114
+ depth-first order, retaining source bounds, coordinate-system metadata, and placement information
115
+ for the output encoder. `encodePointCloudSource` streams non-empty PNTS resources, each paired with
116
+ its original header, coordinate system, origin, and transform. `encodePointCloudSourceTile` encodes
117
+ one yielded tile. Set `maxDepth` to bound traversal; pass an `AbortSignal` to stop between source
118
+ operations. These helpers do not transform coordinates or package a tileset manifest.
119
+
120
+ Pass encoder options directly to `encodePointCloudSourceTile`, or select them for each non-empty
121
+ tile with `encodePointCloudSource`'s `getTileEncodingOptions` callback. A declared `rtcCenter` in the
122
+ point-position coordinate frame is subtracted before float32 encoding and stored as PNTS
123
+ `RTC_CENTER`, retaining small offsets in large double-precision coordinates. `batchTableJson`
124
+ supplies properties for existing `BATCH_ID` values. An explicit `constantRGBA` overrides the source
125
+ constant color; the source origin and placement transform remain attached to the encoded tile.
126
+
127
+ The PNTS encoder accepts `POSITION`, `NORMAL`, `BATCH_ID`, and one color attribute (`COLOR_0` or
128
+ `COLOR`). Other attributes, including classification, intensity, and an additional color column,
129
+ raise `POINT_CLOUD_ATTRIBUTE_UNSUPPORTED` rather than silently disappearing. Applications must
130
+ explicitly map unsupported fields to supported batch-table properties or remove them before
131
+ encoding; this initial encoder does not automatically map point attributes.
132
+
133
+ `convertPointCloudSource` connects the same traversal and encoder to a
134
+ `TileConversionSink<EncodedPointCloudSourceTile>`. Writes are awaited before reading the next tile;
135
+ the sink is finalized on success and aborted on failures or cancellation. Set
136
+ `maxOutputResourceBytes` to limit each PNTS resource and use `onProgress` for the shared v5 progress
137
+ report. `maxDepth`, `signal`, and `getTileEncodingOptions` have the same meanings as above.
138
+ Applications provide `measureInputBytes` for decoded input accounting, returning zero for empty
139
+ tiles when appropriate. Reports count visited tile headers as inputs, including empty tiles, and
140
+ encoded PNTS tiles as outputs. Applications own source cleanup and output naming and packaging.
141
+
142
+ ```ts
143
+ import {convertPointCloudSource} from '@loaders.gl/tile-converter/v5';
144
+
145
+ const report = await convertPointCloudSource(pointCloudSource, {
146
+ sink: outputSink,
147
+ measureInputBytes: measureDecodedTileBytes,
148
+ maxOutputResourceBytes: 8 * 1024 * 1024,
149
+ signal: abortController.signal
150
+ });
151
+ ```
152
+
153
+ ## V5 browser entrypoint
154
+
155
+ Import `@loaders.gl/tile-converter/v5/browser` for the portable conversion API,
156
+ `createBrowserTileConversionSource`, `createBrowserTilesetConversionSource`, and
157
+ `createBoundedMemoryTileConversionSink`. The single-resource source reads one URL or Blob. The
158
+ tileset source traverses explicit 3D Tiles 1.0 and 1.1 documents in depth-first order and reads each
159
+ declared content placement under aggregate byte and resource limits. It rejects implicit tiling and
160
+ nested JSON content. Both sources yield raw bytes to an application-provided codec. The sink retains
161
+ named Blob outputs under a required total-byte limit; applications remain responsible for codecs,
162
+ packaging, and triggering downloads.
163
+
9
164
  ## Installation
10
165
 
11
166
  ```bash