@loaders.gl/i3s 3.3.0-alpha.1 → 3.3.0-alpha.2
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 +56 -49
- package/dist/es5/arcgis-webscene-loader.js +1 -1
- package/dist/es5/i3s-attribute-loader.js +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
- package/dist/es5/i3s-content-loader.js +19 -8
- 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/lib/parsers/parse-i3s-tile-content.js +76 -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/esm/arcgis-webscene-loader.js +1 -1
- package/dist/esm/i3s-attribute-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-content-loader.js +12 -4
- 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/lib/parsers/parse-i3s-tile-content.js +37 -34
- 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/i3s-content-loader.d.ts.map +1 -1
- package/dist/i3s-content-loader.js +7 -3
- package/dist/i3s-content-worker.js +54 -46
- 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 +36 -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/package.json +8 -8
- package/src/i3s-content-loader.ts +17 -5
- package/src/i3s-loader.ts +15 -12
- package/src/lib/parsers/parse-i3s-tile-content.ts +46 -41
- package/src/lib/parsers/parse-i3s.ts +1 -1
- package/src/types.ts +45 -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.3.0-alpha.
|
|
58
|
+
var VERSION = true ? "3.3.0-alpha.2" : 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;
|
|
@@ -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.3.0-alpha.
|
|
1085
|
+
var VERSION3 = true ? "3.3.0-alpha.2" : "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.3.0-alpha.
|
|
1831
|
+
var VERSION4 = true ? "3.3.0-alpha.2" : "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.3.0-alpha.
|
|
4953
|
+
var VERSION5 = true ? "3.3.0-alpha.2" : "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.3.0-alpha.
|
|
5301
|
+
var VERSION6 = true ? "3.3.0-alpha.2" : "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.3.0-alpha.
|
|
6285
|
+
var VERSION7 = true ? "3.3.0-alpha.2" : "beta";
|
|
6286
6286
|
|
|
6287
6287
|
// ../textures/src/lib/parsers/basis-module-loader.ts
|
|
6288
|
-
var VERSION8 = true ? "3.3.0-alpha.
|
|
6288
|
+
var VERSION8 = true ? "3.3.0-alpha.2" : "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,37 @@
|
|
|
7936
7936
|
}
|
|
7937
7937
|
}
|
|
7938
7938
|
var I3S_ATTRIBUTE_TYPE = "i3s-attribute-type";
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7939
|
+
var defaultContent = {
|
|
7940
|
+
attributes: {},
|
|
7941
|
+
indices: null,
|
|
7942
|
+
featureIds: [],
|
|
7943
|
+
vertexCount: 0,
|
|
7944
|
+
modelMatrix: new Matrix4(),
|
|
7945
|
+
coordinateSystem: 0,
|
|
7946
|
+
byteLength: 0,
|
|
7947
|
+
texture: null
|
|
7948
|
+
};
|
|
7949
|
+
async function parseI3STileContent(arrayBuffer, tileOptions, tilesetOptions, options, context) {
|
|
7950
|
+
const content = defaultContent;
|
|
7951
|
+
if (tileOptions.textureUrl) {
|
|
7952
|
+
const url = getUrlWithToken(tileOptions.textureUrl, options?.i3s?.token);
|
|
7953
|
+
const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
7946
7954
|
const response = await fetch(url, options?.fetch);
|
|
7947
7955
|
const arrayBuffer2 = await response.arrayBuffer();
|
|
7948
7956
|
if (options?.i3s.decodeTextures) {
|
|
7949
7957
|
if (loader === ImageLoader) {
|
|
7950
|
-
const options2 = { ...
|
|
7958
|
+
const options2 = { ...tileOptions.textureLoaderOptions, image: { type: "data" } };
|
|
7951
7959
|
try {
|
|
7952
|
-
|
|
7960
|
+
content.texture = await context.parse(arrayBuffer2, options2);
|
|
7953
7961
|
} catch (e2) {
|
|
7954
|
-
|
|
7962
|
+
content.texture = await parse(arrayBuffer2, loader, options2);
|
|
7955
7963
|
}
|
|
7956
7964
|
} else if (loader === CompressedTextureLoader || loader === BasisLoader) {
|
|
7957
|
-
let texture = await load(arrayBuffer2, loader,
|
|
7965
|
+
let texture = await load(arrayBuffer2, loader, tileOptions.textureLoaderOptions);
|
|
7958
7966
|
if (loader === BasisLoader) {
|
|
7959
7967
|
texture = texture[0];
|
|
7960
7968
|
}
|
|
7961
|
-
|
|
7969
|
+
content.texture = {
|
|
7962
7970
|
compressed: true,
|
|
7963
7971
|
mipmaps: false,
|
|
7964
7972
|
width: texture[0].width,
|
|
@@ -7967,27 +7975,23 @@
|
|
|
7967
7975
|
};
|
|
7968
7976
|
}
|
|
7969
7977
|
} else {
|
|
7970
|
-
|
|
7978
|
+
content.texture = arrayBuffer2;
|
|
7971
7979
|
}
|
|
7972
7980
|
}
|
|
7973
|
-
|
|
7974
|
-
if (
|
|
7975
|
-
|
|
7981
|
+
content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);
|
|
7982
|
+
if (content.material) {
|
|
7983
|
+
content.texture = null;
|
|
7976
7984
|
}
|
|
7977
|
-
return await parseI3SNodeGeometry(arrayBuffer,
|
|
7985
|
+
return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
7978
7986
|
}
|
|
7979
|
-
async function parseI3SNodeGeometry(arrayBuffer,
|
|
7980
|
-
if (!tile.content) {
|
|
7981
|
-
return tile;
|
|
7982
|
-
}
|
|
7983
|
-
const content = tile.content;
|
|
7987
|
+
async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options) {
|
|
7984
7988
|
const contentByteLength = arrayBuffer.byteLength;
|
|
7985
7989
|
let attributes;
|
|
7986
7990
|
let vertexCount;
|
|
7987
7991
|
let byteOffset = 0;
|
|
7988
7992
|
let featureCount = 0;
|
|
7989
7993
|
let indices;
|
|
7990
|
-
if (
|
|
7994
|
+
if (tileOptions.isDracoGeometry) {
|
|
7991
7995
|
const decompressedGeometry = await parse(arrayBuffer, DracoLoader2, {
|
|
7992
7996
|
draco: {
|
|
7993
7997
|
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
@@ -8022,8 +8026,8 @@
|
|
|
8022
8026
|
ordering: attributesOrder,
|
|
8023
8027
|
featureAttributes,
|
|
8024
8028
|
featureAttributeOrder
|
|
8025
|
-
} =
|
|
8026
|
-
const headers = parseHeaders(
|
|
8029
|
+
} = tilesetOptions.store.defaultGeometrySchema;
|
|
8030
|
+
const headers = parseHeaders(arrayBuffer, tilesetOptions);
|
|
8027
8031
|
byteOffset = headers.byteOffset;
|
|
8028
8032
|
vertexCount = headers.vertexCount;
|
|
8029
8033
|
featureCount = headers.featureCount;
|
|
@@ -8033,7 +8037,7 @@
|
|
|
8033
8037
|
attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
|
|
8034
8038
|
}
|
|
8035
8039
|
if (!options?.i3s?.coordinateSystem || options.i3s.coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS) {
|
|
8036
|
-
const enuMatrix = parsePositions(attributes.position,
|
|
8040
|
+
const enuMatrix = parsePositions(attributes.position, tileOptions);
|
|
8037
8041
|
content.modelMatrix = enuMatrix.invert();
|
|
8038
8042
|
content.coordinateSystem = COORDINATE_SYSTEM.METER_OFFSETS;
|
|
8039
8043
|
} else {
|
|
@@ -8049,7 +8053,7 @@
|
|
|
8049
8053
|
};
|
|
8050
8054
|
content.indices = indices || null;
|
|
8051
8055
|
if (attributes.id && attributes.id.value) {
|
|
8052
|
-
|
|
8056
|
+
content.featureIds = attributes.id.value;
|
|
8053
8057
|
}
|
|
8054
8058
|
for (const attributeIndex in content.attributes) {
|
|
8055
8059
|
if (!content.attributes[attributeIndex]) {
|
|
@@ -8058,7 +8062,7 @@
|
|
|
8058
8062
|
}
|
|
8059
8063
|
content.vertexCount = vertexCount;
|
|
8060
8064
|
content.byteLength = contentByteLength;
|
|
8061
|
-
return
|
|
8065
|
+
return content;
|
|
8062
8066
|
}
|
|
8063
8067
|
function updateAttributesMetadata(attributes, decompressedGeometry) {
|
|
8064
8068
|
for (const key in decompressedGeometry.loaderData.attributes) {
|
|
@@ -8085,11 +8089,11 @@
|
|
|
8085
8089
|
attribute.normalized = true;
|
|
8086
8090
|
return attribute;
|
|
8087
8091
|
}
|
|
8088
|
-
function parseHeaders(
|
|
8092
|
+
function parseHeaders(arrayBuffer, options) {
|
|
8089
8093
|
let byteOffset = 0;
|
|
8090
8094
|
let vertexCount = 0;
|
|
8091
8095
|
let featureCount = 0;
|
|
8092
|
-
for (const { property, type } of
|
|
8096
|
+
for (const { property, type } of options.store.defaultGeometrySchema.header) {
|
|
8093
8097
|
const TypedArrayTypeHeader = getConstructorForDataFormat(type);
|
|
8094
8098
|
switch (property) {
|
|
8095
8099
|
case HeaderAttributeProperty.vertexCount:
|
|
@@ -8159,8 +8163,8 @@
|
|
|
8159
8163
|
}
|
|
8160
8164
|
return new Uint32Array(values);
|
|
8161
8165
|
}
|
|
8162
|
-
function parsePositions(attribute,
|
|
8163
|
-
const mbs =
|
|
8166
|
+
function parsePositions(attribute, options) {
|
|
8167
|
+
const mbs = options.mbs;
|
|
8164
8168
|
const value = attribute.value;
|
|
8165
8169
|
const metadata = attribute.metadata;
|
|
8166
8170
|
const enuMatrix = new Matrix4();
|
|
@@ -8292,7 +8296,7 @@
|
|
|
8292
8296
|
}
|
|
8293
8297
|
|
|
8294
8298
|
// src/i3s-content-loader.ts
|
|
8295
|
-
var VERSION9 = true ? "3.3.0-alpha.
|
|
8299
|
+
var VERSION9 = true ? "3.3.0-alpha.2" : "beta";
|
|
8296
8300
|
var I3SContentLoader = {
|
|
8297
8301
|
name: "I3S Content (Indexed Scene Layers)",
|
|
8298
8302
|
id: "i3s-content",
|
|
@@ -8307,9 +8311,13 @@
|
|
|
8307
8311
|
}
|
|
8308
8312
|
};
|
|
8309
8313
|
async function parse3(data, options, context) {
|
|
8310
|
-
const { tile, tileset } = options?.i3s || {};
|
|
8311
|
-
|
|
8312
|
-
|
|
8314
|
+
const { tile, _tileOptions, tileset, _tilesetOptions } = options?.i3s || {};
|
|
8315
|
+
const tileOptions = _tileOptions || tile;
|
|
8316
|
+
const tilesetOptions = _tilesetOptions || tileset;
|
|
8317
|
+
if (!tileOptions || !tilesetOptions) {
|
|
8318
|
+
return null;
|
|
8319
|
+
}
|
|
8320
|
+
return await parseI3STileContent(data, tileOptions, tilesetOptions, options, context);
|
|
8313
8321
|
}
|
|
8314
8322
|
|
|
8315
8323
|
// 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;AAkCrB,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,CA8CzB"}
|
|
@@ -25,36 +25,44 @@ function getLoaderForTextureFormat(textureFormat) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
const I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const defaultContent = {
|
|
29
|
+
attributes: {},
|
|
30
|
+
indices: null,
|
|
31
|
+
featureIds: [],
|
|
32
|
+
vertexCount: 0,
|
|
33
|
+
modelMatrix: new core_2.Matrix4(),
|
|
34
|
+
coordinateSystem: 0,
|
|
35
|
+
byteLength: 0,
|
|
36
|
+
texture: null
|
|
37
|
+
};
|
|
38
|
+
async function parseI3STileContent(arrayBuffer, tileOptions, tilesetOptions, options, context) {
|
|
39
|
+
const content = defaultContent;
|
|
40
|
+
if (tileOptions.textureUrl) {
|
|
41
|
+
const url = (0, url_utils_1.getUrlWithToken)(tileOptions.textureUrl, options?.i3s?.token);
|
|
42
|
+
const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
35
43
|
const response = await fetch(url, options?.fetch);
|
|
36
44
|
const arrayBuffer = await response.arrayBuffer();
|
|
37
45
|
if (options?.i3s.decodeTextures) {
|
|
38
46
|
if (loader === images_1.ImageLoader) {
|
|
39
|
-
const options = { ...
|
|
47
|
+
const options = { ...tileOptions.textureLoaderOptions, image: { type: 'data' } };
|
|
40
48
|
try {
|
|
41
49
|
// @ts-ignore context must be defined
|
|
42
50
|
// Image constructor is not supported in worker thread.
|
|
43
51
|
// Do parsing image data on the main thread by using context to avoid worker issues.
|
|
44
|
-
|
|
52
|
+
content.texture = await context.parse(arrayBuffer, options);
|
|
45
53
|
}
|
|
46
54
|
catch (e) {
|
|
47
55
|
// context object is different between worker and node.js conversion script.
|
|
48
56
|
// To prevent error we parse data in ordinary way if it is not parsed by using context.
|
|
49
|
-
|
|
57
|
+
content.texture = await (0, core_1.parse)(arrayBuffer, loader, options);
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
else if (loader === textures_1.CompressedTextureLoader || loader === textures_1.BasisLoader) {
|
|
53
|
-
let texture = await (0, core_1.load)(arrayBuffer, loader,
|
|
61
|
+
let texture = await (0, core_1.load)(arrayBuffer, loader, tileOptions.textureLoaderOptions);
|
|
54
62
|
if (loader === textures_1.BasisLoader) {
|
|
55
63
|
texture = texture[0];
|
|
56
64
|
}
|
|
57
|
-
|
|
65
|
+
content.texture = {
|
|
58
66
|
compressed: true,
|
|
59
67
|
mipmaps: false,
|
|
60
68
|
width: texture[0].width,
|
|
@@ -64,29 +72,25 @@ async function parseI3STileContent(arrayBuffer, tile, tileset, options, context)
|
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
else {
|
|
67
|
-
|
|
75
|
+
content.texture = arrayBuffer;
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
78
|
+
content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);
|
|
79
|
+
if (content.material) {
|
|
80
|
+
content.texture = null;
|
|
73
81
|
}
|
|
74
|
-
return await parseI3SNodeGeometry(arrayBuffer,
|
|
82
|
+
return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
75
83
|
}
|
|
76
84
|
exports.parseI3STileContent = parseI3STileContent;
|
|
77
85
|
/* eslint-disable max-statements */
|
|
78
|
-
async function parseI3SNodeGeometry(arrayBuffer,
|
|
79
|
-
if (!tile.content) {
|
|
80
|
-
return tile;
|
|
81
|
-
}
|
|
82
|
-
const content = tile.content;
|
|
86
|
+
async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options) {
|
|
83
87
|
const contentByteLength = arrayBuffer.byteLength;
|
|
84
88
|
let attributes;
|
|
85
89
|
let vertexCount;
|
|
86
90
|
let byteOffset = 0;
|
|
87
91
|
let featureCount = 0;
|
|
88
92
|
let indices;
|
|
89
|
-
if (
|
|
93
|
+
if (tileOptions.isDracoGeometry) {
|
|
90
94
|
const decompressedGeometry = await (0, core_1.parse)(arrayBuffer, draco_1.DracoLoader, {
|
|
91
95
|
draco: {
|
|
92
96
|
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
@@ -111,9 +115,9 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
111
115
|
}
|
|
112
116
|
}
|
|
113
117
|
else {
|
|
114
|
-
const { vertexAttributes, ordering: attributesOrder, featureAttributes, featureAttributeOrder } =
|
|
118
|
+
const { vertexAttributes, ordering: attributesOrder, featureAttributes, featureAttributeOrder } = tilesetOptions.store.defaultGeometrySchema;
|
|
115
119
|
// First 8 bytes reserved for header (vertexCount and featureCount)
|
|
116
|
-
const headers = parseHeaders(
|
|
120
|
+
const headers = parseHeaders(arrayBuffer, tilesetOptions);
|
|
117
121
|
byteOffset = headers.byteOffset;
|
|
118
122
|
vertexCount = headers.vertexCount;
|
|
119
123
|
featureCount = headers.featureCount;
|
|
@@ -126,7 +130,7 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
126
130
|
}
|
|
127
131
|
if (!options?.i3s?.coordinateSystem ||
|
|
128
132
|
options.i3s.coordinateSystem === constants_1.COORDINATE_SYSTEM.METER_OFFSETS) {
|
|
129
|
-
const enuMatrix = parsePositions(attributes.position,
|
|
133
|
+
const enuMatrix = parsePositions(attributes.position, tileOptions);
|
|
130
134
|
content.modelMatrix = enuMatrix.invert();
|
|
131
135
|
content.coordinateSystem = constants_1.COORDINATE_SYSTEM.METER_OFFSETS;
|
|
132
136
|
}
|
|
@@ -143,7 +147,7 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
143
147
|
};
|
|
144
148
|
content.indices = indices || null;
|
|
145
149
|
if (attributes.id && attributes.id.value) {
|
|
146
|
-
|
|
150
|
+
content.featureIds = attributes.id.value;
|
|
147
151
|
}
|
|
148
152
|
// Remove undefined attributes
|
|
149
153
|
for (const attributeIndex in content.attributes) {
|
|
@@ -153,7 +157,7 @@ async function parseI3SNodeGeometry(arrayBuffer, tile, tileset, options) {
|
|
|
153
157
|
}
|
|
154
158
|
content.vertexCount = vertexCount;
|
|
155
159
|
content.byteLength = contentByteLength;
|
|
156
|
-
return
|
|
160
|
+
return content;
|
|
157
161
|
}
|
|
158
162
|
/**
|
|
159
163
|
* Update attributes with metadata from decompressed geometry.
|
|
@@ -197,12 +201,12 @@ function normalizeAttribute(attribute) {
|
|
|
197
201
|
attribute.normalized = true;
|
|
198
202
|
return attribute;
|
|
199
203
|
}
|
|
200
|
-
function parseHeaders(
|
|
204
|
+
function parseHeaders(arrayBuffer, options) {
|
|
201
205
|
let byteOffset = 0;
|
|
202
206
|
// First 8 bytes reserved for header (vertexCount and featurecount)
|
|
203
207
|
let vertexCount = 0;
|
|
204
208
|
let featureCount = 0;
|
|
205
|
-
for (const { property, type } of
|
|
209
|
+
for (const { property, type } of options.store.defaultGeometrySchema.header) {
|
|
206
210
|
const TypedArrayTypeHeader = (0, constants_1.getConstructorForDataFormat)(type);
|
|
207
211
|
switch (property) {
|
|
208
212
|
case types_1.HeaderAttributeProperty.vertexCount:
|
|
@@ -292,8 +296,8 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
|
292
296
|
}
|
|
293
297
|
return new Uint32Array(values);
|
|
294
298
|
}
|
|
295
|
-
function parsePositions(attribute,
|
|
296
|
-
const mbs =
|
|
299
|
+
function parsePositions(attribute, options) {
|
|
300
|
+
const mbs = options.mbs;
|
|
297
301
|
const value = attribute.value;
|
|
298
302
|
const metadata = attribute.metadata;
|
|
299
303
|
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;
|