@deck.gl/extensions 8.9.0-beta.2 → 8.9.0-beta.4

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.
Files changed (109) hide show
  1. package/dist/dist.dev.js +281 -460
  2. package/dist/es5/{collide/collide-effect.js → collision-filter/collision-filter-effect.js} +79 -72
  3. package/dist/es5/collision-filter/collision-filter-effect.js.map +1 -0
  4. package/dist/es5/{collide/collide-pass.js → collision-filter/collision-filter-pass.js} +13 -13
  5. package/dist/es5/collision-filter/collision-filter-pass.js.map +1 -0
  6. package/dist/es5/{collide/collide.js → collision-filter/collision-filter.js} +30 -30
  7. package/dist/es5/collision-filter/collision-filter.js.map +1 -0
  8. package/dist/es5/collision-filter/shader-module.js +39 -0
  9. package/dist/es5/collision-filter/shader-module.js.map +1 -0
  10. package/dist/es5/data-filter/data-filter.js +1 -1
  11. package/dist/es5/data-filter/data-filter.js.map +1 -1
  12. package/dist/es5/index.js +4 -4
  13. package/dist/es5/index.js.map +1 -1
  14. package/dist/es5/mask/mask-effect.js +17 -8
  15. package/dist/es5/mask/mask-effect.js.map +1 -1
  16. package/dist/es5/terrain/height-map-builder.js +1 -1
  17. package/dist/es5/terrain/height-map-builder.js.map +1 -1
  18. package/dist/es5/terrain/shader-module.js.map +1 -1
  19. package/dist/es5/terrain/terrain-cover.js +1 -1
  20. package/dist/es5/terrain/terrain-cover.js.map +1 -1
  21. package/dist/es5/terrain/terrain-effect.js +5 -5
  22. package/dist/es5/terrain/terrain-effect.js.map +1 -1
  23. package/dist/es5/terrain/terrain.js +7 -7
  24. package/dist/es5/terrain/terrain.js.map +1 -1
  25. package/dist/es5/{common → utils}/projection-utils.js +3 -1
  26. package/dist/es5/utils/projection-utils.js.map +1 -0
  27. package/dist/esm/{collide/collide-effect.js → collision-filter/collision-filter-effect.js} +69 -64
  28. package/dist/esm/collision-filter/collision-filter-effect.js.map +1 -0
  29. package/dist/esm/{collide/collide-pass.js → collision-filter/collision-filter-pass.js} +5 -5
  30. package/dist/esm/collision-filter/collision-filter-pass.js.map +1 -0
  31. package/dist/esm/collision-filter/collision-filter.js +78 -0
  32. package/dist/esm/collision-filter/collision-filter.js.map +1 -0
  33. package/dist/esm/collision-filter/shader-module.js +32 -0
  34. package/dist/esm/collision-filter/shader-module.js.map +1 -0
  35. package/dist/esm/data-filter/data-filter.js +1 -1
  36. package/dist/esm/data-filter/data-filter.js.map +1 -1
  37. package/dist/esm/index.js +2 -2
  38. package/dist/esm/index.js.map +1 -1
  39. package/dist/esm/mask/mask-effect.js +14 -8
  40. package/dist/esm/mask/mask-effect.js.map +1 -1
  41. package/dist/esm/terrain/height-map-builder.js +1 -1
  42. package/dist/esm/terrain/height-map-builder.js.map +1 -1
  43. package/dist/esm/terrain/shader-module.js.map +1 -1
  44. package/dist/esm/terrain/terrain-cover.js +1 -1
  45. package/dist/esm/terrain/terrain-cover.js.map +1 -1
  46. package/dist/esm/terrain/terrain-effect.js +5 -5
  47. package/dist/esm/terrain/terrain-effect.js.map +1 -1
  48. package/dist/esm/terrain/terrain.js +7 -7
  49. package/dist/esm/terrain/terrain.js.map +1 -1
  50. package/dist/esm/{common → utils}/projection-utils.js +3 -1
  51. package/dist/esm/utils/projection-utils.js.map +1 -0
  52. package/dist.min.js +59 -62
  53. package/package.json +2 -2
  54. package/src/{collide/collide-effect.ts → collision-filter/collision-filter-effect.ts} +81 -78
  55. package/src/{collide/collide-pass.ts → collision-filter/collision-filter-pass.ts} +6 -6
  56. package/src/collision-filter/collision-filter.ts +83 -0
  57. package/src/collision-filter/shader-module.ts +113 -0
  58. package/src/data-filter/data-filter.ts +1 -1
  59. package/src/index.ts +3 -3
  60. package/src/mask/mask-effect.ts +32 -13
  61. package/src/terrain/height-map-builder.ts +2 -2
  62. package/src/terrain/shader-module.ts +4 -1
  63. package/src/terrain/terrain-cover.ts +2 -2
  64. package/src/terrain/terrain-effect.ts +5 -5
  65. package/src/terrain/terrain.ts +10 -10
  66. package/src/{common → utils}/projection-utils.ts +4 -2
  67. package/typed/collision-filter/collision-filter-effect.d.ts +28 -0
  68. package/typed/collision-filter/collision-filter-effect.d.ts.map +1 -0
  69. package/typed/collision-filter/collision-filter-pass.d.ts +14 -0
  70. package/typed/collision-filter/collision-filter-pass.d.ts.map +1 -0
  71. package/typed/collision-filter/collision-filter.d.ts +41 -0
  72. package/typed/collision-filter/collision-filter.d.ts.map +1 -0
  73. package/typed/collision-filter/shader-module.d.ts +4 -0
  74. package/typed/collision-filter/shader-module.d.ts.map +1 -0
  75. package/typed/data-filter/data-filter.d.ts +1 -1
  76. package/typed/index.d.ts +3 -3
  77. package/typed/index.d.ts.map +1 -1
  78. package/typed/mask/mask-effect.d.ts +2 -2
  79. package/typed/mask/mask-effect.d.ts.map +1 -1
  80. package/typed/terrain/height-map-builder.d.ts +2 -2
  81. package/typed/terrain/height-map-builder.d.ts.map +1 -1
  82. package/typed/terrain/shader-module.d.ts +1 -1
  83. package/typed/terrain/shader-module.d.ts.map +1 -1
  84. package/typed/terrain/terrain-cover.d.ts +2 -2
  85. package/typed/terrain/terrain-cover.d.ts.map +1 -1
  86. package/typed/terrain/terrain.d.ts +2 -2
  87. package/typed/terrain/terrain.d.ts.map +1 -1
  88. package/typed/utils/projection-utils.d.ts +27 -0
  89. package/typed/utils/projection-utils.d.ts.map +1 -0
  90. package/dist/es5/collide/collide-effect.js.map +0 -1
  91. package/dist/es5/collide/collide-pass.js.map +0 -1
  92. package/dist/es5/collide/collide.js.map +0 -1
  93. package/dist/es5/collide/shader-module.js +0 -39
  94. package/dist/es5/collide/shader-module.js.map +0 -1
  95. package/dist/es5/common/projection-utils.js.map +0 -1
  96. package/dist/es5/mask/utils.js +0 -136
  97. package/dist/es5/mask/utils.js.map +0 -1
  98. package/dist/esm/collide/collide-effect.js.map +0 -1
  99. package/dist/esm/collide/collide-pass.js.map +0 -1
  100. package/dist/esm/collide/collide.js +0 -78
  101. package/dist/esm/collide/collide.js.map +0 -1
  102. package/dist/esm/collide/shader-module.js +0 -32
  103. package/dist/esm/collide/shader-module.js.map +0 -1
  104. package/dist/esm/common/projection-utils.js.map +0 -1
  105. package/dist/esm/mask/utils.js +0 -109
  106. package/dist/esm/mask/utils.js.map +0 -1
  107. package/src/collide/collide.ts +0 -79
  108. package/src/collide/shader-module.ts +0 -113
  109. package/src/mask/utils.ts +0 -148
