@loaders.gl/terrain 3.4.14 → 3.4.15
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/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/index.js +11 -30
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/decode-quantized-mesh.js +105 -116
- package/dist/es5/lib/decode-quantized-mesh.js.map +1 -1
- package/dist/es5/lib/delatin/index.js +309 -355
- package/dist/es5/lib/delatin/index.js.map +1 -1
- package/dist/es5/lib/helpers/skirt.js +40 -50
- package/dist/es5/lib/helpers/skirt.js.map +1 -1
- package/dist/es5/lib/parse-quantized-mesh.js +43 -45
- package/dist/es5/lib/parse-quantized-mesh.js.map +1 -1
- package/dist/es5/lib/parse-terrain.js +82 -97
- package/dist/es5/lib/parse-terrain.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/lib/utils/version.js.map +1 -1
- package/dist/es5/quantized-mesh-loader.js +2 -2
- package/dist/es5/quantized-mesh-loader.js.map +1 -1
- package/dist/es5/terrain-loader.js +2 -2
- package/dist/es5/terrain-loader.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/quantized-mesh-worker.js +1 -1
- package/dist/terrain-worker.js +1 -1
- package/package.json +5 -5
package/dist/es5/bundle.js
CHANGED
package/dist/es5/bundle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"sources":["../../src/bundle.ts"],"sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"file":"bundle.js","names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"sources":["../../src/bundle.ts"],"sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAS,CAAC;AACxCC,UAAU,CAACC,OAAO,GAAGD,UAAU,CAACC,OAAO,IAAI,CAAC,CAAC;AAC7CC,MAAM,CAACC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACL,UAAU,CAACC,OAAO,EAAEH,aAAa,CAAC"}
|
package/dist/es5/index.js
CHANGED
|
@@ -7,54 +7,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.QuantizedMeshLoader = void 0;
|
|
8
8
|
Object.defineProperty(exports, "QuantizedMeshWorkerLoader", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function
|
|
10
|
+
get: function () {
|
|
11
11
|
return _quantizedMeshLoader.QuantizedMeshLoader;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
exports.TerrainLoader = void 0;
|
|
15
15
|
Object.defineProperty(exports, "TerrainWorkerLoader", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function
|
|
17
|
+
get: function () {
|
|
18
18
|
return _terrainLoader.TerrainLoader;
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
exports._typecheckTerrainLoader = exports._typecheckQuantizedMeshLoader = void 0;
|
|
22
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
23
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
24
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
22
|
var _parseQuantizedMesh = _interopRequireDefault(require("./lib/parse-quantized-mesh"));
|
|
26
23
|
var _parseTerrain = _interopRequireDefault(require("./lib/parse-terrain"));
|
|
27
24
|
var _terrainLoader = require("./terrain-loader");
|
|
28
25
|
var _quantizedMeshLoader = require("./quantized-mesh-loader");
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var TerrainLoader = _objectSpread(_objectSpread({}, _terrainLoader.TerrainLoader), {}, {
|
|
26
|
+
const TerrainLoader = {
|
|
27
|
+
..._terrainLoader.TerrainLoader,
|
|
32
28
|
parse: _parseTerrain.default
|
|
33
|
-
}
|
|
29
|
+
};
|
|
34
30
|
exports.TerrainLoader = TerrainLoader;
|
|
35
|
-
|
|
31
|
+
const _typecheckTerrainLoader = TerrainLoader;
|
|
36
32
|
exports._typecheckTerrainLoader = _typecheckTerrainLoader;
|
|
37
|
-
|
|
33
|
+
const QuantizedMeshLoader = {
|
|
34
|
+
..._quantizedMeshLoader.QuantizedMeshLoader,
|
|
38
35
|
parseSync: _parseQuantizedMesh.default,
|
|
39
|
-
parse:
|
|
40
|
-
|
|
41
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
42
|
-
while (1) switch (_context.prev = _context.next) {
|
|
43
|
-
case 0:
|
|
44
|
-
return _context.abrupt("return", (0, _parseQuantizedMesh.default)(arrayBuffer, options));
|
|
45
|
-
case 1:
|
|
46
|
-
case "end":
|
|
47
|
-
return _context.stop();
|
|
48
|
-
}
|
|
49
|
-
}, _callee);
|
|
50
|
-
}));
|
|
51
|
-
function parse(_x, _x2) {
|
|
52
|
-
return _parse.apply(this, arguments);
|
|
53
|
-
}
|
|
54
|
-
return parse;
|
|
55
|
-
}()
|
|
56
|
-
});
|
|
36
|
+
parse: async (arrayBuffer, options) => (0, _parseQuantizedMesh.default)(arrayBuffer, options)
|
|
37
|
+
};
|
|
57
38
|
exports.QuantizedMeshLoader = QuantizedMeshLoader;
|
|
58
|
-
|
|
39
|
+
const _typecheckQuantizedMeshLoader = QuantizedMeshLoader;
|
|
59
40
|
exports._typecheckQuantizedMeshLoader = _typecheckQuantizedMeshLoader;
|
|
60
41
|
//# sourceMappingURL=index.js.map
|
package/dist/es5/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_parseQuantizedMesh","_interopRequireDefault","require","_parseTerrain","_terrainLoader","_quantizedMeshLoader","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_parseQuantizedMesh","_interopRequireDefault","require","_parseTerrain","_terrainLoader","_quantizedMeshLoader","TerrainLoader","TerrainWorkerLoader","parse","loadTerrain","exports","_typecheckTerrainLoader","QuantizedMeshLoader","QuantizedMeshWorkerLoader","parseSync","parseQuantizedMesh","arrayBuffer","options","_typecheckQuantizedMeshLoader"],"sources":["../../src/index.ts"],"sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport parseQuantizedMesh from './lib/parse-quantized-mesh';\nimport loadTerrain from './lib/parse-terrain';\n\nimport {TerrainLoader as TerrainWorkerLoader} from './terrain-loader';\nimport {QuantizedMeshLoader as QuantizedMeshWorkerLoader} from './quantized-mesh-loader';\n\n// TerrainLoader\n\nexport {TerrainWorkerLoader};\n\nexport const TerrainLoader = {\n ...TerrainWorkerLoader,\n parse: loadTerrain\n};\n\nexport const _typecheckTerrainLoader: LoaderWithParser = TerrainLoader; // eslint-disable-line\n\n// QuantizedMeshLoader\n\nexport {QuantizedMeshWorkerLoader};\n\n/**\n * Loader for quantized meshes\n */\nexport const QuantizedMeshLoader = {\n ...QuantizedMeshWorkerLoader,\n parseSync: parseQuantizedMesh,\n parse: async (arrayBuffer, options) => parseQuantizedMesh(arrayBuffer, options)\n};\n\nexport const _typecheckQuantizedMeshLoader: LoaderWithParser = QuantizedMeshLoader;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAH,OAAA;AAMO,MAAMI,aAAa,GAAG;EAC3B,GAAGC,4BAAmB;EACtBC,KAAK,EAAEC;AACT,CAAC;AAACC,OAAA,CAAAJ,aAAA,GAAAA,aAAA;AAEK,MAAMK,uBAAyC,GAAGL,aAAa;AAACI,OAAA,CAAAC,uBAAA,GAAAA,uBAAA;AAShE,MAAMC,mBAAmB,GAAG;EACjC,GAAGC,wCAAyB;EAC5BC,SAAS,EAAEC,2BAAkB;EAC7BP,KAAK,EAAE,MAAAA,CAAOQ,WAAW,EAAEC,OAAO,KAAK,IAAAF,2BAAkB,EAACC,WAAW,EAAEC,OAAO;AAChF,CAAC;AAACP,OAAA,CAAAE,mBAAA,GAAAA,mBAAA;AAEK,MAAMM,6BAA+C,GAAGN,mBAAmB;AAACF,OAAA,CAAAQ,6BAAA,GAAAA,6BAAA"}
|
|
@@ -1,58 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.DECODING_STEPS = void 0;
|
|
8
7
|
exports.default = decode;
|
|
9
|
-
|
|
10
|
-
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; } } }; }
|
|
11
|
-
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); }
|
|
12
|
-
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; }
|
|
13
|
-
var QUANTIZED_MESH_HEADER = new Map([['centerX', Float64Array.BYTES_PER_ELEMENT], ['centerY', Float64Array.BYTES_PER_ELEMENT], ['centerZ', Float64Array.BYTES_PER_ELEMENT], ['minHeight', Float32Array.BYTES_PER_ELEMENT], ['maxHeight', Float32Array.BYTES_PER_ELEMENT], ['boundingSphereCenterX', Float64Array.BYTES_PER_ELEMENT], ['boundingSphereCenterY', Float64Array.BYTES_PER_ELEMENT], ['boundingSphereCenterZ', Float64Array.BYTES_PER_ELEMENT], ['boundingSphereRadius', Float64Array.BYTES_PER_ELEMENT], ['horizonOcclusionPointX', Float64Array.BYTES_PER_ELEMENT], ['horizonOcclusionPointY', Float64Array.BYTES_PER_ELEMENT], ['horizonOcclusionPointZ', Float64Array.BYTES_PER_ELEMENT]]);
|
|
8
|
+
const QUANTIZED_MESH_HEADER = new Map([['centerX', Float64Array.BYTES_PER_ELEMENT], ['centerY', Float64Array.BYTES_PER_ELEMENT], ['centerZ', Float64Array.BYTES_PER_ELEMENT], ['minHeight', Float32Array.BYTES_PER_ELEMENT], ['maxHeight', Float32Array.BYTES_PER_ELEMENT], ['boundingSphereCenterX', Float64Array.BYTES_PER_ELEMENT], ['boundingSphereCenterY', Float64Array.BYTES_PER_ELEMENT], ['boundingSphereCenterZ', Float64Array.BYTES_PER_ELEMENT], ['boundingSphereRadius', Float64Array.BYTES_PER_ELEMENT], ['horizonOcclusionPointX', Float64Array.BYTES_PER_ELEMENT], ['horizonOcclusionPointY', Float64Array.BYTES_PER_ELEMENT], ['horizonOcclusionPointZ', Float64Array.BYTES_PER_ELEMENT]]);
|
|
14
9
|
function decodeZigZag(value) {
|
|
15
10
|
return value >> 1 ^ -(value & 1);
|
|
16
11
|
}
|
|
17
12
|
function decodeHeader(dataView) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
|
|
25
|
-
key = _step$value[0],
|
|
26
|
-
bytesCount = _step$value[1];
|
|
27
|
-
var getter = bytesCount === 8 ? dataView.getFloat64 : dataView.getFloat32;
|
|
28
|
-
header[key] = getter.call(dataView, position, true);
|
|
29
|
-
position += bytesCount;
|
|
30
|
-
}
|
|
31
|
-
} catch (err) {
|
|
32
|
-
_iterator.e(err);
|
|
33
|
-
} finally {
|
|
34
|
-
_iterator.f();
|
|
13
|
+
let position = 0;
|
|
14
|
+
const header = {};
|
|
15
|
+
for (const [key, bytesCount] of QUANTIZED_MESH_HEADER) {
|
|
16
|
+
const getter = bytesCount === 8 ? dataView.getFloat64 : dataView.getFloat32;
|
|
17
|
+
header[key] = getter.call(dataView, position, true);
|
|
18
|
+
position += bytesCount;
|
|
35
19
|
}
|
|
36
20
|
return {
|
|
37
|
-
header
|
|
21
|
+
header,
|
|
38
22
|
headerEndPosition: position
|
|
39
23
|
};
|
|
40
24
|
}
|
|
41
25
|
function decodeVertexData(dataView, headerEndPosition) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
let position = headerEndPosition;
|
|
27
|
+
const elementsPerVertex = 3;
|
|
28
|
+
const vertexCount = dataView.getUint32(position, true);
|
|
29
|
+
const vertexData = new Uint16Array(vertexCount * elementsPerVertex);
|
|
46
30
|
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
for (
|
|
31
|
+
const bytesPerArrayElement = Uint16Array.BYTES_PER_ELEMENT;
|
|
32
|
+
const elementArrayLength = vertexCount * bytesPerArrayElement;
|
|
33
|
+
const uArrayStartPosition = position;
|
|
34
|
+
const vArrayStartPosition = uArrayStartPosition + elementArrayLength;
|
|
35
|
+
const heightArrayStartPosition = vArrayStartPosition + elementArrayLength;
|
|
36
|
+
let u = 0;
|
|
37
|
+
let v = 0;
|
|
38
|
+
let height = 0;
|
|
39
|
+
for (let i = 0; i < vertexCount; i++) {
|
|
56
40
|
u += decodeZigZag(dataView.getUint16(uArrayStartPosition + bytesPerArrayElement * i, true));
|
|
57
41
|
v += decodeZigZag(dataView.getUint16(vArrayStartPosition + bytesPerArrayElement * i, true));
|
|
58
42
|
height += decodeZigZag(dataView.getUint16(heightArrayStartPosition + bytesPerArrayElement * i, true));
|
|
@@ -62,13 +46,13 @@ function decodeVertexData(dataView, headerEndPosition) {
|
|
|
62
46
|
}
|
|
63
47
|
position += elementArrayLength * 3;
|
|
64
48
|
return {
|
|
65
|
-
vertexData
|
|
49
|
+
vertexData,
|
|
66
50
|
vertexDataEndPosition: position
|
|
67
51
|
};
|
|
68
52
|
}
|
|
69
53
|
function decodeIndex(buffer, position, indicesCount, bytesPerIndex) {
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
let encoded = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
55
|
+
let indices;
|
|
72
56
|
if (bytesPerIndex === 2) {
|
|
73
57
|
indices = new Uint16Array(buffer, position, indicesCount);
|
|
74
58
|
} else {
|
|
@@ -77,9 +61,9 @@ function decodeIndex(buffer, position, indicesCount, bytesPerIndex) {
|
|
|
77
61
|
if (!encoded) {
|
|
78
62
|
return indices;
|
|
79
63
|
}
|
|
80
|
-
|
|
81
|
-
for (
|
|
82
|
-
|
|
64
|
+
let highest = 0;
|
|
65
|
+
for (let i = 0; i < indices.length; ++i) {
|
|
66
|
+
const code = indices[i];
|
|
83
67
|
indices[i] = highest - code;
|
|
84
68
|
if (code === 0) {
|
|
85
69
|
++highest;
|
|
@@ -88,50 +72,50 @@ function decodeIndex(buffer, position, indicesCount, bytesPerIndex) {
|
|
|
88
72
|
return indices;
|
|
89
73
|
}
|
|
90
74
|
function decodeTriangleIndices(dataView, vertexData, vertexDataEndPosition) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
75
|
+
let position = vertexDataEndPosition;
|
|
76
|
+
const elementsPerVertex = 3;
|
|
77
|
+
const vertexCount = vertexData.length / elementsPerVertex;
|
|
78
|
+
const bytesPerIndex = vertexCount > 65536 ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;
|
|
95
79
|
if (position % bytesPerIndex !== 0) {
|
|
96
80
|
position += bytesPerIndex - position % bytesPerIndex;
|
|
97
81
|
}
|
|
98
|
-
|
|
82
|
+
const triangleCount = dataView.getUint32(position, true);
|
|
99
83
|
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
100
|
-
|
|
101
|
-
|
|
84
|
+
const triangleIndicesCount = triangleCount * 3;
|
|
85
|
+
const triangleIndices = decodeIndex(dataView.buffer, position, triangleIndicesCount, bytesPerIndex);
|
|
102
86
|
position += triangleIndicesCount * bytesPerIndex;
|
|
103
87
|
return {
|
|
104
88
|
triangleIndicesEndPosition: position,
|
|
105
|
-
triangleIndices
|
|
89
|
+
triangleIndices
|
|
106
90
|
};
|
|
107
91
|
}
|
|
108
92
|
function decodeEdgeIndices(dataView, vertexData, triangleIndicesEndPosition) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
93
|
+
let position = triangleIndicesEndPosition;
|
|
94
|
+
const elementsPerVertex = 3;
|
|
95
|
+
const vertexCount = vertexData.length / elementsPerVertex;
|
|
96
|
+
const bytesPerIndex = vertexCount > 65536 ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;
|
|
97
|
+
const westVertexCount = dataView.getUint32(position, true);
|
|
114
98
|
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
115
|
-
|
|
99
|
+
const westIndices = decodeIndex(dataView.buffer, position, westVertexCount, bytesPerIndex, false);
|
|
116
100
|
position += westVertexCount * bytesPerIndex;
|
|
117
|
-
|
|
101
|
+
const southVertexCount = dataView.getUint32(position, true);
|
|
118
102
|
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
119
|
-
|
|
103
|
+
const southIndices = decodeIndex(dataView.buffer, position, southVertexCount, bytesPerIndex, false);
|
|
120
104
|
position += southVertexCount * bytesPerIndex;
|
|
121
|
-
|
|
105
|
+
const eastVertexCount = dataView.getUint32(position, true);
|
|
122
106
|
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
123
|
-
|
|
107
|
+
const eastIndices = decodeIndex(dataView.buffer, position, eastVertexCount, bytesPerIndex, false);
|
|
124
108
|
position += eastVertexCount * bytesPerIndex;
|
|
125
|
-
|
|
109
|
+
const northVertexCount = dataView.getUint32(position, true);
|
|
126
110
|
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
127
|
-
|
|
111
|
+
const northIndices = decodeIndex(dataView.buffer, position, northVertexCount, bytesPerIndex, false);
|
|
128
112
|
position += northVertexCount * bytesPerIndex;
|
|
129
113
|
return {
|
|
130
114
|
edgeIndicesEndPosition: position,
|
|
131
|
-
westIndices
|
|
132
|
-
southIndices
|
|
133
|
-
eastIndices
|
|
134
|
-
northIndices
|
|
115
|
+
westIndices,
|
|
116
|
+
southIndices,
|
|
117
|
+
eastIndices,
|
|
118
|
+
northIndices
|
|
135
119
|
};
|
|
136
120
|
}
|
|
137
121
|
function decodeVertexNormalsExtension(extensionDataView) {
|
|
@@ -141,20 +125,20 @@ function decodeWaterMaskExtension(extensionDataView) {
|
|
|
141
125
|
return extensionDataView.buffer.slice(extensionDataView.byteOffset, extensionDataView.byteOffset + extensionDataView.byteLength);
|
|
142
126
|
}
|
|
143
127
|
function decodeExtensions(dataView, indicesEndPosition) {
|
|
144
|
-
|
|
128
|
+
const extensions = {};
|
|
145
129
|
if (dataView.byteLength <= indicesEndPosition) {
|
|
146
130
|
return {
|
|
147
|
-
extensions
|
|
131
|
+
extensions,
|
|
148
132
|
extensionsEndPosition: indicesEndPosition
|
|
149
133
|
};
|
|
150
134
|
}
|
|
151
|
-
|
|
135
|
+
let position = indicesEndPosition;
|
|
152
136
|
while (position < dataView.byteLength) {
|
|
153
|
-
|
|
137
|
+
const extensionId = dataView.getUint8(position, true);
|
|
154
138
|
position += Uint8Array.BYTES_PER_ELEMENT;
|
|
155
|
-
|
|
139
|
+
const extensionLength = dataView.getUint32(position, true);
|
|
156
140
|
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
157
|
-
|
|
141
|
+
const extensionView = new DataView(dataView.buffer, position, extensionLength);
|
|
158
142
|
switch (extensionId) {
|
|
159
143
|
case 1:
|
|
160
144
|
{
|
|
@@ -172,11 +156,11 @@ function decodeExtensions(dataView, indicesEndPosition) {
|
|
|
172
156
|
position += extensionLength;
|
|
173
157
|
}
|
|
174
158
|
return {
|
|
175
|
-
extensions
|
|
159
|
+
extensions,
|
|
176
160
|
extensionsEndPosition: position
|
|
177
161
|
};
|
|
178
162
|
}
|
|
179
|
-
|
|
163
|
+
const DECODING_STEPS = {
|
|
180
164
|
header: 0,
|
|
181
165
|
vertices: 1,
|
|
182
166
|
triangleIndices: 2,
|
|
@@ -184,67 +168,72 @@ var DECODING_STEPS = {
|
|
|
184
168
|
extensions: 4
|
|
185
169
|
};
|
|
186
170
|
exports.DECODING_STEPS = DECODING_STEPS;
|
|
187
|
-
|
|
171
|
+
const DEFAULT_OPTIONS = {
|
|
188
172
|
maxDecodingStep: DECODING_STEPS.extensions
|
|
189
173
|
};
|
|
190
174
|
function decode(data, userOptions) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
header
|
|
195
|
-
headerEndPosition
|
|
175
|
+
const options = Object.assign({}, DEFAULT_OPTIONS, userOptions);
|
|
176
|
+
const view = new DataView(data);
|
|
177
|
+
const {
|
|
178
|
+
header,
|
|
179
|
+
headerEndPosition
|
|
180
|
+
} = decodeHeader(view);
|
|
196
181
|
if (options.maxDecodingStep < DECODING_STEPS.vertices) {
|
|
197
182
|
return {
|
|
198
|
-
header
|
|
183
|
+
header
|
|
199
184
|
};
|
|
200
185
|
}
|
|
201
|
-
|
|
202
|
-
vertexData
|
|
203
|
-
vertexDataEndPosition
|
|
186
|
+
const {
|
|
187
|
+
vertexData,
|
|
188
|
+
vertexDataEndPosition
|
|
189
|
+
} = decodeVertexData(view, headerEndPosition);
|
|
204
190
|
if (options.maxDecodingStep < DECODING_STEPS.triangleIndices) {
|
|
205
191
|
return {
|
|
206
|
-
header
|
|
207
|
-
vertexData
|
|
192
|
+
header,
|
|
193
|
+
vertexData
|
|
208
194
|
};
|
|
209
195
|
}
|
|
210
|
-
|
|
211
|
-
triangleIndices
|
|
212
|
-
triangleIndicesEndPosition
|
|
196
|
+
const {
|
|
197
|
+
triangleIndices,
|
|
198
|
+
triangleIndicesEndPosition
|
|
199
|
+
} = decodeTriangleIndices(view, vertexData, vertexDataEndPosition);
|
|
213
200
|
if (options.maxDecodingStep < DECODING_STEPS.edgeIndices) {
|
|
214
201
|
return {
|
|
215
|
-
header
|
|
216
|
-
vertexData
|
|
217
|
-
triangleIndices
|
|
202
|
+
header,
|
|
203
|
+
vertexData,
|
|
204
|
+
triangleIndices
|
|
218
205
|
};
|
|
219
206
|
}
|
|
220
|
-
|
|
221
|
-
westIndices
|
|
222
|
-
southIndices
|
|
223
|
-
eastIndices
|
|
224
|
-
northIndices
|
|
225
|
-
edgeIndicesEndPosition
|
|
207
|
+
const {
|
|
208
|
+
westIndices,
|
|
209
|
+
southIndices,
|
|
210
|
+
eastIndices,
|
|
211
|
+
northIndices,
|
|
212
|
+
edgeIndicesEndPosition
|
|
213
|
+
} = decodeEdgeIndices(view, vertexData, triangleIndicesEndPosition);
|
|
226
214
|
if (options.maxDecodingStep < DECODING_STEPS.extensions) {
|
|
227
215
|
return {
|
|
228
|
-
header
|
|
229
|
-
vertexData
|
|
230
|
-
triangleIndices
|
|
231
|
-
westIndices
|
|
232
|
-
northIndices
|
|
233
|
-
eastIndices
|
|
234
|
-
southIndices
|
|
216
|
+
header,
|
|
217
|
+
vertexData,
|
|
218
|
+
triangleIndices,
|
|
219
|
+
westIndices,
|
|
220
|
+
northIndices,
|
|
221
|
+
eastIndices,
|
|
222
|
+
southIndices
|
|
235
223
|
};
|
|
236
224
|
}
|
|
237
|
-
|
|
238
|
-
extensions
|
|
225
|
+
const {
|
|
226
|
+
extensions
|
|
227
|
+
} = decodeExtensions(view, edgeIndicesEndPosition);
|
|
239
228
|
return {
|
|
240
|
-
header
|
|
241
|
-
vertexData
|
|
242
|
-
triangleIndices
|
|
243
|
-
westIndices
|
|
244
|
-
northIndices
|
|
245
|
-
eastIndices
|
|
246
|
-
southIndices
|
|
247
|
-
extensions
|
|
229
|
+
header,
|
|
230
|
+
vertexData,
|
|
231
|
+
triangleIndices,
|
|
232
|
+
westIndices,
|
|
233
|
+
northIndices,
|
|
234
|
+
eastIndices,
|
|
235
|
+
southIndices,
|
|
236
|
+
extensions
|
|
248
237
|
};
|
|
249
238
|
}
|
|
250
239
|
//# sourceMappingURL=decode-quantized-mesh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decode-quantized-mesh.js","names":["QUANTIZED_MESH_HEADER","Map","Float64Array","BYTES_PER_ELEMENT","Float32Array","decodeZigZag","value","decodeHeader","dataView","position","header","_iterator","_createForOfIteratorHelper","_step","s","n","done","_step$value","_slicedToArray2","default","key","bytesCount","getter","getFloat64","getFloat32","call","err","e","f","headerEndPosition","decodeVertexData","elementsPerVertex","vertexCount","getUint32","vertexData","Uint16Array","Uint32Array","bytesPerArrayElement","elementArrayLength","uArrayStartPosition","vArrayStartPosition","heightArrayStartPosition","u","v","height","i","getUint16","vertexDataEndPosition","decodeIndex","buffer","indicesCount","bytesPerIndex","encoded","arguments","length","undefined","indices","highest","code","decodeTriangleIndices","triangleCount","triangleIndicesCount","triangleIndices","triangleIndicesEndPosition","decodeEdgeIndices","westVertexCount","westIndices","southVertexCount","southIndices","eastVertexCount","eastIndices","northVertexCount","northIndices","edgeIndicesEndPosition","decodeVertexNormalsExtension","extensionDataView","Uint8Array","byteOffset","byteLength","decodeWaterMaskExtension","slice","decodeExtensions","indicesEndPosition","extensions","extensionsEndPosition","extensionId","getUint8","extensionLength","extensionView","DataView","vertexNormals","waterMask","DECODING_STEPS","vertices","edgeIndices","exports","DEFAULT_OPTIONS","maxDecodingStep","decode","data","userOptions","options","Object","assign","view","_decodeHeader","_decodeVertexData","_decodeTriangleIndice","_decodeEdgeIndices","_decodeExtensions"],"sources":["../../../src/lib/decode-quantized-mesh.ts"],"sourcesContent":["// Copyright (C) 2018-2019 HERE Europe B.V.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nconst QUANTIZED_MESH_HEADER = new Map([\n ['centerX', Float64Array.BYTES_PER_ELEMENT],\n ['centerY', Float64Array.BYTES_PER_ELEMENT],\n ['centerZ', Float64Array.BYTES_PER_ELEMENT],\n\n ['minHeight', Float32Array.BYTES_PER_ELEMENT],\n ['maxHeight', Float32Array.BYTES_PER_ELEMENT],\n\n ['boundingSphereCenterX', Float64Array.BYTES_PER_ELEMENT],\n ['boundingSphereCenterY', Float64Array.BYTES_PER_ELEMENT],\n ['boundingSphereCenterZ', Float64Array.BYTES_PER_ELEMENT],\n ['boundingSphereRadius', Float64Array.BYTES_PER_ELEMENT],\n\n ['horizonOcclusionPointX', Float64Array.BYTES_PER_ELEMENT],\n ['horizonOcclusionPointY', Float64Array.BYTES_PER_ELEMENT],\n ['horizonOcclusionPointZ', Float64Array.BYTES_PER_ELEMENT]\n]);\n\nfunction decodeZigZag(value) {\n return (value >> 1) ^ -(value & 1);\n}\n\nfunction decodeHeader(dataView) {\n let position = 0;\n const header = {};\n\n for (const [key, bytesCount] of QUANTIZED_MESH_HEADER) {\n const getter = bytesCount === 8 ? dataView.getFloat64 : dataView.getFloat32;\n\n header[key] = getter.call(dataView, position, true);\n position += bytesCount;\n }\n\n return {header, headerEndPosition: position};\n}\n\nfunction decodeVertexData(dataView, headerEndPosition) {\n let position = headerEndPosition;\n const elementsPerVertex = 3;\n const vertexCount = dataView.getUint32(position, true);\n const vertexData = new Uint16Array(vertexCount * elementsPerVertex);\n\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const bytesPerArrayElement = Uint16Array.BYTES_PER_ELEMENT;\n const elementArrayLength = vertexCount * bytesPerArrayElement;\n const uArrayStartPosition = position;\n const vArrayStartPosition = uArrayStartPosition + elementArrayLength;\n const heightArrayStartPosition = vArrayStartPosition + elementArrayLength;\n\n let u = 0;\n let v = 0;\n let height = 0;\n\n for (let i = 0; i < vertexCount; i++) {\n u += decodeZigZag(dataView.getUint16(uArrayStartPosition + bytesPerArrayElement * i, true));\n v += decodeZigZag(dataView.getUint16(vArrayStartPosition + bytesPerArrayElement * i, true));\n height += decodeZigZag(\n dataView.getUint16(heightArrayStartPosition + bytesPerArrayElement * i, true)\n );\n\n vertexData[i] = u;\n vertexData[i + vertexCount] = v;\n vertexData[i + vertexCount * 2] = height;\n }\n\n position += elementArrayLength * 3;\n\n return {vertexData, vertexDataEndPosition: position};\n}\n\nfunction decodeIndex(buffer, position, indicesCount, bytesPerIndex, encoded = true) {\n let indices;\n\n if (bytesPerIndex === 2) {\n indices = new Uint16Array(buffer, position, indicesCount);\n } else {\n indices = new Uint32Array(buffer, position, indicesCount);\n }\n\n if (!encoded) {\n return indices;\n }\n\n let highest = 0;\n\n for (let i = 0; i < indices.length; ++i) {\n const code = indices[i];\n\n indices[i] = highest - code;\n\n if (code === 0) {\n ++highest;\n }\n }\n\n return indices;\n}\n\nfunction decodeTriangleIndices(dataView, vertexData, vertexDataEndPosition) {\n let position = vertexDataEndPosition;\n const elementsPerVertex = 3;\n const vertexCount = vertexData.length / elementsPerVertex;\n const bytesPerIndex =\n vertexCount > 65536 ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;\n\n if (position % bytesPerIndex !== 0) {\n position += bytesPerIndex - (position % bytesPerIndex);\n }\n\n const triangleCount = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const triangleIndicesCount = triangleCount * 3;\n const triangleIndices = decodeIndex(\n dataView.buffer,\n position,\n triangleIndicesCount,\n bytesPerIndex\n );\n position += triangleIndicesCount * bytesPerIndex;\n\n return {\n triangleIndicesEndPosition: position,\n triangleIndices\n };\n}\n\nfunction decodeEdgeIndices(dataView, vertexData, triangleIndicesEndPosition) {\n let position = triangleIndicesEndPosition;\n const elementsPerVertex = 3;\n const vertexCount = vertexData.length / elementsPerVertex;\n const bytesPerIndex =\n vertexCount > 65536 ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;\n\n const westVertexCount = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const westIndices = decodeIndex(dataView.buffer, position, westVertexCount, bytesPerIndex, false);\n position += westVertexCount * bytesPerIndex;\n\n const southVertexCount = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const southIndices = decodeIndex(\n dataView.buffer,\n position,\n southVertexCount,\n bytesPerIndex,\n false\n );\n position += southVertexCount * bytesPerIndex;\n\n const eastVertexCount = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const eastIndices = decodeIndex(dataView.buffer, position, eastVertexCount, bytesPerIndex, false);\n position += eastVertexCount * bytesPerIndex;\n\n const northVertexCount = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const northIndices = decodeIndex(\n dataView.buffer,\n position,\n northVertexCount,\n bytesPerIndex,\n false\n );\n position += northVertexCount * bytesPerIndex;\n\n return {\n edgeIndicesEndPosition: position,\n westIndices,\n southIndices,\n eastIndices,\n northIndices\n };\n}\n\nfunction decodeVertexNormalsExtension(extensionDataView) {\n return new Uint8Array(\n extensionDataView.buffer,\n extensionDataView.byteOffset,\n extensionDataView.byteLength\n );\n}\n\nfunction decodeWaterMaskExtension(extensionDataView) {\n return extensionDataView.buffer.slice(\n extensionDataView.byteOffset,\n extensionDataView.byteOffset + extensionDataView.byteLength\n );\n}\n\ntype Extensions = {\n vertexNormals?: any;\n waterMask?: any;\n};\n\nfunction decodeExtensions(dataView, indicesEndPosition) {\n const extensions: Extensions = {};\n\n if (dataView.byteLength <= indicesEndPosition) {\n return {extensions, extensionsEndPosition: indicesEndPosition};\n }\n\n let position = indicesEndPosition;\n\n while (position < dataView.byteLength) {\n const extensionId = dataView.getUint8(position, true);\n position += Uint8Array.BYTES_PER_ELEMENT;\n\n const extensionLength = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const extensionView = new DataView(dataView.buffer, position, extensionLength);\n\n switch (extensionId) {\n case 1: {\n extensions.vertexNormals = decodeVertexNormalsExtension(extensionView);\n\n break;\n }\n case 2: {\n extensions.waterMask = decodeWaterMaskExtension(extensionView);\n\n break;\n }\n default: {\n // console.warn(`Unknown extension with id ${extensionId}`)\n }\n }\n\n position += extensionLength;\n }\n\n return {extensions, extensionsEndPosition: position};\n}\n\nexport const DECODING_STEPS = {\n header: 0,\n vertices: 1,\n triangleIndices: 2,\n edgeIndices: 3,\n extensions: 4\n};\n\nconst DEFAULT_OPTIONS = {\n maxDecodingStep: DECODING_STEPS.extensions\n};\n\nexport default function decode(data, userOptions) {\n const options = Object.assign({}, DEFAULT_OPTIONS, userOptions);\n const view = new DataView(data);\n const {header, headerEndPosition} = decodeHeader(view);\n\n if (options.maxDecodingStep < DECODING_STEPS.vertices) {\n return {header};\n }\n\n const {vertexData, vertexDataEndPosition} = decodeVertexData(view, headerEndPosition);\n\n if (options.maxDecodingStep < DECODING_STEPS.triangleIndices) {\n return {header, vertexData};\n }\n\n const {triangleIndices, triangleIndicesEndPosition} = decodeTriangleIndices(\n view,\n vertexData,\n vertexDataEndPosition\n );\n\n if (options.maxDecodingStep < DECODING_STEPS.edgeIndices) {\n return {header, vertexData, triangleIndices};\n }\n\n const {westIndices, southIndices, eastIndices, northIndices, edgeIndicesEndPosition} =\n decodeEdgeIndices(view, vertexData, triangleIndicesEndPosition);\n\n if (options.maxDecodingStep < DECODING_STEPS.extensions) {\n return {\n header,\n vertexData,\n triangleIndices,\n westIndices,\n northIndices,\n eastIndices,\n southIndices\n };\n }\n\n const {extensions} = decodeExtensions(view, edgeIndicesEndPosition);\n\n return {\n header,\n vertexData,\n triangleIndices,\n westIndices,\n northIndices,\n eastIndices,\n southIndices,\n extensions\n };\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAMA,qBAAqB,GAAG,IAAIC,GAAG,CAAC,CACpC,CAAC,SAAS,EAAEC,YAAY,CAACC,iBAAiB,CAAC,EAC3C,CAAC,SAAS,EAAED,YAAY,CAACC,iBAAiB,CAAC,EAC3C,CAAC,SAAS,EAAED,YAAY,C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;IACZF,WAAW,EAAXA,WAAW;IACXF,YAAY,EAAZA,YAAY;IACZe,UAAU,EAAVA;EACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"decode-quantized-mesh.js","names":["QUANTIZED_MESH_HEADER","Map","Float64Array","BYTES_PER_ELEMENT","Float32Array","decodeZigZag","value","decodeHeader","dataView","position","header","key","bytesCount","getter","getFloat64","getFloat32","call","headerEndPosition","decodeVertexData","elementsPerVertex","vertexCount","getUint32","vertexData","Uint16Array","Uint32Array","bytesPerArrayElement","elementArrayLength","uArrayStartPosition","vArrayStartPosition","heightArrayStartPosition","u","v","height","i","getUint16","vertexDataEndPosition","decodeIndex","buffer","indicesCount","bytesPerIndex","encoded","arguments","length","undefined","indices","highest","code","decodeTriangleIndices","triangleCount","triangleIndicesCount","triangleIndices","triangleIndicesEndPosition","decodeEdgeIndices","westVertexCount","westIndices","southVertexCount","southIndices","eastVertexCount","eastIndices","northVertexCount","northIndices","edgeIndicesEndPosition","decodeVertexNormalsExtension","extensionDataView","Uint8Array","byteOffset","byteLength","decodeWaterMaskExtension","slice","decodeExtensions","indicesEndPosition","extensions","extensionsEndPosition","extensionId","getUint8","extensionLength","extensionView","DataView","vertexNormals","waterMask","DECODING_STEPS","vertices","edgeIndices","exports","DEFAULT_OPTIONS","maxDecodingStep","decode","data","userOptions","options","Object","assign","view"],"sources":["../../../src/lib/decode-quantized-mesh.ts"],"sourcesContent":["// Copyright (C) 2018-2019 HERE Europe B.V.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nconst QUANTIZED_MESH_HEADER = new Map([\n ['centerX', Float64Array.BYTES_PER_ELEMENT],\n ['centerY', Float64Array.BYTES_PER_ELEMENT],\n ['centerZ', Float64Array.BYTES_PER_ELEMENT],\n\n ['minHeight', Float32Array.BYTES_PER_ELEMENT],\n ['maxHeight', Float32Array.BYTES_PER_ELEMENT],\n\n ['boundingSphereCenterX', Float64Array.BYTES_PER_ELEMENT],\n ['boundingSphereCenterY', Float64Array.BYTES_PER_ELEMENT],\n ['boundingSphereCenterZ', Float64Array.BYTES_PER_ELEMENT],\n ['boundingSphereRadius', Float64Array.BYTES_PER_ELEMENT],\n\n ['horizonOcclusionPointX', Float64Array.BYTES_PER_ELEMENT],\n ['horizonOcclusionPointY', Float64Array.BYTES_PER_ELEMENT],\n ['horizonOcclusionPointZ', Float64Array.BYTES_PER_ELEMENT]\n]);\n\nfunction decodeZigZag(value) {\n return (value >> 1) ^ -(value & 1);\n}\n\nfunction decodeHeader(dataView) {\n let position = 0;\n const header = {};\n\n for (const [key, bytesCount] of QUANTIZED_MESH_HEADER) {\n const getter = bytesCount === 8 ? dataView.getFloat64 : dataView.getFloat32;\n\n header[key] = getter.call(dataView, position, true);\n position += bytesCount;\n }\n\n return {header, headerEndPosition: position};\n}\n\nfunction decodeVertexData(dataView, headerEndPosition) {\n let position = headerEndPosition;\n const elementsPerVertex = 3;\n const vertexCount = dataView.getUint32(position, true);\n const vertexData = new Uint16Array(vertexCount * elementsPerVertex);\n\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const bytesPerArrayElement = Uint16Array.BYTES_PER_ELEMENT;\n const elementArrayLength = vertexCount * bytesPerArrayElement;\n const uArrayStartPosition = position;\n const vArrayStartPosition = uArrayStartPosition + elementArrayLength;\n const heightArrayStartPosition = vArrayStartPosition + elementArrayLength;\n\n let u = 0;\n let v = 0;\n let height = 0;\n\n for (let i = 0; i < vertexCount; i++) {\n u += decodeZigZag(dataView.getUint16(uArrayStartPosition + bytesPerArrayElement * i, true));\n v += decodeZigZag(dataView.getUint16(vArrayStartPosition + bytesPerArrayElement * i, true));\n height += decodeZigZag(\n dataView.getUint16(heightArrayStartPosition + bytesPerArrayElement * i, true)\n );\n\n vertexData[i] = u;\n vertexData[i + vertexCount] = v;\n vertexData[i + vertexCount * 2] = height;\n }\n\n position += elementArrayLength * 3;\n\n return {vertexData, vertexDataEndPosition: position};\n}\n\nfunction decodeIndex(buffer, position, indicesCount, bytesPerIndex, encoded = true) {\n let indices;\n\n if (bytesPerIndex === 2) {\n indices = new Uint16Array(buffer, position, indicesCount);\n } else {\n indices = new Uint32Array(buffer, position, indicesCount);\n }\n\n if (!encoded) {\n return indices;\n }\n\n let highest = 0;\n\n for (let i = 0; i < indices.length; ++i) {\n const code = indices[i];\n\n indices[i] = highest - code;\n\n if (code === 0) {\n ++highest;\n }\n }\n\n return indices;\n}\n\nfunction decodeTriangleIndices(dataView, vertexData, vertexDataEndPosition) {\n let position = vertexDataEndPosition;\n const elementsPerVertex = 3;\n const vertexCount = vertexData.length / elementsPerVertex;\n const bytesPerIndex =\n vertexCount > 65536 ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;\n\n if (position % bytesPerIndex !== 0) {\n position += bytesPerIndex - (position % bytesPerIndex);\n }\n\n const triangleCount = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const triangleIndicesCount = triangleCount * 3;\n const triangleIndices = decodeIndex(\n dataView.buffer,\n position,\n triangleIndicesCount,\n bytesPerIndex\n );\n position += triangleIndicesCount * bytesPerIndex;\n\n return {\n triangleIndicesEndPosition: position,\n triangleIndices\n };\n}\n\nfunction decodeEdgeIndices(dataView, vertexData, triangleIndicesEndPosition) {\n let position = triangleIndicesEndPosition;\n const elementsPerVertex = 3;\n const vertexCount = vertexData.length / elementsPerVertex;\n const bytesPerIndex =\n vertexCount > 65536 ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;\n\n const westVertexCount = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const westIndices = decodeIndex(dataView.buffer, position, westVertexCount, bytesPerIndex, false);\n position += westVertexCount * bytesPerIndex;\n\n const southVertexCount = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const southIndices = decodeIndex(\n dataView.buffer,\n position,\n southVertexCount,\n bytesPerIndex,\n false\n );\n position += southVertexCount * bytesPerIndex;\n\n const eastVertexCount = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const eastIndices = decodeIndex(dataView.buffer, position, eastVertexCount, bytesPerIndex, false);\n position += eastVertexCount * bytesPerIndex;\n\n const northVertexCount = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const northIndices = decodeIndex(\n dataView.buffer,\n position,\n northVertexCount,\n bytesPerIndex,\n false\n );\n position += northVertexCount * bytesPerIndex;\n\n return {\n edgeIndicesEndPosition: position,\n westIndices,\n southIndices,\n eastIndices,\n northIndices\n };\n}\n\nfunction decodeVertexNormalsExtension(extensionDataView) {\n return new Uint8Array(\n extensionDataView.buffer,\n extensionDataView.byteOffset,\n extensionDataView.byteLength\n );\n}\n\nfunction decodeWaterMaskExtension(extensionDataView) {\n return extensionDataView.buffer.slice(\n extensionDataView.byteOffset,\n extensionDataView.byteOffset + extensionDataView.byteLength\n );\n}\n\ntype Extensions = {\n vertexNormals?: any;\n waterMask?: any;\n};\n\nfunction decodeExtensions(dataView, indicesEndPosition) {\n const extensions: Extensions = {};\n\n if (dataView.byteLength <= indicesEndPosition) {\n return {extensions, extensionsEndPosition: indicesEndPosition};\n }\n\n let position = indicesEndPosition;\n\n while (position < dataView.byteLength) {\n const extensionId = dataView.getUint8(position, true);\n position += Uint8Array.BYTES_PER_ELEMENT;\n\n const extensionLength = dataView.getUint32(position, true);\n position += Uint32Array.BYTES_PER_ELEMENT;\n\n const extensionView = new DataView(dataView.buffer, position, extensionLength);\n\n switch (extensionId) {\n case 1: {\n extensions.vertexNormals = decodeVertexNormalsExtension(extensionView);\n\n break;\n }\n case 2: {\n extensions.waterMask = decodeWaterMaskExtension(extensionView);\n\n break;\n }\n default: {\n // console.warn(`Unknown extension with id ${extensionId}`)\n }\n }\n\n position += extensionLength;\n }\n\n return {extensions, extensionsEndPosition: position};\n}\n\nexport const DECODING_STEPS = {\n header: 0,\n vertices: 1,\n triangleIndices: 2,\n edgeIndices: 3,\n extensions: 4\n};\n\nconst DEFAULT_OPTIONS = {\n maxDecodingStep: DECODING_STEPS.extensions\n};\n\nexport default function decode(data, userOptions) {\n const options = Object.assign({}, DEFAULT_OPTIONS, userOptions);\n const view = new DataView(data);\n const {header, headerEndPosition} = decodeHeader(view);\n\n if (options.maxDecodingStep < DECODING_STEPS.vertices) {\n return {header};\n }\n\n const {vertexData, vertexDataEndPosition} = decodeVertexData(view, headerEndPosition);\n\n if (options.maxDecodingStep < DECODING_STEPS.triangleIndices) {\n return {header, vertexData};\n }\n\n const {triangleIndices, triangleIndicesEndPosition} = decodeTriangleIndices(\n view,\n vertexData,\n vertexDataEndPosition\n );\n\n if (options.maxDecodingStep < DECODING_STEPS.edgeIndices) {\n return {header, vertexData, triangleIndices};\n }\n\n const {westIndices, southIndices, eastIndices, northIndices, edgeIndicesEndPosition} =\n decodeEdgeIndices(view, vertexData, triangleIndicesEndPosition);\n\n if (options.maxDecodingStep < DECODING_STEPS.extensions) {\n return {\n header,\n vertexData,\n triangleIndices,\n westIndices,\n northIndices,\n eastIndices,\n southIndices\n };\n }\n\n const {extensions} = decodeExtensions(view, edgeIndicesEndPosition);\n\n return {\n header,\n vertexData,\n triangleIndices,\n westIndices,\n northIndices,\n eastIndices,\n southIndices,\n extensions\n };\n}\n"],"mappings":";;;;;;;AAoBA,MAAMA,qBAAqB,GAAG,IAAIC,GAAG,CAAC,CACpC,CAAC,SAAS,EAAEC,YAAY,CAACC,iBAAiB,CAAC,EAC3C,CAAC,SAAS,EAAED,YAAY,CAACC,iBAAiB,CAAC,EAC3C,CAAC,SAAS,EAAED,YAAY,CAACC,iBAAiB,CAAC,EAE3C,CAAC,WAAW,EAAEC,YAAY,CAACD,iBAAiB,CAAC,EAC7C,CAAC,WAAW,EAAEC,YAAY,CAACD,iBAAiB,CAAC,EAE7C,CAAC,uBAAuB,EAAED,YAAY,CAACC,iBAAiB,CAAC,EACzD,CAAC,uBAAuB,EAAED,YAAY,CAACC,iBAAiB,CAAC,EACzD,CAAC,uBAAuB,EAAED,YAAY,CAACC,iBAAiB,CAAC,EACzD,CAAC,sBAAsB,EAAED,YAAY,CAACC,iBAAiB,CAAC,EAExD,CAAC,wBAAwB,EAAED,YAAY,CAACC,iBAAiB,CAAC,EAC1D,CAAC,wBAAwB,EAAED,YAAY,CAACC,iBAAiB,CAAC,EAC1D,CAAC,wBAAwB,EAAED,YAAY,CAACC,iBAAiB,CAAC,CAC3D,CAAC;AAEF,SAASE,YAAYA,CAACC,KAAK,EAAE;EAC3B,OAAQA,KAAK,IAAI,CAAC,GAAI,EAAEA,KAAK,GAAG,CAAC,CAAC;AACpC;AAEA,SAASC,YAAYA,CAACC,QAAQ,EAAE;EAC9B,IAAIC,QAAQ,GAAG,CAAC;EAChB,MAAMC,MAAM,GAAG,CAAC,CAAC;EAEjB,KAAK,MAAM,CAACC,GAAG,EAAEC,UAAU,CAAC,IAAIZ,qBAAqB,EAAE;IACrD,MAAMa,MAAM,GAAGD,UAAU,KAAK,CAAC,GAAGJ,QAAQ,CAAC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