@loaders.gl/tile-converter 4.2.0-alpha.4 → 4.2.0-alpha.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 (144) hide show
  1. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +3 -3
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  3. package/dist/3d-tiles-converter/3d-tiles-converter.js +329 -293
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +257 -200
  5. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +14 -5
  6. package/dist/3d-tiles-converter/helpers/load-i3s.js +106 -75
  7. package/dist/3d-tiles-converter/helpers/texture-atlas.js +44 -21
  8. package/dist/3d-tiles-converter/json-templates/tileset.js +32 -33
  9. package/dist/constants.js +0 -1
  10. package/dist/converter-cli.js +255 -234
  11. package/dist/converter.min.cjs +80 -90
  12. package/dist/deps-installer/deps-installer.js +72 -58
  13. package/dist/i3s-converter/helpers/attribute-metadata-info.js +207 -153
  14. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +1 -1
  15. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  16. package/dist/i3s-converter/helpers/batch-ids-extensions.js +145 -103
  17. package/dist/i3s-converter/helpers/coordinate-converter.js +100 -65
  18. package/dist/i3s-converter/helpers/create-scene-server-path.js +14 -9
  19. package/dist/i3s-converter/helpers/feature-attributes.js +168 -105
  20. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +1 -1
  21. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  22. package/dist/i3s-converter/helpers/geometry-attributes.js +204 -212
  23. package/dist/i3s-converter/helpers/geometry-converter.d.ts +2 -2
  24. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  25. package/dist/i3s-converter/helpers/geometry-converter.js +1148 -829
  26. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
  27. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  28. package/dist/i3s-converter/helpers/gltf-attributes.js +111 -97
  29. package/dist/i3s-converter/helpers/load-3d-tiles.js +103 -66
  30. package/dist/i3s-converter/helpers/node-debug.js +98 -54
  31. package/dist/i3s-converter/helpers/node-index-document.d.ts +3 -3
  32. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  33. package/dist/i3s-converter/helpers/node-index-document.js +248 -177
  34. package/dist/i3s-converter/helpers/node-pages.d.ts +1 -1
  35. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  36. package/dist/i3s-converter/helpers/node-pages.js +299 -194
  37. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +1 -1
  38. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  39. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +92 -60
  40. package/dist/i3s-converter/helpers/progress.js +134 -83
  41. package/dist/i3s-converter/helpers/tileset-traversal.d.ts +1 -1
  42. package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -1
  43. package/dist/i3s-converter/helpers/tileset-traversal.js +24 -13
  44. package/dist/i3s-converter/i3s-converter.d.ts +7 -7
  45. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  46. package/dist/i3s-converter/i3s-converter.js +1044 -898
  47. package/dist/i3s-converter/json-templates/geometry-definitions.js +70 -79
  48. package/dist/i3s-converter/json-templates/layers.js +120 -121
  49. package/dist/i3s-converter/json-templates/metadata.js +19 -20
  50. package/dist/i3s-converter/json-templates/node.js +73 -71
  51. package/dist/i3s-converter/json-templates/scene-server.js +25 -26
  52. package/dist/i3s-converter/json-templates/shared-resources.js +107 -108
  53. package/dist/i3s-converter/json-templates/store.js +96 -94
  54. package/dist/i3s-converter/types.js +35 -23
  55. package/dist/i3s-server/app.js +15 -12
  56. package/dist/i3s-server/bin/www.js +14 -7
  57. package/dist/i3s-server/controllers/index-controller.js +18 -15
  58. package/dist/i3s-server/controllers/slpk-controller.js +22 -11
  59. package/dist/i3s-server/routes/index.js +9 -8
  60. package/dist/i3s-server/routes/slpk-router.js +18 -17
  61. package/dist/i3s-server/utils/create-scene-server.js +15 -10
  62. package/dist/i3s-server/utils/server-utils.js +49 -32
  63. package/dist/index.cjs +292 -851
  64. package/dist/index.cjs.map +7 -0
  65. package/dist/index.d.ts +2 -2
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +0 -1
  68. package/dist/lib/json-schemas/conversion-dump-json-schema.js +243 -421
  69. package/dist/lib/utils/cli-utils.js +63 -36
  70. package/dist/lib/utils/compress-util.js +20 -15
  71. package/dist/lib/utils/conversion-dump.d.ts +1 -1
  72. package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
  73. package/dist/lib/utils/conversion-dump.js +209 -187
  74. package/dist/lib/utils/file-utils.js +122 -74
  75. package/dist/lib/utils/geometry-utils.js +13 -7
  76. package/dist/lib/utils/lod-conversion-utils.js +65 -33
  77. package/dist/lib/utils/queue.js +12 -13
  78. package/dist/lib/utils/statistic-utills.d.ts +6 -23
  79. package/dist/lib/utils/statistic-utills.js +64 -59
  80. package/dist/lib/utils/write-queue.d.ts +2 -2
  81. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  82. package/dist/lib/utils/write-queue.js +68 -86
  83. package/dist/pgm-loader.js +16 -12
  84. package/dist/slpk-extractor/slpk-extractor.js +59 -50
  85. package/dist/slpk-extractor-cli.js +82 -59
  86. package/package.json +18 -18
  87. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  88. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  89. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  90. package/dist/3d-tiles-converter/helpers/load-i3s.js.map +0 -1
  91. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  92. package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  93. package/dist/constants.js.map +0 -1
  94. package/dist/converter-cli.js.map +0 -1
  95. package/dist/deps-installer/deps-installer.js.map +0 -1
  96. package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +0 -1
  97. package/dist/i3s-converter/helpers/batch-ids-extensions.js.map +0 -1
  98. package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  99. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  100. package/dist/i3s-converter/helpers/feature-attributes.js.map +0 -1
  101. package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  102. package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
  103. package/dist/i3s-converter/helpers/gltf-attributes.js.map +0 -1
  104. package/dist/i3s-converter/helpers/load-3d-tiles.js.map +0 -1
  105. package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
  106. package/dist/i3s-converter/helpers/node-index-document.js.map +0 -1
  107. package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
  108. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js.map +0 -1
  109. package/dist/i3s-converter/helpers/progress.js.map +0 -1
  110. package/dist/i3s-converter/helpers/tileset-traversal.js.map +0 -1
  111. package/dist/i3s-converter/i3s-converter.js.map +0 -1
  112. package/dist/i3s-converter/json-templates/geometry-definitions.js.map +0 -1
  113. package/dist/i3s-converter/json-templates/layers.js.map +0 -1
  114. package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
  115. package/dist/i3s-converter/json-templates/node.js.map +0 -1
  116. package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
  117. package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
  118. package/dist/i3s-converter/json-templates/store.js.map +0 -1
  119. package/dist/i3s-converter/types.js.map +0 -1
  120. package/dist/i3s-server/README.md +0 -63
  121. package/dist/i3s-server/app.js.map +0 -1
  122. package/dist/i3s-server/bin/www.js.map +0 -1
  123. package/dist/i3s-server/certs/cert.pem +0 -19
  124. package/dist/i3s-server/certs/key.pem +0 -27
  125. package/dist/i3s-server/controllers/index-controller.js.map +0 -1
  126. package/dist/i3s-server/controllers/slpk-controller.js.map +0 -1
  127. package/dist/i3s-server/routes/index.js.map +0 -1
  128. package/dist/i3s-server/routes/slpk-router.js.map +0 -1
  129. package/dist/i3s-server/utils/create-scene-server.js.map +0 -1
  130. package/dist/i3s-server/utils/server-utils.js.map +0 -1
  131. package/dist/index.js.map +0 -1
  132. package/dist/lib/json-schemas/conversion-dump-json-schema.js.map +0 -1
  133. package/dist/lib/utils/cli-utils.js.map +0 -1
  134. package/dist/lib/utils/compress-util.js.map +0 -1
  135. package/dist/lib/utils/conversion-dump.js.map +0 -1
  136. package/dist/lib/utils/file-utils.js.map +0 -1
  137. package/dist/lib/utils/geometry-utils.js.map +0 -1
  138. package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
  139. package/dist/lib/utils/queue.js.map +0 -1
  140. package/dist/lib/utils/statistic-utills.js.map +0 -1
  141. package/dist/lib/utils/write-queue.js.map +0 -1
  142. package/dist/pgm-loader.js.map +0 -1
  143. package/dist/slpk-extractor/slpk-extractor.js.map +0 -1
  144. package/dist/slpk-extractor-cli.js.map +0 -1
