@deck.gl/extensions 9.0.40 → 9.1.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 (160) hide show
  1. package/dist/brushing/brushing-extension.d.ts +1 -0
  2. package/dist/brushing/brushing-extension.d.ts.map +1 -1
  3. package/dist/brushing/brushing-extension.js +16 -19
  4. package/dist/brushing/brushing-extension.js.map +1 -0
  5. package/dist/brushing/shader-module.d.ts +8 -2
  6. package/dist/brushing/shader-module.d.ts.map +1 -1
  7. package/dist/brushing/shader-module.js +75 -50
  8. package/dist/brushing/shader-module.js.map +1 -0
  9. package/dist/clip/clip-extension.d.ts +5 -2
  10. package/dist/clip/clip-extension.d.ts.map +1 -1
  11. package/dist/clip/clip-extension.js +37 -42
  12. package/dist/clip/clip-extension.js.map +1 -0
  13. package/dist/collision-filter/collision-filter-effect.d.ts +4 -4
  14. package/dist/collision-filter/collision-filter-effect.d.ts.map +1 -1
  15. package/dist/collision-filter/collision-filter-effect.js +28 -13
  16. package/dist/collision-filter/collision-filter-effect.js.map +1 -0
  17. package/dist/collision-filter/collision-filter-extension.d.ts +1 -1
  18. package/dist/collision-filter/collision-filter-extension.d.ts.map +1 -1
  19. package/dist/collision-filter/collision-filter-extension.js +6 -6
  20. package/dist/collision-filter/collision-filter-extension.js.map +1 -0
  21. package/dist/collision-filter/collision-filter-pass.d.ts +9 -5
  22. package/dist/collision-filter/collision-filter-pass.d.ts.map +1 -1
  23. package/dist/collision-filter/collision-filter-pass.js +15 -4
  24. package/dist/collision-filter/collision-filter-pass.js.map +1 -0
  25. package/dist/collision-filter/shader-module.d.ts +3 -2
  26. package/dist/collision-filter/shader-module.d.ts.map +1 -1
  27. package/dist/collision-filter/shader-module.js +75 -52
  28. package/dist/collision-filter/shader-module.js.map +1 -0
  29. package/dist/data-filter/aggregator.d.ts +4 -10
  30. package/dist/data-filter/aggregator.d.ts.map +1 -1
  31. package/dist/data-filter/aggregator.js +15 -8
  32. package/dist/data-filter/aggregator.js.map +1 -0
  33. package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
  34. package/dist/data-filter/data-filter-extension.js +49 -39
  35. package/dist/data-filter/data-filter-extension.js.map +1 -0
  36. package/dist/data-filter/shader-module.d.ts +12 -5
  37. package/dist/data-filter/shader-module.d.ts.map +1 -1
  38. package/dist/data-filter/shader-module.js +190 -131
  39. package/dist/data-filter/shader-module.js.map +1 -0
  40. package/dist/dist.dev.js +2720 -2037
  41. package/dist/fill-style/fill-style-extension.d.ts.map +1 -1
  42. package/dist/fill-style/fill-style-extension.js +12 -4
  43. package/dist/fill-style/fill-style-extension.js.map +1 -0
  44. package/dist/fill-style/shader-module.d.ts +64 -6
  45. package/dist/fill-style/shader-module.d.ts.map +1 -1
  46. package/dist/fill-style/shader-module.js +74 -51
  47. package/dist/fill-style/shader-module.js.map +1 -0
  48. package/dist/fp64/fp64-extension.d.ts +1 -0
  49. package/dist/fp64/fp64-extension.d.ts.map +1 -1
  50. package/dist/fp64/fp64-extension.js +8 -19
  51. package/dist/fp64/fp64-extension.js.map +1 -0
  52. package/dist/fp64/project64.d.ts +2 -2
  53. package/dist/fp64/project64.d.ts.map +1 -1
  54. package/dist/fp64/project64.glsl.d.ts +1 -1
  55. package/dist/fp64/project64.glsl.d.ts.map +1 -1
  56. package/dist/fp64/project64.glsl.js +19 -21
  57. package/dist/fp64/project64.glsl.js.map +1 -0
  58. package/dist/fp64/project64.js +25 -24
  59. package/dist/fp64/project64.js.map +1 -0
  60. package/dist/index.cjs +1034 -528
  61. package/dist/index.cjs.map +4 -4
  62. package/dist/index.d.ts +1 -0
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +4 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/mask/mask-effect.d.ts +5 -3
  67. package/dist/mask/mask-effect.d.ts.map +1 -1
  68. package/dist/mask/mask-effect.js +13 -5
  69. package/dist/mask/mask-effect.js.map +1 -0
  70. package/dist/mask/mask-extension.d.ts +1 -1
  71. package/dist/mask/mask-extension.d.ts.map +1 -1
  72. package/dist/mask/mask-extension.js +14 -8
  73. package/dist/mask/mask-extension.js.map +1 -0
  74. package/dist/mask/mask-pass.d.ts +2 -43
  75. package/dist/mask/mask-pass.d.ts.map +1 -1
  76. package/dist/mask/mask-pass.js +5 -1
  77. package/dist/mask/mask-pass.js.map +1 -0
  78. package/dist/mask/shader-module.d.ts +60 -3
  79. package/dist/mask/shader-module.d.ts.map +1 -1
  80. package/dist/mask/shader-module.js +74 -46
  81. package/dist/mask/shader-module.js.map +1 -0
  82. package/dist/path-style/path-style-extension.d.ts.map +1 -1
  83. package/dist/path-style/path-style-extension.js +21 -24
  84. package/dist/path-style/path-style-extension.js.map +1 -0
  85. package/dist/path-style/shaders.glsl.d.ts.map +1 -1
  86. package/dist/path-style/shaders.glsl.js +12 -7
  87. package/dist/path-style/shaders.glsl.js.map +1 -0
  88. package/dist/terrain/height-map-builder.d.ts.map +1 -1
  89. package/dist/terrain/height-map-builder.js +4 -0
  90. package/dist/terrain/height-map-builder.js.map +1 -0
  91. package/dist/terrain/shader-module.d.ts +60 -6
  92. package/dist/terrain/shader-module.d.ts.map +1 -1
  93. package/dist/terrain/shader-module.js +70 -61
  94. package/dist/terrain/shader-module.js.map +1 -0
  95. package/dist/terrain/terrain-cover.d.ts.map +1 -1
  96. package/dist/terrain/terrain-cover.js +4 -0
  97. package/dist/terrain/terrain-cover.js.map +1 -0
  98. package/dist/terrain/terrain-effect.d.ts +4 -2
  99. package/dist/terrain/terrain-effect.d.ts.map +1 -1
  100. package/dist/terrain/terrain-effect.js +32 -18
  101. package/dist/terrain/terrain-effect.js.map +1 -0
  102. package/dist/terrain/terrain-extension.d.ts.map +1 -1
  103. package/dist/terrain/terrain-extension.js +4 -0
  104. package/dist/terrain/terrain-extension.js.map +1 -0
  105. package/dist/terrain/terrain-pass.d.ts +6 -41
  106. package/dist/terrain/terrain-pass.d.ts.map +1 -1
  107. package/dist/terrain/terrain-pass.js +12 -1
  108. package/dist/terrain/terrain-pass.js.map +1 -0
  109. package/dist/terrain/terrain-picking-pass.d.ts +7 -1
  110. package/dist/terrain/terrain-picking-pass.d.ts.map +1 -1
  111. package/dist/terrain/terrain-picking-pass.js +12 -1
  112. package/dist/terrain/terrain-picking-pass.js.map +1 -0
  113. package/dist/terrain/utils.d.ts.map +1 -1
  114. package/dist/terrain/utils.js +4 -0
  115. package/dist/terrain/utils.js.map +1 -0
  116. package/dist/utils/debug.d.ts +2 -2
  117. package/dist/utils/debug.d.ts.map +1 -1
  118. package/dist/utils/debug.js +4 -1
  119. package/dist/utils/debug.js.map +1 -0
  120. package/dist/utils/projection-utils.d.ts.map +1 -1
  121. package/dist/utils/projection-utils.js +4 -0
  122. package/dist/utils/projection-utils.js.map +1 -0
  123. package/dist.min.js +1102 -817
  124. package/package.json +8 -8
  125. package/src/brushing/brushing-extension.ts +17 -20
  126. package/src/brushing/shader-module.ts +58 -47
  127. package/src/clip/clip-extension.ts +38 -40
  128. package/src/collision-filter/collision-filter-effect.ts +31 -20
  129. package/src/collision-filter/collision-filter-extension.ts +6 -7
  130. package/src/collision-filter/collision-filter-pass.ts +17 -6
  131. package/src/collision-filter/shader-module.ts +40 -22
  132. package/src/data-filter/aggregator.ts +23 -11
  133. package/src/data-filter/data-filter-extension.ts +76 -49
  134. package/src/data-filter/shader-module.ts +150 -90
  135. package/src/fill-style/fill-style-extension.ts +13 -5
  136. package/src/fill-style/shader-module.ts +84 -52
  137. package/src/fp64/fp64-extension.ts +8 -19
  138. package/src/fp64/project64.glsl.ts +18 -21
  139. package/src/fp64/project64.ts +27 -28
  140. package/src/index.ts +5 -0
  141. package/src/mask/mask-effect.ts +17 -7
  142. package/src/mask/mask-extension.ts +16 -9
  143. package/src/mask/mask-pass.ts +17 -3
  144. package/src/mask/shader-module.ts +63 -27
  145. package/src/path-style/path-style-extension.ts +27 -28
  146. package/src/path-style/shaders.glsl.ts +13 -7
  147. package/src/terrain/height-map-builder.ts +4 -0
  148. package/src/terrain/shader-module.ts +62 -44
  149. package/src/terrain/terrain-cover.ts +4 -0
  150. package/src/terrain/terrain-effect.ts +36 -19
  151. package/src/terrain/terrain-extension.ts +4 -0
  152. package/src/terrain/terrain-pass.ts +19 -3
  153. package/src/terrain/terrain-picking-pass.ts +15 -2
  154. package/src/terrain/utils.ts +4 -0
  155. package/src/utils/debug.ts +4 -0
  156. package/src/utils/projection-utils.ts +4 -0
  157. package/dist/utils/syntax-tags.d.ts +0 -6
  158. package/dist/utils/syntax-tags.d.ts.map +0 -1
  159. package/dist/utils/syntax-tags.js +0 -5
  160. package/src/utils/syntax-tags.ts +0 -5