@@ -1,113 +0,0 @@
1
- import {Framebuffer, Texture2D} from '@luma.gl/core';
2
- import {project} from '@deck.gl/core';
3
- import type {_ShaderModule as ShaderModule} from '@deck.gl/core';
4
-
5
- const vs = `
6
- #ifdef NON_INSTANCED_MODEL
7
- attribute float collidePriorities;
8
- #else
9
- attribute float instanceCollidePriorities;
10
- #endif
11
-
12
- uniform sampler2D collide_texture;
13
- uniform bool collide_sort;
14
- uniform bool collide_enabled;
15
-
16
- vec2 collide_getCoords(vec4 position) {
17
- vec4 collide_clipspace = project_common_position_to_clipspace(position);
18
- return (1.0 + collide_clipspace.xy / collide_clipspace.w) / 2.0;
19
- }
20
-
21
- float collide_match(vec2 tex, vec3 pickingColor) {
22
- vec4 collide_pickingColor = texture2D(collide_texture, tex);
23
- float delta = dot(abs(collide_pickingColor.rgb - pickingColor), vec3(1.0));
24
- float e = 0.001;
25
- return step(delta, e);
26
- }
27
-
28
- float collide_isVisible(vec2 texCoords, vec3 pickingColor) {
29
- if (!collide_enabled) {
30
- return 1.0;
31
- }
32
-
33
- // Visibility test, sample area of 5x5 pixels in order to fade in/out.
34
- // Due to the locality, the lookups will be cached
35
- // This reduces the flicker present when objects are shown/hidden
36
- const int N = 2;
37
- float accumulator = 0.0;
38
- vec2 step = vec2(1.0 / project_uViewportSize);
39
-
40
- const float floatN = float(N);
41
- vec2 delta = -floatN * step;
42
- for(int i = -N; i <= N; i++) {
43
- delta.x = -step.x * floatN;
44
- for(int j = -N; j <= N; j++) {
45
- accumulator += collide_match(texCoords + delta, pickingColor);
46
- delta.x += step.x;
47
- }
48
- delta.y += step.y;
49
- }
50
-
51
- float W = 2.0 * floatN + 1.0;
52
- return pow(accumulator / (W * W), 2.2);
53
- }
54
- `;
55
-
56
- const inject = {
57
- 'vs:#decl': `
58
- float collide_fade = 1.0;
59
- `,
60
- 'vs:DECKGL_FILTER_GL_POSITION': `
61
- if (collide_sort) {
62
- #ifdef NON_INSTANCED_MODEL
63
- float collidePriority = collidePriorities;
64
- #else
65
- float collidePriority = instanceCollidePriorities;
66
- #endif
67
- position.z = -0.001 * collidePriority * position.w; // Support range -1000 -> 1000
68
- }
69
-
70
- if (collide_enabled) {
71
- vec4 collide_common_position = project_position(vec4(geometry.worldPosition, 1.0));
72
- vec2 collide_texCoords = collide_getCoords(collide_common_position);
73
- collide_fade = collide_isVisible(collide_texCoords, geometry.pickingColor / 255.0);
74
- if (collide_fade < 0.0001) {
75
- position = vec4(0.);
76
- }
77
- }
78
- `,
79
- 'vs:DECKGL_FILTER_COLOR': `
80
- color.a *= collide_fade;
81
- `
82
- };
83
-
84
- type CollideModuleSettings = {
85
- collideFBO?: Framebuffer;
86
- drawToCollideMap?: boolean;
87
- dummyCollideMap?: Texture2D;
88
- };
89
-
90
- /* eslint-disable camelcase */
91
- type CollideUniforms = {collide_sort?: boolean; collide_texture?: Framebuffer | Texture2D};
92
-
93
- const getCollideUniforms = (
94
- opts: CollideModuleSettings | {},
95
- uniforms: Record<string, any>
96
- ): CollideUniforms => {
97
- if (!opts || !('dummyCollideMap' in opts)) {
98
- return {};
99
- }
100
- const {collideFBO, drawToCollideMap, dummyCollideMap} = opts;
101
- return {
102
- collide_sort: Boolean(drawToCollideMap),
103
- collide_texture: !drawToCollideMap && collideFBO ? collideFBO : dummyCollideMap
104
- };
105
- };
106
-
107
- export default {
108
- name: 'collide',
109
- dependencies: [project],
110
- vs,
111
- inject,
112
- getUniforms: getCollideUniforms
113
- } as ShaderModule;
package/src/mask/utils.ts DELETED
@@ -1,148 +0,0 @@
1
- import {OrthographicView, WebMercatorViewport, log, Layer, Viewport} from '@deck.gl/core';
2
- import {fitBounds} from '@math.gl/web-mercator';
3
-
4
- export type MaskBounds = [number, number, number, number];
5
-
6
- /*
7
- * Compute the bounds of the mask in world space, such that it covers an
8
- * area currently visible (extended by a buffer) or the area of the masking
9
- * data, whichever is smaller
10
- */
11
- export function getMaskBounds({
12
- layers,
13
- viewport
14
- }: {
15
- layers: Layer[];
16
- viewport: Viewport;
17
- }): MaskBounds {
18
- // Join the bounds of layer data
19
- let bounds: MaskBounds | null = null;
20
- for (const layer of layers) {
21
- const subLayerBounds = layer.getBounds();
22
- if (subLayerBounds) {
23
- if (bounds) {
24
- bounds[0] = Math.min(bounds[0], subLayerBounds[0][0]);
25
- bounds[1] = Math.min(bounds[1], subLayerBounds[0][1]);
26
- bounds[2] = Math.max(bounds[2], subLayerBounds[1][0]);
27
- bounds[3] = Math.max(bounds[3], subLayerBounds[1][1]);
28
- } else {
29
- bounds = [
30
- subLayerBounds[0][0],
31
- subLayerBounds[0][1],
32
- subLayerBounds[1][0],
33
- subLayerBounds[1][1]
34
- ];
35
- }
36
- }
37
- }
38
- const viewportBounds = viewport.getBounds();
39
- if (!bounds) {
40
- return viewportBounds;
41
- }
42
-
43
- // Expand viewport bounds by 2X. Heurestically chosen to avoid masking
44
- // errors when mask is partially out of view
45
- const paddedBounds = _doubleBounds(viewportBounds);
46
-
47
- // When bounds of the mask are smaller than the viewport bounds simply use
48
- // mask bounds, so as to maximize resolution & avoid mask rerenders
49
- if (
50
- bounds[2] - bounds[0] < paddedBounds[2] - paddedBounds[0] ||
51
- bounds[3] - bounds[1] < paddedBounds[3] - paddedBounds[1]
52
- ) {
53
- return bounds;
54
- }
55
-
56
- // As viewport shrinks, to avoid pixelation along mask edges
57
- // we need to reduce the bounds and only render the visible portion
58
- // of the mask.
59
- // We pad the viewport bounds to capture the section
60
- // of the mask just outside the viewport to correctly maskByInstance.
61
- // Intersect mask & padded viewport bounds
62
- bounds[0] = Math.max(bounds[0], paddedBounds[0]);
63
- bounds[1] = Math.max(bounds[1], paddedBounds[1]);
64
- bounds[2] = Math.min(bounds[2], paddedBounds[2]);
65
- bounds[3] = Math.min(bounds[3], paddedBounds[3]);
66
- return bounds;
67
- }
68
-
69
- /*
70
- * Compute viewport to render the mask into, covering the given bounds
71
- */
72
- export function getMaskViewport({
73
- bounds,
74
- viewport,
75
- width,
76
- height
77
- }: {
78
- bounds: MaskBounds;
79
- viewport: Viewport;
80
- width: number;
81
- height: number;
82
- }): Viewport | null {
83
- if (bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
84
- return null;
85
- }
86
-
87
- if (viewport.resolution !== undefined) {
88
- log.warn('MaskExtension is not supported in GlobeView')();
89
- return null;
90
- }
91
-
92
- // Single pixel border to prevent mask bleeding at edge of texture
93
- const padding = 1;
94
- width -= padding * 2;
95
- height -= padding * 2;
96
-
97
- if (viewport.isGeospatial) {
98
- const {longitude, latitude, zoom} = fitBounds({
99
- width,
100
- height,
101
- bounds: [
102
- [bounds[0], bounds[1]],
103
- [bounds[2], bounds[3]]
104
- ],
105
- maxZoom: 20
106
- });
107
- return new WebMercatorViewport({
108
- longitude,
109
- latitude,
110
- zoom,
111
- x: padding,
112
- y: padding,
113
- width,
114
- height
115
- });
116
- }
117
-
118
- const center = [(bounds[0] + bounds[2]) / 2, (bounds[1] + bounds[3]) / 2, 0];
119
- const scale = Math.min(
120
- 1048576, // maxZoom of 20: Math.pow(2, 20) = 1048576
121
- width / (bounds[2] - bounds[0]),
122
- height / (bounds[3] - bounds[1])
123
- );
124
-
125
- return new OrthographicView({
126
- x: padding,
127
- y: padding
128
- }).makeViewport({
129
- width,
130
- height,
131
- viewState: {
132
- target: center,
133
- zoom: Math.log2(scale)
134
- }
135
- });
136
- }
137
-
138
- function _doubleBounds(bounds: MaskBounds): MaskBounds {
139
- const size = {
140
- x: bounds[2] - bounds[0],
141
- y: bounds[3] - bounds[1]
142
- };
143
- const center = {
144
- x: bounds[0] + 0.5 * size.x,
145
- y: bounds[1] + 0.5 * size.y
146
- };
147
- return [center.x - size.x, center.y - size.y, center.x + size.x, center.y + size.y];
148
- }