@loaders.gl/tile-converter 3.3.0-alpha.5 → 3.3.0-alpha.7
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/3d-tiles-attributes-worker.js +2 -3
- package/dist/3d-tiles-attributes-worker.js.map +3 -3
- package/dist/converter-cli.js +15 -2
- package/dist/converter.min.js +23 -20
- package/dist/dist.min.js +38236 -46911
- package/dist/es5/3d-tiles-attributes-worker.js +3 -6
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +12 -111
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +32 -72
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -8
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +0 -5
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js +0 -6
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/es5/bundle.js +0 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/converter-cli.js +11 -56
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +5 -35
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +3 -6
- package/dist/es5/i3s-attributes-worker.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +2 -28
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +8 -25
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +0 -11
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +5 -34
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +13 -45
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +26 -221
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +2 -16
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-debug.js +4 -23
- package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +50 -86
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +69 -384
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/layers.js +1 -15
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/metadata.js +0 -2
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/node.js +2 -12
- package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/scene-server.js +0 -2
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +6 -29
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/i3s-server/app.js +0 -5
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/controllers/index-controller.js +0 -16
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/es5/i3s-server/routes/index.js +1 -10
- package/dist/es5/i3s-server/routes/index.js.map +1 -1
- package/dist/es5/index.js +0 -3
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/utils/compress-util.js +19 -74
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +10 -38
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +0 -7
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/queue.js +0 -14
- package/dist/es5/lib/utils/queue.js.map +1 -1
- package/dist/es5/lib/utils/statistic-utills.js +1 -46
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/lib/utils/write-queue.js +0 -52
- package/dist/es5/lib/utils/write-queue.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -8
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/es5/workers/3d-tiles-attributes-worker.js +1 -8
- package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/es5/workers/i3s-attributes-worker.js +1 -9
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +3 -1
- package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +8 -40
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +7 -38
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +1 -0
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +1 -4
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js +0 -3
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/esm/bundle.js +1 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/converter-cli.js +12 -41
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +6 -7
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +3 -1
- package/dist/esm/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +4 -23
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js +11 -12
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +1 -0
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +6 -20
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +3 -22
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +28 -139
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +7 -12
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-debug.js +3 -13
- package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-pages.js +2 -21
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +59 -144
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/layers.js +1 -11
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/node.js +0 -4
- package/dist/esm/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/shared-resources.js +0 -12
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/i3s-server/app.js +0 -5
- package/dist/esm/i3s-server/app.js.map +1 -1
- package/dist/esm/i3s-server/controllers/index-controller.js +0 -5
- package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/esm/i3s-server/routes/index.js +0 -3
- package/dist/esm/i3s-server/routes/index.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/utils/compress-util.js +19 -12
- package/dist/esm/lib/utils/compress-util.js.map +1 -1
- package/dist/esm/lib/utils/file-utils.js +10 -8
- package/dist/esm/lib/utils/file-utils.js.map +1 -1
- package/dist/esm/lib/utils/lod-conversion-utils.js +2 -6
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/esm/lib/utils/queue.js +0 -4
- package/dist/esm/lib/utils/queue.js.map +1 -1
- package/dist/esm/lib/utils/statistic-utills.js +0 -11
- package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
- package/dist/esm/lib/utils/write-queue.js +5 -23
- package/dist/esm/lib/utils/write-queue.js.map +1 -1
- package/dist/esm/pgm-loader.js +3 -1
- package/dist/esm/pgm-loader.js.map +1 -1
- package/dist/esm/workers/3d-tiles-attributes-worker.js +4 -1
- package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -1
- package/dist/esm/workers/i3s-attributes-worker.js +4 -1
- package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/i3s-attributes-worker.js +2 -3
- package/dist/i3s-attributes-worker.js.map +3 -3
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +8 -6
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +2 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +14 -8
- package/dist/pgm-loader.d.ts.map +1 -1
- package/dist/pgm-loader.js +2 -1
- package/package.json +15 -15
- package/src/converter-cli.ts +16 -2
- package/src/i3s-converter/helpers/coordinate-converter.ts +8 -6
- package/src/i3s-converter/helpers/geometry-converter.ts +2 -0
- package/src/i3s-converter/i3s-converter.ts +17 -7
- package/src/pgm-loader.ts +2 -2
|
@@ -1,52 +1,31 @@
|
|
|
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
|
-
exports.default = convertB3dmToI3sGeometry;
|
|
9
7
|
exports.convertAttributes = convertAttributes;
|
|
8
|
+
exports.default = convertB3dmToI3sGeometry;
|
|
10
9
|
exports.getPropertyTable = getPropertyTable;
|
|
11
|
-
|
|
12
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
|
-
|
|
14
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
-
|
|
18
13
|
var _core = require("@math.gl/core");
|
|
19
|
-
|
|
20
14
|
var _geospatial = require("@math.gl/geospatial");
|
|
21
|
-
|
|
22
15
|
var _draco = require("@loaders.gl/draco");
|
|
23
|
-
|
|
24
16
|
var _core2 = require("@loaders.gl/core");
|
|
25
|
-
|
|
26
17
|
var _loaderUtils = require("@loaders.gl/loader-utils");
|
|
27
|
-
|
|
28
18
|
var _md = _interopRequireDefault(require("md5"));
|
|
29
|
-
|
|
30
19
|
var _geometryAttributes = require("./geometry-attributes");
|
|
31
|
-
|
|
32
20
|
var _coordinateConverter = require("./coordinate-converter");
|
|
33
|
-
|
|
34
21
|
var _gltfAttributes = require("./gltf-attributes");
|
|
35
|
-
|
|
36
22
|
var _batchIdsExtensions = require("./batch-ids-extensions");
|
|
37
|
-
|
|
38
23
|
var _featureAttributes = require("./feature-attributes");
|
|
39
|
-
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
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; }
|
|
43
|
-
|
|
24
|
+
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; }
|
|
25
|
+
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; }
|
|
44
26
|
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; } } }; }
|
|
45
|
-
|
|
46
27
|
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); }
|
|
47
|
-
|
|
48
28
|
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; }
|
|
49
|
-
|
|
50
29
|
var DEFAULT_ROUGHNESS_FACTOR = 1;
|
|
51
30
|
var DEFAULT_METALLIC_FACTOR = 1;
|
|
52
31
|
var VALUES_PER_VERTEX = 3;
|
|
@@ -64,13 +43,10 @@ var scratchVector = new _core.Vector3();
|
|
|
64
43
|
function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
|
|
65
44
|
return _convertB3dmToI3sGeometry.apply(this, arguments);
|
|
66
45
|
}
|
|
67
|
-
|
|
68
46
|
function _convertB3dmToI3sGeometry() {
|
|
69
47
|
_convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, geoidHeightModel, workerSource) {
|
|
70
48
|
var _tileContent$gltf4;
|
|
71
|
-
|
|
72
49
|
var useCartesianPositions, materialAndTextureList, dataForAttributesConversion, convertedAttributesMap, result, _ref3, _ref3$materials, materials, i, sourceMaterial, convertedAttributes, _materialAndTextureLi, material, texture, nodeId;
|
|
73
|
-
|
|
74
50
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
75
51
|
while (1) {
|
|
76
52
|
switch (_context.prev = _context.next) {
|
|
@@ -80,58 +56,45 @@ function _convertB3dmToI3sGeometry() {
|
|
|
80
56
|
dataForAttributesConversion = (0, _gltfAttributes.prepareDataForAttributesConversion)(tileContent);
|
|
81
57
|
_context.next = 5;
|
|
82
58
|
return convertAttributes(dataForAttributesConversion, useCartesianPositions);
|
|
83
|
-
|
|
84
59
|
case 5:
|
|
85
60
|
convertedAttributesMap = _context.sent;
|
|
86
61
|
|
|
87
62
|
if (generateBoundingVolumes) {
|
|
88
63
|
_generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
|
|
89
64
|
}
|
|
90
|
-
|
|
91
65
|
if (convertedAttributesMap.has('default')) {
|
|
92
66
|
materialAndTextureList.push({
|
|
93
67
|
material: getDefaultMaterial()
|
|
94
68
|
});
|
|
95
69
|
}
|
|
96
|
-
|
|
97
70
|
result = [];
|
|
98
71
|
_ref3 = tileContent.gltf || {
|
|
99
72
|
materials: []
|
|
100
73
|
}, _ref3$materials = _ref3.materials, materials = _ref3$materials === void 0 ? [] : _ref3$materials;
|
|
101
|
-
|
|
102
74
|
if (!(materials !== null && materials !== void 0 && materials.length)) {
|
|
103
75
|
materials.push({
|
|
104
76
|
id: 'default'
|
|
105
77
|
});
|
|
106
78
|
}
|
|
107
|
-
|
|
108
79
|
i = 0;
|
|
109
|
-
|
|
110
80
|
case 12:
|
|
111
81
|
if (!(i < materials.length)) {
|
|
112
82
|
_context.next = 29;
|
|
113
83
|
break;
|
|
114
84
|
}
|
|
115
|
-
|
|
116
85
|
sourceMaterial = materials[i];
|
|
117
|
-
|
|
118
86
|
if (convertedAttributesMap.has(sourceMaterial.id)) {
|
|
119
87
|
_context.next = 16;
|
|
120
88
|
break;
|
|
121
89
|
}
|
|
122
|
-
|
|
123
90
|
return _context.abrupt("continue", 26);
|
|
124
|
-
|
|
125
91
|
case 16:
|
|
126
92
|
convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);
|
|
127
|
-
|
|
128
93
|
if (convertedAttributes) {
|
|
129
94
|
_context.next = 19;
|
|
130
95
|
break;
|
|
131
96
|
}
|
|
132
|
-
|
|
133
97
|
return _context.abrupt("continue", 26);
|
|
134
|
-
|
|
135
98
|
case 19:
|
|
136
99
|
_materialAndTextureLi = materialAndTextureList[i], material = _materialAndTextureLi.material, texture = _materialAndTextureLi.texture;
|
|
137
100
|
nodeId = addNodeToNodePage();
|
|
@@ -149,28 +112,21 @@ function _convertB3dmToI3sGeometry() {
|
|
|
149
112
|
draco: draco,
|
|
150
113
|
workerSource: workerSource
|
|
151
114
|
});
|
|
152
|
-
|
|
153
115
|
case 24:
|
|
154
116
|
_context.t1 = _context.sent;
|
|
155
|
-
|
|
156
117
|
_context.t0.push.call(_context.t0, _context.t1);
|
|
157
|
-
|
|
158
118
|
case 26:
|
|
159
119
|
i++;
|
|
160
120
|
_context.next = 12;
|
|
161
121
|
break;
|
|
162
|
-
|
|
163
122
|
case 29:
|
|
164
123
|
if (result.length) {
|
|
165
124
|
_context.next = 31;
|
|
166
125
|
break;
|
|
167
126
|
}
|
|
168
|
-
|
|
169
127
|
return _context.abrupt("return", null);
|
|
170
|
-
|
|
171
128
|
case 31:
|
|
172
129
|
return _context.abrupt("return", result);
|
|
173
|
-
|
|
174
130
|
case 32:
|
|
175
131
|
case "end":
|
|
176
132
|
return _context.stop();
|
|
@@ -180,23 +136,18 @@ function _convertB3dmToI3sGeometry() {
|
|
|
180
136
|
}));
|
|
181
137
|
return _convertB3dmToI3sGeometry.apply(this, arguments);
|
|
182
138
|
}
|
|
183
|
-
|
|
184
139
|
function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel) {
|
|
185
140
|
var _iterator = _createForOfIteratorHelper(convertedAttributesMap.values()),
|
|
186
|
-
|
|
187
|
-
|
|
141
|
+
_step;
|
|
188
142
|
try {
|
|
189
143
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
190
144
|
var attributes = _step.value;
|
|
191
145
|
var boundingVolumes = (0, _coordinateConverter.createBoundingVolumesFromGeometry)(attributes.positions, geoidHeightModel);
|
|
192
146
|
attributes.boundingVolumes = boundingVolumes;
|
|
193
147
|
var cartographicOrigin = boundingVolumes.obb.center;
|
|
194
|
-
|
|
195
148
|
for (var index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX) {
|
|
196
149
|
var vertex = attributes.positions.subarray(index, index + VALUES_PER_VERTEX);
|
|
197
|
-
|
|
198
150
|
_geospatial.Ellipsoid.WGS84.cartesianToCartographic(Array.from(vertex), scratchVector);
|
|
199
|
-
|
|
200
151
|
scratchVector[2] = scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
|
|
201
152
|
scratchVector = scratchVector.subtract(cartographicOrigin);
|
|
202
153
|
attributes.positions.set(scratchVector, index);
|
|
@@ -212,13 +163,10 @@ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeigh
|
|
|
212
163
|
function _makeNodeResources(_x10) {
|
|
213
164
|
return _makeNodeResources2.apply(this, arguments);
|
|
214
165
|
}
|
|
215
|
-
|
|
216
166
|
function _makeNodeResources2() {
|
|
217
167
|
_makeNodeResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref) {
|
|
218
168
|
var _tileContent$gltf5;
|
|
219
|
-
|
|
220
169
|
var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, propertyTable, attributeStorageInfo, draco, workerSource, boundingVolumes, vertexCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, texCoords, featureCount, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
|
|
221
|
-
|
|
222
170
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
223
171
|
while (1) {
|
|
224
172
|
switch (_context2.prev = _context2.next) {
|
|
@@ -227,11 +175,9 @@ function _makeNodeResources2() {
|
|
|
227
175
|
boundingVolumes = convertedAttributes.boundingVolumes;
|
|
228
176
|
vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
|
|
229
177
|
_generateAttributes = (0, _geometryAttributes.generateAttributes)(convertedAttributes), faceRange = _generateAttributes.faceRange, featureIds = _generateAttributes.featureIds, positions = _generateAttributes.positions, normals = _generateAttributes.normals, colors = _generateAttributes.colors, texCoords = _generateAttributes.texCoords, featureCount = _generateAttributes.featureCount;
|
|
230
|
-
|
|
231
178
|
if (tileContent.batchTableJson) {
|
|
232
179
|
makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
|
|
233
180
|
}
|
|
234
|
-
|
|
235
181
|
header = new Uint32Array(2);
|
|
236
182
|
typedFeatureIds = generateBigUint64Array(featureIds);
|
|
237
183
|
header.set([vertexCount, featureCount], 0);
|
|
@@ -245,11 +191,9 @@ function _makeNodeResources2() {
|
|
|
245
191
|
faceRange: faceRange
|
|
246
192
|
}, workerSource.draco) : null;
|
|
247
193
|
attributes = [];
|
|
248
|
-
|
|
249
194
|
if (attributeStorageInfo && propertyTable) {
|
|
250
195
|
attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
|
|
251
196
|
}
|
|
252
|
-
|
|
253
197
|
return _context2.abrupt("return", {
|
|
254
198
|
nodeId: nodeId,
|
|
255
199
|
geometry: fileBuffer,
|
|
@@ -262,7 +206,6 @@ function _makeNodeResources2() {
|
|
|
262
206
|
featureCount: featureCount,
|
|
263
207
|
boundingVolumes: boundingVolumes
|
|
264
208
|
});
|
|
265
|
-
|
|
266
209
|
case 13:
|
|
267
210
|
case "end":
|
|
268
211
|
return _context2.stop();
|
|
@@ -272,15 +215,12 @@ function _makeNodeResources2() {
|
|
|
272
215
|
}));
|
|
273
216
|
return _makeNodeResources2.apply(this, arguments);
|
|
274
217
|
}
|
|
275
|
-
|
|
276
218
|
function convertAttributes(_x11, _x12) {
|
|
277
219
|
return _convertAttributes.apply(this, arguments);
|
|
278
220
|
}
|
|
279
|
-
|
|
280
221
|
function _convertAttributes() {
|
|
281
222
|
_convertAttributes = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(attributesData, useCartesianPositions) {
|
|
282
223
|
var gltfMaterials, nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, _iterator7, _step7, material, _iterator8, _step8, attrKey, attributes;
|
|
283
|
-
|
|
284
224
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
285
225
|
while (1) {
|
|
286
226
|
switch (_context3.prev = _context3.next) {
|
|
@@ -290,7 +230,6 @@ function _convertAttributes() {
|
|
|
290
230
|
_iterator7 = _createForOfIteratorHelper(gltfMaterials || [{
|
|
291
231
|
id: 'default'
|
|
292
232
|
}]);
|
|
293
|
-
|
|
294
233
|
try {
|
|
295
234
|
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
296
235
|
material = _step7.value;
|
|
@@ -309,38 +248,29 @@ function _convertAttributes() {
|
|
|
309
248
|
} finally {
|
|
310
249
|
_iterator7.f();
|
|
311
250
|
}
|
|
312
|
-
|
|
313
251
|
convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
|
|
314
252
|
_iterator8 = _createForOfIteratorHelper(attributesMap.keys());
|
|
315
253
|
_context3.prev = 6;
|
|
316
|
-
|
|
317
254
|
_iterator8.s();
|
|
318
|
-
|
|
319
255
|
case 8:
|
|
320
256
|
if ((_step8 = _iterator8.n()).done) {
|
|
321
257
|
_context3.next = 19;
|
|
322
258
|
break;
|
|
323
259
|
}
|
|
324
|
-
|
|
325
260
|
attrKey = _step8.value;
|
|
326
261
|
attributes = attributesMap.get(attrKey);
|
|
327
|
-
|
|
328
262
|
if (attributes) {
|
|
329
263
|
_context3.next = 13;
|
|
330
264
|
break;
|
|
331
265
|
}
|
|
332
|
-
|
|
333
266
|
return _context3.abrupt("continue", 17);
|
|
334
|
-
|
|
335
267
|
case 13:
|
|
336
268
|
if (!(attributes.positions.length === 0)) {
|
|
337
269
|
_context3.next = 16;
|
|
338
270
|
break;
|
|
339
271
|
}
|
|
340
|
-
|
|
341
272
|
attributesMap.delete(attrKey);
|
|
342
273
|
return _context3.abrupt("continue", 17);
|
|
343
|
-
|
|
344
274
|
case 16:
|
|
345
275
|
if (attributes.featureIndicesGroups) {
|
|
346
276
|
attributes.featureIndices = attributes.featureIndicesGroups.reduce(function (acc, value) {
|
|
@@ -348,31 +278,22 @@ function _convertAttributes() {
|
|
|
348
278
|
});
|
|
349
279
|
delete attributes.featureIndicesGroups;
|
|
350
280
|
}
|
|
351
|
-
|
|
352
281
|
case 17:
|
|
353
282
|
_context3.next = 8;
|
|
354
283
|
break;
|
|
355
|
-
|
|
356
284
|
case 19:
|
|
357
285
|
_context3.next = 24;
|
|
358
286
|
break;
|
|
359
|
-
|
|
360
287
|
case 21:
|
|
361
288
|
_context3.prev = 21;
|
|
362
289
|
_context3.t0 = _context3["catch"](6);
|
|
363
|
-
|
|
364
290
|
_iterator8.e(_context3.t0);
|
|
365
|
-
|
|
366
291
|
case 24:
|
|
367
292
|
_context3.prev = 24;
|
|
368
|
-
|
|
369
293
|
_iterator8.f();
|
|
370
|
-
|
|
371
294
|
return _context3.finish(24);
|
|
372
|
-
|
|
373
295
|
case 27:
|
|
374
296
|
return _context3.abrupt("return", attributesMap);
|
|
375
|
-
|
|
376
297
|
case 28:
|
|
377
298
|
case "end":
|
|
378
299
|
return _context3.stop();
|
|
@@ -382,14 +303,11 @@ function _convertAttributes() {
|
|
|
382
303
|
}));
|
|
383
304
|
return _convertAttributes.apply(this, arguments);
|
|
384
305
|
}
|
|
385
|
-
|
|
386
306
|
function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
|
|
387
307
|
var matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
388
|
-
|
|
389
308
|
if (nodes) {
|
|
390
309
|
var _iterator2 = _createForOfIteratorHelper(nodes),
|
|
391
|
-
|
|
392
|
-
|
|
310
|
+
_step2;
|
|
393
311
|
try {
|
|
394
312
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
395
313
|
var node = _step2.value;
|
|
@@ -406,26 +324,21 @@ function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, a
|
|
|
406
324
|
function getCompositeTransformationMatrix(node, matrix) {
|
|
407
325
|
var transformationMatrix = matrix;
|
|
408
326
|
var nodeMatrix = node.matrix,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
327
|
+
rotation = node.rotation,
|
|
328
|
+
scale = node.scale,
|
|
329
|
+
translation = node.translation;
|
|
413
330
|
if (nodeMatrix) {
|
|
414
331
|
transformationMatrix = matrix.multiplyRight(nodeMatrix);
|
|
415
332
|
}
|
|
416
|
-
|
|
417
333
|
if (translation) {
|
|
418
334
|
transformationMatrix = transformationMatrix.translate(translation);
|
|
419
335
|
}
|
|
420
|
-
|
|
421
336
|
if (rotation) {
|
|
422
337
|
transformationMatrix = transformationMatrix.rotateXYZ(rotation);
|
|
423
338
|
}
|
|
424
|
-
|
|
425
339
|
if (scale) {
|
|
426
340
|
transformationMatrix = transformationMatrix.scale(scale);
|
|
427
341
|
}
|
|
428
|
-
|
|
429
342
|
return transformationMatrix;
|
|
430
343
|
}
|
|
431
344
|
|
|
@@ -433,41 +346,32 @@ function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, att
|
|
|
433
346
|
var matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
434
347
|
var transformationMatrix = getCompositeTransformationMatrix(node, matrix);
|
|
435
348
|
var mesh = node.mesh;
|
|
436
|
-
|
|
437
349
|
if (mesh) {
|
|
438
350
|
convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
|
|
439
351
|
}
|
|
440
|
-
|
|
441
352
|
convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
|
|
442
353
|
}
|
|
443
354
|
|
|
444
355
|
function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap) {
|
|
445
356
|
var useCartesianPositions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
446
357
|
var matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
447
|
-
|
|
448
358
|
var _iterator3 = _createForOfIteratorHelper(mesh.primitives),
|
|
449
|
-
|
|
450
|
-
|
|
359
|
+
_step3;
|
|
451
360
|
try {
|
|
452
361
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
453
362
|
var _primitive$indices, _primitive$indices2, _primitive$indices3, _primitive$indices4, _primitive$indices5;
|
|
454
|
-
|
|
455
363
|
var primitive = _step3.value;
|
|
456
364
|
var outputAttributes = null;
|
|
457
|
-
|
|
458
365
|
if (primitive.material) {
|
|
459
366
|
outputAttributes = attributesMap.get(primitive.material.id);
|
|
460
367
|
} else if (attributesMap.has('default')) {
|
|
461
368
|
outputAttributes = attributesMap.get('default');
|
|
462
369
|
}
|
|
463
|
-
|
|
464
370
|
(0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
|
|
465
371
|
var attributes = primitive.attributes;
|
|
466
|
-
|
|
467
372
|
if (!outputAttributes) {
|
|
468
373
|
continue;
|
|
469
374
|
}
|
|
470
|
-
|
|
471
375
|
outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
|
|
472
376
|
vertices: attributes.POSITION.value,
|
|
473
377
|
cartographicOrigin: cartographicOrigin,
|
|
@@ -500,14 +404,12 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
|
|
|
500
404
|
|
|
501
405
|
function transformVertexArray(args) {
|
|
502
406
|
var vertices = args.vertices,
|
|
503
|
-
|
|
504
|
-
|
|
407
|
+
indices = args.indices,
|
|
408
|
+
attributeSpecificTransformation = args.attributeSpecificTransformation;
|
|
505
409
|
var newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
|
|
506
|
-
|
|
507
410
|
if (!vertices) {
|
|
508
411
|
return newVertices;
|
|
509
412
|
}
|
|
510
|
-
|
|
511
413
|
for (var i = 0; i < indices.length; i++) {
|
|
512
414
|
var coordIndex = indices[i] * VALUES_PER_VERTEX;
|
|
513
415
|
var vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
|
|
@@ -517,85 +419,68 @@ function transformVertexArray(args) {
|
|
|
517
419
|
newVertices[i * VALUES_PER_VERTEX + 1] = vertexVector.y;
|
|
518
420
|
newVertices[i * VALUES_PER_VERTEX + 2] = vertexVector.z;
|
|
519
421
|
}
|
|
520
|
-
|
|
521
422
|
return newVertices;
|
|
522
423
|
}
|
|
523
424
|
|
|
524
425
|
function transformVertexPositions(vertexVector, calleeArgs) {
|
|
525
426
|
var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
427
|
+
cartographicOrigin = calleeArgs.cartographicOrigin,
|
|
428
|
+
nodeMatrix = calleeArgs.nodeMatrix,
|
|
429
|
+
useCartesianPositions = calleeArgs.useCartesianPositions;
|
|
530
430
|
if (nodeMatrix) {
|
|
531
431
|
vertexVector = vertexVector.transform(nodeMatrix);
|
|
532
432
|
}
|
|
533
|
-
|
|
534
433
|
vertexVector = vertexVector.transform(cartesianModelMatrix);
|
|
535
|
-
|
|
536
434
|
if (useCartesianPositions) {
|
|
537
435
|
return vertexVector;
|
|
538
436
|
}
|
|
539
|
-
|
|
540
437
|
_geospatial.Ellipsoid.WGS84.cartesianToCartographic([vertexVector[0], vertexVector[1], vertexVector[2]], vertexVector);
|
|
541
|
-
|
|
542
438
|
vertexVector = vertexVector.subtract(cartographicOrigin);
|
|
543
439
|
return vertexVector;
|
|
544
440
|
}
|
|
545
441
|
|
|
546
442
|
function transformVertexNormals(vertexVector, calleeArgs) {
|
|
547
443
|
var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
|
|
548
|
-
|
|
549
|
-
|
|
444
|
+
nodeMatrix = calleeArgs.nodeMatrix;
|
|
550
445
|
if (nodeMatrix) {
|
|
551
446
|
vertexVector = vertexVector.transformAsVector(nodeMatrix);
|
|
552
447
|
}
|
|
553
|
-
|
|
554
448
|
vertexVector = vertexVector.transformAsVector(cartesianModelMatrix);
|
|
555
449
|
return vertexVector;
|
|
556
450
|
}
|
|
557
451
|
|
|
558
452
|
function flattenTexCoords(texCoords, indices) {
|
|
559
453
|
var newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
|
|
560
|
-
|
|
561
454
|
if (!texCoords) {
|
|
562
455
|
newTexCoords.fill(1);
|
|
563
456
|
return newTexCoords;
|
|
564
457
|
}
|
|
565
|
-
|
|
566
458
|
for (var i = 0; i < indices.length; i++) {
|
|
567
459
|
var coordIndex = indices[i] * VALUES_PER_TEX_COORD;
|
|
568
460
|
var texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
|
|
569
461
|
newTexCoords[i * VALUES_PER_TEX_COORD] = texCoord[0];
|
|
570
462
|
newTexCoords[i * VALUES_PER_TEX_COORD + 1] = texCoord[1];
|
|
571
463
|
}
|
|
572
|
-
|
|
573
464
|
return newTexCoords;
|
|
574
465
|
}
|
|
575
466
|
|
|
576
467
|
function flattenColors(colorsAttribute, indices) {
|
|
577
468
|
var components = (colorsAttribute === null || colorsAttribute === void 0 ? void 0 : colorsAttribute.components) || VALUES_PER_COLOR_ELEMENT;
|
|
578
469
|
var newColors = new Uint8Array(indices.length * components);
|
|
579
|
-
|
|
580
470
|
if (!colorsAttribute) {
|
|
581
471
|
newColors.fill(255);
|
|
582
472
|
return newColors;
|
|
583
473
|
}
|
|
584
|
-
|
|
585
474
|
var colors = colorsAttribute.value;
|
|
586
|
-
|
|
587
475
|
for (var i = 0; i < indices.length; i++) {
|
|
588
476
|
var colorIndex = indices[i] * components;
|
|
589
477
|
var color = colors.subarray(colorIndex, colorIndex + components);
|
|
590
478
|
var colorUint8 = new Uint8Array(components);
|
|
591
|
-
|
|
592
479
|
for (var j = 0; j < color.length; j++) {
|
|
593
480
|
colorUint8[j] = color[j] * 255;
|
|
594
481
|
}
|
|
595
|
-
|
|
596
482
|
newColors.set(colorUint8, i * components);
|
|
597
483
|
}
|
|
598
|
-
|
|
599
484
|
return newColors;
|
|
600
485
|
}
|
|
601
486
|
|
|
@@ -603,42 +488,33 @@ function flattenBatchIds(batchedIds, indices) {
|
|
|
603
488
|
if (!batchedIds.length || !indices.length) {
|
|
604
489
|
return [];
|
|
605
490
|
}
|
|
606
|
-
|
|
607
491
|
var newBatchIds = [];
|
|
608
|
-
|
|
609
492
|
for (var i = 0; i < indices.length; i++) {
|
|
610
493
|
var coordIndex = indices[i];
|
|
611
494
|
newBatchIds.push(batchedIds[coordIndex]);
|
|
612
495
|
}
|
|
613
|
-
|
|
614
496
|
return newBatchIds;
|
|
615
497
|
}
|
|
616
498
|
|
|
617
499
|
function getBatchIds(attributes, primitive, images) {
|
|
618
500
|
var batchIds = (0, _batchIdsExtensions.handleBatchIdsExtensions)(attributes, primitive, images);
|
|
619
|
-
|
|
620
501
|
if (batchIds.length) {
|
|
621
502
|
return batchIds;
|
|
622
503
|
}
|
|
623
|
-
|
|
624
504
|
for (var index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
|
|
625
505
|
var possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
|
|
626
|
-
|
|
627
506
|
if (attributes[possibleBatchIdAttributeName] && attributes[possibleBatchIdAttributeName].value) {
|
|
628
507
|
return attributes[possibleBatchIdAttributeName].value;
|
|
629
508
|
}
|
|
630
509
|
}
|
|
631
|
-
|
|
632
510
|
return [];
|
|
633
511
|
}
|
|
634
512
|
|
|
635
513
|
function convertMaterials() {
|
|
636
514
|
var sourceMaterials = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
637
515
|
var result = [];
|
|
638
|
-
|
|
639
516
|
var _iterator4 = _createForOfIteratorHelper(sourceMaterials),
|
|
640
|
-
|
|
641
|
-
|
|
517
|
+
_step4;
|
|
642
518
|
try {
|
|
643
519
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
644
520
|
var sourceMaterial = _step4.value;
|
|
@@ -649,13 +525,11 @@ function convertMaterials() {
|
|
|
649
525
|
} finally {
|
|
650
526
|
_iterator4.f();
|
|
651
527
|
}
|
|
652
|
-
|
|
653
528
|
return result;
|
|
654
529
|
}
|
|
655
530
|
|
|
656
531
|
function convertMaterial(sourceMaterial) {
|
|
657
532
|
var _sourceMaterial$emiss, _sourceMaterial$pbrMe, _sourceMaterial$pbrMe2, _sourceMaterial$pbrMe3;
|
|
658
|
-
|
|
659
533
|
var material = {
|
|
660
534
|
doubleSided: sourceMaterial.doubleSided,
|
|
661
535
|
emissiveFactor: (_sourceMaterial$emiss = sourceMaterial.emissiveFactor) === null || _sourceMaterial$emiss === void 0 ? void 0 : _sourceMaterial$emiss.map(function (c) {
|
|
@@ -668,7 +542,6 @@ function convertMaterial(sourceMaterial) {
|
|
|
668
542
|
}
|
|
669
543
|
};
|
|
670
544
|
var texture;
|
|
671
|
-
|
|
672
545
|
if (sourceMaterial !== null && sourceMaterial !== void 0 && (_sourceMaterial$pbrMe3 = sourceMaterial.pbrMetallicRoughness) !== null && _sourceMaterial$pbrMe3 !== void 0 && _sourceMaterial$pbrMe3.baseColorTexture) {
|
|
673
546
|
texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
|
|
674
547
|
material.pbrMetallicRoughness.baseColorTexture = {
|
|
@@ -680,16 +553,13 @@ function convertMaterial(sourceMaterial) {
|
|
|
680
553
|
textureSetDefinitionId: 0
|
|
681
554
|
};
|
|
682
555
|
}
|
|
683
|
-
|
|
684
556
|
if (!texture) {
|
|
685
557
|
var _sourceMaterial$pbrMe4;
|
|
686
|
-
|
|
687
558
|
var baseColorFactor = sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe4 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe4 === void 0 ? void 0 : _sourceMaterial$pbrMe4.baseColorFactor;
|
|
688
559
|
material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(function (c) {
|
|
689
560
|
return Math.round(c * 255);
|
|
690
561
|
}) || undefined;
|
|
691
562
|
}
|
|
692
|
-
|
|
693
563
|
return {
|
|
694
564
|
material: material,
|
|
695
565
|
texture: texture
|
|
@@ -700,13 +570,10 @@ function convertAlphaMode(gltfAlphaMode) {
|
|
|
700
570
|
switch (gltfAlphaMode) {
|
|
701
571
|
case 'OPAQUE':
|
|
702
572
|
return 'opaque';
|
|
703
|
-
|
|
704
573
|
case 'MASK':
|
|
705
574
|
return 'mask';
|
|
706
|
-
|
|
707
575
|
case 'BLEND':
|
|
708
576
|
return 'blend';
|
|
709
|
-
|
|
710
577
|
default:
|
|
711
578
|
return 'opaque';
|
|
712
579
|
}
|
|
@@ -724,26 +591,19 @@ function getDefaultMaterial() {
|
|
|
724
591
|
|
|
725
592
|
function getSharedResources(gltfMaterials, nodeId) {
|
|
726
593
|
var i3sResources = {};
|
|
727
|
-
|
|
728
594
|
if (!gltfMaterials || !gltfMaterials.length) {
|
|
729
595
|
return i3sResources;
|
|
730
596
|
}
|
|
731
|
-
|
|
732
597
|
i3sResources.materialDefinitionInfos = [];
|
|
733
|
-
|
|
734
598
|
var _iterator5 = _createForOfIteratorHelper(gltfMaterials),
|
|
735
|
-
|
|
736
|
-
|
|
599
|
+
_step5;
|
|
737
600
|
try {
|
|
738
601
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
739
602
|
var gltfMaterial = _step5.value;
|
|
740
|
-
|
|
741
603
|
var _convertGLTFMaterialT = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId),
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
604
|
+
materialDefinitionInfo = _convertGLTFMaterialT.materialDefinitionInfo,
|
|
605
|
+
textureDefinitionInfo = _convertGLTFMaterialT.textureDefinitionInfo;
|
|
745
606
|
i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
|
|
746
|
-
|
|
747
607
|
if (textureDefinitionInfo) {
|
|
748
608
|
i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
|
|
749
609
|
i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
|
|
@@ -754,31 +614,24 @@ function getSharedResources(gltfMaterials, nodeId) {
|
|
|
754
614
|
} finally {
|
|
755
615
|
_iterator5.f();
|
|
756
616
|
}
|
|
757
|
-
|
|
758
617
|
return i3sResources;
|
|
759
618
|
}
|
|
760
619
|
|
|
761
620
|
function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
|
|
762
621
|
var _gltfMaterial$pbrMeta;
|
|
763
|
-
|
|
764
622
|
var texture = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : (_gltfMaterial$pbrMeta = gltfMaterial.pbrMetallicRoughness) === null || _gltfMaterial$pbrMeta === void 0 ? void 0 : _gltfMaterial$pbrMeta.baseColorTexture) || gltfMaterial.emissiveTexture;
|
|
765
623
|
var textureDefinitionInfo = null;
|
|
766
|
-
|
|
767
624
|
if (texture) {
|
|
768
625
|
textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
|
|
769
626
|
}
|
|
770
|
-
|
|
771
627
|
var _ref2 = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : gltfMaterial.pbrMetallicRoughness) || {},
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
628
|
+
baseColorFactor = _ref2.baseColorFactor,
|
|
629
|
+
metallicFactor = _ref2.metallicFactor;
|
|
775
630
|
var colorFactor = baseColorFactor;
|
|
776
|
-
|
|
777
631
|
if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
|
|
778
632
|
colorFactor = gltfMaterial.emissiveFactor;
|
|
779
633
|
colorFactor[3] = colorFactor[3] || 1;
|
|
780
634
|
}
|
|
781
|
-
|
|
782
635
|
return {
|
|
783
636
|
materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor || [1, 1, 1, 1], metallicFactor),
|
|
784
637
|
textureDefinitionInfo: textureDefinitionInfo
|
|
@@ -807,7 +660,6 @@ function extractSharedResourcesMaterialInfo(baseColorFactor) {
|
|
|
807
660
|
|
|
808
661
|
function extractSharedResourcesTextureInfo(texture, nodeId) {
|
|
809
662
|
var _texture$source, _texture$source2, _texture$source3;
|
|
810
|
-
|
|
811
663
|
return {
|
|
812
664
|
encoding: texture !== null && texture !== void 0 && (_texture$source = texture.source) !== null && _texture$source !== void 0 && _texture$source.mimeType ? [texture.source.mimeType] : undefined,
|
|
813
665
|
images: [{
|
|
@@ -820,11 +672,9 @@ function extractSharedResourcesTextureInfo(texture, nodeId) {
|
|
|
820
672
|
|
|
821
673
|
function generateImageId(texture, nodeId) {
|
|
822
674
|
var _texture$source4;
|
|
823
|
-
|
|
824
675
|
var _texture$source$image = (_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image,
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
676
|
+
width = _texture$source$image.width,
|
|
677
|
+
height = _texture$source$image.height;
|
|
828
678
|
var levelCountOfTexture = 1;
|
|
829
679
|
var indexOfLevel = 0;
|
|
830
680
|
var indexOfTextureInStore = nodeId + 1;
|
|
@@ -847,34 +697,28 @@ function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, bat
|
|
|
847
697
|
|
|
848
698
|
function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
|
|
849
699
|
var featureMap = {};
|
|
850
|
-
|
|
851
700
|
for (var index = 0; index < featureIds.length; index++) {
|
|
852
701
|
var oldFeatureId = featureIds[index];
|
|
853
702
|
var uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
|
|
854
703
|
featureMap[oldFeatureId.toString()] = uniqueFeatureId;
|
|
855
704
|
}
|
|
856
|
-
|
|
857
705
|
return featureMap;
|
|
858
706
|
}
|
|
859
707
|
|
|
860
708
|
function generateStringFromBatchTableByIndex(batchTable, index) {
|
|
861
709
|
var str = '';
|
|
862
|
-
|
|
863
710
|
for (var _key in batchTable) {
|
|
864
711
|
str += batchTable[_key][index];
|
|
865
712
|
}
|
|
866
|
-
|
|
867
713
|
return str;
|
|
868
714
|
}
|
|
869
715
|
|
|
870
716
|
function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
|
|
871
717
|
var batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
|
|
872
718
|
var hash = (0, _md.default)(batchTableStr);
|
|
873
|
-
|
|
874
719
|
if (featuresHashArray.includes(hash)) {
|
|
875
720
|
return featuresHashArray.indexOf(hash);
|
|
876
721
|
}
|
|
877
|
-
|
|
878
722
|
return featuresHashArray.push(hash) - 1;
|
|
879
723
|
}
|
|
880
724
|
|
|
@@ -888,42 +732,34 @@ function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attri
|
|
|
888
732
|
var attributeBuffers = [];
|
|
889
733
|
var needFlattenPropertyTable = (0, _featureAttributes.checkPropertiesLength)(featureIds, propertyTable);
|
|
890
734
|
var properties = needFlattenPropertyTable ? (0, _featureAttributes.flattenPropertyTableByFeatureIds)(featureIds, propertyTable) : propertyTable;
|
|
891
|
-
|
|
892
735
|
var propertyTableWithObjectIds = _objectSpread({
|
|
893
736
|
OBJECTID: featureIds
|
|
894
737
|
}, properties);
|
|
895
|
-
|
|
896
738
|
for (var propertyName in propertyTableWithObjectIds) {
|
|
897
739
|
var type = getAttributeType(propertyName, attributeStorageInfo);
|
|
898
740
|
var value = propertyTableWithObjectIds[propertyName];
|
|
899
741
|
var attributeBuffer = generateAttributeBuffer(type, value);
|
|
900
742
|
attributeBuffers.push(attributeBuffer);
|
|
901
743
|
}
|
|
902
|
-
|
|
903
744
|
return attributeBuffers;
|
|
904
745
|
}
|
|
905
746
|
|
|
906
747
|
function generateAttributeBuffer(type, value) {
|
|
907
748
|
var attributeBuffer;
|
|
908
|
-
|
|
909
749
|
switch (type) {
|
|
910
750
|
case OBJECT_ID_TYPE:
|
|
911
751
|
case SHORT_INT_TYPE:
|
|
912
752
|
attributeBuffer = generateShortIntegerAttributeBuffer(value);
|
|
913
753
|
break;
|
|
914
|
-
|
|
915
754
|
case DOUBLE_TYPE:
|
|
916
755
|
attributeBuffer = generateDoubleAttributeBuffer(value);
|
|
917
756
|
break;
|
|
918
|
-
|
|
919
757
|
case STRING_TYPE:
|
|
920
758
|
attributeBuffer = generateStringAttributeBuffer(value);
|
|
921
759
|
break;
|
|
922
|
-
|
|
923
760
|
default:
|
|
924
761
|
attributeBuffer = generateStringAttributeBuffer(value);
|
|
925
762
|
}
|
|
926
|
-
|
|
927
763
|
return attributeBuffer;
|
|
928
764
|
}
|
|
929
765
|
|
|
@@ -952,7 +788,6 @@ function generateStringAttributeBuffer(batchAttributes) {
|
|
|
952
788
|
var totalNumberOfBytes = 0;
|
|
953
789
|
var stringSizesArray = new Uint32Array(batchAttributes.length);
|
|
954
790
|
var stringBufferArray = [];
|
|
955
|
-
|
|
956
791
|
for (var index = 0; index < batchAttributes.length; index++) {
|
|
957
792
|
var currentString = "".concat(String(batchAttributes[index]), "\0");
|
|
958
793
|
var currentStringBuffer = Buffer.from(currentString);
|
|
@@ -961,25 +796,21 @@ function generateStringAttributeBuffer(batchAttributes) {
|
|
|
961
796
|
stringSizesArray[index] = currentStringSize;
|
|
962
797
|
stringBufferArray.push(currentStringBuffer);
|
|
963
798
|
}
|
|
964
|
-
|
|
965
799
|
var totalBytes = new Uint32Array([totalNumberOfBytes]);
|
|
966
800
|
return _loaderUtils.concatenateArrayBuffers.apply(void 0, [stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer].concat(stringBufferArray));
|
|
967
801
|
}
|
|
968
802
|
|
|
969
803
|
function generateBigUint64Array(featureIds) {
|
|
970
804
|
var typedFeatureIds = new BigUint64Array(featureIds.length);
|
|
971
|
-
|
|
972
805
|
for (var index = 0; index < featureIds.length; index++) {
|
|
973
806
|
typedFeatureIds[index] = BigInt(featureIds[index]);
|
|
974
807
|
}
|
|
975
|
-
|
|
976
808
|
return typedFeatureIds;
|
|
977
809
|
}
|
|
978
810
|
|
|
979
811
|
function generateCompressedGeometry(_x13, _x14, _x15, _x16) {
|
|
980
812
|
return _generateCompressedGeometry.apply(this, arguments);
|
|
981
813
|
}
|
|
982
|
-
|
|
983
814
|
function _generateCompressedGeometry() {
|
|
984
815
|
_generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(vertexCount, convertedAttributes, attributes, dracoWorkerSoure) {
|
|
985
816
|
var positions, normals, texCoords, colors, featureIds, faceRange, indices, index, featureIndices, featureIndex, compressedAttributes, attributesMetadata;
|
|
@@ -989,11 +820,9 @@ function _generateCompressedGeometry() {
|
|
|
989
820
|
case 0:
|
|
990
821
|
positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
|
|
991
822
|
indices = new Uint32Array(vertexCount);
|
|
992
|
-
|
|
993
823
|
for (index = 0; index < indices.length; index++) {
|
|
994
824
|
indices.set([index], index);
|
|
995
825
|
}
|
|
996
|
-
|
|
997
826
|
featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
|
|
998
827
|
featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
|
|
999
828
|
compressedAttributes = {
|
|
@@ -1002,11 +831,9 @@ function _generateCompressedGeometry() {
|
|
|
1002
831
|
colors: colors,
|
|
1003
832
|
'feature-index': featureIndex
|
|
1004
833
|
};
|
|
1005
|
-
|
|
1006
834
|
if (texCoords.length) {
|
|
1007
835
|
compressedAttributes.texCoords = texCoords;
|
|
1008
836
|
}
|
|
1009
|
-
|
|
1010
837
|
attributesMetadata = {
|
|
1011
838
|
'feature-index': {
|
|
1012
839
|
'i3s-attribute-type': 'feature-index',
|
|
@@ -1025,7 +852,6 @@ function _generateCompressedGeometry() {
|
|
|
1025
852
|
attributesMetadata: attributesMetadata
|
|
1026
853
|
}
|
|
1027
854
|
})));
|
|
1028
|
-
|
|
1029
855
|
case 9:
|
|
1030
856
|
case "end":
|
|
1031
857
|
return _context4.stop();
|
|
@@ -1035,45 +861,37 @@ function _generateCompressedGeometry() {
|
|
|
1035
861
|
}));
|
|
1036
862
|
return _generateCompressedGeometry.apply(this, arguments);
|
|
1037
863
|
}
|
|
1038
|
-
|
|
1039
864
|
function generateFeatureIndexAttribute(featureIndex, faceRange) {
|
|
1040
865
|
var orderedFeatureIndices = new Uint32Array(featureIndex.length);
|
|
1041
866
|
var fillIndex = 0;
|
|
1042
867
|
var startIndex = 0;
|
|
1043
|
-
|
|
1044
868
|
for (var index = 1; index < faceRange.length; index += 2) {
|
|
1045
869
|
var endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
|
|
1046
870
|
orderedFeatureIndices.fill(fillIndex, startIndex, endIndex);
|
|
1047
871
|
fillIndex++;
|
|
1048
872
|
startIndex = endIndex + 1;
|
|
1049
873
|
}
|
|
1050
|
-
|
|
1051
874
|
return orderedFeatureIndices;
|
|
1052
875
|
}
|
|
1053
876
|
|
|
1054
877
|
function getPropertyTable(tileContent) {
|
|
1055
878
|
var batchTableJson = tileContent === null || tileContent === void 0 ? void 0 : tileContent.batchTableJson;
|
|
1056
|
-
|
|
1057
879
|
if (batchTableJson) {
|
|
1058
880
|
return batchTableJson;
|
|
1059
881
|
}
|
|
1060
|
-
|
|
1061
882
|
var _getPropertyTableExte = getPropertyTableExtension(tileContent),
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
883
|
+
extensionName = _getPropertyTableExte.extensionName,
|
|
884
|
+
extension = _getPropertyTableExte.extension;
|
|
1065
885
|
switch (extensionName) {
|
|
1066
886
|
case EXT_MESH_FEATURES:
|
|
1067
887
|
{
|
|
1068
888
|
console.warn('The I3S converter does not yet support the EXT_mesh_features extension');
|
|
1069
889
|
return null;
|
|
1070
890
|
}
|
|
1071
|
-
|
|
1072
891
|
case EXT_FEATURE_METADATA:
|
|
1073
892
|
{
|
|
1074
893
|
return getPropertyTableFromExtFeatureMetadata(extension);
|
|
1075
894
|
}
|
|
1076
|
-
|
|
1077
895
|
default:
|
|
1078
896
|
return null;
|
|
1079
897
|
}
|
|
@@ -1081,26 +899,20 @@ function getPropertyTable(tileContent) {
|
|
|
1081
899
|
|
|
1082
900
|
function getPropertyTableExtension(tileContent) {
|
|
1083
901
|
var _tileContent$gltf, _tileContent$gltf2, _tileContent$gltf2$ex, _tileContent$gltf3;
|
|
1084
|
-
|
|
1085
902
|
var extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
|
|
1086
903
|
var extensionsUsed = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf = tileContent.gltf) === null || _tileContent$gltf === void 0 ? void 0 : _tileContent$gltf.extensionsUsed;
|
|
1087
|
-
|
|
1088
904
|
if (!extensionsUsed) {
|
|
1089
905
|
return {
|
|
1090
906
|
extensionName: null,
|
|
1091
907
|
extension: null
|
|
1092
908
|
};
|
|
1093
909
|
}
|
|
1094
|
-
|
|
1095
910
|
var extensionName = '';
|
|
1096
|
-
|
|
1097
911
|
var _iterator6 = _createForOfIteratorHelper((tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf3 = tileContent.gltf) === null || _tileContent$gltf3 === void 0 ? void 0 : _tileContent$gltf3.extensionsUsed) || []),
|
|
1098
|
-
|
|
1099
|
-
|
|
912
|
+
_step6;
|
|
1100
913
|
try {
|
|
1101
914
|
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1102
915
|
var extensionItem = _step6.value;
|
|
1103
|
-
|
|
1104
916
|
if (extensionsWithPropertyTables.includes(extensionItem)) {
|
|
1105
917
|
extensionName = extensionItem;
|
|
1106
918
|
break;
|
|
@@ -1111,7 +923,6 @@ function getPropertyTableExtension(tileContent) {
|
|
|
1111
923
|
} finally {
|
|
1112
924
|
_iterator6.f();
|
|
1113
925
|
}
|
|
1114
|
-
|
|
1115
926
|
var extension = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf2 = tileContent.gltf) === null || _tileContent$gltf2 === void 0 ? void 0 : (_tileContent$gltf2$ex = _tileContent$gltf2.extensions) === null || _tileContent$gltf2$ex === void 0 ? void 0 : _tileContent$gltf2$ex[extensionName];
|
|
1116
927
|
return {
|
|
1117
928
|
extensionName: extensionName,
|
|
@@ -1124,24 +935,18 @@ function getPropertyTableFromExtFeatureMetadata(extension) {
|
|
|
1124
935
|
console.warn('The I3S converter does not yet support the EXT_feature_metadata feature textures');
|
|
1125
936
|
return null;
|
|
1126
937
|
}
|
|
1127
|
-
|
|
1128
938
|
if (extension !== null && extension !== void 0 && extension.featureTables) {
|
|
1129
939
|
var _Object$keys;
|
|
1130
|
-
|
|
1131
940
|
var firstFeatureTableName = (_Object$keys = Object.keys(extension.featureTables)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
|
|
1132
|
-
|
|
1133
941
|
if (firstFeatureTableName) {
|
|
1134
942
|
var featureTable = extension === null || extension === void 0 ? void 0 : extension.featureTables[firstFeatureTableName];
|
|
1135
943
|
var propertyTable = {};
|
|
1136
|
-
|
|
1137
944
|
for (var propertyName in featureTable.properties) {
|
|
1138
945
|
propertyTable[propertyName] = featureTable.properties[propertyName].data;
|
|
1139
946
|
}
|
|
1140
|
-
|
|
1141
947
|
return propertyTable;
|
|
1142
948
|
}
|
|
1143
949
|
}
|
|
1144
|
-
|
|
1145
950
|
console.warn("The I3S converter couldn't handle EXT_feature_metadata extension");
|
|
1146
951
|
return null;
|
|
1147
952
|
}
|