@loaders.gl/terrain 3.4.11 → 3.4.13
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/lib/utils/version.js +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/bundle.js +0 -5
- package/dist/index.js +0 -26
- package/dist/lib/decode-quantized-mesh.js +0 -227
- package/dist/lib/delatin/index.js +0 -418
- package/dist/lib/helpers/skirt.js +0 -127
- package/dist/lib/parse-quantized-mesh.js +0 -99
- package/dist/lib/parse-terrain.js +0 -165
- package/dist/lib/utils/version.js +0 -7
- package/dist/quantized-mesh-loader.js +0 -23
- package/dist/terrain-loader.js +0 -34
- package/dist/workers/quantized-mesh-worker.js +0 -5
- package/dist/workers/terrain-worker.js +0 -5
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.VERSION = void 0;
|
|
7
|
-
var VERSION = typeof "3.4.
|
|
7
|
+
var VERSION = typeof "3.4.13" !== 'undefined' ? "3.4.13" : 'latest';
|
|
8
8
|
exports.VERSION = VERSION;
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = typeof "3.4.
|
|
1
|
+
export const VERSION = typeof "3.4.13" !== 'undefined' ? "3.4.13" : 'latest';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/dist/terrain-worker.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/terrain",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.13",
|
|
4
4
|
"description": "Framework-independent loader for terrain raster formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@babel/runtime": "^7.3.1",
|
|
38
|
-
"@loaders.gl/images": "3.4.
|
|
39
|
-
"@loaders.gl/loader-utils": "3.4.
|
|
40
|
-
"@loaders.gl/schema": "3.4.
|
|
38
|
+
"@loaders.gl/images": "3.4.13",
|
|
39
|
+
"@loaders.gl/loader-utils": "3.4.13",
|
|
40
|
+
"@loaders.gl/schema": "3.4.13",
|
|
41
41
|
"@mapbox/martini": "^0.2.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "be8849c02972ce541e01720d29b976f830d6af92"
|
|
44
44
|
}
|
package/dist/bundle.js
DELETED
package/dist/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports._typecheckQuantizedMeshLoader = exports.QuantizedMeshLoader = exports.QuantizedMeshWorkerLoader = exports._typecheckTerrainLoader = exports.TerrainLoader = exports.TerrainWorkerLoader = void 0;
|
|
7
|
-
const parse_quantized_mesh_1 = __importDefault(require("./lib/parse-quantized-mesh"));
|
|
8
|
-
const parse_terrain_1 = __importDefault(require("./lib/parse-terrain"));
|
|
9
|
-
const terrain_loader_1 = require("./terrain-loader");
|
|
10
|
-
Object.defineProperty(exports, "TerrainWorkerLoader", { enumerable: true, get: function () { return terrain_loader_1.TerrainLoader; } });
|
|
11
|
-
const quantized_mesh_loader_1 = require("./quantized-mesh-loader");
|
|
12
|
-
Object.defineProperty(exports, "QuantizedMeshWorkerLoader", { enumerable: true, get: function () { return quantized_mesh_loader_1.QuantizedMeshLoader; } });
|
|
13
|
-
exports.TerrainLoader = {
|
|
14
|
-
...terrain_loader_1.TerrainLoader,
|
|
15
|
-
parse: parse_terrain_1.default
|
|
16
|
-
};
|
|
17
|
-
exports._typecheckTerrainLoader = exports.TerrainLoader; // eslint-disable-line
|
|
18
|
-
/**
|
|
19
|
-
* Loader for quantized meshes
|
|
20
|
-
*/
|
|
21
|
-
exports.QuantizedMeshLoader = {
|
|
22
|
-
...quantized_mesh_loader_1.QuantizedMeshLoader,
|
|
23
|
-
parseSync: parse_quantized_mesh_1.default,
|
|
24
|
-
parse: async (arrayBuffer, options) => (0, parse_quantized_mesh_1.default)(arrayBuffer, options)
|
|
25
|
-
};
|
|
26
|
-
exports._typecheckQuantizedMeshLoader = exports.QuantizedMeshLoader;
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (C) 2018-2019 HERE Europe B.V.
|
|
3
|
-
//
|
|
4
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
// in the Software without restriction, including without limitation the rights
|
|
7
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
// furnished to do so, subject to the following conditions:
|
|
10
|
-
//
|
|
11
|
-
// The above copyright notice and this permission notice shall be included in
|
|
12
|
-
// all copies or substantial portions of the Software.
|
|
13
|
-
//
|
|
14
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
// SOFTWARE.
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.DECODING_STEPS = void 0;
|
|
23
|
-
const QUANTIZED_MESH_HEADER = new Map([
|
|
24
|
-
['centerX', Float64Array.BYTES_PER_ELEMENT],
|
|
25
|
-
['centerY', Float64Array.BYTES_PER_ELEMENT],
|
|
26
|
-
['centerZ', Float64Array.BYTES_PER_ELEMENT],
|
|
27
|
-
['minHeight', Float32Array.BYTES_PER_ELEMENT],
|
|
28
|
-
['maxHeight', Float32Array.BYTES_PER_ELEMENT],
|
|
29
|
-
['boundingSphereCenterX', Float64Array.BYTES_PER_ELEMENT],
|
|
30
|
-
['boundingSphereCenterY', Float64Array.BYTES_PER_ELEMENT],
|
|
31
|
-
['boundingSphereCenterZ', Float64Array.BYTES_PER_ELEMENT],
|
|
32
|
-
['boundingSphereRadius', Float64Array.BYTES_PER_ELEMENT],
|
|
33
|
-
['horizonOcclusionPointX', Float64Array.BYTES_PER_ELEMENT],
|
|
34
|
-
['horizonOcclusionPointY', Float64Array.BYTES_PER_ELEMENT],
|
|
35
|
-
['horizonOcclusionPointZ', Float64Array.BYTES_PER_ELEMENT]
|
|
36
|
-
]);
|
|
37
|
-
function decodeZigZag(value) {
|
|
38
|
-
return (value >> 1) ^ -(value & 1);
|
|
39
|
-
}
|
|
40
|
-
function decodeHeader(dataView) {
|
|
41
|
-
let position = 0;
|
|
42
|
-
const header = {};
|
|
43
|
-
for (const [key, bytesCount] of QUANTIZED_MESH_HEADER) {
|
|
44
|
-
const getter = bytesCount === 8 ? dataView.getFloat64 : dataView.getFloat32;
|
|
45
|
-
header[key] = getter.call(dataView, position, true);
|
|
46
|
-
position += bytesCount;
|
|
47
|
-
}
|
|
48
|
-
return { header, headerEndPosition: position };
|
|
49
|
-
}
|
|
50
|
-
function decodeVertexData(dataView, headerEndPosition) {
|
|
51
|
-
let position = headerEndPosition;
|
|
52
|
-
const elementsPerVertex = 3;
|
|
53
|
-
const vertexCount = dataView.getUint32(position, true);
|
|
54
|
-
const vertexData = new Uint16Array(vertexCount * elementsPerVertex);
|
|
55
|
-
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
56
|
-
const bytesPerArrayElement = Uint16Array.BYTES_PER_ELEMENT;
|
|
57
|
-
const elementArrayLength = vertexCount * bytesPerArrayElement;
|
|
58
|
-
const uArrayStartPosition = position;
|
|
59
|
-
const vArrayStartPosition = uArrayStartPosition + elementArrayLength;
|
|
60
|
-
const heightArrayStartPosition = vArrayStartPosition + elementArrayLength;
|
|
61
|
-
let u = 0;
|
|
62
|
-
let v = 0;
|
|
63
|
-
let height = 0;
|
|
64
|
-
for (let i = 0; i < vertexCount; i++) {
|
|
65
|
-
u += decodeZigZag(dataView.getUint16(uArrayStartPosition + bytesPerArrayElement * i, true));
|
|
66
|
-
v += decodeZigZag(dataView.getUint16(vArrayStartPosition + bytesPerArrayElement * i, true));
|
|
67
|
-
height += decodeZigZag(dataView.getUint16(heightArrayStartPosition + bytesPerArrayElement * i, true));
|
|
68
|
-
vertexData[i] = u;
|
|
69
|
-
vertexData[i + vertexCount] = v;
|
|
70
|
-
vertexData[i + vertexCount * 2] = height;
|
|
71
|
-
}
|
|
72
|
-
position += elementArrayLength * 3;
|
|
73
|
-
return { vertexData, vertexDataEndPosition: position };
|
|
74
|
-
}
|
|
75
|
-
function decodeIndex(buffer, position, indicesCount, bytesPerIndex, encoded = true) {
|
|
76
|
-
let indices;
|
|
77
|
-
if (bytesPerIndex === 2) {
|
|
78
|
-
indices = new Uint16Array(buffer, position, indicesCount);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
indices = new Uint32Array(buffer, position, indicesCount);
|
|
82
|
-
}
|
|
83
|
-
if (!encoded) {
|
|
84
|
-
return indices;
|
|
85
|
-
}
|
|
86
|
-
let highest = 0;
|
|
87
|
-
for (let i = 0; i < indices.length; ++i) {
|
|
88
|
-
const code = indices[i];
|
|
89
|
-
indices[i] = highest - code;
|
|
90
|
-
if (code === 0) {
|
|
91
|
-
++highest;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return indices;
|
|
95
|
-
}
|
|
96
|
-
function decodeTriangleIndices(dataView, vertexData, vertexDataEndPosition) {
|
|
97
|
-
let position = vertexDataEndPosition;
|
|
98
|
-
const elementsPerVertex = 3;
|
|
99
|
-
const vertexCount = vertexData.length / elementsPerVertex;
|
|
100
|
-
const bytesPerIndex = vertexCount > 65536 ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;
|
|
101
|
-
if (position % bytesPerIndex !== 0) {
|
|
102
|
-
position += bytesPerIndex - (position % bytesPerIndex);
|
|
103
|
-
}
|
|
104
|
-
const triangleCount = dataView.getUint32(position, true);
|
|
105
|
-
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
106
|
-
const triangleIndicesCount = triangleCount * 3;
|
|
107
|
-
const triangleIndices = decodeIndex(dataView.buffer, position, triangleIndicesCount, bytesPerIndex);
|
|
108
|
-
position += triangleIndicesCount * bytesPerIndex;
|
|
109
|
-
return {
|
|
110
|
-
triangleIndicesEndPosition: position,
|
|
111
|
-
triangleIndices
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
function decodeEdgeIndices(dataView, vertexData, triangleIndicesEndPosition) {
|
|
115
|
-
let position = triangleIndicesEndPosition;
|
|
116
|
-
const elementsPerVertex = 3;
|
|
117
|
-
const vertexCount = vertexData.length / elementsPerVertex;
|
|
118
|
-
const bytesPerIndex = vertexCount > 65536 ? Uint32Array.BYTES_PER_ELEMENT : Uint16Array.BYTES_PER_ELEMENT;
|
|
119
|
-
const westVertexCount = dataView.getUint32(position, true);
|
|
120
|
-
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
121
|
-
const westIndices = decodeIndex(dataView.buffer, position, westVertexCount, bytesPerIndex, false);
|
|
122
|
-
position += westVertexCount * bytesPerIndex;
|
|
123
|
-
const southVertexCount = dataView.getUint32(position, true);
|
|
124
|
-
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
125
|
-
const southIndices = decodeIndex(dataView.buffer, position, southVertexCount, bytesPerIndex, false);
|
|
126
|
-
position += southVertexCount * bytesPerIndex;
|
|
127
|
-
const eastVertexCount = dataView.getUint32(position, true);
|
|
128
|
-
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
129
|
-
const eastIndices = decodeIndex(dataView.buffer, position, eastVertexCount, bytesPerIndex, false);
|
|
130
|
-
position += eastVertexCount * bytesPerIndex;
|
|
131
|
-
const northVertexCount = dataView.getUint32(position, true);
|
|
132
|
-
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
133
|
-
const northIndices = decodeIndex(dataView.buffer, position, northVertexCount, bytesPerIndex, false);
|
|
134
|
-
position += northVertexCount * bytesPerIndex;
|
|
135
|
-
return {
|
|
136
|
-
edgeIndicesEndPosition: position,
|
|
137
|
-
westIndices,
|
|
138
|
-
southIndices,
|
|
139
|
-
eastIndices,
|
|
140
|
-
northIndices
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function decodeVertexNormalsExtension(extensionDataView) {
|
|
144
|
-
return new Uint8Array(extensionDataView.buffer, extensionDataView.byteOffset, extensionDataView.byteLength);
|
|
145
|
-
}
|
|
146
|
-
function decodeWaterMaskExtension(extensionDataView) {
|
|
147
|
-
return extensionDataView.buffer.slice(extensionDataView.byteOffset, extensionDataView.byteOffset + extensionDataView.byteLength);
|
|
148
|
-
}
|
|
149
|
-
function decodeExtensions(dataView, indicesEndPosition) {
|
|
150
|
-
const extensions = {};
|
|
151
|
-
if (dataView.byteLength <= indicesEndPosition) {
|
|
152
|
-
return { extensions, extensionsEndPosition: indicesEndPosition };
|
|
153
|
-
}
|
|
154
|
-
let position = indicesEndPosition;
|
|
155
|
-
while (position < dataView.byteLength) {
|
|
156
|
-
const extensionId = dataView.getUint8(position, true);
|
|
157
|
-
position += Uint8Array.BYTES_PER_ELEMENT;
|
|
158
|
-
const extensionLength = dataView.getUint32(position, true);
|
|
159
|
-
position += Uint32Array.BYTES_PER_ELEMENT;
|
|
160
|
-
const extensionView = new DataView(dataView.buffer, position, extensionLength);
|
|
161
|
-
switch (extensionId) {
|
|
162
|
-
case 1: {
|
|
163
|
-
extensions.vertexNormals = decodeVertexNormalsExtension(extensionView);
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
case 2: {
|
|
167
|
-
extensions.waterMask = decodeWaterMaskExtension(extensionView);
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
default: {
|
|
171
|
-
// console.warn(`Unknown extension with id ${extensionId}`)
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
position += extensionLength;
|
|
175
|
-
}
|
|
176
|
-
return { extensions, extensionsEndPosition: position };
|
|
177
|
-
}
|
|
178
|
-
exports.DECODING_STEPS = {
|
|
179
|
-
header: 0,
|
|
180
|
-
vertices: 1,
|
|
181
|
-
triangleIndices: 2,
|
|
182
|
-
edgeIndices: 3,
|
|
183
|
-
extensions: 4
|
|
184
|
-
};
|
|
185
|
-
const DEFAULT_OPTIONS = {
|
|
186
|
-
maxDecodingStep: exports.DECODING_STEPS.extensions
|
|
187
|
-
};
|
|
188
|
-
function decode(data, userOptions) {
|
|
189
|
-
const options = Object.assign({}, DEFAULT_OPTIONS, userOptions);
|
|
190
|
-
const view = new DataView(data);
|
|
191
|
-
const { header, headerEndPosition } = decodeHeader(view);
|
|
192
|
-
if (options.maxDecodingStep < exports.DECODING_STEPS.vertices) {
|
|
193
|
-
return { header };
|
|
194
|
-
}
|
|
195
|
-
const { vertexData, vertexDataEndPosition } = decodeVertexData(view, headerEndPosition);
|
|
196
|
-
if (options.maxDecodingStep < exports.DECODING_STEPS.triangleIndices) {
|
|
197
|
-
return { header, vertexData };
|
|
198
|
-
}
|
|
199
|
-
const { triangleIndices, triangleIndicesEndPosition } = decodeTriangleIndices(view, vertexData, vertexDataEndPosition);
|
|
200
|
-
if (options.maxDecodingStep < exports.DECODING_STEPS.edgeIndices) {
|
|
201
|
-
return { header, vertexData, triangleIndices };
|
|
202
|
-
}
|
|
203
|
-
const { westIndices, southIndices, eastIndices, northIndices, edgeIndicesEndPosition } = decodeEdgeIndices(view, vertexData, triangleIndicesEndPosition);
|
|
204
|
-
if (options.maxDecodingStep < exports.DECODING_STEPS.extensions) {
|
|
205
|
-
return {
|
|
206
|
-
header,
|
|
207
|
-
vertexData,
|
|
208
|
-
triangleIndices,
|
|
209
|
-
westIndices,
|
|
210
|
-
northIndices,
|
|
211
|
-
eastIndices,
|
|
212
|
-
southIndices
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
const { extensions } = decodeExtensions(view, edgeIndicesEndPosition);
|
|
216
|
-
return {
|
|
217
|
-
header,
|
|
218
|
-
vertexData,
|
|
219
|
-
triangleIndices,
|
|
220
|
-
westIndices,
|
|
221
|
-
northIndices,
|
|
222
|
-
eastIndices,
|
|
223
|
-
southIndices,
|
|
224
|
-
extensions
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
exports.default = decode;
|
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ISC License
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
// Copyright(c) 2019, Michael Fogleman, Vladimir Agafonkin
|
|
5
|
-
// Permission to use, copy, modify, and / or distribute this software for any purpose
|
|
6
|
-
// with or without fee is hereby granted, provided that the above copyright notice
|
|
7
|
-
// and this permission notice appear in all copies.
|
|
8
|
-
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
10
|
-
// FITNESS.IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
12
|
-
// OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
13
|
-
// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
14
|
-
// THIS SOFTWARE.
|
|
15
|
-
// @ts-nocheck
|
|
16
|
-
/* eslint-disable complexity, max-params, max-statements, max-depth, no-constant-condition */
|
|
17
|
-
class Delatin {
|
|
18
|
-
constructor(data, width, height = width) {
|
|
19
|
-
this.data = data; // height data
|
|
20
|
-
this.width = width;
|
|
21
|
-
this.height = height;
|
|
22
|
-
this.coords = []; // vertex coordinates (x, y)
|
|
23
|
-
this.triangles = []; // mesh triangle indices
|
|
24
|
-
// additional triangle data
|
|
25
|
-
this._halfedges = [];
|
|
26
|
-
this._candidates = [];
|
|
27
|
-
this._queueIndices = [];
|
|
28
|
-
this._queue = []; // queue of added triangles
|
|
29
|
-
this._errors = [];
|
|
30
|
-
this._rms = [];
|
|
31
|
-
this._pending = []; // triangles pending addition to queue
|
|
32
|
-
this._pendingLen = 0;
|
|
33
|
-
this._rmsSum = 0;
|
|
34
|
-
const x1 = width - 1;
|
|
35
|
-
const y1 = height - 1;
|
|
36
|
-
const p0 = this._addPoint(0, 0);
|
|
37
|
-
const p1 = this._addPoint(x1, 0);
|
|
38
|
-
const p2 = this._addPoint(0, y1);
|
|
39
|
-
const p3 = this._addPoint(x1, y1);
|
|
40
|
-
// add initial two triangles
|
|
41
|
-
const t0 = this._addTriangle(p3, p0, p2, -1, -1, -1);
|
|
42
|
-
this._addTriangle(p0, p3, p1, t0, -1, -1);
|
|
43
|
-
this._flush();
|
|
44
|
-
}
|
|
45
|
-
// refine the mesh until its maximum error gets below the given one
|
|
46
|
-
run(maxError = 1) {
|
|
47
|
-
while (this.getMaxError() > maxError) {
|
|
48
|
-
this.refine();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// refine the mesh with a single point
|
|
52
|
-
refine() {
|
|
53
|
-
this._step();
|
|
54
|
-
this._flush();
|
|
55
|
-
}
|
|
56
|
-
// max error of the current mesh
|
|
57
|
-
getMaxError() {
|
|
58
|
-
return this._errors[0];
|
|
59
|
-
}
|
|
60
|
-
// root-mean-square deviation of the current mesh
|
|
61
|
-
getRMSD() {
|
|
62
|
-
return this._rmsSum > 0 ? Math.sqrt(this._rmsSum / (this.width * this.height)) : 0;
|
|
63
|
-
}
|
|
64
|
-
// height value at a given position
|
|
65
|
-
heightAt(x, y) {
|
|
66
|
-
return this.data[this.width * y + x];
|
|
67
|
-
}
|
|
68
|
-
// rasterize and queue all triangles that got added or updated in _step
|
|
69
|
-
_flush() {
|
|
70
|
-
const coords = this.coords;
|
|
71
|
-
for (let i = 0; i < this._pendingLen; i++) {
|
|
72
|
-
const t = this._pending[i];
|
|
73
|
-
// rasterize triangle to find maximum pixel error
|
|
74
|
-
const a = 2 * this.triangles[t * 3 + 0];
|
|
75
|
-
const b = 2 * this.triangles[t * 3 + 1];
|
|
76
|
-
const c = 2 * this.triangles[t * 3 + 2];
|
|
77
|
-
this._findCandidate(coords[a], coords[a + 1], coords[b], coords[b + 1], coords[c], coords[c + 1], t);
|
|
78
|
-
}
|
|
79
|
-
this._pendingLen = 0;
|
|
80
|
-
}
|
|
81
|
-
// rasterize a triangle, find its max error, and queue it for processing
|
|
82
|
-
_findCandidate(p0x, p0y, p1x, p1y, p2x, p2y, t) {
|
|
83
|
-
// triangle bounding box
|
|
84
|
-
const minX = Math.min(p0x, p1x, p2x);
|
|
85
|
-
const minY = Math.min(p0y, p1y, p2y);
|
|
86
|
-
const maxX = Math.max(p0x, p1x, p2x);
|
|
87
|
-
const maxY = Math.max(p0y, p1y, p2y);
|
|
88
|
-
// forward differencing variables
|
|
89
|
-
let w00 = orient(p1x, p1y, p2x, p2y, minX, minY);
|
|
90
|
-
let w01 = orient(p2x, p2y, p0x, p0y, minX, minY);
|
|
91
|
-
let w02 = orient(p0x, p0y, p1x, p1y, minX, minY);
|
|
92
|
-
const a01 = p1y - p0y;
|
|
93
|
-
const b01 = p0x - p1x;
|
|
94
|
-
const a12 = p2y - p1y;
|
|
95
|
-
const b12 = p1x - p2x;
|
|
96
|
-
const a20 = p0y - p2y;
|
|
97
|
-
const b20 = p2x - p0x;
|
|
98
|
-
// pre-multiplied z values at vertices
|
|
99
|
-
const a = orient(p0x, p0y, p1x, p1y, p2x, p2y);
|
|
100
|
-
const z0 = this.heightAt(p0x, p0y) / a;
|
|
101
|
-
const z1 = this.heightAt(p1x, p1y) / a;
|
|
102
|
-
const z2 = this.heightAt(p2x, p2y) / a;
|
|
103
|
-
// iterate over pixels in bounding box
|
|
104
|
-
let maxError = 0;
|
|
105
|
-
let mx = 0;
|
|
106
|
-
let my = 0;
|
|
107
|
-
let rms = 0;
|
|
108
|
-
for (let y = minY; y <= maxY; y++) {
|
|
109
|
-
// compute starting offset
|
|
110
|
-
let dx = 0;
|
|
111
|
-
if (w00 < 0 && a12 !== 0) {
|
|
112
|
-
dx = Math.max(dx, Math.floor(-w00 / a12));
|
|
113
|
-
}
|
|
114
|
-
if (w01 < 0 && a20 !== 0) {
|
|
115
|
-
dx = Math.max(dx, Math.floor(-w01 / a20));
|
|
116
|
-
}
|
|
117
|
-
if (w02 < 0 && a01 !== 0) {
|
|
118
|
-
dx = Math.max(dx, Math.floor(-w02 / a01));
|
|
119
|
-
}
|
|
120
|
-
let w0 = w00 + a12 * dx;
|
|
121
|
-
let w1 = w01 + a20 * dx;
|
|
122
|
-
let w2 = w02 + a01 * dx;
|
|
123
|
-
let wasInside = false;
|
|
124
|
-
for (let x = minX + dx; x <= maxX; x++) {
|
|
125
|
-
// check if inside triangle
|
|
126
|
-
if (w0 >= 0 && w1 >= 0 && w2 >= 0) {
|
|
127
|
-
wasInside = true;
|
|
128
|
-
// compute z using barycentric coordinates
|
|
129
|
-
const z = z0 * w0 + z1 * w1 + z2 * w2;
|
|
130
|
-
const dz = Math.abs(z - this.heightAt(x, y));
|
|
131
|
-
rms += dz * dz;
|
|
132
|
-
if (dz > maxError) {
|
|
133
|
-
maxError = dz;
|
|
134
|
-
mx = x;
|
|
135
|
-
my = y;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else if (wasInside) {
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
w0 += a12;
|
|
142
|
-
w1 += a20;
|
|
143
|
-
w2 += a01;
|
|
144
|
-
}
|
|
145
|
-
w00 += b12;
|
|
146
|
-
w01 += b20;
|
|
147
|
-
w02 += b01;
|
|
148
|
-
}
|
|
149
|
-
if ((mx === p0x && my === p0y) || (mx === p1x && my === p1y) || (mx === p2x && my === p2y)) {
|
|
150
|
-
maxError = 0;
|
|
151
|
-
}
|
|
152
|
-
// update triangle metadata
|
|
153
|
-
this._candidates[2 * t] = mx;
|
|
154
|
-
this._candidates[2 * t + 1] = my;
|
|
155
|
-
this._rms[t] = rms;
|
|
156
|
-
// add triangle to priority queue
|
|
157
|
-
this._queuePush(t, maxError, rms);
|
|
158
|
-
}
|
|
159
|
-
// process the next triangle in the queue, splitting it with a new point
|
|
160
|
-
_step() {
|
|
161
|
-
// pop triangle with highest error from priority queue
|
|
162
|
-
const t = this._queuePop();
|
|
163
|
-
const e0 = t * 3 + 0;
|
|
164
|
-
const e1 = t * 3 + 1;
|
|
165
|
-
const e2 = t * 3 + 2;
|
|
166
|
-
const p0 = this.triangles[e0];
|
|
167
|
-
const p1 = this.triangles[e1];
|
|
168
|
-
const p2 = this.triangles[e2];
|
|
169
|
-
const ax = this.coords[2 * p0];
|
|
170
|
-
const ay = this.coords[2 * p0 + 1];
|
|
171
|
-
const bx = this.coords[2 * p1];
|
|
172
|
-
const by = this.coords[2 * p1 + 1];
|
|
173
|
-
const cx = this.coords[2 * p2];
|
|
174
|
-
const cy = this.coords[2 * p2 + 1];
|
|
175
|
-
const px = this._candidates[2 * t];
|
|
176
|
-
const py = this._candidates[2 * t + 1];
|
|
177
|
-
const pn = this._addPoint(px, py);
|
|
178
|
-
if (orient(ax, ay, bx, by, px, py) === 0) {
|
|
179
|
-
this._handleCollinear(pn, e0);
|
|
180
|
-
}
|
|
181
|
-
else if (orient(bx, by, cx, cy, px, py) === 0) {
|
|
182
|
-
this._handleCollinear(pn, e1);
|
|
183
|
-
}
|
|
184
|
-
else if (orient(cx, cy, ax, ay, px, py) === 0) {
|
|
185
|
-
this._handleCollinear(pn, e2);
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
const h0 = this._halfedges[e0];
|
|
189
|
-
const h1 = this._halfedges[e1];
|
|
190
|
-
const h2 = this._halfedges[e2];
|
|
191
|
-
const t0 = this._addTriangle(p0, p1, pn, h0, -1, -1, e0);
|
|
192
|
-
const t1 = this._addTriangle(p1, p2, pn, h1, -1, t0 + 1);
|
|
193
|
-
const t2 = this._addTriangle(p2, p0, pn, h2, t0 + 2, t1 + 1);
|
|
194
|
-
this._legalize(t0);
|
|
195
|
-
this._legalize(t1);
|
|
196
|
-
this._legalize(t2);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
// add coordinates for a new vertex
|
|
200
|
-
_addPoint(x, y) {
|
|
201
|
-
const i = this.coords.length >> 1;
|
|
202
|
-
this.coords.push(x, y);
|
|
203
|
-
return i;
|
|
204
|
-
}
|
|
205
|
-
// add or update a triangle in the mesh
|
|
206
|
-
_addTriangle(a, b, c, ab, bc, ca, e = this.triangles.length) {
|
|
207
|
-
const t = e / 3; // new triangle index
|
|
208
|
-
// add triangle vertices
|
|
209
|
-
this.triangles[e + 0] = a;
|
|
210
|
-
this.triangles[e + 1] = b;
|
|
211
|
-
this.triangles[e + 2] = c;
|
|
212
|
-
// add triangle halfedges
|
|
213
|
-
this._halfedges[e + 0] = ab;
|
|
214
|
-
this._halfedges[e + 1] = bc;
|
|
215
|
-
this._halfedges[e + 2] = ca;
|
|
216
|
-
// link neighboring halfedges
|
|
217
|
-
if (ab >= 0) {
|
|
218
|
-
this._halfedges[ab] = e + 0;
|
|
219
|
-
}
|
|
220
|
-
if (bc >= 0) {
|
|
221
|
-
this._halfedges[bc] = e + 1;
|
|
222
|
-
}
|
|
223
|
-
if (ca >= 0) {
|
|
224
|
-
this._halfedges[ca] = e + 2;
|
|
225
|
-
}
|
|
226
|
-
// init triangle metadata
|
|
227
|
-
this._candidates[2 * t + 0] = 0;
|
|
228
|
-
this._candidates[2 * t + 1] = 0;
|
|
229
|
-
this._queueIndices[t] = -1;
|
|
230
|
-
this._rms[t] = 0;
|
|
231
|
-
// add triangle to pending queue for later rasterization
|
|
232
|
-
this._pending[this._pendingLen++] = t;
|
|
233
|
-
// return first halfedge index
|
|
234
|
-
return e;
|
|
235
|
-
}
|
|
236
|
-
_legalize(a) {
|
|
237
|
-
// if the pair of triangles doesn't satisfy the Delaunay condition
|
|
238
|
-
// (p1 is inside the circumcircle of [p0, pl, pr]), flip them,
|
|
239
|
-
// then do the same check/flip recursively for the new pair of triangles
|
|
240
|
-
//
|
|
241
|
-
// pl pl
|
|
242
|
-
// /||\ / \
|
|
243
|
-
// al/ || \bl al/ \a
|
|
244
|
-
// / || \ / \
|
|
245
|
-
// / a||b \ flip /___ar___\
|
|
246
|
-
// p0\ || /p1 => p0\---bl---/p1
|
|
247
|
-
// \ || / \ /
|
|
248
|
-
// ar\ || /br b\ /br
|
|
249
|
-
// \||/ \ /
|
|
250
|
-
// pr pr
|
|
251
|
-
const b = this._halfedges[a];
|
|
252
|
-
if (b < 0) {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
const a0 = a - (a % 3);
|
|
256
|
-
const b0 = b - (b % 3);
|
|
257
|
-
const al = a0 + ((a + 1) % 3);
|
|
258
|
-
const ar = a0 + ((a + 2) % 3);
|
|
259
|
-
const bl = b0 + ((b + 2) % 3);
|
|
260
|
-
const br = b0 + ((b + 1) % 3);
|
|
261
|
-
const p0 = this.triangles[ar];
|
|
262
|
-
const pr = this.triangles[a];
|
|
263
|
-
const pl = this.triangles[al];
|
|
264
|
-
const p1 = this.triangles[bl];
|
|
265
|
-
const coords = this.coords;
|
|
266
|
-
if (!inCircle(coords[2 * p0], coords[2 * p0 + 1], coords[2 * pr], coords[2 * pr + 1], coords[2 * pl], coords[2 * pl + 1], coords[2 * p1], coords[2 * p1 + 1])) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
const hal = this._halfedges[al];
|
|
270
|
-
const har = this._halfedges[ar];
|
|
271
|
-
const hbl = this._halfedges[bl];
|
|
272
|
-
const hbr = this._halfedges[br];
|
|
273
|
-
this._queueRemove(a0 / 3);
|
|
274
|
-
this._queueRemove(b0 / 3);
|
|
275
|
-
const t0 = this._addTriangle(p0, p1, pl, -1, hbl, hal, a0);
|
|
276
|
-
const t1 = this._addTriangle(p1, p0, pr, t0, har, hbr, b0);
|
|
277
|
-
this._legalize(t0 + 1);
|
|
278
|
-
this._legalize(t1 + 2);
|
|
279
|
-
}
|
|
280
|
-
// handle a case where new vertex is on the edge of a triangle
|
|
281
|
-
_handleCollinear(pn, a) {
|
|
282
|
-
const a0 = a - (a % 3);
|
|
283
|
-
const al = a0 + ((a + 1) % 3);
|
|
284
|
-
const ar = a0 + ((a + 2) % 3);
|
|
285
|
-
const p0 = this.triangles[ar];
|
|
286
|
-
const pr = this.triangles[a];
|
|
287
|
-
const pl = this.triangles[al];
|
|
288
|
-
const hal = this._halfedges[al];
|
|
289
|
-
const har = this._halfedges[ar];
|
|
290
|
-
const b = this._halfedges[a];
|
|
291
|
-
if (b < 0) {
|
|
292
|
-
const t0 = this._addTriangle(pn, p0, pr, -1, har, -1, a0);
|
|
293
|
-
const t1 = this._addTriangle(p0, pn, pl, t0, -1, hal);
|
|
294
|
-
this._legalize(t0 + 1);
|
|
295
|
-
this._legalize(t1 + 2);
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
const b0 = b - (b % 3);
|
|
299
|
-
const bl = b0 + ((b + 2) % 3);
|
|
300
|
-
const br = b0 + ((b + 1) % 3);
|
|
301
|
-
const p1 = this.triangles[bl];
|
|
302
|
-
const hbl = this._halfedges[bl];
|
|
303
|
-
const hbr = this._halfedges[br];
|
|
304
|
-
this._queueRemove(b0 / 3);
|
|
305
|
-
const t0 = this._addTriangle(p0, pr, pn, har, -1, -1, a0);
|
|
306
|
-
const t1 = this._addTriangle(pr, p1, pn, hbr, -1, t0 + 1, b0);
|
|
307
|
-
const t2 = this._addTriangle(p1, pl, pn, hbl, -1, t1 + 1);
|
|
308
|
-
const t3 = this._addTriangle(pl, p0, pn, hal, t0 + 2, t2 + 1);
|
|
309
|
-
this._legalize(t0);
|
|
310
|
-
this._legalize(t1);
|
|
311
|
-
this._legalize(t2);
|
|
312
|
-
this._legalize(t3);
|
|
313
|
-
}
|
|
314
|
-
// priority queue methods
|
|
315
|
-
_queuePush(t, error, rms) {
|
|
316
|
-
const i = this._queue.length;
|
|
317
|
-
this._queueIndices[t] = i;
|
|
318
|
-
this._queue.push(t);
|
|
319
|
-
this._errors.push(error);
|
|
320
|
-
this._rmsSum += rms;
|
|
321
|
-
this._queueUp(i);
|
|
322
|
-
}
|
|
323
|
-
_queuePop() {
|
|
324
|
-
const n = this._queue.length - 1;
|
|
325
|
-
this._queueSwap(0, n);
|
|
326
|
-
this._queueDown(0, n);
|
|
327
|
-
return this._queuePopBack();
|
|
328
|
-
}
|
|
329
|
-
_queuePopBack() {
|
|
330
|
-
const t = this._queue.pop();
|
|
331
|
-
this._errors.pop();
|
|
332
|
-
this._rmsSum -= this._rms[t];
|
|
333
|
-
this._queueIndices[t] = -1;
|
|
334
|
-
return t;
|
|
335
|
-
}
|
|
336
|
-
_queueRemove(t) {
|
|
337
|
-
const i = this._queueIndices[t];
|
|
338
|
-
if (i < 0) {
|
|
339
|
-
const it = this._pending.indexOf(t);
|
|
340
|
-
if (it !== -1) {
|
|
341
|
-
this._pending[it] = this._pending[--this._pendingLen];
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
throw new Error('Broken triangulation (something went wrong).');
|
|
345
|
-
}
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
const n = this._queue.length - 1;
|
|
349
|
-
if (n !== i) {
|
|
350
|
-
this._queueSwap(i, n);
|
|
351
|
-
if (!this._queueDown(i, n)) {
|
|
352
|
-
this._queueUp(i);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
this._queuePopBack();
|
|
356
|
-
}
|
|
357
|
-
_queueLess(i, j) {
|
|
358
|
-
return this._errors[i] > this._errors[j];
|
|
359
|
-
}
|
|
360
|
-
_queueSwap(i, j) {
|
|
361
|
-
const pi = this._queue[i];
|
|
362
|
-
const pj = this._queue[j];
|
|
363
|
-
this._queue[i] = pj;
|
|
364
|
-
this._queue[j] = pi;
|
|
365
|
-
this._queueIndices[pi] = j;
|
|
366
|
-
this._queueIndices[pj] = i;
|
|
367
|
-
const e = this._errors[i];
|
|
368
|
-
this._errors[i] = this._errors[j];
|
|
369
|
-
this._errors[j] = e;
|
|
370
|
-
}
|
|
371
|
-
_queueUp(j0) {
|
|
372
|
-
let j = j0;
|
|
373
|
-
while (true) {
|
|
374
|
-
const i = (j - 1) >> 1;
|
|
375
|
-
if (i === j || !this._queueLess(j, i)) {
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
this._queueSwap(i, j);
|
|
379
|
-
j = i;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
_queueDown(i0, n) {
|
|
383
|
-
let i = i0;
|
|
384
|
-
while (true) {
|
|
385
|
-
const j1 = 2 * i + 1;
|
|
386
|
-
if (j1 >= n || j1 < 0) {
|
|
387
|
-
break;
|
|
388
|
-
}
|
|
389
|
-
const j2 = j1 + 1;
|
|
390
|
-
let j = j1;
|
|
391
|
-
if (j2 < n && this._queueLess(j2, j1)) {
|
|
392
|
-
j = j2;
|
|
393
|
-
}
|
|
394
|
-
if (!this._queueLess(j, i)) {
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
this._queueSwap(i, j);
|
|
398
|
-
i = j;
|
|
399
|
-
}
|
|
400
|
-
return i > i0;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
exports.default = Delatin;
|
|
404
|
-
function orient(ax, ay, bx, by, cx, cy) {
|
|
405
|
-
return (bx - cx) * (ay - cy) - (by - cy) * (ax - cx);
|
|
406
|
-
}
|
|
407
|
-
function inCircle(ax, ay, bx, by, cx, cy, px, py) {
|
|
408
|
-
const dx = ax - px;
|
|
409
|
-
const dy = ay - py;
|
|
410
|
-
const ex = bx - px;
|
|
411
|
-
const ey = by - py;
|
|
412
|
-
const fx = cx - px;
|
|
413
|
-
const fy = cy - py;
|
|
414
|
-
const ap = dx * dx + dy * dy;
|
|
415
|
-
const bp = ex * ex + ey * ey;
|
|
416
|
-
const cp = fx * fx + fy * fy;
|
|
417
|
-
return dx * (ey * cp - bp * fy) - dy * (ex * cp - bp * fx) + ap * (ex * fy - ey * fx) < 0;
|
|
418
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addSkirt = void 0;
|
|
4
|
-
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
5
|
-
/**
|
|
6
|
-
* Add skirt to existing mesh
|
|
7
|
-
* @param {object} attributes - POSITION and TEXCOOD_0 attributes data
|
|
8
|
-
* @param {any} triangles - indices array of the mesh geometry
|
|
9
|
-
* @param skirtHeight - height of the skirt geometry
|
|
10
|
-
* @param outsideIndices - edge indices from quantized mesh data
|
|
11
|
-
* @returns - geometry data with added skirt
|
|
12
|
-
*/
|
|
13
|
-
function addSkirt(attributes, triangles, skirtHeight, outsideIndices) {
|
|
14
|
-
const outsideEdges = outsideIndices
|
|
15
|
-
? getOutsideEdgesFromIndices(outsideIndices, attributes.POSITION.value)
|
|
16
|
-
: getOutsideEdgesFromTriangles(triangles);
|
|
17
|
-
// 2 new vertices for each outside edge
|
|
18
|
-
const newPosition = new attributes.POSITION.value.constructor(outsideEdges.length * 6);
|
|
19
|
-
const newTexcoord0 = new attributes.TEXCOORD_0.value.constructor(outsideEdges.length * 4);
|
|
20
|
-
// 2 new triangles for each outside edge
|
|
21
|
-
const newTriangles = new triangles.constructor(outsideEdges.length * 6);
|
|
22
|
-
for (let i = 0; i < outsideEdges.length; i++) {
|
|
23
|
-
const edge = outsideEdges[i];
|
|
24
|
-
updateAttributesForNewEdge({
|
|
25
|
-
edge,
|
|
26
|
-
edgeIndex: i,
|
|
27
|
-
attributes,
|
|
28
|
-
skirtHeight,
|
|
29
|
-
newPosition,
|
|
30
|
-
newTexcoord0,
|
|
31
|
-
newTriangles
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
attributes.POSITION.value = (0, loader_utils_1.concatenateTypedArrays)(attributes.POSITION.value, newPosition);
|
|
35
|
-
attributes.TEXCOORD_0.value = (0, loader_utils_1.concatenateTypedArrays)(attributes.TEXCOORD_0.value, newTexcoord0);
|
|
36
|
-
const resultTriangles = triangles instanceof Array
|
|
37
|
-
? triangles.concat(newTriangles)
|
|
38
|
-
: (0, loader_utils_1.concatenateTypedArrays)(triangles, newTriangles);
|
|
39
|
-
return {
|
|
40
|
-
attributes,
|
|
41
|
-
triangles: resultTriangles
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
exports.addSkirt = addSkirt;
|
|
45
|
-
/**
|
|
46
|
-
* Get geometry edges that located on a border of the mesh
|
|
47
|
-
* @param {any} triangles - indices array of the mesh geometry
|
|
48
|
-
* @returns {number[][]} - outside edges data
|
|
49
|
-
*/
|
|
50
|
-
function getOutsideEdgesFromTriangles(triangles) {
|
|
51
|
-
const edges = [];
|
|
52
|
-
for (let i = 0; i < triangles.length; i += 3) {
|
|
53
|
-
edges.push([triangles[i], triangles[i + 1]]);
|
|
54
|
-
edges.push([triangles[i + 1], triangles[i + 2]]);
|
|
55
|
-
edges.push([triangles[i + 2], triangles[i]]);
|
|
56
|
-
}
|
|
57
|
-
edges.sort((a, b) => Math.min(...a) - Math.min(...b) || Math.max(...a) - Math.max(...b));
|
|
58
|
-
const outsideEdges = [];
|
|
59
|
-
let index = 0;
|
|
60
|
-
while (index < edges.length) {
|
|
61
|
-
if (edges[index][0] === edges[index + 1]?.[1] && edges[index][1] === edges[index + 1]?.[0]) {
|
|
62
|
-
index += 2;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
outsideEdges.push(edges[index]);
|
|
66
|
-
index++;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return outsideEdges;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get geometry edges that located on a border of the mesh
|
|
73
|
-
* @param {object} indices - edge indices from quantized mesh data
|
|
74
|
-
* @param {TypedArray} position - position attribute geometry data
|
|
75
|
-
* @returns {number[][]} - outside edges data
|
|
76
|
-
*/
|
|
77
|
-
function getOutsideEdgesFromIndices(indices, position) {
|
|
78
|
-
// Sort skirt indices to create adjacent triangles
|
|
79
|
-
indices.westIndices.sort((a, b) => position[3 * a + 1] - position[3 * b + 1]);
|
|
80
|
-
// Reverse (b - a) to match triangle winding
|
|
81
|
-
indices.eastIndices.sort((a, b) => position[3 * b + 1] - position[3 * a + 1]);
|
|
82
|
-
indices.southIndices.sort((a, b) => position[3 * b] - position[3 * a]);
|
|
83
|
-
// Reverse (b - a) to match triangle winding
|
|
84
|
-
indices.northIndices.sort((a, b) => position[3 * a] - position[3 * b]);
|
|
85
|
-
const edges = [];
|
|
86
|
-
for (const index in indices) {
|
|
87
|
-
const indexGroup = indices[index];
|
|
88
|
-
for (let i = 0; i < indexGroup.length - 1; i++) {
|
|
89
|
-
edges.push([indexGroup[i], indexGroup[i + 1]]);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return edges;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Get geometry edges that located on a border of the mesh
|
|
96
|
-
* @param {object} args
|
|
97
|
-
* @param {number[]} args.edge - edge indices in geometry
|
|
98
|
-
* @param {number} args.edgeIndex - edge index in outsideEdges array
|
|
99
|
-
* @param {object} args.attributes - POSITION and TEXCOORD_0 attributes
|
|
100
|
-
* @param {number} args.skirtHeight - height of the skirt geometry
|
|
101
|
-
* @param {TypedArray} args.newPosition - POSITION array for skirt data
|
|
102
|
-
* @param {TypedArray} args.newTexcoord0 - TEXCOORD_0 array for skirt data
|
|
103
|
-
* @param {TypedArray | Array} args.newTriangles - trinagle indices array for skirt data
|
|
104
|
-
* @returns {void}
|
|
105
|
-
*/
|
|
106
|
-
function updateAttributesForNewEdge({ edge, edgeIndex, attributes, skirtHeight, newPosition, newTexcoord0, newTriangles }) {
|
|
107
|
-
const positionsLength = attributes.POSITION.value.length;
|
|
108
|
-
const vertex1Offset = edgeIndex * 2;
|
|
109
|
-
const vertex2Offset = edgeIndex * 2 + 1;
|
|
110
|
-
// Define POSITION for new 1st vertex
|
|
111
|
-
newPosition.set(attributes.POSITION.value.subarray(edge[0] * 3, edge[0] * 3 + 3), vertex1Offset * 3);
|
|
112
|
-
newPosition[vertex1Offset * 3 + 2] = newPosition[vertex1Offset * 3 + 2] - skirtHeight; // put down elevation on the skirt height
|
|
113
|
-
// Define POSITION for new 2nd vertex
|
|
114
|
-
newPosition.set(attributes.POSITION.value.subarray(edge[1] * 3, edge[1] * 3 + 3), vertex2Offset * 3);
|
|
115
|
-
newPosition[vertex2Offset * 3 + 2] = newPosition[vertex2Offset * 3 + 2] - skirtHeight; // put down elevation on the skirt height
|
|
116
|
-
// Use same TEXCOORDS for skirt vertices
|
|
117
|
-
newTexcoord0.set(attributes.TEXCOORD_0.value.subarray(edge[0] * 2, edge[0] * 2 + 2), vertex1Offset * 2);
|
|
118
|
-
newTexcoord0.set(attributes.TEXCOORD_0.value.subarray(edge[1] * 2, edge[1] * 2 + 2), vertex2Offset * 2);
|
|
119
|
-
// Define new triangles
|
|
120
|
-
const triangle1Offset = edgeIndex * 2 * 3;
|
|
121
|
-
newTriangles[triangle1Offset] = edge[0];
|
|
122
|
-
newTriangles[triangle1Offset + 1] = positionsLength / 3 + vertex2Offset;
|
|
123
|
-
newTriangles[triangle1Offset + 2] = edge[1];
|
|
124
|
-
newTriangles[triangle1Offset + 3] = positionsLength / 3 + vertex2Offset;
|
|
125
|
-
newTriangles[triangle1Offset + 4] = edge[0];
|
|
126
|
-
newTriangles[triangle1Offset + 5] = positionsLength / 3 + vertex1Offset;
|
|
127
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const schema_1 = require("@loaders.gl/schema");
|
|
27
|
-
const decode_quantized_mesh_1 = __importStar(require("./decode-quantized-mesh"));
|
|
28
|
-
const skirt_1 = require("./helpers/skirt");
|
|
29
|
-
function getMeshAttributes(vertexData, header, bounds) {
|
|
30
|
-
const { minHeight, maxHeight } = header;
|
|
31
|
-
const [minX, minY, maxX, maxY] = bounds || [0, 0, 1, 1];
|
|
32
|
-
const xScale = maxX - minX;
|
|
33
|
-
const yScale = maxY - minY;
|
|
34
|
-
const zScale = maxHeight - minHeight;
|
|
35
|
-
const nCoords = vertexData.length / 3;
|
|
36
|
-
// vec3. x, y defined by bounds, z in meters
|
|
37
|
-
const positions = new Float32Array(nCoords * 3);
|
|
38
|
-
// vec2. 1 to 1 relationship with position. represents the uv on the texture image. 0,0 to 1,1.
|
|
39
|
-
const texCoords = new Float32Array(nCoords * 2);
|
|
40
|
-
// Data is not interleaved; all u, then all v, then all heights
|
|
41
|
-
for (let i = 0; i < nCoords; i++) {
|
|
42
|
-
const x = vertexData[i] / 32767;
|
|
43
|
-
const y = vertexData[i + nCoords] / 32767;
|
|
44
|
-
const z = vertexData[i + nCoords * 2] / 32767;
|
|
45
|
-
positions[3 * i + 0] = x * xScale + minX;
|
|
46
|
-
positions[3 * i + 1] = y * yScale + minY;
|
|
47
|
-
positions[3 * i + 2] = z * zScale + minHeight;
|
|
48
|
-
texCoords[2 * i + 0] = x;
|
|
49
|
-
texCoords[2 * i + 1] = y;
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
POSITION: { value: positions, size: 3 },
|
|
53
|
-
TEXCOORD_0: { value: texCoords, size: 2 }
|
|
54
|
-
// TODO: Parse normals if they exist in the file
|
|
55
|
-
// NORMAL: {}, - optional, but creates the high poly look with lighting
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function getTileMesh(arrayBuffer, options) {
|
|
59
|
-
if (!arrayBuffer) {
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
const { bounds } = options;
|
|
63
|
-
// Don't parse edge indices or format extensions
|
|
64
|
-
const { header, vertexData, triangleIndices: originalTriangleIndices, westIndices, northIndices, eastIndices, southIndices } = (0, decode_quantized_mesh_1.default)(arrayBuffer, decode_quantized_mesh_1.DECODING_STEPS.triangleIndices);
|
|
65
|
-
let triangleIndices = originalTriangleIndices;
|
|
66
|
-
let attributes = getMeshAttributes(vertexData, header, bounds);
|
|
67
|
-
// Compute bounding box before adding skirt so that z values are not skewed
|
|
68
|
-
// TODO: Find bounding box from header, instead of doing extra pass over
|
|
69
|
-
// vertices.
|
|
70
|
-
const boundingBox = (0, schema_1.getMeshBoundingBox)(attributes);
|
|
71
|
-
if (options.skirtHeight) {
|
|
72
|
-
const { attributes: newAttributes, triangles: newTriangles } = (0, skirt_1.addSkirt)(attributes, triangleIndices, options.skirtHeight, {
|
|
73
|
-
westIndices,
|
|
74
|
-
northIndices,
|
|
75
|
-
eastIndices,
|
|
76
|
-
southIndices
|
|
77
|
-
});
|
|
78
|
-
attributes = newAttributes;
|
|
79
|
-
triangleIndices = newTriangles;
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
// Data return by this loader implementation
|
|
83
|
-
loaderData: {
|
|
84
|
-
header: {}
|
|
85
|
-
},
|
|
86
|
-
header: {
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
vertexCount: triangleIndices.length,
|
|
89
|
-
boundingBox
|
|
90
|
-
},
|
|
91
|
-
mode: 4,
|
|
92
|
-
indices: { value: triangleIndices, size: 1 },
|
|
93
|
-
attributes
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function loadQuantizedMesh(arrayBuffer, options) {
|
|
97
|
-
return getTileMesh(arrayBuffer, options['quantized-mesh']);
|
|
98
|
-
}
|
|
99
|
-
exports.default = loadQuantizedMesh;
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const schema_1 = require("@loaders.gl/schema");
|
|
7
|
-
const martini_1 = __importDefault(require("@mapbox/martini"));
|
|
8
|
-
const delatin_1 = __importDefault(require("./delatin"));
|
|
9
|
-
const skirt_1 = require("./helpers/skirt");
|
|
10
|
-
function getTerrain(imageData, width, height, elevationDecoder, tesselator) {
|
|
11
|
-
const { rScaler, bScaler, gScaler, offset } = elevationDecoder;
|
|
12
|
-
// From Martini demo
|
|
13
|
-
// https://observablehq.com/@mourner/martin-real-time-rtin-terrain-mesh
|
|
14
|
-
const terrain = new Float32Array((width + 1) * (height + 1));
|
|
15
|
-
// decode terrain values
|
|
16
|
-
for (let i = 0, y = 0; y < height; y++) {
|
|
17
|
-
for (let x = 0; x < width; x++, i++) {
|
|
18
|
-
const k = i * 4;
|
|
19
|
-
const r = imageData[k + 0];
|
|
20
|
-
const g = imageData[k + 1];
|
|
21
|
-
const b = imageData[k + 2];
|
|
22
|
-
terrain[i + y] = r * rScaler + g * gScaler + b * bScaler + offset;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (tesselator === 'martini') {
|
|
26
|
-
// backfill bottom border
|
|
27
|
-
for (let i = (width + 1) * width, x = 0; x < width; x++, i++) {
|
|
28
|
-
terrain[i] = terrain[i - width - 1];
|
|
29
|
-
}
|
|
30
|
-
// backfill right border
|
|
31
|
-
for (let i = height, y = 0; y < height + 1; y++, i += height + 1) {
|
|
32
|
-
terrain[i] = terrain[i - 1];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return terrain;
|
|
36
|
-
}
|
|
37
|
-
function getMeshAttributes(vertices, terrain, width, height, bounds) {
|
|
38
|
-
const gridSize = width + 1;
|
|
39
|
-
const numOfVerticies = vertices.length / 2;
|
|
40
|
-
// vec3. x, y in pixels, z in meters
|
|
41
|
-
const positions = new Float32Array(numOfVerticies * 3);
|
|
42
|
-
// vec2. 1 to 1 relationship with position. represents the uv on the texture image. 0,0 to 1,1.
|
|
43
|
-
const texCoords = new Float32Array(numOfVerticies * 2);
|
|
44
|
-
const [minX, minY, maxX, maxY] = bounds || [0, 0, width, height];
|
|
45
|
-
const xScale = (maxX - minX) / width;
|
|
46
|
-
const yScale = (maxY - minY) / height;
|
|
47
|
-
for (let i = 0; i < numOfVerticies; i++) {
|
|
48
|
-
const x = vertices[i * 2];
|
|
49
|
-
const y = vertices[i * 2 + 1];
|
|
50
|
-
const pixelIdx = y * gridSize + x;
|
|
51
|
-
positions[3 * i + 0] = x * xScale + minX;
|
|
52
|
-
positions[3 * i + 1] = -y * yScale + maxY;
|
|
53
|
-
positions[3 * i + 2] = terrain[pixelIdx];
|
|
54
|
-
texCoords[2 * i + 0] = x / width;
|
|
55
|
-
texCoords[2 * i + 1] = y / height;
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
POSITION: { value: positions, size: 3 },
|
|
59
|
-
TEXCOORD_0: { value: texCoords, size: 2 }
|
|
60
|
-
// NORMAL: {}, - optional, but creates the high poly look with lighting
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Returns generated mesh object from image data
|
|
65
|
-
*
|
|
66
|
-
* @param {object} terrainImage terrain image data
|
|
67
|
-
* @param {object} terrainOptions terrain options
|
|
68
|
-
* @returns mesh object
|
|
69
|
-
*/
|
|
70
|
-
function getMesh(terrainImage, terrainOptions) {
|
|
71
|
-
if (terrainImage === null) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
const { meshMaxError, bounds, elevationDecoder } = terrainOptions;
|
|
75
|
-
const { data, width, height } = terrainImage;
|
|
76
|
-
let terrain;
|
|
77
|
-
let mesh;
|
|
78
|
-
switch (terrainOptions.tesselator) {
|
|
79
|
-
case 'martini':
|
|
80
|
-
terrain = getTerrain(data, width, height, elevationDecoder, terrainOptions.tesselator);
|
|
81
|
-
mesh = getMartiniTileMesh(meshMaxError, width, terrain);
|
|
82
|
-
break;
|
|
83
|
-
case 'delatin':
|
|
84
|
-
terrain = getTerrain(data, width, height, elevationDecoder, terrainOptions.tesselator);
|
|
85
|
-
mesh = getDelatinTileMesh(meshMaxError, width, height, terrain);
|
|
86
|
-
break;
|
|
87
|
-
// auto
|
|
88
|
-
default:
|
|
89
|
-
if (width === height && !(height & (width - 1))) {
|
|
90
|
-
terrain = getTerrain(data, width, height, elevationDecoder, 'martini');
|
|
91
|
-
mesh = getMartiniTileMesh(meshMaxError, width, terrain);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
terrain = getTerrain(data, width, height, elevationDecoder, 'delatin');
|
|
95
|
-
mesh = getDelatinTileMesh(meshMaxError, width, height, terrain);
|
|
96
|
-
}
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
const { vertices } = mesh;
|
|
100
|
-
let { triangles } = mesh;
|
|
101
|
-
let attributes = getMeshAttributes(vertices, terrain, width, height, bounds);
|
|
102
|
-
// Compute bounding box before adding skirt so that z values are not skewed
|
|
103
|
-
const boundingBox = (0, schema_1.getMeshBoundingBox)(attributes);
|
|
104
|
-
if (terrainOptions.skirtHeight) {
|
|
105
|
-
const { attributes: newAttributes, triangles: newTriangles } = (0, skirt_1.addSkirt)(attributes, triangles, terrainOptions.skirtHeight);
|
|
106
|
-
attributes = newAttributes;
|
|
107
|
-
triangles = newTriangles;
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
// Data return by this loader implementation
|
|
111
|
-
loaderData: {
|
|
112
|
-
header: {}
|
|
113
|
-
},
|
|
114
|
-
header: {
|
|
115
|
-
vertexCount: triangles.length,
|
|
116
|
-
boundingBox
|
|
117
|
-
},
|
|
118
|
-
mode: 4,
|
|
119
|
-
indices: { value: Uint32Array.from(triangles), size: 1 },
|
|
120
|
-
attributes
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Get Martini generated vertices and triangles
|
|
125
|
-
*
|
|
126
|
-
* @param {number} meshMaxError threshold for simplifying mesh
|
|
127
|
-
* @param {number} width width of the input data
|
|
128
|
-
* @param {number[] | Float32Array} terrain elevation data
|
|
129
|
-
* @returns {{vertices: Uint16Array, triangles: Uint32Array}} vertices and triangles data
|
|
130
|
-
*/
|
|
131
|
-
function getMartiniTileMesh(meshMaxError, width, terrain) {
|
|
132
|
-
const gridSize = width + 1;
|
|
133
|
-
const martini = new martini_1.default(gridSize);
|
|
134
|
-
const tile = martini.createTile(terrain);
|
|
135
|
-
const { vertices, triangles } = tile.getMesh(meshMaxError);
|
|
136
|
-
return { vertices, triangles };
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Get Delatin generated vertices and triangles
|
|
140
|
-
*
|
|
141
|
-
* @param {number} meshMaxError threshold for simplifying mesh
|
|
142
|
-
* @param {number} width width of the input data array
|
|
143
|
-
* @param {number} height height of the input data array
|
|
144
|
-
* @param {number[] | Float32Array} terrain elevation data
|
|
145
|
-
* @returns {{vertices: number[], triangles: number[]}} vertices and triangles data
|
|
146
|
-
*/
|
|
147
|
-
function getDelatinTileMesh(meshMaxError, width, height, terrain) {
|
|
148
|
-
const tin = new delatin_1.default(terrain, width + 1, height + 1);
|
|
149
|
-
tin.run(meshMaxError);
|
|
150
|
-
// @ts-expect-error
|
|
151
|
-
const { coords, triangles } = tin;
|
|
152
|
-
const vertices = coords;
|
|
153
|
-
return { vertices, triangles };
|
|
154
|
-
}
|
|
155
|
-
async function loadTerrain(arrayBuffer, options, context) {
|
|
156
|
-
const loadImageOptions = {
|
|
157
|
-
...options,
|
|
158
|
-
mimeType: 'application/x.image',
|
|
159
|
-
image: { ...options.image, type: 'data' }
|
|
160
|
-
};
|
|
161
|
-
const image = await context.parse(arrayBuffer, loadImageOptions);
|
|
162
|
-
// Extend function to support additional mesh generation options (square grid or delatin)
|
|
163
|
-
return getMesh(image, options.terrain);
|
|
164
|
-
}
|
|
165
|
-
exports.default = loadTerrain;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VERSION = void 0;
|
|
4
|
-
// Version constant cannot be imported, it needs to correspond to the build version of **this** module.
|
|
5
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
|
-
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
-
exports.VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._typecheckQuantizedMeshLoader = exports.QuantizedMeshLoader = void 0;
|
|
4
|
-
const version_1 = require("./lib/utils/version");
|
|
5
|
-
/**
|
|
6
|
-
* Worker loader for quantized meshes
|
|
7
|
-
*/
|
|
8
|
-
exports.QuantizedMeshLoader = {
|
|
9
|
-
name: 'Quantized Mesh',
|
|
10
|
-
id: 'quantized-mesh',
|
|
11
|
-
module: 'terrain',
|
|
12
|
-
version: version_1.VERSION,
|
|
13
|
-
worker: true,
|
|
14
|
-
extensions: ['terrain'],
|
|
15
|
-
mimeTypes: ['application/vnd.quantized-mesh'],
|
|
16
|
-
options: {
|
|
17
|
-
'quantized-mesh': {
|
|
18
|
-
bounds: [0, 0, 1, 1],
|
|
19
|
-
skirtHeight: null
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
exports._typecheckQuantizedMeshLoader = exports.QuantizedMeshLoader;
|
package/dist/terrain-loader.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._typecheckTerrainWorkerLoader = exports.TerrainLoader = void 0;
|
|
4
|
-
const version_1 = require("./lib/utils/version");
|
|
5
|
-
/**
|
|
6
|
-
* Worker loader for color-encoded images
|
|
7
|
-
*/
|
|
8
|
-
exports.TerrainLoader = {
|
|
9
|
-
name: 'Terrain',
|
|
10
|
-
id: 'terrain',
|
|
11
|
-
module: 'terrain',
|
|
12
|
-
version: version_1.VERSION,
|
|
13
|
-
worker: true,
|
|
14
|
-
extensions: ['png', 'pngraw', 'jpg', 'jpeg', 'gif', 'webp', 'bmp'],
|
|
15
|
-
mimeTypes: ['image/png', 'image/jpeg', 'image/gif', 'image/webp', 'image/bmp'],
|
|
16
|
-
options: {
|
|
17
|
-
terrain: {
|
|
18
|
-
tesselator: 'auto',
|
|
19
|
-
bounds: null,
|
|
20
|
-
meshMaxError: 10,
|
|
21
|
-
elevationDecoder: {
|
|
22
|
-
rScaler: 1,
|
|
23
|
-
gScaler: 0,
|
|
24
|
-
bScaler: 0,
|
|
25
|
-
offset: 0
|
|
26
|
-
},
|
|
27
|
-
skirtHeight: null
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Loader for color-encoded images
|
|
33
|
-
*/
|
|
34
|
-
exports._typecheckTerrainWorkerLoader = exports.TerrainLoader;
|