@deck.gl/extensions 9.0.0-beta.1 → 9.0.0-beta.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.
Files changed (232) hide show
  1. package/dist/brushing/brushing-extension.js +80 -0
  2. package/dist/{esm/brushing → brushing}/shader-module.js +24 -30
  3. package/dist/clip/clip-extension.js +117 -0
  4. package/{typed → dist}/collision-filter/collision-filter-effect.d.ts.map +1 -1
  5. package/dist/collision-filter/collision-filter-effect.js +193 -0
  6. package/dist/collision-filter/collision-filter-extension.js +49 -0
  7. package/{typed → dist}/collision-filter/collision-filter-pass.d.ts.map +1 -1
  8. package/dist/collision-filter/collision-filter-pass.js +25 -0
  9. package/dist/{esm/collision-filter → collision-filter}/shader-module.js +17 -24
  10. package/dist/data-filter/aggregator.js +104 -0
  11. package/{typed → dist}/data-filter/data-filter-extension.d.ts.map +1 -1
  12. package/dist/data-filter/data-filter-extension.js +162 -0
  13. package/dist/data-filter/shader-module.js +159 -0
  14. package/dist/dist.dev.js +1519 -9832
  15. package/dist/fill-style/fill-style-extension.js +118 -0
  16. package/dist/{esm/fill-style → fill-style}/shaders.glsl.js +37 -43
  17. package/dist/fp64/fp64-extension.js +35 -0
  18. package/dist/{esm/fp64 → fp64}/project64.glsl.js +19 -1
  19. package/dist/fp64/project64.js +50 -0
  20. package/dist/index.cjs +2724 -0
  21. package/dist/index.cjs.map +7 -0
  22. package/dist/index.js +11 -0
  23. package/{typed → dist}/mask/mask-effect.d.ts.map +1 -1
  24. package/dist/mask/mask-effect.js +194 -0
  25. package/dist/mask/mask-extension.js +57 -0
  26. package/{typed → dist}/mask/mask-pass.d.ts.map +1 -1
  27. package/dist/mask/mask-pass.js +44 -0
  28. package/dist/{esm/mask → mask}/shader-module.js +18 -21
  29. package/dist/path-style/path-style-extension.js +111 -0
  30. package/dist/{esm/path-style → path-style}/shaders.glsl.js +20 -13
  31. package/dist/terrain/height-map-builder.js +104 -0
  32. package/dist/terrain/shader-module.js +139 -0
  33. package/dist/terrain/terrain-cover.js +187 -0
  34. package/{typed → dist}/terrain/terrain-effect.d.ts.map +1 -1
  35. package/dist/terrain/terrain-effect.js +184 -0
  36. package/dist/terrain/terrain-extension.js +44 -0
  37. package/{typed → dist}/terrain/terrain-pass.d.ts.map +1 -1
  38. package/dist/terrain/terrain-pass.js +61 -0
  39. package/{typed → dist}/terrain/terrain-picking-pass.d.ts.map +1 -1
  40. package/dist/terrain/terrain-picking-pass.js +66 -0
  41. package/dist/terrain/utils.js +21 -0
  42. package/{typed → dist}/utils/debug.d.ts.map +1 -1
  43. package/dist/utils/debug.js +50 -0
  44. package/dist/utils/projection-utils.js +153 -0
  45. package/dist.min.js +72 -201
  46. package/package.json +19 -12
  47. package/src/collision-filter/collision-filter-effect.ts +12 -8
  48. package/src/collision-filter/collision-filter-pass.ts +1 -3
  49. package/src/data-filter/data-filter-extension.ts +3 -5
  50. package/src/mask/mask-effect.ts +0 -1
  51. package/src/mask/mask-pass.ts +1 -3
  52. package/src/terrain/terrain-effect.ts +8 -2
  53. package/src/terrain/terrain-pass.ts +2 -5
  54. package/src/terrain/terrain-picking-pass.ts +1 -3
  55. package/src/utils/debug.ts +1 -2
  56. package/dist/es5/brushing/brushing-extension.js +0 -108
  57. package/dist/es5/brushing/brushing-extension.js.map +0 -1
  58. package/dist/es5/brushing/shader-module.js +0 -50
  59. package/dist/es5/brushing/shader-module.js.map +0 -1
  60. package/dist/es5/clip/clip-extension.js +0 -98
  61. package/dist/es5/clip/clip-extension.js.map +0 -1
  62. package/dist/es5/collision-filter/collision-filter-effect.js +0 -294
  63. package/dist/es5/collision-filter/collision-filter-effect.js.map +0 -1
  64. package/dist/es5/collision-filter/collision-filter-extension.js +0 -109
  65. package/dist/es5/collision-filter/collision-filter-extension.js.map +0 -1
  66. package/dist/es5/collision-filter/collision-filter-pass.js +0 -79
  67. package/dist/es5/collision-filter/collision-filter-pass.js.map +0 -1
  68. package/dist/es5/collision-filter/shader-module.js +0 -39
  69. package/dist/es5/collision-filter/shader-module.js.map +0 -1
  70. package/dist/es5/data-filter/aggregator.js +0 -79
  71. package/dist/es5/data-filter/aggregator.js.map +0 -1
  72. package/dist/es5/data-filter/data-filter-extension.js +0 -236
  73. package/dist/es5/data-filter/data-filter-extension.js.map +0 -1
  74. package/dist/es5/data-filter/shader-module.js +0 -122
  75. package/dist/es5/data-filter/shader-module.js.map +0 -1
  76. package/dist/es5/fill-style/fill-style-extension.js +0 -190
  77. package/dist/es5/fill-style/fill-style-extension.js.map +0 -1
  78. package/dist/es5/fill-style/shaders.glsl.js +0 -59
  79. package/dist/es5/fill-style/shaders.glsl.js.map +0 -1
  80. package/dist/es5/fp64/fp64-extension.js +0 -55
  81. package/dist/es5/fp64/fp64-extension.js.map +0 -1
  82. package/dist/es5/fp64/project64.glsl.js +0 -9
  83. package/dist/es5/fp64/project64.glsl.js.map +0 -1
  84. package/dist/es5/fp64/project64.js +0 -52
  85. package/dist/es5/fp64/project64.js.map +0 -1
  86. package/dist/es5/index.js +0 -88
  87. package/dist/es5/index.js.map +0 -1
  88. package/dist/es5/mask/mask-effect.js +0 -279
  89. package/dist/es5/mask/mask-effect.js.map +0 -1
  90. package/dist/es5/mask/mask-extension.js +0 -113
  91. package/dist/es5/mask/mask-extension.js.map +0 -1
  92. package/dist/es5/mask/mask-pass.js +0 -106
  93. package/dist/es5/mask/mask-pass.js.map +0 -1
  94. package/dist/es5/mask/shader-module.js +0 -38
  95. package/dist/es5/mask/shader-module.js.map +0 -1
  96. package/dist/es5/path-style/path-style-extension.js +0 -169
  97. package/dist/es5/path-style/path-style-extension.js.map +0 -1
  98. package/dist/es5/path-style/shaders.glsl.js +0 -25
  99. package/dist/es5/path-style/shaders.glsl.js.map +0 -1
  100. package/dist/es5/terrain/height-map-builder.js +0 -111
  101. package/dist/es5/terrain/height-map-builder.js.map +0 -1
  102. package/dist/es5/terrain/shader-module.js +0 -86
  103. package/dist/es5/terrain/shader-module.js.map +0 -1
  104. package/dist/es5/terrain/terrain-cover.js +0 -256
  105. package/dist/es5/terrain/terrain-cover.js.map +0 -1
  106. package/dist/es5/terrain/terrain-effect.js +0 -326
  107. package/dist/es5/terrain/terrain-effect.js.map +0 -1
  108. package/dist/es5/terrain/terrain-extension.js +0 -94
  109. package/dist/es5/terrain/terrain-extension.js.map +0 -1
  110. package/dist/es5/terrain/terrain-pass.js +0 -121
  111. package/dist/es5/terrain/terrain-pass.js.map +0 -1
  112. package/dist/es5/terrain/terrain-picking-pass.js +0 -124
  113. package/dist/es5/terrain/terrain-picking-pass.js.map +0 -1
  114. package/dist/es5/terrain/utils.js +0 -35
  115. package/dist/es5/terrain/utils.js.map +0 -1
  116. package/dist/es5/utils/debug.js +0 -71
  117. package/dist/es5/utils/debug.js.map +0 -1
  118. package/dist/es5/utils/projection-utils.js +0 -168
  119. package/dist/es5/utils/projection-utils.js.map +0 -1
  120. package/dist/esm/brushing/brushing-extension.js +0 -68
  121. package/dist/esm/brushing/brushing-extension.js.map +0 -1
  122. package/dist/esm/brushing/shader-module.js.map +0 -1
  123. package/dist/esm/clip/clip-extension.js +0 -86
  124. package/dist/esm/clip/clip-extension.js.map +0 -1
  125. package/dist/esm/collision-filter/collision-filter-effect.js +0 -246
  126. package/dist/esm/collision-filter/collision-filter-effect.js.map +0 -1
  127. package/dist/esm/collision-filter/collision-filter-extension.js +0 -75
  128. package/dist/esm/collision-filter/collision-filter-extension.js.map +0 -1
  129. package/dist/esm/collision-filter/collision-filter-pass.js +0 -32
  130. package/dist/esm/collision-filter/collision-filter-pass.js.map +0 -1
  131. package/dist/esm/collision-filter/shader-module.js.map +0 -1
  132. package/dist/esm/data-filter/aggregator.js +0 -102
  133. package/dist/esm/data-filter/aggregator.js.map +0 -1
  134. package/dist/esm/data-filter/data-filter-extension.js +0 -189
  135. package/dist/esm/data-filter/data-filter-extension.js.map +0 -1
  136. package/dist/esm/data-filter/shader-module.js +0 -164
  137. package/dist/esm/data-filter/shader-module.js.map +0 -1
  138. package/dist/esm/fill-style/fill-style-extension.js +0 -156
  139. package/dist/esm/fill-style/fill-style-extension.js.map +0 -1
  140. package/dist/esm/fill-style/shaders.glsl.js.map +0 -1
  141. package/dist/esm/fp64/fp64-extension.js +0 -20
  142. package/dist/esm/fp64/fp64-extension.js.map +0 -1
  143. package/dist/esm/fp64/project64.glsl.js.map +0 -1
  144. package/dist/esm/fp64/project64.js +0 -43
  145. package/dist/esm/fp64/project64.js.map +0 -1
  146. package/dist/esm/index.js +0 -11
  147. package/dist/esm/index.js.map +0 -1
  148. package/dist/esm/mask/mask-effect.js +0 -228
  149. package/dist/esm/mask/mask-effect.js.map +0 -1
  150. package/dist/esm/mask/mask-extension.js +0 -83
  151. package/dist/esm/mask/mask-extension.js.map +0 -1
  152. package/dist/esm/mask/mask-pass.js +0 -58
  153. package/dist/esm/mask/mask-pass.js.map +0 -1
  154. package/dist/esm/mask/shader-module.js.map +0 -1
  155. package/dist/esm/path-style/path-style-extension.js +0 -130
  156. package/dist/esm/path-style/path-style-extension.js.map +0 -1
  157. package/dist/esm/path-style/shaders.glsl.js.map +0 -1
  158. package/dist/esm/terrain/height-map-builder.js +0 -86
  159. package/dist/esm/terrain/height-map-builder.js.map +0 -1
  160. package/dist/esm/terrain/shader-module.js +0 -127
  161. package/dist/esm/terrain/shader-module.js.map +0 -1
  162. package/dist/esm/terrain/terrain-cover.js +0 -212
  163. package/dist/esm/terrain/terrain-cover.js.map +0 -1
  164. package/dist/esm/terrain/terrain-effect.js +0 -219
  165. package/dist/esm/terrain/terrain-effect.js.map +0 -1
  166. package/dist/esm/terrain/terrain-extension.js +0 -59
  167. package/dist/esm/terrain/terrain-extension.js.map +0 -1
  168. package/dist/esm/terrain/terrain-pass.js +0 -71
  169. package/dist/esm/terrain/terrain-pass.js.map +0 -1
  170. package/dist/esm/terrain/terrain-picking-pass.js +0 -73
  171. package/dist/esm/terrain/terrain-picking-pass.js.map +0 -1
  172. package/dist/esm/terrain/utils.js +0 -19
  173. package/dist/esm/terrain/utils.js.map +0 -1
  174. package/dist/esm/utils/debug.js +0 -61
  175. package/dist/esm/utils/debug.js.map +0 -1
  176. package/dist/esm/utils/projection-utils.js +0 -134
  177. package/dist/esm/utils/projection-utils.js.map +0 -1
  178. /package/{typed → dist}/brushing/brushing-extension.d.ts +0 -0
  179. /package/{typed → dist}/brushing/brushing-extension.d.ts.map +0 -0
  180. /package/{typed → dist}/brushing/shader-module.d.ts +0 -0
  181. /package/{typed → dist}/brushing/shader-module.d.ts.map +0 -0
  182. /package/{typed → dist}/clip/clip-extension.d.ts +0 -0
  183. /package/{typed → dist}/clip/clip-extension.d.ts.map +0 -0
  184. /package/{typed → dist}/collision-filter/collision-filter-effect.d.ts +0 -0
  185. /package/{typed → dist}/collision-filter/collision-filter-extension.d.ts +0 -0
  186. /package/{typed → dist}/collision-filter/collision-filter-extension.d.ts.map +0 -0
  187. /package/{typed → dist}/collision-filter/collision-filter-pass.d.ts +0 -0
  188. /package/{typed → dist}/collision-filter/shader-module.d.ts +0 -0
  189. /package/{typed → dist}/collision-filter/shader-module.d.ts.map +0 -0
  190. /package/{typed → dist}/data-filter/aggregator.d.ts +0 -0
  191. /package/{typed → dist}/data-filter/aggregator.d.ts.map +0 -0
  192. /package/{typed → dist}/data-filter/data-filter-extension.d.ts +0 -0
  193. /package/{typed → dist}/data-filter/shader-module.d.ts +0 -0
  194. /package/{typed → dist}/data-filter/shader-module.d.ts.map +0 -0
  195. /package/{typed → dist}/fill-style/fill-style-extension.d.ts +0 -0
  196. /package/{typed → dist}/fill-style/fill-style-extension.d.ts.map +0 -0
  197. /package/{typed → dist}/fill-style/shaders.glsl.d.ts +0 -0
  198. /package/{typed → dist}/fill-style/shaders.glsl.d.ts.map +0 -0
  199. /package/{typed → dist}/fp64/fp64-extension.d.ts +0 -0
  200. /package/{typed → dist}/fp64/fp64-extension.d.ts.map +0 -0
  201. /package/{typed → dist}/fp64/project64.d.ts +0 -0
  202. /package/{typed → dist}/fp64/project64.d.ts.map +0 -0
  203. /package/{typed → dist}/fp64/project64.glsl.d.ts +0 -0
  204. /package/{typed → dist}/fp64/project64.glsl.d.ts.map +0 -0
  205. /package/{typed → dist}/index.d.ts +0 -0
  206. /package/{typed → dist}/index.d.ts.map +0 -0
  207. /package/{typed → dist}/mask/mask-effect.d.ts +0 -0
  208. /package/{typed → dist}/mask/mask-extension.d.ts +0 -0
  209. /package/{typed → dist}/mask/mask-extension.d.ts.map +0 -0
  210. /package/{typed → dist}/mask/mask-pass.d.ts +0 -0
  211. /package/{typed → dist}/mask/shader-module.d.ts +0 -0
  212. /package/{typed → dist}/mask/shader-module.d.ts.map +0 -0
  213. /package/{typed → dist}/path-style/path-style-extension.d.ts +0 -0
  214. /package/{typed → dist}/path-style/path-style-extension.d.ts.map +0 -0
  215. /package/{typed → dist}/path-style/shaders.glsl.d.ts +0 -0
  216. /package/{typed → dist}/path-style/shaders.glsl.d.ts.map +0 -0
  217. /package/{typed → dist}/terrain/height-map-builder.d.ts +0 -0
  218. /package/{typed → dist}/terrain/height-map-builder.d.ts.map +0 -0
  219. /package/{typed → dist}/terrain/shader-module.d.ts +0 -0
  220. /package/{typed → dist}/terrain/shader-module.d.ts.map +0 -0
  221. /package/{typed → dist}/terrain/terrain-cover.d.ts +0 -0
  222. /package/{typed → dist}/terrain/terrain-cover.d.ts.map +0 -0
  223. /package/{typed → dist}/terrain/terrain-effect.d.ts +0 -0
  224. /package/{typed → dist}/terrain/terrain-extension.d.ts +0 -0
  225. /package/{typed → dist}/terrain/terrain-extension.d.ts.map +0 -0
  226. /package/{typed → dist}/terrain/terrain-pass.d.ts +0 -0
  227. /package/{typed → dist}/terrain/terrain-picking-pass.d.ts +0 -0
  228. /package/{typed → dist}/terrain/utils.d.ts +0 -0
  229. /package/{typed → dist}/terrain/utils.d.ts.map +0 -0
  230. /package/{typed → dist}/utils/debug.d.ts +0 -0
  231. /package/{typed → dist}/utils/projection-utils.d.ts +0 -0
  232. /package/{typed → dist}/utils/projection-utils.d.ts.map +0 -0
