@loaders.gl/i3s 3.1.0-alpha.4 → 3.1.0-beta.5

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 (125) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +10364 -0
  4. package/dist/es5/bundle.js +1 -1
  5. package/dist/es5/bundle.js.map +1 -1
  6. package/dist/es5/i3s-attribute-loader.js +89 -138
  7. package/dist/es5/i3s-attribute-loader.js.map +1 -1
  8. package/dist/es5/i3s-building-scene-layer-loader.js +8 -36
  9. package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
  10. package/dist/es5/i3s-content-loader.js +10 -36
  11. package/dist/es5/i3s-content-loader.js.map +1 -1
  12. package/dist/es5/i3s-loader.js +56 -176
  13. package/dist/es5/i3s-loader.js.map +1 -1
  14. package/dist/es5/i3s-node-page-loader.js +8 -51
  15. package/dist/es5/i3s-node-page-loader.js.map +1 -1
  16. package/dist/es5/index.js +13 -5
  17. package/dist/es5/index.js.map +1 -1
  18. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +172 -325
  19. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  20. package/dist/es5/lib/parsers/constants.js +71 -25
  21. package/dist/es5/lib/parsers/constants.js.map +1 -1
  22. package/dist/es5/lib/parsers/parse-i3s-attribute.js +34 -68
  23. package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
  24. package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +28 -59
  25. package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
  26. package/dist/es5/lib/parsers/parse-i3s-tile-content.js +314 -415
  27. package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  28. package/dist/es5/lib/parsers/parse-i3s.js +31 -70
  29. package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
  30. package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +4 -8
  31. package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
  32. package/dist/es5/lib/utils/url-utils.js +17 -14
  33. package/dist/es5/lib/utils/url-utils.js.map +1 -1
  34. package/dist/es5/types.js +19 -0
  35. package/dist/es5/types.js.map +1 -1
  36. package/dist/esm/i3s-attribute-loader.js +44 -14
  37. package/dist/esm/i3s-attribute-loader.js.map +1 -1
  38. package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
  39. package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
  40. package/dist/esm/i3s-content-loader.js +1 -1
  41. package/dist/esm/i3s-content-loader.js.map +1 -1
  42. package/dist/esm/i3s-loader.js +5 -2
  43. package/dist/esm/i3s-loader.js.map +1 -1
  44. package/dist/esm/i3s-node-page-loader.js +1 -1
  45. package/dist/esm/i3s-node-page-loader.js.map +1 -1
  46. package/dist/esm/index.js +1 -0
  47. package/dist/esm/index.js.map +1 -1
  48. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +3 -3
  49. package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  50. package/dist/esm/lib/parsers/constants.js +55 -15
  51. package/dist/esm/lib/parsers/constants.js.map +1 -1
  52. package/dist/esm/lib/parsers/parse-i3s-attribute.js +9 -1
  53. package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +1 -1
  54. package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js +3 -1
  55. package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
  56. package/dist/esm/lib/parsers/parse-i3s-tile-content.js +87 -61
  57. package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  58. package/dist/esm/lib/parsers/parse-i3s.js +4 -4
  59. package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
  60. package/dist/esm/lib/utils/url-utils.js +3 -3
  61. package/dist/esm/lib/utils/url-utils.js.map +1 -1
  62. package/dist/esm/types.js +13 -1
  63. package/dist/esm/types.js.map +1 -1
  64. package/dist/i3s-attribute-loader.d.ts +14 -0
  65. package/dist/i3s-attribute-loader.d.ts.map +1 -0
  66. package/dist/i3s-attribute-loader.js +177 -0
  67. package/dist/i3s-building-scene-layer-loader.d.ts +6 -0
  68. package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -0
  69. package/dist/i3s-building-scene-layer-loader.js +26 -0
  70. package/dist/i3s-content-loader.d.ts +6 -0
  71. package/dist/i3s-content-loader.d.ts.map +1 -0
  72. package/dist/i3s-content-loader.js +28 -0
  73. package/dist/i3s-content-worker.js +7657 -2
  74. package/dist/i3s-loader.d.ts +6 -0
  75. package/dist/i3s-loader.d.ts.map +1 -0
  76. package/dist/i3s-loader.js +100 -0
  77. package/dist/i3s-node-page-loader.d.ts +6 -0
  78. package/dist/i3s-node-page-loader.d.ts.map +1 -0
  79. package/dist/i3s-node-page-loader.js +26 -0
  80. package/dist/index.d.ts +7 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/index.js +14 -0
  83. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +73 -0
  84. package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -0
  85. package/dist/lib/helpers/i3s-nodepages-tiles.js +231 -0
  86. package/dist/lib/parsers/constants.d.ts +56 -0
  87. package/dist/lib/parsers/constants.d.ts.map +1 -0
  88. package/dist/lib/parsers/constants.js +107 -0
  89. package/dist/lib/parsers/parse-i3s-attribute.d.ts +10 -0
  90. package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +1 -0
  91. package/dist/lib/parsers/parse-i3s-attribute.js +98 -0
  92. package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts +9 -0
  93. package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -0
  94. package/dist/lib/parsers/parse-i3s-building-scene-layer.js +46 -0
  95. package/dist/lib/parsers/parse-i3s-tile-content.d.ts +4 -0
  96. package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -0
  97. package/dist/lib/parsers/parse-i3s-tile-content.js +508 -0
  98. package/dist/lib/parsers/parse-i3s.d.ts +4 -0
  99. package/dist/lib/parsers/parse-i3s.d.ts.map +1 -0
  100. package/dist/lib/parsers/parse-i3s.js +84 -0
  101. package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts +2 -0
  102. package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts.map +1 -0
  103. package/dist/lib/utils/convert-i3s-obb-to-mbs.js +20 -0
  104. package/dist/lib/utils/url-utils.d.ts +22 -0
  105. package/dist/lib/utils/url-utils.d.ts.map +1 -0
  106. package/dist/lib/utils/url-utils.js +44 -0
  107. package/dist/types.d.ts +429 -0
  108. package/dist/types.d.ts.map +1 -0
  109. package/dist/types.js +15 -0
  110. package/dist/workers/i3s-content-worker.d.ts +2 -0
  111. package/dist/workers/i3s-content-worker.d.ts.map +1 -0
  112. package/dist/workers/i3s-content-worker.js +5 -0
  113. package/package.json +14 -12
  114. package/src/i3s-attribute-loader.ts +56 -19
  115. package/src/i3s-loader.ts +4 -1
  116. package/src/index.ts +1 -0
  117. package/src/lib/parsers/constants.ts +73 -18
  118. package/src/lib/parsers/parse-i3s-attribute.ts +19 -1
  119. package/src/lib/parsers/parse-i3s-building-scene-layer.ts +2 -1
  120. package/src/lib/parsers/parse-i3s-tile-content.ts +159 -109
  121. package/src/lib/utils/url-utils.ts +1 -1
  122. package/src/types.ts +153 -22
  123. package/dist/dist.min.js +0 -2
  124. package/dist/dist.min.js.map +0 -1
  125. package/dist/i3s-content-worker.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ import type { LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ /**
3
+ * Loader for I3S - Indexed 3D Scene Layer
4
+ */
5
+ export declare const I3SLoader: LoaderWithParser;
6
+ //# sourceMappingURL=i3s-loader.d.ts.map
@@ -0,0 +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;AAc/D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAsBvB,CAAC"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.I3SLoader = void 0;
4
+ const core_1 = require("@loaders.gl/core");
5
+ const i3s_content_loader_1 = require("./i3s-content-loader");
6
+ const parse_i3s_1 = require("./lib/parsers/parse-i3s");
7
+ const constants_1 = require("./lib/parsers/constants");
8
+ // __VERSION__ is injected by babel-plugin-version-inline
9
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
10
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
11
+ const TILESET_REGEX = /layers\/[0-9]+$/;
12
+ const TILE_HEADER_REGEX = /nodes\/([0-9-]+|root)$/;
13
+ const SLPK_HEX = '504b0304';
14
+ /**
15
+ * Loader for I3S - Indexed 3D Scene Layer
16
+ */
17
+ exports.I3SLoader = {
18
+ name: 'I3S (Indexed Scene Layers)',
19
+ id: 'i3s',
20
+ module: 'i3s',
21
+ version: VERSION,
22
+ mimeTypes: ['application/octet-stream'],
23
+ parse: parseI3S,
24
+ extensions: ['bin'],
25
+ options: {
26
+ i3s: {
27
+ loadContent: true,
28
+ token: null,
29
+ isTileset: 'auto',
30
+ isTileHeader: 'auto',
31
+ tile: null,
32
+ tileset: null,
33
+ useDracoGeometry: true,
34
+ useCompressedTextures: true,
35
+ decodeTextures: true,
36
+ coordinateSystem: constants_1.COORDINATE_SYSTEM.METER_OFFSETS
37
+ }
38
+ }
39
+ };
40
+ async function parseI3S(data, options, context) {
41
+ const url = context.url;
42
+ options.i3s = options.i3s || {};
43
+ const magicNumber = getMagicNumber(data);
44
+ // check if file is slpk
45
+ if (magicNumber === SLPK_HEX) {
46
+ throw new Error('Files with .slpk extention currently are not supported by I3SLoader');
47
+ }
48
+ // auto detect file type based on url
49
+ let isTileset;
50
+ if (options.i3s.isTileset === 'auto') {
51
+ isTileset = TILESET_REGEX.test(url);
52
+ }
53
+ else {
54
+ isTileset = options.i3s.isTileset;
55
+ }
56
+ let isTileHeader;
57
+ if (options.isTileHeader === 'auto') {
58
+ isTileHeader = TILE_HEADER_REGEX.test(url);
59
+ }
60
+ else {
61
+ isTileHeader = options.i3s.isTileHeader;
62
+ }
63
+ if (isTileset) {
64
+ data = await parseTileset(data, options, context);
65
+ }
66
+ else if (isTileHeader) {
67
+ data = await parseTile(data, options, context);
68
+ if (options.i3s.loadContent) {
69
+ options.i3s.tile = data;
70
+ await (0, core_1.load)(data.contentUrl, exports.I3SLoader, options);
71
+ }
72
+ }
73
+ else {
74
+ data = await parseTileContent(data, options);
75
+ }
76
+ return data;
77
+ }
78
+ async function parseTileContent(arrayBuffer, options) {
79
+ return await (0, core_1.parse)(arrayBuffer, i3s_content_loader_1.I3SContentLoader, options);
80
+ }
81
+ async function parseTileset(data, options, context) {
82
+ const tilesetJson = JSON.parse(new TextDecoder().decode(data));
83
+ // eslint-disable-next-line no-use-before-define
84
+ tilesetJson.loader = exports.I3SLoader;
85
+ await (0, parse_i3s_1.normalizeTilesetData)(tilesetJson, options, context);
86
+ return tilesetJson;
87
+ }
88
+ async function parseTile(data, options, context) {
89
+ data = JSON.parse(new TextDecoder().decode(data));
90
+ return (0, parse_i3s_1.normalizeTileData)(data, options, context);
91
+ }
92
+ function getMagicNumber(data) {
93
+ if (data instanceof ArrayBuffer) {
94
+ // slice binary data (4 bytes from the beginning) and transform it to hexadecimal numeral system
95
+ return [...new Uint8Array(data, 0, 4)]
96
+ .map((value) => value.toString(16).padStart(2, '0'))
97
+ .join('');
98
+ }
99
+ return null;
100
+ }
@@ -0,0 +1,6 @@
1
+ import type { LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ /**
3
+ * Loader for I3S node pages
4
+ */
5
+ export declare const I3SNodePageLoader: LoaderWithParser;
6
+ //# sourceMappingURL=i3s-node-page-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-node-page-loader.d.ts","sourceRoot":"","sources":["../src/i3s-node-page-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAU/D;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAS/B,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.I3SNodePageLoader = void 0;
4
+ // __VERSION__ is injected by babel-plugin-version-inline
5
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
6
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
7
+ async function parseNodePage(data) {
8
+ return JSON.parse(new TextDecoder().decode(data));
9
+ }
10
+ /**
11
+ * Loader for I3S node pages
12
+ */
13
+ exports.I3SNodePageLoader = {
14
+ name: 'I3S Node Page',
15
+ id: 'i3s-node-page',
16
+ module: 'i3s',
17
+ version: VERSION,
18
+ mimeTypes: ['application/json'],
19
+ parse,
20
+ extensions: ['json'],
21
+ options: {}
22
+ };
23
+ async function parse(data) {
24
+ data = parseNodePage(data);
25
+ return data;
26
+ }
@@ -0,0 +1,7 @@
1
+ export { I3SLoader } from './i3s-loader';
2
+ export { I3SContentLoader } from './i3s-content-loader';
3
+ export { I3SAttributeLoader, loadFeatureAttributes } from './i3s-attribute-loader';
4
+ export { I3SBuildingSceneLayerLoader } from './i3s-building-scene-layer-loader';
5
+ export type { BoundingVolumes, Mbs, Obb, SceneLayer3D, AttributeStorageInfo, Field, ESRIField, PopupInfo, Node3DIndexDocument, LodSelection, NodeReference, Resource, I3SGeometry, MaxScreenThresholdSQ, NodeInPage, SharedResources, TextureImage, Attribute, Extent, FeatureAttribute } from './types';
6
+ export { COORDINATE_SYSTEM } from './lib/parsers/constants';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAE,qBAAqB,EAAC,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAC,2BAA2B,EAAC,MAAM,mCAAmC,CAAC;AAC9E,YAAY,EACV,eAAe,EACf,GAAG,EACH,GAAG,EACH,YAAY,EACZ,oBAAoB,EACpB,KAAK,EACL,SAAS,EACT,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,WAAW,EACX,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,SAAS,EACT,MAAM,EACN,gBAAgB,EACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COORDINATE_SYSTEM = exports.I3SBuildingSceneLayerLoader = exports.loadFeatureAttributes = exports.I3SAttributeLoader = exports.I3SContentLoader = exports.I3SLoader = void 0;
4
+ var i3s_loader_1 = require("./i3s-loader");
5
+ Object.defineProperty(exports, "I3SLoader", { enumerable: true, get: function () { return i3s_loader_1.I3SLoader; } });
6
+ var i3s_content_loader_1 = require("./i3s-content-loader");
7
+ Object.defineProperty(exports, "I3SContentLoader", { enumerable: true, get: function () { return i3s_content_loader_1.I3SContentLoader; } });
8
+ var i3s_attribute_loader_1 = require("./i3s-attribute-loader");
9
+ Object.defineProperty(exports, "I3SAttributeLoader", { enumerable: true, get: function () { return i3s_attribute_loader_1.I3SAttributeLoader; } });
10
+ Object.defineProperty(exports, "loadFeatureAttributes", { enumerable: true, get: function () { return i3s_attribute_loader_1.loadFeatureAttributes; } });
11
+ var i3s_building_scene_layer_loader_1 = require("./i3s-building-scene-layer-loader");
12
+ Object.defineProperty(exports, "I3SBuildingSceneLayerLoader", { enumerable: true, get: function () { return i3s_building_scene_layer_loader_1.I3SBuildingSceneLayerLoader; } });
13
+ var constants_1 = require("./lib/parsers/constants");
14
+ Object.defineProperty(exports, "COORDINATE_SYSTEM", { enumerable: true, get: function () { return constants_1.COORDINATE_SYSTEM; } });
@@ -0,0 +1,73 @@
1
+ import { Tileset, NodePage } from '../../types';
2
+ /**
3
+ * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them
4
+ */
5
+ export default class I3SNodePagesTiles {
6
+ tileset: Tileset;
7
+ nodePages: NodePage[];
8
+ pendingNodePages: {
9
+ promise: Promise<NodePage>;
10
+ status: 'Pending' | 'Done';
11
+ }[];
12
+ nodesPerPage: number;
13
+ options: {
14
+ [key: string]: any;
15
+ };
16
+ lodSelectionMetricType: any;
17
+ textureDefinitionsSelectedFormats: any[];
18
+ private textureLoaderOptions;
19
+ /**
20
+ * @constructs
21
+ * Create a I3SNodePagesTiles instance.
22
+ * @param tileset - i3s tileset header ('layers/0')
23
+ * @param options - i3s loader options
24
+ */
25
+ constructor(tileset: Tileset, options: object);
26
+ /**
27
+ * Loads some nodePage and return a particular node from it
28
+ * @param id - id of node through all node pages
29
+ */
30
+ getNodeById(id: number): Promise<any>;
31
+ /**
32
+ * Forms tile header using node and tileset data
33
+ * @param id - id of node through all node pages
34
+ */
35
+ formTileFromNodePages(id: number): Promise<any>;
36
+ /**
37
+ * Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset
38
+ * @param {Object} meshGeometryData - data about the node's mesh from the nodepage
39
+ * @returns {Object} -
40
+ * {string} url - url to the geometry resource
41
+ * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry
42
+ */
43
+ private getContentUrl;
44
+ /**
45
+ * Forms 1.6 compatible LOD selection object from a nodepage's node data
46
+ * @param {Object} node - a node from nodepage
47
+ * @returns {Object[]} - Array of object of following properties:
48
+ * {string} metricType - the label of the LOD metric
49
+ * {number} maxError - the value of the metric
50
+ */
51
+ private getLodSelection;
52
+ /**
53
+ * Returns information about texture and material from `materialDefinitions`
54
+ * @param {Object} material - material data from nodepage
55
+ * @returns {Object[]} - Couple [textureData, materialDefinition]
56
+ * {string} textureData.name - path name of the texture
57
+ * {string} textureData.format - format of the texture
58
+ * materialDefinition - PBR-like material definition from `materialDefinitions`
59
+ */
60
+ private getInformationFromMaterial;
61
+ /**
62
+ * Sets preferable and supported format for each textureDefinition of the tileset
63
+ * @param {Object} tileset - I3S layer data
64
+ * @returns {void}
65
+ */
66
+ private initSelectedFormatsForTextureDefinitions;
67
+ /**
68
+ * Returns the array of supported texture format
69
+ * @returns list of format strings
70
+ */
71
+ private getSupportedTextureFormats;
72
+ }
73
+ //# sourceMappingURL=i3s-nodepages-tiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i3s-nodepages-tiles.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers/i3s-nodepages-tiles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AAK9C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,QAAQ,EAAE,CAAM;IAC3B,gBAAgB,EAAE;QAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAA;KAAC,EAAE,CAAM;IAClF,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;IAC9B,sBAAsB,EAAE,GAAG,CAAC;IAC5B,iCAAiC,EAAE,GAAG,EAAE,CAAM;IAC9C,OAAO,CAAC,oBAAoB,CAA4B;IAExD;;;;;OAKG;gBACS,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM;IAS7C;;;OAGG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM;IAqB5B;;;OAGG;IAEG,qBAAqB,CAAC,EAAE,EAAE,MAAM;IAwDtC;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IA4BrB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAevB;;;;;;;OAOG;IACH,OAAO,CAAC,0BAA0B;IAmBlC;;;;OAIG;IACH,OAAO,CAAC,wCAAwC;IA2BhD;;;OAGG;IACH,OAAO,CAAC,0BAA0B;CAuBnC"}
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@loaders.gl/core");
4
+ const textures_1 = require("@loaders.gl/textures");
5
+ const i3s_node_page_loader_1 = require("../../i3s-node-page-loader");
6
+ const parse_i3s_1 = require("../parsers/parse-i3s");
7
+ const url_utils_1 = require("../utils/url-utils");
8
+ /**
9
+ * class I3SNodePagesTiles - loads nodePages and form i3s tiles from them
10
+ */
11
+ class I3SNodePagesTiles {
12
+ /**
13
+ * @constructs
14
+ * Create a I3SNodePagesTiles instance.
15
+ * @param tileset - i3s tileset header ('layers/0')
16
+ * @param options - i3s loader options
17
+ */
18
+ constructor(tileset, options) {
19
+ this.nodePages = [];
20
+ this.pendingNodePages = [];
21
+ this.textureDefinitionsSelectedFormats = [];
22
+ this.textureLoaderOptions = {};
23
+ this.tileset = { ...tileset }; // spread the tileset to avoid circular reference
24
+ this.nodesPerPage = tileset.nodePages.nodesPerPage;
25
+ this.lodSelectionMetricType = tileset.nodePages.lodSelectionMetricType;
26
+ this.options = options;
27
+ this.initSelectedFormatsForTextureDefinitions(tileset);
28
+ }
29
+ /**
30
+ * Loads some nodePage and return a particular node from it
31
+ * @param id - id of node through all node pages
32
+ */
33
+ async getNodeById(id) {
34
+ const pageIndex = Math.floor(id / this.nodesPerPage);
35
+ if (!this.nodePages[pageIndex] && !this.pendingNodePages[pageIndex]) {
36
+ const nodePageUrl = (0, url_utils_1.getUrlWithToken)(`${this.tileset.url}/nodepages/${pageIndex}`, this.options.i3s?.token);
37
+ this.pendingNodePages[pageIndex] = {
38
+ status: 'Pending',
39
+ promise: (0, core_1.load)(nodePageUrl, i3s_node_page_loader_1.I3SNodePageLoader, this.options)
40
+ };
41
+ this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
42
+ this.pendingNodePages[pageIndex].status = 'Done';
43
+ }
44
+ if (this.pendingNodePages[pageIndex].status === 'Pending') {
45
+ this.nodePages[pageIndex] = await this.pendingNodePages[pageIndex].promise;
46
+ }
47
+ const nodeIndex = id % this.nodesPerPage;
48
+ return this.nodePages[pageIndex].nodes[nodeIndex];
49
+ }
50
+ /**
51
+ * Forms tile header using node and tileset data
52
+ * @param id - id of node through all node pages
53
+ */
54
+ // eslint-disable-next-line complexity
55
+ async formTileFromNodePages(id) {
56
+ const node = await this.getNodeById(id);
57
+ const children = [];
58
+ for (const child of node.children || []) {
59
+ const childNode = await this.getNodeById(child);
60
+ children.push({
61
+ id: child,
62
+ obb: childNode.obb
63
+ });
64
+ }
65
+ let contentUrl = null;
66
+ let textureUrl = null;
67
+ let materialDefinition = null;
68
+ let textureFormat = 'jpeg';
69
+ let attributeUrls = [];
70
+ let isDracoGeometry = false;
71
+ if (node && node.mesh) {
72
+ // Get geometry resource URL and type (compressed / non-compressed)
73
+ const { url, isDracoGeometry: isDracoGeometryResult } = (node.mesh.geometry &&
74
+ this.getContentUrl(node.mesh.geometry)) || { url: null, isDracoGeometry: null };
75
+ contentUrl = url;
76
+ isDracoGeometry = isDracoGeometryResult;
77
+ const [textureData, nodeMaterialDefinition] = this.getInformationFromMaterial(node.mesh.material);
78
+ materialDefinition = nodeMaterialDefinition;
79
+ textureFormat = textureData.format || textureFormat;
80
+ if (textureData.name) {
81
+ textureUrl = `${this.tileset.url}/nodes/${node.mesh.material.resource}/textures/${textureData.name}`;
82
+ }
83
+ if (this.tileset.attributeStorageInfo) {
84
+ attributeUrls = (0, url_utils_1.generateTilesetAttributeUrls)(this.tileset, node.mesh.attribute.resource);
85
+ }
86
+ }
87
+ const lodSelection = this.getLodSelection(node);
88
+ return (0, parse_i3s_1.normalizeTileNonUrlData)({
89
+ id,
90
+ lodSelection,
91
+ obb: node.obb,
92
+ contentUrl,
93
+ textureUrl,
94
+ attributeUrls,
95
+ materialDefinition,
96
+ textureFormat,
97
+ textureLoaderOptions: this.textureLoaderOptions,
98
+ children,
99
+ isDracoGeometry
100
+ });
101
+ }
102
+ /**
103
+ * Forms url and type of geometry resource by nodepage's data and `geometryDefinitions` in the tileset
104
+ * @param {Object} meshGeometryData - data about the node's mesh from the nodepage
105
+ * @returns {Object} -
106
+ * {string} url - url to the geometry resource
107
+ * {boolean} isDracoGeometry - whether the geometry resource contain DRACO compressed geometry
108
+ */
109
+ getContentUrl(meshGeometryData) {
110
+ let result = {};
111
+ const geometryDefinition = this.tileset.geometryDefinitions[meshGeometryData.definition];
112
+ let geometryIndex = -1;
113
+ // Try to find DRACO geometryDefinition of `useDracoGeometry` option is set
114
+ if (this.options.i3s && this.options.i3s.useDracoGeometry) {
115
+ geometryIndex = geometryDefinition.geometryBuffers.findIndex((buffer) => buffer.compressedAttributes && buffer.compressedAttributes.encoding === 'draco');
116
+ }
117
+ // If DRACO geometry is not applicable try to select non-compressed geometry
118
+ if (geometryIndex === -1) {
119
+ geometryIndex = geometryDefinition.geometryBuffers.findIndex((buffer) => !buffer.compressedAttributes);
120
+ }
121
+ if (geometryIndex !== -1) {
122
+ const isDracoGeometry = Boolean(geometryDefinition.geometryBuffers[geometryIndex].compressedAttributes);
123
+ result = {
124
+ url: `${this.tileset.url}/nodes/${meshGeometryData.resource}/geometries/${geometryIndex}`,
125
+ isDracoGeometry
126
+ };
127
+ }
128
+ return result;
129
+ }
130
+ /**
131
+ * Forms 1.6 compatible LOD selection object from a nodepage's node data
132
+ * @param {Object} node - a node from nodepage
133
+ * @returns {Object[]} - Array of object of following properties:
134
+ * {string} metricType - the label of the LOD metric
135
+ * {number} maxError - the value of the metric
136
+ */
137
+ getLodSelection(node) {
138
+ const lodSelection = [];
139
+ if (this.lodSelectionMetricType === 'maxScreenThresholdSQ') {
140
+ lodSelection.push({
141
+ metricType: 'maxScreenThreshold',
142
+ maxError: Math.sqrt(node.lodThreshold / (Math.PI * 0.25))
143
+ });
144
+ }
145
+ lodSelection.push({
146
+ metricType: this.lodSelectionMetricType,
147
+ maxError: node.lodThreshold
148
+ });
149
+ return lodSelection;
150
+ }
151
+ /**
152
+ * Returns information about texture and material from `materialDefinitions`
153
+ * @param {Object} material - material data from nodepage
154
+ * @returns {Object[]} - Couple [textureData, materialDefinition]
155
+ * {string} textureData.name - path name of the texture
156
+ * {string} textureData.format - format of the texture
157
+ * materialDefinition - PBR-like material definition from `materialDefinitions`
158
+ */
159
+ getInformationFromMaterial(material) {
160
+ const textureDataDefault = { name: null, format: null };
161
+ if (material) {
162
+ const materialDefinition = this.tileset.materialDefinitions[material.definition];
163
+ const textureSetDefinitionIndex = materialDefinition &&
164
+ materialDefinition.pbrMetallicRoughness &&
165
+ materialDefinition.pbrMetallicRoughness.baseColorTexture &&
166
+ materialDefinition.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId;
167
+ if (textureSetDefinitionIndex || textureSetDefinitionIndex === 0) {
168
+ const textureData = this.textureDefinitionsSelectedFormats[textureSetDefinitionIndex] || textureDataDefault;
169
+ return [textureData, materialDefinition];
170
+ }
171
+ return [textureDataDefault, materialDefinition];
172
+ }
173
+ return [textureDataDefault, null];
174
+ }
175
+ /**
176
+ * Sets preferable and supported format for each textureDefinition of the tileset
177
+ * @param {Object} tileset - I3S layer data
178
+ * @returns {void}
179
+ */
180
+ initSelectedFormatsForTextureDefinitions(tileset) {
181
+ this.textureDefinitionsSelectedFormats = [];
182
+ const possibleI3sFormats = this.getSupportedTextureFormats();
183
+ const textureSetDefinitions = tileset.textureSetDefinitions || [];
184
+ for (const textureSetDefinition of textureSetDefinitions) {
185
+ const formats = (textureSetDefinition && textureSetDefinition.formats) || [];
186
+ let selectedFormat = null;
187
+ for (const i3sFormat of possibleI3sFormats) {
188
+ const format = formats.find((value) => value.format === i3sFormat);
189
+ if (format) {
190
+ selectedFormat = format;
191
+ break;
192
+ }
193
+ }
194
+ // For I3S 1.8 need to define basis target format to decode
195
+ if (selectedFormat && selectedFormat.format === 'ktx2') {
196
+ this.textureLoaderOptions.basis = {
197
+ format: (0, textures_1.selectSupportedBasisFormat)(),
198
+ containerFormat: 'ktx2',
199
+ module: 'encoder'
200
+ };
201
+ }
202
+ this.textureDefinitionsSelectedFormats.push(selectedFormat);
203
+ }
204
+ }
205
+ /**
206
+ * Returns the array of supported texture format
207
+ * @returns list of format strings
208
+ */
209
+ getSupportedTextureFormats() {
210
+ const formats = [];
211
+ if (!this.options.i3s || this.options.i3s.useCompressedTextures) {
212
+ // I3S 1.7 selection
213
+ const supportedCompressedFormats = (0, textures_1.getSupportedGPUTextureFormats)();
214
+ // List of possible in i3s formats:
215
+ // https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md
216
+ if (supportedCompressedFormats.has('etc2')) {
217
+ formats.push('ktx-etc2');
218
+ }
219
+ if (supportedCompressedFormats.has('dxt')) {
220
+ formats.push('dds');
221
+ }
222
+ // I3S 1.8 selection
223
+ // ktx2 wraps basis texture which at the edge case can be decoded as uncompressed image
224
+ formats.push('ktx2');
225
+ }
226
+ formats.push('jpg');
227
+ formats.push('png');
228
+ return formats;
229
+ }
230
+ }
231
+ exports.default = I3SNodePagesTiles;
@@ -0,0 +1,56 @@
1
+ export declare function getConstructorForDataFormat(dataType: string): Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | null;
2
+ export declare const GL_TYPE_MAP: {
3
+ [key: string]: number;
4
+ };
5
+ export declare const I3S_NAMED_VERTEX_ATTRIBUTES: {
6
+ position: string;
7
+ normal: string;
8
+ uv0: string;
9
+ color: string;
10
+ region: string;
11
+ };
12
+ export declare const I3S_NAMED_GEOMETRY_ATTRIBUTES: {
13
+ vertexAttributes: string;
14
+ featureAttributeOrder: string;
15
+ featureAttributes: string;
16
+ };
17
+ export declare const I3S_NAMED_HEADER_ATTRIBUTES: {
18
+ vertexCount: string;
19
+ featureCount: string;
20
+ };
21
+ /**
22
+ * Returns how many bytes a type occupies
23
+ * @param dataType
24
+ * @returns
25
+ */
26
+ export declare function sizeOf(dataType: string): number;
27
+ export declare const STRING_ATTRIBUTE_TYPE = "String";
28
+ export declare const OBJECT_ID_ATTRIBUTE_TYPE = "Oid32";
29
+ export declare const FLOAT_64_TYPE = "Float64";
30
+ export declare const INT_16_ATTRIBUTE_TYPE = "Int16";
31
+ export declare enum COORDINATE_SYSTEM {
32
+ /**
33
+ * `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise
34
+ */
35
+ DEFAULT = -1,
36
+ /**
37
+ * Positions are interpreted as [lng, lat, elevation]
38
+ * lng lat are degrees, elevation is meters. distances as meters.
39
+ */
40
+ LNGLAT = 1,
41
+ /**
42
+ * Positions are interpreted as meter offsets, distances as meters
43
+ */
44
+ METER_OFFSETS = 2,
45
+ /**
46
+ * Positions are interpreted as lng lat offsets: [deltaLng, deltaLat, elevation]
47
+ * deltaLng, deltaLat are delta degrees, elevation is meters.
48
+ * distances as meters.
49
+ */
50
+ LNGLAT_OFFSETS = 3,
51
+ /**
52
+ * Non-geospatial
53
+ */
54
+ CARTESIAN = 0
55
+ }
56
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/constants.ts"],"names":[],"mappings":"AAGA,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,sIAe3D;AAED,eAAO,MAAM,WAAW,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAM/C,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;CAMvC,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;CAIzC,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;CAIvC,CAAC;AACF;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkB/C;AAED,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,wBAAwB,UAAU,CAAC;AAChD,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,qBAAqB,UAAU,CAAC;AAI7C,oBAAY,iBAAiB;IAC3B;;OAEG;IACH,OAAO,KAAK;IACZ;;;OAGG;IACH,MAAM,IAAI;IACV;;OAEG;IACH,aAAa,IAAI;IACjB;;;;OAIG;IACH,cAAc,IAAI;IAClB;;OAEG;IACH,SAAS,IAAI;CACd"}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.COORDINATE_SYSTEM = exports.INT_16_ATTRIBUTE_TYPE = exports.FLOAT_64_TYPE = exports.OBJECT_ID_ATTRIBUTE_TYPE = exports.STRING_ATTRIBUTE_TYPE = exports.sizeOf = exports.I3S_NAMED_HEADER_ATTRIBUTES = exports.I3S_NAMED_GEOMETRY_ATTRIBUTES = exports.I3S_NAMED_VERTEX_ATTRIBUTES = exports.GL_TYPE_MAP = exports.getConstructorForDataFormat = void 0;
7
+ const constants_1 = __importDefault(require("@luma.gl/constants"));
8
+ const types_1 = require("../../types");
9
+ function getConstructorForDataFormat(dataType) {
10
+ switch (dataType) {
11
+ case types_1.DATA_TYPE.UInt8:
12
+ return Uint8Array;
13
+ case types_1.DATA_TYPE.UInt16:
14
+ return Uint16Array;
15
+ case types_1.DATA_TYPE.UInt32:
16
+ return Uint32Array;
17
+ case types_1.DATA_TYPE.Float32:
18
+ return Float32Array;
19
+ case types_1.DATA_TYPE.UInt64:
20
+ return Float64Array;
21
+ default:
22
+ return null;
23
+ }
24
+ }
25
+ exports.getConstructorForDataFormat = getConstructorForDataFormat;
26
+ exports.GL_TYPE_MAP = {
27
+ UInt8: constants_1.default.UNSIGNED_BYTE,
28
+ UInt16: constants_1.default.UNSIGNED_INT,
29
+ Float32: constants_1.default.FLOAT,
30
+ UInt32: constants_1.default.UNSIGNED_INT,
31
+ UInt64: constants_1.default.DOUBLE
32
+ };
33
+ exports.I3S_NAMED_VERTEX_ATTRIBUTES = {
34
+ position: 'position',
35
+ normal: 'normal',
36
+ uv0: 'uv0',
37
+ color: 'color',
38
+ region: 'region'
39
+ };
40
+ exports.I3S_NAMED_GEOMETRY_ATTRIBUTES = {
41
+ vertexAttributes: 'vertexAttributes',
42
+ featureAttributeOrder: 'featureAttributeOrder',
43
+ featureAttributes: 'featureAttributes'
44
+ };
45
+ // TODO Remove Named Attributes and replase with Typescipt types
46
+ exports.I3S_NAMED_HEADER_ATTRIBUTES = {
47
+ // header: 'header',
48
+ vertexCount: 'vertexCount',
49
+ featureCount: 'featureCount'
50
+ };
51
+ /**
52
+ * Returns how many bytes a type occupies
53
+ * @param dataType
54
+ * @returns
55
+ */
56
+ function sizeOf(dataType) {
57
+ switch (dataType) {
58
+ case types_1.DATA_TYPE.UInt8:
59
+ return 1;
60
+ case types_1.DATA_TYPE.UInt16:
61
+ case types_1.DATA_TYPE.Int16:
62
+ return 2;
63
+ case types_1.DATA_TYPE.UInt32:
64
+ case types_1.DATA_TYPE.Int32:
65
+ case types_1.DATA_TYPE.Float32:
66
+ return 4;
67
+ case types_1.DATA_TYPE.UInt64:
68
+ case types_1.DATA_TYPE.Int64:
69
+ case types_1.DATA_TYPE.Float64:
70
+ return 8;
71
+ default:
72
+ return NaN;
73
+ }
74
+ }
75
+ exports.sizeOf = sizeOf;
76
+ exports.STRING_ATTRIBUTE_TYPE = 'String';
77
+ exports.OBJECT_ID_ATTRIBUTE_TYPE = 'Oid32';
78
+ exports.FLOAT_64_TYPE = 'Float64';
79
+ exports.INT_16_ATTRIBUTE_TYPE = 'Int16';
80
+ // https://github.com/visgl/deck.gl/blob/9548f43cba2234a1f4877b6b17f6c88eb35b2e08/modules/core/src/lib/constants.js#L27
81
+ // Describes the format of positions
82
+ var COORDINATE_SYSTEM;
83
+ (function (COORDINATE_SYSTEM) {
84
+ /**
85
+ * `LNGLAT` if rendering into a geospatial viewport, `CARTESIAN` otherwise
86
+ */
87
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["DEFAULT"] = -1] = "DEFAULT";
88
+ /**
89
+ * Positions are interpreted as [lng, lat, elevation]
90
+ * lng lat are degrees, elevation is meters. distances as meters.
91
+ */
92
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["LNGLAT"] = 1] = "LNGLAT";
93
+ /**
94
+ * Positions are interpreted as meter offsets, distances as meters
95
+ */
96
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["METER_OFFSETS"] = 2] = "METER_OFFSETS";
97
+ /**
98
+ * Positions are interpreted as lng lat offsets: [deltaLng, deltaLat, elevation]
99
+ * deltaLng, deltaLat are delta degrees, elevation is meters.
100
+ * distances as meters.
101
+ */
102
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["LNGLAT_OFFSETS"] = 3] = "LNGLAT_OFFSETS";
103
+ /**
104
+ * Non-geospatial
105
+ */
106
+ COORDINATE_SYSTEM[COORDINATE_SYSTEM["CARTESIAN"] = 0] = "CARTESIAN";
107
+ })(COORDINATE_SYSTEM = exports.COORDINATE_SYSTEM || (exports.COORDINATE_SYSTEM = {}));
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Get particular tile and creates attribute object inside.
3
+ * @param {ArrayBuffer} arrayBuffer
4
+ * @param {Object} options
5
+ * @returns {Promise<object>}
6
+ */
7
+ export declare function parseI3STileAttribute(arrayBuffer: any, options: any): Promise<{
8
+ [x: number]: Int16Array | Uint32Array | Float64Array | string[] | null;
9
+ }>;
10
+ //# sourceMappingURL=parse-i3s-attribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-i3s-attribute.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-i3s-attribute.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,KAAA,EAAE,OAAO,KAAA;;GAS/D"}