@gisatcz/deckgl-geolib 2.5.0-dev.2 → 2.5.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +34 -23
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +34 -23
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +2 -2
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/types/core/lib/TerrainGenerator.d.ts +1 -1
- package/dist/esm/types/core/types.d.ts +19 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -4874,6 +4874,7 @@ const DefaultGeoImageOptions = {
|
|
|
4874
4874
|
useChannelIndex: null,
|
|
4875
4875
|
noDataValue: undefined,
|
|
4876
4876
|
multiplier: 1.0,
|
|
4877
|
+
verticalExaggeration: 1.0,
|
|
4877
4878
|
numOfChannels: undefined,
|
|
4878
4879
|
planarConfig: undefined,
|
|
4879
4880
|
// --- Mesh generation (terrain only) ---
|
|
@@ -5548,25 +5549,31 @@ function addSkirt(attributes, triangles, skirtHeight, outsideIndices) {
|
|
|
5548
5549
|
* @returns {number[][]} - outside edges data
|
|
5549
5550
|
*/
|
|
5550
5551
|
function getOutsideEdgesFromTriangles(triangles) {
|
|
5551
|
-
|
|
5552
|
-
for
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
if (edges[index][0] === edges[index + 1]?.[1] && edges[index][1] === edges[index + 1]?.[0]) {
|
|
5562
|
-
index += 2;
|
|
5552
|
+
// Use integer keys instead of strings: min * 70000 + max is collision-free
|
|
5553
|
+
// for any grid ≤ 257×257 (66,049 vertices < 70,000)
|
|
5554
|
+
const edgeMap = new Map();
|
|
5555
|
+
const processEdge = (a, b) => {
|
|
5556
|
+
const min = Math.min(a, b);
|
|
5557
|
+
const max = Math.max(a, b);
|
|
5558
|
+
// Integer key: no string allocation per edge
|
|
5559
|
+
const key = min * 70000 + max;
|
|
5560
|
+
if (edgeMap.has(key)) {
|
|
5561
|
+
edgeMap.delete(key); // Interior edge, remove
|
|
5563
5562
|
}
|
|
5564
5563
|
else {
|
|
5565
|
-
|
|
5566
|
-
index++;
|
|
5564
|
+
edgeMap.set(key, [a, b]);
|
|
5567
5565
|
}
|
|
5566
|
+
};
|
|
5567
|
+
for (let i = 0; i < triangles.length; i += 3) {
|
|
5568
|
+
const v0 = triangles[i];
|
|
5569
|
+
const v1 = triangles[i + 1];
|
|
5570
|
+
const v2 = triangles[i + 2];
|
|
5571
|
+
// Process each edge inline — no temporary array allocation per triangle
|
|
5572
|
+
processEdge(v0, v1);
|
|
5573
|
+
processEdge(v1, v2);
|
|
5574
|
+
processEdge(v2, v0);
|
|
5568
5575
|
}
|
|
5569
|
-
return
|
|
5576
|
+
return Array.from(edgeMap.values());
|
|
5570
5577
|
}
|
|
5571
5578
|
/**
|
|
5572
5579
|
* Get geometry edges that located on a border of the mesh
|
|
@@ -6284,7 +6291,7 @@ class TerrainGenerator {
|
|
|
6284
6291
|
const meshWidth = isKernel ? 257 : width;
|
|
6285
6292
|
const meshHeight = isKernel ? 257 : height;
|
|
6286
6293
|
// 2. Tesselate (Generate Mesh)
|
|
6287
|
-
const { terrainSkirtHeight } = options;
|
|
6294
|
+
const { terrainSkirtHeight, verticalExaggeration = 1.0 } = options;
|
|
6288
6295
|
let mesh;
|
|
6289
6296
|
switch (options.tesselator) {
|
|
6290
6297
|
case 'martini':
|
|
@@ -6300,13 +6307,17 @@ class TerrainGenerator {
|
|
|
6300
6307
|
}
|
|
6301
6308
|
const { vertices } = mesh;
|
|
6302
6309
|
let { triangles } = mesh;
|
|
6303
|
-
let attributes = this.getMeshAttributes(vertices, meshTerrain, meshWidth, meshHeight, input.bounds);
|
|
6310
|
+
let attributes = this.getMeshAttributes(vertices, meshTerrain, meshWidth, meshHeight, input.bounds, verticalExaggeration);
|
|
6304
6311
|
// Compute bounding box before adding skirt so that z values are not skewed
|
|
6305
6312
|
const boundingBox = schema.getMeshBoundingBox(attributes);
|
|
6306
6313
|
if (terrainSkirtHeight) {
|
|
6307
|
-
const
|
|
6308
|
-
|
|
6309
|
-
|
|
6314
|
+
const scaledSkirtHeight = terrainSkirtHeight * verticalExaggeration;
|
|
6315
|
+
// Skip skirt generation if scaled height is zero (e.g., verticalExaggeration = 0)
|
|
6316
|
+
if (scaledSkirtHeight > 0) {
|
|
6317
|
+
const { attributes: newAttributes, triangles: newTriangles } = addSkirt(attributes, triangles, scaledSkirtHeight);
|
|
6318
|
+
attributes = newAttributes;
|
|
6319
|
+
triangles = newTriangles;
|
|
6320
|
+
}
|
|
6310
6321
|
}
|
|
6311
6322
|
const map = {
|
|
6312
6323
|
// Data return by this loader implementation
|
|
@@ -6502,10 +6513,10 @@ class TerrainGenerator {
|
|
|
6502
6513
|
const vertices = coords;
|
|
6503
6514
|
return { vertices, triangles };
|
|
6504
6515
|
}
|
|
6505
|
-
static getMeshAttributes(vertices, terrain, width, height, bounds) {
|
|
6516
|
+
static getMeshAttributes(vertices, terrain, width, height, bounds, verticalExaggeration = 1.0) {
|
|
6506
6517
|
const gridSize = width === 257 ? 257 : width + 1;
|
|
6507
6518
|
const numOfVerticies = vertices.length / 2;
|
|
6508
|
-
// vec3. x, y in pixels, z in meters
|
|
6519
|
+
// vec3. x, y in pixels, z in meters (scaled by verticalExaggeration)
|
|
6509
6520
|
const positions = new Float32Array(numOfVerticies * 3);
|
|
6510
6521
|
// vec2. 1 to 1 relationship with position. represents the uv on the texture image. 0,0 to 1,1.
|
|
6511
6522
|
const texCoords = new Float32Array(numOfVerticies * 2);
|
|
@@ -6522,7 +6533,7 @@ class TerrainGenerator {
|
|
|
6522
6533
|
const pixelIdx = y * gridSize + x;
|
|
6523
6534
|
positions[3 * i] = x * xScale + minX;
|
|
6524
6535
|
positions[3 * i + 1] = -y * yScale + maxY;
|
|
6525
|
-
positions[3 * i + 2] = terrain[pixelIdx];
|
|
6536
|
+
positions[3 * i + 2] = terrain[pixelIdx] * verticalExaggeration;
|
|
6526
6537
|
texCoords[2 * i] = x / effectiveWidth;
|
|
6527
6538
|
texCoords[2 * i + 1] = y / effectiveHeight;
|
|
6528
6539
|
}
|