@@ -0,0 +1,153 @@
1
+ import { WebMercatorViewport, OrthographicViewport } from '@deck.gl/core';
2
+ /*
3
+ * Compute the union of bounds from multiple layers
4
+ * Returns bounds in CARTESIAN coordinates
5
+ */
6
+ export function joinLayerBounds(
7
+ /** The layers to combine */
8
+ layers,
9
+ /** A Viewport instance that is used to determine the type of the view */
10
+ viewport) {
11
+ // Join the bounds of layer data
12
+ const bounds = [Infinity, Infinity, -Infinity, -Infinity];
13
+ for (const layer of layers) {
14
+ const layerBounds = layer.getBounds();
15
+ if (layerBounds) {
16
+ const bottomLeftCommon = layer.projectPosition(layerBounds[0], { viewport, autoOffset: false });
17
+ const topRightCommon = layer.projectPosition(layerBounds[1], { viewport, autoOffset: false });
18
+ bounds[0] = Math.min(bounds[0], bottomLeftCommon[0]);
19
+ bounds[1] = Math.min(bounds[1], bottomLeftCommon[1]);
20
+ bounds[2] = Math.max(bounds[2], topRightCommon[0]);
21
+ bounds[3] = Math.max(bounds[3], topRightCommon[1]);
22
+ }
23
+ }
24
+ if (Number.isFinite(bounds[0])) {
25
+ return bounds;
26
+ }
27
+ return null;
28
+ }
29
+ const MAX_VIEWPORT_SIZE = 2048;
30
+ /** Construct a viewport that just covers the target bounds. Used for rendering to common space indexed texture. */
31
+ export function makeViewport(opts) {
32
+ const { bounds, viewport, border = 0 } = opts;
33
+ const { isGeospatial } = viewport;
34
+ if (bounds[2] <= bounds[0] || bounds[3] <= bounds[1]) {
35
+ return null;
36
+ }
37
+ const centerWorld = viewport.unprojectPosition([
38
+ (bounds[0] + bounds[2]) / 2,
39
+ (bounds[1] + bounds[3]) / 2,
40
+ 0
41
+ ]);
42
+ let { width, height, zoom } = opts;
43
+ if (zoom === undefined) {
44
+ // Use width and height to determine zoom
45
+ width = width - border * 2;
46
+ height = height - border * 2;
47
+ const scale = Math.min(width / (bounds[2] - bounds[0]), height / (bounds[3] - bounds[1]));
48
+ zoom = Math.min(Math.log2(scale), 20);
49
+ }
50
+ else if (!width || !height) {
51
+ // Use zoom to determine width and height
52
+ const scale = 2 ** zoom;
53
+ width = Math.round(Math.abs(bounds[2] - bounds[0]) * scale);
54
+ height = Math.round(Math.abs(bounds[3] - bounds[1]) * scale);
55
+ const maxSize = MAX_VIEWPORT_SIZE - border * 2;
56
+ if (width > maxSize || height > maxSize) {
57
+ const r = maxSize / Math.max(width, height);
58
+ width = Math.round(width * r);
59
+ height = Math.round(height * r);
60
+ zoom += Math.log2(r);
61
+ }
62
+ }
63
+ // TODO - find a more generic way to construct this viewport
64
+ // Geospatial viewports may not be web-mercator
65
+ return isGeospatial
66
+ ? new WebMercatorViewport({
67
+ id: viewport.id,
68
+ x: border,
69
+ y: border,
70
+ width,
71
+ height,
72
+ longitude: centerWorld[0],
73
+ latitude: centerWorld[1],
74
+ zoom,
75
+ orthographic: true
76
+ })
77
+ : new OrthographicViewport({
78
+ id: viewport.id,
79
+ x: border,
80
+ y: border,
81
+ width,
82
+ height,
83
+ target: centerWorld,
84
+ zoom,
85
+ flipY: false
86
+ });
87
+ }
88
+ /** Returns viewport bounds in CARTESIAN coordinates */
89
+ export function getViewportBounds(viewport, zRange) {
90
+ // Viewport bounds in world coordinates
91
+ let viewportBoundsWorld;
92
+ if (zRange && zRange.length === 2) {
93
+ const [minZ, maxZ] = zRange;
94
+ const bounds0 = viewport.getBounds({ z: minZ });
95
+ const bounds1 = viewport.getBounds({ z: maxZ });
96
+ viewportBoundsWorld = [
97
+ Math.min(bounds0[0], bounds1[0]),
98
+ Math.min(bounds0[1], bounds1[1]),
99
+ Math.max(bounds0[2], bounds1[2]),
100
+ Math.max(bounds0[3], bounds1[3])
101
+ ];
102
+ }
103
+ else {
104
+ viewportBoundsWorld = viewport.getBounds();
105
+ }
106
+ // Viewport bounds in cartesian coordinates
107
+ const viewportBottomLeftCommon = viewport.projectPosition(viewportBoundsWorld.slice(0, 2));
108
+ const viewportTopRightCommon = viewport.projectPosition(viewportBoundsWorld.slice(2, 4));
109
+ return [
110
+ viewportBottomLeftCommon[0],
111
+ viewportBottomLeftCommon[1],
112
+ viewportTopRightCommon[0],
113
+ viewportTopRightCommon[1]
114
+ ];
115
+ }
116
+ /*
117
+ * Determine the common space bounds that best cover the given data for the given viewport
118
+ * Returns bounds in CARTESIAN coordinates
119
+ */
120
+ export function getRenderBounds(layerBounds, viewport, zRange) {
121
+ if (!layerBounds) {
122
+ return [0, 0, 1, 1];
123
+ }
124
+ const viewportBounds = getViewportBounds(viewport, zRange);
125
+ // Expand viewport bounds by 2X. Heurestically chosen to avoid masking
126
+ // errors when mask is partially out of view
127
+ const paddedBounds = doubleBounds(viewportBounds);
128
+ // When bounds of the layers are smaller than the viewport bounds simply use
129
+ // mask bounds, so as to maximize resolution & avoid rerenders
130
+ if (layerBounds[2] - layerBounds[0] <= paddedBounds[2] - paddedBounds[0] &&
131
+ layerBounds[3] - layerBounds[1] <= paddedBounds[3] - paddedBounds[1]) {
132
+ return layerBounds;
133
+ }
134
+ // As viewport shrinks, to avoid pixelation along mask edges
135
+ // we need to reduce the bounds and only render the visible portion
136
+ // of the mask.
137
+ // We pad the viewport bounds to capture the section
138
+ // of the mask just outside the viewport to correctly maskByInstance.
139
+ // Intersect mask & padded viewport bounds
140
+ return [
141
+ Math.max(layerBounds[0], paddedBounds[0]),
142
+ Math.max(layerBounds[1], paddedBounds[1]),
143
+ Math.min(layerBounds[2], paddedBounds[2]),
144
+ Math.min(layerBounds[3], paddedBounds[3])
145
+ ];
146
+ }
147
+ function doubleBounds(bounds) {
148
+ const dx = bounds[2] - bounds[0];
149
+ const dy = bounds[3] - bounds[1];
150
+ const centerX = (bounds[0] + bounds[2]) / 2;
151
+ const centerY = (bounds[1] + bounds[3]) / 2;
152
+ return [centerX - dx, centerY - dy, centerX + dx, centerY + dy];
153
+ }