@loaders.gl/tile-converter 3.3.0-alpha.8 → 3.3.0

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 (132) hide show
  1. package/dist/3d-tiles-attributes-worker.js +2 -2
  2. package/dist/3d-tiles-attributes-worker.js.map +3 -3
  3. package/dist/converter-cli.js +14 -2
  4. package/dist/converter.min.js +22 -22
  5. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  6. package/dist/deps-installer/deps-installer.js +8 -0
  7. package/dist/dist.min.js +1165 -846
  8. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  9. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  10. package/dist/es5/converter-cli.js +14 -2
  11. package/dist/es5/converter-cli.js.map +1 -1
  12. package/dist/es5/deps-installer/deps-installer.js +13 -2
  13. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  14. package/dist/es5/i3s-attributes-worker.js +1 -1
  15. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  16. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  17. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +16 -7
  18. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  19. package/dist/es5/i3s-converter/helpers/geometry-converter.js +363 -113
  20. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  21. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +6 -11
  22. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/node-index-document.js +517 -0
  24. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -0
  25. package/dist/es5/i3s-converter/helpers/node-pages.js +455 -173
  26. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  27. package/dist/es5/i3s-converter/i3s-converter.js +549 -618
  28. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  29. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +107 -0
  30. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  31. package/dist/es5/i3s-converter/json-templates/layers.js +2 -93
  32. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  33. package/dist/es5/i3s-converter/json-templates/shared-resources.js +3 -3
  34. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
  35. package/dist/es5/i3s-converter/types.js.map +1 -1
  36. package/dist/es5/lib/utils/file-utils.js +93 -9
  37. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  38. package/dist/es5/lib/utils/write-queue.js +38 -25
  39. package/dist/es5/lib/utils/write-queue.js.map +1 -1
  40. package/dist/es5/pgm-loader.js +1 -1
  41. package/dist/es5/pgm-loader.js.map +1 -1
  42. package/dist/es5/workers/i3s-attributes-worker.js +1 -1
  43. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
  44. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  45. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
  46. package/dist/esm/converter-cli.js +14 -2
  47. package/dist/esm/converter-cli.js.map +1 -1
  48. package/dist/esm/deps-installer/deps-installer.js +9 -1
  49. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  50. package/dist/esm/i3s-attributes-worker.js +1 -1
  51. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  52. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  53. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +16 -7
  54. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  55. package/dist/esm/i3s-converter/helpers/geometry-converter.js +150 -40
  56. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  57. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +6 -9
  58. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  59. package/dist/esm/i3s-converter/helpers/node-index-document.js +202 -0
  60. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -0
  61. package/dist/esm/i3s-converter/helpers/node-pages.js +162 -76
  62. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  63. package/dist/esm/i3s-converter/i3s-converter.js +115 -220
  64. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  65. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js +89 -0
  66. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  67. package/dist/esm/i3s-converter/json-templates/layers.js +2 -85
  68. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
  69. package/dist/esm/i3s-converter/json-templates/shared-resources.js +3 -3
  70. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
  71. package/dist/esm/i3s-converter/types.js.map +1 -1
  72. package/dist/esm/lib/utils/file-utils.js +44 -3
  73. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  74. package/dist/esm/lib/utils/write-queue.js +19 -10
  75. package/dist/esm/lib/utils/write-queue.js.map +1 -1
  76. package/dist/esm/pgm-loader.js +1 -1
  77. package/dist/esm/pgm-loader.js.map +1 -1
  78. package/dist/esm/workers/i3s-attributes-worker.js +1 -1
  79. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
  80. package/dist/i3s-attributes-worker.js +2 -2
  81. package/dist/i3s-attributes-worker.js.map +2 -2
  82. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +3 -3
  83. package/dist/i3s-converter/helpers/batch-ids-extensions.js +3 -3
  84. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  85. package/dist/i3s-converter/helpers/geometry-attributes.js +16 -10
  86. package/dist/i3s-converter/helpers/geometry-converter.d.ts +8 -4
  87. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  88. package/dist/i3s-converter/helpers/geometry-converter.js +200 -44
  89. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  90. package/dist/i3s-converter/helpers/gltf-attributes.js +2 -3
  91. package/dist/i3s-converter/helpers/node-index-document.d.ts +95 -0
  92. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -0
  93. package/dist/i3s-converter/helpers/node-index-document.js +250 -0
  94. package/dist/i3s-converter/helpers/node-pages.d.ts +78 -43
  95. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  96. package/dist/i3s-converter/helpers/node-pages.js +195 -94
  97. package/dist/i3s-converter/i3s-converter.d.ts +33 -58
  98. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  99. package/dist/i3s-converter/i3s-converter.js +122 -233
  100. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +7 -0
  101. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +1 -0
  102. package/dist/i3s-converter/json-templates/geometry-definitions.js +87 -0
  103. package/dist/i3s-converter/json-templates/layers.d.ts +1 -30
  104. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
  105. package/dist/i3s-converter/json-templates/layers.js +2 -86
  106. package/dist/i3s-converter/json-templates/shared-resources.js +3 -3
  107. package/dist/i3s-converter/types.d.ts +28 -2
  108. package/dist/i3s-converter/types.d.ts.map +1 -1
  109. package/dist/lib/utils/file-utils.d.ts +17 -1
  110. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  111. package/dist/lib/utils/file-utils.js +64 -7
  112. package/dist/lib/utils/write-queue.d.ts +18 -2
  113. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  114. package/dist/lib/utils/write-queue.js +18 -12
  115. package/dist/workers/i3s-attributes-worker.js +1 -1
  116. package/package.json +25 -20
  117. package/src/converter-cli.ts +22 -2
  118. package/src/deps-installer/deps-installer.ts +9 -0
  119. package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -3
  120. package/src/i3s-converter/helpers/geometry-attributes.ts +16 -11
  121. package/src/i3s-converter/helpers/geometry-converter.ts +217 -48
  122. package/src/i3s-converter/helpers/gltf-attributes.ts +2 -3
  123. package/src/i3s-converter/helpers/node-index-document.ts +315 -0
  124. package/src/i3s-converter/helpers/node-pages.ts +215 -110
  125. package/src/i3s-converter/i3s-converter.ts +170 -312
  126. package/src/i3s-converter/json-templates/geometry-definitions.ts +83 -0
  127. package/src/i3s-converter/json-templates/layers.ts +2 -91
  128. package/src/i3s-converter/json-templates/shared-resources.ts +3 -3
  129. package/src/i3s-converter/types.ts +29 -2
  130. package/src/lib/utils/file-utils.ts +62 -7
  131. package/src/lib/utils/write-queue.ts +36 -15
  132. package/src/workers/i3s-attributes-worker.ts +2 -1
