@loaders.gl/i3s 3.1.0-alpha.4 → 3.1.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +10364 -0
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/i3s-attribute-loader.js +89 -138
- package/dist/es5/i3s-attribute-loader.js.map +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +8 -36
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/es5/i3s-content-loader.js +10 -36
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +56 -176
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +8 -51
- package/dist/es5/i3s-node-page-loader.js.map +1 -1
- package/dist/es5/index.js +13 -5
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +172 -325
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/constants.js +71 -25
- package/dist/es5/lib/parsers/constants.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-attribute.js +34 -68
- package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +28 -59
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +314 -415
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +31 -70
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +4 -8
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
- package/dist/es5/lib/utils/url-utils.js +17 -14
- package/dist/es5/lib/utils/url-utils.js.map +1 -1
- package/dist/es5/types.js +19 -0
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/i3s-attribute-loader.js +44 -14
- package/dist/esm/i3s-attribute-loader.js.map +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/esm/i3s-content-loader.js +1 -1
- package/dist/esm/i3s-content-loader.js.map +1 -1
- package/dist/esm/i3s-loader.js +5 -2
- package/dist/esm/i3s-loader.js.map +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -1
- package/dist/esm/i3s-node-page-loader.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +3 -3
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/constants.js +55 -15
- package/dist/esm/lib/parsers/constants.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-attribute.js +9 -1
- package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js +3 -1
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +87 -61
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js +4 -4
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/esm/lib/utils/url-utils.js +3 -3
- package/dist/esm/lib/utils/url-utils.js.map +1 -1
- package/dist/esm/types.js +13 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/i3s-attribute-loader.d.ts +14 -0
- package/dist/i3s-attribute-loader.d.ts.map +1 -0
- package/dist/i3s-attribute-loader.js +177 -0
- package/dist/i3s-building-scene-layer-loader.d.ts +6 -0
- package/dist/i3s-building-scene-layer-loader.d.ts.map +1 -0
- package/dist/i3s-building-scene-layer-loader.js +26 -0
- package/dist/i3s-content-loader.d.ts +6 -0
- package/dist/i3s-content-loader.d.ts.map +1 -0
- package/dist/i3s-content-loader.js +28 -0
- package/dist/i3s-content-worker.js +7657 -2
- package/dist/i3s-loader.d.ts +6 -0
- package/dist/i3s-loader.d.ts.map +1 -0
- package/dist/i3s-loader.js +100 -0
- package/dist/i3s-node-page-loader.d.ts +6 -0
- package/dist/i3s-node-page-loader.d.ts.map +1 -0
- package/dist/i3s-node-page-loader.js +26 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts +73 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.d.ts.map +1 -0
- package/dist/lib/helpers/i3s-nodepages-tiles.js +231 -0
- package/dist/lib/parsers/constants.d.ts +56 -0
- package/dist/lib/parsers/constants.d.ts.map +1 -0
- package/dist/lib/parsers/constants.js +107 -0
- package/dist/lib/parsers/parse-i3s-attribute.d.ts +10 -0
- package/dist/lib/parsers/parse-i3s-attribute.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s-attribute.js +98 -0
- package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts +9 -0
- package/dist/lib/parsers/parse-i3s-building-scene-layer.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s-building-scene-layer.js +46 -0
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts +4 -0
- package/dist/lib/parsers/parse-i3s-tile-content.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s-tile-content.js +508 -0
- package/dist/lib/parsers/parse-i3s.d.ts +4 -0
- package/dist/lib/parsers/parse-i3s.d.ts.map +1 -0
- package/dist/lib/parsers/parse-i3s.js +84 -0
- package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts +2 -0
- package/dist/lib/utils/convert-i3s-obb-to-mbs.d.ts.map +1 -0
- package/dist/lib/utils/convert-i3s-obb-to-mbs.js +20 -0
- package/dist/lib/utils/url-utils.d.ts +22 -0
- package/dist/lib/utils/url-utils.d.ts.map +1 -0
- package/dist/lib/utils/url-utils.js +44 -0
- package/dist/types.d.ts +429 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/workers/i3s-content-worker.d.ts +2 -0
- package/dist/workers/i3s-content-worker.d.ts.map +1 -0
- package/dist/workers/i3s-content-worker.js +5 -0
- package/package.json +14 -12
- package/src/i3s-attribute-loader.ts +56 -19
- package/src/i3s-loader.ts +4 -1
- package/src/index.ts +1 -0
- package/src/lib/parsers/constants.ts +73 -18
- package/src/lib/parsers/parse-i3s-attribute.ts +19 -1
- package/src/lib/parsers/parse-i3s-building-scene-layer.ts +2 -1
- package/src/lib/parsers/parse-i3s-tile-content.ts +159 -109
- package/src/lib/utils/url-utils.ts +1 -1
- package/src/types.ts +153 -22
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
- package/dist/i3s-content-worker.js.map +0 -1
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.parseI3STileContent = parseI3STileContent;
|
|
9
7
|
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
-
|
|
18
8
|
var _core = require("@loaders.gl/core");
|
|
19
9
|
|
|
20
10
|
var _core2 = require("@math.gl/core");
|
|
@@ -31,271 +21,183 @@ var _urlUtils = require("../utils/url-utils");
|
|
|
31
21
|
|
|
32
22
|
var _constants = require("./constants");
|
|
33
23
|
|
|
34
|
-
|
|
24
|
+
const scratchVector = new _core2.Vector3([0, 0, 0]);
|
|
35
25
|
|
|
36
|
-
function
|
|
26
|
+
function getLoaderForTextureFormat(textureFormat) {
|
|
27
|
+
switch (textureFormat) {
|
|
28
|
+
case 'jpeg':
|
|
29
|
+
case 'png':
|
|
30
|
+
return _images.ImageLoader;
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
case 'ktx-etc2':
|
|
33
|
+
case 'dds':
|
|
34
|
+
return _textures.CompressedTextureLoader;
|
|
39
35
|
|
|
40
|
-
|
|
36
|
+
case 'ktx2':
|
|
37
|
+
return _textures.BasisLoader;
|
|
41
38
|
|
|
42
|
-
|
|
39
|
+
default:
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
var FORMAT_LOADER_MAP = {
|
|
46
|
-
jpeg: _images.ImageLoader,
|
|
47
|
-
png: _images.ImageLoader,
|
|
48
|
-
'ktx-etc2': _textures.CompressedTextureLoader,
|
|
49
|
-
dds: _textures.CompressedTextureLoader,
|
|
50
|
-
ktx2: _textures.BasisLoader
|
|
51
|
-
};
|
|
52
|
-
var I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
|
|
44
|
+
const I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
|
|
53
45
|
|
|
54
|
-
function parseI3STileContent(
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
async function parseI3STileContent(arrayBuffer, tile, tileset, options, context) {
|
|
47
|
+
tile.content = tile.content || {};
|
|
48
|
+
tile.content.featureIds = tile.content.featureIds || null;
|
|
49
|
+
tile.content.featureData = constructFeatureDataStruct(tileset);
|
|
50
|
+
tile.content.attributes = {};
|
|
51
|
+
|
|
52
|
+
if (tile.textureUrl) {
|
|
53
|
+
var _options$i3s;
|
|
54
|
+
|
|
55
|
+
const url = (0, _urlUtils.getUrlWithToken)(tile.textureUrl, options === null || options === void 0 ? void 0 : (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
url = (0, _urlUtils.getUrlWithToken)(tile.textureUrl, options === null || options === void 0 ? void 0 : (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
|
|
77
|
-
loader = FORMAT_LOADER_MAP[tile.textureFormat] || _images.ImageLoader;
|
|
78
|
-
_context.next = 9;
|
|
79
|
-
return fetch(url);
|
|
80
|
-
|
|
81
|
-
case 9:
|
|
82
|
-
response = _context.sent;
|
|
83
|
-
_context.next = 12;
|
|
84
|
-
return response.arrayBuffer();
|
|
85
|
-
|
|
86
|
-
case 12:
|
|
87
|
-
_arrayBuffer = _context.sent;
|
|
88
|
-
|
|
89
|
-
if (!(loader === _images.ImageLoader)) {
|
|
90
|
-
_context.next = 20;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
_options = _objectSpread(_objectSpread({}, tile.textureLoaderOptions), {}, {
|
|
95
|
-
image: {
|
|
96
|
-
type: 'data'
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
_context.next = 17;
|
|
100
|
-
return context.parse(_arrayBuffer, _options);
|
|
101
|
-
|
|
102
|
-
case 17:
|
|
103
|
-
tile.content.texture = _context.sent;
|
|
104
|
-
_context.next = 25;
|
|
105
|
-
break;
|
|
106
|
-
|
|
107
|
-
case 20:
|
|
108
|
-
if (!(loader === _textures.CompressedTextureLoader || loader === _textures.BasisLoader)) {
|
|
109
|
-
_context.next = 25;
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
_context.next = 23;
|
|
114
|
-
return (0, _core.load)(_arrayBuffer, loader, tile.textureLoaderOptions);
|
|
115
|
-
|
|
116
|
-
case 23:
|
|
117
|
-
texture = _context.sent;
|
|
118
|
-
tile.content.texture = {
|
|
119
|
-
compressed: true,
|
|
120
|
-
mipmaps: false,
|
|
121
|
-
width: texture[0].width,
|
|
122
|
-
height: texture[0].height,
|
|
123
|
-
data: texture
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
case 25:
|
|
127
|
-
tile.content.material = makePbrMaterial(tile.materialDefinition, tile.content.texture);
|
|
128
|
-
|
|
129
|
-
if (tile.content.material) {
|
|
130
|
-
tile.content.texture = null;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
_context.next = 29;
|
|
134
|
-
return parseI3SNodeGeometry(arrayBuffer, tile, context);
|
|
135
|
-
|
|
136
|
-
case 29:
|
|
137
|
-
return _context.abrupt("return", _context.sent);
|
|
138
|
-
|
|
139
|
-
case 30:
|
|
140
|
-
case "end":
|
|
141
|
-
return _context.stop();
|
|
57
|
+
const loader = getLoaderForTextureFormat(tile.textureFormat) || _images.ImageLoader;
|
|
58
|
+
|
|
59
|
+
const response = await fetch(url);
|
|
60
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
61
|
+
|
|
62
|
+
if (options !== null && options !== void 0 && options.i3s.decodeTextures) {
|
|
63
|
+
if (loader === _images.ImageLoader) {
|
|
64
|
+
const options = { ...tile.textureLoaderOptions,
|
|
65
|
+
image: {
|
|
66
|
+
type: 'data'
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
tile.content.texture = await context.parse(arrayBuffer, options);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
tile.content.texture = await (0, _core.parse)(arrayBuffer, loader, options);
|
|
142
74
|
}
|
|
75
|
+
} else if (loader === _textures.CompressedTextureLoader || loader === _textures.BasisLoader) {
|
|
76
|
+
const texture = await (0, _core.load)(arrayBuffer, loader, tile.textureLoaderOptions);
|
|
77
|
+
tile.content.texture = {
|
|
78
|
+
compressed: true,
|
|
79
|
+
mipmaps: false,
|
|
80
|
+
width: texture[0].width,
|
|
81
|
+
height: texture[0].height,
|
|
82
|
+
data: texture
|
|
83
|
+
};
|
|
143
84
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
85
|
+
} else {
|
|
86
|
+
tile.content.texture = arrayBuffer;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
tile.content.material = makePbrMaterial(tile.materialDefinition, tile.content.texture);
|
|
148
91
|
|
|
149
|
-
|
|
150
|
-
|
|
92
|
+
if (tile.content.material) {
|
|
93
|
+
tile.content.texture = null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return await parseI3SNodeGeometry(arrayBuffer, tile, options);
|
|
151
97
|
}
|
|
152
98
|
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
uvRegion,
|
|
171
|
-
featureIds,
|
|
172
|
-
_content$featureData,
|
|
173
|
-
vertexAttributes,
|
|
174
|
-
attributesOrder,
|
|
175
|
-
featureAttributes,
|
|
176
|
-
featureAttributeOrder,
|
|
177
|
-
headers,
|
|
178
|
-
_normalizeAttributes,
|
|
179
|
-
normalizedVertexAttributes,
|
|
180
|
-
offset,
|
|
181
|
-
_normalizeAttributes2,
|
|
182
|
-
normalizedFeatureAttributes,
|
|
183
|
-
_parsePositions,
|
|
184
|
-
enuMatrix,
|
|
185
|
-
cartographicOrigin,
|
|
186
|
-
cartesianOrigin,
|
|
187
|
-
matrix,
|
|
188
|
-
attributeIndex,
|
|
189
|
-
_args2 = arguments;
|
|
190
|
-
|
|
191
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
192
|
-
while (1) {
|
|
193
|
-
switch (_context2.prev = _context2.next) {
|
|
194
|
-
case 0:
|
|
195
|
-
tile = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
196
|
-
context = _args2.length > 2 ? _args2[2] : undefined;
|
|
197
|
-
|
|
198
|
-
if (tile.content) {
|
|
199
|
-
_context2.next = 4;
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return _context2.abrupt("return", tile);
|
|
204
|
-
|
|
205
|
-
case 4:
|
|
206
|
-
content = tile.content;
|
|
207
|
-
byteOffset = 0;
|
|
208
|
-
featureCount = 0;
|
|
209
|
-
|
|
210
|
-
if (!tile.isDracoGeometry) {
|
|
211
|
-
_context2.next = 20;
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
_context2.next = 10;
|
|
216
|
-
return (0, _core.parse)(arrayBuffer, _draco.DracoLoader, {
|
|
217
|
-
draco: {
|
|
218
|
-
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
case 10:
|
|
223
|
-
decompressedGeometry = _context2.sent;
|
|
224
|
-
vertexCount = decompressedGeometry.header.vertexCount;
|
|
225
|
-
indices = decompressedGeometry.indices.value;
|
|
226
|
-
_decompressedGeometry = decompressedGeometry.attributes, POSITION = _decompressedGeometry.POSITION, NORMAL = _decompressedGeometry.NORMAL, COLOR_0 = _decompressedGeometry.COLOR_0, TEXCOORD_0 = _decompressedGeometry.TEXCOORD_0, featureIndex = _decompressedGeometry['feature-index'], uvRegion = _decompressedGeometry['uv-region'];
|
|
227
|
-
attributes = {
|
|
228
|
-
position: POSITION,
|
|
229
|
-
normal: NORMAL,
|
|
230
|
-
color: COLOR_0,
|
|
231
|
-
uv0: TEXCOORD_0,
|
|
232
|
-
uvRegion: uvRegion,
|
|
233
|
-
id: featureIndex,
|
|
234
|
-
indices: indices
|
|
235
|
-
};
|
|
236
|
-
updateAttributesMetadata(attributes, decompressedGeometry);
|
|
237
|
-
featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);
|
|
238
|
-
|
|
239
|
-
if (featureIds) {
|
|
240
|
-
flattenFeatureIdsByFeatureIndices(attributes, featureIds);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
_context2.next = 29;
|
|
244
|
-
break;
|
|
245
|
-
|
|
246
|
-
case 20:
|
|
247
|
-
_content$featureData = content.featureData, vertexAttributes = _content$featureData.vertexAttributes, attributesOrder = _content$featureData.attributesOrder, featureAttributes = _content$featureData.featureAttributes, featureAttributeOrder = _content$featureData.featureAttributeOrder;
|
|
248
|
-
headers = parseHeaders(content, arrayBuffer);
|
|
249
|
-
byteOffset = headers.byteOffset;
|
|
250
|
-
vertexCount = headers.vertexCount;
|
|
251
|
-
featureCount = headers.featureCount;
|
|
252
|
-
_normalizeAttributes = normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder), normalizedVertexAttributes = _normalizeAttributes.attributes, offset = _normalizeAttributes.byteOffset;
|
|
253
|
-
_normalizeAttributes2 = normalizeAttributes(arrayBuffer, offset, featureAttributes, featureCount, featureAttributeOrder), normalizedFeatureAttributes = _normalizeAttributes2.attributes;
|
|
254
|
-
flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);
|
|
255
|
-
attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
|
|
256
|
-
|
|
257
|
-
case 29:
|
|
258
|
-
_parsePositions = parsePositions(attributes.position, tile), enuMatrix = _parsePositions.enuMatrix, cartographicOrigin = _parsePositions.cartographicOrigin, cartesianOrigin = _parsePositions.cartesianOrigin;
|
|
259
|
-
matrix = new _core2.Matrix4().multiplyRight(enuMatrix);
|
|
260
|
-
content.attributes = {
|
|
261
|
-
positions: attributes.position,
|
|
262
|
-
normals: attributes.normal,
|
|
263
|
-
colors: normalizeAttribute(attributes.color),
|
|
264
|
-
texCoords: attributes.uv0,
|
|
265
|
-
uvRegions: normalizeAttribute(attributes.uvRegion)
|
|
266
|
-
};
|
|
267
|
-
content.indices = attributes.indices || null;
|
|
268
|
-
|
|
269
|
-
if (attributes.id && attributes.id.value) {
|
|
270
|
-
tile.content.featureIds = attributes.id.value;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
for (attributeIndex in content.attributes) {
|
|
274
|
-
if (!content.attributes[attributeIndex]) {
|
|
275
|
-
delete content.attributes[attributeIndex];
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
content.vertexCount = vertexCount;
|
|
280
|
-
content.cartographicCenter = cartographicOrigin;
|
|
281
|
-
content.cartesianOrigin = cartesianOrigin;
|
|
282
|
-
content.modelMatrix = matrix.invert();
|
|
283
|
-
content.byteLength = arrayBuffer.byteLength;
|
|
284
|
-
return _context2.abrupt("return", tile);
|
|
285
|
-
|
|
286
|
-
case 41:
|
|
287
|
-
case "end":
|
|
288
|
-
return _context2.stop();
|
|
289
|
-
}
|
|
99
|
+
async function parseI3SNodeGeometry(arrayBuffer, tile, options) {
|
|
100
|
+
var _options$i3s2;
|
|
101
|
+
|
|
102
|
+
if (!tile.content) {
|
|
103
|
+
return tile;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const content = tile.content;
|
|
107
|
+
let attributes;
|
|
108
|
+
let vertexCount;
|
|
109
|
+
let byteOffset = 0;
|
|
110
|
+
let featureCount = 0;
|
|
111
|
+
|
|
112
|
+
if (tile.isDracoGeometry) {
|
|
113
|
+
const decompressedGeometry = await (0, _core.parse)(arrayBuffer, _draco.DracoLoader, {
|
|
114
|
+
draco: {
|
|
115
|
+
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
290
116
|
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
117
|
+
});
|
|
118
|
+
vertexCount = decompressedGeometry.header.vertexCount;
|
|
119
|
+
const indices = decompressedGeometry.indices.value;
|
|
120
|
+
const {
|
|
121
|
+
POSITION,
|
|
122
|
+
NORMAL,
|
|
123
|
+
COLOR_0,
|
|
124
|
+
TEXCOORD_0,
|
|
125
|
+
['feature-index']: featureIndex,
|
|
126
|
+
['uv-region']: uvRegion
|
|
127
|
+
} = decompressedGeometry.attributes;
|
|
128
|
+
attributes = {
|
|
129
|
+
position: POSITION,
|
|
130
|
+
normal: NORMAL,
|
|
131
|
+
color: COLOR_0,
|
|
132
|
+
uv0: TEXCOORD_0,
|
|
133
|
+
uvRegion,
|
|
134
|
+
id: featureIndex,
|
|
135
|
+
indices
|
|
136
|
+
};
|
|
137
|
+
updateAttributesMetadata(attributes, decompressedGeometry);
|
|
138
|
+
const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);
|
|
139
|
+
|
|
140
|
+
if (featureIds) {
|
|
141
|
+
flattenFeatureIdsByFeatureIndices(attributes, featureIds);
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
const {
|
|
145
|
+
vertexAttributes,
|
|
146
|
+
attributesOrder,
|
|
147
|
+
featureAttributes,
|
|
148
|
+
featureAttributeOrder
|
|
149
|
+
} = content.featureData;
|
|
150
|
+
const headers = parseHeaders(content, arrayBuffer);
|
|
151
|
+
byteOffset = headers.byteOffset;
|
|
152
|
+
vertexCount = headers.vertexCount;
|
|
153
|
+
featureCount = headers.featureCount;
|
|
154
|
+
const {
|
|
155
|
+
attributes: normalizedVertexAttributes,
|
|
156
|
+
byteOffset: offset
|
|
157
|
+
} = normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder);
|
|
158
|
+
const {
|
|
159
|
+
attributes: normalizedFeatureAttributes
|
|
160
|
+
} = normalizeAttributes(arrayBuffer, offset, featureAttributes, featureCount, featureAttributeOrder);
|
|
161
|
+
flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);
|
|
162
|
+
attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
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) {
|
|
166
|
+
const enuMatrix = parsePositions(attributes.position, tile);
|
|
167
|
+
content.modelMatrix = enuMatrix.invert();
|
|
168
|
+
content.coordinateSystem = _constants.COORDINATE_SYSTEM.METER_OFFSETS;
|
|
169
|
+
} else {
|
|
170
|
+
content.modelMatrix = getModelMatrix(attributes.position);
|
|
171
|
+
content.coordinateSystem = _constants.COORDINATE_SYSTEM.LNGLAT_OFFSETS;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
content.attributes = {
|
|
175
|
+
positions: attributes.position,
|
|
176
|
+
normals: attributes.normal,
|
|
177
|
+
colors: normalizeAttribute(attributes.color),
|
|
178
|
+
texCoords: attributes.uv0,
|
|
179
|
+
uvRegions: normalizeAttribute(attributes.uvRegion)
|
|
180
|
+
};
|
|
181
|
+
content.indices = attributes.indices || null;
|
|
182
|
+
|
|
183
|
+
if (attributes.id && attributes.id.value) {
|
|
184
|
+
tile.content.featureIds = attributes.id.value;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
for (const attributeIndex in content.attributes) {
|
|
188
|
+
if (!content.attributes[attributeIndex]) {
|
|
189
|
+
delete content.attributes[attributeIndex];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
content.vertexCount = vertexCount;
|
|
194
|
+
content.byteLength = arrayBuffer.byteLength;
|
|
195
|
+
return tile;
|
|
294
196
|
}
|
|
295
197
|
|
|
296
198
|
function updateAttributesMetadata(attributes, decompressedGeometry) {
|
|
297
|
-
for (
|
|
298
|
-
|
|
199
|
+
for (const key in decompressedGeometry.loaderData.attributes) {
|
|
200
|
+
const dracoAttribute = decompressedGeometry.loaderData.attributes[key];
|
|
299
201
|
|
|
300
202
|
switch (dracoAttribute.name) {
|
|
301
203
|
case 'POSITION':
|
|
@@ -313,7 +215,9 @@ function updateAttributesMetadata(attributes, decompressedGeometry) {
|
|
|
313
215
|
}
|
|
314
216
|
|
|
315
217
|
function concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes) {
|
|
316
|
-
return
|
|
218
|
+
return { ...normalizedVertexAttributes,
|
|
219
|
+
...normalizedFeatureAttributes
|
|
220
|
+
};
|
|
317
221
|
}
|
|
318
222
|
|
|
319
223
|
function normalizeAttribute(attribute) {
|
|
@@ -325,26 +229,26 @@ function normalizeAttribute(attribute) {
|
|
|
325
229
|
return attribute;
|
|
326
230
|
}
|
|
327
231
|
|
|
328
|
-
function constructFeatureDataStruct(
|
|
329
|
-
|
|
330
|
-
|
|
232
|
+
function constructFeatureDataStruct(tileset) {
|
|
233
|
+
const defaultGeometrySchema = tileset.store.defaultGeometrySchema;
|
|
234
|
+
const featureData = defaultGeometrySchema;
|
|
331
235
|
|
|
332
|
-
for (
|
|
333
|
-
for (
|
|
334
|
-
|
|
236
|
+
for (const geometryAttribute in _constants.I3S_NAMED_GEOMETRY_ATTRIBUTES) {
|
|
237
|
+
for (const namedAttribute in _constants.I3S_NAMED_VERTEX_ATTRIBUTES) {
|
|
238
|
+
const attribute = defaultGeometrySchema[geometryAttribute][namedAttribute];
|
|
335
239
|
|
|
336
240
|
if (attribute) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
241
|
+
const {
|
|
242
|
+
byteOffset = 0,
|
|
243
|
+
count = 0,
|
|
244
|
+
valueType,
|
|
245
|
+
valuesPerElement
|
|
246
|
+
} = attribute;
|
|
343
247
|
featureData[geometryAttribute][namedAttribute] = {
|
|
344
|
-
valueType
|
|
345
|
-
valuesPerElement
|
|
346
|
-
byteOffset
|
|
347
|
-
count
|
|
248
|
+
valueType,
|
|
249
|
+
valuesPerElement,
|
|
250
|
+
byteOffset,
|
|
251
|
+
count
|
|
348
252
|
};
|
|
349
253
|
}
|
|
350
254
|
}
|
|
@@ -354,107 +258,94 @@ function constructFeatureDataStruct(tile, tileset) {
|
|
|
354
258
|
return featureData;
|
|
355
259
|
}
|
|
356
260
|
|
|
357
|
-
function parseHeaders(content,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
type = _headers$header.type;
|
|
367
|
-
var TypedArrayTypeHeader = _constants.TYPE_ARRAY_MAP[type];
|
|
261
|
+
function parseHeaders(content, arrayBuffer) {
|
|
262
|
+
let byteOffset = 0;
|
|
263
|
+
let vertexCount = 0;
|
|
264
|
+
let featureCount = 0;
|
|
265
|
+
content.featureData.header.forEach(({
|
|
266
|
+
property,
|
|
267
|
+
type
|
|
268
|
+
}) => {
|
|
269
|
+
const TypedArrayTypeHeader = (0, _constants.getConstructorForDataFormat)(type);
|
|
368
270
|
|
|
369
271
|
if (property === _constants.I3S_NAMED_HEADER_ATTRIBUTES.vertexCount) {
|
|
370
|
-
vertexCount = new TypedArrayTypeHeader(
|
|
371
|
-
byteOffset += _constants.
|
|
272
|
+
vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];
|
|
273
|
+
byteOffset += (0, _constants.sizeOf)(type);
|
|
372
274
|
}
|
|
373
275
|
|
|
374
276
|
if (property === _constants.I3S_NAMED_HEADER_ATTRIBUTES.featureCount) {
|
|
375
|
-
featureCount = new TypedArrayTypeHeader(
|
|
376
|
-
byteOffset += _constants.
|
|
277
|
+
featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];
|
|
278
|
+
byteOffset += (0, _constants.sizeOf)(type);
|
|
377
279
|
}
|
|
378
|
-
}
|
|
379
|
-
|
|
280
|
+
});
|
|
380
281
|
return {
|
|
381
|
-
vertexCount
|
|
382
|
-
featureCount
|
|
383
|
-
byteOffset
|
|
282
|
+
vertexCount,
|
|
283
|
+
featureCount,
|
|
284
|
+
byteOffset
|
|
384
285
|
};
|
|
385
286
|
}
|
|
386
287
|
|
|
387
288
|
function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
var _iterator = _createForOfIteratorHelper(attributesOrder),
|
|
391
|
-
_step;
|
|
392
|
-
|
|
393
|
-
try {
|
|
394
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
395
|
-
var attribute = _step.value;
|
|
289
|
+
const attributes = {};
|
|
396
290
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
291
|
+
for (const attribute of attributesOrder) {
|
|
292
|
+
if (vertexAttributes[attribute]) {
|
|
293
|
+
const {
|
|
294
|
+
valueType,
|
|
295
|
+
valuesPerElement
|
|
296
|
+
} = vertexAttributes[attribute];
|
|
297
|
+
const count = vertexCount;
|
|
402
298
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
var buffer = arrayBuffer.slice(byteOffset);
|
|
408
|
-
var value = [];
|
|
299
|
+
if (byteOffset + count * valuesPerElement > arrayBuffer.byteLength) {
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
409
302
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
} else {
|
|
413
|
-
var TypedArrayType = _constants.TYPE_ARRAY_MAP[valueType];
|
|
414
|
-
value = new TypedArrayType(buffer, 0, count * valuesPerElement);
|
|
415
|
-
}
|
|
303
|
+
const buffer = arrayBuffer.slice(byteOffset);
|
|
304
|
+
let value = [];
|
|
416
305
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
306
|
+
if (valueType === 'UInt64') {
|
|
307
|
+
value = parseUint64Values(buffer, count * valuesPerElement, (0, _constants.sizeOf)(valueType));
|
|
308
|
+
} else {
|
|
309
|
+
const TypedArrayType = (0, _constants.getConstructorForDataFormat)(valueType);
|
|
310
|
+
value = new TypedArrayType(buffer, 0, count * valuesPerElement);
|
|
311
|
+
}
|
|
422
312
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
313
|
+
attributes[attribute] = {
|
|
314
|
+
value,
|
|
315
|
+
type: _constants.GL_TYPE_MAP[valueType],
|
|
316
|
+
size: valuesPerElement
|
|
317
|
+
};
|
|
427
318
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
}
|
|
319
|
+
switch (attribute) {
|
|
320
|
+
case 'color':
|
|
321
|
+
attributes.color.normalized = true;
|
|
322
|
+
break;
|
|
433
323
|
|
|
434
|
-
|
|
324
|
+
case 'position':
|
|
325
|
+
case 'region':
|
|
326
|
+
case 'normal':
|
|
327
|
+
default:
|
|
435
328
|
}
|
|
329
|
+
|
|
330
|
+
byteOffset = byteOffset + count * valuesPerElement * (0, _constants.sizeOf)(valueType);
|
|
436
331
|
}
|
|
437
|
-
} catch (err) {
|
|
438
|
-
_iterator.e(err);
|
|
439
|
-
} finally {
|
|
440
|
-
_iterator.f();
|
|
441
332
|
}
|
|
442
333
|
|
|
443
334
|
return {
|
|
444
|
-
attributes
|
|
445
|
-
byteOffset
|
|
335
|
+
attributes,
|
|
336
|
+
byteOffset
|
|
446
337
|
};
|
|
447
338
|
}
|
|
448
339
|
|
|
449
340
|
function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
for (
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
341
|
+
const values = [];
|
|
342
|
+
const dataView = new DataView(buffer);
|
|
343
|
+
let offset = 0;
|
|
344
|
+
|
|
345
|
+
for (let index = 0; index < elementsCount; index++) {
|
|
346
|
+
const left = dataView.getUint32(offset, true);
|
|
347
|
+
const right = dataView.getUint32(offset + 4, true);
|
|
348
|
+
const value = left + 2 ** 32 * right;
|
|
458
349
|
values.push(value);
|
|
459
350
|
offset += attributeSize;
|
|
460
351
|
}
|
|
@@ -463,59 +354,65 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
|
463
354
|
}
|
|
464
355
|
|
|
465
356
|
function parsePositions(attribute, tile) {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
357
|
+
const mbs = tile.mbs;
|
|
358
|
+
const value = attribute.value;
|
|
359
|
+
const metadata = attribute.metadata;
|
|
360
|
+
const enuMatrix = new _core2.Matrix4();
|
|
361
|
+
const cartographicOrigin = new _core2.Vector3(mbs[0], mbs[1], mbs[2]);
|
|
362
|
+
const cartesianOrigin = new _core2.Vector3();
|
|
472
363
|
|
|
473
364
|
_geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);
|
|
474
365
|
|
|
475
366
|
_geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin, enuMatrix);
|
|
476
367
|
|
|
477
368
|
attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);
|
|
478
|
-
return
|
|
479
|
-
enuMatrix: enuMatrix,
|
|
480
|
-
fixedFrameToENUMatrix: enuMatrix.invert(),
|
|
481
|
-
cartographicOrigin: cartographicOrigin,
|
|
482
|
-
cartesianOrigin: cartesianOrigin
|
|
483
|
-
};
|
|
369
|
+
return enuMatrix;
|
|
484
370
|
}
|
|
485
371
|
|
|
486
|
-
function offsetsToCartesians(vertices) {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
var scaleX = metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double || 1;
|
|
491
|
-
var scaleY = metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double || 1;
|
|
372
|
+
function offsetsToCartesians(vertices, metadata = {}, cartographicOrigin) {
|
|
373
|
+
const positions = new Float64Array(vertices.length);
|
|
374
|
+
const scaleX = metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double || 1;
|
|
375
|
+
const scaleY = metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double || 1;
|
|
492
376
|
|
|
493
|
-
for (
|
|
377
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
494
378
|
positions[i] = vertices[i] * scaleX + cartographicOrigin.x;
|
|
495
379
|
positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;
|
|
496
380
|
positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;
|
|
497
381
|
}
|
|
498
382
|
|
|
499
|
-
for (
|
|
500
|
-
_geospatial.Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(
|
|
383
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
384
|
+
_geospatial.Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);
|
|
501
385
|
|
|
502
|
-
positions[
|
|
503
|
-
positions[
|
|
504
|
-
positions[
|
|
386
|
+
positions[i] = scratchVector.x;
|
|
387
|
+
positions[i + 1] = scratchVector.y;
|
|
388
|
+
positions[i + 2] = scratchVector.z;
|
|
505
389
|
}
|
|
506
390
|
|
|
507
391
|
return positions;
|
|
508
392
|
}
|
|
509
393
|
|
|
394
|
+
function getModelMatrix(positions) {
|
|
395
|
+
var _metadata$i3sScale_x, _metadata$i3sScale_y;
|
|
396
|
+
|
|
397
|
+
const metadata = positions.metadata;
|
|
398
|
+
const scaleX = (metadata === null || metadata === void 0 ? void 0 : (_metadata$i3sScale_x = metadata['i3s-scale_x']) === null || _metadata$i3sScale_x === void 0 ? void 0 : _metadata$i3sScale_x.double) || 1;
|
|
399
|
+
const scaleY = (metadata === null || metadata === void 0 ? void 0 : (_metadata$i3sScale_y = metadata['i3s-scale_y']) === null || _metadata$i3sScale_y === void 0 ? void 0 : _metadata$i3sScale_y.double) || 1;
|
|
400
|
+
const modelMatrix = new _core2.Matrix4();
|
|
401
|
+
modelMatrix[0] = scaleX;
|
|
402
|
+
modelMatrix[5] = scaleY;
|
|
403
|
+
return modelMatrix;
|
|
404
|
+
}
|
|
405
|
+
|
|
510
406
|
function makePbrMaterial(materialDefinition, texture) {
|
|
511
|
-
|
|
407
|
+
let pbrMaterial;
|
|
512
408
|
|
|
513
409
|
if (materialDefinition) {
|
|
514
|
-
pbrMaterial =
|
|
515
|
-
pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness ?
|
|
410
|
+
pbrMaterial = { ...materialDefinition,
|
|
411
|
+
pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness ? { ...materialDefinition.pbrMetallicRoughness
|
|
412
|
+
} : {
|
|
516
413
|
baseColorFactor: [255, 255, 255, 255]
|
|
517
414
|
}
|
|
518
|
-
}
|
|
415
|
+
};
|
|
519
416
|
} else {
|
|
520
417
|
pbrMaterial = {
|
|
521
418
|
pbrMetallicRoughness: {}
|
|
@@ -549,9 +446,9 @@ function makePbrMaterial(materialDefinition, texture) {
|
|
|
549
446
|
}
|
|
550
447
|
|
|
551
448
|
function convertColorFormat(colorFactor) {
|
|
552
|
-
|
|
449
|
+
const normalizedColor = [...colorFactor];
|
|
553
450
|
|
|
554
|
-
for (
|
|
451
|
+
for (let index = 0; index < colorFactor.length; index++) {
|
|
555
452
|
normalizedColor[index] = colorFactor[index] / 255;
|
|
556
453
|
}
|
|
557
454
|
|
|
@@ -559,56 +456,58 @@ function convertColorFormat(colorFactor) {
|
|
|
559
456
|
}
|
|
560
457
|
|
|
561
458
|
function setMaterialTexture(material, image) {
|
|
562
|
-
|
|
459
|
+
const texture = {
|
|
563
460
|
source: {
|
|
564
|
-
image
|
|
461
|
+
image
|
|
565
462
|
}
|
|
566
463
|
};
|
|
567
464
|
|
|
568
465
|
if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {
|
|
569
|
-
material.pbrMetallicRoughness.baseColorTexture =
|
|
570
|
-
texture
|
|
571
|
-
}
|
|
466
|
+
material.pbrMetallicRoughness.baseColorTexture = { ...material.pbrMetallicRoughness.baseColorTexture,
|
|
467
|
+
texture
|
|
468
|
+
};
|
|
572
469
|
} else if (material.emissiveTexture) {
|
|
573
|
-
material.emissiveTexture =
|
|
574
|
-
texture
|
|
575
|
-
}
|
|
470
|
+
material.emissiveTexture = { ...material.emissiveTexture,
|
|
471
|
+
texture
|
|
472
|
+
};
|
|
576
473
|
} else if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.metallicRoughnessTexture) {
|
|
577
|
-
material.pbrMetallicRoughness.metallicRoughnessTexture =
|
|
578
|
-
texture
|
|
579
|
-
}
|
|
474
|
+
material.pbrMetallicRoughness.metallicRoughnessTexture = { ...material.pbrMetallicRoughness.metallicRoughnessTexture,
|
|
475
|
+
texture
|
|
476
|
+
};
|
|
580
477
|
} else if (material.normalTexture) {
|
|
581
|
-
material.normalTexture =
|
|
582
|
-
texture
|
|
583
|
-
}
|
|
478
|
+
material.normalTexture = { ...material.normalTexture,
|
|
479
|
+
texture
|
|
480
|
+
};
|
|
584
481
|
} else if (material.occlusionTexture) {
|
|
585
|
-
material.occlusionTexture =
|
|
586
|
-
texture
|
|
587
|
-
}
|
|
482
|
+
material.occlusionTexture = { ...material.occlusionTexture,
|
|
483
|
+
texture
|
|
484
|
+
};
|
|
588
485
|
}
|
|
589
486
|
}
|
|
590
487
|
|
|
591
488
|
function flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes) {
|
|
592
|
-
|
|
593
|
-
|
|
489
|
+
const {
|
|
490
|
+
id,
|
|
491
|
+
faceRange
|
|
492
|
+
} = normalizedFeatureAttributes;
|
|
594
493
|
|
|
595
494
|
if (!id || !faceRange) {
|
|
596
495
|
return;
|
|
597
496
|
}
|
|
598
497
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
for (
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
498
|
+
const featureIds = id.value;
|
|
499
|
+
const range = faceRange.value;
|
|
500
|
+
const featureIdsLength = range[range.length - 1] + 1;
|
|
501
|
+
const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);
|
|
502
|
+
let featureIndex = 0;
|
|
503
|
+
let startIndex = 0;
|
|
504
|
+
|
|
505
|
+
for (let index = 1; index < range.length; index += 2) {
|
|
506
|
+
const fillId = Number(featureIds[featureIndex]);
|
|
507
|
+
const endValue = range[index];
|
|
508
|
+
const prevValue = range[index - 1];
|
|
509
|
+
const trianglesCount = endValue - prevValue + 1;
|
|
510
|
+
const endIndex = startIndex + trianglesCount * 3;
|
|
612
511
|
orderedFeatureIndices.fill(fillId, startIndex, endIndex);
|
|
613
512
|
featureIndex++;
|
|
614
513
|
startIndex = endIndex;
|
|
@@ -618,10 +517,10 @@ function flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes) {
|
|
|
618
517
|
}
|
|
619
518
|
|
|
620
519
|
function flattenFeatureIdsByFeatureIndices(attributes, featureIds) {
|
|
621
|
-
|
|
622
|
-
|
|
520
|
+
const featureIndices = attributes.id.value;
|
|
521
|
+
const result = new Float32Array(featureIndices.length);
|
|
623
522
|
|
|
624
|
-
for (
|
|
523
|
+
for (let index = 0; index < featureIndices.length; index++) {
|
|
625
524
|
result[index] = featureIds[featureIndices[index]];
|
|
626
525
|
}
|
|
627
526
|
|