@deck.gl/extensions 9.0.0-beta.4 → 9.0.0-beta.6

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 (47) hide show
  1. package/dist/brushing/shader-module.d.ts.map +1 -1
  2. package/dist/brushing/shader-module.js +52 -57
  3. package/dist/clip/clip-extension.d.ts.map +1 -1
  4. package/dist/clip/clip-extension.js +6 -6
  5. package/dist/collision-filter/shader-module.d.ts.map +1 -1
  6. package/dist/collision-filter/shader-module.js +46 -56
  7. package/dist/data-filter/aggregator.d.ts.map +1 -1
  8. package/dist/data-filter/aggregator.js +11 -14
  9. package/dist/data-filter/data-filter-extension.d.ts +2 -1
  10. package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
  11. package/dist/data-filter/data-filter-extension.js +13 -7
  12. package/dist/data-filter/shader-module.d.ts.map +1 -1
  13. package/dist/data-filter/shader-module.js +70 -78
  14. package/dist/dist.dev.js +297 -302
  15. package/dist/fill-style/fill-style-extension.js +1 -1
  16. package/dist/fill-style/{shaders.glsl.d.ts → shader-module.d.ts} +1 -1
  17. package/dist/fill-style/shader-module.d.ts.map +1 -0
  18. package/dist/fill-style/{shaders.glsl.js → shader-module.js} +27 -33
  19. package/dist/fp64/project64.glsl.js +41 -60
  20. package/dist/index.cjs +374 -432
  21. package/dist/index.cjs.map +4 -4
  22. package/dist/mask/mask-pass.js +2 -2
  23. package/dist/mask/shader-module.d.ts.map +1 -1
  24. package/dist/mask/shader-module.js +33 -37
  25. package/dist/path-style/shaders.glsl.js +42 -47
  26. package/dist/terrain/shader-module.d.ts.map +1 -1
  27. package/dist/terrain/shader-module.js +30 -32
  28. package/dist/terrain/terrain-pass.js +2 -2
  29. package/dist/terrain/utils.js +2 -2
  30. package/dist/utils/syntax-tags.d.ts +6 -0
  31. package/dist/utils/syntax-tags.d.ts.map +1 -0
  32. package/dist/utils/syntax-tags.js +5 -0
  33. package/dist.min.js +364 -431
  34. package/package.json +8 -8
  35. package/src/brushing/shader-module.ts +4 -3
  36. package/src/clip/clip-extension.ts +10 -9
  37. package/src/collision-filter/shader-module.ts +6 -4
  38. package/src/data-filter/aggregator.ts +8 -13
  39. package/src/data-filter/data-filter-extension.ts +18 -8
  40. package/src/data-filter/shader-module.ts +7 -6
  41. package/src/fill-style/fill-style-extension.ts +1 -1
  42. package/src/fill-style/{shaders.glsl.ts → shader-module.ts} +6 -5
  43. package/src/mask/shader-module.ts +7 -6
  44. package/src/terrain/shader-module.ts +11 -10
  45. package/src/terrain/utils.ts +1 -1
  46. package/src/utils/syntax-tags.ts +5 -0
  47. package/dist/fill-style/shaders.glsl.d.ts.map +0 -1