@@ -1,28 +1,16 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
20
4
 
21
5
  export default `\
22
6
 
23
7
  const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
24
8
 
25
- uniform vec2 project_uViewProjectionMatrixFP64[16];
9
+ uniform project64Uniforms {
10
+ vec2 scale;
11
+ mat4 viewProjectionMatrix;
12
+ mat4 viewProjectionMatrix64Low;
13
+ } project64;
26
14
 
27
15
  // longitude: lnglat_fp64.xy; latitude: lnglat_fp64.zw
28
16
  void mercatorProject_fp64(vec4 lnglat_fp64, out vec2 out_val[2]) {
@@ -56,7 +44,16 @@ void project_position_fp64(vec2 position, vec2 position64xyLow, out vec2 out_val
56
44
 
57
45
  vec4 project_common_position_to_clipspace_fp64(vec2 vertex_pos_modelspace[4]) {
58
46
  vec2 vertex_pos_clipspace[4];
59
- mat4_vec4_mul_fp64(project_uViewProjectionMatrixFP64, vertex_pos_modelspace,
47
+ vec2 viewProjectionMatrixFP64[16];
48
+ for (int i = 0; i < 4; i++) {
49
+ for (int j = 0; j < 4; j++) {
50
+ viewProjectionMatrixFP64[4 * i + j] = vec2(
51
+ project64.viewProjectionMatrix[j][i],
52
+ project64.viewProjectionMatrix64Low[j][i]
53
+ );
54
+ }
55
+ }
56
+ mat4_vec4_mul_fp64(viewProjectionMatrixFP64, vertex_pos_modelspace,
60
57
  vertex_pos_clipspace);
61
58
  return vec4(
62
59
  vertex_pos_clipspace[0].x,
@@ -1,22 +1,6 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
20
4
 
21
5
  /* eslint-disable camelcase */
22
6
  import {fp64} from '@luma.gl/shadertools';
@@ -27,7 +11,7 @@ import {project, _memoize as memoize} from '@deck.gl/core';
27
11
  import type {Viewport} from '@deck.gl/core';
28
12
  import project64Shader from './project64.glsl';
29
13
 
30
- type Project64ModuleSettings = {
14
+ type Project64ModuleProps = {
31
15
  viewport: Viewport;
32
16
  };
33
17
 
@@ -35,15 +19,21 @@ export default {
35
19
  name: 'project64',
36
20
  dependencies: [project, fp64],
37
21
  vs: project64Shader,
38
- getUniforms
39
- } as ShaderModule<Project64ModuleSettings>;
22
+ getUniforms,
23
+ uniformTypes: {
24
+ scale: 'vec2<f32>',
25
+ // Cannot pass as vec2[16], so instead split into 2 mat4x4
26
+ viewProjectionMatrix: 'mat4x4<f32>',
27
+ viewProjectionMatrix64Low: 'mat4x4<f32>'
28
+ }
29
+ } as ShaderModule<Project64ModuleProps>;
40
30
 
41
31
  // TODO - this module should calculate the 64 bit uniforms
42
32
  // It is currently done by project to minimize duplicated work
43
33
 
44
34
  const getMemoizedUniforms = memoize(calculateUniforms);
45
35
 
46
- function getUniforms(opts?: Project64ModuleSettings | {}): Record<string, any> {
36
+ function getUniforms(opts?: Project64ModuleProps | {}): Record<string, any> {
47
37
  if (opts && 'viewport' in opts) {
48
38
  const {viewProjectionMatrix, scale} = opts.viewport;
49
39
  // We only need to update fp64 uniforms if fp32 projection is being updated
@@ -60,11 +50,20 @@ function calculateUniforms({
60
50
  scale: number;
61
51
  }) {
62
52
  const glViewProjectionMatrixFP64 = fp64ifyMatrix4(viewProjectionMatrix);
63
- const scaleFP64 = fp64ify(scale);
64
-
53
+ const viewProjectionMatrix64High = new Float32Array(16);
54
+ const viewProjectionMatrix64Low = new Float32Array(16);
55
+ for (let i = 0; i < 4; i++) {
56
+ for (let j = 0; j < 4; j++) {
57
+ // Match order used in project.viewProjectionMatrix
58
+ const from = 4 * i + j;
59
+ const to = 4 * j + i;
60
+ viewProjectionMatrix64High[to] = glViewProjectionMatrixFP64[2 * from];
61
+ viewProjectionMatrix64Low[to] = glViewProjectionMatrixFP64[2 * from + 1];
62
+ }
63
+ }
65
64
  return {
66
- project_uViewProjectionMatrixFP64: glViewProjectionMatrixFP64,
67
- project64_uViewProjectionMatrix: glViewProjectionMatrixFP64,
68
- project64_uScale: scaleFP64
65
+ scale: fp64ify(scale),
66
+ viewProjectionMatrix: [...viewProjectionMatrix64High],
67
+ viewProjectionMatrix64Low: [...viewProjectionMatrix64Low]
69
68
  };
70
69
  }
package/src/index.ts CHANGED
@@ -1,3 +1,7 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  export {default as BrushingExtension} from './brushing/brushing-extension';
2
6
  export {default as DataFilterExtension} from './data-filter/data-filter-extension';
3
7
  export {default as Fp64Extension} from './fp64/fp64-extension';
@@ -29,3 +33,4 @@ export type {ClipExtensionProps} from './clip/clip-extension';
29
33
  export type {CollisionFilterExtensionProps} from './collision-filter/collision-filter-extension';
30
34
  export type {MaskExtensionProps} from './mask/mask-extension';
31
35
  export type {TerrainExtensionProps} from './terrain/terrain-extension';
36
+ export type {TerrainModuleProps} from './terrain/shader-module';
@@ -1,3 +1,7 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import {
2
6
  Layer,
3
7
  Viewport,
@@ -186,8 +190,10 @@ export default class MaskEffect implements Effect {
186
190
  viewports: maskViewport ? [maskViewport] : [],
187
191
  onViewportActive,
188
192
  views,
189
- moduleParameters: {
190
- devicePixelRatio: 1
193
+ shaderModuleProps: {
194
+ project: {
195
+ devicePixelRatio: 1
196
+ }
191
197
  }
192
198
  });
193
199
 
@@ -257,13 +263,17 @@ export default class MaskEffect implements Effect {
257
263
  return channelMap;
258
264
  }
259
265
 
260
- getModuleParameters(): {
261
- maskMap: Texture;
262
- maskChannels: Record<string, Mask> | null;
266
+ getShaderModuleProps(): {
267
+ mask: {
268
+ maskMap: Texture;
269
+ maskChannels: Record<string, Mask> | null;
270
+ };
263
271
  } {
264
272
  return {
265
- maskMap: this.masks ? this.maskMap! : this.dummyMaskMap!,
266
- maskChannels: this.masks
273
+ mask: {
274
+ maskMap: this.masks ? this.maskMap! : this.dummyMaskMap!,
275
+ maskChannels: this.masks
276
+ }
267
277
  };
268
278
  }
269
279
 
@@ -1,5 +1,9 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import {COORDINATE_SYSTEM, Layer, LayerExtension, log} from '@deck.gl/core';
2
- import mask from './shader-module';
6
+ import mask, {MaskProps} from './shader-module';
3
7
  import MaskEffect from './mask-effect';
4
8
 
5
9
  const defaultProps = {
@@ -49,17 +53,18 @@ export default class MaskExtension extends LayerExtension {
49
53
  }
50
54
 
51
55
  /* eslint-disable camelcase */
52
- draw(this: Layer<Required<MaskExtensionProps>>, {uniforms, context, moduleParameters}: any) {
53
- uniforms.mask_maskByInstance = this.state.maskByInstance;
56
+ draw(this: Layer<Required<MaskExtensionProps>>, {context, shaderModuleProps}: any) {
57
+ const maskProps = {} as MaskProps;
58
+ maskProps.maskByInstance = Boolean(this.state.maskByInstance);
54
59
  const {maskId, maskInverted} = this.props;
55
- const {maskChannels} = moduleParameters;
60
+ const {maskChannels} = shaderModuleProps.mask || {};
56
61
  const {viewport} = context;
57
62
  if (maskChannels && maskChannels[maskId]) {
58
63
  const {index, bounds, coordinateOrigin: fromCoordinateOrigin} = maskChannels[maskId];
59
64
  let {coordinateSystem: fromCoordinateSystem} = maskChannels[maskId];
60
- uniforms.mask_enabled = true;
61
- uniforms.mask_channel = index;
62
- uniforms.mask_inverted = maskInverted;
65
+ maskProps.enabled = true;
66
+ maskProps.channel = index;
67
+ maskProps.inverted = maskInverted;
63
68
 
64
69
  if (fromCoordinateSystem === COORDINATE_SYSTEM.DEFAULT) {
65
70
  fromCoordinateSystem = viewport.isGeospatial
@@ -69,12 +74,14 @@ export default class MaskExtension extends LayerExtension {
69
74
  const opts = {modelMatrix: null, fromCoordinateOrigin, fromCoordinateSystem};
70
75
  const bl = this.projectPosition([bounds[0], bounds[1], 0], opts);
71
76
  const tr = this.projectPosition([bounds[2], bounds[3], 0], opts);
72
- uniforms.mask_bounds = [bl[0], bl[1], tr[0], tr[1]];
77
+ maskProps.bounds = [bl[0], bl[1], tr[0], tr[1]];
73
78
  } else {
74
79
  if (maskId) {
75
80
  log.warn(`Could not find a mask layer with id: ${maskId}`)();
76
81
  }
77
- uniforms.mask_enabled = false;
82
+ maskProps.enabled = false;
78
83
  }
84
+
85
+ this.setShaderModuleProps({mask: maskProps});
79
86
  }
80
87
  }
@@ -1,4 +1,14 @@
1
- import type {Device, Framebuffer, RenderPipelineParameters, Texture} from '@luma.gl/core';
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
5
+ import type {
6
+ Device,
7
+ Framebuffer,
8
+ Parameters,
9
+ RenderPipelineParameters,
10
+ Texture
11
+ } from '@luma.gl/core';
2
12
  import {Layer, _LayersPass as LayersPass, LayersPassRenderOptions, Viewport} from '@deck.gl/core';
3
13
 
4
14
  type MaskPassRenderOptions = LayersPassRenderOptions & {
@@ -50,11 +60,15 @@ export default class MaskPass extends LayersPass {
50
60
  super.render({...options, clearColor, colorMask, target: this.fbo, pass: 'mask'});
51
61
  }
52
62
 
53
- protected getLayerParameters(layer: Layer<{}>, layerIndex: number, viewport: Viewport) {
63
+ protected getLayerParameters(
64
+ layer: Layer<{}>,
65
+ layerIndex: number,
66
+ viewport: Viewport
67
+ ): Parameters {
54
68
  return {
55
69
  ...layer.props.parameters,
56
70
  blend: true,
57
- depthTest: false,
71
+ depthCompare: 'always',
58
72
  ...MASK_BLENDING
59
73
  };
60
74
  }
@@ -1,38 +1,52 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import type {ShaderModule} from '@luma.gl/shadertools';
2
6
  import {project} from '@deck.gl/core';
3
7
  import type {Texture} from '@luma.gl/core';
4
- import {glsl} from '../utils/syntax-tags';
5
8
 
6
- const vs = glsl`
7
- uniform vec4 mask_bounds;
8
- uniform bool mask_maskByInstance;
9
+ const uniformBlock = /* glsl */ `\
10
+ uniform maskUniforms {
11
+ vec4 bounds;
12
+ highp int channel;
13
+ bool enabled;
14
+ bool inverted;
15
+ bool maskByInstance;
16
+ } mask;
17
+ `;
18
+
19
+ const vertex = /* glsl */ `
9
20
  vec2 mask_getCoords(vec4 position) {
10
- return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);
21
+ return (position.xy - mask.bounds.xy) / (mask.bounds.zw - mask.bounds.xy);
11
22
  }
12
23
  `;
