@loaders.gl/i3s 3.3.0-alpha.5 → 3.3.0-alpha.6
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 +984 -1291
- package/dist/es5/arcgis-webscene-loader.js +2 -8
- package/dist/es5/arcgis-webscene-loader.js.map +1 -1
- package/dist/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/i3s-attribute-loader.js +19 -60
- package/dist/es5/i3s-attribute-loader.js.map +1 -1
- package/dist/es5/i3s-building-scene-layer-loader.js +1 -10
- package/dist/es5/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/es5/i3s-content-loader.js +1 -14
- package/dist/es5/i3s-content-loader.js.map +1 -1
- package/dist/es5/i3s-loader.js +7 -45
- package/dist/es5/i3s-loader.js.map +1 -1
- package/dist/es5/i3s-node-page-loader.js +1 -12
- package/dist/es5/i3s-node-page-loader.js.map +1 -1
- package/dist/es5/index.js +12 -18
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +18 -78
- package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/constants.js +2 -18
- package/dist/es5/lib/parsers/constants.js.map +1 -1
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js +128 -30
- package/dist/es5/lib/parsers/parse-arcgis-webscene.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-attribute.js +1 -23
- package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js +8 -25
- package/dist/es5/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js +10 -124
- package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/es5/lib/parsers/parse-i3s.js +5 -36
- package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +0 -7
- package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
- package/dist/es5/lib/utils/customizeColors.js +4 -53
- package/dist/es5/lib/utils/customizeColors.js.map +1 -1
- package/dist/es5/lib/utils/url-utils.js +3 -8
- package/dist/es5/lib/utils/url-utils.js.map +1 -1
- package/dist/es5/types.js +0 -3
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/workers/i3s-content-nodejs-worker.js +0 -3
- package/dist/es5/workers/i3s-content-nodejs-worker.js.map +1 -1
- package/dist/es5/workers/i3s-content-worker.js +0 -2
- package/dist/es5/workers/i3s-content-worker.js.map +1 -1
- package/dist/esm/arcgis-webscene-loader.js +3 -1
- package/dist/esm/arcgis-webscene-loader.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/i3s-attribute-loader.js +8 -25
- package/dist/esm/i3s-attribute-loader.js.map +1 -1
- package/dist/esm/i3s-building-scene-layer-loader.js +2 -3
- package/dist/esm/i3s-building-scene-layer-loader.js.map +1 -1
- package/dist/esm/i3s-content-loader.js +2 -4
- package/dist/esm/i3s-content-loader.js.map +1 -1
- package/dist/esm/i3s-loader.js +4 -13
- package/dist/esm/i3s-loader.js.map +1 -1
- package/dist/esm/i3s-node-page-loader.js +1 -2
- package/dist/esm/i3s-node-page-loader.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js +2 -45
- package/dist/esm/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/constants.js +1 -10
- package/dist/esm/lib/parsers/constants.js.map +1 -1
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js +50 -11
- package/dist/esm/lib/parsers/parse-arcgis-webscene.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-attribute.js +1 -8
- package/dist/esm/lib/parsers/parse-i3s-attribute.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js +1 -4
- package/dist/esm/lib/parsers/parse-i3s-building-scene-layer.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js +23 -71
- package/dist/esm/lib/parsers/parse-i3s-tile-content.js.map +1 -1
- package/dist/esm/lib/parsers/parse-i3s.js +15 -17
- package/dist/esm/lib/parsers/parse-i3s.js.map +1 -1
- package/dist/esm/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
- package/dist/esm/lib/utils/customizeColors.js +24 -36
- package/dist/esm/lib/utils/customizeColors.js.map +1 -1
- package/dist/esm/lib/utils/url-utils.js +5 -5
- package/dist/esm/lib/utils/url-utils.js.map +1 -1
- package/dist/esm/types.js +0 -3
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/workers/i3s-content-nodejs-worker.js.map +1 -1
- package/dist/esm/workers/i3s-content-worker.js.map +1 -1
- package/dist/i3s-content-nodejs-worker.js +61 -60
- package/dist/i3s-content-nodejs-worker.js.map +3 -3
- package/dist/i3s-content-worker.js +490 -1020
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/parsers/parse-arcgis-webscene.d.ts.map +1 -1
- package/dist/lib/parsers/parse-arcgis-webscene.js +49 -7
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +2 -1
- package/src/lib/parsers/parse-arcgis-webscene.ts +57 -7
- package/src/types.ts +1 -0
|
@@ -1,78 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.parseI3STileContent = parseI3STileContent;
|
|
9
|
-
|
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
9
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
-
|
|
18
12
|
var _core = require("@loaders.gl/core");
|
|
19
|
-
|
|
20
13
|
var _core2 = require("@math.gl/core");
|
|
21
|
-
|
|
22
14
|
var _geospatial = require("@math.gl/geospatial");
|
|
23
|
-
|
|
24
15
|
var _images = require("@loaders.gl/images");
|
|
25
|
-
|
|
26
16
|
var _draco = require("@loaders.gl/draco");
|
|
27
|
-
|
|
28
17
|
var _textures = require("@loaders.gl/textures");
|
|
29
|
-
|
|
30
18
|
var _types = require("../../types");
|
|
31
|
-
|
|
32
19
|
var _urlUtils = require("../utils/url-utils");
|
|
33
|
-
|
|
34
20
|
var _constants = require("./constants");
|
|
35
|
-
|
|
36
21
|
var _customizeColors = require("../utils/customizeColors");
|
|
37
|
-
|
|
38
22
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
39
|
-
|
|
40
23
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
41
|
-
|
|
42
24
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
43
|
-
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
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; }
|
|
47
|
-
|
|
25
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
48
27
|
var scratchVector = new _core2.Vector3([0, 0, 0]);
|
|
49
|
-
|
|
50
28
|
function getLoaderForTextureFormat(textureFormat) {
|
|
51
29
|
switch (textureFormat) {
|
|
52
30
|
case 'ktx-etc2':
|
|
53
31
|
case 'dds':
|
|
54
32
|
return _textures.CompressedTextureLoader;
|
|
55
|
-
|
|
56
33
|
case 'ktx2':
|
|
57
34
|
return _textures.BasisLoader;
|
|
58
|
-
|
|
59
35
|
case 'jpg':
|
|
60
36
|
case 'png':
|
|
61
37
|
default:
|
|
62
38
|
return _images.ImageLoader;
|
|
63
39
|
}
|
|
64
40
|
}
|
|
65
|
-
|
|
66
41
|
var I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
|
|
67
|
-
|
|
68
42
|
function parseI3STileContent(_x, _x2, _x3, _x4, _x5) {
|
|
69
43
|
return _parseI3STileContent.apply(this, arguments);
|
|
70
44
|
}
|
|
71
|
-
|
|
72
45
|
function _parseI3STileContent() {
|
|
73
46
|
_parseI3STileContent = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, tileOptions, tilesetOptions, options, context) {
|
|
74
47
|
var content, _options$i3s, url, loader, response, _arrayBuffer, _options, texture;
|
|
75
|
-
|
|
76
48
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
77
49
|
while (1) {
|
|
78
50
|
switch (_context.prev = _context.next) {
|
|
@@ -87,35 +59,28 @@ function _parseI3STileContent() {
|
|
|
87
59
|
byteLength: 0,
|
|
88
60
|
texture: null
|
|
89
61
|
};
|
|
90
|
-
|
|
91
62
|
if (!tileOptions.textureUrl) {
|
|
92
63
|
_context.next = 35;
|
|
93
64
|
break;
|
|
94
65
|
}
|
|
95
|
-
|
|
96
66
|
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);
|
|
97
67
|
loader = getLoaderForTextureFormat(tileOptions.textureFormat);
|
|
98
68
|
_context.next = 6;
|
|
99
69
|
return fetch(url, options === null || options === void 0 ? void 0 : options.fetch);
|
|
100
|
-
|
|
101
70
|
case 6:
|
|
102
71
|
response = _context.sent;
|
|
103
72
|
_context.next = 9;
|
|
104
73
|
return response.arrayBuffer();
|
|
105
|
-
|
|
106
74
|
case 9:
|
|
107
75
|
_arrayBuffer = _context.sent;
|
|
108
|
-
|
|
109
76
|
if (!(options !== null && options !== void 0 && options.i3s.decodeTextures)) {
|
|
110
77
|
_context.next = 34;
|
|
111
78
|
break;
|
|
112
79
|
}
|
|
113
|
-
|
|
114
80
|
if (!(loader === _images.ImageLoader)) {
|
|
115
81
|
_context.next = 26;
|
|
116
82
|
break;
|
|
117
83
|
}
|
|
118
|
-
|
|
119
84
|
_options = _objectSpread(_objectSpread({}, tileOptions.textureLoaderOptions), {}, {
|
|
120
85
|
image: {
|
|
121
86
|
type: 'data'
|
|
@@ -124,41 +89,32 @@ function _parseI3STileContent() {
|
|
|
124
89
|
_context.prev = 13;
|
|
125
90
|
_context.next = 16;
|
|
126
91
|
return context.parse(_arrayBuffer, _options);
|
|
127
|
-
|
|
128
92
|
case 16:
|
|
129
93
|
content.texture = _context.sent;
|
|
130
94
|
_context.next = 24;
|
|
131
95
|
break;
|
|
132
|
-
|
|
133
96
|
case 19:
|
|
134
97
|
_context.prev = 19;
|
|
135
98
|
_context.t0 = _context["catch"](13);
|
|
136
99
|
_context.next = 23;
|
|
137
100
|
return (0, _core.parse)(_arrayBuffer, loader, _options);
|
|
138
|
-
|
|
139
101
|
case 23:
|
|
140
102
|
content.texture = _context.sent;
|
|
141
|
-
|
|
142
103
|
case 24:
|
|
143
104
|
_context.next = 32;
|
|
144
105
|
break;
|
|
145
|
-
|
|
146
106
|
case 26:
|
|
147
107
|
if (!(loader === _textures.CompressedTextureLoader || loader === _textures.BasisLoader)) {
|
|
148
108
|
_context.next = 32;
|
|
149
109
|
break;
|
|
150
110
|
}
|
|
151
|
-
|
|
152
111
|
_context.next = 29;
|
|
153
112
|
return (0, _core.load)(_arrayBuffer, loader, tileOptions.textureLoaderOptions);
|
|
154
|
-
|
|
155
113
|
case 29:
|
|
156
114
|
texture = _context.sent;
|
|
157
|
-
|
|
158
115
|
if (loader === _textures.BasisLoader) {
|
|
159
116
|
texture = texture[0];
|
|
160
117
|
}
|
|
161
|
-
|
|
162
118
|
content.texture = {
|
|
163
119
|
compressed: true,
|
|
164
120
|
mipmaps: false,
|
|
@@ -166,27 +122,20 @@ function _parseI3STileContent() {
|
|
|
166
122
|
height: texture[0].height,
|
|
167
123
|
data: texture
|
|
168
124
|
};
|
|
169
|
-
|
|
170
125
|
case 32:
|
|
171
126
|
_context.next = 35;
|
|
172
127
|
break;
|
|
173
|
-
|
|
174
128
|
case 34:
|
|
175
129
|
content.texture = _arrayBuffer;
|
|
176
|
-
|
|
177
130
|
case 35:
|
|
178
131
|
content.material = makePbrMaterial(tileOptions.materialDefinition, content.texture);
|
|
179
|
-
|
|
180
132
|
if (content.material) {
|
|
181
133
|
content.texture = null;
|
|
182
134
|
}
|
|
183
|
-
|
|
184
135
|
_context.next = 39;
|
|
185
136
|
return parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOptions, options);
|
|
186
|
-
|
|
187
137
|
case 39:
|
|
188
138
|
return _context.abrupt("return", _context.sent);
|
|
189
|
-
|
|
190
139
|
case 40:
|
|
191
140
|
case "end":
|
|
192
141
|
return _context.stop();
|
|
@@ -196,17 +145,13 @@ function _parseI3STileContent() {
|
|
|
196
145
|
}));
|
|
197
146
|
return _parseI3STileContent.apply(this, arguments);
|
|
198
147
|
}
|
|
199
|
-
|
|
200
148
|
function parseI3SNodeGeometry(_x6, _x7, _x8, _x9, _x10) {
|
|
201
149
|
return _parseI3SNodeGeometry.apply(this, arguments);
|
|
202
150
|
}
|
|
203
|
-
|
|
204
151
|
function _parseI3SNodeGeometry() {
|
|
205
152
|
_parseI3SNodeGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(arrayBuffer, content, tileOptions, tilesetOptions, options) {
|
|
206
153
|
var _options$i3s2;
|
|
207
|
-
|
|
208
154
|
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;
|
|
209
|
-
|
|
210
155
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
211
156
|
while (1) {
|
|
212
157
|
switch (_context2.prev = _context2.next) {
|
|
@@ -214,19 +159,16 @@ function _parseI3SNodeGeometry() {
|
|
|
214
159
|
contentByteLength = arrayBuffer.byteLength;
|
|
215
160
|
byteOffset = 0;
|
|
216
161
|
featureCount = 0;
|
|
217
|
-
|
|
218
162
|
if (!tileOptions.isDracoGeometry) {
|
|
219
163
|
_context2.next = 16;
|
|
220
164
|
break;
|
|
221
165
|
}
|
|
222
|
-
|
|
223
166
|
_context2.next = 6;
|
|
224
167
|
return (0, _core.parse)(arrayBuffer, _draco.DracoLoader, {
|
|
225
168
|
draco: {
|
|
226
169
|
attributeNameEntry: I3S_ATTRIBUTE_TYPE
|
|
227
170
|
}
|
|
228
171
|
});
|
|
229
|
-
|
|
230
172
|
case 6:
|
|
231
173
|
decompressedGeometry = _context2.sent;
|
|
232
174
|
vertexCount = decompressedGeometry.header.vertexCount;
|
|
@@ -242,14 +184,11 @@ function _parseI3SNodeGeometry() {
|
|
|
242
184
|
};
|
|
243
185
|
updateAttributesMetadata(attributes, decompressedGeometry);
|
|
244
186
|
featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);
|
|
245
|
-
|
|
246
187
|
if (featureIds) {
|
|
247
188
|
flattenFeatureIdsByFeatureIndices(attributes, featureIds);
|
|
248
189
|
}
|
|
249
|
-
|
|
250
190
|
_context2.next = 25;
|
|
251
191
|
break;
|
|
252
|
-
|
|
253
192
|
case 16:
|
|
254
193
|
_tilesetOptions$store = tilesetOptions.store.defaultGeometrySchema, vertexAttributes = _tilesetOptions$store.vertexAttributes, attributesOrder = _tilesetOptions$store.ordering, featureAttributes = _tilesetOptions$store.featureAttributes, featureAttributeOrder = _tilesetOptions$store.featureAttributeOrder;
|
|
255
194
|
headers = parseHeaders(arrayBuffer, tilesetOptions);
|
|
@@ -260,7 +199,6 @@ function _parseI3SNodeGeometry() {
|
|
|
260
199
|
_normalizeAttributes2 = normalizeAttributes(arrayBuffer, offset, featureAttributes, featureCount, featureAttributeOrder), normalizedFeatureAttributes = _normalizeAttributes2.attributes;
|
|
261
200
|
flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);
|
|
262
201
|
attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
|
|
263
|
-
|
|
264
202
|
case 25:
|
|
265
203
|
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
204
|
enuMatrix = parsePositions(attributes.position, tileOptions);
|
|
@@ -270,10 +208,8 @@ function _parseI3SNodeGeometry() {
|
|
|
270
208
|
content.modelMatrix = getModelMatrix(attributes.position);
|
|
271
209
|
content.coordinateSystem = _constants.COORDINATE_SYSTEM.LNGLAT_OFFSETS;
|
|
272
210
|
}
|
|
273
|
-
|
|
274
211
|
_context2.next = 28;
|
|
275
212
|
return (0, _customizeColors.customizeColors)(attributes.color, attributes.id, tileOptions, tilesetOptions, options);
|
|
276
|
-
|
|
277
213
|
case 28:
|
|
278
214
|
attributes.color = _context2.sent;
|
|
279
215
|
content.attributes = {
|
|
@@ -283,8 +219,8 @@ function _parseI3SNodeGeometry() {
|
|
|
283
219
|
texCoords: attributes.uv0,
|
|
284
220
|
uvRegions: normalizeAttribute(attributes.uvRegion)
|
|
285
221
|
};
|
|
286
|
-
content.indices = indices || null;
|
|
287
222
|
|
|
223
|
+
content.indices = indices || null;
|
|
288
224
|
if (attributes.id && attributes.id.value) {
|
|
289
225
|
content.featureIds = attributes.id.value;
|
|
290
226
|
}
|
|
@@ -294,11 +230,9 @@ function _parseI3SNodeGeometry() {
|
|
|
294
230
|
delete content.attributes[attributeIndex];
|
|
295
231
|
}
|
|
296
232
|
}
|
|
297
|
-
|
|
298
233
|
content.vertexCount = vertexCount;
|
|
299
234
|
content.byteLength = contentByteLength;
|
|
300
235
|
return _context2.abrupt("return", content);
|
|
301
|
-
|
|
302
236
|
case 36:
|
|
303
237
|
case "end":
|
|
304
238
|
return _context2.stop();
|
|
@@ -308,20 +242,16 @@ function _parseI3SNodeGeometry() {
|
|
|
308
242
|
}));
|
|
309
243
|
return _parseI3SNodeGeometry.apply(this, arguments);
|
|
310
244
|
}
|
|
311
|
-
|
|
312
245
|
function updateAttributesMetadata(attributes, decompressedGeometry) {
|
|
313
246
|
for (var key in decompressedGeometry.loaderData.attributes) {
|
|
314
247
|
var dracoAttribute = decompressedGeometry.loaderData.attributes[key];
|
|
315
|
-
|
|
316
248
|
switch (dracoAttribute.name) {
|
|
317
249
|
case 'POSITION':
|
|
318
250
|
attributes.position.metadata = dracoAttribute.metadata;
|
|
319
251
|
break;
|
|
320
|
-
|
|
321
252
|
case 'feature-index':
|
|
322
253
|
attributes.id.metadata = dracoAttribute.metadata;
|
|
323
254
|
break;
|
|
324
|
-
|
|
325
255
|
default:
|
|
326
256
|
break;
|
|
327
257
|
}
|
|
@@ -336,37 +266,30 @@ function normalizeAttribute(attribute) {
|
|
|
336
266
|
if (!attribute) {
|
|
337
267
|
return attribute;
|
|
338
268
|
}
|
|
339
|
-
|
|
340
269
|
attribute.normalized = true;
|
|
341
270
|
return attribute;
|
|
342
271
|
}
|
|
343
|
-
|
|
344
272
|
function parseHeaders(arrayBuffer, options) {
|
|
345
273
|
var byteOffset = 0;
|
|
346
274
|
var vertexCount = 0;
|
|
347
275
|
var featureCount = 0;
|
|
348
|
-
|
|
349
276
|
var _iterator = _createForOfIteratorHelper(options.store.defaultGeometrySchema.header),
|
|
350
|
-
|
|
351
|
-
|
|
277
|
+
_step;
|
|
352
278
|
try {
|
|
353
279
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
354
280
|
var _step$value = _step.value,
|
|
355
|
-
|
|
356
|
-
|
|
281
|
+
property = _step$value.property,
|
|
282
|
+
type = _step$value.type;
|
|
357
283
|
var TypedArrayTypeHeader = (0, _constants.getConstructorForDataFormat)(type);
|
|
358
|
-
|
|
359
284
|
switch (property) {
|
|
360
285
|
case _types.HeaderAttributeProperty.vertexCount:
|
|
361
286
|
vertexCount = new TypedArrayTypeHeader(arrayBuffer, 0, 4)[0];
|
|
362
287
|
byteOffset += (0, _constants.sizeOf)(type);
|
|
363
288
|
break;
|
|
364
|
-
|
|
365
289
|
case _types.HeaderAttributeProperty.featureCount:
|
|
366
290
|
featureCount = new TypedArrayTypeHeader(arrayBuffer, 4, 4)[0];
|
|
367
291
|
byteOffset += (0, _constants.sizeOf)(type);
|
|
368
292
|
break;
|
|
369
|
-
|
|
370
293
|
default:
|
|
371
294
|
break;
|
|
372
295
|
}
|
|
@@ -376,7 +299,6 @@ function parseHeaders(arrayBuffer, options) {
|
|
|
376
299
|
} finally {
|
|
377
300
|
_iterator.f();
|
|
378
301
|
}
|
|
379
|
-
|
|
380
302
|
return {
|
|
381
303
|
vertexCount: vertexCount,
|
|
382
304
|
featureCount: featureCount,
|
|
@@ -388,45 +310,37 @@ function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, attribut
|
|
|
388
310
|
var attributes = {};
|
|
389
311
|
|
|
390
312
|
var _iterator2 = _createForOfIteratorHelper(attributesOrder),
|
|
391
|
-
|
|
392
|
-
|
|
313
|
+
_step2;
|
|
393
314
|
try {
|
|
394
315
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
395
316
|
var attribute = _step2.value;
|
|
396
|
-
|
|
397
317
|
if (vertexAttributes[attribute]) {
|
|
398
318
|
var _vertexAttributes$att = vertexAttributes[attribute],
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
319
|
+
valueType = _vertexAttributes$att.valueType,
|
|
320
|
+
valuesPerElement = _vertexAttributes$att.valuesPerElement;
|
|
402
321
|
if (byteOffset + attributeCount * valuesPerElement * (0, _constants.sizeOf)(valueType) <= arrayBuffer.byteLength) {
|
|
403
322
|
var buffer = arrayBuffer.slice(byteOffset);
|
|
404
323
|
var value = void 0;
|
|
405
|
-
|
|
406
324
|
if (valueType === 'UInt64') {
|
|
407
325
|
value = parseUint64Values(buffer, attributeCount * valuesPerElement, (0, _constants.sizeOf)(valueType));
|
|
408
326
|
} else {
|
|
409
327
|
var TypedArrayType = (0, _constants.getConstructorForDataFormat)(valueType);
|
|
410
328
|
value = new TypedArrayType(buffer, 0, attributeCount * valuesPerElement);
|
|
411
329
|
}
|
|
412
|
-
|
|
413
330
|
attributes[attribute] = {
|
|
414
331
|
value: value,
|
|
415
332
|
type: _constants.GL_TYPE_MAP[valueType],
|
|
416
333
|
size: valuesPerElement
|
|
417
334
|
};
|
|
418
|
-
|
|
419
335
|
switch (attribute) {
|
|
420
336
|
case 'color':
|
|
421
337
|
attributes.color.normalized = true;
|
|
422
338
|
break;
|
|
423
|
-
|
|
424
339
|
case 'position':
|
|
425
340
|
case 'region':
|
|
426
341
|
case 'normal':
|
|
427
342
|
default:
|
|
428
343
|
}
|
|
429
|
-
|
|
430
344
|
byteOffset = byteOffset + attributeCount * valuesPerElement * (0, _constants.sizeOf)(valueType);
|
|
431
345
|
} else if (attribute !== 'uv0') {
|
|
432
346
|
break;
|
|
@@ -438,7 +352,6 @@ function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, attribut
|
|
|
438
352
|
} finally {
|
|
439
353
|
_iterator2.f();
|
|
440
354
|
}
|
|
441
|
-
|
|
442
355
|
return {
|
|
443
356
|
attributes: attributes,
|
|
444
357
|
byteOffset: byteOffset
|
|
@@ -449,7 +362,6 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
|
449
362
|
var values = [];
|
|
450
363
|
var dataView = new DataView(buffer);
|
|
451
364
|
var offset = 0;
|
|
452
|
-
|
|
453
365
|
for (var index = 0; index < elementsCount; index++) {
|
|
454
366
|
var left = dataView.getUint32(offset, true);
|
|
455
367
|
var right = dataView.getUint32(offset + 4, true);
|
|
@@ -457,10 +369,8 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
|
|
|
457
369
|
values.push(value);
|
|
458
370
|
offset += attributeSize;
|
|
459
371
|
}
|
|
460
|
-
|
|
461
372
|
return new Uint32Array(values);
|
|
462
373
|
}
|
|
463
|
-
|
|
464
374
|
function parsePositions(attribute, options) {
|
|
465
375
|
var mbs = options.mbs;
|
|
466
376
|
var value = attribute.value;
|
|
@@ -468,11 +378,8 @@ function parsePositions(attribute, options) {
|
|
|
468
378
|
var enuMatrix = new _core2.Matrix4();
|
|
469
379
|
var cartographicOrigin = new _core2.Vector3(mbs[0], mbs[1], mbs[2]);
|
|
470
380
|
var cartesianOrigin = new _core2.Vector3();
|
|
471
|
-
|
|
472
381
|
_geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);
|
|
473
|
-
|
|
474
382
|
_geospatial.Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin, enuMatrix);
|
|
475
|
-
|
|
476
383
|
attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);
|
|
477
384
|
return enuMatrix;
|
|
478
385
|
}
|
|
@@ -483,27 +390,22 @@ function offsetsToCartesians(vertices) {
|
|
|
483
390
|
var positions = new Float64Array(vertices.length);
|
|
484
391
|
var scaleX = metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double || 1;
|
|
485
392
|
var scaleY = metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double || 1;
|
|
486
|
-
|
|
487
393
|
for (var i = 0; i < positions.length; i += 3) {
|
|
488
394
|
positions[i] = vertices[i] * scaleX + cartographicOrigin.x;
|
|
489
395
|
positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;
|
|
490
396
|
positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;
|
|
491
397
|
}
|
|
492
|
-
|
|
493
398
|
for (var _i = 0; _i < positions.length; _i += 3) {
|
|
494
399
|
_geospatial.Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(_i, _i + 3), scratchVector);
|
|
495
|
-
|
|
496
400
|
positions[_i] = scratchVector.x;
|
|
497
401
|
positions[_i + 1] = scratchVector.y;
|
|
498
402
|
positions[_i + 2] = scratchVector.z;
|
|
499
403
|
}
|
|
500
|
-
|
|
501
404
|
return positions;
|
|
502
405
|
}
|
|
503
406
|
|
|
504
407
|
function getModelMatrix(positions) {
|
|
505
408
|
var _metadata$i3sScale_x, _metadata$i3sScale_y;
|
|
506
|
-
|
|
507
409
|
var metadata = positions.metadata;
|
|
508
410
|
var 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;
|
|
509
411
|
var 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;
|
|
@@ -515,7 +417,6 @@ function getModelMatrix(positions) {
|
|
|
515
417
|
|
|
516
418
|
function makePbrMaterial(materialDefinition, texture) {
|
|
517
419
|
var pbrMaterial;
|
|
518
|
-
|
|
519
420
|
if (materialDefinition) {
|
|
520
421
|
pbrMaterial = _objectSpread(_objectSpread({}, materialDefinition), {}, {
|
|
521
422
|
pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness ? _objectSpread({}, materialDefinition.pbrMetallicRoughness) : {
|
|
@@ -526,7 +427,6 @@ function makePbrMaterial(materialDefinition, texture) {
|
|
|
526
427
|
pbrMaterial = {
|
|
527
428
|
pbrMetallicRoughness: {}
|
|
528
429
|
};
|
|
529
|
-
|
|
530
430
|
if (texture) {
|
|
531
431
|
pbrMaterial.pbrMetallicRoughness.baseColorTexture = {
|
|
532
432
|
texCoord: 0
|
|
@@ -537,7 +437,6 @@ function makePbrMaterial(materialDefinition, texture) {
|
|
|
537
437
|
}
|
|
538
438
|
|
|
539
439
|
pbrMaterial.alphaCutoff = pbrMaterial.alphaCutoff || 0.25;
|
|
540
|
-
|
|
541
440
|
if (pbrMaterial.alphaMode) {
|
|
542
441
|
pbrMaterial.alphaMode = pbrMaterial.alphaMode.toUpperCase();
|
|
543
442
|
}
|
|
@@ -545,25 +444,20 @@ function makePbrMaterial(materialDefinition, texture) {
|
|
|
545
444
|
if (pbrMaterial.emissiveFactor) {
|
|
546
445
|
pbrMaterial.emissiveFactor = convertColorFormat(pbrMaterial.emissiveFactor);
|
|
547
446
|
}
|
|
548
|
-
|
|
549
447
|
if (pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorFactor) {
|
|
550
448
|
pbrMaterial.pbrMetallicRoughness.baseColorFactor = convertColorFormat(pbrMaterial.pbrMetallicRoughness.baseColorFactor);
|
|
551
449
|
}
|
|
552
|
-
|
|
553
450
|
if (texture) {
|
|
554
451
|
setMaterialTexture(pbrMaterial, texture);
|
|
555
452
|
}
|
|
556
|
-
|
|
557
453
|
return pbrMaterial;
|
|
558
454
|
}
|
|
559
455
|
|
|
560
456
|
function convertColorFormat(colorFactor) {
|
|
561
457
|
var normalizedColor = (0, _toConsumableArray2.default)(colorFactor);
|
|
562
|
-
|
|
563
458
|
for (var index = 0; index < colorFactor.length; index++) {
|
|
564
459
|
normalizedColor[index] = colorFactor[index] / 255;
|
|
565
460
|
}
|
|
566
|
-
|
|
567
461
|
return normalizedColor;
|
|
568
462
|
}
|
|
569
463
|
|
|
@@ -573,7 +467,6 @@ function setMaterialTexture(material, image) {
|
|
|
573
467
|
image: image
|
|
574
468
|
}
|
|
575
469
|
};
|
|
576
|
-
|
|
577
470
|
if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {
|
|
578
471
|
material.pbrMetallicRoughness.baseColorTexture = _objectSpread(_objectSpread({}, material.pbrMetallicRoughness.baseColorTexture), {}, {
|
|
579
472
|
texture: texture
|
|
@@ -599,19 +492,16 @@ function setMaterialTexture(material, image) {
|
|
|
599
492
|
|
|
600
493
|
function flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes) {
|
|
601
494
|
var id = normalizedFeatureAttributes.id,
|
|
602
|
-
|
|
603
|
-
|
|
495
|
+
faceRange = normalizedFeatureAttributes.faceRange;
|
|
604
496
|
if (!id || !faceRange) {
|
|
605
497
|
return;
|
|
606
498
|
}
|
|
607
|
-
|
|
608
499
|
var featureIds = id.value;
|
|
609
500
|
var range = faceRange.value;
|
|
610
501
|
var featureIdsLength = range[range.length - 1] + 1;
|
|
611
502
|
var orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);
|
|
612
503
|
var featureIndex = 0;
|
|
613
504
|
var startIndex = 0;
|
|
614
|
-
|
|
615
505
|
for (var index = 1; index < range.length; index += 2) {
|
|
616
506
|
var fillId = Number(featureIds[featureIndex]);
|
|
617
507
|
var endValue = range[index];
|
|
@@ -622,24 +512,20 @@ function flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes) {
|
|
|
622
512
|
featureIndex++;
|
|
623
513
|
startIndex = endIndex;
|
|
624
514
|
}
|
|
625
|
-
|
|
626
515
|
normalizedFeatureAttributes.id.value = orderedFeatureIndices;
|
|
627
516
|
}
|
|
628
517
|
|
|
629
518
|
function flattenFeatureIdsByFeatureIndices(attributes, featureIds) {
|
|
630
519
|
var featureIndices = attributes.id.value;
|
|
631
520
|
var result = new Float32Array(featureIndices.length);
|
|
632
|
-
|
|
633
521
|
for (var index = 0; index < featureIndices.length; index++) {
|
|
634
522
|
result[index] = featureIds[featureIndices[index]];
|
|
635
523
|
}
|
|
636
|
-
|
|
637
524
|
attributes.id.value = result;
|
|
638
525
|
}
|
|
639
526
|
|
|
640
527
|
function getFeatureIdsFromFeatureIndexMetadata(featureIndex) {
|
|
641
528
|
var _featureIndex$metadat, _featureIndex$metadat2;
|
|
642
|
-
|
|
643
529
|
return featureIndex === null || featureIndex === void 0 ? void 0 : (_featureIndex$metadat = featureIndex.metadata) === null || _featureIndex$metadat === void 0 ? void 0 : (_featureIndex$metadat2 = _featureIndex$metadat['i3s-feature-ids']) === null || _featureIndex$metadat2 === void 0 ? void 0 : _featureIndex$metadat2.intArray;
|
|
644
530
|
}
|
|
645
531
|
//# sourceMappingURL=parse-i3s-tile-content.js.map
|