@loaders.gl/tile-converter 3.1.8 → 3.2.0-alpha.1

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 (112) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +78 -0
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js +242 -0
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +83 -0
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +278 -0
  7. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +13 -0
  8. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
  9. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +23 -0
  10. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
  11. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
  12. package/dist/3d-tiles-converter/helpers/texture-atlas.js +52 -0
  13. package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
  14. package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
  15. package/dist/3d-tiles-converter/json-templates/tileset.js +43 -0
  16. package/dist/bundle.d.ts +2 -0
  17. package/dist/bundle.d.ts.map +1 -0
  18. package/dist/bundle.js +5 -0
  19. package/dist/converter.min.js +19 -19
  20. package/dist/deps-installer/deps-installer.d.ts +4 -0
  21. package/dist/deps-installer/deps-installer.d.ts.map +1 -0
  22. package/dist/deps-installer/deps-installer.js +21 -0
  23. package/dist/dist.min.js +304 -494
  24. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +2 -1
  25. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  26. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +14 -21
  27. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  28. package/dist/es5/i3s-converter/i3s-converter.js +35 -25
  29. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  30. package/dist/es5/pgm-loader.js +1 -1
  31. package/dist/es5/pgm-loader.js.map +1 -1
  32. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +2 -1
  33. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  34. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +7 -5
  35. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  36. package/dist/esm/i3s-converter/i3s-converter.js +10 -0
  37. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  38. package/dist/esm/pgm-loader.js +1 -1
  39. package/dist/esm/pgm-loader.js.map +1 -1
  40. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
  41. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
  42. package/dist/i3s-converter/helpers/coordinate-converter.js +118 -0
  43. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
  44. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
  45. package/dist/i3s-converter/helpers/create-scene-server-path.js +28 -0
  46. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +8 -0
  47. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
  48. package/dist/i3s-converter/helpers/geometry-attributes.js +176 -0
  49. package/dist/i3s-converter/helpers/geometry-converter.d.ts +12 -0
  50. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
  51. package/dist/i3s-converter/helpers/geometry-converter.js +791 -0
  52. package/dist/i3s-converter/helpers/node-debug.d.ts +8 -0
  53. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
  54. package/dist/i3s-converter/helpers/node-debug.js +114 -0
  55. package/dist/i3s-converter/helpers/node-pages.d.ts +116 -0
  56. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
  57. package/dist/i3s-converter/helpers/node-pages.js +203 -0
  58. package/dist/i3s-converter/i3s-converter.d.ts +321 -0
  59. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
  60. package/dist/i3s-converter/i3s-converter.js +994 -0
  61. package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
  62. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
  63. package/dist/i3s-converter/json-templates/layers.js +199 -0
  64. package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
  65. package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
  66. package/dist/i3s-converter/json-templates/metadata.js +25 -0
  67. package/dist/i3s-converter/json-templates/node.d.ts +61 -0
  68. package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
  69. package/dist/i3s-converter/json-templates/node.js +89 -0
  70. package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
  71. package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
  72. package/dist/i3s-converter/json-templates/scene-server.js +31 -0
  73. package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
  74. package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
  75. package/dist/i3s-converter/json-templates/shared-resources.js +129 -0
  76. package/dist/i3s-converter/json-templates/store.d.ts +95 -0
  77. package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
  78. package/dist/i3s-converter/json-templates/store.js +103 -0
  79. package/dist/i3s-converter/types.d.ts +39 -0
  80. package/dist/i3s-converter/types.d.ts.map +1 -0
  81. package/dist/i3s-converter/types.js +2 -0
  82. package/dist/i3s-server/app.d.ts +3 -0
  83. package/dist/i3s-server/app.d.ts.map +1 -0
  84. package/dist/i3s-server/app.js +14 -0
  85. package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
  86. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
  87. package/dist/i3s-server/controllers/index-controller.js +23 -0
  88. package/dist/i3s-server/routes/index.d.ts +3 -0
  89. package/dist/i3s-server/routes/index.d.ts.map +1 -0
  90. package/dist/i3s-server/routes/index.js +16 -0
  91. package/dist/index.d.ts +5 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +14 -0
  94. package/dist/lib/utils/compress-util.d.ts +6 -0
  95. package/dist/lib/utils/compress-util.d.ts.map +1 -0
  96. package/dist/lib/utils/compress-util.js +190 -0
  97. package/dist/lib/utils/file-utils.d.ts +6 -0
  98. package/dist/lib/utils/file-utils.d.ts.map +1 -0
  99. package/dist/lib/utils/file-utils.js +42 -0
  100. package/dist/lib/utils/lod-conversion-utils.d.ts +20 -0
  101. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
  102. package/dist/lib/utils/lod-conversion-utils.js +57 -0
  103. package/dist/lib/utils/statistic-utills.d.ts +3 -0
  104. package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
  105. package/dist/lib/utils/statistic-utills.js +64 -0
  106. package/dist/pgm-loader.d.ts +6 -0
  107. package/dist/pgm-loader.d.ts.map +1 -0
  108. package/dist/pgm-loader.js +23 -0
  109. package/package.json +16 -17
  110. package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -1
  111. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +6 -5
  112. package/src/i3s-converter/i3s-converter.ts +12 -0
