@deck.gl/extensions 8.9.3 → 8.9.5

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 (40) hide show
  1. package/dist/dist.dev.js +2 -1
  2. package/dist/es5/collision-filter/shader-module.js +1 -1
  3. package/dist/es5/collision-filter/shader-module.js.map +1 -1
  4. package/dist/esm/collision-filter/shader-module.js +1 -1
  5. package/dist/esm/collision-filter/shader-module.js.map +1 -1
  6. package/dist.min.js +2 -1
  7. package/package.json +2 -2
  8. package/src/collision-filter/shader-module.ts +2 -1
  9. package/typed/collide/collide-effect.d.ts +1 -1
  10. package/typed/collide/collide-effect.d.ts.map +1 -1
  11. package/typed/collide/collide-pass.d.ts +1 -0
  12. package/typed/collide/collide-pass.d.ts.map +1 -1
  13. package/typed/collide/collide.d.ts +1 -0
  14. package/typed/collide/collide.d.ts.map +1 -1
  15. package/typed/collide/shader-module.d.ts.map +1 -1
  16. package/typed/collision-filter/shader-module.d.ts.map +1 -1
  17. package/typed/effect-order.d.ts +6 -0
  18. package/typed/effect-order.d.ts.map +1 -0
  19. package/typed/brushing/brushing.js +0 -83
  20. package/typed/brushing/shader-module.js +0 -116
  21. package/typed/clip/clip.js +0 -114
  22. package/typed/data-filter/aggregator.js +0 -98
  23. package/typed/data-filter/data-filter.js +0 -159
  24. package/typed/data-filter/shader-module.js +0 -152
  25. package/typed/fill-style/fill-style.js +0 -152
  26. package/typed/fill-style/shaders.glsl.js +0 -95
  27. package/typed/fp64/fp64.js +0 -34
  28. package/typed/fp64/project64.glsl.js +0 -100
  29. package/typed/fp64/project64.js +0 -50
  30. package/typed/index.js +0 -9
  31. package/typed/mask/mask.js +0 -48
  32. package/typed/mask/shader-module.js +0 -73
  33. package/typed/path-style/path-style.js +0 -107
  34. package/typed/path-style/shaders.glsl.js +0 -93
  35. package/typed/terrain/height-map.d.ts +0 -27
  36. package/typed/terrain/height-map.d.ts.map +0 -1
  37. package/typed/terrain/shader-module-offset.d.ts +0 -4
  38. package/typed/terrain/shader-module-offset.d.ts.map +0 -1
  39. package/typed/terrain/shader-module-source.d.ts +0 -4
  40. package/typed/terrain/shader-module-source.d.ts.map +0 -1
package/dist/dist.dev.js CHANGED
@@ -2201,7 +2201,8 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
2201
2201
  vec2 collision_texCoords = collision_getCoords(collision_common_position);
2202
2202
  collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);
2203
2203
  if (collision_fade < 0.0001) {
2204
- position = vec4(0.);
2204
+ // Position outside clip space bounds to discard
2205
+ position = vec4(0.0, 0.0, 2.0, 1.0);
2205
2206
  }
2206
2207
  }
