@loaders.gl/i3s 3.2.7 → 3.3.0-alpha.3
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.min.js +62 -55
- package/dist/es5/arcgis-webscene-loader.js +1 -1
- package/dist/es5/arcgis-webscene-loader.js.map +1 -1
- package/dist/es5/i3s-attribute-loader.js +1 -1
- package/dist/es5/i3s-attribute-loader.js.map +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/es5/i3s-content-loader.js +22 -9
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +36 -38
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +1 -1
- package/dist/es5/i3s-node-page-loader.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +75 -77
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/workers/i3s-content-nodejs-worker.js +10 -0
- package/dist/es5/workers/i3s-content-nodejs-worker.js.map +1 -0
- package/dist/esm/arcgis-webscene-loader.js +1 -1
- package/dist/esm/arcgis-webscene-loader.js.map +1 -1
- package/dist/esm/i3s-attribute-loader.js +1 -1
- package/dist/esm/i3s-attribute-loader.js.map +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/esm/i3s-content-loader.js +14 -5
- package/dist/esm/i3s-content-loader.js.map +1 -1
- package/dist/esm/i3s-loader.js +8 -12
- package/dist/esm/i3s-loader.js.map +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -1
- package/dist/esm/i3s-node-page-loader.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +35 -33
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/workers/i3s-content-nodejs-worker.js +5 -0
- package/dist/esm/workers/i3s-content-nodejs-worker.js.map +1 -0
- package/dist/i3s-building-scene-layer-loader.js +1 -1
- package/dist/i3s-content-loader.d.ts.map +1 -1
- package/dist/i3s-content-loader.js +10 -5
- package/dist/i3s-content-nodejs-worker.js +200 -0
- package/dist/i3s-content-nodejs-worker.js.map +7 -0
- package/dist/i3s-content-worker.js +56 -49
- package/dist/i3s-loader.d.ts +5 -0
- package/dist/i3s-loader.d.ts.map +1 -1
- package/dist/i3s-loader.js +6 -9
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts +2 -2
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js +35 -32
- package/dist/lib/parsers/parse-i3s.d.ts +1 -1
- package/dist/lib/parsers/parse-i3s.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s.js +1 -1
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/workers/i3s-content-nodejs-worker.d.ts +2 -0
- package/dist/workers/i3s-content-nodejs-worker.d.ts.map +1 -0
- package/dist/workers/i3s-content-nodejs-worker.js +6 -0
- package/package.json +11 -10
- package/src/i3s-building-scene-layer-loader.ts +1 -1
- package/src/i3s-content-loader.ts +20 -7
- package/src/i3s-loader.ts +15 -12
- package/src/lib/parsers/parse-i3s-tile-content.ts +44 -41
- package/src/lib/parsers/parse-i3s.ts +1 -1
- package/src/types.ts +45 -0
- package/src/workers/i3s-content-nodejs-worker.ts +5 -0
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
56
56
|
|
|
57
57
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
58
|
-
var VERSION = true ? "3.
|
|
58
|
+
var VERSION = true ? "3.3.0-alpha.3" : DEFAULT_VERSION;
|
|
59
59
|
if (false) {
|
|
60
60
|
console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
61
61
|
}
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
this.worker = isBrowser2 ? this._createBrowserWorker() : this._createNodeWorker();
|
|
213
213
|
}
|
|
214
214
|
static isSupported() {
|
|
215
|
-
return typeof Worker !== "undefined" && isBrowser2 || typeof Worker2 !==
|
|
215
|
+
return typeof Worker !== "undefined" && isBrowser2 || typeof Worker2 !== "undefined" && !isBrowser2;
|
|
216
216
|
}
|
|
217
217
|
destroy() {
|
|
218
218
|
this.onMessage = NOOP;
|
|
@@ -518,7 +518,7 @@
|
|
|
518
518
|
}
|
|
519
519
|
|
|
520
520
|
// ../worker-utils/src/lib/worker-api/get-worker-url.ts
|
|
521
|
-
var NPM_TAG = "
|
|
521
|
+
var NPM_TAG = "beta";
|
|
522
522
|
function getWorkerURL(worker, options = {}) {
|
|
523
523
|
const workerOptions = options[worker.id] || {};
|
|
524
524
|
const workerFile = `${worker.id}-worker.js`;
|
|
@@ -553,7 +553,7 @@
|
|
|
553
553
|
|
|
554
554
|
// ../worker-utils/src/lib/library-utils/library-utils.ts
|
|
555
555
|
var node = __toModule(require_require_utils());
|
|
556
|
-
var LATEST = "
|
|
556
|
+
var LATEST = "beta";
|
|
557
557
|
var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
|
|
558
558
|
var loadLibraryPromises = {};
|
|
559
559
|
async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
|
|
@@ -1082,7 +1082,7 @@
|
|
|
1082
1082
|
var process_ = globals3.process || {};
|
|
1083
1083
|
|
|
1084
1084
|
// ../../node_modules/probe.gl/dist/esm/utils/globals.js
|
|
1085
|
-
var VERSION3 = true ? "3.
|
|
1085
|
+
var VERSION3 = true ? "3.3.0-alpha.3" : "untranspiled source";
|
|
1086
1086
|
var isBrowser4 = isBrowser3();
|
|
1087
1087
|
|
|
1088
1088
|
// ../../node_modules/probe.gl/dist/esm/utils/local-storage.js
|
|
@@ -1828,7 +1828,7 @@
|
|
|
1828
1828
|
var process_2 = globals4.process || {};
|
|
1829
1829
|
|
|
1830
1830
|
// ../../node_modules/@probe.gl/env/dist/esm/utils/globals.js
|
|
1831
|
-
var VERSION4 = true ? "3.
|
|
1831
|
+
var VERSION4 = true ? "3.3.0-alpha.3" : "untranspiled source";
|
|
1832
1832
|
var isBrowser6 = isBrowser5();
|
|
1833
1833
|
|
|
1834
1834
|
// ../../node_modules/@probe.gl/log/dist/esm/utils/local-storage.js
|
|
@@ -4950,7 +4950,7 @@
|
|
|
4950
4950
|
};
|
|
4951
4951
|
|
|
4952
4952
|
// ../images/src/lib/utils/version.ts
|
|
4953
|
-
var VERSION5 = true ? "3.
|
|
4953
|
+
var VERSION5 = true ? "3.3.0-alpha.3" : "latest";
|
|
4954
4954
|
|
|
4955
4955
|
// ../images/src/lib/category-api/image-type.ts
|
|
4956
4956
|
var { _parseImageNode } = globalThis;
|
|
@@ -5298,7 +5298,7 @@
|
|
|
5298
5298
|
};
|
|
5299
5299
|
|
|
5300
5300
|
// ../draco/src/lib/utils/version.ts
|
|
5301
|
-
var VERSION6 = true ? "3.
|
|
5301
|
+
var VERSION6 = true ? "3.3.0-alpha.3" : "latest";
|
|
5302
5302
|
|
|
5303
5303
|
// ../draco/src/draco-loader.ts
|
|
5304
5304
|
var DEFAULT_DRACO_OPTIONS = {
|
|
@@ -5311,7 +5311,7 @@
|
|
|
5311
5311
|
};
|
|
5312
5312
|
var DracoLoader = {
|
|
5313
5313
|
name: "Draco",
|
|
5314
|
-
id: "draco",
|
|
5314
|
+
id: isBrowser2 ? "draco" : "draco-nodejs",
|
|
5315
5315
|
module: "draco",
|
|
5316
5316
|
shapes: ["mesh"],
|
|
5317
5317
|
version: VERSION6,
|
|
@@ -6282,10 +6282,10 @@
|
|
|
6282
6282
|
}
|
|
6283
6283
|
|
|
6284
6284
|
// ../textures/src/lib/utils/version.ts
|
|
6285
|
-
var VERSION7 = true ? "3.
|
|
6285
|
+
var VERSION7 = true ? "3.3.0-alpha.3" : "beta";
|
|
6286
6286
|
|
|
6287
6287
|
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
6288
|
-
var VERSION8 = true ? "3.
|
|
6288
|
+
var VERSION8 = true ? "3.3.0-alpha.3" : "beta";
|
|
6289
6289
|
var BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION8}/dist/libs/basis_encoder.wasm`;
|
|
6290
6290
|
var BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION8}/dist/libs/basis_encoder.js`;
|
|
6291
6291
|
var loadBasisTranscoderPromise;
|
|
@@ -6874,7 +6874,7 @@
|
|
|
6874
6874
|
// ../textures/src/basis-loader.ts
|
|
6875
6875
|
var BasisWorkerLoader = {
|
|
6876
6876
|
name: "Basis",
|
|
6877
|
-
id: "basis",
|
|
6877
|
+
id: isBrowser2 ? "basis" : "basis-nodejs",
|
|
6878
6878
|
module: "textures",
|
|
6879
6879
|
version: VERSION7,
|
|
6880
6880
|
worker: true,
|
|
@@ -7936,29 +7936,36 @@
|
|
|
7936
7936
|
}
|
|
7937
7937
|
}
|
|
7938
7938
|
var I3S_ATTRIBUTE_TYPE = "i3s-attribute-type";
|
|
7939
|
-
async function parseI3STileContent(arrayBuffer,
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7939
|
+
async function parseI3STileContent(arrayBuffer, tileOptions, tilesetOptions, options, context) {
|
|
7940
|
+
const content = {
|
|
7941
|
+
attributes: {},
|
|
7942
|
+
indices: null,
|
|
7943
|
+
featureIds: [],
|
|
7944
|
+
vertexCount: 0,
|
|
7945
|
+
modelMatrix: new Matrix4(),
|
|
7946
|
+
coordinateSystem: 0,
|
|
7947
|
+
byteLength: 0,
|
|
7948
|
+
texture: null
|
|
7949
|
+
};
|
|
7950
|
+
if (tileOptions.textureUrl) {
|
|
7951
|
+
const url = getUrlWithToken(tileOptions.textureUrl, options?.i3s?.token);
|
|
7952
|
+
const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
7946
7953
|
const response = await fetch(url, options?.fetch);
|
|
7947
7954
|
const arrayBuffer2 = await response.arrayBuffer();
|
|
7948
7955
|
if (options?.i3s.decodeTextures) {
|
|
7949
7956
|
if (loader === ImageLoader) {
|
|
7950
|
-
const options2 = { ...
|
|
7957
|
+
const options2 = { ...tileOptions.textureLoaderOptions, image: { type: "data" } };
|
|
7951
7958
|
try {
|
|
7952
|
-
|
|
7959
|
+
content.texture = await context.parse(arrayBuffer2, options2);
|
|
7953
7960
|
} catch (e2) {
|
|
7954
|
-
|
|
7961
|
+
content.texture = await parse(arrayBuffer2, loader, options2);
|
|
7955
7962
|
}
|
|
7956
7963
|
} else if (loader === CompressedTextureLoader || loader === BasisLoader) {
|
|
7957
|
-
let texture = await load(arrayBuffer2, loader,
|
|
7964
|
+
let texture = await load(arrayBuffer2, loader, tileOptions.textureLoaderOptions);
|
|
7958
7965
|
if (loader === BasisLoader) {
|
|
7959
7966
|
texture = texture[0];
|
|
7960
7967
|
}
|
|
7961
|
-
|
|
7968
|
+
content.texture = {
|
|
7962
7969
|
compressed: true,
|
|
7963
7970
|
mipmaps: false,
|
|
7964
7971
|
width: texture[0].width,
|
|
@@ -7967,27 +7974,23 @@
|
|
|
7967
7974
|
};
|
|
7968
7975
|
}
|
|
7969
7976
|
} else {
|
|
7970
|
-
|
|
7977
|
+
content.texture = arrayBuffer2;
|
|
7971
7978
|
}
|
|
7972
7979
|
}
|
|
7973
|
-
|
|
7974
|
-
if (
|
|
7975
|
-
|
|
7980
|
+
content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);
|
|
7981
|
+
if (content.material) {
|
|
7982
|
+
content.texture = null;
|
|
7976
7983
|
}
|
|
7977
|
-
return await parseI3SNodeGeometry(arrayBuffer,
|
|
7984
|
+
return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
7978
7985
|
}
|
|
7979
|
-
async function parseI3SNodeGeometry(arrayBuffer,
|
|
7980
|
-
if (!tile.content) {
|
|
7981
|
-
return tile;
|
|
7982
|
-
}
|
|
7983
|
-
const content = tile.content;
|
|
7986
|
+
async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options) {
|
|
7984
7987
|
const contentByteLength = arrayBuffer.byteLength;
|
|
7985
7988
|
let attributes;
|
|
7986
7989
|
let vertexCount;
|
|
7987
7990
|
let byteOffset = 0;
|
|
7988
7991
|
let featureCount = 0;
|
|
7989
7992
|
let indices;
|
|
7990
|
-
if (
|
|
7993
|
+
if (tileOptions.isDracoGeometry) {
|
|
7991
7994
|
const decompressedGeometry = await parse(arrayBuffer, DracoLoader2, {
|
|
7992
7995
|
draco: {
|
|
7993
7996
|
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
@@ -8022,8 +8025,8 @@
|
|
|
8022
8025
|
ordering: attributesOrder,
|
|
8023
8026
|
featureAttributes,
|
|
8024
8027
|
featureAttributeOrder
|
|
8025
|
-
} =
|
|
8026
|
-
const headers = parseHeaders(
|
|
8028
|
+
} = tilesetOptions.store.defaultGeometrySchema;
|
|
8029
|
+
const headers = parseHeaders(arrayBuffer, tilesetOptions);
|
|
8027
8030
|
byteOffset = headers.byteOffset;
|
|
8028
8031
|
vertexCount = headers.vertexCount;
|
|
8029
8032
|
featureCount = headers.featureCount;
|
|
@@ -8033,7 +8036,7 @@
|
|
|
8033
8036
|
attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
|
|
8034
8037
|
}
|
|
8035
8038
|
if (!options?.i3s?.coordinateSystem || options.i3s.coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS) {
|
|
8036
|
-
const enuMatrix = parsePositions(attributes.position,
|
|
8039
|
+
const enuMatrix = parsePositions(attributes.position, tileOptions);
|
|
8037
8040
|
content.modelMatrix = enuMatrix.invert();
|
|
8038
8041
|
content.coordinateSystem = COORDINATE_SYSTEM.METER_OFFSETS;
|
|
8039
8042
|
} else {
|
|
@@ -8049,7 +8052,7 @@
|
|
|
8049
8052
|
};
|
|
8050
8053
|
content.indices = indices || null;
|
|
8051
8054
|
if (attributes.id && attributes.id.value) {
|
|
8052
|
-
|
|
8055
|
+
content.featureIds = attributes.id.value;
|
|
8053
8056
|
}
|
|
8054
8057
|
for (const attributeIndex in content.attributes) {
|
|
8055
8058
|
if (!content.attributes[attributeIndex]) {
|
|
@@ -8058,7 +8061,7 @@
|
|
|
8058
8061
|
}
|
|
8059
8062
|
content.vertexCount = vertexCount;
|
|
8060
8063
|
content.byteLength = contentByteLength;
|
|
8061
|
-
return
|
|
8064
|
+
return content;
|
|
8062
8065
|
}
|
|
8063
8066
|
function updateAttributesMetadata(attributes, decompressedGeometry) {
|
|
8064
8067
|
for (const key in decompressedGeometry.loaderData.attributes) {
|
|
@@ -8085,11 +8088,11 @@
|
|
|
8085
8088
|
attribute.normalized = true;
|
|
8086
8089
|
return attribute;
|
|
8087
8090
|
}
|
|
8088
|
-
function parseHeaders(
|
|
8091
|
+
function parseHeaders(arrayBuffer, options) {
|
|
8089
8092
|
let byteOffset = 0;
|
|
8090
8093
|
let vertexCount = 0;
|
|
8091
8094
|
let featureCount = 0;
|
|
8092
|
-
for (const { property, type } of
|
|
8095
|
+
for (const { property, type } of options.store.defaultGeometrySchema.header) {
|
|
8093
8096
|
const TypedArrayTypeHeader = getConstructorForDataFormat(type);
|
|
8094
8097
|
switch (property) {
|
|
8095
8098
|
case HeaderAttributeProperty.vertexCount:
|
|
@@ -8159,8 +8162,8 @@
|
|
|
8159
8162
|
}
|
|
8160
8163
|
return new Uint32Array(values);
|
|
8161
8164
|
}
|
|
8162
|
-
function parsePositions(attribute,
|
|
8163
|
-
const mbs =
|
|
8165
|
+
function parsePositions(attribute, options) {
|
|
8166
|
+
const mbs = options.mbs;
|
|
8164
8167
|
const value = attribute.value;
|
|
8165
8168
|
const metadata = attribute.metadata;
|
|
8166
8169
|
const enuMatrix = new Matrix4();
|
|
@@ -8292,10 +8295,10 @@
|
|
|
8292
8295
|
}
|
|
8293
8296
|
|
|
8294
8297
|
// src/i3s-content-loader.ts
|
|
8295
|
-
var VERSION9 = true ? "3.
|
|
8298
|
+
var VERSION9 = true ? "3.3.0-alpha.3" : "beta";
|
|
8296
8299
|
var I3SContentLoader = {
|
|
8297
8300
|
name: "I3S Content (Indexed Scene Layers)",
|
|
8298
|
-
id: "i3s-content",
|
|
8301
|
+
id: isBrowser2 ? "i3s-content" : "i3s-content-nodejs",
|
|
8299
8302
|
module: "i3s",
|
|
8300
8303
|
worker: true,
|
|
8301
8304
|
version: VERSION9,
|
|
@@ -8307,9 +8310,13 @@
|
|
|
8307
8310
|
}
|
|
8308
8311
|
};
|
|
8309
8312
|
async function parse3(data, options, context) {
|
|
8310
|
-
const { tile, tileset } = options?.i3s || {};
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
+
const { tile, _tileOptions, tileset, _tilesetOptions } = options?.i3s || {};
|
|
8314
|
+
const tileOptions = _tileOptions || tile;
|
|
8315
|
+
const tilesetOptions = _tilesetOptions || tileset;
|
|
8316
|
+
if (!tileOptions || !tilesetOptions) {
|
|
8317
|
+
return null;
|
|
8318
|
+
}
|
|
8319
|
+
return await parseI3STileContent(data, tileOptions, tilesetOptions, options, context);
|
|
8313
8320
|
}
|
|
8314
8321
|
|
|
8315
8322
|
// src/workers/i3s-content-worker.ts
|
package/dist/i3s-loader.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
2
|
+
import { I3SParseOptions } from './types';
|
|
3
|
+
import { LoaderOptions } from './../../loader-utils/src/types';
|
|
4
|
+
export declare type I3SLoaderOptions = LoaderOptions & {
|
|
5
|
+
i3s?: I3SParseOptions;
|
|
6
|
+
};
|
|
2
7
|
/**
|
|
3
8
|
* Loader for I3S - Indexed 3D Scene Layer
|
|
4
9
|
*/
|
package/dist/i3s-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-loader.d.ts","sourceRoot":"","sources":["../src/i3s-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"i3s-loader.d.ts","sourceRoot":"","sources":["../src/i3s-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAK/D,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AACxC,OAAO,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAU7D,oBAAY,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAuBvB,CAAC"}
|
package/dist/i3s-loader.js
CHANGED
|
@@ -24,12 +24,13 @@ exports.I3SLoader = {
|
|
|
24
24
|
extensions: ['bin'],
|
|
25
25
|
options: {
|
|
26
26
|
i3s: {
|
|
27
|
-
loadContent: true,
|
|
28
27
|
token: null,
|
|
29
28
|
isTileset: 'auto',
|
|
30
29
|
isTileHeader: 'auto',
|
|
31
30
|
tile: null,
|
|
32
31
|
tileset: null,
|
|
32
|
+
_tileOptions: null,
|
|
33
|
+
_tilesetOptions: null,
|
|
33
34
|
useDracoGeometry: true,
|
|
34
35
|
useCompressedTextures: true,
|
|
35
36
|
decodeTextures: true,
|
|
@@ -37,7 +38,7 @@ exports.I3SLoader = {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
|
-
async function parseI3S(data, options, context) {
|
|
41
|
+
async function parseI3S(data, options = {}, context) {
|
|
41
42
|
const url = context.url;
|
|
42
43
|
options.i3s = options.i3s || {};
|
|
43
44
|
const magicNumber = getMagicNumber(data);
|
|
@@ -64,11 +65,7 @@ async function parseI3S(data, options, context) {
|
|
|
64
65
|
data = await parseTileset(data, options, context);
|
|
65
66
|
}
|
|
66
67
|
else if (isTileHeader) {
|
|
67
|
-
data = await parseTile(data,
|
|
68
|
-
if (options.i3s.loadContent) {
|
|
69
|
-
options.i3s.tile = data;
|
|
70
|
-
await (0, core_1.load)(data.contentUrl, exports.I3SLoader, options);
|
|
71
|
-
}
|
|
68
|
+
data = await parseTile(data, context);
|
|
72
69
|
}
|
|
73
70
|
else {
|
|
74
71
|
data = await parseTileContent(data, options);
|
|
@@ -85,9 +82,9 @@ async function parseTileset(data, options, context) {
|
|
|
85
82
|
await (0, parse_i3s_1.normalizeTilesetData)(tilesetJson, options, context);
|
|
86
83
|
return tilesetJson;
|
|
87
84
|
}
|
|
88
|
-
async function parseTile(data,
|
|
85
|
+
async function parseTile(data, context) {
|
|
89
86
|
data = JSON.parse(new TextDecoder().decode(data));
|
|
90
|
-
return (0, parse_i3s_1.normalizeTileData)(data,
|
|
87
|
+
return (0, parse_i3s_1.normalizeTileData)(data, context);
|
|
91
88
|
}
|
|
92
89
|
function getMagicNumber(data) {
|
|
93
90
|
if (data instanceof ArrayBuffer) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LoaderOptions, LoaderContext } from '@loaders.gl/loader-utils';
|
|
2
|
-
import {
|
|
3
|
-
export declare function parseI3STileContent(arrayBuffer: ArrayBuffer,
|
|
2
|
+
import { I3STileContent, I3STileOptions, I3STilesetOptions } from '../../types';
|
|
3
|
+
export declare function parseI3STileContent(arrayBuffer: ArrayBuffer, tileOptions: I3STileOptions, tilesetOptions: I3STilesetOptions, options?: LoaderOptions, context?: LoaderContext): Promise<I3STileContent>;
|
|
4
4
|
//# sourceMappingURL=parse-i3s-tile-content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-i3s-tile-content.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAK3E,OAAO,
|
|
1
|
+
{"version":3,"file":"parse-i3s-tile-content.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAK3E,OAAO,EAQL,cAAc,EACd,cAAc,EACd,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAuBrB,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,cAAc,EAC3B,cAAc,EAAE,iBAAiB,EACjC,OAAO,CAAC,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,cAAc,CAAC,CAuDzB"}
|
|
@@ -25,36 +25,43 @@ function getLoaderForTextureFormat(textureFormat) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
const I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
|
|
28
|
-
async function parseI3STileContent(arrayBuffer,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
async function parseI3STileContent(arrayBuffer, tileOptions, tilesetOptions, options, context) {
|
|
29
|
+
const content = {
|
|
30
|
+
attributes: {},
|
|
31
|
+
indices: null,
|
|
32
|
+
featureIds: [],
|
|
33
|
+
vertexCount: 0,
|
|
34
|
+
modelMatrix: new core_2.Matrix4(),
|
|
35
|
+
coordinateSystem: 0,
|
|
36
|
+
byteLength: 0,
|
|
37
|
+
texture: null
|
|
38
|
+
};
|
|
39
|
+
if (tileOptions.textureUrl) {
|
|
40
|
+
const url = (0, url_utils_1.getUrlWithToken)(tileOptions.textureUrl, options?.i3s?.token);
|
|
41
|
+
const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
35
42
|
const response = await fetch(url, options?.fetch);
|
|
36
43
|
const arrayBuffer = await response.arrayBuffer();
|
|
37
44
|
if (options?.i3s.decodeTextures) {
|
|
38
45
|
if (loader === images_1.ImageLoader) {
|
|
39
|
-
const options = { ...
|
|
46
|
+
const options = { ...tileOptions.textureLoaderOptions, image: { type: 'data' } };
|
|
40
47
|
try {
|
|
41
48
|
// @ts-ignore context must be defined
|
|
42
49
|
// Image constructor is not supported in worker thread.
|
|
43
50
|
// Do parsing image data on the main thread by using context to avoid worker issues.
|
|
44
|
-
|
|
51
|
+
content.texture = await context.parse(arrayBuffer, options);
|
|
45
52
|
}
|
|
46
53
|
catch (e) {
|
|
47
54
|
// context object is different between worker and node.js conversion script.
|
|
48
55
|
// To prevent error we parse data in ordinary way if it is not parsed by using context.
|
|
49
|
-
|
|
56
|
+
content.texture = await (0, core_1.parse)(arrayBuffer, loader, options);
|
|
50
57
|
}
|
|
51
58
|
}
|
|
52
59
|
else if (loader === textures_1.CompressedTextureLoader || loader === textures_1.BasisLoader) {
|
|
53
|
-
let texture = await (0, core_1.load)(arrayBuffer, loader,
|
|
60
|
+
let texture = await (0, core_1.load)(arrayBuffer, loader, tileOptions.textureLoaderOptions);
|
|
54
61
|
if (loader === textures_1.BasisLoader) {
|
|
55
62
|
texture = texture[0];
|
|
56
63
|
}
|
|
57
|
-
|
|
64
|
+
content.texture = {
|
|
58
65
|
compressed: true,
|
|
59
66
|
mipmaps: false,
|
|
60
67
|
width: texture[0].width,
|
|
@@ -64,29 +71,25 @@ async function parseI3STileContent(arrayBuffer, tile, tileset, options, context)
|
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
else {
|
|
67
|
-
|
|
74
|
+
content.texture = arrayBuffer;
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
77
|
+
content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);
|
|
78
|
+
if (content.material) {
|
|
79
|
+
content.texture = null;
|
|
73
80
|
}
|
|
74
|
-
return await parseI3SNodeGeometry(arrayBuffer,
|
|
81
|
+
return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
75
82
|
}
|
|
76
83
|
exports.parseI3STileContent = parseI3STileContent;
|
|
77
84
|
/* eslint-disable max-statements */
|
|
78
|
-
async function parseI3SNodeGeometry(arrayBuffer,
|
|
79
|
-
if (!tile.content) {
|
|
80
|
-
return tile;
|
|
81
|
-
}
|
|
82
|
-
const content = tile.content;
|
|
85
|
+
async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options) {
|
|
83
86
|
const contentByteLength = arrayBuffer.byteLength;
|
|
84
87
|
let attributes;
|
|
85
88
|
let vertexCount;
|
|
86
89
|
let byteOffset = 0;
|
|
87
90
|
let featureCount = 0;
|
|
88
91
|
let indices;
|
|
89
|
-
if (
|
|
92
|
+
if (tileOptions.isDracoGeometry) {
|
|
90
93
|
const decompressedGeometry = await (0, core_1.parse)(arrayBuffer, draco_1.DracoLoader, {
|
|
91
94
|
draco: {
|
|
92
95
|
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
@@ -111,9 +114,9 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
else {
|
|
114
|
-
const { vertexAttributes, ordering: attributesOrder, featureAttributes, featureAttributeOrder } =
|
|
117
|
+
const { vertexAttributes, ordering: attributesOrder, featureAttributes, featureAttributeOrder } = tilesetOptions.store.defaultGeometrySchema;
|
|
115
118
|
// First 8 bytes reserved for header (vertexCount and featureCount)
|
|
116
|
-
const headers = parseHeaders(
|
|
119
|
+
const headers = parseHeaders(arrayBuffer, tilesetOptions);
|
|
117
120
|
byteOffset = headers.byteOffset;
|
|
118
121
|
vertexCount = headers.vertexCount;
|
|
119
122
|
featureCount = headers.featureCount;
|
|
@@ -126,7 +129,7 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
126
129
|
}
|
|
127
130
|
if (!options?.i3s?.coordinateSystem ||
|
|
128
131
|
options.i3s.coordinateSystem === constants_1.COORDINATE_SYSTEM.METER_OFFSETS) {
|
|
129
|
-
const enuMatrix = parsePositions(attributes.position,
|
|
132
|
+
const enuMatrix = parsePositions(attributes.position, tileOptions);
|
|
130
133
|
content.modelMatrix = enuMatrix.invert();
|
|
131
134
|
content.coordinateSystem = constants_1.COORDINATE_SYSTEM.METER_OFFSETS;
|
|
132
135
|
}
|
|
@@ -143,7 +146,7 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
143
146
|
};
|
|
144
147
|
content.indices = indices || null;
|
|
145
148
|
if (attributes.id && attributes.id.value) {
|
|
146
|
-
|
|
149
|
+
content.featureIds = attributes.id.value;
|
|
147
150
|
}
|
|
148
151
|
// Remove undefined attributes
|
|
149
152
|
for (const attributeIndex in content.attributes) {
|
|
@@ -153,7 +156,7 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
153
156
|
}
|
|
154
157
|
content.vertexCount = vertexCount;
|
|
155
158
|
content.byteLength = contentByteLength;
|
|
156
|
-
return
|
|
159
|
+
return content;
|
|
157
160
|
}
|
|
158
161
|
/**
|
|
159
162
|
* Update attributes with metadata from decompressed geometry.
|
|
@@ -197,12 +200,12 @@ function normalizeAttribute(attribute) {
|
|
|
197
200
|
attribute.normalized = true;
|
|
198
201
|
return attribute;
|
|
199
202
|
}
|
|
200
|
-
function parseHeaders(
|
|
203
|
+
function parseHeaders(arrayBuffer, options) {
|
|
201
204
|
let byteOffset = 0;
|
|
202
205
|
// First 8 bytes reserved for header (vertexCount and featurecount)
|
|
203
206
|
let vertexCount = 0;
|
|
204
207
|
let featureCount = 0;
|
|
205
|
-
for (const { property, type } of
|
|
208
|
+
for (const { property, type } of options.store.defaultGeometrySchema.header) {
|
|
206
209
|
const TypedArrayTypeHeader = (0, constants_1.getConstructorForDataFormat)(type);
|
|
207
210
|
switch (property) {
|
|
208
211
|
case types_1.HeaderAttributeProperty.vertexCount:
|
|
@@ -292,8 +295,8 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
|
292
295
|
}
|
|
293
296
|
return new Uint32Array(values);
|
|
294
297
|
}
|
|
295
|
-
function parsePositions(attribute,
|
|
296
|
-
const mbs =
|
|
298
|
+
function parsePositions(attribute, options) {
|
|
299
|
+
const mbs = options.mbs;
|
|
297
300
|
const value = attribute.value;
|
|
298
301
|
const metadata = attribute.metadata;
|
|
299
302
|
const enuMatrix = new core_2.Matrix4();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { I3STilesetHeader, I3STileHeader, I3SMinimalNodeData, Node3DIndexDocument } from '../../types';
|
|
2
2
|
import type { LoaderOptions, LoaderContext } from '@loaders.gl/loader-utils';
|
|
3
|
-
export declare function normalizeTileData(tile: Node3DIndexDocument,
|
|
3
|
+
export declare function normalizeTileData(tile: Node3DIndexDocument, context: LoaderContext): I3STileHeader;
|
|
4
4
|
export declare function normalizeTileNonUrlData(tile: I3SMinimalNodeData): I3STileHeader;
|
|
5
5
|
export declare function normalizeTilesetData(tileset: I3STilesetHeader, options: LoaderOptions, context: LoaderContext): Promise<void>;
|
|
6
6
|
//# sourceMappingURL=parse-i3s.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-i3s.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gBAAgB,EAChB,aAAa,EAEb,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE3E,wBAAgB,iBAAiB,CAAC,IAAI,EAAG,mBAAmB,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"parse-i3s.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,gBAAgB,EAChB,aAAa,EAEb,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE3E,wBAAgB,iBAAiB,CAAC,IAAI,EAAG,mBAAmB,EAAE,OAAO,EAAE,aAAa,GAAG,aAAa,CAyBnG;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAG,kBAAkB,GAAG,aAAa,CAmChF;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAG,gBAAgB,EAAE,OAAO,EAAG,aAAa,EAAE,OAAO,EAAE,aAAa,iBAwBrH"}
|
|
@@ -10,7 +10,7 @@ const core_1 = require("@loaders.gl/core");
|
|
|
10
10
|
const tiles_1 = require("@loaders.gl/tiles");
|
|
11
11
|
const i3s_nodepages_tiles_1 = __importDefault(require("../helpers/i3s-nodepages-tiles"));
|
|
12
12
|
const url_utils_1 = require("../utils/url-utils");
|
|
13
|
-
function normalizeTileData(tile,
|
|
13
|
+
function normalizeTileData(tile, context) {
|
|
14
14
|
const url = context.url || '';
|
|
15
15
|
let contentUrl;
|
|
16
16
|
if (tile.geometryData) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Matrix4, Quaternion, Vector3 } from '@math.gl/core';
|
|
2
2
|
import type { TypedArray, MeshAttribute, TextureLevel } from '@loaders.gl/schema';
|
|
3
|
+
import { Tile3D, Tileset3D } from '@loaders.gl/tiles';
|
|
3
4
|
export declare enum DATA_TYPE {
|
|
4
5
|
UInt8 = "UInt8",
|
|
5
6
|
UInt16 = "UInt16",
|
|
@@ -75,6 +76,46 @@ export declare type I3STileHeader = {
|
|
|
75
76
|
lodSelection?: LodSelection[];
|
|
76
77
|
[key: string]: any;
|
|
77
78
|
};
|
|
79
|
+
export declare type I3SParseOptions = {
|
|
80
|
+
/** ArcGIS access token */
|
|
81
|
+
token?: string;
|
|
82
|
+
/** Is 3DSceneLayer json expected in response */
|
|
83
|
+
isTileset?: string;
|
|
84
|
+
/** Is 3DNodeIndexDocument json expected in response */
|
|
85
|
+
isTileHeader?: string;
|
|
86
|
+
/** Tile3D instance. This property used only to load tile content */
|
|
87
|
+
/** @deprecated */
|
|
88
|
+
tile?: Tile3D | I3STileOptions;
|
|
89
|
+
/** Tileset3D instance. This property used only to load tile content */
|
|
90
|
+
/** @deprecated */
|
|
91
|
+
tileset?: Tileset3D | I3STilesetOptions;
|
|
92
|
+
/** Tile-specific options */
|
|
93
|
+
_tileOptions?: I3STileOptions;
|
|
94
|
+
/** Tileset-specific options */
|
|
95
|
+
_tilesetOptions?: I3STilesetOptions;
|
|
96
|
+
/** Load Draco Compressed geometry if available */
|
|
97
|
+
useDracoGeometry?: boolean;
|
|
98
|
+
/** Load compressed textures if available */
|
|
99
|
+
useCompressedTextures?: boolean;
|
|
100
|
+
/** Set false if don't need to parse textures */
|
|
101
|
+
decodeTextures?: boolean;
|
|
102
|
+
/** deck.gl compatible coordinate system.
|
|
103
|
+
* https://github.com/visgl/deck.gl/blob/master/docs/developer-guide/coordinate-systems.md
|
|
104
|
+
* Supported coordinate systems: METER_OFFSETS, LNGLAT_OFFSETS
|
|
105
|
+
*/
|
|
106
|
+
coordinateSystem?: number;
|
|
107
|
+
};
|
|
108
|
+
export declare type I3STileOptions = {
|
|
109
|
+
isDracoGeometry: boolean;
|
|
110
|
+
textureUrl?: string;
|
|
111
|
+
textureFormat?: I3STextureFormat;
|
|
112
|
+
textureLoaderOptions?: any;
|
|
113
|
+
materialDefinition?: I3SMaterialDefinition;
|
|
114
|
+
mbs: Mbs;
|
|
115
|
+
};
|
|
116
|
+
export declare type I3STilesetOptions = {
|
|
117
|
+
store: Store;
|
|
118
|
+
};
|
|
78
119
|
export declare type I3STileContent = {
|
|
79
120
|
attributes: I3SMeshAttributes;
|
|
80
121
|
indices: TypedArray | null;
|