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