@loaders.gl/i3s 3.3.0-alpha.1 → 3.3.0-alpha.2
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/dist.min.js +56 -49
- package/dist/es5/arcgis-webscene-loader.js +1 -1
- package/dist/es5/i3s-attribute-loader.js +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -1
- package/dist/es5/i3s-content-loader.js +19 -8
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +36 -38
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +76 -77
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/arcgis-webscene-loader.js +1 -1
- package/dist/esm/i3s-attribute-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-content-loader.js +12 -4
- package/dist/esm/i3s-content-loader.js.map +1 -1
- package/dist/esm/i3s-loader.js +8 -12
- package/dist/esm/i3s-loader.js.map +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +37 -34
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/i3s-content-loader.d.ts.map +1 -1
- package/dist/i3s-content-loader.js +7 -3
- package/dist/i3s-content-worker.js +54 -46
- package/dist/i3s-loader.d.ts +5 -0
- package/dist/i3s-loader.d.ts.map +1 -1
- package/dist/i3s-loader.js +6 -9
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts +2 -2
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s-tile-content.js +36 -32
- package/dist/lib/parsers/parse-i3s.d.ts +1 -1
- package/dist/lib/parsers/parse-i3s.d.ts.map +1 -1
- package/dist/lib/parsers/parse-i3s.js +1 -1
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/i3s-content-loader.ts +17 -5
- package/src/i3s-loader.ts +15 -12
- package/src/lib/parsers/parse-i3s-tile-content.ts +46 -41
- package/src/lib/parsers/parse-i3s.ts +1 -1
- package/src/types.ts +45 -0
|
@@ -62,95 +62,103 @@ function getLoaderForTextureFormat(textureFormat) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
var I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
|
|
65
|
+
var defaultContent = {
|
|
66
|
+
attributes: {},
|
|
67
|
+
indices: null,
|
|
68
|
+
featureIds: [],
|
|
69
|
+
vertexCount: 0,
|
|
70
|
+
modelMatrix: new _core2.Matrix4(),
|
|
71
|
+
coordinateSystem: 0,
|
|
72
|
+
byteLength: 0,
|
|
73
|
+
texture: null
|
|
74
|
+
};
|
|
65
75
|
|
|
66
76
|
function parseI3STileContent(_x, _x2, _x3, _x4, _x5) {
|
|
67
77
|
return _parseI3STileContent.apply(this, arguments);
|
|
68
78
|
}
|
|
69
79
|
|
|
70
80
|
function _parseI3STileContent() {
|
|
71
|
-
_parseI3STileContent = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer,
|
|
72
|
-
var _options$i3s, url, loader, response, _arrayBuffer, _options, texture;
|
|
81
|
+
_parseI3STileContent = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, tileOptions, tilesetOptions, options, context) {
|
|
82
|
+
var content, _options$i3s, url, loader, response, _arrayBuffer, _options, texture;
|
|
73
83
|
|
|
74
84
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
75
85
|
while (1) {
|
|
76
86
|
switch (_context.prev = _context.next) {
|
|
77
87
|
case 0:
|
|
78
|
-
|
|
79
|
-
tile.content.featureIds = tile.content.featureIds || null;
|
|
80
|
-
tile.content.attributes = {};
|
|
88
|
+
content = defaultContent;
|
|
81
89
|
|
|
82
|
-
if (!
|
|
83
|
-
_context.next =
|
|
90
|
+
if (!tileOptions.textureUrl) {
|
|
91
|
+
_context.next = 35;
|
|
84
92
|
break;
|
|
85
93
|
}
|
|
86
94
|
|
|
87
|
-
url = (0, _urlUtils.getUrlWithToken)(
|
|
88
|
-
loader = getLoaderForTextureFormat(
|
|
89
|
-
_context.next =
|
|
95
|
+
url = (0, _urlUtils.getUrlWithToken)(tileOptions.textureUrl, options === null || options === void 0 ? void 0 : (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
|
|
96
|
+
loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
97
|
+
_context.next = 6;
|
|
90
98
|
return fetch(url, options === null || options === void 0 ? void 0 : options.fetch);
|
|
91
99
|
|
|
92
|
-
case
|
|
100
|
+
case 6:
|
|
93
101
|
response = _context.sent;
|
|
94
|
-
_context.next =
|
|
102
|
+
_context.next = 9;
|
|
95
103
|
return response.arrayBuffer();
|
|
96
104
|
|
|
97
|
-
case
|
|
105
|
+
case 9:
|
|
98
106
|
_arrayBuffer = _context.sent;
|
|
99
107
|
|
|
100
108
|
if (!(options !== null && options !== void 0 && options.i3s.decodeTextures)) {
|
|
101
|
-
_context.next =
|
|
109
|
+
_context.next = 34;
|
|
102
110
|
break;
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
if (!(loader === _images.ImageLoader)) {
|
|
106
|
-
_context.next =
|
|
114
|
+
_context.next = 26;
|
|
107
115
|
break;
|
|
108
116
|
}
|
|
109
117
|
|
|
110
|
-
_options = _objectSpread(_objectSpread({},
|
|
118
|
+
_options = _objectSpread(_objectSpread({}, tileOptions.textureLoaderOptions), {}, {
|
|
111
119
|
image: {
|
|
112
120
|
type: 'data'
|
|
113
121
|
}
|
|
114
122
|
});
|
|
115
|
-
_context.prev =
|
|
116
|
-
_context.next =
|
|
123
|
+
_context.prev = 13;
|
|
124
|
+
_context.next = 16;
|
|
117
125
|
return context.parse(_arrayBuffer, _options);
|
|
118
126
|
|
|
119
|
-
case
|
|
120
|
-
|
|
121
|
-
_context.next =
|
|
127
|
+
case 16:
|
|
128
|
+
content.texture = _context.sent;
|
|
129
|
+
_context.next = 24;
|
|
122
130
|
break;
|
|
123
131
|
|
|
124
|
-
case
|
|
125
|
-
_context.prev =
|
|
126
|
-
_context.t0 = _context["catch"](
|
|
127
|
-
_context.next =
|
|
132
|
+
case 19:
|
|
133
|
+
_context.prev = 19;
|
|
134
|
+
_context.t0 = _context["catch"](13);
|
|
135
|
+
_context.next = 23;
|
|
128
136
|
return (0, _core.parse)(_arrayBuffer, loader, _options);
|
|
129
137
|
|
|
130
|
-
case
|
|
131
|
-
|
|
138
|
+
case 23:
|
|
139
|
+
content.texture = _context.sent;
|
|
132
140
|
|
|
133
|
-
case
|
|
134
|
-
_context.next =
|
|
141
|
+
case 24:
|
|
142
|
+
_context.next = 32;
|
|
135
143
|
break;
|
|
136
144
|
|
|
137
|
-
case
|
|
145
|
+
case 26:
|
|
138
146
|
if (!(loader === _textures.CompressedTextureLoader || loader === _textures.BasisLoader)) {
|
|
139
|
-
_context.next =
|
|
147
|
+
_context.next = 32;
|
|
140
148
|
break;
|
|
141
149
|
}
|
|
142
150
|
|
|
143
|
-
_context.next =
|
|
144
|
-
return (0, _core.load)(_arrayBuffer, loader,
|
|
151
|
+
_context.next = 29;
|
|
152
|
+
return (0, _core.load)(_arrayBuffer, loader, tileOptions.textureLoaderOptions);
|
|
145
153
|
|
|
146
|
-
case
|
|
154
|
+
case 29:
|
|
147
155
|
texture = _context.sent;
|
|
148
156
|
|
|
149
157
|
if (loader === _textures.BasisLoader) {
|
|
150
158
|
texture = texture[0];
|
|
151
159
|
}
|
|
152
160
|
|
|
153
|
-
|
|
161
|
+
content.texture = {
|
|
154
162
|
compressed: true,
|
|
155
163
|
mipmaps: false,
|
|
156
164
|
width: texture[0].width,
|
|
@@ -158,76 +166,67 @@ function _parseI3STileContent() {
|
|
|
158
166
|
data: texture
|
|
159
167
|
};
|
|
160
168
|
|
|
161
|
-
case
|
|
162
|
-
_context.next =
|
|
169
|
+
case 32:
|
|
170
|
+
_context.next = 35;
|
|
163
171
|
break;
|
|
164
172
|
|
|
165
|
-
case
|
|
166
|
-
|
|
173
|
+
case 34:
|
|
174
|
+
content.texture = _arrayBuffer;
|
|
167
175
|
|
|
168
|
-
case
|
|
169
|
-
|
|
176
|
+
case 35:
|
|
177
|
+
content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);
|
|
170
178
|
|
|
171
|
-
if (
|
|
172
|
-
|
|
179
|
+
if (content.material) {
|
|
180
|
+
content.texture = null;
|
|
173
181
|
}
|
|
174
182
|
|
|
175
|
-
_context.next =
|
|
176
|
-
return parseI3SNodeGeometry(arrayBuffer,
|
|
183
|
+
_context.next = 39;
|
|
184
|
+
return parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
177
185
|
|
|
178
|
-
case
|
|
186
|
+
case 39:
|
|
179
187
|
return _context.abrupt("return", _context.sent);
|
|
180
188
|
|
|
181
|
-
case
|
|
189
|
+
case 40:
|
|
182
190
|
case "end":
|
|
183
191
|
return _context.stop();
|
|
184
192
|
}
|
|
185
193
|
}
|
|
186
|
-
}, _callee, null, [[
|
|
194
|
+
}, _callee, null, [[13, 19]]);
|
|
187
195
|
}));
|
|
188
196
|
return _parseI3STileContent.apply(this, arguments);
|
|
189
197
|
}
|
|
190
198
|
|
|
191
|
-
function parseI3SNodeGeometry(_x6, _x7, _x8, _x9) {
|
|
199
|
+
function parseI3SNodeGeometry(_x6, _x7, _x8, _x9, _x10) {
|
|
192
200
|
return _parseI3SNodeGeometry.apply(this, arguments);
|
|
193
201
|
}
|
|
194
202
|
|
|
195
203
|
function _parseI3SNodeGeometry() {
|
|
196
|
-
_parseI3SNodeGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(arrayBuffer,
|
|
204
|
+
_parseI3SNodeGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(arrayBuffer, content, tileOptions, tilesetOptions, options) {
|
|
197
205
|
var _options$i3s2;
|
|
198
206
|
|
|
199
|
-
var
|
|
207
|
+
var contentByteLength, attributes, vertexCount, byteOffset, featureCount, indices, _decompressedGeometry, decompressedGeometry, _decompressedGeometry2, POSITION, NORMAL, COLOR_0, TEXCOORD_0, featureIndex, uvRegion, featureIds, _tilesetOptions$store, vertexAttributes, attributesOrder, featureAttributes, featureAttributeOrder, headers, _normalizeAttributes, normalizedVertexAttributes, offset, _normalizeAttributes2, normalizedFeatureAttributes, enuMatrix, attributeIndex;
|
|
200
208
|
|
|
201
209
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
202
210
|
while (1) {
|
|
203
211
|
switch (_context2.prev = _context2.next) {
|
|
204
212
|
case 0:
|
|
205
|
-
if (tile.content) {
|
|
206
|
-
_context2.next = 2;
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return _context2.abrupt("return", tile);
|
|
211
|
-
|
|
212
|
-
case 2:
|
|
213
|
-
content = tile.content;
|
|
214
213
|
contentByteLength = arrayBuffer.byteLength;
|
|
215
214
|
byteOffset = 0;
|
|
216
215
|
featureCount = 0;
|
|
217
216
|
|
|
218
|
-
if (!
|
|
219
|
-
_context2.next =
|
|
217
|
+
if (!tileOptions.isDracoGeometry) {
|
|
218
|
+
_context2.next = 16;
|
|
220
219
|
break;
|
|
221
220
|
}
|
|
222
221
|
|
|
223
|
-
_context2.next =
|
|
222
|
+
_context2.next = 6;
|
|
224
223
|
return (0, _core.parse)(arrayBuffer, _draco.DracoLoader, {
|
|
225
224
|
draco: {
|
|
226
225
|
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
227
226
|
}
|
|
228
227
|
});
|
|
229
228
|
|
|
230
|
-
case
|
|
229
|
+
case 6:
|
|
231
230
|
decompressedGeometry = _context2.sent;
|
|
232
231
|
vertexCount = decompressedGeometry.header.vertexCount;
|
|
233
232
|
indices = (_decompressedGeometry = decompressedGeometry.indices) === null || _decompressedGeometry === void 0 ? void 0 : _decompressedGeometry.value;
|
|
@@ -247,12 +246,12 @@ function _parseI3SNodeGeometry() {
|
|
|
247
246
|
flattenFeatureIdsByFeatureIndices(attributes, featureIds);
|
|
248
247
|
}
|
|
249
248
|
|
|
250
|
-
_context2.next =
|
|
249
|
+
_context2.next = 25;
|
|
251
250
|
break;
|
|
252
251
|
|
|
253
|
-
case
|
|
254
|
-
|
|
255
|
-
headers = parseHeaders(
|
|
252
|
+
case 16:
|
|
253
|
+
_tilesetOptions$store = tilesetOptions.store.defaultGeometrySchema, vertexAttributes = _tilesetOptions$store.vertexAttributes, attributesOrder = _tilesetOptions$store.ordering, featureAttributes = _tilesetOptions$store.featureAttributes, featureAttributeOrder = _tilesetOptions$store.featureAttributeOrder;
|
|
254
|
+
headers = parseHeaders(arrayBuffer, tilesetOptions);
|
|
256
255
|
byteOffset = headers.byteOffset;
|
|
257
256
|
vertexCount = headers.vertexCount;
|
|
258
257
|
featureCount = headers.featureCount;
|
|
@@ -261,9 +260,9 @@ function _parseI3SNodeGeometry() {
|
|
|
261
260
|
flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);
|
|
262
261
|
attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
|
|
263
262
|
|
|
264
|
-
case
|
|
263
|
+
case 25:
|
|
265
264
|
if (!(options !== null && options !== void 0 && (_options$i3s2 = options.i3s) !== null && _options$i3s2 !== void 0 && _options$i3s2.coordinateSystem) || options.i3s.coordinateSystem === _constants.COORDINATE_SYSTEM.METER_OFFSETS) {
|
|
266
|
-
enuMatrix = parsePositions(attributes.position,
|
|
265
|
+
enuMatrix = parsePositions(attributes.position, tileOptions);
|
|
267
266
|
content.modelMatrix = enuMatrix.invert();
|
|
268
267
|
content.coordinateSystem = _constants.COORDINATE_SYSTEM.METER_OFFSETS;
|
|
269
268
|
} else {
|
|
@@ -281,7 +280,7 @@ function _parseI3SNodeGeometry() {
|
|
|
281
280
|
content.indices = indices || null;
|
|
282
281
|
|
|
283
282
|
if (attributes.id && attributes.id.value) {
|
|
284
|
-
|
|
283
|
+
content.featureIds = attributes.id.value;
|
|
285
284
|
}
|
|
286
285
|
|
|
287
286
|
for (attributeIndex in content.attributes) {
|
|
@@ -292,9 +291,9 @@ function _parseI3SNodeGeometry() {
|
|
|
292
291
|
|
|
293
292
|
content.vertexCount = vertexCount;
|
|
294
293
|
content.byteLength = contentByteLength;
|
|
295
|
-
return _context2.abrupt("return",
|
|
294
|
+
return _context2.abrupt("return", content);
|
|
296
295
|
|
|
297
|
-
case
|
|
296
|
+
case 33:
|
|
298
297
|
case "end":
|
|
299
298
|
return _context2.stop();
|
|
300
299
|
}
|
|
@@ -336,12 +335,12 @@ function normalizeAttribute(attribute) {
|
|
|
336
335
|
return attribute;
|
|
337
336
|
}
|
|
338
337
|
|
|
339
|
-
function parseHeaders(
|
|
338
|
+
function parseHeaders(arrayBuffer, options) {
|
|
340
339
|
var byteOffset = 0;
|
|
341
340
|
var vertexCount = 0;
|
|
342
341
|
var featureCount = 0;
|
|
343
342
|
|
|
344
|
-
var _iterator = _createForOfIteratorHelper(
|
|
343
|
+
var _iterator = _createForOfIteratorHelper(options.store.defaultGeometrySchema.header),
|
|
345
344
|
_step;
|
|
346
345
|
|
|
347
346
|
try {
|
|
@@ -456,8 +455,8 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
|
456
455
|
return new Uint32Array(values);
|
|
457
456
|
}
|
|
458
457
|
|
|
459
|
-
function parsePositions(attribute,
|
|
460
|
-
var mbs =
|
|
458
|
+
function parsePositions(attribute, options) {
|
|
459
|
+
var mbs = options.mbs;
|
|
461
460
|
var value = attribute.value;
|
|
462
461
|
var metadata = attribute.metadata;
|
|
463
462
|
var enuMatrix = new _core2.Matrix4();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":["scratchVector","Vector3","getLoaderForTextureFormat","textureFormat","CompressedTextureLoader","BasisLoader","ImageLoader","I3S_ATTRIBUTE_TYPE","parseI3STileContent","arrayBuffer","tile","tileset","options","context","content","featureIds","attributes","textureUrl","url","i3s","token","loader","fetch","response","decodeTextures","textureLoaderOptions","image","type","parse","texture","compressed","mipmaps","width","height","data","material","makePbrMaterial","materialDefinition","parseI3SNodeGeometry","contentByteLength","byteLength","byteOffset","featureCount","isDracoGeometry","DracoLoader","draco","attributeNameEntry","decompressedGeometry","vertexCount","header","indices","value","POSITION","NORMAL","COLOR_0","TEXCOORD_0","featureIndex","uvRegion","position","normal","color","uv0","id","updateAttributesMetadata","getFeatureIdsFromFeatureIndexMetadata","flattenFeatureIdsByFeatureIndices","store","defaultGeometrySchema","vertexAttributes","attributesOrder","ordering","featureAttributes","featureAttributeOrder","headers","parseHeaders","normalizeAttributes","normalizedVertexAttributes","offset","normalizedFeatureAttributes","flattenFeatureIdsByFaceRanges","concatAttributes","coordinateSystem","COORDINATE_SYSTEM","METER_OFFSETS","enuMatrix","parsePositions","modelMatrix","invert","getModelMatrix","LNGLAT_OFFSETS","positions","normals","colors","normalizeAttribute","texCoords","uvRegions","attributeIndex","key","loaderData","dracoAttribute","name","metadata","attribute","normalized","property","TypedArrayTypeHeader","HeaderAttributeProperty","attributeCount","valueType","valuesPerElement","buffer","slice","parseUint64Values","TypedArrayType","GL_TYPE_MAP","size","elementsCount","attributeSize","values","dataView","DataView","index","left","getUint32","right","push","Uint32Array","mbs","Matrix4","cartographicOrigin","cartesianOrigin","Ellipsoid","WGS84","cartographicToCartesian","eastNorthUpToFixedFrame","offsetsToCartesians","vertices","Float64Array","length","scaleX","double","scaleY","i","x","y","z","subarray","pbrMaterial","pbrMetallicRoughness","baseColorFactor","baseColorTexture","texCoord","alphaCutoff","alphaMode","toUpperCase","emissiveFactor","convertColorFormat","setMaterialTexture","colorFactor","normalizedColor","source","emissiveTexture","metallicRoughnessTexture","normalTexture","occlusionTexture","faceRange","range","featureIdsLength","orderedFeatureIndices","startIndex","fillId","Number","endValue","prevValue","trianglesCount","endIndex","fill","featureIndices","result","Float32Array","intArray"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AAWA;;AAEA;;;;;;;;;;;;AAEA,IAAMA,aAAa,GAAG,IAAIC,cAAJ,CAAY,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAZ,CAAtB;;AAEA,SAASC,yBAAT,CAAmCC,aAAnC,EAAgG;AAC9F,UAAQA,aAAR;AACE,SAAK,UAAL;AACA,SAAK,KAAL;AACE,aAAOC,iCAAP;;AACF,SAAK,MAAL;AACE,aAAOC,qBAAP;;AACF,SAAK,KAAL;AACA,SAAK,KAAL;AACA;AACE,aAAOC,mBAAP;AATJ;AAWD;;AAED,IAAMC,kBAAkB,GAAG,oBAA3B;;SAEsBC,mB;;;;;mFAAf,iBACLC,WADK,EAELC,IAFK,EAGLC,OAHK,EAILC,OAJK,EAKLC,OALK;AAAA;;AAAA;AAAA;AAAA;AAAA;AAOLH,YAAAA,IAAI,CAACI,OAAL,GAAeJ,IAAI,CAACI,OAAL,IAAgB,EAA/B;AACAJ,YAAAA,IAAI,CAACI,OAAL,CAAaC,UAAb,GAA0BL,IAAI,CAACI,OAAL,CAAaC,UAAb,IAA2B,IAArD;AAEAL,YAAAA,IAAI,CAACI,OAAL,CAAaE,UAAb,GAA0B,EAA1B;;AAVK,iBAYDN,IAAI,CAACO,UAZJ;AAAA;AAAA;AAAA;;AAaGC,YAAAA,GAbH,GAaS,+BAAgBR,IAAI,CAACO,UAArB,EAAiCL,OAAjC,aAAiCA,OAAjC,uCAAiCA,OAAO,CAAEO,GAA1C,iDAAiC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AAM,CAAC5J,UAAU,CAACyC,YAAD,CAAX,CAArB;AACA,QAAMoH,QAAQ,GAAGN,KAAK,CAAC7C,KAAD,CAAtB;AACA,QAAMoD,SAAS,GAAGP,KAAK,CAAC7C,KAAK,GAAG,CAAT,CAAvB;AACA,QAAMqD,cAAc,GAAGF,QAAQ,GAAGC,SAAX,GAAuB,CAA9C;AACA,QAAME,QAAQ,GAAGN,UAAU,GAAGK,cAAc,GAAG,CAA/C;AAEAN,IAAAA,qBAAqB,CAACQ,IAAtB,CAA2BN,MAA3B,EAAmCD,UAAnC,EAA+CM,QAA/C;AAEAvH,IAAAA,YAAY;AACZiH,IAAAA,UAAU,GAAGM,QAAb;AACD;;AAEDjG,EAAAA,2BAA2B,CAAChB,EAA5B,CAA+BX,KAA/B,GAAuCqH,qBAAvC;AACD;;AAQD,SAASvG,iCAAT,CACEjD,UADF,EAEED,UAFF,EAGQ;AACN,MAAMkK,cAAc,GAAGjK,UAAU,CAAC8C,EAAX,CAAcX,KAArC;AACA,MAAM+H,MAAM,GAAG,IAAIC,YAAJ,CAAiBF,cAAc,CAACvC,MAAhC,CAAf;;AAEA,OAAK,IAAIjB,KAAK,GAAG,CAAjB,EAAoBA,KAAK,GAAGwD,cAAc,CAACvC,MAA3C,EAAmDjB,KAAK,EAAxD,EAA4D;AAC1DyD,IAAAA,MAAM,CAACzD,KAAD,CAAN,GAAgB1G,UAAU,CAACkK,cAAc,CAACxD,KAAD,CAAf,CAA1B;AACD;;AAEDzG,EAAAA,UAAU,CAAC8C,EAAX,CAAcX,KAAd,GAAsB+H,MAAtB;AACD;;AAOD,SAASlH,qCAAT,CACER,YADF,EAE0B;AAAA;;AACxB,SAAOA,YAAP,aAAOA,YAAP,gDAAOA,YAAY,CAAE6C,QAArB,oFAAO,sBAAyB,iBAAzB,CAAP,2DAAO,uBAA6C+E,QAApD;AACD","sourcesContent":["import type {TypedArray} from '@loaders.gl/schema';\nimport {load, parse} from '@loaders.gl/core';\nimport {Vector3, Matrix4} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport type {LoaderOptions, LoaderContext} from '@loaders.gl/loader-utils';\nimport {ImageLoader} from '@loaders.gl/images';\nimport {DracoLoader, DracoMesh} from '@loaders.gl/draco';\nimport {BasisLoader, CompressedTextureLoader} from '@loaders.gl/textures';\n\nimport {\n I3STilesetHeader,\n I3STileHeader,\n FeatureAttribute,\n VertexAttribute,\n I3SMeshAttributes,\n I3SMeshAttribute,\n TileContentTexture,\n HeaderAttributeProperty,\n I3SMaterialDefinition\n} from '../../types';\nimport {getUrlWithToken} from '../utils/url-utils';\n\nimport {GL_TYPE_MAP, getConstructorForDataFormat, sizeOf, COORDINATE_SYSTEM} from './constants';\n\nconst scratchVector = new Vector3([0, 0, 0]);\n\nfunction getLoaderForTextureFormat(textureFormat?: 'jpg' | 'png' | 'ktx-etc2' | 'dds' | 'ktx2') {\n switch (textureFormat) {\n case 'ktx-etc2':\n case 'dds':\n return CompressedTextureLoader;\n case 'ktx2':\n return BasisLoader;\n case 'jpg':\n case 'png':\n default:\n return ImageLoader;\n }\n}\n\nconst I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';\n\nexport async function parseI3STileContent(\n arrayBuffer: ArrayBuffer,\n tile: I3STileHeader,\n tileset: I3STilesetHeader,\n options?: LoaderOptions,\n context?: LoaderContext\n) {\n tile.content = tile.content || {};\n tile.content.featureIds = tile.content.featureIds || null;\n\n tile.content.attributes = {};\n\n if (tile.textureUrl) {\n const url = getUrlWithToken(tile.textureUrl, options?.i3s?.token);\n const loader = getLoaderForTextureFormat(tile.textureFormat);\n const response = await fetch(url, options?.fetch as RequestInit);\n const arrayBuffer = await response.arrayBuffer();\n\n if (options?.i3s.decodeTextures) {\n if (loader === ImageLoader) {\n const options = {...tile.textureLoaderOptions, image: {type: 'data'}};\n try {\n // @ts-ignore context must be defined\n // Image constructor is not supported in worker thread.\n // Do parsing image data on the main thread by using context to avoid worker issues.\n tile.content.texture = await context.parse(arrayBuffer, options);\n } catch (e) {\n // context object is different between worker and node.js conversion script.\n // To prevent error we parse data in ordinary way if it is not parsed by using context.\n tile.content.texture = await parse(arrayBuffer, loader, options);\n }\n } else if (loader === CompressedTextureLoader || loader === BasisLoader) {\n let texture = await load(arrayBuffer, loader, tile.textureLoaderOptions);\n if (loader === BasisLoader) {\n texture = texture[0];\n }\n tile.content.texture = {\n compressed: true,\n mipmaps: false,\n width: texture[0].width,\n height: texture[0].height,\n data: texture\n };\n }\n } else {\n tile.content.texture = arrayBuffer;\n }\n }\n\n tile.content.material = makePbrMaterial(tile.materialDefinition, tile.content.texture);\n if (tile.content.material) {\n tile.content.texture = null;\n }\n\n return await parseI3SNodeGeometry(arrayBuffer, tile, tileset, options);\n}\n\n/* eslint-disable max-statements */\nasync function parseI3SNodeGeometry(\n arrayBuffer: ArrayBuffer,\n tile: I3STileHeader,\n tileset: I3STilesetHeader,\n options?: LoaderOptions\n) {\n if (!tile.content) {\n return tile;\n }\n\n const content = tile.content;\n const contentByteLength = arrayBuffer.byteLength;\n let attributes: I3SMeshAttributes;\n let vertexCount: number;\n let byteOffset: number = 0;\n let featureCount: number = 0;\n let indices: TypedArray | undefined;\n\n if (tile.isDracoGeometry) {\n const decompressedGeometry: DracoMesh = await parse(arrayBuffer, DracoLoader, {\n draco: {\n attributeNameEntry: I3S_ATTRIBUTE_TYPE\n }\n });\n // @ts-expect-error\n vertexCount = decompressedGeometry.header.vertexCount;\n indices = decompressedGeometry.indices?.value;\n const {\n POSITION,\n NORMAL,\n COLOR_0,\n TEXCOORD_0,\n ['feature-index']: featureIndex,\n ['uv-region']: uvRegion\n } = decompressedGeometry.attributes;\n\n attributes = {\n position: POSITION,\n normal: NORMAL,\n color: COLOR_0,\n uv0: TEXCOORD_0,\n uvRegion,\n id: featureIndex\n };\n\n updateAttributesMetadata(attributes, decompressedGeometry);\n\n const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);\n\n if (featureIds) {\n flattenFeatureIdsByFeatureIndices(attributes, featureIds);\n }\n } else {\n const {\n vertexAttributes,\n ordering: attributesOrder,\n featureAttributes,\n featureAttributeOrder\n } = tileset.store.defaultGeometrySchema;\n // First 8 bytes reserved for header (vertexCount and featureCount)\n const headers = parseHeaders(tileset, arrayBuffer);\n byteOffset = headers.byteOffset;\n vertexCount = headers.vertexCount;\n featureCount = headers.featureCount;\n // Getting vertex attributes such as positions, normals, colors, etc...\n const {attributes: normalizedVertexAttributes, byteOffset: offset} = normalizeAttributes(\n arrayBuffer,\n byteOffset,\n vertexAttributes,\n vertexCount,\n attributesOrder\n );\n\n // Getting feature attributes such as featureIds and faceRange\n const {attributes: normalizedFeatureAttributes} = normalizeAttributes(\n arrayBuffer,\n offset,\n featureAttributes,\n featureCount,\n featureAttributeOrder\n );\n\n flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);\n attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);\n }\n\n if (\n !options?.i3s?.coordinateSystem ||\n options.i3s.coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS\n ) {\n const enuMatrix = parsePositions(attributes.position, tile);\n content.modelMatrix = enuMatrix.invert();\n content.coordinateSystem = COORDINATE_SYSTEM.METER_OFFSETS;\n } else {\n content.modelMatrix = getModelMatrix(attributes.position);\n content.coordinateSystem = COORDINATE_SYSTEM.LNGLAT_OFFSETS;\n }\n\n content.attributes = {\n positions: attributes.position,\n normals: attributes.normal,\n colors: normalizeAttribute(attributes.color), // Normalize from UInt8\n texCoords: attributes.uv0,\n uvRegions: normalizeAttribute(attributes.uvRegion) // Normalize from UInt16\n };\n content.indices = indices || null;\n\n if (attributes.id && attributes.id.value) {\n tile.content.featureIds = attributes.id.value;\n }\n\n // Remove undefined attributes\n for (const attributeIndex in content.attributes) {\n if (!content.attributes[attributeIndex]) {\n delete content.attributes[attributeIndex];\n }\n }\n\n content.vertexCount = vertexCount;\n content.byteLength = contentByteLength;\n\n return tile;\n}\n\n/**\n * Update attributes with metadata from decompressed geometry.\n * @param decompressedGeometry\n * @param attributes\n */\nfunction updateAttributesMetadata(\n attributes: I3SMeshAttributes,\n decompressedGeometry: DracoMesh\n): void {\n for (const key in decompressedGeometry.loaderData.attributes) {\n const dracoAttribute = decompressedGeometry.loaderData.attributes[key];\n\n switch (dracoAttribute.name) {\n case 'POSITION':\n attributes.position.metadata = dracoAttribute.metadata;\n break;\n case 'feature-index':\n attributes.id.metadata = dracoAttribute.metadata;\n break;\n default:\n break;\n }\n }\n}\n\n/**\n * Do concatenation of attribute objects.\n * Done as separate fucntion to avoid ts errors.\n * @param normalizedVertexAttributes\n * @param normalizedFeatureAttributes\n * @returns - result of attributes concatenation.\n */\nfunction concatAttributes(\n normalizedVertexAttributes: I3SMeshAttributes,\n normalizedFeatureAttributes: I3SMeshAttributes\n): I3SMeshAttributes {\n return {...normalizedVertexAttributes, ...normalizedFeatureAttributes};\n}\n\n/**\n * Normalize attribute to range [0..1] . Eg. convert colors buffer from [255,255,255,255] to [1,1,1,1]\n * @param attribute - geometry attribute\n * @returns - geometry attribute in right format\n */\nfunction normalizeAttribute(attribute: I3SMeshAttribute): I3SMeshAttribute {\n if (!attribute) {\n return attribute;\n }\n attribute.normalized = true;\n return attribute;\n}\n\nfunction parseHeaders(tileset: I3STilesetHeader, arrayBuffer: ArrayBuffer) {\n let byteOffset = 0;\n // First 8 bytes reserved for header (vertexCount and featurecount)\n let vertexCount = 0;\n let featureCount = 0;\n for (const {property, type} of tileset.store.defaultGeometrySchema.header) {\n const TypedArrayTypeHeader = getConstructorForDataFormat(type);\n switch (property) {\n case HeaderAttributeProperty.vertexCount:\n vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];\n byteOffset += sizeOf(type);\n break;\n case HeaderAttributeProperty.featureCount:\n featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];\n byteOffset += sizeOf(type);\n break;\n default:\n break;\n }\n }\n\n return {\n vertexCount,\n featureCount,\n byteOffset\n };\n}\n\n/* eslint-enable max-statements */\n\nfunction normalizeAttributes(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n vertexAttributes: VertexAttribute | FeatureAttribute,\n attributeCount: number,\n attributesOrder: string[]\n) {\n const attributes: I3SMeshAttributes = {};\n\n // the order of attributes depend on the order being added to the vertexAttributes object\n for (const attribute of attributesOrder) {\n if (vertexAttributes[attribute]) {\n const {valueType, valuesPerElement}: {valueType: string; valuesPerElement: number} =\n vertexAttributes[attribute];\n // protect from arrayBuffer read overunns by NOT assuming node has regions always even though its declared in defaultGeometrySchema.\n // In i3s 1.6: client is required to decide that based on ./shared resource of the node (materialDefinitions.[Mat_id].params.vertexRegions == true)\n // In i3s 1.7 the property has been rolled into the 3d scene layer json/node pages.\n // Code below does not account when the bytelength is actually bigger than\n // the calculated value (b\\c the tile potentially could have mesh segmentation information).\n // In those cases tiles without regions could fail or have garbage values.\n if (\n byteOffset + attributeCount * valuesPerElement * sizeOf(valueType) <=\n arrayBuffer.byteLength\n ) {\n const buffer = arrayBuffer.slice(byteOffset);\n let value: TypedArray;\n\n if (valueType === 'UInt64') {\n value = parseUint64Values(buffer, attributeCount * valuesPerElement, sizeOf(valueType));\n } else {\n const TypedArrayType = getConstructorForDataFormat(valueType);\n value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);\n }\n\n attributes[attribute] = {\n value,\n type: GL_TYPE_MAP[valueType],\n size: valuesPerElement\n };\n\n switch (attribute) {\n case 'color':\n attributes.color.normalized = true;\n break;\n case 'position':\n case 'region':\n case 'normal':\n default:\n }\n\n byteOffset = byteOffset + attributeCount * valuesPerElement * sizeOf(valueType);\n } else if (attribute !== 'uv0') {\n break;\n }\n }\n }\n\n return {attributes, byteOffset};\n}\n\n/**\n * Parse buffer to return array of uint64 values\n *\n * @param buffer\n * @param elementsCount\n * @returns 64-bit array of values until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Values(\n buffer: ArrayBuffer,\n elementsCount: number,\n attributeSize: number\n): Uint32Array {\n const values: number[] = [];\n const dataView = new DataView(buffer);\n let offset = 0;\n\n for (let index = 0; index < elementsCount; index++) {\n // split 64-bit number into two 32-bit parts\n const left = dataView.getUint32(offset, true);\n const right = dataView.getUint32(offset + 4, true);\n // combine the two 32-bit values\n const value = left + 2 ** 32 * right;\n\n values.push(value);\n offset += attributeSize;\n }\n\n return new Uint32Array(values);\n}\n\nfunction parsePositions(attribute: I3SMeshAttribute, tile: I3STileHeader): Matrix4 {\n const mbs = tile.mbs;\n const value = attribute.value;\n const metadata = attribute.metadata;\n const enuMatrix = new Matrix4();\n const cartographicOrigin = new Vector3(mbs[0], mbs[1], mbs[2]);\n const cartesianOrigin = new Vector3();\n Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin, enuMatrix);\n attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);\n\n return enuMatrix;\n}\n\n/**\n * Converts position coordinates to absolute cartesian coordinates\n * @param vertices - \"position\" attribute data\n * @param metadata - When the geometry is DRACO compressed, contain position attribute's metadata\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/compressedAttributes.cmn.md\n * @param cartographicOrigin - Cartographic origin coordinates\n * @returns - converted \"position\" data\n */\nfunction offsetsToCartesians(\n vertices: number[] | TypedArray,\n metadata: any = {},\n cartographicOrigin: Vector3\n): Float64Array {\n const positions = new Float64Array(vertices.length);\n const scaleX = (metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double) || 1;\n const scaleY = (metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double) || 1;\n for (let i = 0; i < positions.length; i += 3) {\n positions[i] = vertices[i] * scaleX + cartographicOrigin.x;\n positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;\n positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;\n }\n\n for (let i = 0; i < positions.length; i += 3) {\n // @ts-ignore\n Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);\n positions[i] = scratchVector.x;\n positions[i + 1] = scratchVector.y;\n positions[i + 2] = scratchVector.z;\n }\n\n return positions;\n}\n\n/**\n * Get model matrix for loaded vertices\n * @param positions positions attribute\n * @returns Matrix4 - model matrix for geometry transformation\n */\nfunction getModelMatrix(positions: I3SMeshAttribute): Matrix4 {\n const metadata = positions.metadata;\n const scaleX: number = metadata?.['i3s-scale_x']?.double || 1;\n const scaleY: number = metadata?.['i3s-scale_y']?.double || 1;\n const modelMatrix = new Matrix4();\n modelMatrix[0] = scaleX;\n modelMatrix[5] = scaleY;\n return modelMatrix;\n}\n\n/**\n * Makes a glTF-compatible PBR material from an I3S material definition\n * @param materialDefinition - i3s material definition\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n * @param texture - texture image\n * @returns {object}\n */\nfunction makePbrMaterial(materialDefinition?: I3SMaterialDefinition, texture?: TileContentTexture) {\n let pbrMaterial;\n if (materialDefinition) {\n pbrMaterial = {\n ...materialDefinition,\n pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness\n ? {...materialDefinition.pbrMetallicRoughness}\n : {baseColorFactor: [255, 255, 255, 255]}\n };\n } else {\n pbrMaterial = {\n pbrMetallicRoughness: {}\n };\n if (texture) {\n pbrMaterial.pbrMetallicRoughness.baseColorTexture = {texCoord: 0};\n } else {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = [255, 255, 255, 255];\n }\n }\n\n // Set default 0.25 per spec https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n pbrMaterial.alphaCutoff = pbrMaterial.alphaCutoff || 0.25;\n\n if (pbrMaterial.alphaMode) {\n // I3S contain alphaMode in lowerCase\n pbrMaterial.alphaMode = pbrMaterial.alphaMode.toUpperCase();\n }\n\n // Convert colors from [255,255,255,255] to [1,1,1,1]\n if (pbrMaterial.emissiveFactor) {\n pbrMaterial.emissiveFactor = convertColorFormat(pbrMaterial.emissiveFactor);\n }\n if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(\n pbrMaterial.pbrMetallicRoughness.baseColorFactor\n );\n }\n\n if (texture) {\n setMaterialTexture(pbrMaterial, texture);\n }\n\n return pbrMaterial;\n}\n\n/**\n * Convert color from [255,255,255,255] to [1,1,1,1]\n * @param colorFactor - color array\n * @returns - new color array\n */\nfunction convertColorFormat(colorFactor: number[]): number[] {\n const normalizedColor = [...colorFactor];\n for (let index = 0; index < colorFactor.length; index++) {\n normalizedColor[index] = colorFactor[index] / 255;\n }\n return normalizedColor;\n}\n\n/**\n * Set texture in PBR material\n * @param {object} material - i3s material definition\n * @param image - texture image\n * @returns\n */\nfunction setMaterialTexture(material, image: TileContentTexture): void {\n const texture = {source: {image}};\n // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of\n // properties defined in materialDefinition\n if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {\n material.pbrMetallicRoughness.baseColorTexture = {\n ...material.pbrMetallicRoughness.baseColorTexture,\n texture\n };\n } else if (material.emissiveTexture) {\n material.emissiveTexture = {...material.emissiveTexture, texture};\n } else if (\n material.pbrMetallicRoughness &&\n material.pbrMetallicRoughness.metallicRoughnessTexture\n ) {\n material.pbrMetallicRoughness.metallicRoughnessTexture = {\n ...material.pbrMetallicRoughness.metallicRoughnessTexture,\n texture\n };\n } else if (material.normalTexture) {\n material.normalTexture = {...material.normalTexture, texture};\n } else if (material.occlusionTexture) {\n material.occlusionTexture = {...material.occlusionTexture, texture};\n }\n}\n\n/**\n * Flatten feature ids using face ranges\n * @param normalizedFeatureAttributes\n * @returns\n */\nfunction flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes: I3SMeshAttributes): void {\n const {id, faceRange} = normalizedFeatureAttributes;\n\n if (!id || !faceRange) {\n return;\n }\n\n const featureIds = id.value;\n const range = faceRange.value;\n const featureIdsLength = range[range.length - 1] + 1;\n const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);\n\n let featureIndex = 0;\n let startIndex = 0;\n\n for (let index = 1; index < range.length; index += 2) {\n const fillId = Number(featureIds[featureIndex]);\n const endValue = range[index];\n const prevValue = range[index - 1];\n const trianglesCount = endValue - prevValue + 1;\n const endIndex = startIndex + trianglesCount * 3;\n\n orderedFeatureIndices.fill(fillId, startIndex, endIndex);\n\n featureIndex++;\n startIndex = endIndex;\n }\n\n normalizedFeatureAttributes.id.value = orderedFeatureIndices;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param attributes\n * @param featureIds\n * @returns\n */\nfunction flattenFeatureIdsByFeatureIndices(\n attributes: I3SMeshAttributes,\n featureIds: Int32Array\n): void {\n const featureIndices = attributes.id.value;\n const result = new Float32Array(featureIndices.length);\n\n for (let index = 0; index < featureIndices.length; index++) {\n result[index] = featureIds[featureIndices[index]];\n }\n\n attributes.id.value = result;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param featureIndex\n * @returns\n */\nfunction getFeatureIdsFromFeatureIndexMetadata(\n featureIndex: I3SMeshAttribute\n): Int32Array | undefined {\n return featureIndex?.metadata?.['i3s-feature-ids']?.intArray;\n}\n"],"file":"parse-i3s-tile-content.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/parsers/parse-i3s-tile-content.ts"],"names":["scratchVector","Vector3","getLoaderForTextureFormat","textureFormat","CompressedTextureLoader","BasisLoader","ImageLoader","I3S_ATTRIBUTE_TYPE","defaultContent","attributes","indices","featureIds","vertexCount","modelMatrix","Matrix4","coordinateSystem","byteLength","texture","parseI3STileContent","arrayBuffer","tileOptions","tilesetOptions","options","context","content","textureUrl","url","i3s","token","loader","fetch","response","decodeTextures","textureLoaderOptions","image","type","parse","compressed","mipmaps","width","height","data","material","makePbrMaterial","materialDefinition","parseI3SNodeGeometry","contentByteLength","byteOffset","featureCount","isDracoGeometry","DracoLoader","draco","attributeNameEntry","decompressedGeometry","header","value","POSITION","NORMAL","COLOR_0","TEXCOORD_0","featureIndex","uvRegion","position","normal","color","uv0","id","updateAttributesMetadata","getFeatureIdsFromFeatureIndexMetadata","flattenFeatureIdsByFeatureIndices","store","defaultGeometrySchema","vertexAttributes","attributesOrder","ordering","featureAttributes","featureAttributeOrder","headers","parseHeaders","normalizeAttributes","normalizedVertexAttributes","offset","normalizedFeatureAttributes","flattenFeatureIdsByFaceRanges","concatAttributes","COORDINATE_SYSTEM","METER_OFFSETS","enuMatrix","parsePositions","invert","getModelMatrix","LNGLAT_OFFSETS","positions","normals","colors","normalizeAttribute","texCoords","uvRegions","attributeIndex","key","loaderData","dracoAttribute","name","metadata","attribute","normalized","property","TypedArrayTypeHeader","HeaderAttributeProperty","attributeCount","valueType","valuesPerElement","buffer","slice","parseUint64Values","TypedArrayType","GL_TYPE_MAP","size","elementsCount","attributeSize","values","dataView","DataView","index","left","getUint32","right","push","Uint32Array","mbs","cartographicOrigin","cartesianOrigin","Ellipsoid","WGS84","cartographicToCartesian","eastNorthUpToFixedFrame","offsetsToCartesians","vertices","Float64Array","length","scaleX","double","scaleY","i","x","y","z","subarray","pbrMaterial","pbrMetallicRoughness","baseColorFactor","baseColorTexture","texCoord","alphaCutoff","alphaMode","toUpperCase","emissiveFactor","convertColorFormat","setMaterialTexture","colorFactor","normalizedColor","source","emissiveTexture","metallicRoughnessTexture","normalTexture","occlusionTexture","faceRange","range","featureIdsLength","orderedFeatureIndices","startIndex","fillId","Number","endValue","prevValue","trianglesCount","endIndex","fill","featureIndices","result","Float32Array","intArray"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AAYA;;AAEA;;;;;;;;;;;;AAEA,IAAMA,aAAa,GAAG,IAAIC,cAAJ,CAAY,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAZ,CAAtB;;AAEA,SAASC,yBAAT,CAAmCC,aAAnC,EAAgG;AAC9F,UAAQA,aAAR;AACE,SAAK,UAAL;AACA,SAAK,KAAL;AACE,aAA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C;AACA,MAAM4H,MAAM,GAAG,IAAIC,YAAJ,CAAiBF,cAAc,CAACvC,MAAhC,CAAf;;AAEA,OAAK,IAAIhB,KAAK,GAAG,CAAjB,EAAoBA,KAAK,GAAGuD,cAAc,CAACvC,MAA3C,EAAmDhB,KAAK,EAAxD,EAA4D;AAC1DwD,IAAAA,MAAM,CAACxD,KAAD,CAAN,GAAgBhH,UAAU,CAACuK,cAAc,CAACvD,KAAD,CAAf,CAA1B;AACD;;AAEDlH,EAAAA,UAAU,CAACyD,EAAX,CAAcX,KAAd,GAAsB4H,MAAtB;AACD;;AAOD,SAAS/G,qCAAT,CACER,YADF,EAE0B;AAAA;;AACxB,SAAOA,YAAP,aAAOA,YAAP,gDAAOA,YAAY,CAAE2C,QAArB,oFAAO,sBAAyB,iBAAzB,CAAP,2DAAO,uBAA6C8E,QAApD;AACD","sourcesContent":["import type {TypedArray} from '@loaders.gl/schema';\nimport {load, parse} from '@loaders.gl/core';\nimport {Vector3, Matrix4} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport type {LoaderOptions, LoaderContext} from '@loaders.gl/loader-utils';\nimport {ImageLoader} from '@loaders.gl/images';\nimport {DracoLoader, DracoMesh} from '@loaders.gl/draco';\nimport {BasisLoader, CompressedTextureLoader} from '@loaders.gl/textures';\n\nimport {\n FeatureAttribute,\n VertexAttribute,\n I3SMeshAttributes,\n I3SMeshAttribute,\n TileContentTexture,\n HeaderAttributeProperty,\n I3SMaterialDefinition,\n I3STileContent,\n I3STileOptions,\n I3STilesetOptions\n} from '../../types';\nimport {getUrlWithToken} from '../utils/url-utils';\n\nimport {GL_TYPE_MAP, getConstructorForDataFormat, sizeOf, COORDINATE_SYSTEM} from './constants';\n\nconst scratchVector = new Vector3([0, 0, 0]);\n\nfunction getLoaderForTextureFormat(textureFormat?: 'jpg' | 'png' | 'ktx-etc2' | 'dds' | 'ktx2') {\n switch (textureFormat) {\n case 'ktx-etc2':\n case 'dds':\n return CompressedTextureLoader;\n case 'ktx2':\n return BasisLoader;\n case 'jpg':\n case 'png':\n default:\n return ImageLoader;\n }\n}\n\nconst I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';\n\nconst defaultContent: I3STileContent = {\n attributes: {},\n indices: null,\n featureIds: [],\n vertexCount: 0,\n modelMatrix: new Matrix4(),\n coordinateSystem: 0,\n byteLength: 0,\n texture: null\n};\n\nexport async function parseI3STileContent(\n arrayBuffer: ArrayBuffer,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: LoaderOptions,\n context?: LoaderContext\n): Promise<I3STileContent> {\n const content: I3STileContent = defaultContent;\n\n if (tileOptions.textureUrl) {\n const url = getUrlWithToken(tileOptions.textureUrl, options?.i3s?.token);\n const loader = getLoaderForTextureFormat(tileOptions.textureFormat);\n const response = await fetch(url, options?.fetch as RequestInit);\n const arrayBuffer = await response.arrayBuffer();\n\n if (options?.i3s.decodeTextures) {\n if (loader === ImageLoader) {\n const options = {...tileOptions.textureLoaderOptions, image: {type: 'data'}};\n try {\n // @ts-ignore context must be defined\n // Image constructor is not supported in worker thread.\n // Do parsing image data on the main thread by using context to avoid worker issues.\n content.texture = await context.parse(arrayBuffer, options);\n } catch (e) {\n // context object is different between worker and node.js conversion script.\n // To prevent error we parse data in ordinary way if it is not parsed by using context.\n content.texture = await parse(arrayBuffer, loader, options);\n }\n } else if (loader === CompressedTextureLoader || loader === BasisLoader) {\n let texture = await load(arrayBuffer, loader, tileOptions.textureLoaderOptions);\n if (loader === BasisLoader) {\n texture = texture[0];\n }\n content.texture = {\n compressed: true,\n mipmaps: false,\n width: texture[0].width,\n height: texture[0].height,\n data: texture\n };\n }\n } else {\n content.texture = arrayBuffer;\n }\n }\n\n content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);\n if (content.material) {\n content.texture = null;\n }\n\n return await parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);\n}\n\n/* eslint-disable max-statements */\nasync function parseI3SNodeGeometry(\n arrayBuffer: ArrayBuffer,\n content: I3STileContent,\n tileOptions: I3STileOptions,\n tilesetOptions: I3STilesetOptions,\n options?: LoaderOptions\n): Promise<I3STileContent> {\n const contentByteLength = arrayBuffer.byteLength;\n let attributes: I3SMeshAttributes;\n let vertexCount: number;\n let byteOffset: number = 0;\n let featureCount: number = 0;\n let indices: TypedArray | undefined;\n\n if (tileOptions.isDracoGeometry) {\n const decompressedGeometry: DracoMesh = await parse(arrayBuffer, DracoLoader, {\n draco: {\n attributeNameEntry: I3S_ATTRIBUTE_TYPE\n }\n });\n // @ts-expect-error\n vertexCount = decompressedGeometry.header.vertexCount;\n indices = decompressedGeometry.indices?.value;\n const {\n POSITION,\n NORMAL,\n COLOR_0,\n TEXCOORD_0,\n ['feature-index']: featureIndex,\n ['uv-region']: uvRegion\n } = decompressedGeometry.attributes;\n\n attributes = {\n position: POSITION,\n normal: NORMAL,\n color: COLOR_0,\n uv0: TEXCOORD_0,\n uvRegion,\n id: featureIndex\n };\n\n updateAttributesMetadata(attributes, decompressedGeometry);\n\n const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);\n\n if (featureIds) {\n flattenFeatureIdsByFeatureIndices(attributes, featureIds);\n }\n } else {\n const {\n vertexAttributes,\n ordering: attributesOrder,\n featureAttributes,\n featureAttributeOrder\n } = tilesetOptions.store.defaultGeometrySchema;\n // First 8 bytes reserved for header (vertexCount and featureCount)\n const headers = parseHeaders(arrayBuffer, tilesetOptions);\n byteOffset = headers.byteOffset;\n vertexCount = headers.vertexCount;\n featureCount = headers.featureCount;\n // Getting vertex attributes such as positions, normals, colors, etc...\n const {attributes: normalizedVertexAttributes, byteOffset: offset} = normalizeAttributes(\n arrayBuffer,\n byteOffset,\n vertexAttributes,\n vertexCount,\n attributesOrder\n );\n\n // Getting feature attributes such as featureIds and faceRange\n const {attributes: normalizedFeatureAttributes} = normalizeAttributes(\n arrayBuffer,\n offset,\n featureAttributes,\n featureCount,\n featureAttributeOrder\n );\n\n flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);\n attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);\n }\n\n if (\n !options?.i3s?.coordinateSystem ||\n options.i3s.coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS\n ) {\n const enuMatrix = parsePositions(attributes.position, tileOptions);\n content.modelMatrix = enuMatrix.invert();\n content.coordinateSystem = COORDINATE_SYSTEM.METER_OFFSETS;\n } else {\n content.modelMatrix = getModelMatrix(attributes.position);\n content.coordinateSystem = COORDINATE_SYSTEM.LNGLAT_OFFSETS;\n }\n\n content.attributes = {\n positions: attributes.position,\n normals: attributes.normal,\n colors: normalizeAttribute(attributes.color), // Normalize from UInt8\n texCoords: attributes.uv0,\n uvRegions: normalizeAttribute(attributes.uvRegion) // Normalize from UInt16\n };\n content.indices = indices || null;\n\n if (attributes.id && attributes.id.value) {\n content.featureIds = attributes.id.value;\n }\n\n // Remove undefined attributes\n for (const attributeIndex in content.attributes) {\n if (!content.attributes[attributeIndex]) {\n delete content.attributes[attributeIndex];\n }\n }\n\n content.vertexCount = vertexCount;\n content.byteLength = contentByteLength;\n\n return content;\n}\n\n/**\n * Update attributes with metadata from decompressed geometry.\n * @param decompressedGeometry\n * @param attributes\n */\nfunction updateAttributesMetadata(\n attributes: I3SMeshAttributes,\n decompressedGeometry: DracoMesh\n): void {\n for (const key in decompressedGeometry.loaderData.attributes) {\n const dracoAttribute = decompressedGeometry.loaderData.attributes[key];\n\n switch (dracoAttribute.name) {\n case 'POSITION':\n attributes.position.metadata = dracoAttribute.metadata;\n break;\n case 'feature-index':\n attributes.id.metadata = dracoAttribute.metadata;\n break;\n default:\n break;\n }\n }\n}\n\n/**\n * Do concatenation of attribute objects.\n * Done as separate fucntion to avoid ts errors.\n * @param normalizedVertexAttributes\n * @param normalizedFeatureAttributes\n * @returns - result of attributes concatenation.\n */\nfunction concatAttributes(\n normalizedVertexAttributes: I3SMeshAttributes,\n normalizedFeatureAttributes: I3SMeshAttributes\n): I3SMeshAttributes {\n return {...normalizedVertexAttributes, ...normalizedFeatureAttributes};\n}\n\n/**\n * Normalize attribute to range [0..1] . Eg. convert colors buffer from [255,255,255,255] to [1,1,1,1]\n * @param attribute - geometry attribute\n * @returns - geometry attribute in right format\n */\nfunction normalizeAttribute(attribute: I3SMeshAttribute): I3SMeshAttribute {\n if (!attribute) {\n return attribute;\n }\n attribute.normalized = true;\n return attribute;\n}\n\nfunction parseHeaders(arrayBuffer: ArrayBuffer, options: I3STilesetOptions) {\n let byteOffset = 0;\n // First 8 bytes reserved for header (vertexCount and featurecount)\n let vertexCount = 0;\n let featureCount = 0;\n for (const {property, type} of options.store.defaultGeometrySchema.header) {\n const TypedArrayTypeHeader = getConstructorForDataFormat(type);\n switch (property) {\n case HeaderAttributeProperty.vertexCount:\n vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];\n byteOffset += sizeOf(type);\n break;\n case HeaderAttributeProperty.featureCount:\n featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];\n byteOffset += sizeOf(type);\n break;\n default:\n break;\n }\n }\n\n return {\n vertexCount,\n featureCount,\n byteOffset\n };\n}\n\n/* eslint-enable max-statements */\n\nfunction normalizeAttributes(\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n vertexAttributes: VertexAttribute | FeatureAttribute,\n attributeCount: number,\n attributesOrder: string[]\n) {\n const attributes: I3SMeshAttributes = {};\n\n // the order of attributes depend on the order being added to the vertexAttributes object\n for (const attribute of attributesOrder) {\n if (vertexAttributes[attribute]) {\n const {valueType, valuesPerElement}: {valueType: string; valuesPerElement: number} =\n vertexAttributes[attribute];\n // protect from arrayBuffer read overunns by NOT assuming node has regions always even though its declared in defaultGeometrySchema.\n // In i3s 1.6: client is required to decide that based on ./shared resource of the node (materialDefinitions.[Mat_id].params.vertexRegions == true)\n // In i3s 1.7 the property has been rolled into the 3d scene layer json/node pages.\n // Code below does not account when the bytelength is actually bigger than\n // the calculated value (b\\c the tile potentially could have mesh segmentation information).\n // In those cases tiles without regions could fail or have garbage values.\n if (\n byteOffset + attributeCount * valuesPerElement * sizeOf(valueType) <=\n arrayBuffer.byteLength\n ) {\n const buffer = arrayBuffer.slice(byteOffset);\n let value: TypedArray;\n\n if (valueType === 'UInt64') {\n value = parseUint64Values(buffer, attributeCount * valuesPerElement, sizeOf(valueType));\n } else {\n const TypedArrayType = getConstructorForDataFormat(valueType);\n value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);\n }\n\n attributes[attribute] = {\n value,\n type: GL_TYPE_MAP[valueType],\n size: valuesPerElement\n };\n\n switch (attribute) {\n case 'color':\n attributes.color.normalized = true;\n break;\n case 'position':\n case 'region':\n case 'normal':\n default:\n }\n\n byteOffset = byteOffset + attributeCount * valuesPerElement * sizeOf(valueType);\n } else if (attribute !== 'uv0') {\n break;\n }\n }\n }\n\n return {attributes, byteOffset};\n}\n\n/**\n * Parse buffer to return array of uint64 values\n *\n * @param buffer\n * @param elementsCount\n * @returns 64-bit array of values until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Values(\n buffer: ArrayBuffer,\n elementsCount: number,\n attributeSize: number\n): Uint32Array {\n const values: number[] = [];\n const dataView = new DataView(buffer);\n let offset = 0;\n\n for (let index = 0; index < elementsCount; index++) {\n // split 64-bit number into two 32-bit parts\n const left = dataView.getUint32(offset, true);\n const right = dataView.getUint32(offset + 4, true);\n // combine the two 32-bit values\n const value = left + 2 ** 32 * right;\n\n values.push(value);\n offset += attributeSize;\n }\n\n return new Uint32Array(values);\n}\n\nfunction parsePositions(attribute: I3SMeshAttribute, options: I3STileOptions): Matrix4 {\n const mbs = options.mbs;\n const value = attribute.value;\n const metadata = attribute.metadata;\n const enuMatrix = new Matrix4();\n const cartographicOrigin = new Vector3(mbs[0], mbs[1], mbs[2]);\n const cartesianOrigin = new Vector3();\n Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);\n Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin, enuMatrix);\n attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);\n\n return enuMatrix;\n}\n\n/**\n * Converts position coordinates to absolute cartesian coordinates\n * @param vertices - \"position\" attribute data\n * @param metadata - When the geometry is DRACO compressed, contain position attribute's metadata\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/compressedAttributes.cmn.md\n * @param cartographicOrigin - Cartographic origin coordinates\n * @returns - converted \"position\" data\n */\nfunction offsetsToCartesians(\n vertices: number[] | TypedArray,\n metadata: any = {},\n cartographicOrigin: Vector3\n): Float64Array {\n const positions = new Float64Array(vertices.length);\n const scaleX = (metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double) || 1;\n const scaleY = (metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double) || 1;\n for (let i = 0; i < positions.length; i += 3) {\n positions[i] = vertices[i] * scaleX + cartographicOrigin.x;\n positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;\n positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;\n }\n\n for (let i = 0; i < positions.length; i += 3) {\n // @ts-ignore\n Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);\n positions[i] = scratchVector.x;\n positions[i + 1] = scratchVector.y;\n positions[i + 2] = scratchVector.z;\n }\n\n return positions;\n}\n\n/**\n * Get model matrix for loaded vertices\n * @param positions positions attribute\n * @returns Matrix4 - model matrix for geometry transformation\n */\nfunction getModelMatrix(positions: I3SMeshAttribute): Matrix4 {\n const metadata = positions.metadata;\n const scaleX: number = metadata?.['i3s-scale_x']?.double || 1;\n const scaleY: number = metadata?.['i3s-scale_y']?.double || 1;\n const modelMatrix = new Matrix4();\n modelMatrix[0] = scaleX;\n modelMatrix[5] = scaleY;\n return modelMatrix;\n}\n\n/**\n * Makes a glTF-compatible PBR material from an I3S material definition\n * @param materialDefinition - i3s material definition\n * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n * @param texture - texture image\n * @returns {object}\n */\nfunction makePbrMaterial(materialDefinition?: I3SMaterialDefinition, texture?: TileContentTexture) {\n let pbrMaterial;\n if (materialDefinition) {\n pbrMaterial = {\n ...materialDefinition,\n pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness\n ? {...materialDefinition.pbrMetallicRoughness}\n : {baseColorFactor: [255, 255, 255, 255]}\n };\n } else {\n pbrMaterial = {\n pbrMetallicRoughness: {}\n };\n if (texture) {\n pbrMaterial.pbrMetallicRoughness.baseColorTexture = {texCoord: 0};\n } else {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = [255, 255, 255, 255];\n }\n }\n\n // Set default 0.25 per spec https://github.com/Esri/i3s-spec/blob/master/docs/1.7/materialDefinitions.cmn.md\n pbrMaterial.alphaCutoff = pbrMaterial.alphaCutoff || 0.25;\n\n if (pbrMaterial.alphaMode) {\n // I3S contain alphaMode in lowerCase\n pbrMaterial.alphaMode = pbrMaterial.alphaMode.toUpperCase();\n }\n\n // Convert colors from [255,255,255,255] to [1,1,1,1]\n if (pbrMaterial.emissiveFactor) {\n pbrMaterial.emissiveFactor = convertColorFormat(pbrMaterial.emissiveFactor);\n }\n if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {\n pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(\n pbrMaterial.pbrMetallicRoughness.baseColorFactor\n );\n }\n\n if (texture) {\n setMaterialTexture(pbrMaterial, texture);\n }\n\n return pbrMaterial;\n}\n\n/**\n * Convert color from [255,255,255,255] to [1,1,1,1]\n * @param colorFactor - color array\n * @returns - new color array\n */\nfunction convertColorFormat(colorFactor: number[]): number[] {\n const normalizedColor = [...colorFactor];\n for (let index = 0; index < colorFactor.length; index++) {\n normalizedColor[index] = colorFactor[index] / 255;\n }\n return normalizedColor;\n}\n\n/**\n * Set texture in PBR material\n * @param {object} material - i3s material definition\n * @param image - texture image\n * @returns\n */\nfunction setMaterialTexture(material, image: TileContentTexture): void {\n const texture = {source: {image}};\n // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of\n // properties defined in materialDefinition\n if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {\n material.pbrMetallicRoughness.baseColorTexture = {\n ...material.pbrMetallicRoughness.baseColorTexture,\n texture\n };\n } else if (material.emissiveTexture) {\n material.emissiveTexture = {...material.emissiveTexture, texture};\n } else if (\n material.pbrMetallicRoughness &&\n material.pbrMetallicRoughness.metallicRoughnessTexture\n ) {\n material.pbrMetallicRoughness.metallicRoughnessTexture = {\n ...material.pbrMetallicRoughness.metallicRoughnessTexture,\n texture\n };\n } else if (material.normalTexture) {\n material.normalTexture = {...material.normalTexture, texture};\n } else if (material.occlusionTexture) {\n material.occlusionTexture = {...material.occlusionTexture, texture};\n }\n}\n\n/**\n * Flatten feature ids using face ranges\n * @param normalizedFeatureAttributes\n * @returns\n */\nfunction flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes: I3SMeshAttributes): void {\n const {id, faceRange} = normalizedFeatureAttributes;\n\n if (!id || !faceRange) {\n return;\n }\n\n const featureIds = id.value;\n const range = faceRange.value;\n const featureIdsLength = range[range.length - 1] + 1;\n const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);\n\n let featureIndex = 0;\n let startIndex = 0;\n\n for (let index = 1; index < range.length; index += 2) {\n const fillId = Number(featureIds[featureIndex]);\n const endValue = range[index];\n const prevValue = range[index - 1];\n const trianglesCount = endValue - prevValue + 1;\n const endIndex = startIndex + trianglesCount * 3;\n\n orderedFeatureIndices.fill(fillId, startIndex, endIndex);\n\n featureIndex++;\n startIndex = endIndex;\n }\n\n normalizedFeatureAttributes.id.value = orderedFeatureIndices;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param attributes\n * @param featureIds\n * @returns\n */\nfunction flattenFeatureIdsByFeatureIndices(\n attributes: I3SMeshAttributes,\n featureIds: Int32Array\n): void {\n const featureIndices = attributes.id.value;\n const result = new Float32Array(featureIndices.length);\n\n for (let index = 0; index < featureIndices.length; index++) {\n result[index] = featureIds[featureIndices[index]];\n }\n\n attributes.id.value = result;\n}\n\n/**\n * Flatten feature ids using featureIndices\n * @param featureIndex\n * @returns\n */\nfunction getFeatureIdsFromFeatureIndexMetadata(\n featureIndex: I3SMeshAttribute\n): Int32Array | undefined {\n return featureIndex?.metadata?.['i3s-feature-ids']?.intArray;\n}\n"],"file":"parse-i3s-tile-content.js"}
|
|
@@ -33,7 +33,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
33
33
|
|
|
34
34
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
35
35
|
|
|
36
|
-
function normalizeTileData(tile,
|
|
36
|
+
function normalizeTileData(tile, context) {
|
|
37
37
|
var url = context.url || '';
|
|
38
38
|
var contentUrl;
|
|
39
39
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/parsers/parse-i3s.ts"],"names":["normalizeTileData","tile","
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/parsers/parse-i3s.ts"],"names":["normalizeTileData","tile","context","url","contentUrl","geometryData","href","textureUrl","textureData","attributeUrls","attributeData","normalizeTileNonUrlData","isDracoGeometry","boundingVolume","mbs","sphere","Ellipsoid","WGS84","cartographicToCartesian","slice","obb","box","center","halfSize","quaternion","OrientedBoundingBox","fromCenterHalfSizeQuaternion","boundingSphere","getBoundingSphere","radius","lodMetricType","lodSelection","metricType","lodMetricValue","maxError","transformMatrix","transform","type","TILE_TYPE","MESH","refine","TILE_REFINEMENT","REPLACE","normalizeTilesetData","tileset","options","nodePages","nodePagesTile","I3SNodePagesTiles","root","formTileFromNodePages","rootNodeUrl","i3s","token","loader","loadContent","isTileHeader","isTileset","basePath","TILESET_TYPE","I3S"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAUO,SAASA,iBAAT,CAA2BC,IAA3B,EAAuDC,OAAvD,EAA8F;AACnG,MAAMC,GAAW,GAAGD,OAAO,CAACC,GAAR,IAAe,EAAnC;AACA,MAAIC,UAAJ;;AACA,MAAIH,IAAI,CAACI,YAAT,EAAuB;AACrBD,IAAAA,UAAU,aAAMD,GAAN,cAAaF,IAAI,CAACI,YAAL,CAAkB,CAAlB,EAAqBC,IAAlC,CAAV;AACD;;AAED,MAAIC,UAAJ;;AACA,MAAIN,IAAI,CAACO,WAAT,EAAsB;AACpBD,IAAAA,UAAU,aAAMJ,GAAN,cAAaF,IAAI,CAACO,WAAL,CAAiB,CAAjB,EAAoBF,IAAjC,CAAV;AACD;;AAED,MAAIG,aAAJ;;AACA,MAAIR,IAAI,CAACS,aAAT,EAAwB;AACtBD,IAAAA,aAAa,GAAG,yCAA0BN,GAA1B,EAA+BF,IAA/B,CAAhB;AACD;;AAED,SAAOU,uBAAuB,iCACzBV,IADyB;AAE5BE,IAAAA,GAAG,EAAHA,GAF4B;AAG5BC,IAAAA,UAAU,EAAVA,UAH4B;AAI5BG,IAAAA,UAAU,EAAVA,UAJ4B;AAK5BE,IAAAA,aAAa,EAAbA,aAL4B;AAM5BG,IAAAA,eAAe,EAAE;AANW,KAA9B;AAQD;;AAEM,SAASD,uBAAT,CAAiCV,IAAjC,EAA2E;AAAA;;AAChF,MAAMY,cAAmD,GAAG,EAA5D;AACA,MAAIC,GAAQ,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAf;;AACA,MAAIb,IAAI,CAACa,GAAT,EAAc;AACZA,IAAAA,GAAG,GAAGb,IAAI,CAACa,GAAX;AACAD,IAAAA,cAAc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IAAR,CAAanB,aAArC;AACAc,YAAAA,OAAO,CAACX,cAAR,GAAyBW,OAAO,CAACK,IAAR,CAAahB,cAAtC;;AAvBK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import {OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {load} from '@loaders.gl/core';\nimport {TILE_TYPE, TILE_REFINEMENT, TILESET_TYPE} from '@loaders.gl/tiles';\nimport I3SNodePagesTiles from '../helpers/i3s-nodepages-tiles';\nimport {generateTileAttributeUrls, getUrlWithToken} from '../utils/url-utils';\nimport {\n I3STilesetHeader,\n I3STileHeader,\n Mbs,\n I3SMinimalNodeData,\n Node3DIndexDocument\n} from '../../types';\nimport type {LoaderOptions, LoaderContext} from '@loaders.gl/loader-utils';\n\nexport function normalizeTileData(tile : Node3DIndexDocument, context: LoaderContext): I3STileHeader {\n const url: string = context.url || '';\n let contentUrl: string | undefined;\n if (tile.geometryData) {\n contentUrl = `${url}/${tile.geometryData[0].href}`;\n }\n\n let textureUrl: string | undefined;\n if (tile.textureData) {\n textureUrl = `${url}/${tile.textureData[0].href}`;\n }\n\n let attributeUrls: string[] | undefined;\n if (tile.attributeData) {\n attributeUrls = generateTileAttributeUrls(url, tile);\n }\n\n return normalizeTileNonUrlData({\n ...tile,\n url,\n contentUrl,\n textureUrl,\n attributeUrls,\n isDracoGeometry: false\n });\n}\n\nexport function normalizeTileNonUrlData(tile : I3SMinimalNodeData): I3STileHeader {\n const boundingVolume: {box?: number[]; sphere?: number[]} = {};\n let mbs: Mbs = [0, 0, 0, 1];\n if (tile.mbs) {\n mbs = tile.mbs;\n boundingVolume.sphere = [\n ...Ellipsoid.WGS84.cartographicToCartesian(tile.mbs.slice(0, 3)), // cartesian center of sphere\n tile.mbs[3] // radius of sphere\n ] as Mbs;\n } else if (tile.obb) {\n boundingVolume.box = [\n ...Ellipsoid.WGS84.cartographicToCartesian(tile.obb.center), // cartesian center of box\n ...tile.obb.halfSize, // halfSize\n ...tile.obb.quaternion // quaternion\n ];\n const obb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(\n boundingVolume.box.slice(0, 3),\n tile.obb.halfSize,\n tile.obb.quaternion\n );\n const boundingSphere = obb.getBoundingSphere();\n boundingVolume.sphere = [...boundingSphere.center , boundingSphere.radius] as Mbs;\n mbs = [...tile.obb.center, boundingSphere.radius] as Mbs;\n }\n\n const lodMetricType = tile.lodSelection?.[0].metricType;\n const lodMetricValue = tile.lodSelection?.[0].maxError;\n const transformMatrix = tile.transform;\n const type = TILE_TYPE.MESH;\n /**\n * I3S specification supports only REPLACE\n */\n const refine = TILE_REFINEMENT.REPLACE;\n\n return {...tile, mbs, boundingVolume, lodMetricType, lodMetricValue, transformMatrix, type, refine};\n}\n\nexport async function normalizeTilesetData(tileset : I3STilesetHeader, options : LoaderOptions, context: LoaderContext) {\n tileset.url = context.url;\n\n if (tileset.nodePages) {\n tileset.nodePagesTile = new I3SNodePagesTiles(tileset, options);\n tileset.root = tileset.nodePagesTile.formTileFromNodePages(0);\n } else {\n const rootNodeUrl = getUrlWithToken(`${tileset.url}/nodes/root`, options.i3s?.token);\n // eslint-disable-next-line no-use-before-define\n tileset.root = await load(rootNodeUrl, tileset.loader, {\n ...options,\n i3s: {\n ...options.i3s,\n loadContent: false, isTileHeader: true, isTileset: false}\n });\n }\n\n // base path that non-absolute paths in tileset are relative to.\n tileset.basePath = tileset.url;\n tileset.type = TILESET_TYPE.I3S;\n\n // populate from root node\n tileset.lodMetricType = tileset.root.lodMetricType;\n tileset.lodMetricValue = tileset.root.lodMetricValue;\n}\n"],"file":"parse-i3s.js"}
|