@loaders.gl/tile-converter 4.1.0 → 4.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.
- package/dist/converter.min.cjs +82 -82
- package/dist/deps-installer/deps-installer.js +1 -1
- package/dist/deps-installer/deps-installer.js.map +1 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +10 -0
- package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/attribute-metadata-info.js +5 -0
- package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.d.ts +2 -1
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.js +6 -8
- package/dist/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +18 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +121 -24
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/index.cjs +283 -56
- package/dist/lib/utils/conversion-dump.d.ts +55 -5
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
- package/dist/lib/utils/conversion-dump.js +77 -17
- package/dist/lib/utils/conversion-dump.js.map +1 -1
- package/dist/pgm-loader.js +1 -1
- package/dist/pgm-loader.js.map +1 -1
- package/package.json +14 -14
- package/src/i3s-converter/helpers/attribute-metadata-info.ts +16 -0
- package/src/i3s-converter/helpers/node-index-document.ts +18 -8
- package/src/i3s-converter/i3s-converter.ts +198 -41
- package/src/lib/utils/conversion-dump.ts +143 -21
|
@@ -1,13 +1,18 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'util';
|
|
1
2
|
import { DUMP_FILE_SUFFIX } from "../../constants.js";
|
|
2
|
-
import { removeFile, writeFile } from "./file-utils.js";
|
|
3
|
+
import { isFileExists, openJson, removeFile, writeFile } from "./file-utils.js";
|
|
3
4
|
import { join } from 'path';
|
|
4
5
|
export class ConversionDump {
|
|
5
6
|
constructor() {
|
|
7
|
+
this.restored = false;
|
|
6
8
|
this.options = void 0;
|
|
7
9
|
this.tilesConverted = void 0;
|
|
10
|
+
this.textureSetDefinitions = void 0;
|
|
11
|
+
this.attributeMetadataInfo = void 0;
|
|
12
|
+
this.materialDefinitions = [];
|
|
8
13
|
this.tilesConverted = {};
|
|
9
14
|
}
|
|
10
|
-
async
|
|
15
|
+
async createDump(currentOptions) {
|
|
11
16
|
const {
|
|
12
17
|
tilesetName,
|
|
13
18
|
slpk,
|
|
@@ -22,7 +27,7 @@ export class ConversionDump {
|
|
|
22
27
|
mergeMaterials = true,
|
|
23
28
|
metadataClass,
|
|
24
29
|
analyze = false
|
|
25
|
-
} =
|
|
30
|
+
} = currentOptions;
|
|
26
31
|
this.options = {
|
|
27
32
|
tilesetName,
|
|
28
33
|
slpk,
|
|
@@ -38,21 +43,49 @@ export class ConversionDump {
|
|
|
38
43
|
metadataClass,
|
|
39
44
|
analyze
|
|
40
45
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
const dumpFilename = join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
|
|
47
|
+
if (await isFileExists(dumpFilename)) {
|
|
48
|
+
const {
|
|
49
|
+
options,
|
|
50
|
+
tilesConverted,
|
|
51
|
+
textureSetDefinitions,
|
|
52
|
+
attributeMetadataInfo,
|
|
53
|
+
materialDefinitions
|
|
54
|
+
} = await openJson(join(this.options.outputPath, this.options.tilesetName), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
|
|
55
|
+
if (isDeepStrictEqual(options, JSON.parse(JSON.stringify(this.options)))) {
|
|
56
|
+
this.tilesConverted = tilesConverted;
|
|
57
|
+
this.textureSetDefinitions = textureSetDefinitions;
|
|
58
|
+
this.attributeMetadataInfo = attributeMetadataInfo;
|
|
59
|
+
this.materialDefinitions = materialDefinitions;
|
|
60
|
+
this.restored = true;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
await this.deleteDumpFile();
|
|
65
|
+
}
|
|
66
|
+
reset() {
|
|
67
|
+
this.restored = false;
|
|
68
|
+
this.tilesConverted = {};
|
|
69
|
+
if (this.textureSetDefinitions) {
|
|
70
|
+
delete this.textureSetDefinitions;
|
|
71
|
+
}
|
|
72
|
+
if (this.attributeMetadataInfo) {
|
|
73
|
+
delete this.attributeMetadataInfo;
|
|
74
|
+
}
|
|
75
|
+
if (this.materialDefinitions.length > 0) {
|
|
76
|
+
this.materialDefinitions = [];
|
|
47
77
|
}
|
|
48
78
|
}
|
|
49
79
|
async updateDumpFile() {
|
|
50
80
|
var _this$options;
|
|
51
81
|
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.outputPath && this.options.tilesetName) {
|
|
52
82
|
try {
|
|
53
|
-
await writeFile(this.options.outputPath, JSON.stringify({
|
|
83
|
+
await writeFile(join(this.options.outputPath, this.options.tilesetName), JSON.stringify({
|
|
54
84
|
options: this.options,
|
|
55
|
-
tilesConverted: this.tilesConverted
|
|
85
|
+
tilesConverted: this.tilesConverted,
|
|
86
|
+
textureSetDefinitions: this.textureSetDefinitions,
|
|
87
|
+
attributeMetadataInfo: this.attributeMetadataInfo,
|
|
88
|
+
materialDefinitions: this.materialDefinitions
|
|
56
89
|
}), `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`);
|
|
57
90
|
} catch (error) {
|
|
58
91
|
console.log("Can't update dump file", error);
|
|
@@ -61,8 +94,8 @@ export class ConversionDump {
|
|
|
61
94
|
}
|
|
62
95
|
async deleteDumpFile() {
|
|
63
96
|
var _this$options2;
|
|
64
|
-
if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.outputPath && this.options.tilesetName) {
|
|
65
|
-
await removeFile(join(this.options.outputPath, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
|
|
97
|
+
if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.outputPath && this.options.tilesetName && (await isFileExists(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`)))) {
|
|
98
|
+
await removeFile(join(this.options.outputPath, this.options.tilesetName, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`));
|
|
66
99
|
}
|
|
67
100
|
}
|
|
68
101
|
getRecord(fileName) {
|
|
@@ -71,7 +104,7 @@ export class ConversionDump {
|
|
|
71
104
|
setRecord(fileName, object) {
|
|
72
105
|
this.tilesConverted[fileName] = object;
|
|
73
106
|
}
|
|
74
|
-
async addNode(filename, nodeId) {
|
|
107
|
+
async addNode(filename, nodeId, dumpMetadata) {
|
|
75
108
|
const {
|
|
76
109
|
nodes
|
|
77
110
|
} = this.getRecord(filename) || {
|
|
@@ -80,7 +113,8 @@ export class ConversionDump {
|
|
|
80
113
|
nodes.push({
|
|
81
114
|
nodeId,
|
|
82
115
|
done: false,
|
|
83
|
-
progress: {}
|
|
116
|
+
progress: {},
|
|
117
|
+
dumpMetadata
|
|
84
118
|
});
|
|
85
119
|
if (nodes.length === 1) {
|
|
86
120
|
this.setRecord(filename, {
|
|
@@ -89,10 +123,21 @@ export class ConversionDump {
|
|
|
89
123
|
}
|
|
90
124
|
await this.updateDumpFile();
|
|
91
125
|
}
|
|
126
|
+
clearDumpRecord(filename) {
|
|
127
|
+
this.setRecord(filename, {
|
|
128
|
+
nodes: []
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
addTexturesDefinitions(textureDefinitions) {
|
|
132
|
+
this.textureSetDefinitions = textureDefinitions;
|
|
133
|
+
}
|
|
92
134
|
updateDoneStatus(filename, nodeId, resourceType, value) {
|
|
93
135
|
var _this$tilesConverted$;
|
|
94
136
|
const nodeDump = (_this$tilesConverted$ = this.tilesConverted[filename]) === null || _this$tilesConverted$ === void 0 ? void 0 : _this$tilesConverted$.nodes.find(element => element.nodeId === nodeId);
|
|
95
137
|
if (nodeDump) {
|
|
138
|
+
if (!nodeDump.progress) {
|
|
139
|
+
nodeDump.progress = {};
|
|
140
|
+
}
|
|
96
141
|
nodeDump.progress[resourceType] = value;
|
|
97
142
|
if (!value) {
|
|
98
143
|
nodeDump.done = false;
|
|
@@ -109,7 +154,7 @@ export class ConversionDump {
|
|
|
109
154
|
} = changedRecords[i];
|
|
110
155
|
if (!sourceId || !resourceType || !outputId) continue;
|
|
111
156
|
for (const node of this.tilesConverted[sourceId].nodes) {
|
|
112
|
-
if (node.nodeId === outputId) {
|
|
157
|
+
if (node.nodeId === outputId && node.progress) {
|
|
113
158
|
node.progress[resourceType] = true;
|
|
114
159
|
let done = false;
|
|
115
160
|
for (const key in node.progress) {
|
|
@@ -118,7 +163,7 @@ export class ConversionDump {
|
|
|
118
163
|
}
|
|
119
164
|
node.done = done;
|
|
120
165
|
if (node.done) {
|
|
121
|
-
node.progress
|
|
166
|
+
delete node.progress;
|
|
122
167
|
}
|
|
123
168
|
break;
|
|
124
169
|
}
|
|
@@ -127,5 +172,20 @@ export class ConversionDump {
|
|
|
127
172
|
}
|
|
128
173
|
await this.updateDumpFile();
|
|
129
174
|
}
|
|
175
|
+
isFileConversionComplete(filename) {
|
|
176
|
+
var _this$tilesConverted$3, _this$tilesConverted$4;
|
|
177
|
+
let result = true;
|
|
178
|
+
for (const node of ((_this$tilesConverted$2 = this.tilesConverted[filename]) === null || _this$tilesConverted$2 === void 0 ? void 0 : _this$tilesConverted$2.nodes) || []) {
|
|
179
|
+
var _this$tilesConverted$2;
|
|
180
|
+
if (!node.done) {
|
|
181
|
+
result = false;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return result && ((_this$tilesConverted$3 = this.tilesConverted[filename]) === null || _this$tilesConverted$3 === void 0 ? void 0 : (_this$tilesConverted$4 = _this$tilesConverted$3.nodes) === null || _this$tilesConverted$4 === void 0 ? void 0 : _this$tilesConverted$4.length) > 0;
|
|
186
|
+
}
|
|
187
|
+
setMaterialsDefinitions(materialDefinitions) {
|
|
188
|
+
this.materialDefinitions = materialDefinitions;
|
|
189
|
+
}
|
|
130
190
|
}
|
|
131
191
|
//# sourceMappingURL=conversion-dump.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion-dump.js","names":["DUMP_FILE_SUFFIX","removeFile","writeFile","join","ConversionDump","constructor","options","tilesConverted","createDumpFile","tilesetName","slpk","egmFilePath","inputUrl","outputPath","draco","maxDepth","token","generateTextures","generateBoundingVolumes","mergeMaterials","metadataClass","analyze","JSON","stringify","error","console","log","updateDumpFile","_this$options","deleteDumpFile","_this$options2","getRecord","fileName","setRecord","object","addNode","filename","nodeId","nodes","push","done","progress","length","updateDoneStatus","resourceType","value","_this$tilesConverted$","nodeDump","find","element","updateConvertedTilesDump","changedRecords","writeResults","i","sourceId","outputId","node","key"],"sources":["../../../src/lib/utils/conversion-dump.ts"],"sourcesContent":["import {DUMP_FILE_SUFFIX} from '../../constants';\nimport {removeFile, writeFile} from './file-utils';\nimport {join} from 'path';\n\nexport type ConversionDumpOptions = {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n maxDepth: number;\n slpk: boolean;\n egmFilePath: string;\n token: string;\n draco: boolean;\n mergeMaterials: boolean;\n generateTextures: boolean;\n generateBoundingVolumes: boolean;\n metadataClass: string;\n analyze: boolean;\n};\n\ntype NodeDoneStatus = {\n nodeId: number;\n done: boolean;\n progress: Record<string, boolean>;\n};\n\ntype TilesConverted = {\n nodes: NodeDoneStatus[];\n};\n\nexport class ConversionDump {\n /** Conversion options */\n private options?: ConversionDumpOptions;\n /** Tiles conversion progress status map */\n tilesConverted: Record<string, TilesConverted>;\n\n constructor() {\n this.tilesConverted = {};\n }\n\n /**\n * Create a dump file with convertion options\n * @param options - converter options\n */\n async createDumpFile(options: ConversionDumpOptions): Promise<void> {\n const {\n tilesetName,\n slpk,\n egmFilePath,\n inputUrl,\n outputPath,\n draco = true,\n maxDepth,\n token,\n generateTextures,\n generateBoundingVolumes,\n mergeMaterials = true,\n metadataClass,\n analyze = false\n } = options;\n this.options = {\n tilesetName,\n slpk,\n egmFilePath,\n inputUrl,\n outputPath,\n draco,\n maxDepth,\n token,\n generateTextures,\n generateBoundingVolumes,\n mergeMaterials,\n metadataClass,\n analyze\n };\n\n try {\n await writeFile(\n options.outputPath,\n JSON.stringify({options: this.options}),\n `${options.tilesetName}${DUMP_FILE_SUFFIX}`\n );\n } catch (error) {\n console.log(\"Can't create dump file\", error);\n }\n }\n\n /**\n * Update conversion status in the dump file\n */\n private async updateDumpFile(): Promise<void> {\n if (this.options?.outputPath && this.options.tilesetName) {\n try {\n await writeFile(\n this.options.outputPath,\n JSON.stringify({\n options: this.options,\n tilesConverted: this.tilesConverted\n }),\n `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`\n );\n } catch (error) {\n console.log(\"Can't update dump file\", error);\n }\n }\n }\n\n /**\n * Delete a dump file\n */\n async deleteDumpFile(): Promise<void> {\n if (this.options?.outputPath && this.options.tilesetName) {\n await removeFile(\n join(this.options.outputPath, `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`)\n );\n }\n }\n\n /**\n * Get record from the tilesConverted Map\n * @param fileName - source filename\n * @returns existing object from the tilesConverted Map\n */\n private getRecord(fileName: string) {\n return this.tilesConverted[fileName];\n }\n\n /**\n * Set a record for the dump file\n * @param fileName - key - source filename\n * @param object - value\n */\n private setRecord(fileName: string, object: any) {\n this.tilesConverted[fileName] = object;\n }\n\n /**\n * Add a node into the dump file for the source file record\n * @param fileName - source filename\n * @param nodeId - nodeId of the node\n */\n async addNode(filename: string, nodeId: number) {\n const {nodes} = this.getRecord(filename) || {nodes: []};\n nodes.push({nodeId, done: false, progress: {}});\n if (nodes.length === 1) {\n this.setRecord(filename, {nodes});\n }\n await this.updateDumpFile();\n }\n\n /**\n * Update done status object for the writing resources\n * @param fileName - key - source filename\n * @param nodeId - nodeId for the source filename\n * @param resourceType - resource type to update status\n * @param value - value\n */\n updateDoneStatus(filename: string, nodeId: number, resourceType: string, value: boolean) {\n const nodeDump = this.tilesConverted[filename]?.nodes.find(\n (element) => element.nodeId === nodeId\n );\n if (nodeDump) {\n nodeDump.progress[resourceType] = value;\n if (!value) {\n nodeDump.done = false;\n }\n }\n }\n\n /**\n * Update dump file according to writing results\n * @param changedRecords - array of parameters ids for the written resources\n * @param writeResults - array of writing resource files results\n */\n async updateConvertedTilesDump(\n changedRecords: {outputId?: number; sourceId?: string; resourceType?: string}[],\n writeResults: PromiseSettledResult<string | null>[]\n ) {\n for (let i = 0; i < changedRecords.length; i++) {\n if (changedRecords[i] && 'value' in writeResults[i]) {\n const {sourceId, resourceType, outputId} = changedRecords[i];\n if (!sourceId || !resourceType || !outputId) continue;\n for (const node of this.tilesConverted[sourceId].nodes) {\n if (node.nodeId === outputId) {\n node.progress[resourceType] = true;\n\n let done = false;\n for (const key in node.progress) {\n done = node.progress[key];\n if (!done) break;\n }\n node.done = done;\n if (node.done) {\n node.progress = {};\n }\n break;\n }\n }\n }\n }\n await this.updateDumpFile();\n }\n}\n"],"mappings":"SAAQA,gBAAgB;AAAA,SAChBC,UAAU,EAAEC,SAAS;AAC7B,SAAQC,IAAI,QAAO,MAAM;AA4BzB,OAAO,MAAMC,cAAc,CAAC;EAM1BC,WAAWA,CAAA,EAAG;IAAA,KAJNC,OAAO;IAAA,KAEfC,cAAc;IAGZ,IAAI,CAACA,cAAc,GAAG,CAAC,CAAC;EAC1B;EAMA,MAAMC,cAAcA,CAACF,OAA8B,EAAiB;IAClE,MAAM;MACJG,WAAW;MACXC,IAAI;MACJC,WAAW;MACXC,QAAQ;MACRC,UAAU;MACVC,KAAK,GAAG,IAAI;MACZC,QAAQ;MACRC,KAAK;MACLC,gBAAgB;MAChBC,uBAAuB;MACvBC,cAAc,GAAG,IAAI;MACrBC,aAAa;MACbC,OAAO,GAAG;IACZ,CAAC,GAAGf,OAAO;IACX,IAAI,CAAC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MACvB;IACF;EACF;EAOA,MAAMU,wBAAwBA,CAC5BC,cAA+E,EAC/EC,YAAmD,EACnD;IACA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,cAAc,CAACT,MAAM,EAAEW,CAAC,EAAE,EAAE;MAC9C,IAAIF,cAAc,CAACE,CAAC,CAAC,IAAI,OAAO,IAAID,YAAY,CAACC,CAAC,CAAC,EAAE;QACnD,MAAM;UAACC,QAAQ;UAAEV,YAAY;UAAEW;QAAQ,CAAC,GAAGJ,cAAc,CAACE,CAAC,CAAC;QAC5D,IAAI,CAACC,QAAQ,IAAI,CAACV,YAAY,IAAI,CAACW,QAAQ,EAAE;QAC7C,KAAK,MAAMC,IAAI,IAAI,IAAI,CAACjD,cAAc,CAAC+C,QAAQ,CAAC,CAAChB,KAAK,EAAE;UACtD,IAAIkB,IAAI,CAACnB,MAAM,KAAKkB,QAAQ,EAAE;YAC5BC,IAAI,CAACf,QAAQ,CAACG,YAAY,CAAC,GAAG,IAAI;YAElC,IAAIJ,IAAI,GAAG,KAAK;YAChB,KAAK,MAAMiB,GAAG,IAAID,IAAI,CAACf,QAAQ,EAAE;cAC/BD,IAAI,GAAGgB,IAAI,CAACf,QAAQ,CAACgB,GAAG,CAAC;cACzB,IAAI,CAACjB,IAAI,EAAE;YACb;YACAgB,IAAI,CAAChB,IAAI,GAAGA,IAAI;YAChB,IAAIgB,IAAI,CAAChB,IAAI,EAAE;cACbgB,IAAI,CAACf,QAAQ,GAAG,CAAC,CAAC;YACpB;YACA;UACF;QACF;MACF;IACF;IACA,MAAM,IAAI,CAACd,cAAc,CAAC,CAAC;EAC7B;AACF"}
|
|
1
|
+
{"version":3,"file":"conversion-dump.js","names":["isDeepStrictEqual","DUMP_FILE_SUFFIX","isFileExists","openJson","removeFile","writeFile","join","ConversionDump","constructor","restored","options","tilesConverted","textureSetDefinitions","attributeMetadataInfo","materialDefinitions","createDump","currentOptions","tilesetName","slpk","egmFilePath","inputUrl","outputPath","draco","maxDepth","token","generateTextures","generateBoundingVolumes","mergeMaterials","metadataClass","analyze","dumpFilename","JSON","parse","stringify","deleteDumpFile","reset","length","updateDumpFile","_this$options","error","console","log","_this$options2","getRecord","fileName","setRecord","object","addNode","filename","nodeId","dumpMetadata","nodes","push","done","progress","clearDumpRecord","addTexturesDefinitions","textureDefinitions","updateDoneStatus","resourceType","value","_this$tilesConverted$","nodeDump","find","element","updateConvertedTilesDump","changedRecords","writeResults","i","sourceId","outputId","node","key","isFileConversionComplete","_this$tilesConverted$3","_this$tilesConverted$4","result","_this$tilesConverted$2","setMaterialsDefinitions"],"sources":["../../../src/lib/utils/conversion-dump.ts"],"sourcesContent":["import {isDeepStrictEqual} from 'util';\nimport {DUMP_FILE_SUFFIX} from '../../constants';\nimport {isFileExists, openJson, removeFile, writeFile} from './file-utils';\nimport {join} from 'path';\nimport {BoundingVolumes, I3SMaterialDefinition, TextureSetDefinitionFormats} from '@loaders.gl/i3s';\nimport {AttributeMetadataInfoObject} from '../../i3s-converter/helpers/attribute-metadata-info';\n\nexport type ConversionDumpOptions = {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n maxDepth: number;\n slpk: boolean;\n egmFilePath: string;\n token: string;\n draco: boolean;\n mergeMaterials: boolean;\n generateTextures: boolean;\n generateBoundingVolumes: boolean;\n metadataClass: string;\n analyze: boolean;\n};\n\ntype NodeDoneStatus = {\n nodeId: number;\n done: boolean;\n progress?: Record<string, boolean>;\n dumpMetadata?: DumpMetadata;\n};\n\ntype TilesConverted = {\n nodes: NodeDoneStatus[];\n};\n\nexport type DumpMetadata = {\n boundingVolumes: BoundingVolumes | null;\n attributesCount?: number;\n featureCount: number | null;\n geometry: boolean;\n hasUvRegions: boolean;\n materialId: number | null;\n texelCountHint?: number;\n vertexCount: number | null;\n};\n\nexport type TextureSetDefinition = {\n formats: TextureSetDefinitionFormats;\n atlas?: boolean;\n};\n\nexport class ConversionDump {\n /**Restored/resumed dump indicator */\n restored: boolean = false;\n /** Conversion options */\n private options?: ConversionDumpOptions;\n /** Tiles conversion progress status map */\n tilesConverted: Record<string, TilesConverted>;\n /** Textures formats definitions */\n textureSetDefinitions?: TextureSetDefinition[];\n /** Attributes Metadata */\n attributeMetadataInfo?: AttributeMetadataInfoObject;\n /** Array of materials definitions */\n materialDefinitions: I3SMaterialDefinition[] = [];\n\n constructor() {\n this.tilesConverted = {};\n }\n\n /**\n * Create a dump with convertion options\n * @param currentOptions - converter options\n */\n async createDump(currentOptions: ConversionDumpOptions): Promise<void> {\n const {\n tilesetName,\n slpk,\n egmFilePath,\n inputUrl,\n outputPath,\n draco = true,\n maxDepth,\n token,\n generateTextures,\n generateBoundingVolumes,\n mergeMaterials = true,\n metadataClass,\n analyze = false\n } = currentOptions;\n this.options = {\n tilesetName,\n slpk,\n egmFilePath,\n inputUrl,\n outputPath,\n draco,\n maxDepth,\n token,\n generateTextures,\n generateBoundingVolumes,\n mergeMaterials,\n metadataClass,\n analyze\n };\n\n const dumpFilename = join(\n this.options.outputPath,\n this.options.tilesetName,\n `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`\n );\n if (await isFileExists(dumpFilename)) {\n const {\n options,\n tilesConverted,\n textureSetDefinitions,\n attributeMetadataInfo,\n materialDefinitions\n } = await openJson(\n join(this.options.outputPath, this.options.tilesetName),\n `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`\n );\n if (isDeepStrictEqual(options, JSON.parse(JSON.stringify(this.options)))) {\n this.tilesConverted = tilesConverted;\n this.textureSetDefinitions = textureSetDefinitions;\n this.attributeMetadataInfo = attributeMetadataInfo;\n this.materialDefinitions = materialDefinitions;\n this.restored = true;\n return;\n }\n }\n await this.deleteDumpFile();\n }\n\n /**\n * Reset a dump\n */\n reset(): void {\n this.restored = false;\n this.tilesConverted = {};\n if (this.textureSetDefinitions) {\n delete this.textureSetDefinitions;\n }\n if (this.attributeMetadataInfo) {\n delete this.attributeMetadataInfo;\n }\n if (this.materialDefinitions.length > 0) {\n this.materialDefinitions = [];\n }\n }\n\n /**\n * Update conversion status in the dump file\n */\n private async updateDumpFile(): Promise<void> {\n if (this.options?.outputPath && this.options.tilesetName) {\n try {\n await writeFile(\n join(this.options.outputPath, this.options.tilesetName),\n JSON.stringify({\n options: this.options,\n tilesConverted: this.tilesConverted,\n textureSetDefinitions: this.textureSetDefinitions,\n attributeMetadataInfo: this.attributeMetadataInfo,\n materialDefinitions: this.materialDefinitions\n }),\n `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`\n );\n } catch (error) {\n console.log(\"Can't update dump file\", error);\n }\n }\n }\n\n /**\n * Delete a dump file\n */\n async deleteDumpFile(): Promise<void> {\n if (\n this.options?.outputPath &&\n this.options.tilesetName &&\n (await isFileExists(\n join(\n this.options.outputPath,\n this.options.tilesetName,\n `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`\n )\n ))\n ) {\n await removeFile(\n join(\n this.options.outputPath,\n this.options.tilesetName,\n `${this.options.tilesetName}${DUMP_FILE_SUFFIX}`\n )\n );\n }\n }\n\n /**\n * Get record from the tilesConverted Map\n * @param fileName - source filename\n * @returns existing object from the tilesConverted Map\n */\n private getRecord(fileName: string) {\n return this.tilesConverted[fileName];\n }\n\n /**\n * Set a record for the dump file\n * @param fileName - key - source filename\n * @param object - value\n */\n private setRecord(fileName: string, object: any) {\n this.tilesConverted[fileName] = object;\n }\n\n /**\n * Add a node into the dump file for the source file record\n * @param fileName - source filename\n * @param nodeId - nodeId of the node\n */\n async addNode(filename: string, nodeId: number, dumpMetadata: DumpMetadata) {\n const {nodes} = this.getRecord(filename) || {nodes: []};\n nodes.push({nodeId, done: false, progress: {}, dumpMetadata});\n if (nodes.length === 1) {\n this.setRecord(filename, {nodes});\n }\n await this.updateDumpFile();\n }\n\n /**\n * Clear dump record got the source filename\n * @param fileName - source filename\n */\n clearDumpRecord(filename: string) {\n this.setRecord(filename, {nodes: []});\n }\n\n /**\n * Add textures definitions into the dump file\n * @param textureDefinitions - textures definitions array\n */\n addTexturesDefinitions(textureDefinitions: TextureSetDefinition[]) {\n this.textureSetDefinitions = textureDefinitions;\n }\n\n /**\n * Update done status object for the writing resources\n * @param fileName - key - source filename\n * @param nodeId - nodeId for the source filename\n * @param resourceType - resource type to update status\n * @param value - value\n */\n updateDoneStatus(filename: string, nodeId: number, resourceType: string, value: boolean) {\n const nodeDump = this.tilesConverted[filename]?.nodes.find(\n (element) => element.nodeId === nodeId\n );\n if (nodeDump) {\n if (!nodeDump.progress) {\n nodeDump.progress = {};\n }\n nodeDump.progress[resourceType] = value;\n if (!value) {\n nodeDump.done = false;\n }\n }\n }\n\n /**\n * Update dump file according to writing results\n * @param changedRecords - array of parameters ids for the written resources\n * @param writeResults - array of writing resource files results\n */\n async updateConvertedTilesDump(\n changedRecords: {outputId?: number; sourceId?: string; resourceType?: string}[],\n writeResults: PromiseSettledResult<string | null>[]\n ) {\n for (let i = 0; i < changedRecords.length; i++) {\n if (changedRecords[i] && 'value' in writeResults[i]) {\n const {sourceId, resourceType, outputId} = changedRecords[i];\n if (!sourceId || !resourceType || !outputId) continue;\n for (const node of this.tilesConverted[sourceId].nodes) {\n if (node.nodeId === outputId && node.progress) {\n node.progress[resourceType] = true;\n\n let done = false;\n for (const key in node.progress) {\n done = node.progress[key];\n if (!done) break;\n }\n node.done = done;\n if (node.done) {\n delete node.progress;\n }\n break;\n }\n }\n }\n }\n await this.updateDumpFile();\n }\n\n /**\n * Check is source file conversion complete\n * @param filename - source filename\n * @returns true if source file conversion complete\n */\n isFileConversionComplete(filename: string): boolean {\n let result = true;\n for (const node of this.tilesConverted[filename]?.nodes || []) {\n if (!node.done) {\n result = false;\n break;\n }\n }\n return result && this.tilesConverted[filename]?.nodes?.length > 0;\n }\n\n /**\n * Set materialDefinitions into a dump\n * @param materialDefinitions - Array materialDefinitions\n */\n setMaterialsDefinitions(materialDefinitions: I3SMaterialDefinition[]): void {\n this.materialDefinitions = materialDefinitions;\n }\n}\n"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,MAAM;AAAC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AC7D,IAAI,CAACN,IAAI,CAAClB,IAAI,EAAE;QACduB,MAAM,GAAG,KAAK;QACd;MACF;IACF;IACA,OAAOA,MAAM,IAAI,EAAAF,sBAAA,OAAI,CAAC/D,cAAc,CAACqC,QAAQ,CAAC,cAAA0B,sBAAA,wBAAAC,sBAAA,GAA7BD,sBAAA,CAA+BvB,KAAK,cAAAwB,sBAAA,uBAApCA,sBAAA,CAAsCvC,MAAM,IAAG,CAAC;EACnE;EAMA0C,uBAAuBA,CAAChE,mBAA4C,EAAQ;IAC1E,IAAI,CAACA,mBAAmB,GAAGA,mBAAmB;EAChD;AACF"}
|
package/dist/pgm-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Geoid, parsePGM } from '@math.gl/geoid';
|
|
2
|
-
const VERSION = typeof "4.
|
|
2
|
+
const VERSION = typeof "4.2.0-alpha.1" !== 'undefined' ? "4.2.0-alpha.1" : 'latest';
|
|
3
3
|
export { Geoid };
|
|
4
4
|
export const PGMLoader = {
|
|
5
5
|
name: 'PGM - Netpbm grayscale image format',
|
package/dist/pgm-loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pgm-loader.js","names":["Geoid","parsePGM","VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","pgm","extensions","cubic"],"sources":["../src/pgm-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {Geoid, parsePGM} from '@math.gl/geoid';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport {Geoid};\n\nexport type PGMLoaderOptions = LoaderOptions & {\n pgm?: {\n cubic?: boolean;\n };\n};\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser<Geoid, never, PGMLoaderOptions> = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options?.pgm || {}),\n extensions: ['pgm'],\n options: {\n pgm: {\n cubic: false\n }\n }\n};\n"],"mappings":"AACA,SAAQA,KAAK,EAAEC,QAAQ,QAAO,gBAAgB;AAI9C,MAAMC,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"pgm-loader.js","names":["Geoid","parsePGM","VERSION","PGMLoader","name","id","module","version","mimeTypes","parse","arrayBuffer","options","Uint8Array","pgm","extensions","cubic"],"sources":["../src/pgm-loader.ts"],"sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {Geoid, parsePGM} from '@math.gl/geoid';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport {Geoid};\n\nexport type PGMLoaderOptions = LoaderOptions & {\n pgm?: {\n cubic?: boolean;\n };\n};\n\n/**\n * Loader for PGM - Netpbm grayscale image format\n */\nexport const PGMLoader: LoaderWithParser<Geoid, never, PGMLoaderOptions> = {\n name: 'PGM - Netpbm grayscale image format',\n id: 'pgm',\n module: 'tile-converter',\n version: VERSION,\n mimeTypes: ['image/x-portable-graymap'],\n parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options?.pgm || {}),\n extensions: ['pgm'],\n options: {\n pgm: {\n cubic: false\n }\n }\n};\n"],"mappings":"AACA,SAAQA,KAAK,EAAEC,QAAQ,QAAO,gBAAgB;AAI9C,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAE3E,SAAQF,KAAK;AAWb,OAAO,MAAMG,SAA2D,GAAG;EACzEC,IAAI,EAAE,qCAAqC;EAC3CC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,gBAAgB;EACxBC,OAAO,EAAEL,OAAO;EAChBM,SAAS,EAAE,CAAC,0BAA0B,CAAC;EACvCC,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEC,OAAO,KAAKV,QAAQ,CAAC,IAAIW,UAAU,CAACF,WAAW,CAAC,EAAE,CAAAC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,GAAG,KAAI,CAAC,CAAC,CAAC;EAChGC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBH,OAAO,EAAE;IACPE,GAAG,EAAE;MACHE,KAAK,EAAE;IACT;EACF;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0-alpha.1",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
"build-i3s-server-bundle": "esbuild src/i3s-server/bin/www.ts --outfile=dist/i3s-server/bin/i3s-server.min.cjs --platform=node --target=esnext,node14 --minify --bundle --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@loaders.gl/3d-tiles": "4.
|
|
56
|
-
"@loaders.gl/crypto": "4.
|
|
57
|
-
"@loaders.gl/draco": "4.
|
|
58
|
-
"@loaders.gl/gltf": "4.
|
|
59
|
-
"@loaders.gl/i3s": "4.
|
|
60
|
-
"@loaders.gl/images": "4.
|
|
61
|
-
"@loaders.gl/loader-utils": "4.
|
|
62
|
-
"@loaders.gl/polyfills": "4.
|
|
63
|
-
"@loaders.gl/textures": "4.
|
|
64
|
-
"@loaders.gl/tiles": "4.
|
|
65
|
-
"@loaders.gl/worker-utils": "4.
|
|
66
|
-
"@loaders.gl/zip": "4.
|
|
55
|
+
"@loaders.gl/3d-tiles": "4.2.0-alpha.1",
|
|
56
|
+
"@loaders.gl/crypto": "4.2.0-alpha.1",
|
|
57
|
+
"@loaders.gl/draco": "4.2.0-alpha.1",
|
|
58
|
+
"@loaders.gl/gltf": "4.2.0-alpha.1",
|
|
59
|
+
"@loaders.gl/i3s": "4.2.0-alpha.1",
|
|
60
|
+
"@loaders.gl/images": "4.2.0-alpha.1",
|
|
61
|
+
"@loaders.gl/loader-utils": "4.2.0-alpha.1",
|
|
62
|
+
"@loaders.gl/polyfills": "4.2.0-alpha.1",
|
|
63
|
+
"@loaders.gl/textures": "4.2.0-alpha.1",
|
|
64
|
+
"@loaders.gl/tiles": "4.2.0-alpha.1",
|
|
65
|
+
"@loaders.gl/worker-utils": "4.2.0-alpha.1",
|
|
66
|
+
"@loaders.gl/zip": "4.2.0-alpha.1",
|
|
67
67
|
"@math.gl/core": "^4.0.0",
|
|
68
68
|
"@math.gl/culling": "^4.0.0",
|
|
69
69
|
"@math.gl/geoid": "^4.0.0",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"join-images": "^1.1.3",
|
|
88
88
|
"sharp": "^0.31.3"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "d4da81f4d8fb2a3b43b0e025109cf7ccfb317d4c",
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@types/express": "^4.17.17",
|
|
93
93
|
"@types/node": "^20.4.2"
|
|
@@ -9,6 +9,12 @@ import type {
|
|
|
9
9
|
|
|
10
10
|
import {AttributeType} from '../types';
|
|
11
11
|
|
|
12
|
+
export type AttributeMetadataInfoObject = {
|
|
13
|
+
attributeStorageInfo: AttributeStorageInfo[];
|
|
14
|
+
fields: Field[];
|
|
15
|
+
popupInfo: PopupInfo | undefined;
|
|
16
|
+
};
|
|
17
|
+
|
|
12
18
|
export class AttributeMetadataInfo {
|
|
13
19
|
private _attributeStorageInfo: AttributeStorageInfo[];
|
|
14
20
|
private _fields: Field[];
|
|
@@ -95,6 +101,16 @@ export class AttributeMetadataInfo {
|
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Set AttributeMetadataInfo from object
|
|
106
|
+
* @param object - object with AttributeMetadataInfo props
|
|
107
|
+
*/
|
|
108
|
+
fromObject(object: AttributeMetadataInfoObject) {
|
|
109
|
+
this._attributeStorageInfo = object.attributeStorageInfo;
|
|
110
|
+
this._fields = object.fields;
|
|
111
|
+
this._popupInfo = object.popupInfo;
|
|
112
|
+
}
|
|
113
|
+
|
|
98
114
|
/**
|
|
99
115
|
* Generates storage attribute for map segmentation.
|
|
100
116
|
* @param attributeIndex - order index of attribute (f_0, f_1 ...).
|
|
@@ -12,6 +12,7 @@ import {openJson, writeFile, writeFileForSlpk} from '../../lib/utils/file-utils'
|
|
|
12
12
|
import I3SConverter from '../i3s-converter';
|
|
13
13
|
import {NODE as nodeTemplate} from '../json-templates/node';
|
|
14
14
|
import {I3SConvertedResources} from '../types';
|
|
15
|
+
import {DumpMetadata} from '../../lib/utils/conversion-dump';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Wrapper for https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md data
|
|
@@ -287,9 +288,8 @@ export class NodeIndexDocument {
|
|
|
287
288
|
boundingVolumes: BoundingVolumes,
|
|
288
289
|
lodSelection: LodSelection[],
|
|
289
290
|
nodeInPage: NodeInPage,
|
|
290
|
-
resources: I3SConvertedResources
|
|
291
|
+
resources: I3SConvertedResources | DumpMetadata
|
|
291
292
|
): Promise<Node3DIndexDocument> {
|
|
292
|
-
const {texture, attributes} = resources;
|
|
293
293
|
const nodeId = nodeInPage.index!;
|
|
294
294
|
const parentNodeData = await parentNode.load();
|
|
295
295
|
const nodeData = {
|
|
@@ -313,19 +313,29 @@ export class NodeIndexDocument {
|
|
|
313
313
|
node.geometryData = [{href: './geometries/0'}];
|
|
314
314
|
node.sharedResource = {href: './shared'};
|
|
315
315
|
|
|
316
|
-
if (
|
|
316
|
+
if (
|
|
317
|
+
('texture' in resources && resources.texture) ||
|
|
318
|
+
('texelCountHint' in resources && resources.texelCountHint)
|
|
319
|
+
) {
|
|
317
320
|
node.textureData = [{href: './textures/0'}, {href: './textures/1'}];
|
|
318
321
|
}
|
|
319
322
|
|
|
320
323
|
if (
|
|
321
|
-
attributes &&
|
|
322
|
-
|
|
323
|
-
|
|
324
|
+
('attributes' in resources &&
|
|
325
|
+
resources.attributes &&
|
|
326
|
+
resources.attributes.length &&
|
|
327
|
+
parentNode.converter.layers0?.attributeStorageInfo?.length) ||
|
|
328
|
+
('attributesCount' in resources &&
|
|
329
|
+
resources.attributesCount &&
|
|
330
|
+
parentNode.converter.layers0?.attributeStorageInfo?.length)
|
|
324
331
|
) {
|
|
332
|
+
const attributesLength =
|
|
333
|
+
('attributes' in resources ? resources.attributes?.length : resources.attributesCount) ||
|
|
334
|
+
0;
|
|
325
335
|
node.attributeData = [];
|
|
326
336
|
const minimumLength =
|
|
327
|
-
|
|
328
|
-
?
|
|
337
|
+
attributesLength < parentNode.converter.layers0.attributeStorageInfo.length
|
|
338
|
+
? attributesLength
|
|
329
339
|
: parentNode.converter.layers0.attributeStorageInfo.length;
|
|
330
340
|
for (let index = 0; index < minimumLength; index++) {
|
|
331
341
|
const folderName = parentNode.converter.layers0.attributeStorageInfo[index].key;
|