2207
2208
  `,
@@ -10,7 +10,7 @@ var _core = require("@deck.gl/core");
10
10
  var vs = "\n#ifdef NON_INSTANCED_MODEL\nattribute float collisionPriorities;\n#else\nattribute float instanceCollisionPriorities;\n#endif\n\nuniform sampler2D collision_texture;\nuniform bool collision_sort;\nuniform bool collision_enabled;\n\nvec2 collision_getCoords(vec4 position) {\n vec4 collision_clipspace = project_common_position_to_clipspace(position);\n return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;\n}\n\nfloat collision_match(vec2 tex, vec3 pickingColor) {\n vec4 collision_pickingColor = texture2D(collision_texture, tex);\n float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));\n float e = 0.001;\n return step(delta, e);\n}\n\nfloat collision_isVisible(vec2 texCoords, vec3 pickingColor) {\n if (!collision_enabled) {\n return 1.0;\n }\n\n // Visibility test, sample area of 5x5 pixels in order to fade in/out.\n // Due to the locality, the lookups will be cached\n // This reduces the flicker present when objects are shown/hidden\n const int N = 2;\n float accumulator = 0.0;\n vec2 step = vec2(1.0 / project_uViewportSize);\n\n const float floatN = float(N);\n vec2 delta = -floatN * step;\n for(int i = -N; i <= N; i++) {\n delta.x = -step.x * floatN;\n for(int j = -N; j <= N; j++) {\n accumulator += collision_match(texCoords + delta, pickingColor);\n delta.x += step.x;\n }\n delta.y += step.y;\n }\n\n float W = 2.0 * floatN + 1.0;\n return pow(accumulator / (W * W), 2.2);\n}\n";
11
11
  var inject = {
12
12
  'vs:#decl': "\n float collision_fade = 1.0;\n",
13
- 'vs:DECKGL_FILTER_GL_POSITION': "\n if (collision_sort) {\n #ifdef NON_INSTANCED_MODEL\n float collisionPriority = collisionPriorities;\n #else\n float collisionPriority = instanceCollisionPriorities;\n #endif\n position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000\n }\n\n if (collision_enabled) {\n vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n vec2 collision_texCoords = collision_getCoords(collision_common_position);\n collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);\n if (collision_fade < 0.0001) {\n position = vec4(0.);\n }\n }\n ",
13
+ 'vs:DECKGL_FILTER_GL_POSITION': "\n if (collision_sort) {\n #ifdef NON_INSTANCED_MODEL\n float collisionPriority = collisionPriorities;\n #else\n float collisionPriority = instanceCollisionPriorities;\n #endif\n position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000\n }\n\n if (collision_enabled) {\n vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n vec2 collision_texCoords = collision_getCoords(collision_common_position);\n collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);\n if (collision_fade < 0.0001) {\n // Position outside clip space bounds to discard\n position = vec4(0.0, 0.0, 2.0, 1.0);\n }\n }\n ",
14
14
  'vs:DECKGL_FILTER_COLOR': "\n color.a *= collision_fade;\n "
15
15
  };
16
16
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collision-filter/shader-module.ts"],"names":["vs","inject","getCollisionUniforms","opts","uniforms","collisionFBO","drawToCollisionMap","dummyCollisionMap","collision_sort","Boolean","collision_texture","name","dependencies","project","getUniforms"],"mappings":";;;;;;;AACA;;AAGA,IAAMA,EAAE,i9CAAR;AAmDA,IAAMC,MAAM,GAAG;AACb,iDADa;AAIb,2rBAJa;AAuBb;AAvBa,CAAf;;AAqCA,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,CAC3BC,IAD2B,EAE3BC,QAF2B,EAGL;AACtB,MAAI,CAACD,IAAD,IAAS,EAAE,uBAAuBA,IAAzB,CAAb,EAA6C;AAC3C,WAAO,EAAP;AACD;;AACD,MAAOE,YAAP,GAA8DF,IAA9D,CAAOE,YAAP;AAAA,MAAqBC,kBAArB,GAA8DH,IAA9D,CAAqBG,kBAArB;AAAA,MAAyCC,iBAAzC,GAA8DJ,IAA9D,CAAyCI,iBAAzC;AACA,SAAO;AACLC,IAAAA,cAAc,EAAEC,OAAO,CAACH,kBAAD,CADlB;AAELI,IAAAA,iBAAiB,EAAE,CAACJ,kBAAD,IAAuBD,YAAvB,GAAsCA,YAAtC,GAAqDE;AAFnE,GAAP;AAID,CAZD;;eAce;AACbI,EAAAA,IAAI,EAAE,WADO;AAEbC,EAAAA,YAAY,EAAE,CAACC,aAAD,CAFD;AAGbb,EAAAA,EAAE,EAAFA,EAHa;AAIbC,EAAAA,MAAM,EAANA,MAJa;AAKba,EAAAA,WAAW,EAAEZ;AALA,C","sourcesContent":["import {Framebuffer, Texture2D} from '@luma.gl/core';\nimport {project} from '@deck.gl/core';\nimport type {_ShaderModule as ShaderModule} from '@deck.gl/core';\n\nconst vs = `\n#ifdef NON_INSTANCED_MODEL\nattribute float collisionPriorities;\n#else\nattribute float instanceCollisionPriorities;\n#endif\n\nuniform sampler2D collision_texture;\nuniform bool collision_sort;\nuniform bool collision_enabled;\n\nvec2 collision_getCoords(vec4 position) {\n vec4 collision_clipspace = project_common_position_to_clipspace(position);\n return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;\n}\n\nfloat collision_match(vec2 tex, vec3 pickingColor) {\n vec4 collision_pickingColor = texture2D(collision_texture, tex);\n float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));\n float e = 0.001;\n return step(delta, e);\n}\n\nfloat collision_isVisible(vec2 texCoords, vec3 pickingColor) {\n if (!collision_enabled) {\n return 1.0;\n }\n\n // Visibility test, sample area of 5x5 pixels in order to fade in/out.\n // Due to the locality, the lookups will be cached\n // This reduces the flicker present when objects are shown/hidden\n const int N = 2;\n float accumulator = 0.0;\n vec2 step = vec2(1.0 / project_uViewportSize);\n\n const float floatN = float(N);\n vec2 delta = -floatN * step;\n for(int i = -N; i <= N; i++) {\n delta.x = -step.x * floatN;\n for(int j = -N; j <= N; j++) {\n accumulator += collision_match(texCoords + delta, pickingColor);\n delta.x += step.x;\n }\n delta.y += step.y;\n }\n\n float W = 2.0 * floatN + 1.0;\n return pow(accumulator / (W * W), 2.2);\n}\n`;\n\nconst inject = {\n 'vs:#decl': `\n float collision_fade = 1.0;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n if (collision_sort) {\n #ifdef NON_INSTANCED_MODEL\n float collisionPriority = collisionPriorities;\n #else\n float collisionPriority = instanceCollisionPriorities;\n #endif\n position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000\n }\n\n if (collision_enabled) {\n vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n vec2 collision_texCoords = collision_getCoords(collision_common_position);\n collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);\n if (collision_fade < 0.0001) {\n position = vec4(0.);\n }\n }\n `,\n 'vs:DECKGL_FILTER_COLOR': `\n color.a *= collision_fade;\n `\n};\n\ntype CollisionModuleSettings = {\n collisionFBO?: Framebuffer;\n drawToCollisionMap?: boolean;\n dummyCollisionMap?: Texture2D;\n};\n\n/* eslint-disable camelcase */\ntype CollisionUniforms = {collision_sort?: boolean; collision_texture?: Framebuffer | Texture2D};\n\nconst getCollisionUniforms = (\n opts: CollisionModuleSettings | {},\n uniforms: Record<string, any>\n): CollisionUniforms => {\n if (!opts || !('dummyCollisionMap' in opts)) {\n return {};\n }\n const {collisionFBO, drawToCollisionMap, dummyCollisionMap} = opts;\n return {\n collision_sort: Boolean(drawToCollisionMap),\n collision_texture: !drawToCollisionMap && collisionFBO ? collisionFBO : dummyCollisionMap\n };\n};\n\nexport default {\n name: 'collision',\n dependencies: [project],\n vs,\n inject,\n getUniforms: getCollisionUniforms\n} as ShaderModule;\n"],"file":"shader-module.js"}
1
+ {"version":3,"sources":["../../../src/collision-filter/shader-module.ts"],"names":["vs","inject","getCollisionUniforms","opts","uniforms","collisionFBO","drawToCollisionMap","dummyCollisionMap","collision_sort","Boolean","collision_texture","name","dependencies","project","getUniforms"],"mappings":";;;;;;;AACA;;AAGA,IAAMA,EAAE,i9CAAR;AAmDA,IAAMC,MAAM,GAAG;AACb,iDADa;AAIb,mwBAJa;AAwBb;AAxBa,CAAf;;AAsCA,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,CAC3BC,IAD2B,EAE3BC,QAF2B,EAGL;AACtB,MAAI,CAACD,IAAD,IAAS,EAAE,uBAAuBA,IAAzB,CAAb,EAA6C;AAC3C,WAAO,EAAP;AACD;;AACD,MAAOE,YAAP,GAA8DF,IAA9D,CAAOE,YAAP;AAAA,MAAqBC,kBAArB,GAA8DH,IAA9D,CAAqBG,kBAArB;AAAA,MAAyCC,iBAAzC,GAA8DJ,IAA9D,CAAyCI,iBAAzC;AACA,SAAO;AACLC,IAAAA,cAAc,EAAEC,OAAO,CAACH,kBAAD,CADlB;AAELI,IAAAA,iBAAiB,EAAE,CAACJ,kBAAD,IAAuBD,YAAvB,GAAsCA,YAAtC,GAAqDE;AAFnE,GAAP;AAID,CAZD;;eAce;AACbI,EAAAA,IAAI,EAAE,WADO;AAEbC,EAAAA,YAAY,EAAE,CAACC,aAAD,CAFD;AAGbb,EAAAA,EAAE,EAAFA,EAHa;AAIbC,EAAAA,MAAM,EAANA,MAJa;AAKba,EAAAA,WAAW,EAAEZ;AALA,C","sourcesContent":["import {Framebuffer, Texture2D} from '@luma.gl/core';\nimport {project} from '@deck.gl/core';\nimport type {_ShaderModule as ShaderModule} from '@deck.gl/core';\n\nconst vs = `\n#ifdef NON_INSTANCED_MODEL\nattribute float collisionPriorities;\n#else\nattribute float instanceCollisionPriorities;\n#endif\n\nuniform sampler2D collision_texture;\nuniform bool collision_sort;\nuniform bool collision_enabled;\n\nvec2 collision_getCoords(vec4 position) {\n vec4 collision_clipspace = project_common_position_to_clipspace(position);\n return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;\n}\n\nfloat collision_match(vec2 tex, vec3 pickingColor) {\n vec4 collision_pickingColor = texture2D(collision_texture, tex);\n float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));\n float e = 0.001;\n return step(delta, e);\n}\n\nfloat collision_isVisible(vec2 texCoords, vec3 pickingColor) {\n if (!collision_enabled) {\n return 1.0;\n }\n\n // Visibility test, sample area of 5x5 pixels in order to fade in/out.\n // Due to the locality, the lookups will be cached\n // This reduces the flicker present when objects are shown/hidden\n const int N = 2;\n float accumulator = 0.0;\n vec2 step = vec2(1.0 / project_uViewportSize);\n\n const float floatN = float(N);\n vec2 delta = -floatN * step;\n for(int i = -N; i <= N; i++) {\n delta.x = -step.x * floatN;\n for(int j = -N; j <= N; j++) {\n accumulator += collision_match(texCoords + delta, pickingColor);\n delta.x += step.x;\n }\n delta.y += step.y;\n }\n\n float W = 2.0 * floatN + 1.0;\n return pow(accumulator / (W * W), 2.2);\n}\n`;\n\nconst inject = {\n 'vs:#decl': `\n float collision_fade = 1.0;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n if (collision_sort) {\n #ifdef NON_INSTANCED_MODEL\n float collisionPriority = collisionPriorities;\n #else\n float collisionPriority = instanceCollisionPriorities;\n #endif\n position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000\n }\n\n if (collision_enabled) {\n vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n vec2 collision_texCoords = collision_getCoords(collision_common_position);\n collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);\n if (collision_fade < 0.0001) {\n // Position outside clip space bounds to discard\n position = vec4(0.0, 0.0, 2.0, 1.0);\n }\n }\n `,\n 'vs:DECKGL_FILTER_COLOR': `\n color.a *= collision_fade;\n `\n};\n\ntype CollisionModuleSettings = {\n collisionFBO?: Framebuffer;\n drawToCollisionMap?: boolean;\n dummyCollisionMap?: Texture2D;\n};\n\n/* eslint-disable camelcase */\ntype CollisionUniforms = {collision_sort?: boolean; collision_texture?: Framebuffer | Texture2D};\n\nconst getCollisionUniforms = (\n opts: CollisionModuleSettings | {},\n uniforms: Record<string, any>\n): CollisionUniforms => {\n if (!opts || !('dummyCollisionMap' in opts)) {\n return {};\n }\n const {collisionFBO, drawToCollisionMap, dummyCollisionMap} = opts;\n return {\n collision_sort: Boolean(drawToCollisionMap),\n collision_texture: !drawToCollisionMap && collisionFBO ? collisionFBO : dummyCollisionMap\n };\n};\n\nexport default {\n name: 'collision',\n dependencies: [project],\n vs,\n inject,\n getUniforms: getCollisionUniforms\n} as ShaderModule;\n"],"file":"shader-module.js"}
@@ -2,7 +2,7 @@ import { project } from '@deck.gl/core';
2
2
  const vs = "\n#ifdef NON_INSTANCED_MODEL\nattribute float collisionPriorities;\n#else\nattribute float instanceCollisionPriorities;\n#endif\n\nuniform sampler2D collision_texture;\nuniform bool collision_sort;\nuniform bool collision_enabled;\n\nvec2 collision_getCoords(vec4 position) {\n vec4 collision_clipspace = project_common_position_to_clipspace(position);\n return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;\n}\n\nfloat collision_match(vec2 tex, vec3 pickingColor) {\n vec4 collision_pickingColor = texture2D(collision_texture, tex);\n float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));\n float e = 0.001;\n return step(delta, e);\n}\n\nfloat collision_isVisible(vec2 texCoords, vec3 pickingColor) {\n if (!collision_enabled) {\n return 1.0;\n }\n\n // Visibility test, sample area of 5x5 pixels in order to fade in/out.\n // Due to the locality, the lookups will be cached\n // This reduces the flicker present when objects are shown/hidden\n const int N = 2;\n float accumulator = 0.0;\n vec2 step = vec2(1.0 / project_uViewportSize);\n\n const float floatN = float(N);\n vec2 delta = -floatN * step;\n for(int i = -N; i <= N; i++) {\n delta.x = -step.x * floatN;\n for(int j = -N; j <= N; j++) {\n accumulator += collision_match(texCoords + delta, pickingColor);\n delta.x += step.x;\n }\n delta.y += step.y;\n }\n\n float W = 2.0 * floatN + 1.0;\n return pow(accumulator / (W * W), 2.2);\n}\n";