@@ -3,197 +3,268 @@ import transform from 'json-map-transform';
3
3
  import { v4 as uuidv4 } from 'uuid';
4
4
  import { openJson, writeFile, writeFileForSlpk } from "../../lib/utils/file-utils.js";
5
5
  import { NODE as nodeTemplate } from "../json-templates/node.js";
6
+ /**
7
+ * Wrapper for https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md data
8
+ * The class allows working with 3DNodeIndexDocument in 2 modes:
9
+ * in memory: the data is stored in `data` field
10
+ * on disk: the data is written on disk in a file. The file can be rewritten when new childrend or neighbors have to be added
11
+ */
6
12
  export class NodeIndexDocument {
7
- get finalized() {
8
- return this._finalized;
9
- }
10
- constructor(id, converter) {
11
- this.id = void 0;
12
- this.inPageId = void 0;
13
- this.data = null;
14
- this.children = [];
15
- this.converter = void 0;
16
- this._finalized = false;
17
- this.inPageId = id;
18
- this.id = id === 0 ? 'root' : id.toString();
19
- this.converter = converter;
20
- }
21
- async addData(data) {
22
- if (this.converter.options.instantNodeWriting) {
23
- await this.write(data);
24
- } else {
25
- this.data = data;
13
+ get finalized() {
14
+ return this._finalized;
26
15
  }
27
- return this;
28
- }
29
- async addChildren(childNodes) {
30
- const newChildren = [];
31
- for (const node of childNodes) {
32
- const nodeData = await node.load();
33
- newChildren.push({
34
- id: node.id,
35
- href: `../${node.id}`,
36
- obb: nodeData.obb,
37
- mbs: nodeData.mbs
38
- });
16
+ /**
17
+ * Constructor
18
+ * @param id - id of the node in node pages
19
+ * @param converter - converter instance
20
+ */
21
+ constructor(id, converter) {
22
+ /** 3DNodeIndexDocument data */
23
+ this.data = null;
24
+ /** children */
25
+ this.children = [];
26
+ /**
27
+ * Finalized property. It means that all child nodes are saved and their data
28
+ * is unloaded
29
+ */
30
+ this._finalized = false;
31
+ this.inPageId = id;
32
+ this.id = id === 0 ? 'root' : id.toString();
33
+ this.converter = converter;
39
34
  }
40
- this.children = this.children.concat(childNodes);
41
- let data = this.data;
42
- if (this.converter.options.instantNodeWriting) {
43
- data = await this.load();
35
+ /**
36
+ * Add Node3DIndexDocument data to the node
37
+ * @param data Node3DIndexDocument data
38
+ * @returns this NodeIndexDocument instance (to recurring with constructor)
39
+ */
40
+ async addData(data) {
41
+ if (this.converter.options.instantNodeWriting) {
42
+ await this.write(data);
43
+ }
44
+ else {
45
+ this.data = data;
46
+ }
47
+ return this;
48
+ }
49
+ /**
50
+ * Add child node references
51
+ * @param childNodes - child NodeIndexDocument instances
52
+ */
53
+ async addChildren(childNodes) {
54
+ const newChildren = [];
55
+ for (const node of childNodes) {
56
+ const nodeData = await node.load();
57
+ newChildren.push({
58
+ id: node.id,
59
+ href: `../${node.id}`,
60
+ obb: nodeData.obb,
61
+ mbs: nodeData.mbs
62
+ });
63
+ }
64
+ this.children = this.children.concat(childNodes);
65
+ let data = this.data;
66
+ if (this.converter.options.instantNodeWriting) {
67
+ data = (await this.load());
68
+ }
69
+ if (data) {
70
+ data.children = data.children ?? [];
71
+ data.children = data.children.concat(newChildren);
72
+ }
73
+ if (this.converter.options.instantNodeWriting && data) {
74
+ await this.write(data);
75
+ }
44
76
  }
45
- if (data) {
46
- var _data$children;
47
- data.children = (_data$children = data.children) !== null && _data$children !== void 0 ? _data$children : [];
48
- data.children = data.children.concat(newChildren);
77
+ /**
78
+ * Add neighbors to child nodes of this node
79
+ */
80
+ async addNeighbors() {
81
+ if (this.finalized) {
82
+ return;
83
+ }
84
+ const nodeData = await this.load();
85
+ for (const childNode of this.children) {
86
+ const childNodeData = await childNode.load();
87
+ childNodeData.neighbors = childNodeData.neighbors ?? [];
88
+ // Don't do large amount of "neightbors" to avoid big memory consumption
89
+ if (Number(nodeData?.children?.length) < 1000) {
90
+ for (const neighbor of nodeData.children || []) {
91
+ if (childNode.id === neighbor.id) {
92
+ continue; // eslint-disable-line
93
+ }
94
+ childNodeData.neighbors.push({ ...neighbor });
95
+ }
96
+ }
97
+ else {
98
+ // eslint-disable-next-line no-console, no-undef
99
+ console.warn(`Node ${childNode.id}: neighbors attribute is omited because of large number of neigbors`);
100
+ delete childNodeData.neighbors;
101
+ }
102
+ if (this.converter.options.instantNodeWriting && childNodeData) {
103
+ await childNode.write(childNodeData);
104
+ }
105
+ await childNode.save();
106
+ }
107
+ // The save after adding neighbors is the last one. Finalize the the node
108
+ this.finalize();
49
109
  }
50
- if (this.converter.options.instantNodeWriting && data) {
51
- await this.write(data);
110
+ /** Save 3DNodeIndexDocument in file on disk */
111
+ async save() {
112
+ if (this.data) {
113
+ await this.write(this.data);
114
+ }
52
115
  }
53
- }
54
- async addNeighbors() {
55
- if (this.finalized) {
56
- return;
116
+ /** Finalize the node */
117
+ finalize() {
118
+ this._finalized = true;
119
+ for (const child of this.children) {
120
+ child.flush();
121
+ }
57
122
  }
58
- const nodeData = await this.load();
59
- for (const childNode of this.children) {
60
- var _childNodeData$neighb, _nodeData$children;
61
- const childNodeData = await childNode.load();
62
- childNodeData.neighbors = (_childNodeData$neighb = childNodeData.neighbors) !== null && _childNodeData$neighb !== void 0 ? _childNodeData$neighb : [];
63
- if (Number(nodeData === null || nodeData === void 0 ? void 0 : (_nodeData$children = nodeData.children) === null || _nodeData$children === void 0 ? void 0 : _nodeData$children.length) < 1000) {
64
- for (const neighbor of nodeData.children || []) {
65
- if (childNode.id === neighbor.id) {
66
- continue;
67
- }
68
- childNodeData.neighbors.push({
69
- ...neighbor
70
- });
123
+ /**
124
+ * Write 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md
125
+ * @param node - Node3DIndexDocument object
126
+ */
127
+ async write(node) {
128
+ const path = join(this.converter.layers0Path, 'nodes', this.id);
129
+ if (this.converter.options.slpk) {
130
+ await this.converter.writeQueue.enqueue({
131
+ archiveKey: `nodes/${this.id}/3dNodeIndexDocument.json.gz`,
132
+ writePromise: () => writeFileForSlpk(path, JSON.stringify(node), '3dNodeIndexDocument.json', true, this.converter.compressList)
133
+ }, true);
134
+ }
135
+ else {
136
+ await this.converter.writeQueue.enqueue({ writePromise: () => writeFile(path, JSON.stringify(node)) }, true);
71
137
  }
72
- } else {
73
- console.warn(`Node ${childNode.id}: neighbors attribute is omited because of large number of neigbors`);
74
- delete childNodeData.neighbors;
75
- }
76
- if (this.converter.options.instantNodeWriting && childNodeData) {
77
- await childNode.write(childNodeData);
78
- }
79
- await childNode.save();
80
138
  }
81
- this.finalize();
82
- }
83
- async save() {
84
- if (this.data) {
85
- await this.write(this.data);
139
+ /**
140
+ * Load 3DNodeIndexDocument data from file on disk
141
+ * @returns 3DNodeIndexDocument object
142
+ */
143
+ async load() {
144
+ if (this.data) {
145
+ return this.data;
146
+ }
147
+ const path = this.id;
148
+ const parentNodePath = join(this.converter.layers0Path, 'nodes', path);
149
+ let parentNodeFileName = 'index.json';
150
+ if (this.converter.options.slpk) {
151
+ parentNodeFileName = '3dNodeIndexDocument.json';
152
+ }
153
+ return (await openJson(parentNodePath, parentNodeFileName));
86
154
  }
87
- }
88
- finalize() {
89
- this._finalized = true;
90
- for (const child of this.children) {
91
- child.flush();
155
+ /**
156
+ * Unload the Node data
157
+ */
158
+ flush() {
159
+ this.data = null;
92
160
  }
93
- }
94
- async write(node) {
95
- const path = join(this.converter.layers0Path, 'nodes', this.id);
96
- if (this.converter.options.slpk) {
97
- await this.converter.writeQueue.enqueue({
98
- archiveKey: `nodes/${this.id}/3dNodeIndexDocument.json.gz`,
99
- writePromise: () => writeFileForSlpk(path, JSON.stringify(node), '3dNodeIndexDocument.json', true, this.converter.compressList)
100
- }, true);
101
- } else {
102
- await this.converter.writeQueue.enqueue({
103
- writePromise: () => writeFile(path, JSON.stringify(node))
104
- }, true);
161
+ /**
162
+ * Create root node of the tree
163
+ * @param boundingVolumes - MBS and OOB bounding volumes data
164
+ * @param converter - I3SConverter instance
165
+ * @returns instance of NodeIndexDocument
166
+ */
167
+ static async createRootNode(boundingVolumes, converter) {
168
+ const rootData = NodeIndexDocument.createRootNodeIndexDocument(boundingVolumes);
169
+ const rootNode = await new NodeIndexDocument(0, converter).addData(rootData);
170
+ return rootNode;
105
171
  }
106
- }
107
- async load() {
108
- if (this.data) {
109
- return this.data;
172
+ /**
173
+ * Create NodeIndexDocument instance
174
+ * @param parentNode - parent NodeIndexDocument
175
+ * @param boundingVolumes - MBS and OOB bounding volumes data
176
+ * @param lodSelection - LOD metrics data
177
+ * @param nodeInPage - node data in node pages
178
+ * @param resources - resources extracted from gltf/b3dm file
179
+ * @param converter - I3SConverter instance
180
+ * @returns NodeIndexDocument instance
181
+ */
182
+ static async createNode(parentNode, boundingVolumes, lodSelection, nodeInPage, resources, converter) {
183
+ const data = await NodeIndexDocument.createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources);
184
+ const node = await new NodeIndexDocument(nodeInPage.index, converter).addData(data);
185
+ return node;
110
186
  }
111
- const path = this.id;
112
- const parentNodePath = join(this.converter.layers0Path, 'nodes', path);
113
- let parentNodeFileName = 'index.json';
114
- if (this.converter.options.slpk) {
115
- parentNodeFileName = '3dNodeIndexDocument.json';
187
+ /**
188
+ * Form 3DNodeIndexDocument data for the root node
189
+ * @param boundingVolumes - mbs and obb data about node's bounding volume
190
+ * @return 3DNodeIndexDocument data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md
191
+ */
192
+ static createRootNodeIndexDocument(boundingVolumes) {
193
+ const root0data = {
194
+ version: `{${uuidv4().toUpperCase()}}`,
195
+ id: 'root',
196
+ level: 0,
197
+ lodSelection: [
198
+ {
199
+ metricType: 'maxScreenThresholdSQ',
200
+ maxError: 0
201
+ },
202
+ {
203
+ metricType: 'maxScreenThreshold',
204
+ maxError: 0
205
+ }
206
+ ],
207
+ ...boundingVolumes,
208
+ children: []
209
+ };
210
+ return transform(root0data, nodeTemplate());
116
211
  }
117
- return await openJson(parentNodePath, parentNodeFileName);
118
- }
119
- flush() {
120
- this.data = null;
121
- }
122
- static async createRootNode(boundingVolumes, converter) {
123
- const rootData = NodeIndexDocument.createRootNodeIndexDocument(boundingVolumes);
124
- const rootNode = await new NodeIndexDocument(0, converter).addData(rootData);
125
- return rootNode;
126
- }
127
- static async createNode(parentNode, boundingVolumes, lodSelection, nodeInPage, resources, converter) {
128
- const data = await NodeIndexDocument.createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources);
129
- const node = await new NodeIndexDocument(nodeInPage.index, converter).addData(data);
130
- return node;
131
- }
132
- static createRootNodeIndexDocument(boundingVolumes) {
133
- const root0data = {
134
- version: `{${uuidv4().toUpperCase()}}`,
135
- id: 'root',
136
- level: 0,
137
- lodSelection: [{
138
- metricType: 'maxScreenThresholdSQ',
139
- maxError: 0
140
- }, {
141
- metricType: 'maxScreenThreshold',
142
- maxError: 0
143
- }],
144
- ...boundingVolumes,
145
- children: []
146
- };
147
- return transform(root0data, nodeTemplate());
148
- }
149
- static async createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
150
- const nodeId = nodeInPage.index;
151
- const parentNodeData = await parentNode.load();
152
- const nodeData = {
153
- version: parentNodeData.version,
154
- id: nodeId.toString(),
155
- level: parentNodeData.level + 1,
156
- ...boundingVolumes,
157
- lodSelection,
158
- parentNode: {
159
- id: parentNode.id,
160
- href: `../${parentNode.id}`,
161
- mbs: parentNodeData.mbs,
162
- obb: parentNodeData.obb
163
- },
164
- children: [],
165
- neighbors: []
166
- };
167
- const node = transform(nodeData, nodeTemplate());
168
- if (nodeInPage.mesh) {
169
- var _parentNode$converter, _parentNode$converter2, _parentNode$converter3, _parentNode$converter4;
170
- node.geometryData = [{
171
- href: './geometries/0'
172
- }];
173
- node.sharedResource = {
174
- href: './shared'
175
- };
176
- if ('texture' in resources && resources.texture || 'texelCountHint' in resources && resources.texelCountHint) {
177
- node.textureData = [{
178
- href: './textures/0'
179
- }, {
180
- href: './textures/1'
181
- }];
182
- }
183
- if ('attributes' in resources && resources.attributes && resources.attributes.length && (_parentNode$converter = parentNode.converter.layers0) !== null && _parentNode$converter !== void 0 && (_parentNode$converter2 = _parentNode$converter.attributeStorageInfo) !== null && _parentNode$converter2 !== void 0 && _parentNode$converter2.length || 'attributesCount' in resources && resources.attributesCount && (_parentNode$converter3 = parentNode.converter.layers0) !== null && _parentNode$converter3 !== void 0 && (_parentNode$converter4 = _parentNode$converter3.attributeStorageInfo) !== null && _parentNode$converter4 !== void 0 && _parentNode$converter4.length) {
184
- var _resources$attributes;
185
- const attributesLength = ('attributes' in resources ? (_resources$attributes = resources.attributes) === null || _resources$attributes === void 0 ? void 0 : _resources$attributes.length : resources.attributesCount) || 0;
186
- node.attributeData = [];
187
- const minimumLength = attributesLength < parentNode.converter.layers0.attributeStorageInfo.length ? attributesLength : parentNode.converter.layers0.attributeStorageInfo.length;
188
- for (let index = 0; index < minimumLength; index++) {
189
- const folderName = parentNode.converter.layers0.attributeStorageInfo[index].key;
190
- node.attributeData.push({
191
- href: `./attributes/${folderName}/0`
192
- });
212
+ /**
213
+ * Create a new Node3DIndexDocument
214
+ * @param parentNode - 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object of the parent node
215
+ * @param boundingVolumes - Bounding volumes
216
+ * @param lodSelection - Level of Details (LOD) metrics
217
+ * @param nodeInPage - corresponding node object in a node page
218
+ * @param resources - the node resources data
219
+ * @param resources.texture - texture image
220
+ * @param resources.attributes - feature attributes
221
+ * @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object
222
+ */
223
+ static async createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
224
+ const nodeId = nodeInPage.index;
225
+ const parentNodeData = await parentNode.load();
226
+ const nodeData = {
227
+ version: parentNodeData.version,
228
+ id: nodeId.toString(),
229
+ level: parentNodeData.level + 1,
230
+ ...boundingVolumes,
231
+ lodSelection,
232
+ parentNode: {
233
+ id: parentNode.id,
234
+ href: `../${parentNode.id}`,
235
+ mbs: parentNodeData.mbs,
236
+ obb: parentNodeData.obb
237
+ },
238
+ children: [],
239
+ neighbors: []
240
+ };
241
+ const node = transform(nodeData, nodeTemplate());
242
+ if (nodeInPage.mesh) {
243
+ node.geometryData = [{ href: './geometries/0' }];
244
+ node.sharedResource = { href: './shared' };
245
+ if (('texture' in resources && resources.texture) ||
246
+ ('texelCountHint' in resources && resources.texelCountHint)) {
247
+ node.textureData = [{ href: './textures/0' }, { href: './textures/1' }];
248
+ }
249
+ if (('attributes' in resources &&
250
+ resources.attributes &&
251
+ resources.attributes.length &&
252
+ parentNode.converter.layers0?.attributeStorageInfo?.length) ||
253
+ ('attributesCount' in resources &&
254
+ resources.attributesCount &&
255
+ parentNode.converter.layers0?.attributeStorageInfo?.length)) {
256
+ const attributesLength = ('attributes' in resources ? resources.attributes?.length : resources.attributesCount) ||
257
+ 0;
258
+ node.attributeData = [];
259
+ const minimumLength = attributesLength < parentNode.converter.layers0.attributeStorageInfo.length
260
+ ? attributesLength
261
+ : parentNode.converter.layers0.attributeStorageInfo.length;
262
+ for (let index = 0; index < minimumLength; index++) {
263
+ const folderName = parentNode.converter.layers0.attributeStorageInfo[index].key;
264
+ node.attributeData.push({ href: `./attributes/${folderName}/0` });
265
+ }
266
+ }
193
267
  }
194
- }
268
+ return node;
195
269
  }
196
- return node;
197
- }
198
270
  }
199
- //# sourceMappingURL=node-index-document.js.map
@@ -1,5 +1,5 @@
1
1
  import { NodeInPage } from '@loaders.gl/i3s';
2
- import I3SConverter from '../i3s-converter';
2
+ import I3SConverter from "../i3s-converter.js";
3
3
  /**
4
4
  * class NodePages - wrapper of nodePages array
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"node-pages.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-pages.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAE3C,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,CAAC,GAAG,IAAI,OAAA,KAAK,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IAC/C,SAAS,EAAE,YAAY,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE;QAAC,KAAK,EAAE,UAAU,EAAE,CAAA;KAAC,EAAE,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAK;IAE5B;;;;;OAKG;gBACS,aAAa,KAAA,EAAE,YAAY,KAAA,EAAE,SAAS,EAAE,YAAY;IAWhE;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,OAAA,KAAK,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG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