@@ -28,8 +28,8 @@ export default class MaskPass extends LayersPass {
28
28
  const clearColor = [255, 255, 255, 255];
29
29
  return this.device.withParametersWebGL({
30
30
  blend: true,
31
- blendFunc: [GL.ZERO, GL.ONE],
32
- blendEquation: GL.FUNC_SUBTRACT,
31
+ blendFunc: [0, 1],
32
+ blendEquation: 32778,
33
33
  colorMask,
34
34
  depthTest: false
35
35
  }, () => super.render({ ...options, clearColor, target: this.fbo, pass: 'mask' }));
@@ -1 +1 @@
1
- {"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/mask/shader-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAoE3C,KAAK,kBAAkB,GAAG;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;;AAYF,wBAOsC"}
1
+ {"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/mask/shader-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAqE3C,KAAK,kBAAkB,GAAG;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;;AAYF,wBAOsC"}
@@ -1,9 +1,10 @@
1
1
  import { project } from '@deck.gl/core';
2
+ import { glsl } from "../utils/syntax-tags.js";
2
3
  const vs = `
3
4
  uniform vec4 mask_bounds;
4
5
  uniform bool mask_maskByInstance;
5
6
  vec2 mask_getCoords(vec4 position) {
6
- return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);
7
+ return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);
7
8
  }
8
9
  `;
9
10
  const fs = `
@@ -12,26 +13,25 @@ uniform int mask_channel;
12
13
  uniform bool mask_enabled;
13
14
  uniform bool mask_inverted;
14
15
  bool mask_isInBounds(vec2 texCoords) {
15
- if (!mask_enabled) {
16
- return true;
17
- }
18
- vec4 maskColor = texture(mask_texture, texCoords);
19
- float maskValue = 1.0;
20
- if (mask_channel == 0) {
21
- maskValue = maskColor.r;
22
- } else if (mask_channel == 1) {
23
- maskValue = maskColor.g;
24
- } else if (mask_channel == 2) {
25
- maskValue = maskColor.b;
26
- } else if (mask_channel == 3) {
27
- maskValue = maskColor.a;
28
- }
29
-
30
- if (mask_inverted) {
31
- return maskValue >= 0.5;
32
- } else {
33
- return maskValue < 0.5;
34
- }
16
+ if (!mask_enabled) {
17
+ return true;
18
+ }
19
+ vec4 maskColor = texture(mask_texture, texCoords);
20
+ float maskValue = 1.0;
21
+ if (mask_channel == 0) {
22
+ maskValue = maskColor.r;
23
+ } else if (mask_channel == 1) {
24
+ maskValue = maskColor.g;
25
+ } else if (mask_channel == 2) {
26
+ maskValue = maskColor.b;
27
+ } else if (mask_channel == 3) {
28
+ maskValue = maskColor.a;
29
+ }
30
+ if (mask_inverted) {
31
+ return maskValue >= 0.5;
32
+ } else {
33
+ return maskValue < 0.5;
34
+ }
35
35
  }
36
36
  `;
37
37
  const inject = {
@@ -39,27 +39,23 @@ const inject = {
39
39
  out vec2 mask_texCoords;
40
40
  `,
41
41
  'vs:#main-end': `
42
- vec4 mask_common_position;
43
- if (mask_maskByInstance) {
44
- mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
45
- } else {
46
- mask_common_position = geometry.position;
47
- }
48
- mask_texCoords = mask_getCoords(mask_common_position);
42
+ vec4 mask_common_position;
43
+ if (mask_maskByInstance) {
44
+ mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
45
+ } else {
46
+ mask_common_position = geometry.position;
47
+ }
48
+ mask_texCoords = mask_getCoords(mask_common_position);
49
49
  `,
50
50
  'fs:#decl': `
51
51
  in vec2 mask_texCoords;
52
52
  `,
53
53
  'fs:#main-start': `
54
- if (mask_enabled) {
55
- bool mask = mask_isInBounds(mask_texCoords);
56
-
57
- // Debug: show extent of render target
58
- // fragColor = vec4(mask_texCoords, 0.0, 1.0);
59
- fragColor = texture(mask_texture, mask_texCoords);
60
-
61
- if (!mask) discard;
62
- }
54
+ if (mask_enabled) {
55
+ bool mask = mask_isInBounds(mask_texCoords);
56
+ fragColor = texture(mask_texture, mask_texCoords);
57
+ if (!mask) discard;
58
+ }
63
59
  `
64
60
  };
65
61
  /* eslint-disable camelcase */
@@ -26,41 +26,36 @@ in float vDashOffset;
26
26
  // 1 - stretch to fit, draw half dash at each end for nicer joints
27
27
  // o-- ---- ---- ---- --o-- --o-- ---- --o
28
28
  'fs:#main-start': `
29
- float solidLength = vDashArray.x;
30
- float gapLength = vDashArray.y;
31
- float unitLength = solidLength + gapLength;
32
-
33
- float offset;
34
-
35
- if (unitLength > 0.0) {
36
- if (dashAlignMode == 0.0) {
37
- offset = vDashOffset;
38
- } else {
39
- unitLength = vPathLength / round(vPathLength / unitLength);
40
- offset = solidLength / 2.0;
41
- }
42
-
43
- float unitOffset = mod(vPathPosition.y + offset, unitLength);
44
-
45
- if (gapLength > 0.0 && unitOffset > solidLength) {
46
- if (capType <= 0.5) {
47
- if (!(dashGapPickable && bool(picking.isActive))) {
48
- discard;
49
- }
50
- } else {
51
- // caps are rounded, test the distance to solid ends
52
- float distToEnd = length(vec2(
53
- min(unitOffset - solidLength, unitLength - unitOffset),
54
- vPathPosition.x
55
- ));
56
- if (distToEnd > 1.0) {
57
- if (!(dashGapPickable && bool(picking.isActive))) {
58
- discard;
59
- }
60
- }
61
- }
62
- }
63
- }
29
+ float solidLength = vDashArray.x;
30
+ float gapLength = vDashArray.y;
31
+ float unitLength = solidLength + gapLength;
32
+ float offset;
33
+ if (unitLength > 0.0) {
34
+ if (dashAlignMode == 0.0) {
35
+ offset = vDashOffset;
36
+ } else {
37
+ unitLength = vPathLength / round(vPathLength / unitLength);
38
+ offset = solidLength / 2.0;
39
+ }
40
+ float unitOffset = mod(vPathPosition.y + offset, unitLength);
41
+ if (gapLength > 0.0 && unitOffset > solidLength) {
42
+ if (capType <= 0.5) {
43
+ if (!(dashGapPickable && bool(picking.isActive))) {
44
+ discard;
45
+ }
46
+ } else {
47
+ float distToEnd = length(vec2(
48
+ min(unitOffset - solidLength, unitLength - unitOffset),
49
+ vPathPosition.x
50
+ ));
51
+ if (distToEnd > 1.0) {
52
+ if (!(dashGapPickable && bool(picking.isActive))) {
53
+ discard;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
64
59
  `
65
60
  }
66
61
  };
@@ -70,22 +65,22 @@ export const offsetShaders = {
70
65
  in float instanceOffsets;
71
66
  `,
72
67
  'vs:DECKGL_FILTER_SIZE': `
73
- float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
74
- size *= offsetWidth;
68
+ float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
69
+ size *= offsetWidth;
75
70
  `,
76
71
  'vs:#main-end': `
77
- float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
78
- float offsetDir = sign(instanceOffsets);
79
- vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir;
80
- vPathPosition.y *= offsetWidth;
81
- vPathLength *= offsetWidth;
72
+ float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
73
+ float offsetDir = sign(instanceOffsets);
74
+ vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir;
75
+ vPathPosition.y *= offsetWidth;
76
+ vPathLength *= offsetWidth;
82
77
  `,
83
78
  'fs:#main-start': `
84
- float isInside;
85
- isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
86
- if (isInside == 0.0) {
87
- discard;
88
- }
79
+ float isInside;
80
+ isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
81
+ if (isInside == 0.0) {
82
+ discard;
83
+ }
89
84
  `
90
85
  }
91
86
  };
@@ -1 +1 @@
1
- {"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/terrain/shader-module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAGvD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAC,MAAM,EAAC,qCAAkC;AACtD,OAAO,KAAK,EAAC,YAAY,EAAC,2BAAwB;AAElD,8DAA8D;AAC9D,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC;IAC9B,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,YAAY;;IAEvB,6EAA6E;;IAE7E,2EAA2E;;IAE3E,6FAA6F;;IAE7F,0EAA0E;;IAE1E,mEAAmE;;CAEpE,CAAC;AAOF,eAAO,MAAM,aAAa,qCA6Hc,CAAC"}
1
+ {"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/terrain/shader-module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAGvD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAC,MAAM,EAAC,qCAAkC;AACtD,OAAO,KAAK,EAAC,YAAY,EAAC,2BAAwB;AAGlD,8DAA8D;AAC9D,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC;IAC9B,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,kDAAkD;AAClD,eAAO,MAAM,YAAY;;IAEvB,6EAA6E;;IAE7E,2EAA2E;;IAE3E,6FAA6F;;IAE7F,0EAA0E;;IAE1E,mEAAmE;;CAEpE,CAAC;AAOF,eAAO,MAAM,aAAa,qCA6Hc,CAAC"}
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable camelcase */
2
2
  import { project } from '@deck.gl/core';
3
+ import { glsl } from "../utils/syntax-tags.js";
3
4
  /** A model can have one of the following modes */
4
5
  export const TERRAIN_MODE = {
5
6
  NONE: 0,
@@ -27,59 +28,56 @@ uniform float terrain_mode;
27
28
  uniform sampler2D terrain_map;
28
29
  uniform vec4 terrain_bounds;
29
30
  out vec3 commonPos;
30
- ${TERRAIN_MODE_CONSTANTS}
31
- `,
31
+ ` + TERRAIN_MODE_CONSTANTS,
32
32
  'vs:#main-start': `
33
33
  if (terrain_mode == TERRAIN_MODE_SKIP) {
34
- gl_Position = vec4(0.0);
35
- return;
34
+ gl_Position = vec4(0.0);
35
+ return;
36
36
  }
37
37
  `,
38
38
  'vs:DECKGL_FILTER_GL_POSITION': `
39
39
  commonPos = geometry.position.xyz;
40
40
  if (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
41
- vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;
42
- position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);
43
- commonPos.z += project_uCommonOrigin.z;
41
+ vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;
42
+ position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);
43
+ commonPos.z += project_uCommonOrigin.z;
44
44
  }
45
45
  if (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
46
- vec3 anchor = geometry.worldPosition;
47
- anchor.z = 0.0;
48
- vec3 anchorCommon = project_position(anchor);
49
- vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;
50
- if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {
51
- float terrainZ = texture(terrain_map, texCoords).r;
52
- geometry.position.z += terrainZ;
53
- position = project_common_position_to_clipspace(geometry.position);
54
- }
46
+ vec3 anchor = geometry.worldPosition;
47
+ anchor.z = 0.0;
48
+ vec3 anchorCommon = project_position(anchor);
49
+ vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;
50
+ if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {
51
+ float terrainZ = texture(terrain_map, texCoords).r;
52
+ geometry.position.z += terrainZ;
53
+ position = project_common_position_to_clipspace(geometry.position);
55
54
  }
56
- `,
55
+ }
56
+ `,
57
57
  'fs:#decl': `
58
58
  uniform float terrain_mode;
59
59
  uniform sampler2D terrain_map;
60
60
  uniform vec4 terrain_bounds;
61
61
  in vec3 commonPos;
62
- ${TERRAIN_MODE_CONSTANTS}
63
- `,
62
+ ` + TERRAIN_MODE_CONSTANTS,
64
63
  'fs:#main-start': `
65
64
  if (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
66
- fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);
67
- return;
65
+ fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);
66
+ return;
68
67
  }
69
- `,
68
+ `,
70
69
  'fs:DECKGL_FILTER_COLOR': `
71
70
  if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {
72
- vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;
73
- vec4 pixel = texture(terrain_map, texCoords);
74
- if (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) {
75
- color = pixel;
76
- } else {
77
- // pixel is premultiplied
78
- color = pixel + color * (1.0 - pixel.a);
79
- }
80
- return;
71
+ vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;
72
+ vec4 pixel = texture(terrain_map, texCoords);
73
+ if (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) {
74
+ color = pixel;
75
+ } else {
76
+ color = pixel + color * (1.0 - pixel.a);
77
+ }
78
+ return;
81
79
  }
82
- `
80
+ `
83
81
  },
84
82
  // eslint-disable-next-line complexity
85
83
  getUniforms: (opts = {}, uniforms) => {
@@ -25,8 +25,8 @@ export class TerrainPass extends LayersPass {
25
25
  this.device.withParametersWebGL({
26
26
  clearColor: [0, 0, 0, 0],
27
27
  blend: true,
28
- blendFunc: [GL.ONE, GL.ONE],
29
- blendEquation: GL.MAX,
28
+ blendFunc: [1, 1],
29
+ blendEquation: 32776,
30
30
  depthTest: false
31
31
  }, () => this.render({
32
32
  ...opts,
@@ -5,8 +5,8 @@ export function createRenderTarget(device, opts) {
5
5
  colorAttachments: [
6
6
  device.createTexture({
7
7
  ...(opts.float && {
8
- format: device.info.type === 'webgl2' ? 'rgba32float' : 'rgba8unorm',
9
- type: GL.FLOAT
8
+ format: 'rgba32float',
9
+ type: 5126
10
10
  }),
11
11
  mipmaps: false,
12
12
  sampler: {
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Marks GLSL shaders for syntax highlighting: glsl`...`
3
+ * Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal
4
+ */
5
+ export declare const glsl: (s: TemplateStringsArray) => string;
6
+ //# sourceMappingURL=syntax-tags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax-tags.d.ts","sourceRoot":"","sources":["../../src/utils/syntax-tags.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,IAAI,MAAO,oBAAoB,WAAW,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Marks GLSL shaders for syntax highlighting: glsl`...`
3
+ * Install https://marketplace.visualstudio.com/items?itemName=boyswan.glsl-literal
4
+ */
5
+ export const glsl = (s) => `${s}`;