3
3
  const inject = {
4
4
  'vs:#decl': "\n float collision_fade = 1.0;\n",
5
- 'vs:DECKGL_FILTER_GL_POSITION': "\n if (collision_sort) {\n #ifdef NON_INSTANCED_MODEL\n float collisionPriority = collisionPriorities;\n #else\n float collisionPriority = instanceCollisionPriorities;\n #endif\n position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000\n }\n\n if (collision_enabled) {\n vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n vec2 collision_texCoords = collision_getCoords(collision_common_position);\n collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);\n if (collision_fade < 0.0001) {\n position = vec4(0.);\n }\n }\n ",
5
+ 'vs:DECKGL_FILTER_GL_POSITION': "\n if (collision_sort) {\n #ifdef NON_INSTANCED_MODEL\n float collisionPriority = collisionPriorities;\n #else\n float collisionPriority = instanceCollisionPriorities;\n #endif\n position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000\n }\n\n if (collision_enabled) {\n vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n vec2 collision_texCoords = collision_getCoords(collision_common_position);\n collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);\n if (collision_fade < 0.0001) {\n // Position outside clip space bounds to discard\n position = vec4(0.0, 0.0, 2.0, 1.0);\n }\n }\n ",
6
6
  'vs:DECKGL_FILTER_COLOR': "\n color.a *= collision_fade;\n "
7
7
  };
