@loaders.gl/tile-converter 3.0.13 → 3.0.14
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.es5.min.js +3 -3
- package/dist/dist.es5.min.js.map +1 -1
- package/dist/dist.min.js +11 -11
- package/dist/dist.min.js.map +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +422 -184
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +299 -202
- 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 +8 -4
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js +17 -7
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/es5/bundle.js +2 -2
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +65 -17
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +16 -16
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +33 -9
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +103 -93
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +505 -344
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-debug.js +26 -30
- package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +203 -102
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +1510 -680
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/layers.js +25 -15
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/metadata.js +1 -1
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/node.js +21 -12
- package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/scene-server.js +4 -2
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +55 -15
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/store.js +4 -2
- package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/es5/i3s-server/app.js +6 -6
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/controllers/index-controller.js +60 -20
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/es5/i3s-server/routes/index.js +41 -14
- package/dist/es5/i3s-server/routes/index.js.map +1 -1
- package/dist/es5/index.js +4 -4
- package/dist/es5/lib/geoid-height-model.js +114 -100
- package/dist/es5/lib/geoid-height-model.js.map +1 -1
- package/dist/es5/lib/pgm-parser.js +122 -68
- package/dist/es5/lib/pgm-parser.js.map +1 -1
- package/dist/es5/lib/utils/compress-util.js +345 -123
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +98 -20
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +9 -9
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/statistic-utills.js +152 -41
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/pgm-loader.js +5 -3
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +11 -3
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/scripts/converter.js +134 -71
- package/package.json +14 -14
- package/src/i3s-converter/i3s-converter.ts +10 -3
|
@@ -7,6 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = convertB3dmToI3sGeometry;
|
|
9
9
|
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
|
|
10
16
|
var _core = require("@math.gl/core");
|
|
11
17
|
|
|
12
18
|
var _geospatial = require("@math.gl/geospatial");
|
|
@@ -21,174 +27,280 @@ var _md = _interopRequireDefault(require("md5"));
|
|
|
21
27
|
|
|
22
28
|
var _geometryAttributes = require("./geometry-attributes");
|
|
23
29
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
30
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
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; } } }; }
|
|
35
|
+
|
|
36
|
+
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); }
|
|
37
|
+
|
|
38
|
+
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; }
|
|
39
|
+
|
|
40
|
+
var VALUES_PER_VERTEX = 3;
|
|
41
|
+
var VALUES_PER_TEX_COORD = 2;
|
|
42
|
+
var VALUES_PER_COLOR_ELEMENT = 4;
|
|
43
|
+
var STRING_TYPE = 'string';
|
|
44
|
+
var SHORT_INT_TYPE = 'Int32';
|
|
45
|
+
var DOUBLE_TYPE = 'Float64';
|
|
46
|
+
var OBJECT_ID_TYPE = 'Oid32';
|
|
47
|
+
var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
|
|
48
|
+
|
|
49
|
+
function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5) {
|
|
50
|
+
return _convertB3dmToI3sGeometry.apply(this, arguments);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function _convertB3dmToI3sGeometry() {
|
|
54
|
+
_convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco) {
|
|
55
|
+
var materialAndTextureList, convertedAttributesMap, result, nodesCounter, i, sourceMaterial, convertedAttributes, _materialAndTextureLi, material, texture;
|
|
56
|
+
|
|
57
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
58
|
+
while (1) {
|
|
59
|
+
switch (_context.prev = _context.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
materialAndTextureList = convertMaterials(tileContent);
|
|
62
|
+
convertedAttributesMap = convertAttributes(tileContent);
|
|
63
|
+
|
|
64
|
+
if (convertedAttributesMap.has('default')) {
|
|
65
|
+
materialAndTextureList.push({
|
|
66
|
+
material: getDefaultMaterial()
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
result = [];
|
|
71
|
+
nodesCounter = nodeId;
|
|
72
|
+
i = 0;
|
|
73
|
+
|
|
74
|
+
case 6:
|
|
75
|
+
if (!(i < (tileContent.gltf.materials.length || 1))) {
|
|
76
|
+
_context.next = 21;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
sourceMaterial = tileContent.gltf.materials[i] || {
|
|
81
|
+
id: 'default'
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
if (convertedAttributesMap.has(sourceMaterial.id)) {
|
|
85
|
+
_context.next = 10;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return _context.abrupt("continue", 18);
|
|
90
|
+
|
|
91
|
+
case 10:
|
|
92
|
+
convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);
|
|
93
|
+
_materialAndTextureLi = materialAndTextureList[i], material = _materialAndTextureLi.material, texture = _materialAndTextureLi.texture;
|
|
94
|
+
_context.t0 = result;
|
|
95
|
+
_context.next = 15;
|
|
96
|
+
return _makeNodeResources({
|
|
97
|
+
convertedAttributes: convertedAttributes,
|
|
98
|
+
material: material,
|
|
99
|
+
texture: texture,
|
|
100
|
+
tileContent: tileContent,
|
|
101
|
+
nodeId: nodesCounter,
|
|
102
|
+
featuresHashArray: featuresHashArray,
|
|
103
|
+
attributeStorageInfo: attributeStorageInfo,
|
|
104
|
+
draco: draco
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
case 15:
|
|
108
|
+
_context.t1 = _context.sent;
|
|
109
|
+
|
|
110
|
+
_context.t0.push.call(_context.t0, _context.t1);
|
|
111
|
+
|
|
112
|
+
nodesCounter++;
|
|
113
|
+
|
|
114
|
+
case 18:
|
|
115
|
+
i++;
|
|
116
|
+
_context.next = 6;
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case 21:
|
|
120
|
+
return _context.abrupt("return", result);
|
|
121
|
+
|
|
122
|
+
case 22:
|
|
123
|
+
case "end":
|
|
124
|
+
return _context.stop();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, _callee);
|
|
128
|
+
}));
|
|
129
|
+
return _convertB3dmToI3sGeometry.apply(this, arguments);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function _makeNodeResources(_x6) {
|
|
133
|
+
return _makeNodeResources2.apply(this, arguments);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function _makeNodeResources2() {
|
|
137
|
+
_makeNodeResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref) {
|
|
138
|
+
var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco, vertexCount, triangleCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, texCoords, featureCount, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
|
|
139
|
+
|
|
140
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
141
|
+
while (1) {
|
|
142
|
+
switch (_context2.prev = _context2.next) {
|
|
143
|
+
case 0:
|
|
144
|
+
convertedAttributes = _ref.convertedAttributes, material = _ref.material, texture = _ref.texture, tileContent = _ref.tileContent, nodeId = _ref.nodeId, featuresHashArray = _ref.featuresHashArray, attributeStorageInfo = _ref.attributeStorageInfo, draco = _ref.draco;
|
|
145
|
+
vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
|
|
146
|
+
triangleCount = vertexCount / 3;
|
|
147
|
+
_generateAttributes = (0, _geometryAttributes.generateAttributes)(_objectSpread({
|
|
148
|
+
triangleCount: triangleCount
|
|
149
|
+
}, convertedAttributes)), faceRange = _generateAttributes.faceRange, featureIds = _generateAttributes.featureIds, positions = _generateAttributes.positions, normals = _generateAttributes.normals, colors = _generateAttributes.colors, texCoords = _generateAttributes.texCoords, featureCount = _generateAttributes.featureCount;
|
|
150
|
+
|
|
151
|
+
if (tileContent.batchTableJson) {
|
|
152
|
+
makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
header = new Uint32Array(2);
|
|
156
|
+
typedFeatureIds = generateBigUint64Array(featureIds);
|
|
157
|
+
header.set([vertexCount, featureCount], 0);
|
|
158
|
+
fileBuffer = new Uint8Array((0, _loaderUtils.concatenateArrayBuffers)(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, typedFeatureIds.buffer, faceRange.buffer));
|
|
159
|
+
|
|
160
|
+
if (!draco) {
|
|
161
|
+
_context2.next = 15;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
_context2.next = 12;
|
|
166
|
+
return generateCompressedGeometry(vertexCount, convertedAttributes, {
|
|
167
|
+
positions: positions,
|
|
168
|
+
normals: normals,
|
|
169
|
+
texCoords: texture ? texCoords : new Float32Array(0),
|
|
170
|
+
colors: colors,
|
|
171
|
+
featureIds: featureIds,
|
|
172
|
+
faceRange: faceRange
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
case 12:
|
|
176
|
+
_context2.t0 = _context2.sent;
|
|
177
|
+
_context2.next = 16;
|
|
178
|
+
break;
|
|
179
|
+
|
|
180
|
+
case 15:
|
|
181
|
+
_context2.t0 = null;
|
|
182
|
+
|
|
183
|
+
case 16:
|
|
184
|
+
compressedGeometry = _context2.t0;
|
|
185
|
+
attributes = convertBatchTableToAttributeBuffers(tileContent.batchTableJson, featureIds, attributeStorageInfo);
|
|
186
|
+
return _context2.abrupt("return", {
|
|
187
|
+
geometry: fileBuffer,
|
|
188
|
+
compressedGeometry: compressedGeometry,
|
|
189
|
+
texture: texture,
|
|
190
|
+
sharedResources: getSharedResources(tileContent, nodeId),
|
|
191
|
+
meshMaterial: material,
|
|
192
|
+
vertexCount: vertexCount,
|
|
193
|
+
attributes: attributes,
|
|
194
|
+
featureCount: featureCount
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
case 19:
|
|
198
|
+
case "end":
|
|
199
|
+
return _context2.stop();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}, _callee2);
|
|
203
|
+
}));
|
|
204
|
+
return _makeNodeResources2.apply(this, arguments);
|
|
128
205
|
}
|
|
129
206
|
|
|
130
207
|
function convertAttributes(tileContent) {
|
|
131
|
-
|
|
208
|
+
var attributesMap = new Map();
|
|
132
209
|
|
|
133
|
-
|
|
210
|
+
var _iterator = _createForOfIteratorHelper(tileContent.gltf.materials || [{
|
|
134
211
|
id: 'default'
|
|
135
|
-
}])
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
212
|
+
}]),
|
|
213
|
+
_step;
|
|
214
|
+
|
|
215
|
+
try {
|
|
216
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
217
|
+
var material = _step.value;
|
|
218
|
+
attributesMap.set(material.id, {
|
|
219
|
+
positions: new Float32Array(0),
|
|
220
|
+
normals: new Float32Array(0),
|
|
221
|
+
texCoords: new Float32Array(0),
|
|
222
|
+
colors: new Uint8Array(0),
|
|
223
|
+
featureIndices: []
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
} catch (err) {
|
|
227
|
+
_iterator.e(err);
|
|
228
|
+
} finally {
|
|
229
|
+
_iterator.f();
|
|
143
230
|
}
|
|
144
231
|
|
|
145
|
-
|
|
232
|
+
var nodes = tileContent.gltf.scene.nodes;
|
|
146
233
|
convertNodes(nodes, tileContent, attributesMap);
|
|
147
234
|
|
|
148
|
-
|
|
149
|
-
|
|
235
|
+
var _iterator2 = _createForOfIteratorHelper(attributesMap.keys()),
|
|
236
|
+
_step2;
|
|
150
237
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
238
|
+
try {
|
|
239
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
240
|
+
var attrKey = _step2.value;
|
|
241
|
+
var attributes = attributesMap.get(attrKey);
|
|
155
242
|
|
|
156
|
-
|
|
243
|
+
if (attributes.positions.length === 0) {
|
|
244
|
+
attributesMap.delete(attrKey);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
var vertexCount = attributes.positions.length / VALUES_PER_VERTEX;
|
|
157
249
|
|
|
158
|
-
|
|
159
|
-
|
|
250
|
+
if (!attributes.colors.length) {
|
|
251
|
+
attributes.colors = new Uint8Array(vertexCount * VALUES_PER_COLOR_ELEMENT);
|
|
160
252
|
|
|
161
|
-
|
|
162
|
-
|
|
253
|
+
for (var index = 0; index < attributes.colors.length; index += 4) {
|
|
254
|
+
attributes.colors.set([255, 255, 255, 255], index);
|
|
255
|
+
}
|
|
163
256
|
}
|
|
164
|
-
}
|
|
165
257
|
|
|
166
|
-
|
|
167
|
-
|
|
258
|
+
if (!attributes.texCoords.length) {
|
|
259
|
+
attributes.texCoords = new Float32Array(vertexCount * VALUES_PER_TEX_COORD);
|
|
168
260
|
|
|
169
|
-
|
|
170
|
-
|
|
261
|
+
for (var _index = 0; _index < attributes.texCoords.length; _index += 2) {
|
|
262
|
+
attributes.texCoords.set([1, 1], _index);
|
|
263
|
+
}
|
|
171
264
|
}
|
|
172
|
-
}
|
|
173
265
|
|
|
174
|
-
|
|
266
|
+
attributes.featureIndices = attributes.featureIndices.reduce(function (acc, value) {
|
|
267
|
+
return acc.concat(value);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
} catch (err) {
|
|
271
|
+
_iterator2.e(err);
|
|
272
|
+
} finally {
|
|
273
|
+
_iterator2.f();
|
|
175
274
|
}
|
|
176
275
|
|
|
177
276
|
return attributesMap;
|
|
178
277
|
}
|
|
179
278
|
|
|
180
|
-
function convertNodes(nodes, tileContent, attributesMap
|
|
279
|
+
function convertNodes(nodes, tileContent, attributesMap) {
|
|
280
|
+
var matrix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
281
|
+
|
|
181
282
|
if (nodes) {
|
|
182
|
-
|
|
183
|
-
|
|
283
|
+
var _iterator3 = _createForOfIteratorHelper(nodes),
|
|
284
|
+
_step3;
|
|
285
|
+
|
|
286
|
+
try {
|
|
287
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
288
|
+
var node = _step3.value;
|
|
289
|
+
convertNode(node, tileContent, attributesMap, matrix);
|
|
290
|
+
}
|
|
291
|
+
} catch (err) {
|
|
292
|
+
_iterator3.e(err);
|
|
293
|
+
} finally {
|
|
294
|
+
_iterator3.f();
|
|
184
295
|
}
|
|
185
296
|
}
|
|
186
297
|
}
|
|
187
298
|
|
|
188
|
-
function convertNode(node, tileContent, attributesMap
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
299
|
+
function convertNode(node, tileContent, attributesMap) {
|
|
300
|
+
var matrix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
301
|
+
var nodeMatrix = node.matrix;
|
|
302
|
+
var compositeMatrix = nodeMatrix ? matrix.multiplyRight(nodeMatrix) : matrix;
|
|
303
|
+
var mesh = node.mesh;
|
|
192
304
|
|
|
193
305
|
if (mesh) {
|
|
194
306
|
convertMesh(mesh, tileContent, attributesMap, compositeMatrix);
|
|
@@ -197,56 +309,66 @@ function convertNode(node, tileContent, attributesMap, matrix = new _core.Matrix
|
|
|
197
309
|
convertNodes(node.children, tileContent, attributesMap, compositeMatrix);
|
|
198
310
|
}
|
|
199
311
|
|
|
200
|
-
function convertMesh(mesh, content, attributesMap
|
|
201
|
-
|
|
202
|
-
let outputAttributes = null;
|
|
312
|
+
function convertMesh(mesh, content, attributesMap) {
|
|
313
|
+
var matrix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
203
314
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
} else if (attributesMap.has('default')) {
|
|
207
|
-
outputAttributes = attributesMap.get('default');
|
|
208
|
-
}
|
|
315
|
+
var _iterator4 = _createForOfIteratorHelper(mesh.primitives),
|
|
316
|
+
_step4;
|
|
209
317
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
318
|
+
try {
|
|
319
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
320
|
+
var primitive = _step4.value;
|
|
321
|
+
var outputAttributes = null;
|
|
322
|
+
|
|
323
|
+
if (primitive.material) {
|
|
324
|
+
outputAttributes = attributesMap.get(primitive.material.id);
|
|
325
|
+
} else if (attributesMap.has('default')) {
|
|
326
|
+
outputAttributes = attributesMap.get('default');
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
(0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
|
|
330
|
+
var attributes = primitive.attributes;
|
|
331
|
+
outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
|
|
332
|
+
vertices: attributes.POSITION.value,
|
|
333
|
+
cartographicOrigin: content.cartographicOrigin,
|
|
334
|
+
cartesianModelMatrix: content.cartesianModelMatrix,
|
|
335
|
+
nodeMatrix: matrix,
|
|
336
|
+
indices: primitive.indices.value,
|
|
337
|
+
attributeSpecificTransformation: transformVertexPositions
|
|
338
|
+
}));
|
|
339
|
+
outputAttributes.normals = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.normals, transformVertexArray({
|
|
340
|
+
vertices: attributes.NORMAL && attributes.NORMAL.value,
|
|
341
|
+
cartographicOrigin: content.cartographicOrigin,
|
|
342
|
+
cartesianModelMatrix: content.cartesianModelMatrix,
|
|
343
|
+
nodeMatrix: matrix,
|
|
344
|
+
indices: primitive.indices.value,
|
|
345
|
+
attributeSpecificTransformation: transformVertexNormals
|
|
346
|
+
}));
|
|
347
|
+
outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, primitive.indices.value));
|
|
348
|
+
outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, primitive.indices.value));
|
|
349
|
+
outputAttributes.featureIndices.push(flattenBatchIds(getBatchIdsByAttributeName(attributes), primitive.indices.value));
|
|
350
|
+
}
|
|
351
|
+
} catch (err) {
|
|
352
|
+
_iterator4.e(err);
|
|
353
|
+
} finally {
|
|
354
|
+
_iterator4.f();
|
|
231
355
|
}
|
|
232
356
|
}
|
|
233
357
|
|
|
234
358
|
function transformVertexArray(args) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
} = args;
|
|
240
|
-
const newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
|
|
359
|
+
var vertices = args.vertices,
|
|
360
|
+
indices = args.indices,
|
|
361
|
+
attributeSpecificTransformation = args.attributeSpecificTransformation;
|
|
362
|
+
var newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
|
|
241
363
|
|
|
242
364
|
if (!vertices) {
|
|
243
365
|
return newVertices;
|
|
244
366
|
}
|
|
245
367
|
|
|
246
|
-
for (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
368
|
+
for (var i = 0; i < indices.length; i++) {
|
|
369
|
+
var coordIndex = indices[i] * VALUES_PER_VERTEX;
|
|
370
|
+
var vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
|
|
371
|
+
var vertexVector = new _core.Vector3(Array.from(vertex));
|
|
250
372
|
vertexVector = attributeSpecificTransformation(vertexVector, args);
|
|
251
373
|
newVertices[i * VALUES_PER_VERTEX] = vertexVector.x;
|
|
252
374
|
newVertices[i * VALUES_PER_VERTEX + 1] = vertexVector.y;
|
|
@@ -257,11 +379,9 @@ function transformVertexArray(args) {
|
|
|
257
379
|
}
|
|
258
380
|
|
|
259
381
|
function transformVertexPositions(vertexVector, calleeArgs) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
nodeMatrix
|
|
264
|
-
} = calleeArgs;
|
|
382
|
+
var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
|
|
383
|
+
cartographicOrigin = calleeArgs.cartographicOrigin,
|
|
384
|
+
nodeMatrix = calleeArgs.nodeMatrix;
|
|
265
385
|
|
|
266
386
|
if (nodeMatrix) {
|
|
267
387
|
vertexVector = vertexVector.transform(nodeMatrix);
|
|
@@ -276,10 +396,8 @@ function transformVertexPositions(vertexVector, calleeArgs) {
|
|
|
276
396
|
}
|
|
277
397
|
|
|
278
398
|
function transformVertexNormals(vertexVector, calleeArgs) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
nodeMatrix
|
|
282
|
-
} = calleeArgs;
|
|
399
|
+
var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
|
|
400
|
+
nodeMatrix = calleeArgs.nodeMatrix;
|
|
283
401
|
|
|
284
402
|
if (nodeMatrix) {
|
|
285
403
|
vertexVector = vertexVector.transformAsVector(nodeMatrix);
|
|
@@ -294,11 +412,11 @@ function flattenTexCoords(texCoords, indices) {
|
|
|
294
412
|
return new Float32Array(0);
|
|
295
413
|
}
|
|
296
414
|
|
|
297
|
-
|
|
415
|
+
var newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
|
|
298
416
|
|
|
299
|
-
for (
|
|
300
|
-
|
|
301
|
-
|
|
417
|
+
for (var i = 0; i < indices.length; i++) {
|
|
418
|
+
var coordIndex = indices[i] * VALUES_PER_TEX_COORD;
|
|
419
|
+
var texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
|
|
302
420
|
newTexCoords[i * VALUES_PER_TEX_COORD] = texCoord[0];
|
|
303
421
|
newTexCoords[i * VALUES_PER_TEX_COORD + 1] = texCoord[1];
|
|
304
422
|
}
|
|
@@ -311,16 +429,16 @@ function flattenColors(colorsAttribute, indices) {
|
|
|
311
429
|
return new Uint8Array(0);
|
|
312
430
|
}
|
|
313
431
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
432
|
+
var components = colorsAttribute.components;
|
|
433
|
+
var colors = colorsAttribute.value;
|
|
434
|
+
var newColors = new Uint8Array(indices.length * components);
|
|
317
435
|
|
|
318
|
-
for (
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
436
|
+
for (var i = 0; i < indices.length; i++) {
|
|
437
|
+
var colorIndex = indices[i] * components;
|
|
438
|
+
var color = colors.subarray(colorIndex, colorIndex + components);
|
|
439
|
+
var colorUint8 = new Uint8Array(components);
|
|
322
440
|
|
|
323
|
-
for (
|
|
441
|
+
for (var j = 0; j < color.length; j++) {
|
|
324
442
|
colorUint8[j] = color[j] * 255;
|
|
325
443
|
}
|
|
326
444
|
|
|
@@ -335,10 +453,10 @@ function flattenBatchIds(batchedIds, indices) {
|
|
|
335
453
|
return [];
|
|
336
454
|
}
|
|
337
455
|
|
|
338
|
-
|
|
456
|
+
var newBatchIds = [];
|
|
339
457
|
|
|
340
|
-
for (
|
|
341
|
-
|
|
458
|
+
for (var i = 0; i < indices.length; i++) {
|
|
459
|
+
var coordIndex = indices[i];
|
|
342
460
|
newBatchIds.push(batchedIds[coordIndex]);
|
|
343
461
|
}
|
|
344
462
|
|
|
@@ -346,10 +464,10 @@ function flattenBatchIds(batchedIds, indices) {
|
|
|
346
464
|
}
|
|
347
465
|
|
|
348
466
|
function getBatchIdsByAttributeName(attributes) {
|
|
349
|
-
|
|
467
|
+
var batchIds = [];
|
|
350
468
|
|
|
351
|
-
for (
|
|
352
|
-
|
|
469
|
+
for (var index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
|
|
470
|
+
var possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
|
|
353
471
|
|
|
354
472
|
if (attributes[possibleBatchIdAttributeName] && attributes[possibleBatchIdAttributeName].value) {
|
|
355
473
|
batchIds = attributes[possibleBatchIdAttributeName].value;
|
|
@@ -361,27 +479,39 @@ function getBatchIdsByAttributeName(attributes) {
|
|
|
361
479
|
}
|
|
362
480
|
|
|
363
481
|
function convertMaterials(tileContent) {
|
|
364
|
-
|
|
365
|
-
|
|
482
|
+
var result = [];
|
|
483
|
+
var sourceMaterials = tileContent.gltf.materials;
|
|
366
484
|
|
|
367
|
-
|
|
368
|
-
|
|
485
|
+
var _iterator5 = _createForOfIteratorHelper(sourceMaterials),
|
|
486
|
+
_step5;
|
|
487
|
+
|
|
488
|
+
try {
|
|
489
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
490
|
+
var sourceMaterial = _step5.value;
|
|
491
|
+
result.push(convertMaterial(sourceMaterial));
|
|
492
|
+
}
|
|
493
|
+
} catch (err) {
|
|
494
|
+
_iterator5.e(err);
|
|
495
|
+
} finally {
|
|
496
|
+
_iterator5.f();
|
|
369
497
|
}
|
|
370
498
|
|
|
371
499
|
return result;
|
|
372
500
|
}
|
|
373
501
|
|
|
374
502
|
function convertMaterial(sourceMaterial) {
|
|
375
|
-
|
|
503
|
+
var material = {
|
|
376
504
|
doubleSided: sourceMaterial.doubleSided,
|
|
377
|
-
emissiveFactor: sourceMaterial.emissiveFactor.map(
|
|
505
|
+
emissiveFactor: sourceMaterial.emissiveFactor.map(function (c) {
|
|
506
|
+
return Math.round(c * 255);
|
|
507
|
+
}),
|
|
378
508
|
alphaMode: (sourceMaterial.alphaMode || 'OPAQUE').toLowerCase(),
|
|
379
509
|
pbrMetallicRoughness: {
|
|
380
510
|
roughnessFactor: sourceMaterial.pbrMetallicRoughness.roughnessFactor,
|
|
381
511
|
metallicFactor: sourceMaterial.pbrMetallicRoughness.metallicFactor
|
|
382
512
|
}
|
|
383
513
|
};
|
|
384
|
-
|
|
514
|
+
var texture;
|
|
385
515
|
|
|
386
516
|
if (sourceMaterial.pbrMetallicRoughness.baseColorTexture) {
|
|
387
517
|
texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
|
|
@@ -396,13 +526,15 @@ function convertMaterial(sourceMaterial) {
|
|
|
396
526
|
}
|
|
397
527
|
|
|
398
528
|
if (!texture) {
|
|
399
|
-
|
|
400
|
-
material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(
|
|
529
|
+
var baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;
|
|
530
|
+
material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(function (c) {
|
|
531
|
+
return Math.round(c * 255);
|
|
532
|
+
}) || undefined;
|
|
401
533
|
}
|
|
402
534
|
|
|
403
535
|
return {
|
|
404
|
-
material,
|
|
405
|
-
texture
|
|
536
|
+
material: material,
|
|
537
|
+
texture: texture
|
|
406
538
|
};
|
|
407
539
|
}
|
|
408
540
|
|
|
@@ -414,8 +546,8 @@ function getDefaultMaterial() {
|
|
|
414
546
|
}
|
|
415
547
|
|
|
416
548
|
function getSharedResources(tileContent, nodeId) {
|
|
417
|
-
|
|
418
|
-
|
|
549
|
+
var gltfMaterials = tileContent.gltf.materials;
|
|
550
|
+
var i3sResources = {};
|
|
419
551
|
|
|
420
552
|
if (!gltfMaterials || !gltfMaterials.length) {
|
|
421
553
|
return i3sResources;
|
|
@@ -423,35 +555,45 @@ function getSharedResources(tileContent, nodeId) {
|
|
|
423
555
|
|
|
424
556
|
i3sResources.materialDefinitionInfos = [];
|
|
425
557
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
558
|
+
var _iterator6 = _createForOfIteratorHelper(gltfMaterials),
|
|
559
|
+
_step6;
|
|
560
|
+
|
|
561
|
+
try {
|
|
562
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
563
|
+
var gltfMaterial = _step6.value;
|
|
564
|
+
|
|
565
|
+
var _convertGLTFMaterialT = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId),
|
|
566
|
+
materialDefinitionInfo = _convertGLTFMaterialT.materialDefinitionInfo,
|
|
567
|
+
textureDefinitionInfo = _convertGLTFMaterialT.textureDefinitionInfo;
|
|
568
|
+
|
|
569
|
+
i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
|
|
432
570
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
571
|
+
if (textureDefinitionInfo) {
|
|
572
|
+
i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
|
|
573
|
+
i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
|
|
574
|
+
}
|
|
436
575
|
}
|
|
576
|
+
} catch (err) {
|
|
577
|
+
_iterator6.e(err);
|
|
578
|
+
} finally {
|
|
579
|
+
_iterator6.f();
|
|
437
580
|
}
|
|
438
581
|
|
|
439
582
|
return i3sResources;
|
|
440
583
|
}
|
|
441
584
|
|
|
442
585
|
function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
|
|
443
|
-
|
|
444
|
-
|
|
586
|
+
var texture = gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;
|
|
587
|
+
var textureDefinitionInfo = null;
|
|
445
588
|
|
|
446
589
|
if (texture) {
|
|
447
590
|
textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
|
|
448
591
|
}
|
|
449
592
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
let colorFactor = baseColorFactor;
|
|
593
|
+
var _gltfMaterial$pbrMeta = gltfMaterial.pbrMetallicRoughness,
|
|
594
|
+
baseColorFactor = _gltfMaterial$pbrMeta.baseColorFactor,
|
|
595
|
+
metallicFactor = _gltfMaterial$pbrMeta.metallicFactor;
|
|
596
|
+
var colorFactor = baseColorFactor;
|
|
455
597
|
|
|
456
598
|
if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
|
|
457
599
|
colorFactor = gltfMaterial.emissiveFactor;
|
|
@@ -460,20 +602,21 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
|
|
|
460
602
|
|
|
461
603
|
return {
|
|
462
604
|
materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor, metallicFactor),
|
|
463
|
-
textureDefinitionInfo
|
|
605
|
+
textureDefinitionInfo: textureDefinitionInfo
|
|
464
606
|
};
|
|
465
607
|
}
|
|
466
608
|
|
|
467
|
-
function extractSharedResourcesMaterialInfo(baseColorFactor
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
609
|
+
function extractSharedResourcesMaterialInfo(baseColorFactor) {
|
|
610
|
+
var metallicFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
611
|
+
var matDielectricColorComponent = 0.04 / 255;
|
|
612
|
+
var black = new _core.Vector4(0, 0, 0, 1);
|
|
613
|
+
var unitVector = new _core.Vector4(1, 1, 1, 1);
|
|
614
|
+
var dielectricSpecular = new _core.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
|
|
615
|
+
var baseColorVector = new _core.Vector4(baseColorFactor);
|
|
616
|
+
var firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
|
|
617
|
+
var diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
|
|
475
618
|
dielectricSpecular[3] = 1;
|
|
476
|
-
|
|
619
|
+
var specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
|
|
477
620
|
return {
|
|
478
621
|
diffuse: diffuse.toArray(),
|
|
479
622
|
specular: specular.toArray()
|
|
@@ -492,36 +635,35 @@ function extractSharedResourcesTextureInfo(texture, nodeId) {
|
|
|
492
635
|
}
|
|
493
636
|
|
|
494
637
|
function generateImageId(texture, nodeId) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
const imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
|
|
638
|
+
var _texture$source$image = texture.source.image,
|
|
639
|
+
width = _texture$source$image.width,
|
|
640
|
+
height = _texture$source$image.height;
|
|
641
|
+
var levelCountOfTexture = 1;
|
|
642
|
+
var indexOfLevel = 0;
|
|
643
|
+
var indexOfTextureInStore = nodeId + 1;
|
|
644
|
+
var zerosCount = 32 - indexOfTextureInStore.toString(2).length;
|
|
645
|
+
var rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));
|
|
646
|
+
var shiftedLevelCountOfTexture = levelCountOfTexture << 28;
|
|
647
|
+
var shiftedIndexOfLevel = indexOfLevel << 24;
|
|
648
|
+
var shiftedWidth = width - 1 << 12;
|
|
649
|
+
var shiftedHeight = height - 1 << 0;
|
|
650
|
+
var leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
|
|
651
|
+
var imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
|
|
510
652
|
return imageId.toString();
|
|
511
653
|
}
|
|
512
654
|
|
|
513
655
|
function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, batchTable) {
|
|
514
|
-
|
|
656
|
+
var replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
|
|
515
657
|
replaceIndicesByUnique(featureIndices, replaceMap);
|
|
516
658
|
replaceIndicesByUnique(featureIds, replaceMap);
|
|
517
659
|
}
|
|
518
660
|
|
|
519
661
|
function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
|
|
520
|
-
|
|
662
|
+
var featureMap = {};
|
|
521
663
|
|
|
522
|
-
for (
|
|
523
|
-
|
|
524
|
-
|
|
664
|
+
for (var index = 0; index < featureIds.length; index++) {
|
|
665
|
+
var oldFeatureId = featureIds[index];
|
|
666
|
+
var uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
|
|
525
667
|
featureMap[oldFeatureId.toString()] = uniqueFeatureId;
|
|
526
668
|
}
|
|
527
669
|
|
|
@@ -529,9 +671,9 @@ function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
|
|
|
529
671
|
}
|
|
530
672
|
|
|
531
673
|
function generateStringFromBatchTableByIndex(batchTable, index) {
|
|
532
|
-
|
|
674
|
+
var str = '';
|
|
533
675
|
|
|
534
|
-
for (
|
|
676
|
+
for (var key in batchTable) {
|
|
535
677
|
str += batchTable[key][index];
|
|
536
678
|
}
|
|
537
679
|
|
|
@@ -539,8 +681,8 @@ function generateStringFromBatchTableByIndex(batchTable, index) {
|
|
|
539
681
|
}
|
|
540
682
|
|
|
541
683
|
function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
|
|
542
|
-
|
|
543
|
-
|
|
684
|
+
var batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
|
|
685
|
+
var hash = (0, _md.default)(batchTableStr);
|
|
544
686
|
|
|
545
687
|
if (featuresHashArray.includes(hash)) {
|
|
546
688
|
return featuresHashArray.indexOf(hash);
|
|
@@ -550,23 +692,22 @@ function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
|
|
|
550
692
|
}
|
|
551
693
|
|
|
552
694
|
function replaceIndicesByUnique(indicesArray, featureMap) {
|
|
553
|
-
for (
|
|
695
|
+
for (var index = 0; index < indicesArray.length; index++) {
|
|
554
696
|
indicesArray[index] = featureMap[indicesArray[index]];
|
|
555
697
|
}
|
|
556
698
|
}
|
|
557
699
|
|
|
558
700
|
function convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeStorageInfo) {
|
|
559
|
-
|
|
701
|
+
var attributeBuffers = [];
|
|
560
702
|
|
|
561
703
|
if (batchTable) {
|
|
562
|
-
|
|
563
|
-
OBJECTID: featureIds
|
|
564
|
-
|
|
565
|
-
};
|
|
704
|
+
var batchTableWithFeatureIds = _objectSpread({
|
|
705
|
+
OBJECTID: featureIds
|
|
706
|
+
}, batchTable);
|
|
566
707
|
|
|
567
|
-
for (
|
|
568
|
-
|
|
569
|
-
|
|
708
|
+
for (var key in batchTableWithFeatureIds) {
|
|
709
|
+
var type = getAttributeType(key, attributeStorageInfo);
|
|
710
|
+
var attributeBuffer = null;
|
|
570
711
|
|
|
571
712
|
switch (type) {
|
|
572
713
|
case OBJECT_ID_TYPE:
|
|
@@ -594,104 +735,124 @@ function convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeSt
|
|
|
594
735
|
}
|
|
595
736
|
|
|
596
737
|
function getAttributeType(key, attributeStorageInfo) {
|
|
597
|
-
|
|
738
|
+
var attribute = attributeStorageInfo.find(function (attr) {
|
|
739
|
+
return attr.name === key;
|
|
740
|
+
});
|
|
598
741
|
return attribute.attributeValues.valueType;
|
|
599
742
|
}
|
|
600
743
|
|
|
601
744
|
function generateShortIntegerAttributeBuffer(featureIds) {
|
|
602
|
-
|
|
603
|
-
|
|
745
|
+
var count = new Uint32Array([featureIds.length]);
|
|
746
|
+
var valuesArray = new Uint32Array(featureIds);
|
|
604
747
|
return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, valuesArray.buffer);
|
|
605
748
|
}
|
|
606
749
|
|
|
607
750
|
function generateDoubleAttributeBuffer(featureIds) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
751
|
+
var count = new Uint32Array([featureIds.length]);
|
|
752
|
+
var padding = new Uint8Array(4);
|
|
753
|
+
var valuesArray = new Float64Array(featureIds);
|
|
611
754
|
return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, padding.buffer, valuesArray.buffer);
|
|
612
755
|
}
|
|
613
756
|
|
|
614
757
|
function generateStringAttributeBuffer(batchAttributes) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
for (
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
758
|
+
var stringCountArray = new Uint32Array([batchAttributes.length]);
|
|
759
|
+
var totalNumberOfBytes = 0;
|
|
760
|
+
var stringSizesArray = new Uint32Array(batchAttributes.length);
|
|
761
|
+
var stringBufferArray = [];
|
|
762
|
+
|
|
763
|
+
for (var index = 0; index < batchAttributes.length; index++) {
|
|
764
|
+
var currentString = "".concat(String(batchAttributes[index]), "\0");
|
|
765
|
+
var currentStringBuffer = Buffer.from(currentString);
|
|
766
|
+
var currentStringSize = currentStringBuffer.length;
|
|
624
767
|
totalNumberOfBytes += currentStringSize;
|
|
625
768
|
stringSizesArray[index] = currentStringSize;
|
|
626
769
|
stringBufferArray.push(currentStringBuffer);
|
|
627
770
|
}
|
|
628
771
|
|
|
629
|
-
|
|
630
|
-
return (0,
|
|
772
|
+
var totalBytes = new Uint32Array([totalNumberOfBytes]);
|
|
773
|
+
return _loaderUtils.concatenateArrayBuffers.apply(void 0, [stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer].concat(stringBufferArray));
|
|
631
774
|
}
|
|
632
775
|
|
|
633
776
|
function generateBigUint64Array(featureIds) {
|
|
634
|
-
|
|
777
|
+
var typedFeatureIds = new BigUint64Array(featureIds.length);
|
|
635
778
|
|
|
636
|
-
for (
|
|
779
|
+
for (var index = 0; index < featureIds.length; index++) {
|
|
637
780
|
typedFeatureIds[index] = BigInt(featureIds[index]);
|
|
638
781
|
}
|
|
639
782
|
|
|
640
783
|
return typedFeatureIds;
|
|
641
784
|
}
|
|
642
785
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
featureIds,
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
786
|
+
function generateCompressedGeometry(_x7, _x8, _x9) {
|
|
787
|
+
return _generateCompressedGeometry.apply(this, arguments);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
function _generateCompressedGeometry() {
|
|
791
|
+
_generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(vertexCount, convertedAttributes, attributes) {
|
|
792
|
+
var positions, normals, texCoords, colors, featureIds, faceRange, indices, index, featureIndices, featureIndex, compressedAttributes, attributesMetadata;
|
|
793
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
794
|
+
while (1) {
|
|
795
|
+
switch (_context3.prev = _context3.next) {
|
|
796
|
+
case 0:
|
|
797
|
+
positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
|
|
798
|
+
indices = new Uint32Array(vertexCount);
|
|
799
|
+
|
|
800
|
+
for (index = 0; index < indices.length; index++) {
|
|
801
|
+
indices.set([index], index);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
|
|
805
|
+
featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
|
|
806
|
+
compressedAttributes = {
|
|
807
|
+
positions: positions,
|
|
808
|
+
normals: normals,
|
|
809
|
+
colors: colors,
|
|
810
|
+
'feature-index': featureIndex
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
if (texCoords.length) {
|
|
814
|
+
compressedAttributes.texCoords = texCoords;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
attributesMetadata = {
|
|
818
|
+
'feature-index': {
|
|
819
|
+
'i3s-attribute-type': 'feature-index',
|
|
820
|
+
'i3s-feature-ids': new Int32Array(featureIds)
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
_context3.t0 = Uint8Array;
|
|
824
|
+
_context3.next = 11;
|
|
825
|
+
return (0, _core2.encode)({
|
|
826
|
+
attributes: compressedAttributes,
|
|
827
|
+
indices: indices
|
|
828
|
+
}, _draco.DracoWriter, {
|
|
829
|
+
draco: {
|
|
830
|
+
method: 'MESH_SEQUENTIAL_ENCODING',
|
|
831
|
+
attributesMetadata: attributesMetadata
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
case 11:
|
|
836
|
+
_context3.t1 = _context3.sent;
|
|
837
|
+
return _context3.abrupt("return", new _context3.t0(_context3.t1));
|
|
838
|
+
|
|
839
|
+
case 13:
|
|
840
|
+
case "end":
|
|
841
|
+
return _context3.stop();
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}, _callee3);
|
|
685
845
|
}));
|
|
846
|
+
return _generateCompressedGeometry.apply(this, arguments);
|
|
686
847
|
}
|
|
687
848
|
|
|
688
849
|
function generateFeatureIndexAttribute(featureIndex, faceRange) {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
850
|
+
var orderedFeatureIndices = new Uint32Array(featureIndex.length);
|
|
851
|
+
var fillIndex = 0;
|
|
852
|
+
var startIndex = 0;
|
|
692
853
|
|
|
693
|
-
for (
|
|
694
|
-
|
|
854
|
+
for (var index = 1; index < faceRange.length; index += 2) {
|
|
855
|
+
var endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
|
|
695
856
|
orderedFeatureIndices.fill(fillIndex, startIndex, endIndex);
|
|
696
857
|
fillIndex++;
|
|
697
858
|
startIndex = endIndex + 1;
|