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