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