@deck.gl/extensions 9.3.7 → 9.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +348 -35
- package/dist/fill-style/shader-module.d.ts +1 -1
- package/dist/index.cjs +78 -35
- package/dist/index.cjs.map +4 -4
- package/dist/mask/shader-module.d.ts +1 -1
- package/dist/terrain/height-map-builder.d.ts.map +1 -1
- package/dist/terrain/height-map-builder.js +16 -10
- package/dist/terrain/height-map-builder.js.map +1 -1
- package/dist/terrain/shader-module.d.ts +6 -6
- package/dist/terrain/shader-module.d.ts.map +1 -1
- package/dist/terrain/shader-module.js +38 -11
- package/dist/terrain/shader-module.js.map +1 -1
- package/dist/terrain/terrain-cover.d.ts.map +1 -1
- package/dist/terrain/terrain-cover.js +10 -5
- package/dist/terrain/terrain-cover.js.map +1 -1
- package/dist/utils/projection-utils.d.ts +4 -0
- package/dist/utils/projection-utils.d.ts.map +1 -1
- package/dist/utils/projection-utils.js +25 -5
- package/dist/utils/projection-utils.js.map +1 -1
- package/dist.min.js +362 -65
- package/package.json +11 -7
- package/src/terrain/height-map-builder.ts +25 -10
- package/src/terrain/shader-module.ts +38 -11
- package/src/terrain/terrain-cover.ts +21 -5
- package/src/utils/projection-utils.ts +28 -5
package/dist/index.cjs
CHANGED
|
@@ -2354,6 +2354,20 @@ var MaskPass = class extends import_core17._LayersPass {
|
|
|
2354
2354
|
|
|
2355
2355
|
// dist/utils/projection-utils.js
|
|
2356
2356
|
var import_core18 = require("@deck.gl/core");
|
|
2357
|
+
var MERCATOR_REFERENCE_VIEWPORT = new import_core18.WebMercatorViewport({
|
|
2358
|
+
width: 1,
|
|
2359
|
+
height: 1,
|
|
2360
|
+
longitude: 0,
|
|
2361
|
+
latitude: 0,
|
|
2362
|
+
zoom: 0
|
|
2363
|
+
});
|
|
2364
|
+
function lngLatToMercatorCommon(lngLat) {
|
|
2365
|
+
const [x, y] = MERCATOR_REFERENCE_VIEWPORT.projectPosition(lngLat);
|
|
2366
|
+
return [x, y];
|
|
2367
|
+
}
|
|
2368
|
+
function getMercatorReferenceViewport(viewport) {
|
|
2369
|
+
return viewport.isGeospatial ? MERCATOR_REFERENCE_VIEWPORT : viewport;
|
|
2370
|
+
}
|
|
2357
2371
|
function joinLayerBounds(layers, viewport) {
|
|
2358
2372
|
const bounds = [Infinity, Infinity, -Infinity, -Infinity];
|
|
2359
2373
|
for (const layer of layers) {
|
|
@@ -2379,11 +2393,11 @@ function makeViewport(opts) {
|
|
|
2379
2393
|
if (bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
|
|
2380
2394
|
return null;
|
|
2381
2395
|
}
|
|
2382
|
-
const centerWorld =
|
|
2396
|
+
const centerWorld = isGeospatial ? MERCATOR_REFERENCE_VIEWPORT.unprojectPosition([
|
|
2383
2397
|
(bounds[0] + bounds[2]) / 2,
|
|
2384
2398
|
(bounds[1] + bounds[3]) / 2,
|
|
2385
2399
|
0
|
|
2386
|
-
]);
|
|
2400
|
+
]) : viewport.unprojectPosition([(bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2, 0]);
|
|
2387
2401
|
let { width, height, zoom } = opts;
|
|
2388
2402
|
if (zoom === void 0) {
|
|
2389
2403
|
width = width - border * 2;
|
|
@@ -2709,10 +2723,10 @@ MaskExtension.extensionName = "MaskExtension";
|
|
|
2709
2723
|
var mask_extension_default = MaskExtension;
|
|
2710
2724
|
|
|
2711
2725
|
// dist/terrain/terrain-extension.js
|
|
2712
|
-
var
|
|
2726
|
+
var import_core28 = require("@deck.gl/core");
|
|
2713
2727
|
|
|
2714
2728
|
// dist/terrain/terrain-effect.js
|
|
2715
|
-
var
|
|
2729
|
+
var import_core27 = require("@deck.gl/core");
|
|
2716
2730
|
|
|
2717
2731
|
// dist/terrain/shader-module.js
|
|
2718
2732
|
var import_core22 = require("@deck.gl/core");
|
|
@@ -2745,12 +2759,22 @@ uniform sampler2D terrain_map;
|
|
|
2745
2759
|
var terrainModule = {
|
|
2746
2760
|
name: "terrain",
|
|
2747
2761
|
dependencies: [import_core22.project],
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2762
|
+
vs: `${uniformBlock5}
|
|
2763
|
+
out vec3 commonPos;
|
|
2764
|
+
// In globe mode, absolute Mercator position for terrain FBO UV lookups
|
|
2765
|
+
out vec2 terrainMercPos;
|
|
2766
|
+
out float terrainHeight;
|
|
2767
|
+
|
|
2768
|
+
vec2 terrain_globe_to_mercator(vec3 globePosition) {
|
|
2769
|
+
float D = length(globePosition);
|
|
2770
|
+
float sinLat = clamp(globePosition.z / D, -0.999998, 0.999998);
|
|
2771
|
+
float x = atan(globePosition.x, -globePosition.y);
|
|
2772
|
+
float y = atanh(sinLat);
|
|
2773
|
+
return (vec2(x, y) + PI) * WORLD_SCALE;
|
|
2774
|
+
}
|
|
2775
|
+
`,
|
|
2776
|
+
fs: `${uniformBlock5}in vec2 terrainMercPos;
|
|
2777
|
+
in float terrainHeight;`,
|
|
2754
2778
|
inject: {
|
|
2755
2779
|
"vs:#main-start": (
|
|
2756
2780
|
/* glsl */
|
|
@@ -2765,19 +2789,35 @@ if (terrain.mode == TERRAIN_MODE_SKIP) {
|
|
|
2765
2789
|
/* glsl */
|
|
2766
2790
|
`
|
|
2767
2791
|
commonPos = geometry.position.xyz;
|
|
2792
|
+
terrainHeight = commonPos.z + project.commonOrigin.z;
|
|
2793
|
+
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
|
2794
|
+
terrainMercPos = terrain_globe_to_mercator(commonPos);
|
|
2795
|
+
terrainHeight = length(commonPos) - GLOBE_RADIUS;
|
|
2796
|
+
} else {
|
|
2797
|
+
terrainMercPos = commonPos.xy;
|
|
2798
|
+
}
|
|
2768
2799
|
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
2769
|
-
vec2 texCoords = (
|
|
2800
|
+
vec2 texCoords = (terrainMercPos - terrain.bounds.xy) / terrain.bounds.zw;
|
|
2770
2801
|
position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);
|
|
2771
|
-
commonPos.z += project.commonOrigin.z;
|
|
2772
2802
|
}
|
|
2773
2803
|
if (terrain.mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
|
|
2774
2804
|
vec3 anchor = geometry.worldPosition;
|
|
2775
2805
|
anchor.z = 0.0;
|
|
2776
2806
|
vec3 anchorCommon = project_position(anchor);
|
|
2777
|
-
vec2
|
|
2807
|
+
vec2 anchorMercPos = project.projectionMode == PROJECTION_MODE_GLOBE
|
|
2808
|
+
? terrain_globe_to_mercator(anchorCommon)
|
|
2809
|
+
: anchorCommon.xy;
|
|
2810
|
+
vec2 texCoords = (anchorMercPos - terrain.bounds.xy) / terrain.bounds.zw;
|
|
2778
2811
|
if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {
|
|
2779
2812
|
float terrainZ = texture(terrain_map, texCoords).r;
|
|
2780
|
-
|
|
2813
|
+
if (project.projectionMode == PROJECTION_MODE_GLOBE) {
|
|
2814
|
+
// Height map is written in Mercator common space (units = TILE_SIZE / EARTH_CIRCUMFERENCE / cos(lat))
|
|
2815
|
+
// Convert to globe radial units (units = GLOBE_RADIUS / EARTH_RADIUS)
|
|
2816
|
+
terrainZ *= cos(radians(geometry.worldPosition.y)) * PI;
|
|
2817
|
+
geometry.position.xyz += normalize(geometry.position.xyz) * terrainZ;
|
|
2818
|
+
} else {
|
|
2819
|
+
geometry.position.z += terrainZ;
|
|
2820
|
+
}
|
|
2781
2821
|
position = project_common_position_to_clipspace(geometry.position);
|
|
2782
2822
|
}
|
|
2783
2823
|
}
|
|
@@ -2787,7 +2827,7 @@ if (terrain.mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
|
|
|
2787
2827
|
/* glsl */
|
|
2788
2828
|
`
|
|
2789
2829
|
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
2790
|
-
fragColor = vec4(
|
|
2830
|
+
fragColor = vec4(terrainHeight, 0.0, 0.0, 1.0);
|
|
2791
2831
|
return;
|
|
2792
2832
|
}
|
|
2793
2833
|
`
|
|
@@ -2796,7 +2836,7 @@ if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
|
2796
2836
|
/* glsl */
|
|
2797
2837
|
`
|
|
2798
2838
|
if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY)) {
|
|
2799
|
-
vec2 texCoords = (
|
|
2839
|
+
vec2 texCoords = (terrainMercPos - terrain.bounds.xy) / terrain.bounds.zw;
|
|
2800
2840
|
vec4 pixel = texture(terrain_map, texCoords);
|
|
2801
2841
|
if (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY) {
|
|
2802
2842
|
color = pixel;
|
|
@@ -2845,7 +2885,7 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
2845
2885
|
return {
|
|
2846
2886
|
mode,
|
|
2847
2887
|
terrain_map: sampler,
|
|
2848
|
-
// Convert bounds to
|
|
2888
|
+
// Convert bounds to common space, as [minX, minY, width, height]
|
|
2849
2889
|
bounds: bounds ? [
|
|
2850
2890
|
bounds[0] - commonOrigin[0],
|
|
2851
2891
|
bounds[1] - commonOrigin[1],
|
|
@@ -2866,6 +2906,9 @@ if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_US
|
|
|
2866
2906
|
}
|
|
2867
2907
|
};
|
|
2868
2908
|
|
|
2909
|
+
// dist/terrain/terrain-cover.js
|
|
2910
|
+
var import_core23 = require("@deck.gl/core");
|
|
2911
|
+
|
|
2869
2912
|
// dist/terrain/utils.js
|
|
2870
2913
|
var import_constants = require("@luma.gl/webgl/constants");
|
|
2871
2914
|
function createRenderTarget(device, opts) {
|
|
@@ -2958,8 +3001,8 @@ var TerrainCover = class {
|
|
|
2958
3001
|
if (!this.targetBounds) {
|
|
2959
3002
|
shouldRedraw = true;
|
|
2960
3003
|
this.targetBounds = this.tile.boundingBox;
|
|
2961
|
-
const bottomLeftCommon =
|
|
2962
|
-
const topRightCommon =
|
|
3004
|
+
const bottomLeftCommon = lngLatToMercatorCommon(this.targetBounds[0]);
|
|
3005
|
+
const topRightCommon = lngLatToMercatorCommon(this.targetBounds[1]);
|
|
2963
3006
|
this.targetBoundsCommon = [
|
|
2964
3007
|
bottomLeftCommon[0],
|
|
2965
3008
|
bottomLeftCommon[1],
|
|
@@ -2970,7 +3013,7 @@ var TerrainCover = class {
|
|
|
2970
3013
|
} else if (this.targetBounds !== targetLayer.getBounds()) {
|
|
2971
3014
|
shouldRedraw = true;
|
|
2972
3015
|
this.targetBounds = targetLayer.getBounds();
|
|
2973
|
-
this.targetBoundsCommon = joinLayerBounds([targetLayer], viewport);
|
|
3016
|
+
this.targetBoundsCommon = joinLayerBounds([targetLayer], getMercatorReferenceViewport(viewport));
|
|
2974
3017
|
}
|
|
2975
3018
|
if (!this.targetBoundsCommon) {
|
|
2976
3019
|
return false;
|
|
@@ -2981,7 +3024,7 @@ var TerrainCover = class {
|
|
|
2981
3024
|
} else {
|
|
2982
3025
|
const oldZoom = (_a = this.renderViewport) == null ? void 0 : _a.zoom;
|
|
2983
3026
|
shouldRedraw = shouldRedraw || newZoom !== oldZoom;
|
|
2984
|
-
const newBounds = getRenderBounds(this.targetBoundsCommon, viewport);
|
|
3027
|
+
const newBounds = viewport instanceof import_core23._GlobeViewport ? this.targetBoundsCommon : getRenderBounds(this.targetBoundsCommon, viewport);
|
|
2985
3028
|
const oldBounds = this.bounds;
|
|
2986
3029
|
shouldRedraw = shouldRedraw || !oldBounds || newBounds.some((x, i) => x !== oldBounds[i]);
|
|
2987
3030
|
this.bounds = newBounds;
|
|
@@ -3058,7 +3101,7 @@ function intersect(b1, b2) {
|
|
|
3058
3101
|
}
|
|
3059
3102
|
|
|
3060
3103
|
// dist/terrain/terrain-pass.js
|
|
3061
|
-
var
|
|
3104
|
+
var import_core24 = require("@deck.gl/core");
|
|
3062
3105
|
var TERRAIN_BLENDING = {
|
|
3063
3106
|
blendColorOperation: "max",
|
|
3064
3107
|
blendColorSrcFactor: "one",
|
|
@@ -3067,7 +3110,7 @@ var TERRAIN_BLENDING = {
|
|
|
3067
3110
|
blendAlphaSrcFactor: "one",
|
|
3068
3111
|
blendAlphaDstFactor: "one"
|
|
3069
3112
|
};
|
|
3070
|
-
var TerrainPass = class extends
|
|
3113
|
+
var TerrainPass = class extends import_core24._LayersPass {
|
|
3071
3114
|
getRenderableLayers(viewport, opts) {
|
|
3072
3115
|
const { layers } = opts;
|
|
3073
3116
|
const result = [];
|
|
@@ -3132,8 +3175,8 @@ var TerrainPass = class extends import_core23._LayersPass {
|
|
|
3132
3175
|
};
|
|
3133
3176
|
|
|
3134
3177
|
// dist/terrain/terrain-picking-pass.js
|
|
3135
|
-
var
|
|
3136
|
-
var TerrainPickingPass = class extends
|
|
3178
|
+
var import_core25 = require("@deck.gl/core");
|
|
3179
|
+
var TerrainPickingPass = class extends import_core25._PickLayersPass {
|
|
3137
3180
|
constructor() {
|
|
3138
3181
|
super(...arguments);
|
|
3139
3182
|
this.drawParameters = {};
|
|
@@ -3204,6 +3247,7 @@ var TerrainPickingPass = class extends import_core24._PickLayersPass {
|
|
|
3204
3247
|
};
|
|
3205
3248
|
|
|
3206
3249
|
// dist/terrain/height-map-builder.js
|
|
3250
|
+
var import_core26 = require("@deck.gl/core");
|
|
3207
3251
|
var MAP_MAX_SIZE = 2048;
|
|
3208
3252
|
var HeightMapBuilder = class {
|
|
3209
3253
|
static isSupported(device) {
|
|
@@ -3244,13 +3288,13 @@ var HeightMapBuilder = class {
|
|
|
3244
3288
|
if (layersChanged) {
|
|
3245
3289
|
this.layers = layers;
|
|
3246
3290
|
this.layersBounds = layers.map((layer) => layer.getBounds());
|
|
3247
|
-
this.layersBoundsCommon = joinLayerBounds(layers, viewport);
|
|
3291
|
+
this.layersBoundsCommon = joinLayerBounds(layers, getMercatorReferenceViewport(viewport));
|
|
3248
3292
|
}
|
|
3249
3293
|
const viewportChanged = !this.lastViewport || !viewport.equals(this.lastViewport);
|
|
3250
3294
|
if (!this.layersBoundsCommon) {
|
|
3251
3295
|
this.renderViewport = null;
|
|
3252
3296
|
} else if (layersChanged || viewportChanged) {
|
|
3253
|
-
const bounds = getRenderBounds(this.layersBoundsCommon, viewport);
|
|
3297
|
+
const bounds = viewport instanceof import_core26._GlobeViewport ? this.layersBoundsCommon : getRenderBounds(this.layersBoundsCommon, viewport);
|
|
3254
3298
|
if (bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
|
|
3255
3299
|
this.renderViewport = null;
|
|
3256
3300
|
return false;
|
|
@@ -3260,17 +3304,16 @@ var HeightMapBuilder = class {
|
|
|
3260
3304
|
const scale = viewport.scale;
|
|
3261
3305
|
const pixelWidth = (bounds[2] - bounds[0]) * scale;
|
|
3262
3306
|
const pixelHeight = (bounds[3] - bounds[1]) * scale;
|
|
3307
|
+
const centerMerc = viewport.isGeospatial ? lngLatToMercatorCommon([
|
|
3308
|
+
viewport.longitude ?? 0,
|
|
3309
|
+
viewport.latitude ?? 0
|
|
3310
|
+
]) : [viewport.center[0], viewport.center[1]];
|
|
3263
3311
|
this.renderViewport = pixelWidth > 0 || pixelHeight > 0 ? makeViewport({
|
|
3264
3312
|
// It's not important whether the geometry is visible in this viewport, because
|
|
3265
3313
|
// vertices will not use the standard project_to_clipspace in the DRAW_TO_HEIGHT_MAP shader
|
|
3266
3314
|
// However the viewport must have the same center and zoom as the screen viewport
|
|
3267
3315
|
// So that projection uniforms used for calculating z are the same
|
|
3268
|
-
bounds: [
|
|
3269
|
-
viewport.center[0] - 1,
|
|
3270
|
-
viewport.center[1] - 1,
|
|
3271
|
-
viewport.center[0] + 1,
|
|
3272
|
-
viewport.center[1] + 1
|
|
3273
|
-
],
|
|
3316
|
+
bounds: [centerMerc[0] - 1, centerMerc[1] - 1, centerMerc[0] + 1, centerMerc[1] + 1],
|
|
3274
3317
|
zoom: viewport.zoom,
|
|
3275
3318
|
width: Math.min(pixelWidth, MAP_MAX_SIZE),
|
|
3276
3319
|
height: Math.min(pixelHeight, MAP_MAX_SIZE),
|
|
@@ -3309,7 +3352,7 @@ var TerrainEffect = class {
|
|
|
3309
3352
|
if (HeightMapBuilder.isSupported(device)) {
|
|
3310
3353
|
this.heightMap = new HeightMapBuilder(device);
|
|
3311
3354
|
} else {
|
|
3312
|
-
|
|
3355
|
+
import_core27.log.warn("Terrain offset mode is not supported by this browser")();
|
|
3313
3356
|
}
|
|
3314
3357
|
deck._addDefaultShaderModule(terrainModule);
|
|
3315
3358
|
}
|
|
@@ -3477,7 +3520,7 @@ var TerrainEffect = class {
|
|
|
3477
3520
|
var defaultProps8 = {
|
|
3478
3521
|
terrainDrawMode: void 0
|
|
3479
3522
|
};
|
|
3480
|
-
var TerrainExtension = class extends
|
|
3523
|
+
var TerrainExtension = class extends import_core28.LayerExtension {
|
|
3481
3524
|
getShaders() {
|
|
3482
3525
|
return {
|
|
3483
3526
|
modules: [terrainModule]
|