8
8
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collision-filter/shader-module.ts"],"names":["project","vs","inject","getCollisionUniforms","opts","uniforms","collisionFBO","drawToCollisionMap","dummyCollisionMap","collision_sort","Boolean","collision_texture","name","dependencies","getUniforms"],"mappings":"AACA,SAAQA,OAAR,QAAsB,eAAtB;AAGA,MAAMC,EAAE,i9CAAR;AAmDA,MAAMC,MAAM,GAAG;AACb,iDADa;AAIb,2rBAJa;AAuBb;AAvBa,CAAf;;AAqCA,MAAMC,oBAAoB,GAAG,CAC3BC,IAD2B,EAE3BC,QAF2B,KAGL;AACtB,MAAI,CAACD,IAAD,IAAS,EAAE,uBAAuBA,IAAzB,CAAb,EAA6C;AAC3C,WAAO,EAAP;AACD;;AACD,QAAM;AAACE,IAAAA,YAAD;AAAeC,IAAAA,kBAAf;AAAmCC,IAAAA;AAAnC,MAAwDJ,IAA9D;AACA,SAAO;AACLK,IAAAA,cAAc,EAAEC,OAAO,CAACH,kBAAD,CADlB;AAELI,IAAAA,iBAAiB,EAAE,CAACJ,kBAAD,IAAuBD,YAAvB,GAAsCA,YAAtC,GAAqDE;AAFnE,GAAP;AAID,CAZD;;AAcA,eAAe;AACbI,EAAAA,IAAI,EAAE,WADO;AAEbC,EAAAA,YAAY,EAAE,CAACb,OAAD,CAFD;AAGbC,EAAAA,EAHa;AAIbC,EAAAA,MAJa;AAKbY,EAAAA,WAAW,EAAEX;AALA,CAAf","sourcesContent":["import {Framebuffer, Texture2D} from '@luma.gl/core';\nimport {project} from '@deck.gl/core';\nimport type {_ShaderModule as ShaderModule} from '@deck.gl/core';\n\nconst vs = `\n#ifdef NON_INSTANCED_MODEL\nattribute float collisionPriorities;\n#else\nattribute float instanceCollisionPriorities;\n#endif\n\nuniform sampler2D collision_texture;\nuniform bool collision_sort;\nuniform bool collision_enabled;\n\nvec2 collision_getCoords(vec4 position) {\n vec4 collision_clipspace = project_common_position_to_clipspace(position);\n return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;\n}\n\nfloat collision_match(vec2 tex, vec3 pickingColor) {\n vec4 collision_pickingColor = texture2D(collision_texture, tex);\n float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));\n float e = 0.001;\n return step(delta, e);\n}\n\nfloat collision_isVisible(vec2 texCoords, vec3 pickingColor) {\n if (!collision_enabled) {\n return 1.0;\n }\n\n // Visibility test, sample area of 5x5 pixels in order to fade in/out.\n // Due to the locality, the lookups will be cached\n // This reduces the flicker present when objects are shown/hidden\n const int N = 2;\n float accumulator = 0.0;\n vec2 step = vec2(1.0 / project_uViewportSize);\n\n const float floatN = float(N);\n vec2 delta = -floatN * step;\n for(int i = -N; i <= N; i++) {\n delta.x = -step.x * floatN;\n for(int j = -N; j <= N; j++) {\n accumulator += collision_match(texCoords + delta, pickingColor);\n delta.x += step.x;\n }\n delta.y += step.y;\n }\n\n float W = 2.0 * floatN + 1.0;\n return pow(accumulator / (W * W), 2.2);\n}\n`;\n\nconst inject = {\n 'vs:#decl': `\n float collision_fade = 1.0;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n if (collision_sort) {\n #ifdef NON_INSTANCED_MODEL\n float collisionPriority = collisionPriorities;\n #else\n float collisionPriority = instanceCollisionPriorities;\n #endif\n position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000\n }\n\n if (collision_enabled) {\n vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n vec2 collision_texCoords = collision_getCoords(collision_common_position);\n collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);\n if (collision_fade < 0.0001) {\n position = vec4(0.);\n }\n }\n `,\n 'vs:DECKGL_FILTER_COLOR': `\n color.a *= collision_fade;\n `\n};\n\ntype CollisionModuleSettings = {\n collisionFBO?: Framebuffer;\n drawToCollisionMap?: boolean;\n dummyCollisionMap?: Texture2D;\n};\n\n/* eslint-disable camelcase */\ntype CollisionUniforms = {collision_sort?: boolean; collision_texture?: Framebuffer | Texture2D};\n\nconst getCollisionUniforms = (\n opts: CollisionModuleSettings | {},\n uniforms: Record<string, any>\n): CollisionUniforms => {\n if (!opts || !('dummyCollisionMap' in opts)) {\n return {};\n }\n const {collisionFBO, drawToCollisionMap, dummyCollisionMap} = opts;\n return {\n collision_sort: Boolean(drawToCollisionMap),\n collision_texture: !drawToCollisionMap && collisionFBO ? collisionFBO : dummyCollisionMap\n };\n};\n\nexport default {\n name: 'collision',\n dependencies: [project],\n vs,\n inject,\n getUniforms: getCollisionUniforms\n} as ShaderModule;\n"],"file":"shader-module.js"}
1
+ {"version":3,"sources":["../../../src/collision-filter/shader-module.ts"],"names":["project","vs","inject","getCollisionUniforms","opts","uniforms","collisionFBO","drawToCollisionMap","dummyCollisionMap","collision_sort","Boolean","collision_texture","name","dependencies","getUniforms"],"mappings":"AACA,SAAQA,OAAR,QAAsB,eAAtB;AAGA,MAAMC,EAAE,i9CAAR;AAmDA,MAAMC,MAAM,GAAG;AACb,iDADa;AAIb,mwBAJa;AAwBb;AAxBa,CAAf;;AAsCA,MAAMC,oBAAoB,GAAG,CAC3BC,IAD2B,EAE3BC,QAF2B,KAGL;AACtB,MAAI,CAACD,IAAD,IAAS,EAAE,uBAAuBA,IAAzB,CAAb,EAA6C;AAC3C,WAAO,EAAP;AACD;;AACD,QAAM;AAACE,IAAAA,YAAD;AAAeC,IAAAA,kBAAf;AAAmCC,IAAAA;AAAnC,MAAwDJ,IAA9D;AACA,SAAO;AACLK,IAAAA,cAAc,EAAEC,OAAO,CAACH,kBAAD,CADlB;AAELI,IAAAA,iBAAiB,EAAE,CAACJ,kBAAD,IAAuBD,YAAvB,GAAsCA,YAAtC,GAAqDE;AAFnE,GAAP;AAID,CAZD;;AAcA,eAAe;AACbI,EAAAA,IAAI,EAAE,WADO;AAEbC,EAAAA,YAAY,EAAE,CAACb,OAAD,CAFD;AAGbC,EAAAA,EAHa;AAIbC,EAAAA,MAJa;AAKbY,EAAAA,WAAW,EAAEX;AALA,CAAf","sourcesContent":["import {Framebuffer, Texture2D} from '@luma.gl/core';\nimport {project} from '@deck.gl/core';\nimport type {_ShaderModule as ShaderModule} from '@deck.gl/core';\n\nconst vs = `\n#ifdef NON_INSTANCED_MODEL\nattribute float collisionPriorities;\n#else\nattribute float instanceCollisionPriorities;\n#endif\n\nuniform sampler2D collision_texture;\nuniform bool collision_sort;\nuniform bool collision_enabled;\n\nvec2 collision_getCoords(vec4 position) {\n vec4 collision_clipspace = project_common_position_to_clipspace(position);\n return (1.0 + collision_clipspace.xy / collision_clipspace.w) / 2.0;\n}\n\nfloat collision_match(vec2 tex, vec3 pickingColor) {\n vec4 collision_pickingColor = texture2D(collision_texture, tex);\n float delta = dot(abs(collision_pickingColor.rgb - pickingColor), vec3(1.0));\n float e = 0.001;\n return step(delta, e);\n}\n\nfloat collision_isVisible(vec2 texCoords, vec3 pickingColor) {\n if (!collision_enabled) {\n return 1.0;\n }\n\n // Visibility test, sample area of 5x5 pixels in order to fade in/out.\n // Due to the locality, the lookups will be cached\n // This reduces the flicker present when objects are shown/hidden\n const int N = 2;\n float accumulator = 0.0;\n vec2 step = vec2(1.0 / project_uViewportSize);\n\n const float floatN = float(N);\n vec2 delta = -floatN * step;\n for(int i = -N; i <= N; i++) {\n delta.x = -step.x * floatN;\n for(int j = -N; j <= N; j++) {\n accumulator += collision_match(texCoords + delta, pickingColor);\n delta.x += step.x;\n }\n delta.y += step.y;\n }\n\n float W = 2.0 * floatN + 1.0;\n return pow(accumulator / (W * W), 2.2);\n}\n`;\n\nconst inject = {\n 'vs:#decl': `\n float collision_fade = 1.0;\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\n if (collision_sort) {\n #ifdef NON_INSTANCED_MODEL\n float collisionPriority = collisionPriorities;\n #else\n float collisionPriority = instanceCollisionPriorities;\n #endif\n position.z = -0.001 * collisionPriority * position.w; // Support range -1000 -> 1000\n }\n\n if (collision_enabled) {\n vec4 collision_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n vec2 collision_texCoords = collision_getCoords(collision_common_position);\n collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);\n if (collision_fade < 0.0001) {\n // Position outside clip space bounds to discard\n position = vec4(0.0, 0.0, 2.0, 1.0);\n }\n }\n `,\n 'vs:DECKGL_FILTER_COLOR': `\n color.a *= collision_fade;\n `\n};\n\ntype CollisionModuleSettings = {\n collisionFBO?: Framebuffer;\n drawToCollisionMap?: boolean;\n dummyCollisionMap?: Texture2D;\n};\n\n/* eslint-disable camelcase */\ntype CollisionUniforms = {collision_sort?: boolean; collision_texture?: Framebuffer | Texture2D};\n\nconst getCollisionUniforms = (\n opts: CollisionModuleSettings | {},\n uniforms: Record<string, any>\n): CollisionUniforms => {\n if (!opts || !('dummyCollisionMap' in opts)) {\n return {};\n }\n const {collisionFBO, drawToCollisionMap, dummyCollisionMap} = opts;\n return {\n collision_sort: Boolean(drawToCollisionMap),\n collision_texture: !drawToCollisionMap && collisionFBO ? collisionFBO : dummyCollisionMap\n };\n};\n\nexport default {\n name: 'collision',\n dependencies: [project],\n vs,\n inject,\n getUniforms: getCollisionUniforms\n} as ShaderModule;\n"],"file":"shader-module.js"}
package/dist.min.js CHANGED
@@ -1242,7 +1242,8 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
1242
1242
  vec2 collision_texCoords = collision_getCoords(collision_common_position);