@@ -0,0 +1,7 @@
1
+ export declare const GEOMETRY_DEFINITION: () => {
2
+ geometryBuffers: {
3
+ path: string;
4
+ transform: (val: any) => any[];
5
+ };
6
+ };
7
+ //# sourceMappingURL=geometry-definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometry-definitions.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/json-templates/geometry-definitions.ts"],"names":[],"mappings":"AAuEA,eAAO,MAAM,mBAAmB;;;;;CAW9B,CAAC"}
@@ -0,0 +1,87 @@
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.GEOMETRY_DEFINITION = void 0;
7
+ const json_map_transform_1 = __importDefault(require("json-map-transform"));
8
+ const PLAIN_GEOMETRY_DEFINITION = () => ({
9
+ offset: {
10
+ default: 8
11
+ },
12
+ position: {
13
+ default: {
14
+ type: 'Float32',
15
+ component: 3
16
+ }
17
+ },
18
+ normal: {
19
+ default: {
20
+ type: 'Float32',
21
+ component: 3
22
+ }
23
+ },
24
+ uv0: {
25
+ path: 'hasTexture',
26
+ transform: (val) => (val && { type: 'Float32', component: 2 }) || false,
27
+ omitValues: [false]
28
+ },
29
+ color: {
30
+ default: {
31
+ type: 'UInt8',
32
+ component: 4
33
+ }
34
+ },
35
+ uvRegion: {
36
+ path: 'hasUvRegions',
37
+ transform: (val) => (val && { type: 'UInt16', component: 4 }) || false,
38
+ omitValues: [false]
39
+ },
40
+ featureId: {
41
+ default: {
42
+ binding: 'per-feature',
43
+ type: 'UInt64',
44
+ component: 1
45
+ }
46
+ },
47
+ faceRange: {
48
+ default: {
49
+ binding: 'per-feature',
50
+ type: 'UInt32',
51
+ component: 2
52
+ }
53
+ }
54
+ });
55
+ const COMPRESSED_GEOMETRY_DEFINITION = () => ({
56
+ 'compressedAttributes.encoding': {
57
+ default: 'draco'
58
+ },
59
+ 'compressedAttributes.attributes': {
60
+ path: 'geometryConfig',
61
+ transform: (val) => {
62
+ const result = ['position', 'normal'];
63
+ if (val.hasTexture) {
64
+ result.push('uv0');
65
+ }
66
+ result.push('color');
67
+ if (val.hasUvRegions) {
68
+ result.push('uv-region');
69
+ }
70
+ result.push('feature-index');
71
+ return result;
72
+ }
73
+ }
74
+ });
75
+ const GEOMETRY_DEFINITION = () => ({
76
+ geometryBuffers: {
77
+ path: 'geometryConfig',
78
+ transform: (val) => {
79
+ const result = [(0, json_map_transform_1.default)(val, PLAIN_GEOMETRY_DEFINITION())];
80
+ if (val.draco) {
81
+ result.push((0, json_map_transform_1.default)({ geometryConfig: val }, COMPRESSED_GEOMETRY_DEFINITION()));
82
+ }
83
+ return result;
84
+ }
85
+ }
86
+ });
87
+ exports.GEOMETRY_DEFINITION = GEOMETRY_DEFINITION;
@@ -52,36 +52,7 @@ export declare const LAYERS: () => {
52
52
  };