13
24
 
14
- const fs = glsl`
25
+ const vs = `
26
+ ${uniformBlock}
27
+ ${vertex}
28
+ `;
29
+
30
+ const fragment = /* glsl */ `
15
31
  uniform sampler2D mask_texture;
16
- uniform int mask_channel;
17
- uniform bool mask_enabled;
18
- uniform bool mask_inverted;
32
+
19
33
  bool mask_isInBounds(vec2 texCoords) {
20
- if (!mask_enabled) {
34
+ if (!mask.enabled) {
21
35
  return true;
22
36
  }
23
37
  vec4 maskColor = texture(mask_texture, texCoords);
24
38
  float maskValue = 1.0;
25
- if (mask_channel == 0) {
39
+ if (mask.channel == 0) {
26
40
  maskValue = maskColor.r;
27
- } else if (mask_channel == 1) {
41
+ } else if (mask.channel == 1) {
28
42
  maskValue = maskColor.g;
29
- } else if (mask_channel == 2) {
43
+ } else if (mask.channel == 2) {
30
44
  maskValue = maskColor.b;
31
- } else if (mask_channel == 3) {
45
+ } else if (mask.channel == 3) {
32
46
  maskValue = maskColor.a;
33
47
  }
34
48
 
35
- if (mask_inverted) {
49
+ if (mask.inverted) {
36
50
  return maskValue >= 0.5;
37
51
  } else {
38
52
  return maskValue < 0.5;
@@ -40,47 +54,62 @@ bool mask_isInBounds(vec2 texCoords) {
40
54
  }
41
55
  `;
42
56
 
57
+ const fs = `
58
+ ${uniformBlock}
59
+ ${fragment}
60
+ `;
61
+
43
62
  const inject = {
44
- 'vs:#decl': glsl`
63
+ 'vs:#decl': /* glsl */ `
45
64
  out vec2 mask_texCoords;
46
65
  `,
47
- 'vs:#main-end': glsl`
66
+ 'vs:#main-end': /* glsl */ `
48
67
  vec4 mask_common_position;
49
- if (mask_maskByInstance) {
68
+ if (mask.maskByInstance) {
50
69
  mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
51
70
  } else {
52
71
  mask_common_position = geometry.position;
53
72
  }
54
73
  mask_texCoords = mask_getCoords(mask_common_position);
55
74
  `,
56
- 'fs:#decl': glsl`
75
+ 'fs:#decl': /* glsl */ `
57
76
  in vec2 mask_texCoords;
58
77
  `,
59
- 'fs:#main-start': glsl`
60
- if (mask_enabled) {
78
+ 'fs:#main-start': /* glsl */ `
79
+ if (mask.enabled) {
61
80
  bool mask = mask_isInBounds(mask_texCoords);
62
81
 
63
82
  // Debug: show extent of render target
64
83
  // fragColor = vec4(mask_texCoords, 0.0, 1.0);
65
- fragColor = texture(mask_texture, mask_texCoords);
84
+ // fragColor = texture(mask_texture, mask_texCoords);
66
85
 
67
86
  if (!mask) discard;
68
87
  }
69
88
  `
70
89
  };
71
90
 
72
- type MaskModuleSettings = {
91
+ type MaskBindingProps = {
73
92
  maskMap?: Texture;
74
93
  };
75
94
 
95
+ type MaskUniformProps = {
96
+ bounds: [number, number, number, number];
97
+ channel: number;
98
+ enabled: boolean;
99
+ inverted: boolean;
100
+ maskByInstance: boolean;
101
+ };
102
+
103
+ export type MaskProps = MaskBindingProps & MaskUniformProps;
104
+
76
105
  /* eslint-disable camelcase */
77
- const getMaskUniforms = (opts?: MaskModuleSettings | {}): Record<string, any> => {
106
+ const getMaskUniforms = (opts?: MaskProps | {}): Record<string, any> => {
78
107
  if (opts && 'maskMap' in opts) {
79
108
  return {
80
109
  mask_texture: opts.maskMap
81
110
  };
82
111
  }
83
- return {};
112
+ return opts || {};
84
113
  };
85
114
 
86
115
  export default {
@@ -89,5 +118,12 @@ export default {
89
118
  vs,
90
119
  fs,
91
120
  inject,
92
- getUniforms: getMaskUniforms
93
- } as ShaderModule<MaskModuleSettings>;
121
+ getUniforms: getMaskUniforms,
122
+ uniformTypes: {
123
+ bounds: 'vec4<f32>',
124
+ channel: 'i32',
125
+ enabled: 'i32',
126
+ inverted: 'i32',
127
+ maskByInstance: 'i32'
128
+ }
129
+ } as const satisfies ShaderModule<MaskProps>;
@@ -1,29 +1,13 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
20
4
 
21
5
  import {LayerExtension, _mergeShaders as mergeShaders} from '@deck.gl/core';
22
6
  import {vec3} from '@math.gl/core';
23
7
  import {dashShaders, offsetShaders} from './shaders.glsl';
24
8
 
25
9
  import type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core';
26
- import type {Model} from '@luma.gl/engine';
10
+ import type {ShaderModule} from '@luma.gl/shadertools';
27
11
 
28
12
  const defaultProps = {
29
13
  getDashArray: {type: 'accessor', value: [0, 0]},
@@ -32,6 +16,11 @@ const defaultProps = {
32
16
  dashGapPickable: false
33
17
  };
34
18
 
19
+ type PathStyleProps = {
20
+ dashAlignMode: number;
21
+ dashGapPickable: boolean;
22
+ };
23
+
35
24
  export type PathStyleExtensionProps<DataT = any> = {
36
25
  /**
37
26
  * Accessor for the dash array to draw each path with: `[dashSize, gapSize]` relative to the width of the path.
@@ -97,7 +86,7 @@ export default class PathStyleExtension extends LayerExtension<PathStyleExtensio
97
86
  }
98
87
 
99
88
  // Merge shader injection
100
- let result = {};
89
+ let result = {} as {inject: Record<string, string>};
101
90
  if (extension.opts.dash) {
102
91
  result = mergeShaders(result, dashShaders);
103
92
  }
@@ -105,7 +94,18 @@ export default class PathStyleExtension extends LayerExtension<PathStyleExtensio
105
94
  result = mergeShaders(result, offsetShaders);
106
95
  }
107
96
 
108
- return result;
97
+ const {inject} = result;
98
+ const pathStyle: ShaderModule<PathStyleProps> = {
99
+ name: 'pathStyle',
100
+ inject,
101
+ uniformTypes: {
102
+ dashAlignMode: 'f32',
103
+ dashGapPickable: 'i32'
104
+ }
105
+ };
106
+ return {
107
+ modules: [pathStyle]
108
+ };
109
109
  }
110
110
 
111
111
  initializeState(this: Layer<PathStyleExtensionProps>, context: LayerContext, extension: this) {
@@ -149,14 +149,13 @@ export default class PathStyleExtension extends LayerExtension<PathStyleExtensio
149
149
  return;
150
150
  }
151
151
 
152
- const uniforms: any = {};
153
-
154
152
  if (extension.opts.dash) {
155
- uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
156
- uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
153
+ const pathStyleProps: PathStyleProps = {
154
+ dashAlignMode: this.props.dashJustified ? 1 : 0,
155
+ dashGapPickable: Boolean(this.props.dashGapPickable)
156
+ };
157
+ this.setShaderModuleProps({pathStyle: pathStyleProps});
157
158
  }
158
-
159
- (this.state.model as Model)?.setUniforms(uniforms);
160
159
  }
161
160
 
162
161
  getDashOffsets(this: Layer<PathStyleExtensionProps>, path: number[] | number[][]): number[] {
@@ -1,3 +1,7 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  export const dashShaders = {
2
6
  inject: {
3
7
  'vs:#decl': `
@@ -13,9 +17,11 @@ vDashOffset = instanceDashOffsets / width.x;
13
17
  `,
14
18
 
15
19
  'fs:#decl': `
16
- uniform float dashAlignMode;
17
- uniform float capType;
18
- uniform bool dashGapPickable;
20
+ uniform pathStyleUniforms {
21
+ float dashAlignMode;
22
+ bool dashGapPickable;
23
+ } pathStyle;
24
+
19
25
  in vec2 vDashArray;
20
26
  in float vDashOffset;
21
27
  `,
@@ -36,7 +42,7 @@ in float vDashOffset;
36
42
  float offset;
37
43
 
38
44
  if (unitLength > 0.0) {
39
- if (dashAlignMode == 0.0) {
45
+ if (pathStyle.dashAlignMode == 0.0) {
40
46
  offset = vDashOffset;
41
47
  } else {
42
48
  unitLength = vPathLength / round(vPathLength / unitLength);
@@ -46,8 +52,8 @@ in float vDashOffset;
46
52
  float unitOffset = mod(vPathPosition.y + offset, unitLength);
47
53
 
48
54
  if (gapLength > 0.0 && unitOffset > solidLength) {
49
- if (capType <= 0.5) {
50
- if (!(dashGapPickable && bool(picking.isActive))) {
55
+ if (path.capType <= 0.5) {
56
+ if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
51
57
  discard;
52
58
  }
53
59
  } else {
@@ -57,7 +63,7 @@ in float vDashOffset;
57
63
  vPathPosition.x
58
64
  ));
59
65
  if (distToEnd > 1.0) {
60
- if (!(dashGapPickable && bool(picking.isActive))) {
66
+ if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
61
67
  discard;
62
68
  }
63
69
  }
@@ -1,3 +1,7 @@
1
+ // deck.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+
1
5
  import {Device, Framebuffer} from '@luma.gl/core';
2
6
  import {joinLayerBounds, getRenderBounds, makeViewport, Bounds} from '../utils/projection-utils';
3
7
  import {createRenderTarget} from './utils';