@@ -0,0 +1,78 @@
1
+ import type { AttributeStorageInfo } from '@loaders.gl/i3s';
2
+ import { Tileset3D } from '@loaders.gl/tiles';
3
+ import { Geoid } from '@math.gl/geoid';
4
+ /**
5
+ * Converter from i3s to 3d-tiles
6
+ */
7
+ export default class Tiles3DConverter {
8
+ options: any;
9
+ tilesetPath: string;
10
+ vertexCounter: number;
11
+ conversionStartTime: [number, number];
12
+ geoidHeightModel: Geoid | null;
13
+ sourceTileset: Tileset3D | null;
14
+ attributeStorageInfo: AttributeStorageInfo | null;
15
+ constructor();
16
+ /**
17
+ * Convert i3s format data to 3dTiles
18
+ * @param options
19
+ * @param options.inputUrl the url to read the tileset from
20
+ * @param options.outputPath the output filename
21
+ * @param options.tilesetName the output name of the tileset
22
+ * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
23
+ * @param options.maxDepth The max tree depth of conversion
24
+ */
25
+ convert(options: {
26
+ inputUrl: string;
27
+ outputPath: string;
28
+ tilesetName: string;
29
+ maxDepth: number;
30
+ egmFilePath: string;
31
+ }): Promise<any>;
32
+ /**
33
+ * The recursive function of traversal of a nodes tree
34
+ * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
35
+ * @param parentNode object in resulting tileset
36
+ * @param level a current level of a tree depth
37
+ */
38
+ private _addChildren;
39
+ /**
40
+ * Load a child node having information from the node header
41
+ * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)
42
+ * @param childNodeInfo child information from 3DNodeIndexDocument
43
+ * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)
44
+ */
45
+ private _loadChildNode;
46
+ /**
47
+ * Make an url of a resource from its relative url having the base url
48
+ * @param baseUrl the base url. A resulting url will be related from this url
49
+ * @param relativeUrl a realtive url of a resource
50
+ */
51
+ private _relativeUrlToFullUrl;
52
+ /**
53
+ * Do loading all attributes related to particular node.
54
+ * @param sourceChild
55
+ * @param attributeStorageInfo
56
+ * @returns Promise of attributes object.
57
+ */
58
+ private _loadChildAttributes;
59
+ /**
60
+ * Returns attribute type for loading attributes
61
+ * @param attribute
62
+ * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.
63
+ * There is an 'Oid32' type if attribute has objectIds property.
64
+ * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md
65
+ */
66
+ private _getAttributeType;
67
+ /**
68
+ * Make simple arrays from attribute typed arrays.
69
+ * @param attributesList
70
+ */
71
+ private _replaceNestedArrays;
72
+ /**
73
+ * Print statistics in the end of conversion
74
+ * @param params - output files data
75
+ */
76
+ private _finishConversion;
77
+ }
78
+ //# sourceMappingURL=3d-tiles-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"3d-tiles-converter.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAkC,MAAM,iBAAiB,CAAC;AAQ3F,OAAO,EAAC,SAAS,EAAS,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAarC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,gBAAgB,EAAE,KAAK,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC;IAChC,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAC;;IAYlD;;;;;;;;OAQG;IACU,OAAO,CAAC,OAAO,EAAE;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,GAAG,CAAC;IA+ChB;;;;;OAKG;YACW,YAAY;IAiD1B;;;;;OAKG;YACW,cAAc;IAyB5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;;;;OAKG;YACW,oBAAoB;IAsBlC;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IASzB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;OAGG;YACW,iBAAiB;CAgBhC"}
@@ -0,0 +1,242 @@
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
+ const path_1 = require("path");
7
+ const process_1 = __importDefault(require("process"));
8
+ const json_map_transform_1 = __importDefault(require("json-map-transform"));
9
+ const core_1 = require("@loaders.gl/core");
10
+ const i3s_1 = require("@loaders.gl/i3s");
11
+ const tiles_1 = require("@loaders.gl/tiles");
12
+ const pgm_loader_1 = require("../pgm-loader");
13
+ const i3s_obb_to_3d_tiles_obb_1 = require("./helpers/i3s-obb-to-3d-tiles-obb");
14
+ const lod_conversion_utils_1 = require("../lib/utils/lod-conversion-utils");
15
+ const file_utils_1 = require("../lib/utils/file-utils");
16
+ const statistic_utills_1 = require("../lib/utils/statistic-utills");
17
+ const tileset_1 = require("./json-templates/tileset");
18
+ const b3dm_converter_1 = __importDefault(require("./helpers/b3dm-converter"));
19
+ const coordinate_converter_1 = require("../i3s-converter/helpers/coordinate-converter");
20
+ const I3S = 'I3S';
21
+ /**
22
+ * Converter from i3s to 3d-tiles
23
+ */
24
+ class Tiles3DConverter {
25
+ constructor() {
26
+ this.options = {};
27
+ this.tilesetPath = '';
28
+ this.vertexCounter = 0;
29
+ this.conversionStartTime = [0, 0];
30
+ this.geoidHeightModel = null;
31
+ this.sourceTileset = null;
32
+ this.attributeStorageInfo = null;
33
+ }
34
+ /**
35
+ * Convert i3s format data to 3dTiles
36
+ * @param options
37
+ * @param options.inputUrl the url to read the tileset from
38
+ * @param options.outputPath the output filename
39
+ * @param options.tilesetName the output name of the tileset
40
+ * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
41
+ * @param options.maxDepth The max tree depth of conversion
42
+ */
43
+ async convert(options) {
44
+ const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath } = options;
45
+ this.conversionStartTime = process_1.default.hrtime();
46
+ this.options = { maxDepth };
47
+ console.log('Loading egm file...'); // eslint-disable-line
48
+ this.geoidHeightModel = await (0, core_1.load)(egmFilePath, pgm_loader_1.PGMLoader);
49
+ console.log('Loading egm file completed!'); // eslint-disable-line
50
+ const sourceTilesetJson = await (0, core_1.load)(inputUrl, i3s_1.I3SLoader, {});
51
+ this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, {
52
+ loadOptions: {
53
+ i3s: { coordinateSystem: i3s_1.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false }
54
+ }
55
+ });
56
+ const rootNode = this.sourceTileset.root;
57
+ if (!rootNode.header.obb) {
58
+ rootNode.header.obb = (0, coordinate_converter_1.createObbFromMbs)(rootNode.header.mbs);
59
+ }
60
+ this.tilesetPath = (0, path_1.join)(`${outputPath}`, `${tilesetName}`);
61
+ this.attributeStorageInfo = sourceTilesetJson.attributeStorageInfo;
62
+ // Removing the tilesetPath needed to exclude erroneous files after conversion
63
+ try {
64
+ await (0, file_utils_1.removeDir)(this.tilesetPath);
65
+ }
66
+ catch (e) {
67
+ // do nothing
68
+ }
69
+ const rootTile = {
70
+ boundingVolume: {
71
+ box: (0, i3s_obb_to_3d_tiles_obb_1.i3sObbTo3dTilesObb)(rootNode.header.obb, this.geoidHeightModel)
72
+ },
73
+ geometricError: (0, lod_conversion_utils_1.convertScreenThresholdToGeometricError)(rootNode),
74
+ children: []
75
+ };
76
+ await this._addChildren(rootNode, rootTile, 1);
77
+ const tileset = (0, json_map_transform_1.default)({ root: rootTile }, (0, tileset_1.TILESET)());
78
+ await (0, file_utils_1.writeFile)(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
79
+ this._finishConversion({ slpk: false, outputPath, tilesetName });
80
+ }
81
+ /**
82
+ * The recursive function of traversal of a nodes tree
83
+ * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
84
+ * @param parentNode object in resulting tileset
85
+ * @param level a current level of a tree depth
86
+ */
87
+ async _addChildren(parentSourceNode, parentNode, level) {
88
+ if (this.options.maxDepth && level > this.options.maxDepth) {
89
+ return;
90
+ }
91
+ for (const childNodeInfo of parentSourceNode.header.children || []) {
92
+ const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
93
+ parentSourceNode.children.push(sourceChild);
94
+ if (sourceChild.contentUrl) {
95
+ await this.sourceTileset._loadTile(sourceChild);
96
+ this.vertexCounter += sourceChild.content.vertexCount;
97
+ let attributes = null;
98
+ if (this.attributeStorageInfo) {
99
+ attributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
100
+ }
101
+ if (!sourceChild.header.obb) {
102
+ sourceChild.header.obb = (0, coordinate_converter_1.createObbFromMbs)(sourceChild.header.mbs);
103
+ }
104
+ const boundingVolume = {
105
+ box: (0, i3s_obb_to_3d_tiles_obb_1.i3sObbTo3dTilesObb)(sourceChild.header.obb, this.geoidHeightModel)
106
+ };
107
+ const child = {
108
+ boundingVolume,
109
+ geometricError: (0, lod_conversion_utils_1.convertScreenThresholdToGeometricError)(sourceChild),
110
+ children: []
111
+ };
112
+ const b3dm = await new b3dm_converter_1.default().convert(sourceChild, attributes);
113
+ child.content = {
114
+ uri: `${sourceChild.id}.b3dm`,
115
+ boundingVolume
116
+ };
117
+ await (0, file_utils_1.writeFile)(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);
118
+ parentNode.children.push(child);
119
+ sourceChild.unloadContent();
120
+ await this._addChildren(sourceChild, child, level + 1);
121
+ }
122
+ else {
123
+ await this._addChildren(sourceChild, parentNode, level + 1);
124
+ }
125
+ }
126
+ }
127
+ /**
128
+ * Load a child node having information from the node header
129
+ * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)
130
+ * @param childNodeInfo child information from 3DNodeIndexDocument
131
+ * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)
132
+ */
133
+ async _loadChildNode(parentNode, childNodeInfo) {
134
+ let header;
135
+ if (this.sourceTileset.tileset.nodePages) {
136
+ console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef
137
+ header = await this.sourceTileset.tileset.nodePagesTile.formTileFromNodePages(childNodeInfo.id);
138
+ }
139
+ else {
140
+ const { loader } = this.sourceTileset;
141
+ const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href);
142
+ // load metadata
143
+ const options = {
144
+ i3s: {
145
+ ...this.sourceTileset.loadOptions,
146
+ isTileHeader: true,
147
+ loadContent: false
148
+ }
149
+ };
150
+ console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef
151
+ header = await (0, core_1.load)(nodeUrl, loader, options);
152
+ }
153
+ return new tiles_1.Tile3D(this.sourceTileset, header, parentNode);
154
+ }
155
+ /**
156
+ * Make an url of a resource from its relative url having the base url
157
+ * @param baseUrl the base url. A resulting url will be related from this url
158
+ * @param relativeUrl a realtive url of a resource
159
+ */
160
+ _relativeUrlToFullUrl(baseUrl, relativeUrl) {
161
+ let resultArray = baseUrl.split('/');
162
+ const relativeUrlArray = relativeUrl.split('/');
163
+ for (const folder of relativeUrlArray) {
164
+ switch (folder) {
165
+ case '.':
166
+ continue; // eslint-disable-line no-continue
167
+ case '..':
168
+ resultArray = resultArray.slice(0, -1);
169
+ break;
170
+ default:
171
+ resultArray.push(folder);
172
+ }
173
+ }
174
+ return resultArray.join('/');
175
+ }
176
+ /**
177
+ * Do loading all attributes related to particular node.
178
+ * @param sourceChild
179
+ * @param attributeStorageInfo
180
+ * @returns Promise of attributes object.
181
+ */
182
+ async _loadChildAttributes(sourceChild, attributeStorageInfo) {
183
+ const promises = [];
184
+ const { attributeUrls } = sourceChild.header;
185
+ for (let index = 0; index < attributeUrls.length; index++) {
186
+ const inputUrl = attributeUrls[index];
187
+ const attribute = attributeStorageInfo[index];
188
+ const options = {
189
+ attributeName: attribute.name,
190
+ attributeType: this._getAttributeType(attribute)
191
+ };
192
+ promises.push((0, core_1.load)(inputUrl, i3s_1.I3SAttributeLoader, options));
193
+ }
194
+ const attributesList = await Promise.all(promises);
195
+ this._replaceNestedArrays(attributesList);
196
+ return Object.assign({}, ...attributesList);
197
+ }
198
+ /**
199
+ * Returns attribute type for loading attributes
200
+ * @param attribute
201
+ * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.
202
+ * There is an 'Oid32' type if attribute has objectIds property.
203
+ * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md
204
+ */
205
+ _getAttributeType(attribute) {
206
+ if (attribute.attributeValues) {
207
+ return attribute.attributeValues.valueType;
208
+ }
209
+ else if (attribute.objectIds) {
210
+ return 'Oid32';
211
+ }
212
+ return '';
213
+ }
214
+ /**
215
+ * Make simple arrays from attribute typed arrays.
216
+ * @param attributesList
217
+ */
218
+ _replaceNestedArrays(attributesList) {
219
+ for (let index = 0; index < attributesList.length; index++) {
220
+ const attributeObject = attributesList[index];
221
+ for (const key in attributeObject) {
222
+ attributeObject[key] = Array.from(attributeObject[key]);
223
+ }
224
+ }
225
+ }
226
+ /**
227
+ * Print statistics in the end of conversion
228
+ * @param params - output files data
229
+ */
230
+ async _finishConversion(params) {
231
+ const filesSize = await (0, statistic_utills_1.calculateFilesSize)(params);
232
+ const diff = process_1.default.hrtime(this.conversionStartTime);
233
+ const conversionTime = (0, statistic_utills_1.timeConverter)(diff);
234
+ console.log(`------------------------------------------------`); // eslint-disable-line
235
+ console.log(`Finish conversion of ${I3S}`); // eslint-disable-line
236
+ console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line
237
+ console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line
238
+ console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line
239
+ console.log(`------------------------------------------------`); // eslint-disable-line
240
+ }
241
+ }
242
+ exports.default = Tiles3DConverter;
@@ -0,0 +1,83 @@
1
+ import { Matrix4 } from '@math.gl/core';
2
+ /**
3
+ * Converts content of an I3S node to *.b3dm's file content
4
+ */
5
+ export default class B3dmConverter {
6
+ rtcCenter: Float32Array;
7
+ i3sTile: any;
8
+ /**
9
+ * The starter of content conversion
10
+ * @param i3sTile - Tile3D instance for I3S node
11
+ * @returns - encoded content
12
+ */
13
+ convert(i3sTile: Object, attributes?: any): Promise<ArrayBuffer>;
14
+ /**
15
+ * Build and encode gltf
16
+ * @param i3sTile - Tile3D instance for I3S node
17
+ * @returns - encoded glb content
18
+ */
19
+ buildGltf(i3sTile: any): Promise<ArrayBuffer>;
20
+ /**
21
+ * Update gltfBuilder with texture from I3S tile
22
+ * @param {object} i3sTile - Tile3D object
23
+ * @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
24
+ * @returns {Promise<number | null>} - GLTF texture index
25
+ */
26
+ _addI3sTextureToGltf(i3sTile: any, gltfBuilder: any): Promise<null>;
27
+ /**
28
+ * Generate a positions array which is correct for 3DTiles/GLTF format
29
+ * @param {Float64Array} positionsValue - the input geometry positions array
30
+ * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
31
+ * @param {number[]} cartographicOrigin - the tile center in the cartographic coordinate system
32
+ * @param {number[]} modelMatrix - the model matrix of geometry
33
+ * @returns {Float32Array} - the output geometry positions array
34
+ */
35
+ _normalizePositions(positionsValue: any, cartesianOrigin: any, cartographicOrigin: any, modelMatrix: any): Float32Array;
36
+ /**
37
+ * Generate the transformation matrix for GLTF node:
38
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-node
39
+ * 1. Create the translate transformation from cartesianOrigin (the positions array stores offsets from this cartesianOrigin)
40
+ * 2. Create the rotation transformation to rotate model from z-up coordinates (I3S specific) to y-up coordinates (GLTF specific)
41
+ * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
42
+ * @returns {Matrix4} - an array of 16 numbers (4x4 matrix)
43
+ */
44
+ _generateTransformMatrix(cartesianOrigin: any): Matrix4;
45
+ /**
46
+ * Generate batchId attribute from faceRanges.
47
+ * @param {Uint32Array} faceRanges - the source array
48
+ * @returns {Float32Array} batchId list.
49
+ */
50
+ _generateBatchId(faceRanges: any): Float32Array;
51
+ /**
52
+ * luma.gl can not work without indices now:
53
+ * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
54
+ * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
55
+ * @param {number} vertexCount - vertex count in the geometry
56
+ * @returns {Uint32Array} indices array.
57
+ */
58
+ _generateSynteticIndices(vertexCount: any): Uint32Array;
59
+ /**
60
+ * Deduce mime type by format from `textureSetDefinition.formats[0].format`
61
+ * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md
62
+ * @param {string} format - format name
63
+ * @returns {string} mime type.
64
+ */
65
+ _deduceMimeTypeFromFormat(format: any): "image/jpeg" | "image/ktx2" | "image/png";
66
+ /**
67
+ * Convert i3s material to GLTF compatible material
68
+ * @param {object} material - i3s material definition
69
+ * @param {number | null} textureIndex - texture index in GLTF
70
+ * @returns {object} GLTF material
71
+ */
72
+ _convertI3sMaterialToGltfMaterial(material: any, textureIndex: any): any;
73
+ /**
74
+ * Set texture properties in material with GLTF textureIndex
75
+ * @param {object} materialDefinition - i3s material definition
76
+ * @param {number} textureIndex - texture index in GLTF
77
+ * @returns {void}
78
+ */
79
+ _setGltfTexture(materialDefinition: any, textureIndex: any): any;
80
+ _getFeaturesLength(attributes: any): any;
81
+ _checkNormals(normals: any): any;
82
+ }
83
+ //# sourceMappingURL=b3dm-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"b3dm-converter.d.ts","sourceRoot":"","sources":["../../../src/3d-tiles-converter/helpers/b3dm-converter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;AAO/C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAEhC,SAAS,EAAE,YAAY,CAAC;IACxB,OAAO,EAAE,GAAG,CAAC;IAEb;;;;OAIG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,GAAE,GAAU,GAAG,OAAO,CAAC,WAAW,CAAC;IAe5E;;;;OAIG;IACG,SAAS,CAAC,OAAO,KAAA,GAAG,OAAO,CAAC,WAAW,CAAC;IAsD9C;;;;;OAKG;IACG,oBAAoB,CAAC,OAAO,KAAA,EAAE,WAAW,KAAA;IAsB/C;;;;;;;OAOG;IACH,mBAAmB,CAAC,cAAc,KAAA,EAAE,eAAe,KAAA,EAAE,kBAAkB,KAAA,EAAE,WAAW,KAAA;IAepF;;;;;;;OAOG;IACH,wBAAwB,CAAC,eAAe,KAAA;IAMxC;;;;OAIG;IACH,gBAAgB,CAAC,UAAU,KAAA;IAiB3B;;;;;;OAMG;IACH,wBAAwB,CAAC,WAAW,KAAA;IAQpC;;;;;OAKG;IACH,yBAAyB,CAAC,MAAM,KAAA;IAchC;;;;;OAKG;IACH,iCAAiC,CAAC,QAAQ,KAAA,EAAE,YAAY,KAAA;IAgCxD;;;;;OAKG;IACH,eAAe,CAAC,kBAAkB,KAAA,EAAE,YAAY,KAAA;IA+ChD,kBAAkB,CAAC,UAAU,KAAA;IAY7B,aAAa,CAAC,OAAO,KAAA;CAItB"}