1243
1243
  collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);
1244
1244
  if (collision_fade < 0.0001) {
1245
- position = vec4(0.);
1245
+ // Position outside clip space bounds to discard
1246
+ position = vec4(0.0, 0.0, 2.0, 1.0);
1246
1247
  }
1247
1248
  }
1248
1249
  `,"vs:DECKGL_FILTER_COLOR":`
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@deck.gl/extensions",
3
3
  "description": "Plug-and-play functionalities for deck.gl layers",
4
4
  "license": "MIT",
5
- "version": "8.9.3",
5
+ "version": "8.9.5",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -40,5 +40,5 @@
40
40
  "@math.gl/web-mercator": "^3.6.2",
41
41
  "gl-matrix": "^3.0.0"
42
42
  },
43
- "gitHead": "6f194255993e10898d6bd01ea38935385d222dd4"
43
+ "gitHead": "001fc31bd3dfa02eb4a0caba299584952f2236f6"
44
44
  }
@@ -72,7 +72,8 @@ const inject = {
72
72
  vec2 collision_texCoords = collision_getCoords(collision_common_position);
73
73
  collision_fade = collision_isVisible(collision_texCoords, geometry.pickingColor / 255.0);
74
74
  if (collision_fade < 0.0001) {
75
- position = vec4(0.);
75
+ // Position outside clip space bounds to discard
76
+ position = vec4(0.0, 0.0, 2.0, 1.0);
76
77
  }
77
78
  }