53
53
  geometryDefinitions: {
54
54
  path: string;
55
- transform: (val: any) => {
56
- geometryBuffers: never[];
57
- }[];
58
- default: {
59
- geometryBuffers: {
60
- offset: number;
61
- position: {
62
- type: string;
63
- component: number;
64
- };
65
- normal: {
66
- type: string;
67
- component: number;
68
- };
69
- color: {
70
- type: string;
71
- component: number;
72
- };
73
- featureId: {
74
- binding: string;
75
- type: string;
76
- component: number;
77
- };
78
- faceRange: {
79
- binding: string;
80
- type: string;
81
- component: number;
82
- };
83
- }[];
84
- }[];
55
+ default: never[];
85
56
  };
86
57
  attributeStorageInfo: {
87
58
  path: string;
@@ -1 +1 @@
1
- {"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/json-templates/layers.ts"],"names":[],"mappings":"AA0IA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuFjB,CAAC"}
1
+ {"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/json-templates/layers.ts"],"names":[],"mappings":"AAoEA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoEjB,CAAC"}
@@ -6,72 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LAYERS = void 0;
7
7
  const json_map_transform_1 = __importDefault(require("json-map-transform"));
8
8
  const store_1 = require("./store");
9
- const PLAIN_GEOMETRY_DEFINITION = () => ({
10
- offset: 8,
11
- position: {
12
- type: 'Float32',
13
- component: 3
14
- },
15
- normal: {
16
- type: 'Float32',
17
- component: 3
18
- },
19
- uv0: {
20
- type: 'Float32',
21
- component: 2
22
- },
23
- color: {
24
- type: 'UInt8',
25
- component: 4
26
- },
27
- featureId: {
28
- binding: 'per-feature',
29
- type: 'UInt64',
30
- component: 1
31
- },
32
- faceRange: {
33
- binding: 'per-feature',
34
- type: 'UInt32',
35
- component: 2
36
- }
37
- });
38
- const PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0 = () => ({
39
- offset: 8,
40
- position: {
41
- type: 'Float32',
42
- component: 3
43
- },
44
- normal: {
45
- type: 'Float32',
46
- component: 3
47
- },
48
- color: {
49
- type: 'UInt8',
50
- component: 4
51
- },
52
- featureId: {
53
- binding: 'per-feature',
54
- type: 'UInt64',
55
- component: 1
56
- },
57
- faceRange: {
58
- binding: 'per-feature',
59
- type: 'UInt32',
60
- component: 2
61
- }
62
- });
63
- const COMPRESSED_GEOMETRY_DEFINITION = () => ({
64
- compressedAttributes: {
65
- encoding: 'draco',
66
- attributes: ['position', 'normal', 'uv0', 'color', 'feature-index']
67
- }
68
- });
69
- const COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0 = () => ({
70
- compressedAttributes: {
71
- encoding: 'draco',
72
- attributes: ['position', 'normal', 'color', 'feature-index']
73
- }
74
- });
75
9
  const SPATIAL_REFERENCE = () => ({
76
10
  wkid: {
77
11
  path: 'wkid',
@@ -186,26 +120,8 @@ const LAYERS = () => ({
186
120
  default: []
187
121
  },
188
122
  geometryDefinitions: {
189
- path: 'compressGeometry',
190
- transform: (val) => {
191
- const result = [{ geometryBuffers: [] }, { geometryBuffers: [] }];
192
- // @ts-expect-error
193
- result[0].geometryBuffers.push(PLAIN_GEOMETRY_DEFINITION());
194
- // @ts-expect-error
195
- result[1].geometryBuffers.push(PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0());
196
- if (val) {
197
- // @ts-expect-error
198
- result[0].geometryBuffers.push(COMPRESSED_GEOMETRY_DEFINITION());
199
- // @ts-expect-error
200
- result[1].geometryBuffers.push(COMPRESSED_GEOMETRY_DEFINITION_WITHOUT_UV0());
201
- }
202
- return result;
203
- },
204
- default: [
205
- {
206
- geometryBuffers: [PLAIN_GEOMETRY_DEFINITION(), PLAIN_GEOMETRY_DEFINITION_WITHOUT_UV0()]
207
- }
208
- ]
123
+ path: 'geometryDefinitions',
124
+ default: []
209
125
  },
210
126
  attributeStorageInfo: {
211
127
  path: 'attributeStorageInfo',
@@ -20,15 +20,15 @@ const MATERIAL_DEFINITION_INFO_PARAMS = () => ({
20
20
  },
21
21
  ambient: {
22
22
  path: 'ambient',
23
- default: [1, 1, 1, 1]
23
+ default: [1, 1, 1]
24
24
  },
25
25
  diffuse: {
26
26
  path: 'diffuse',
27
- default: [1, 1, 1, 1]
27
+ default: [1, 1, 1]
28
28
  },
29
29
  specular: {
30
30
  path: 'specular',
31
- default: [0, 0, 0, 0]
31
+ default: [0, 0, 0]
32
32
  },
33
33
  useVertexColorAlpha: {
34
34
  path: 'useVertexColorAlpha',
@@ -1,5 +1,5 @@
1
+ import { GLTFImagePostprocessed } from '@loaders.gl/gltf';
1
2
  import { BoundingVolumes, I3SMaterialDefinition, MaterialDefinitionInfo, TextureDefinitionInfo } from '@loaders.gl/i3s';
2
- import { ImageDataType } from '@loaders.gl/images';
3
3
  /** Converted resources for specific node */
4
4
  export type I3SConvertedResources = {
5
5
  /**
@@ -19,6 +19,10 @@ export type I3SConvertedResources = {
19
19
  * Texture image content
20
20
  */
21
21
  texture: any | null;
22
+ /**
23
+ * If the resource has uvRegions geometry attribute
24
+ */
25
+ hasUvRegions: boolean;
22
26
  /**
23
27
  * Shared resources built from GLTF material
24
28
  */
@@ -56,6 +60,8 @@ export type ConvertedAttributes = {
56
60
  texCoords: Float32Array;
57
61
  /** COLOR_0 attribute value */
58
62
  colors: Uint8Array;
63
+ /** uvRegion attribute for a texture atlas */
64
+ uvRegions: Uint16Array;
59
65
  /** Feature indices grouped by ...
60
66
  * converted from "batch ids" of GLTF
61
67
  */
@@ -66,6 +72,8 @@ export type ConvertedAttributes = {
66
72
  * MBS and/or OBB bounding volumes of the node
67
73
  */
68
74
  boundingVolumes: null | BoundingVolumes;
75
+ /** merged materials data */
76
+ mergedMaterials: MergedMaterial[];
69
77
  };
70
78
  /** Postprocessed geometry and feature attributes
71
79
  * https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md
@@ -79,6 +87,8 @@ export type GeometryAttributes = {
79
87
  texCoords: Float32Array;
80
88
  /** COLOR_0 attribute value */
81
89
  colors: Uint8Array;
90
+ /** uvRegion attribute for a texture atlas */
91
+ uvRegions: Uint16Array;
82
92
  /** faceRanges attribute value */
83
93
  faceRange: Uint32Array;
84
94
  /** feature Ids attribute value */
@@ -96,6 +106,8 @@ export type GroupedByFeatureIdAttributes = {
96
106
  normals: Float32Array;
97
107
  /** COLOR_0 attribute value */
98
108
  colors: Uint8Array;
109
+ /** uvRegion attribute for a texture atlas */
110
+ uvRegions: Uint16Array;
99
111
  /** TEXCOORD_0 attribute value */
100
112
  texCoords: Float32Array;
101
113
  };
@@ -113,6 +125,20 @@ export type I3SMaterialWithTexture = {
113
125
  /** Material definition https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitions.cmn.md */
114
126
  material: I3SMaterialDefinition;
115
127
  /** Texture content (image) */
116
- texture?: ImageDataType;
128
+ texture?: GLTFImagePostprocessed;
129
+ /** Metadata of all merged materials */
130
+ mergedMaterials: MergedMaterial[];
131
+ };
132
+ /** Metadata of some original texture */
133
+ export type MergedMaterial = {
134
+ /** Gltf material Id */
135
+ originalMaterialId: string;
136
+ /** Original texture size */
137
+ textureSize?: {
138
+ width: number;
139
+ height: number;
140
+ };
141
+ /** Uint16Array of 4 elements https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md */
142
+ uvRegion?: Uint16Array;
117
143
  };
118
144
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAEjD,4CAA4C;AAC5C,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7B;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IACjD;;OAEG;IACH,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;IACpB;;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4B,GAAG;IACzC,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,SAAS,EAAE,YAAY,CAAC;IACxB,6BAA6B;IAC7B,OAAO,EAAE,YAAY,CAAC;IACtB,8BAA8B;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,6CAA6C;IAC7C,SAAS,EAAE,WAAW,CAAC;IACvB,iCAAiC;IACjC,SAAS,EAAE,YAAY,CAAC;CACzB,CAAC;AAEF,+CAA+C;AAC/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,oHAAoH;IACpH,uBAAuB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACnD,kHAAkH;IAClH,sBAAsB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACjD,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,sBAAsB,GAAG;IACnC,2GAA2G;IAC3G,QAAQ,EAAE,qBAAqB,CAAC;IAChC,8BAA8B;IAC9B,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,uCAAuC;IACvC,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC,CAAC;AAEF,wCAAwC;AACxC,MAAM,MAAM,cAAc,GAAG;IAC3B,uBAAuB;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4BAA4B;IAC5B,WAAW,CAAC,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,8GAA8G;IAC9G,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB,CAAC"}
@@ -13,8 +13,24 @@ export declare function writeFile(path: string, data: string | Uint8Array | Arra
13
13
  * @param data - file content
14
14
  * @param fileName - name of output file (default: index.json)
15
15
  * @param compress - if need to compress file with gzip (default: true)
16
+ * @param compressList - if set - the file should be added to this list and compressed in the end of conversion
16
17
  */
17
- export declare function writeFileForSlpk(path: string, data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>, fileName?: string, compress?: boolean): Promise<string>;
18
+ export declare function writeFileForSlpk(path: string, data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>, fileName?: string, compress?: boolean, compressList?: string[] | null): Promise<string | null>;
19
+ /**
20
+ * Open json file
21
+ * @param path - path to the file
22
+ * @param fileName - file name
23
+ * @returns object
24
+ */
25
+ export declare function openJson(path: string, fileName: string): Promise<{
26
+ [key: string]: any;
27
+ }>;
28
+ /**
29
+ * Check if the file exists
30
+ * @param fileName - full name of file
31
+ * @returns true if file exists, otherwise - false
32
+ */
33
+ export declare function isFileExists(fileName: string): Promise<boolean>;
18
34
  /**
19
35
  * Remove dir with path
20
36
  *
@@ -1 +1 @@
1
- {"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/file-utils.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9D,QAAQ,GAAE,MAAqB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9D,QAAQ,GAAE,MAAqB,EAC/B,QAAQ,GAAE,OAAc,GACvB,OAAO,CAAC,MAAM,CAAC,CASjB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,iBAErC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,iBAEtC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAEnD"}
1
+ {"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/file-utils.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9D,QAAQ,GAAE,MAAqB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9D,QAAQ,GAAE,MAAqB,EAC/B,QAAQ,GAAE,OAAc,EACxB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,GAC7B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkBxB;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAAC,CAoB5F;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOrE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,iBAErC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,iBAEtC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAEnD"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAbsoluteFilePath = exports.removeFile = exports.removeDir = exports.writeFileForSlpk = exports.writeFile = void 0;
3
+ exports.getAbsoluteFilePath = exports.removeFile = exports.removeDir = exports.isFileExists = exports.openJson = exports.writeFileForSlpk = exports.writeFile = void 0;
4
+ const core_1 = require("@loaders.gl/core");
5
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
4
6
  const fs_1 = require("fs");
5
7
  const path_1 = require("path");
6
8
  const compress_util_1 = require("./compress-util");
@@ -41,18 +43,73 @@ exports.writeFile = writeFile;
41
43
  * @param data - file content
42
44
  * @param fileName - name of output file (default: index.json)
43
45
  * @param compress - if need to compress file with gzip (default: true)
46
+ * @param compressList - if set - the file should be added to this list and compressed in the end of conversion
44
47
  */
45
- async function writeFileForSlpk(path, data, fileName = 'index.json', compress = true) {
48
+ async function writeFileForSlpk(path, data, fileName = 'index.json', compress = true, compressList) {
46
49
  const pathFile = await writeFile(path, data, fileName);
47
50
  if (compress) {
48
- const pathGzFile = await (0, compress_util_1.compressFileWithGzip)(pathFile);
49
- // After compression, we don't need an uncompressed file
50
- await removeFile(pathFile);
51
- return pathGzFile;
51
+ if (compressList) {
52
+ if (!compressList.includes(pathFile)) {
53
+ compressList.push(pathFile);
54
+ return `${pathFile}.gz`;
55
+ }
56
+ else {
57
+ return null;
58
+ }
59
+ }
60
+ else {
61
+ const pathGzFile = await (0, compress_util_1.compressFileWithGzip)(pathFile);
62
+ // After compression, we don't need an uncompressed file
63
+ await removeFile(pathFile);
64
+ return pathGzFile;
65
+ }
52
66
  }
53
67
  return pathFile;
54
68
  }
55
69
  exports.writeFileForSlpk = writeFileForSlpk;
70
+ /**
71
+ * Open json file
72
+ * @param path - path to the file
73
+ * @param fileName - file name
74
+ * @returns object
75
+ */
76
+ async function openJson(path, fileName) {
77
+ return new Promise((resolve, reject) => {
78
+ let count = 0;
79
+ console.log(`load ${path}/${fileName}.`); // eslint-disable-line
80
+ const intervalId = setInterval(() => {
81
+ const pathFile = (0, path_1.join)(path, fileName);
82
+ (0, core_1.load)(pathFile, loader_utils_1.JSONLoader)
83
+ .then((result) => {
84
+ clearInterval(intervalId);
85
+ resolve(result);
86
+ })
87
+ .catch(() => {
88
+ count++;
89
+ if (count > 100) {
90
+ clearInterval(intervalId);
91
+ reject(new Error(`Cannon load ${path}/${fileName}.`));
92
+ }
93
+ });
94
+ }, 200);
95
+ });
96
+ }
97
+ exports.openJson = openJson;
98
+ /**
99
+ * Check if the file exists
100
+ * @param fileName - full name of file
101
+ * @returns true if file exists, otherwise - false
102
+ */
103
+ async function isFileExists(fileName) {
104
+ try {
105
+ await fs_1.promises.stat(fileName);
106
+ return true;
107
+ }
108
+ catch {
109
+ return false;
110
+ }
111
+ }
112
+ exports.isFileExists = isFileExists;
56
113
  /**
57
114
  * Remove dir with path
58
115
  *
@@ -76,6 +133,6 @@ exports.removeFile = removeFile;
76
133
  * @param filePath
77
134
  */
78
135
  function getAbsoluteFilePath(filePath) {
79
- return (0, path_1.isAbsolute)(filePath) ? filePath : (0, path_1.join)(process.cwd(), filePath); // eslint-disable-line no-undef
136
+ return (0, path_1.isAbsolute)(filePath) ? filePath : (0, path_1.join)(process.cwd(), filePath);
80
137
  }
81
138
  exports.getAbsoluteFilePath = getAbsoluteFilePath;
@@ -1,7 +1,23 @@
1
1
  import { Queue } from './queue';
2
2
  export type WriteQueueItem = {
3
3
  archiveKey?: string;
4
- writePromise: Promise<string>;
4
+ /**
5
+ * writePromise() returns a Promise that will be awaited in Promise.allSettled(promises);
6
+ * Arguments for this call are specified in writeQueue.enqueue call like this:
7
+ * await writeQueue.enqueue({
8
+ * archiveKey: `nodePages/xxx.json.gz`,
9
+ * writePromise: () => writeFileForSlpk(slpkPath, data, `xxx.json`)
10
+ * });
11
+ * Note, a function like writeFileForSlpk should NOT be called when initializing the object for enqueue().
12
+ * If he function is called, the promise will be created
13
+ * and the function will allocate resources (file descriptors) for file writing.
14
+ * It will be done for ALL items in the queue, which is not supposed to happen.
15
+ * That's why the function should be passed as
16
+ * writePromise: () => writeFileForSlpk(slpkPath, content, `xxx.json`)
17
+ * instead of
18
+ * writePromise: writeFileForSlpk(slpkPath, content, `xxx.json`) // INCORRECT !
19
+ */
20
+ writePromise: () => Promise<string | null>;
5
21
  };
6
22
  export default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {
7
23
  private intervalId?;
@@ -12,7 +28,7 @@ export default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {
12
28
  listeningInterval: number;
13
29
  writeConcurrency: number;
14
30
  constructor(listeningInterval?: number, writeConcurrency?: number);
15
- enqueue(val: T): Promise<void>;
31
+ enqueue(val: T, writeImmediately?: boolean): Promise<void>;
16
32
  startListening(): void;
17
33
  stopListening(): void;
18
34
  startWrite(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"write-queue.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/write-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAM9B,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/B,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,UAAU,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,UAAU,CAAC,CAAiB;IAC7B,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAQ;IAC1C,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAM;IACtC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;gBAEpB,iBAAiB,GAAE,MAAa,EAAE,gBAAgB,GAAE,MAAY;IAMtE,OAAO,CAAC,GAAG,EAAE,CAAC;IAQpB,cAAc;IAId,aAAa;IAMP,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;YAKjB,OAAO;IAmBrB,OAAO,CAAC,aAAa;CAWtB"}
1
+ {"version":3,"file":"write-queue.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/write-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAM9B,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;;;;OAeG;IACH,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,UAAU,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,UAAU,CAAC,CAAiB;IAC7B,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAQ;IAC1C,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAM;IACtC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;gBAEpB,iBAAiB,GAAE,MAAa,EAAE,gBAAgB,GAAE,MAAY;IAMtE,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,gBAAgB,GAAE,OAAe;IAgBvD,cAAc;IAId,aAAa;IAMP,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;YAKjB,OAAO;IAmBrB,OAAO,CAAC,aAAa;CAWtB"}
@@ -15,11 +15,20 @@ class WriteQueue extends queue_1.Queue {
15
15
  this.listeningInterval = listeningInterval;
16
16
  this.writeConcurrency = writeConcurrency;
17
17
  }
18
- async enqueue(val) {
19
- super.enqueue(val);
20
- /** https://nodejs.org/docs/latest-v14.x/api/process.html#process_process_memoryusage */
21
- if (process_1.default.memoryUsage().rss > MEMORY_LIMIT) {
22
- await this.startWrite();
18
+ async enqueue(val, writeImmediately = false) {
19
+ if (writeImmediately) {
20
+ const { archiveKey, writePromise } = val;
21
+ const result = await writePromise();
22
+ if (archiveKey && result) {
23
+ this.fileMap[archiveKey] = result;
24
+ }
25
+ }
26
+ else {
27
+ super.enqueue(val);
28
+ /** https://nodejs.org/docs/latest-v14.x/api/process.html#process_process_memoryusage */
29
+ if (process_1.default.memoryUsage().rss > MEMORY_LIMIT) {
30
+ await this.startWrite();
31
+ }
23
32
  }
24
33
  }
25
34
  startListening() {
@@ -31,12 +40,9 @@ class WriteQueue extends queue_1.Queue {
31
40
  }
32
41
  }
33
42
  async startWrite() {
34
- if (this.writePromise) {
35
- await this.writePromise;
36
- this.writePromise = null;
37
- return;
43
+ if (!this.writePromise) {
44
+ this.writePromise = this.doWrite();
38
45
  }
39
- this.writePromise = this.doWrite();
40
46
  await this.writePromise;
41
47
  this.writePromise = null;
42
48
  }
@@ -55,12 +61,12 @@ class WriteQueue extends queue_1.Queue {
55
61
  }
56
62
  const { archiveKey, writePromise } = item;
57
63
  archiveKeys.push(archiveKey);
58
- promises.push(writePromise);
64
+ const promise = writePromise();
65
+ promises.push(promise);
59
66
  }
60
67
  const writeResults = await Promise.allSettled(promises);
61
68
  this.updateFileMap(archiveKeys, writeResults);
62
69
  }
63
- this.writePromise = null;
64
70
  }
65
71
  updateFileMap(archiveKeys, writeResults) {
66
72
  for (let i = 0; i < archiveKeys.length; i++) {
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const worker_utils_1 = require("@loaders.gl/worker-utils");
4
4
  const geometry_converter_1 = require("../i3s-converter/helpers/geometry-converter");
5
- (0, worker_utils_1.createWorker)(async (data, options = {}) => await (0, geometry_converter_1.convertAttributes)(data, options.useCartesianPositions));
5
+ (0, worker_utils_1.createWorker)(async (data, options = {}) => await (0, geometry_converter_1.convertAttributes)(data, options.materialAndTextureList, options.useCartesianPositions));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tile-converter",
3
- "version": "3.3.0-alpha.8",
3
+ "version": "3.3.0",
4
4
  "description": "Converter",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,29 +33,30 @@
33
33
  "fs": false,
34
34
  "path": false,
35
35
  "process": false,
36
- "archiver": false
36
+ "archiver": false,
37
+ "join-images": false
37
38
  },
38
39
  "scripts": {
39
40
  "pre-build": "npm run build-bundle && npm run build-converter-bundle && npm run build-i3s-attributes-worker && npm run build-3d-tiles-attributes-worker",
40
- "build-bundle": "esbuild ./src/index.ts --bundle --outfile=dist/dist.min.js --platform=node",
41
+ "build-bundle": "esbuild ./src/index.ts --bundle --outfile=dist/dist.min.js --platform=node --external:join-images",
41
42
  "build-converter-bundle": "webpack --display errors-only --config ./converter-webpack/bundle.js",
42
- "build-i3s-attributes-worker": "esbuild src/workers/i3s-attributes-worker.ts --outfile=dist/i3s-attributes-worker.js --platform=node --target=esnext,node12 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\"",
43
- "build-3d-tiles-attributes-worker": "esbuild src/workers/3d-tiles-attributes-worker.ts --outfile=dist/3d-tiles-attributes-worker.js --platform=node --target=esnext,node12 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
43
+ "build-i3s-attributes-worker": "esbuild src/workers/i3s-attributes-worker.ts --outfile=dist/i3s-attributes-worker.js --platform=node --target=esnext,node12 --external:join-images --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\"",
44
+ "build-3d-tiles-attributes-worker": "esbuild src/workers/3d-tiles-attributes-worker.ts --outfile=dist/3d-tiles-attributes-worker.js --platform=node --target=esnext,node12 --external:join-images --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
44
45
  },
45
46
  "dependencies": {
46
- "@loaders.gl/3d-tiles": "3.3.0-alpha.8",
47
- "@loaders.gl/crypto": "3.3.0-alpha.8",
48
- "@loaders.gl/draco": "3.3.0-alpha.8",
49
- "@loaders.gl/gltf": "3.3.0-alpha.8",
50
- "@loaders.gl/i3s": "3.3.0-alpha.8",
51
- "@loaders.gl/images": "3.3.0-alpha.8",
52
- "@loaders.gl/loader-utils": "3.3.0-alpha.8",
53
- "@loaders.gl/polyfills": "3.3.0-alpha.8",
54
- "@loaders.gl/schema": "3.3.0-alpha.8",
55
- "@loaders.gl/textures": "3.3.0-alpha.8",
56
- "@loaders.gl/tiles": "3.3.0-alpha.8",
57
- "@loaders.gl/worker-utils": "3.3.0-alpha.8",
58
- "@loaders.gl/zip": "3.3.0-alpha.8",
47
+ "@loaders.gl/3d-tiles": "3.3.0",
48
+ "@loaders.gl/crypto": "3.3.0",
49
+ "@loaders.gl/draco": "3.3.0",
50
+ "@loaders.gl/gltf": "3.3.0",
51
+ "@loaders.gl/i3s": "3.3.0",
52
+ "@loaders.gl/images": "3.3.0",
53
+ "@loaders.gl/loader-utils": "3.3.0",
54
+ "@loaders.gl/polyfills": "3.3.0",
55
+ "@loaders.gl/schema": "3.3.0",
56
+ "@loaders.gl/textures": "3.3.0",
57
+ "@loaders.gl/tiles": "3.3.0",
58
+ "@loaders.gl/worker-utils": "3.3.0",
59
+ "@loaders.gl/zip": "3.3.0",
59
60
  "@luma.gl/engine": "^8.5.4",
60
61
  "@math.gl/core": "^3.5.1",
61
62
  "@math.gl/culling": "^3.5.1",
@@ -65,7 +66,7 @@
65
66
  "cors": "^2.8.5",
66
67
  "crypt": "^0.0.2",
67
68
  "debug": "~2.6.9",
68
- "express": "~4.16.1",
69
+ "express": "~4.17.3",
69
70
  "json-map-transform": "^1.2.6",
70
71
  "jszip": "^3.5.0",
71
72
  "md5": "^2.3.0",
@@ -75,5 +76,9 @@
75
76
  "peerDependencies": {
76
77
  "@loaders.gl/core": "^3.2.0"
77
78
  },
78
- "gitHead": "69cfde0340328dd800c7c90151b56b406f47e9ae"
79
+ "quarantinedDependencies": {
80
+ "join-images": "^1.1.3",
81
+ "sharp": "^0.31.3"
82
+ },
83
+ "gitHead": "566d194f175a03e042d3e588cdd514048f428cc1"
79
84
  }