78
79
  `,
@@ -10,7 +10,7 @@ export default class CollideEffect implements Effect {
10
10
  private collideFBOs;
11
11
  private dummyCollideMap?;
12
12
  private lastViewport?;
13
- preRender(gl: WebGLRenderingContext, { effects: allEffects, layers, layerFilter, viewports, onViewportActive, views, isPicking, preRenderStats }: PreRenderOptions): void;
13
+ preRender(gl: WebGLRenderingContext, { effects: allEffects, layers, layerFilter, viewports, onViewportActive, views, pass, preRenderStats }: PreRenderOptions): void;
14
14
  private _render;
15
15
  /**
16
16
  * Group layers by collideGroup
@@ -1 +1 @@
1
- {"version":3,"file":"collide-effect.d.ts","sourceRoot":"","sources":["../../src/collide/collide-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAgB,SAAS,EAAmB,MAAM,eAAe,CAAC;AAGrF,OAAO,KAAK,EAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAW,MAAM,eAAe,CAAC;AAoB7E,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,MAAM;IAClD,EAAE,SAAoB;IACtB,KAAK,OAAQ;IACb,YAAY,UAAQ;IACpB,KAAK,SAAK;IAEV,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,eAAe,CAAC,CAAY;IACpC,OAAO,CAAC,YAAY,CAAC,CAAW;IAEhC,SAAS,CACP,EAAE,EAAE,qBAAqB,EACzB,EACE,OAAO,EAAE,UAAU,EACnB,MAAM,EACN,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,SAAS,EACT,cAAmB,EACpB,EAAE,gBAAgB,GAClB,IAAI;IAuDP,OAAO,CAAC,OAAO;IA0Df;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAsC5B,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG;QACjC,UAAU,EAAE,WAAW,CAAC;QACxB,eAAe,EAAE,SAAS,CAAC;KAC5B;IAMD,OAAO,IAAI,IAAI;IAaf,SAAS,CAAC,EAAE,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM;IAyBzD,UAAU,CAAC,YAAY,EAAE,MAAM;CAQhC"}
1
+ {"version":3,"file":"collide-effect.d.ts","sourceRoot":"","sources":["../../src/collide/collide-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAgB,SAAS,EAAmB,MAAM,eAAe,CAAC;AAGrF,OAAO,KAAK,EAAC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAW,MAAM,eAAe,CAAC;AAoB7E,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,MAAM;IAClD,EAAE,SAAoB;IACtB,KAAK,OAAQ;IACb,YAAY,UAAQ;IACpB,KAAK,SAAK;IAEV,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,WAAW,CAAmC;IACtD,OAAO,CAAC,eAAe,CAAC,CAAY;IACpC,OAAO,CAAC,YAAY,CAAC,CAAW;IAEhC,SAAS,CACP,EAAE,EAAE,qBAAqB,EACzB,EACE,OAAO,EAAE,UAAU,EACnB,MAAM,EACN,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,IAAI,EACJ,cAAmB,EACpB,EAAE,gBAAgB,GAClB,IAAI;IAuDP,OAAO,CAAC,OAAO;IAyDf;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAsC5B,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG;QACjC,UAAU,EAAE,WAAW,CAAC;QACxB,eAAe,EAAE,SAAS,CAAC;KAC5B;IAMD,OAAO,IAAI,IAAI;IAaf,SAAS,CAAC,EAAE,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM;IAyBzD,UAAU,CAAC,YAAY,EAAE,MAAM;CAQhC"}
@@ -3,6 +3,7 @@ import { _LayersPass as LayersPass, LayersPassRenderOptions } from '@deck.gl/cor
3
3
  declare type CollidePassRenderOptions = LayersPassRenderOptions & {};
4
4
  export default class CollidePass extends LayersPass {
5
5
  renderCollideMap(target: Framebuffer, options: CollidePassRenderOptions): any;
6
+ shouldDrawLayer(layer: any): any;
6
7
  getModuleParameters(): {
7
8
  drawToCollideMap: boolean;
8
9
  pickingActive: number;
@@ -1 +1 @@
1
- {"version":3,"file":"collide-pass.d.ts","sourceRoot":"","sources":["../../src/collide/collide-pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAiB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,WAAW,IAAI,UAAU,EAAE,uBAAuB,EAAC,MAAM,eAAe,CAAC;AAEjF,aAAK,wBAAwB,GAAG,uBAAuB,GAAG,EAAE,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAwB;IAmBvE,mBAAmB;;;;;;CASpB"}
1
+ {"version":3,"file":"collide-pass.d.ts","sourceRoot":"","sources":["../../src/collide/collide-pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAiB,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAC,WAAW,IAAI,UAAU,EAAE,uBAAuB,EAAC,MAAM,eAAe,CAAC;AAEjF,aAAK,wBAAwB,GAAG,uBAAuB,GAAG,EAAE,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,UAAU;IACjD,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,wBAAwB;IAqBvE,eAAe,CAAC,KAAK,KAAA;IAQrB,mBAAmB;;;;;;CASpB"}
@@ -33,6 +33,7 @@ export default class CollideExtension extends LayerExtension {
33
33
  collideTestProps: {};
34
34
  };
35
35
  static extensionName: string;
36
+ isEnabled(layer: Layer<CollideExtensionProps>): boolean;
36
37
  getShaders(this: Layer<CollideExtensionProps>): any;
37
38
  draw(this: Layer<CollideExtensionProps>, { uniforms, context, moduleParameters }: any): void;
38
39
  initializeState(this: Layer<CollideExtensionProps>, context: LayerContext, extension: this): void;
@@ -1 +1 @@
1
- {"version":3,"file":"collide.d.ts","sourceRoot":"","sources":["../../src/collide/collide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAW5E,oBAAY,qBAAqB,CAAC,KAAK,GAAG,GAAG,IAAI;IAC/C;;OAEG;IACH,kBAAkB,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE7C;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,EAAE,CAAC;CACvB,CAAC;AAEF,iDAAiD;AACjD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,MAAM,CAAC,YAAY;;;;;;;;;;;MAAgB;IACnC,MAAM,CAAC,aAAa,SAAsB;IAE1C,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,GAAG,GAAG;IAKnD,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAC,EAAE,GAAG;IAanF,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI;IAkB1F,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,GAAG,OAAO;CAGnE"}
1
+ {"version":3,"file":"collide.d.ts","sourceRoot":"","sources":["../../src/collide/collide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,cAAc,EAAC,MAAM,eAAe,CAAC;AAW5E,oBAAY,qBAAqB,CAAC,KAAK,GAAG,GAAG,IAAI;IAC/C;;OAEG;IACH,kBAAkB,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAE7C;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,gBAAgB,CAAC,EAAE,EAAE,CAAC;CACvB,CAAC;AAEF,iDAAiD;AACjD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,MAAM,CAAC,YAAY;;;;;;;;;;;MAAgB;IACnC,MAAM,CAAC,aAAa,SAAsB;IAE1C,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,qBAAqB,CAAC,GAAG,OAAO;IAIvD,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,GAAG,GAAG;IAKnD,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAC,EAAE,GAAG;IAanF,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI;IAkB1F,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,qBAAqB,CAAC,GAAG,OAAO;CAGnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/collide/shader-module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;;AAwGjE,wBAMkB"}
1
+ {"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/collide/shader-module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;;AAuGjE,wBAMkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/collision-filter/shader-module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;;AAwGjE,wBAMkB"}
1
+ {"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/collision-filter/shader-module.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;;AAyGjE,wBAMkB"}
@@ -0,0 +1,6 @@
1
+ declare const EffectOrder: {
2
+ MaskEffect: number;
3
+ CollideEffect: number;
4
+ };
5
+ export default EffectOrder;
6
+ //# sourceMappingURL=effect-order.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effect-order.d.ts","sourceRoot":"","sources":["../src/effect-order.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,WAAW;;;CAGhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,83 +0,0 @@
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.
20
- import { LayerExtension } from '@deck.gl/core';
21
- import shaderModule from './shader-module';
22
- const defaultProps = {
23
- getBrushingTarget: { type: 'accessor', value: [0, 0] },
24
- brushingTarget: 'source',
25
- brushingEnabled: true,
26
- brushingRadius: 10000
27
- };
28
- export default class BrushingExtension extends LayerExtension {
29
- getShaders(extension) {
30
- return {
31
- modules: [shaderModule]
32
- };
33
- }
34
- initializeState(context, extension) {
35
- const attributeManager = this.getAttributeManager();
36
- if (attributeManager) {
37
- attributeManager.add({
38
- brushingTargets: {
39
- size: 2,
40
- accessor: 'getBrushingTarget',
41
- // Hack: extension's defaultProps is not merged with the layer's defaultProps,
42
- // So we can't use the standard accessor when the prop is undefined
43
- update: !this.props.getBrushingTarget && extension.useConstantTargetPositions,
44
- shaderAttributes: {
45
- brushingTargets: {
46
- divisor: 0
47
- },
48
- instanceBrushingTargets: {
49
- divisor: 1
50
- }
51
- }
52
- }
53
- });
54
- }
55
- // Trigger redraw when mouse moves
56
- // TODO - expose this in a better way
57
- extension.onMouseMove = () => {
58
- this.getCurrentLayer().setNeedsRedraw();
59
- };
60
- if (this.context.deck) {
61
- this.context.deck.eventManager.on({
62
- pointermove: extension.onMouseMove,
63
- pointerleave: extension.onMouseMove
64
- });
65
- }
66
- }
67
- finalizeState(extension) {
68
- // Remove event listeners
69
- if (this.context.deck) {
70
- this.context.deck.eventManager.off({
71
- pointermove: extension.onMouseMove,
72
- pointerleave: extension.onMouseMove
73
- });
74
- }
75
- }
76
- useConstantTargetPositions(attribute) {
77
- attribute.constant = true;
78
- attribute.value = new Float32Array(2);
79
- return;
80
- }
81
- }
82
- BrushingExtension.extensionName = 'BrushingExtension';
83
- BrushingExtension.defaultProps = defaultProps;
@@ -1,116 +0,0 @@
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.
20
- import { project } from '@deck.gl/core';
21
- const vs = `
22
- uniform bool brushing_enabled;
23
- uniform int brushing_target;
24
- uniform vec2 brushing_mousePos;
25
- uniform float brushing_radius;
26
-
27
- #ifdef NON_INSTANCED_MODEL
28
- attribute vec2 brushingTargets;
29
- #else
30
- attribute vec2 instanceBrushingTargets;
31
- #endif
32
-
33
- varying float brushing_isVisible;
34
-
35
- bool brushing_isPointInRange(vec2 position) {
36
- if (!brushing_enabled) {
37
- return true;
38
- }
39
- vec2 source_commonspace = project_position(position);
40
- vec2 target_commonspace = project_position(brushing_mousePos);
41
- float distance = length((target_commonspace - source_commonspace) / project_uCommonUnitsPerMeter.xy);
42
-
43
- return distance <= brushing_radius;
44
- }
45
-
46
- bool brushing_arePointsInRange(vec2 sourcePos, vec2 targetPos) {
47
- return brushing_isPointInRange(sourcePos) || brushing_isPointInRange(targetPos);
48
- }
49
-
50
- void brushing_setVisible(bool visible) {
51
- brushing_isVisible = float(visible);
52
- }
53
- `;
54
- const fs = `
55
- uniform bool brushing_enabled;
56
- varying float brushing_isVisible;
57
- `;
58
- const TARGET = {
59
- source: 0,
60
- target: 1,
61
- custom: 2,
62
- source_target: 3
63
- };
64
- const inject = {
65
- 'vs:DECKGL_FILTER_GL_POSITION': `
66
- vec2 brushingTarget;
67
- vec2 brushingSource;
68
- if (brushing_target == 3) {
69
- brushingTarget = geometry.worldPositionAlt.xy;
70
- brushingSource = geometry.worldPosition.xy;
71
- } else if (brushing_target == 0) {
72
- brushingTarget = geometry.worldPosition.xy;
73
- } else if (brushing_target == 1) {
74
- brushingTarget = geometry.worldPositionAlt.xy;
75
- } else {
76
- #ifdef NON_INSTANCED_MODEL
77
- brushingTarget = brushingTargets;
78
- #else
79
- brushingTarget = instanceBrushingTargets;
80
- #endif
81
- }
82
- bool visible;
83
- if (brushing_target == 3) {
84
- visible = brushing_arePointsInRange(brushingSource, brushingTarget);
85
- } else {
86
- visible = brushing_isPointInRange(brushingTarget);
87
- }
88
- brushing_setVisible(visible);
89
- `,
90
- 'fs:DECKGL_FILTER_COLOR': `
91
- if (brushing_enabled && brushing_isVisible < 0.5) {
92
- discard;
93
- }
94
- `
95
- };
96
- export default {
97
- name: 'brushing',
98
- dependencies: [project],
99
- vs,
100
- fs,
101
- inject,
102
- getUniforms: opts => {
103
- if (!opts || !opts.viewport) {
104
- return {};
105
- }
106
- const { brushingEnabled = true, brushingRadius = 10000, brushingTarget = 'source', mousePosition, viewport } = opts;
107
- return {
108
- brushing_enabled: Boolean(brushingEnabled && mousePosition && viewport.containsPixel(mousePosition)),
109
- brushing_radius: brushingRadius,
110
- brushing_target: TARGET[brushingTarget] || 0,
111
- brushing_mousePos: mousePosition
112
- ? viewport.unproject([mousePosition.x - viewport.x, mousePosition.y - viewport.y])
113
- : [0, 0]
114
- };
115
- }
116
- };
@@ -1,114 +0,0 @@
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.
20
- import { LayerExtension } from '@deck.gl/core';
21
- const defaultProps = {
22
- clipBounds: [0, 0, 1, 1]
23
- };
24
- const shaderFunction = `
25
- uniform vec4 clip_bounds;
26
-
27
- bool clip_isInBounds(vec2 position) {
28
- return position.x >= clip_bounds[0] && position.y >= clip_bounds[1] && position.x < clip_bounds[2] && position.y < clip_bounds[3];
29
- }
30
- `;
31
- /*
32
- * The vertex-shader version clips geometries by their anchor position
33
- * e.g. ScatterplotLayer - show if the center of a circle is within bounds
34
- */
35
- const shaderModuleVs = {
36
- name: 'clip-vs',
37
- vs: shaderFunction
38
- };
39
- const injectionVs = {
40
- 'vs:#decl': `
41
- varying float clip_isVisible;
42
- `,
43
- 'vs:DECKGL_FILTER_GL_POSITION': `
44
- clip_isVisible = float(clip_isInBounds(geometry.worldPosition.xy));
45
- `,
46
- 'fs:#decl': `
47
- varying float clip_isVisible;
48
- `,
49
- 'fs:DECKGL_FILTER_COLOR': `
50
- if (clip_isVisible < 0.5) discard;
51
- `
52
- };
53
- /*
54
- * The fragment-shader version clips pixels at the bounds
55
- * e.g. PolygonLayer - show the part of the polygon that intersect with the bounds
56
- */
57
- const shaderModuleFs = {
58
- name: 'clip-fs',
59
- fs: shaderFunction
60
- };
61
- const injectionFs = {
62
- 'vs:#decl': `
63
- varying vec2 clip_commonPosition;
64
- `,
65
- 'vs:DECKGL_FILTER_GL_POSITION': `
66
- clip_commonPosition = geometry.position.xy;
67
- `,
68
- 'fs:#decl': `
69
- varying vec2 clip_commonPosition;
70
- `,
71
- 'fs:DECKGL_FILTER_COLOR': `
72
- if (!clip_isInBounds(clip_commonPosition)) discard;
73
- `
74
- };
75
- export default class ClipExtension extends LayerExtension {
76
- getShaders() {
77
- // If `clipByInstance: true`, the entire object is shown/hidden based on its anchor position (done by vertex shader)
78
- // Otherwise, the object is trimmed by the clip bounds (done by fragment shader)
79
- // Default behavior: consider a layer instanced if it has attribute `instancePositions`
80
- let clipByInstance = 'instancePositions' in this.getAttributeManager().attributes;
81
- // Users can override by setting the `clipByInstance` prop
82
- if ('clipByInstance' in this.props) {
83
- clipByInstance = this.props.clipByInstance;
84
- }
85
- this.state.clipByInstance = clipByInstance;
86
- return clipByInstance
87
- ? {
88
- modules: [shaderModuleVs],
89
- inject: injectionVs
90
- }
91
- : {
92
- modules: [shaderModuleFs],
93
- inject: injectionFs
94
- };
95
- }
96
- draw({ uniforms }) {
97
- const { clipBounds = defaultProps.clipBounds } = this.props;
98
- if (this.state.clipByInstance) {
99
- uniforms.clip_bounds = clipBounds;
100
- }
101
- else {
102
- const corner0 = this.projectPosition([clipBounds[0], clipBounds[1], 0]);
103
- const corner1 = this.projectPosition([clipBounds[2], clipBounds[3], 0]);
104
- uniforms.clip_bounds = [
105
- Math.min(corner0[0], corner1[0]),
106
- Math.min(corner0[1], corner1[1]),
107
- Math.max(corner0[0], corner1[0]),
108
- Math.max(corner0[1], corner1[1])
109
- ];
110
- }
111
- }
112
- }
113
- ClipExtension.extensionName = 'ClipExtension';
114
- ClipExtension.defaultProps = defaultProps;
@@ -1,98 +0,0 @@
1
- import { Model, Texture2D, Framebuffer, isWebGL2 } from '@luma.gl/core';
2
- import GL from '@luma.gl/constants';
3
- const AGGREGATE_VS = `\
4
- #define SHADER_NAME data-filter-vertex-shader
5
-
6
- #ifdef FLOAT_TARGET
7
- attribute float filterIndices;
8
- attribute float filterPrevIndices;
9
- #else
10
- attribute vec2 filterIndices;
11
- attribute vec2 filterPrevIndices;
12
- #endif
13
-
14
- varying vec4 vColor;
15
- const float component = 1.0 / 255.0;
16
-
17
- void main() {
18
- #ifdef FLOAT_TARGET
19
- dataFilter_value *= float(filterIndices != filterPrevIndices);
20
- gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
21
- vColor = vec4(0.0, 0.0, 0.0, 1.0);
22
- #else
23
- // Float texture is not supported: pack result into 4 channels x 256 px x 64px
24
- dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);
25
- float col = filterIndices.x;
26
- float row = filterIndices.y * 4.0;
27
- float channel = floor(row);
28
- row = fract(row);
29
- vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));
30
- gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);
31
- #endif
32
- gl_PointSize = 1.0;
33
- }
34
- `;
35
- const AGGREGATE_FS = `\
36
- #define SHADER_NAME data-filter-fragment-shader
37
- precision highp float;
38
-
39
- varying vec4 vColor;
40
-
41
- void main() {
42
- if (dataFilter_value < 0.5) {
43
- discard;
44
- }
45
- gl_FragColor = vColor;
46
- }
47
- `;
48
- export function supportsFloatTarget(gl) {
49
- // https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#Support_for_float_textures_doesnt_mean_you_can_render_into_them!
50
- return (gl.getExtension('EXT_float_blend') &&
51
- // WebGL 2
52
- (gl.getExtension('EXT_color_buffer_float') ||
53
- // WebGL 1
54
- gl.getExtension('WEBGL_color_buffer_float')));
55
- }
56
- // A 1x1 framebuffer object that encodes the total count of filtered items
57
- export function getFramebuffer(gl, useFloatTarget) {
58
- if (useFloatTarget) {
59
- return new Framebuffer(gl, {
60
- width: 1,
61
- height: 1,
62
- attachments: {
63
- [GL.COLOR_ATTACHMENT0]: new Texture2D(gl, {
64
- format: isWebGL2(gl) ? GL.RGBA32F : GL.RGBA,
65
- type: GL.FLOAT,
66
- mipmaps: false
67
- })
68
- }
69
- });
70
- }
71
- return new Framebuffer(gl, {
72
- width: 256,
73
- height: 64,
74
- depth: false
75
- });
76
- }
77
- // Increments the counter based on dataFilter_value
78
- export function getModel(gl, shaderOptions, useFloatTarget) {
79
- shaderOptions.defines.NON_INSTANCED_MODEL = 1;
80
- if (useFloatTarget) {
81
- shaderOptions.defines.FLOAT_TARGET = 1;
82
- }
83
- return new Model(gl, {
84
- id: 'data-filter-aggregation-model',
85
- vertexCount: 1,
86
- isInstanced: false,
87
- drawMode: GL.POINTS,
88
- vs: AGGREGATE_VS,
89
- fs: AGGREGATE_FS,
90
- ...shaderOptions
91
- });
92
- }
93
- export const parameters = {
94
- blend: true,
95
- blendFunc: [GL.ONE, GL.ONE, GL.ONE, GL.ONE],
96
- blendEquation: [GL.FUNC_ADD, GL.FUNC_ADD],
97
- depthTest: false
98
- };