@deck.gl/extensions 8.10.0-alpha.7 → 9.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/dist.dev.js +10070 -589
  2. package/dist/es5/brushing/brushing-extension.js +8 -5
  3. package/dist/es5/brushing/brushing-extension.js.map +1 -1
  4. package/dist/es5/clip/clip-extension.js.map +1 -1
  5. package/dist/es5/collision-filter/collision-filter-effect.js +44 -35
  6. package/dist/es5/collision-filter/collision-filter-effect.js.map +1 -1
  7. package/dist/es5/collision-filter/collision-filter-pass.js +6 -6
  8. package/dist/es5/collision-filter/collision-filter-pass.js.map +1 -1
  9. package/dist/es5/collision-filter/shader-module.js +1 -1
  10. package/dist/es5/collision-filter/shader-module.js.map +1 -1
  11. package/dist/es5/data-filter/aggregator.js +18 -11
  12. package/dist/es5/data-filter/aggregator.js.map +1 -1
  13. package/dist/es5/data-filter/data-filter-extension.js +27 -27
  14. package/dist/es5/data-filter/data-filter-extension.js.map +1 -1
  15. package/dist/es5/fill-style/fill-style-extension.js +4 -6
  16. package/dist/es5/fill-style/fill-style-extension.js.map +1 -1
  17. package/dist/es5/fill-style/shaders.glsl.js.map +1 -1
  18. package/dist/es5/mask/mask-effect.js +5 -7
  19. package/dist/es5/mask/mask-effect.js.map +1 -1
  20. package/dist/es5/mask/mask-pass.js +20 -14
  21. package/dist/es5/mask/mask-pass.js.map +1 -1
  22. package/dist/es5/mask/shader-module.js.map +1 -1
  23. package/dist/es5/path-style/path-style-extension.js +11 -8
  24. package/dist/es5/path-style/path-style-extension.js.map +1 -1
  25. package/dist/es5/terrain/height-map-builder.js +7 -11
  26. package/dist/es5/terrain/height-map-builder.js.map +1 -1
  27. package/dist/es5/terrain/shader-module.js.map +1 -1
  28. package/dist/es5/terrain/terrain-cover.js +6 -6
  29. package/dist/es5/terrain/terrain-cover.js.map +1 -1
  30. package/dist/es5/terrain/terrain-effect.js +11 -13
  31. package/dist/es5/terrain/terrain-effect.js.map +1 -1
  32. package/dist/es5/terrain/terrain-pass.js +7 -5
  33. package/dist/es5/terrain/terrain-pass.js.map +1 -1
  34. package/dist/es5/terrain/terrain-picking-pass.js +2 -2
  35. package/dist/es5/terrain/terrain-picking-pass.js.map +1 -1
  36. package/dist/es5/terrain/utils.js +12 -9
  37. package/dist/es5/terrain/utils.js.map +1 -1
  38. package/dist/es5/utils/debug.js +2 -2
  39. package/dist/es5/utils/debug.js.map +1 -1
  40. package/dist/esm/brushing/brushing-extension.js +8 -5
  41. package/dist/esm/brushing/brushing-extension.js.map +1 -1
  42. package/dist/esm/clip/clip-extension.js.map +1 -1
  43. package/dist/esm/collision-filter/collision-filter-effect.js +32 -33
  44. package/dist/esm/collision-filter/collision-filter-effect.js.map +1 -1
  45. package/dist/esm/collision-filter/collision-filter-pass.js +4 -4
  46. package/dist/esm/collision-filter/collision-filter-pass.js.map +1 -1
  47. package/dist/esm/collision-filter/shader-module.js +1 -1
  48. package/dist/esm/collision-filter/shader-module.js.map +1 -1
  49. package/dist/esm/data-filter/aggregator.js +19 -15
  50. package/dist/esm/data-filter/aggregator.js.map +1 -1
  51. package/dist/esm/data-filter/data-filter-extension.js +23 -30
  52. package/dist/esm/data-filter/data-filter-extension.js.map +1 -1
  53. package/dist/esm/fill-style/fill-style-extension.js +3 -6
  54. package/dist/esm/fill-style/fill-style-extension.js.map +1 -1
  55. package/dist/esm/fill-style/shaders.glsl.js.map +1 -1
  56. package/dist/esm/mask/mask-effect.js +3 -4
  57. package/dist/esm/mask/mask-effect.js.map +1 -1
  58. package/dist/esm/mask/mask-pass.js +16 -16
  59. package/dist/esm/mask/mask-pass.js.map +1 -1
  60. package/dist/esm/mask/shader-module.js.map +1 -1
  61. package/dist/esm/path-style/path-style-extension.js +11 -8
  62. package/dist/esm/path-style/path-style-extension.js.map +1 -1
  63. package/dist/esm/terrain/height-map-builder.js +7 -10
  64. package/dist/esm/terrain/height-map-builder.js.map +1 -1
  65. package/dist/esm/terrain/shader-module.js.map +1 -1
  66. package/dist/esm/terrain/terrain-cover.js +6 -6
  67. package/dist/esm/terrain/terrain-cover.js.map +1 -1
  68. package/dist/esm/terrain/terrain-effect.js +10 -11
  69. package/dist/esm/terrain/terrain-effect.js.map +1 -1
  70. package/dist/esm/terrain/terrain-pass.js +4 -3
  71. package/dist/esm/terrain/terrain-pass.js.map +1 -1
  72. package/dist/esm/terrain/terrain-picking-pass.js +2 -2
  73. package/dist/esm/terrain/terrain-picking-pass.js.map +1 -1
  74. package/dist/esm/terrain/utils.js +15 -17
  75. package/dist/esm/terrain/utils.js.map +1 -1
  76. package/dist/esm/utils/debug.js +1 -1
  77. package/dist/esm/utils/debug.js.map +1 -1
  78. package/dist.min.js +249 -51
  79. package/package.json +8 -5
  80. package/src/brushing/brushing-extension.ts +8 -6
  81. package/src/clip/clip-extension.ts +1 -2
  82. package/src/collision-filter/collision-filter-effect.ts +40 -32
  83. package/src/collision-filter/collision-filter-pass.ts +6 -7
  84. package/src/collision-filter/shader-module.ts +7 -5
  85. package/src/data-filter/aggregator.ts +18 -18
  86. package/src/data-filter/data-filter-extension.ts +37 -29
  87. package/src/fill-style/fill-style-extension.ts +6 -7
  88. package/src/fill-style/shaders.glsl.ts +2 -2
  89. package/src/mask/mask-effect.ts +11 -10
  90. package/src/mask/mask-pass.ts +21 -22
  91. package/src/mask/shader-module.ts +2 -2
  92. package/src/path-style/path-style-extension.ts +16 -11
  93. package/src/terrain/height-map-builder.ts +8 -8
  94. package/src/terrain/shader-module.ts +8 -6
  95. package/src/terrain/terrain-cover.ts +8 -6
  96. package/src/terrain/terrain-effect.ts +14 -13
  97. package/src/terrain/terrain-pass.ts +6 -7
  98. package/src/terrain/terrain-picking-pass.ts +3 -3
  99. package/src/terrain/utils.ts +13 -13
  100. package/src/utils/debug.ts +2 -1
  101. package/typed/brushing/brushing-extension.d.ts.map +1 -1
  102. package/typed/clip/clip-extension.d.ts.map +1 -1
  103. package/typed/collision-filter/collision-filter-effect.d.ts +4 -4
  104. package/typed/collision-filter/collision-filter-effect.d.ts.map +1 -1
  105. package/typed/collision-filter/collision-filter-pass.d.ts.map +1 -1
  106. package/typed/collision-filter/shader-module.d.ts +7 -1
  107. package/typed/collision-filter/shader-module.d.ts.map +1 -1
  108. package/typed/data-filter/aggregator.d.ts +10 -8
  109. package/typed/data-filter/aggregator.d.ts.map +1 -1
  110. package/typed/data-filter/data-filter-extension.d.ts +1 -1
  111. package/typed/data-filter/data-filter-extension.d.ts.map +1 -1
  112. package/typed/fill-style/fill-style-extension.d.ts +3 -3
  113. package/typed/fill-style/fill-style-extension.d.ts.map +1 -1
  114. package/typed/fill-style/shaders.glsl.d.ts +2 -2
  115. package/typed/fill-style/shaders.glsl.d.ts.map +1 -1
  116. package/typed/mask/mask-effect.d.ts +3 -3
  117. package/typed/mask/mask-effect.d.ts.map +1 -1
  118. package/typed/mask/mask-pass.d.ts +3 -3
  119. package/typed/mask/mask-pass.d.ts.map +1 -1
  120. package/typed/mask/shader-module.d.ts +2 -2
  121. package/typed/mask/shader-module.d.ts.map +1 -1
  122. package/typed/path-style/path-style-extension.d.ts.map +1 -1
  123. package/typed/terrain/height-map-builder.d.ts +4 -4
  124. package/typed/terrain/height-map-builder.d.ts.map +1 -1
  125. package/typed/terrain/shader-module.d.ts +3 -3
  126. package/typed/terrain/shader-module.d.ts.map +1 -1
  127. package/typed/terrain/terrain-cover.d.ts.map +1 -1
  128. package/typed/terrain/terrain-effect.d.ts +4 -3
  129. package/typed/terrain/terrain-effect.d.ts.map +1 -1
  130. package/typed/terrain/terrain-pass.d.ts.map +1 -1
  131. package/typed/terrain/utils.d.ts +3 -2
  132. package/typed/terrain/utils.d.ts.map +1 -1
  133. package/typed/utils/debug.d.ts +1 -0
  134. package/typed/utils/debug.d.ts.map +1 -1
  135. package/LICENSE +0 -19
@@ -1,7 +1,8 @@
1
+ import { readPixelsToArray, clear, withGLParameters } from '@luma.gl/webgl';
2
+ import { GL } from '@luma.gl/constants';
1
3
  import { LayerExtension } from '@deck.gl/core';
2
4
  import { shaderModule, shaderModule64 } from './shader-module';
3
5
  import * as aggregator from './aggregator';
4
- import { readPixelsToArray, clear } from '@luma.gl/core';
5
6
  const defaultProps = {
6
7
  getFilterValue: {
7
8
  type: 'accessor',
@@ -77,11 +78,11 @@ export default class DataFilterExtension extends LayerExtension {
77
78
  }
78
79
 
79
80
  const {
80
- gl
81
+ device
81
82
  } = this.context;
82
83
 
83
84
  if (attributeManager && extension.opts.countItems) {
84
- const useFloatTarget = aggregator.supportsFloatTarget(gl);
85
+ const useFloatTarget = aggregator.supportsFloatTarget(device);
85
86
  attributeManager.add({
86
87
  filterIndices: {
87
88
  size: useFloatTarget ? 1 : 2,
@@ -104,8 +105,8 @@ export default class DataFilterExtension extends LayerExtension {
104
105
  }
105
106
  }
106
107
  });
107
- const filterFBO = aggregator.getFramebuffer(gl, useFloatTarget);
108
- const filterModel = aggregator.getModel(gl, extension.getShaders.call(this, extension), useFloatTarget);
108
+ const filterFBO = aggregator.getFramebuffer(device, useFloatTarget);
109
+ const filterModel = aggregator.getModel(device, extension.getShaders.call(this, extension), useFloatTarget);
109
110
  this.setState({
110
111
  filterFBO,
111
112
  filterModel
@@ -130,11 +131,9 @@ export default class DataFilterExtension extends LayerExtension {
130
131
  }
131
132
 
132
133
  draw(params, extension) {
133
- const {
134
- filterFBO,
135
- filterModel,
136
- filterNeedsUpdate
137
- } = this.state;
134
+ const filterFBO = this.state.filterFBO;
135
+ const filterModel = this.state.filterModel;
136
+ const filterNeedsUpdate = this.state.filterNeedsUpdate;
138
137
  const {
139
138
  onFilteredItemsChange
140
139
  } = this.props;
@@ -147,20 +146,20 @@ export default class DataFilterExtension extends LayerExtension {
147
146
  }
148
147
  } = this.getAttributeManager();
149
148
  filterModel.setVertexCount(this.getNumInstances());
150
- const {
151
- gl
152
- } = this.context;
153
- clear(gl, {
149
+ clear(this.context.device, {
154
150
  framebuffer: filterFBO,
155
151
  color: [0, 0, 0, 0]
156
152
  });
157
- filterModel.updateModuleSettings(params.moduleParameters).setAttributes({ ...filterValues.getShaderAttributes(),
158
- ...(filterIndices && filterIndices.getShaderAttributes())
159
- }).draw({
153
+ filterModel.updateModuleSettings(params.moduleParameters);
154
+ filterModel.setAttributes({ ...filterValues.getValue(),
155
+ ...(filterIndices === null || filterIndices === void 0 ? void 0 : filterIndices.getValue())
156
+ });
157
+ withGLParameters(filterModel.device, {
160
158
  framebuffer: filterFBO,
161
- parameters: { ...aggregator.parameters,
162
- viewport: [0, 0, filterFBO.width, filterFBO.height]
163
- }
159
+ ...aggregator.parameters,
160
+ viewport: [0, 0, filterFBO.width, filterFBO.height]
161
+ }, () => {
162
+ filterModel.draw(this.context.renderPass);
164
163
  });
165
164
  const color = readPixelsToArray(filterFBO);
166
165
  let count = 0;
@@ -178,16 +177,10 @@ export default class DataFilterExtension extends LayerExtension {
178
177
  }
179
178
 
180
179
  finalizeState() {
181
- const {
182
- filterFBO,
183
- filterModel
184
- } = this.state;
185
-
186
- if (filterFBO) {
187
- filterFBO.color.delete();
188
- filterFBO.delete();
189
- filterModel.delete();
190
- }
180
+ const filterFBO = this.state.filterFBO;
181
+ const filterModel = this.state.filterModel;
182
+ filterFBO === null || filterFBO === void 0 ? void 0 : filterFBO.destroy();
183
+ filterModel === null || filterModel === void 0 ? void 0 : filterModel.destroy();
191
184
  }
192
185
 
193
186
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/data-filter/data-filter-extension.ts"],"names":["LayerExtension","shaderModule","shaderModule64","aggregator","readPixelsToArray","clear","defaultProps","getFilterValue","type","value","onFilteredItemsChange","optional","filterEnabled","filterRange","filterSoftRange","filterTransformSize","filterTransformColor","DATA_TYPE_FROM_SIZE","DataFilterExtension","constructor","filterSize","fp64","countItems","Error","getShaders","extension","opts","modules","defines","DATAFILTER_TYPE","DATAFILTER_DOUBLE","Boolean","initializeState","context","attributeManager","getAttributeManager","add","filterValues","size","accessor","shaderAttributes","divisor","instanceFilterValues","gl","useFloatTarget","supportsFloatTarget","filterIndices","vertexOffset","normalized","object","index","i","__source","Math","floor","filterPrevIndices","filterFBO","getFramebuffer","filterModel","getModel","call","setState","updateState","props","oldProps","state","filterNeedsUpdate","attributes","needsUpdate","draw","params","setVertexCount","getNumInstances","framebuffer","color","updateModuleSettings","moduleParameters","setAttributes","getShaderAttributes","parameters","viewport","width","height","count","length","id","finalizeState","delete","extensionName"],"mappings":"AAoBA,SAAQA,cAAR,QAA6B,eAA7B;AACA,SAAQC,YAAR,EAAsBC,cAAtB,QAA2C,iBAA3C;AACA,OAAO,KAAKC,UAAZ,MAA4B,cAA5B;AACA,SAAQC,iBAAR,EAA2BC,KAA3B,QAAuC,eAAvC;AAKA,MAAMC,YAAY,GAAG;AACnBC,EAAAA,cAAc,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GADG;AAEnBC,EAAAA,qBAAqB,EAAE;AAACF,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE,IAA1B;AAAgCE,IAAAA,QAAQ,EAAE;AAA1C,GAFJ;AAInBC,EAAAA,aAAa,EAAE,IAJI;AAKnBC,EAAAA,WAAW,EAAE,CAAC,CAAC,CAAF,EAAK,CAAL,CALM;AAMnBC,EAAAA,eAAe,EAAE,IANE;AAOnBC,EAAAA,mBAAmB,EAAE,IAPF;AAQnBC,EAAAA,oBAAoB,EAAE;AARH,CAArB;AAyEA,MAAMC,mBAAmB,GAAG;AAC1B,KAAG,OADuB;AAE1B,KAAG,MAFuB;AAG1B,KAAG,MAHuB;AAI1B,KAAG;AAJuB,CAA5B;AAQA,eAAe,MAAMC,mBAAN,SAAkClB,cAAlC,CAA6E;AAI1FmB,EAAAA,WAAW,CAAC;AACVC,IAAAA,UAAU,GAAG,CADH;AAEVC,IAAAA,IAAI,GAAG,KAFG;AAGVC,IAAAA,UAAU,GAAG;AAHH,MAI6B,EAJ9B,EAIkC;AAC3C,QAAI,CA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GAAGxC,YAAY,CAACyC,mBAAb,EADU;AAEb,YAAIhC,aAAa,IAAIA,aAAa,CAACgC,mBAAd,EAArB;AAFa,OAFjB,EAMGT,IANH,CAMQ;AACJI,QAAAA,WAAW,EAAEjB,SADT;AAEJuB,QAAAA,UAAU,EAAE,EACV,GAAG5E,UAAU,CAAC4E,UADJ;AAEVC,UAAAA,QAAQ,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAOxB,SAAS,CAACyB,KAAjB,EAAwBzB,SAAS,CAAC0B,MAAlC;AAFA;AAFR,OANR;AAaA,YAAMR,KAAK,GAAGtE,iBAAiB,CAACoD,SAAD,CAA/B;AACA,UAAI2B,KAAK,GAAG,CAAZ;;AACA,WAAK,IAAIhC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGuB,KAAK,CAACU,MAA1B,EAAkCjC,CAAC,EAAnC,EAAuC;AACrCgC,QAAAA,KAAK,IAAIT,KAAK,CAACvB,CAAD,CAAd;AACD;;AACDzC,MAAAA,qBAAqB,CAAC;AAAC2E,QAAAA,EAAE,EAAE,KAAKA,EAAV;AAAcF,QAAAA;AAAd,OAAD,CAArB;AAEA,WAAKlB,KAAL,CAAWC,iBAAX,GAA+B,KAA/B;AACD;AACF;;AAEDoB,EAAAA,aAAa,GAAwC;AACnD,UAAM;AAAC9B,MAAAA,SAAD;AAAYE,MAAAA;AAAZ,QAA2B,KAAKO,KAAtC;;AACA,QAAIT,SAAJ,EAAe;AACbA,MAAAA,SAAS,CAACkB,KAAV,CAAgBa,MAAhB;AACA/B,MAAAA,SAAS,CAAC+B,MAAV;AACA7B,MAAAA,WAAW,CAAC6B,MAAZ;AACD;AACF;;AAlJyF;AAAvErE,mB,CACZZ,Y,GAAeA,Y;AADHY,mB,CAEZsE,a,GAAgB,qB","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport {LayerExtension} from '@deck.gl/core';\nimport {shaderModule, shaderModule64} from './shader-module';\nimport * as aggregator from './aggregator';\nimport {readPixelsToArray, clear} from '@luma.gl/core';\nimport GL from '@luma.gl/constants';\n\nimport type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core';\n\nconst defaultProps = {\n getFilterValue: {type: 'accessor', value: 0},\n onFilteredItemsChange: {type: 'function', value: null, optional: true},\n\n filterEnabled: true,\n filterRange: [-1, 1],\n filterSoftRange: null,\n filterTransformSize: true,\n filterTransformColor: true\n};\n\nexport type DataFilterExtensionProps<DataT = any> = {\n /**\n * Accessor to retrieve the value for each object that it will be filtered by.\n * Returns either a number (if `filterSize: 1`) or an array of numbers.\n */\n getFilterValue?: Accessor<DataT, number | number[]>;\n /**\n * Enable/disable the data filter. If the data filter is disabled, all objects are rendered.\n * @default true\n */\n filterEnabled?: boolean;\n /**\n * The [min, max] bounds which defines whether an object should be rendered.\n * If an object's filtered value is within the bounds, the object will be rendered; otherwise it will be hidden.\n * @default [-1, 1]\n */\n filterRange?: [number, number] | [number, number][];\n /**\n * If specified, objects will be faded in/out instead of abruptly shown/hidden.\n * When the filtered value is outside of the bounds defined by `filterSoftRange` but still within the bounds defined by `filterRange`, the object will be rendered as \"faded.\"\n * @default null\n */\n filterSoftRange?: [number, number] | [number, number][] | null;\n /**\n * When an object is \"faded\", manipulate its size so that it appears smaller or thinner. Only works if `filterSoftRange` is specified.\n * @default true\n */\n filterTransformSize?: boolean;\n /**\n * When an object is \"faded\", manipulate its opacity so that it appears more translucent. Only works if `filterSoftRange` is specified.\n * @default true\n */\n filterTransformColor?: boolean;\n /**\n * Only called if the `countItems` option is enabled.\n */\n onFilteredItemsChange?: (evt: {\n /** The id of the source layer. */\n id: string;\n /** The number of data objects that pass the filter. */\n count: number;\n }) => void;\n};\n\ntype DataFilterExtensionOptions = {\n /**\n * The size of the filter (number of columns to filter by). The data filter can show/hide data based on 1-4 numeric properties of each object.\n * @default 1\n */\n filterSize: number;\n /**\n * Use 64-bit precision instead of 32-bit.\n * @default false\n */\n fp64: boolean;\n /**\n * If `true`, reports the number of filtered objects with the `onFilteredItemsChange` callback.\n * @default `false`.\n */\n countItems: boolean;\n};\n\nconst DATA_TYPE_FROM_SIZE = {\n 1: 'float',\n 2: 'vec2',\n 3: 'vec3',\n 4: 'vec4'\n};\n\n/** Adds GPU-based data filtering functionalities to layers. It allows the layer to show/hide objects based on user-defined properties. */\nexport default class DataFilterExtension extends LayerExtension<DataFilterExtensionOptions> {\n static defaultProps = defaultProps;\n static extensionName = 'DataFilterExtension';\n\n constructor({\n filterSize = 1,\n fp64 = false,\n countItems = false\n }: Partial<DataFilterExtensionOptions> = {}) {\n if (!DATA_TYPE_FROM_SIZE[filterSize]) {\n throw new Error('filterSize out of range');\n }\n\n super({filterSize, fp64, countItems});\n }\n\n getShaders(this: Layer<DataFilterExtensionProps>, extension: this): any {\n const {filterSize, fp64} = extension.opts;\n\n return {\n modules: [fp64 ? shaderModule64 : shaderModule],\n defines: {\n DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],\n DATAFILTER_DOUBLE: Boolean(fp64)\n }\n };\n }\n\n initializeState(this: Layer<DataFilterExtensionProps>, context: LayerContext, extension: this) {\n const attributeManager = this.getAttributeManager();\n if (attributeManager) {\n attributeManager.add({\n filterValues: {\n size: extension.opts.filterSize,\n type: extension.opts.fp64 ? GL.DOUBLE : GL.FLOAT,\n accessor: 'getFilterValue',\n shaderAttributes: {\n filterValues: {\n divisor: 0\n },\n instanceFilterValues: {\n divisor: 1\n }\n }\n }\n });\n }\n\n const {gl} = this.context;\n if (attributeManager && extension.opts.countItems) {\n const useFloatTarget = aggregator.supportsFloatTarget(gl);\n // This attribute is needed for variable-width data, e.g. Path, SolidPolygon, Text\n // The vertex shader checks if a vertex has the same \"index\" as the previous vertex\n // so that we only write one count cross multiple vertices of the same object\n attributeManager.add({\n filterIndices: {\n size: useFloatTarget ? 1 : 2,\n vertexOffset: 1,\n type: GL.UNSIGNED_BYTE,\n normalized: true,\n accessor: (object, {index}) => {\n const i = object && object.__source ? object.__source.index : index;\n return useFloatTarget ? (i + 1) % 255 : [(i + 1) % 255, Math.floor(i / 255) % 255];\n },\n shaderAttributes: {\n filterPrevIndices: {\n vertexOffset: 0\n },\n filterIndices: {\n vertexOffset: 1\n }\n }\n }\n });\n\n const filterFBO = aggregator.getFramebuffer(gl, useFloatTarget);\n const filterModel = aggregator.getModel(\n gl,\n extension.getShaders.call(this, extension),\n useFloatTarget\n );\n this.setState({filterFBO, filterModel});\n }\n }\n\n updateState(\n this: Layer<DataFilterExtensionProps>,\n {props, oldProps}: UpdateParameters<Layer<DataFilterExtensionProps>>\n ) {\n if (this.state.filterModel) {\n const attributeManager = this.getAttributeManager();\n const filterNeedsUpdate =\n // attributeManager must be defined for filterModel to be set\n attributeManager!.attributes.filterValues.needsUpdate() ||\n props.filterEnabled !== oldProps.filterEnabled ||\n props.filterRange !== oldProps.filterRange ||\n props.filterSoftRange !== oldProps.filterSoftRange;\n if (filterNeedsUpdate) {\n this.setState({filterNeedsUpdate});\n }\n }\n }\n\n draw(this: Layer<DataFilterExtensionProps>, params: any, extension: this) {\n const {filterFBO, filterModel, filterNeedsUpdate} = this.state;\n const {onFilteredItemsChange} = this.props;\n if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {\n const {\n attributes: {filterValues, filterIndices}\n } = this.getAttributeManager()!;\n filterModel.setVertexCount(this.getNumInstances());\n\n const {gl} = this.context;\n clear(gl, {framebuffer: filterFBO, color: [0, 0, 0, 0]});\n\n filterModel\n .updateModuleSettings(params.moduleParameters)\n .setAttributes({\n ...filterValues.getShaderAttributes(),\n ...(filterIndices && filterIndices.getShaderAttributes())\n })\n .draw({\n framebuffer: filterFBO,\n parameters: {\n ...aggregator.parameters,\n viewport: [0, 0, filterFBO.width, filterFBO.height]\n }\n });\n const color = readPixelsToArray(filterFBO);\n let count = 0;\n for (let i = 0; i < color.length; i++) {\n count += color[i];\n }\n onFilteredItemsChange({id: this.id, count});\n\n this.state.filterNeedsUpdate = false;\n }\n }\n\n finalizeState(this: Layer<DataFilterExtensionProps>) {\n const {filterFBO, filterModel} = this.state;\n if (filterFBO) {\n filterFBO.color.delete();\n filterFBO.delete();\n filterModel.delete();\n }\n }\n}\n"],"file":"data-filter-extension.js"}
1
+ {"version":3,"sources":["../../../src/data-filter/data-filter-extension.ts"],"names":["readPixelsToArray","clear","withGLParameters","GL","LayerExtension","shaderModule","shaderModule64","aggregator","defaultProps","getFilterValue","type","value","onFilteredItemsChange","optional","filterEnabled","filterRange","filterSoftRange","filterTransformSize","filterTransformColor","DATA_TYPE_FROM_SIZE","DataFilterExtension","constructor","filterSize","fp64","countItems","Error","getShaders","extension","opts","modules","defines","DATAFILTER_TYPE","DATAFILTER_DOUBLE","Boolean","initializeState","context","attributeManager","getAttributeManager","add","filterValues","size","accessor","shaderAttributes","divisor","instanceFilterValues","device","useFloatTarget","supportsFloatTarget","filterIndices","vertexOffset","normalized","object","index","i","__source","Math","floor","filterPrevIndices","filterFBO","getFramebuffer","filterModel","getModel","call","setState","updateState","props","oldProps","state","filterNeedsUpdate","attributes","needsUpdate","draw","params","setVertexCount","getNumInstances","framebuffer","color","updateModuleSettings","moduleParameters","setAttributes","getValue","parameters","viewport","width","height","renderPass","count","length","id","finalizeState","destroy","extensionName"],"mappings":"AAoBA,SAAQA,iBAAR,EAA2BC,KAA3B,EAAkCC,gBAAlC,QAAyD,gBAAzD;AACA,SAAQC,EAAR,QAAiB,oBAAjB;AAIA,SAAQC,cAAR,QAA6B,eAA7B;AACA,SAAQC,YAAR,EAAsBC,cAAtB,QAA2C,iBAA3C;AACA,OAAO,KAAKC,UAAZ,MAA4B,cAA5B;AAEA,MAAMC,YAAY,GAAG;AACnBC,EAAAA,cAAc,EAAE;AAACC,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GADG;AAEnBC,EAAAA,qBAAqB,EAAE;AAACF,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE,IAA1B;AAAgCE,IAAAA,QAAQ,EAAE;AAA1C,GAFJ;AAInBC,EAAAA,aAAa,EAAE,IAJI;AAKnBC,EAAAA,WAAW,EAAE,CAAC,CAAC,CAAF,EAAK,CAAL,CALM;AAMnBC,EAAAA,eAAe,EAAE,IANE;AAOnBC,EAAAA,mBAAmB,EAAE,IAPF;AAQnBC,EAAAA,oBAAoB,EAAE;AARH,CAArB;AAyEA,MAAMC,mBAAmB,GAAG;AAC1B,KAAG,OADuB;AAE1B,KAAG,MAFuB;AAG1B,KAAG,MAHuB;AAI1B,KAAG;AAJuB,CAA5B;AAQA,eAAe,MAAMC,mBAAN,SAAkChB,cAAlC,CAA6E;AAI1FiB,EAAAA,WAAW,CAAC;AACVC,IAAAA,UAAU,GAAG,CADH;AAEVC,IAAAA,IAAI,GAAG,KAFG;AAGVC,IAAAA,UAAU,GAAG;AAHH,MAI6B,EAJ9B,EAIkC;AAC3C,QAAI,CAACL,mBAAmB,CAACG,UAAD,CAAxB,EAAsC;AACpC,YAAM,IA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EZuE,a,GAAgB,qB","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport {readPixelsToArray, clear, withGLParameters} from '@luma.gl/webgl';\nimport {GL} from '@luma.gl/constants';\nimport type {Framebuffer} from '@luma.gl/core';\nimport type {Model} from '@luma.gl/engine';\nimport type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core';\nimport {LayerExtension} from '@deck.gl/core';\nimport {shaderModule, shaderModule64} from './shader-module';\nimport * as aggregator from './aggregator';\n\nconst defaultProps = {\n getFilterValue: {type: 'accessor', value: 0},\n onFilteredItemsChange: {type: 'function', value: null, optional: true},\n\n filterEnabled: true,\n filterRange: [-1, 1],\n filterSoftRange: null,\n filterTransformSize: true,\n filterTransformColor: true\n};\n\nexport type DataFilterExtensionProps<DataT = any> = {\n /**\n * Accessor to retrieve the value for each object that it will be filtered by.\n * Returns either a number (if `filterSize: 1`) or an array of numbers.\n */\n getFilterValue?: Accessor<DataT, number | number[]>;\n /**\n * Enable/disable the data filter. If the data filter is disabled, all objects are rendered.\n * @default true\n */\n filterEnabled?: boolean;\n /**\n * The [min, max] bounds which defines whether an object should be rendered.\n * If an object's filtered value is within the bounds, the object will be rendered; otherwise it will be hidden.\n * @default [-1, 1]\n */\n filterRange?: [number, number] | [number, number][];\n /**\n * If specified, objects will be faded in/out instead of abruptly shown/hidden.\n * When the filtered value is outside of the bounds defined by `filterSoftRange` but still within the bounds defined by `filterRange`, the object will be rendered as \"faded.\"\n * @default null\n */\n filterSoftRange?: [number, number] | [number, number][] | null;\n /**\n * When an object is \"faded\", manipulate its size so that it appears smaller or thinner. Only works if `filterSoftRange` is specified.\n * @default true\n */\n filterTransformSize?: boolean;\n /**\n * When an object is \"faded\", manipulate its opacity so that it appears more translucent. Only works if `filterSoftRange` is specified.\n * @default true\n */\n filterTransformColor?: boolean;\n /**\n * Only called if the `countItems` option is enabled.\n */\n onFilteredItemsChange?: (evt: {\n /** The id of the source layer. */\n id: string;\n /** The number of data objects that pass the filter. */\n count: number;\n }) => void;\n};\n\ntype DataFilterExtensionOptions = {\n /**\n * The size of the filter (number of columns to filter by). The data filter can show/hide data based on 1-4 numeric properties of each object.\n * @default 1\n */\n filterSize: number;\n /**\n * Use 64-bit precision instead of 32-bit.\n * @default false\n */\n fp64: boolean;\n /**\n * If `true`, reports the number of filtered objects with the `onFilteredItemsChange` callback.\n * @default `false`.\n */\n countItems: boolean;\n};\n\nconst DATA_TYPE_FROM_SIZE = {\n 1: 'float',\n 2: 'vec2',\n 3: 'vec3',\n 4: 'vec4'\n};\n\n/** Adds GPU-based data filtering functionalities to layers. It allows the layer to show/hide objects based on user-defined properties. */\nexport default class DataFilterExtension extends LayerExtension<DataFilterExtensionOptions> {\n static defaultProps = defaultProps;\n static extensionName = 'DataFilterExtension';\n\n constructor({\n filterSize = 1,\n fp64 = false,\n countItems = false\n }: Partial<DataFilterExtensionOptions> = {}) {\n if (!DATA_TYPE_FROM_SIZE[filterSize]) {\n throw new Error('filterSize out of range');\n }\n\n super({filterSize, fp64, countItems});\n }\n\n getShaders(this: Layer<DataFilterExtensionProps>, extension: this): any {\n const {filterSize, fp64} = extension.opts;\n\n return {\n modules: [fp64 ? shaderModule64 : shaderModule],\n defines: {\n DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],\n DATAFILTER_DOUBLE: Boolean(fp64)\n }\n };\n }\n\n initializeState(this: Layer<DataFilterExtensionProps>, context: LayerContext, extension: this) {\n const attributeManager = this.getAttributeManager();\n if (attributeManager) {\n attributeManager.add({\n filterValues: {\n size: extension.opts.filterSize,\n type: extension.opts.fp64 ? GL.DOUBLE : GL.FLOAT,\n accessor: 'getFilterValue',\n shaderAttributes: {\n filterValues: {\n divisor: 0\n },\n instanceFilterValues: {\n divisor: 1\n }\n }\n }\n });\n }\n\n const {device} = this.context;\n if (attributeManager && extension.opts.countItems) {\n const useFloatTarget = aggregator.supportsFloatTarget(device);\n // This attribute is needed for variable-width data, e.g. Path, SolidPolygon, Text\n // The vertex shader checks if a vertex has the same \"index\" as the previous vertex\n // so that we only write one count cross multiple vertices of the same object\n attributeManager.add({\n filterIndices: {\n size: useFloatTarget ? 1 : 2,\n vertexOffset: 1,\n type: GL.UNSIGNED_BYTE,\n normalized: true,\n accessor: (object, {index}) => {\n const i = object && object.__source ? object.__source.index : index;\n return useFloatTarget ? (i + 1) % 255 : [(i + 1) % 255, Math.floor(i / 255) % 255];\n },\n shaderAttributes: {\n filterPrevIndices: {\n vertexOffset: 0\n },\n filterIndices: {\n vertexOffset: 1\n }\n }\n }\n });\n\n const filterFBO = aggregator.getFramebuffer(device, useFloatTarget);\n const filterModel = aggregator.getModel(\n device,\n extension.getShaders.call(this, extension),\n useFloatTarget\n );\n this.setState({filterFBO, filterModel});\n }\n }\n\n updateState(\n this: Layer<DataFilterExtensionProps>,\n {props, oldProps}: UpdateParameters<Layer<DataFilterExtensionProps>>\n ) {\n if (this.state.filterModel) {\n const attributeManager = this.getAttributeManager();\n const filterNeedsUpdate =\n // attributeManager must be defined for filterModel to be set\n attributeManager!.attributes.filterValues.needsUpdate() ||\n props.filterEnabled !== oldProps.filterEnabled ||\n props.filterRange !== oldProps.filterRange ||\n props.filterSoftRange !== oldProps.filterSoftRange;\n if (filterNeedsUpdate) {\n this.setState({filterNeedsUpdate});\n }\n }\n }\n\n draw(this: Layer<DataFilterExtensionProps>, params: any, extension: this) {\n const filterFBO = this.state.filterFBO as Framebuffer;\n const filterModel = this.state.filterModel as Model;\n const filterNeedsUpdate = this.state.filterNeedsUpdate as boolean;\n\n const {onFilteredItemsChange} = this.props;\n if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {\n const {\n attributes: {filterValues, filterIndices}\n } = this.getAttributeManager()!;\n filterModel.setVertexCount(this.getNumInstances());\n\n clear(this.context.device, {framebuffer: filterFBO, color: [0, 0, 0, 0]});\n\n filterModel.updateModuleSettings(params.moduleParameters);\n // @ts-expect-error filterValue and filterIndices should always have buffer value\n filterModel.setAttributes({\n ...filterValues.getValue(),\n ...filterIndices?.getValue()\n });\n withGLParameters(\n filterModel.device,\n {\n framebuffer: filterFBO,\n // ts-ignore 'readonly' cannot be assigned to the mutable type '[GLBlendEquation, GLBlendEquation]'\n ...(aggregator.parameters as any),\n viewport: [0, 0, filterFBO.width, filterFBO.height]\n },\n () => {\n filterModel.draw(this.context.renderPass);\n }\n );\n const color = readPixelsToArray(filterFBO);\n let count = 0;\n for (let i = 0; i < color.length; i++) {\n count += color[i];\n }\n onFilteredItemsChange({id: this.id, count});\n\n this.state.filterNeedsUpdate = false;\n }\n }\n\n finalizeState(this: Layer<DataFilterExtensionProps>) {\n const filterFBO = this.state.filterFBO as Framebuffer;\n const filterModel = this.state.filterModel as Model;\n\n // filterFBO.color.delete();\n filterFBO?.destroy();\n filterModel?.destroy();\n }\n}\n"],"file":"data-filter-extension.js"}
@@ -1,5 +1,4 @@
1
1
  import { LayerExtension } from '@deck.gl/core';
2
- import { Texture2D } from '@luma.gl/core';
3
2
  import { patternShaders } from './shaders.glsl';
4
3
  const defaultProps = {
5
4
  fillPatternEnabled: true,
@@ -8,7 +7,7 @@ const defaultProps = {
8
7
  value: null,
9
8
  async: true,
10
9
  parameters: {
11
- [10241]: 9729
10
+ minFilter: 'linear'
12
11
  }
13
12
  },
14
13
  fillPatternMapping: {
@@ -104,7 +103,7 @@ export default class FillStyleExtension extends LayerExtension {
104
103
  }
105
104
 
106
105
  this.setState({
107
- emptyTexture: new Texture2D(this.context.gl, {
106
+ emptyTexture: this.context.device.createTexture({
108
107
  data: new Uint8Array(4),
109
108
  width: 1,
110
109
  height: 1
@@ -139,9 +138,7 @@ export default class FillStyleExtension extends LayerExtension {
139
138
  }
140
139
 
141
140
  finalizeState() {
142
- const {
143
- emptyTexture
144
- } = this.state;
141
+ const emptyTexture = this.state.emptyTexture;
145
142
  emptyTexture === null || emptyTexture === void 0 ? void 0 : emptyTexture.delete();
146
143
  }
147
144
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fill-style/fill-style-extension.ts"],"names":["LayerExtension","Texture2D","patternShaders","defaultProps","fillPatternEnabled","fillPatternAtlas","type","value","async","parameters","fillPatternMapping","fillPatternMask","getFillPattern","d","pattern","getFillPatternScale","getFillPatternOffset","FillStyleExtension","constructor","isEnabled","layer","getAttributeManager","state","getShaders","extension","modules","opts","filter","Boolean","initializeState","context","attributeManager","add","fillPatternFrames","size","accessor","transform","getPatternFrame","bind","shaderAttributes","divisor","instanceFillPatternFrames","fillPatternScales","defaultValue","instanceFillPatternScales","fillPatternOffsets","instanceFillPatternOffsets","setState","emptyTexture","gl","data","Uint8Array","width","height","updateState","props","oldProps","invalidate","draw","params","setModuleParameters","fillPatternTexture","finalizeState","delete","name","getCurrentLayer","def","x","y","extensionName"],"mappings":"AAAA,SAAQA,cAAR,QAA6B,eAA7B;AACA,SAAQC,SAAR,QAAwB,eAAxB;AAGA,SAAQC,cAAR,QAA6B,gBAA7B;AAWA,MAAMC,YAAY,GAAG;AAC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ClE,UAAM;AAACtD,MAAAA;AAAD,QAAuB,KAAKuD,eAAL,GAAwBV,KAArD;AACA,UAAMW,GAAG,GAAGxD,kBAAkB,IAAIA,kBAAkB,CAACsD,IAAD,CAApD;AACA,WAAOE,GAAG,GAAG,CAACA,GAAG,CAACC,CAAL,EAAQD,GAAG,CAACE,CAAZ,EAAeF,GAAG,CAACd,KAAnB,EAA0Bc,GAAG,CAACb,MAA9B,CAAH,GAA2C,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAArD;AACD;;AAlHuF;AAArEpC,kB,CACZd,Y,GAAeA,Y;AADHc,kB,CAEZoD,a,GAAgB,oB","sourcesContent":["import {LayerExtension} from '@deck.gl/core';\nimport {Texture2D} from '@luma.gl/core';\nimport GL from '@luma.gl/constants';\n\nimport {patternShaders} from './shaders.glsl';\n\nimport type {\n Layer,\n LayerContext,\n Accessor,\n AccessorFunction,\n Texture,\n UpdateParameters\n} from '@deck.gl/core';\n\nconst defaultProps = {\n fillPatternEnabled: true,\n fillPatternAtlas: {\n type: 'image',\n value: null,\n async: true,\n parameters: {\n [GL.TEXTURE_MIN_FILTER]: GL.LINEAR\n }\n },\n fillPatternMapping: {type: 'object', value: {}, async: true},\n fillPatternMask: true,\n getFillPattern: {type: 'accessor', value: d => d.pattern},\n getFillPatternScale: {type: 'accessor', value: 1},\n getFillPatternOffset: {type: 'accessor', value: [0, 0]}\n};\n\nexport type FillStyleExtensionProps<DataT = any> = {\n /** Cheap toggle to enable/disable pattern fill. Requires the `pattern` option to be on.\n * @default true\n */\n fillPatternEnabled?: boolean;\n /** Sprite image url or texture that packs all your patterns into one layout. */\n fillPatternAtlas?: string | Texture;\n /** Pattern names mapped to pattern definitions, or a url that points to a JSON file. */\n fillPatternMapping?:\n | string\n | Record<\n string,\n {\n /** Left position of the pattern on the atlas */\n x: number;\n /** Top position of the pattern on the atlas */\n y: number;\n /** Width of the pattern */\n width: number;\n /** Height of the pattern */\n height: number;\n }\n >;\n /**\n * Whether to treat the patterns as transparency masks.\n * @default true\n */\n fillPatternMask?: boolean;\n /** Accessor for the name of the pattern. */\n getFillPattern?: AccessorFunction<DataT, string>;\n /** Accessor for the scale of the pattern, relative to the original size. If the pattern is 24 x 24 pixels, scale `1` roughly yields 24 meters.\n * @default 1\n */\n getFillPatternScale?: Accessor<DataT, number>;\n /**\n * Accessor for the offset of the pattern, relative to the original size. Offset `[0.5, 0.5]` shifts the pattern alignment by half.\n * @default [0, 0]\n */\n getFillPatternOffset?: Accessor<DataT, [number, number]>;\n};\n\ntype FillStyleExtensionOptions = {\n /** If `true`, adds the ability to tile the filled area with a pattern.\n * @default false\n */\n pattern: boolean;\n};\n\n/** Adds selected features to layers that render a \"fill\", such as the `PolygonLayer` and `ScatterplotLayer`. */\nexport default class FillStyleExtension extends LayerExtension<FillStyleExtensionOptions> {\n static defaultProps = defaultProps;\n static extensionName = 'FillStyleExtension';\n\n constructor({pattern = false}: Partial<FillStyleExtensionOptions> = {}) {\n super({pattern});\n }\n\n isEnabled(layer: Layer<FillStyleExtensionProps>): boolean {\n return layer.getAttributeManager() !== null && !('pathTesselator' in layer.state);\n }\n\n getShaders(this: Layer<FillStyleExtensionProps>, extension: this): any {\n if (!extension.isEnabled(this)) {\n return null;\n }\n\n return {\n modules: [extension.opts.pattern && patternShaders].filter(Boolean)\n };\n }\n\n initializeState(this: Layer<FillStyleExtensionProps>, context: LayerContext, extension: this) {\n if (!extension.isEnabled(this)) {\n return;\n }\n\n const attributeManager = this.getAttributeManager();\n\n if (extension.opts.pattern) {\n attributeManager!.add({\n fillPatternFrames: {\n size: 4,\n accessor: 'getFillPattern',\n transform: extension.getPatternFrame.bind(this),\n shaderAttributes: {\n fillPatternFrames: {\n divisor: 0\n },\n instanceFillPatternFrames: {\n divisor: 1\n }\n }\n },\n fillPatternScales: {\n size: 1,\n accessor: 'getFillPatternScale',\n defaultValue: 1,\n shaderAttributes: {\n fillPatternScales: {\n divisor: 0\n },\n instanceFillPatternScales: {\n divisor: 1\n }\n }\n },\n fillPatternOffsets: {\n size: 2,\n accessor: 'getFillPatternOffset',\n shaderAttributes: {\n fillPatternOffsets: {\n divisor: 0\n },\n instanceFillPatternOffsets: {\n divisor: 1\n }\n }\n }\n });\n }\n this.setState({\n emptyTexture: new Texture2D(this.context.gl, {\n data: new Uint8Array(4),\n width: 1,\n height: 1\n })\n });\n }\n\n updateState(\n this: Layer<FillStyleExtensionProps>,\n {props, oldProps}: UpdateParameters<Layer<FillStyleExtensionProps>>,\n extension: this\n ) {\n if (!extension.isEnabled(this)) {\n return;\n }\n\n if (props.fillPatternMapping && props.fillPatternMapping !== oldProps.fillPatternMapping) {\n this.getAttributeManager()!.invalidate('getFillPattern');\n }\n }\n\n draw(this: Layer<FillStyleExtensionProps>, params: any, extension: this) {\n if (!extension.isEnabled(this)) {\n return;\n }\n\n const {fillPatternAtlas} = this.props;\n this.setModuleParameters({\n fillPatternTexture: fillPatternAtlas || this.state.emptyTexture\n });\n }\n\n finalizeState(this: Layer<FillStyleExtensionProps>) {\n const {emptyTexture} = this.state;\n emptyTexture?.delete();\n }\n\n getPatternFrame(this: Layer<FillStyleExtensionProps>, name: string) {\n const {fillPatternMapping} = this.getCurrentLayer()!.props;\n const def = fillPatternMapping && fillPatternMapping[name];\n return def ? [def.x, def.y, def.width, def.height] : [0, 0, 0, 0];\n }\n}\n"],"file":"fill-style-extension.js"}
1
+ {"version":3,"sources":["../../../src/fill-style/fill-style-extension.ts"],"names":["LayerExtension","patternShaders","defaultProps","fillPatternEnabled","fillPatternAtlas","type","value","async","parameters","minFilter","fillPatternMapping","fillPatternMask","getFillPattern","d","pattern","getFillPatternScale","getFillPatternOffset","FillStyleExtension","constructor","isEnabled","layer","getAttributeManager","state","getShaders","extension","modules","opts","filter","Boolean","initializeState","context","attributeManager","add","fillPatternFrames","size","accessor","transform","getPatternFrame","bind","shaderAttributes","divisor","instanceFillPatternFrames","fillPatternScales","defaultValue","instanceFillPatternScales","fillPatternOffsets","instanceFillPatternOffsets","setState","emptyTexture","device","createTexture","data","Uint8Array","width","height","updateState","props","oldProps","invalidate","draw","params","setModuleParameters","fillPatternTexture","finalizeState","delete","name","getCurrentLayer","def","x","y","extensionName"],"mappings":"AAAA,SAAQA,cAAR,QAA6B,eAA7B;AAEA,SAAQC,cAAR,QAA6B,gBAA7B;AAYA,MAAMC,YAAY,GAAG;AACnBC,EAAAA,kBAAkB,EAAE,IADD;AAEnBC,EAAAA,gBAAgB,EAAE;AAChBC,IAAAA,IAAI,EAAE,OADU;AAEhBC,IAAAA,KAAK,EAAE,IAFS;AAGhBC,IAAAA,KAAK,EAAE,IAHS;AAIhBC,IAAAA,UAAU,EAAE;AACVC,MAAAA,SAAS,EAAE;AADD;AAJI,GAFC;AAUnBC,EAAAA,kBAAkB,EAAE;AAACL,IAAAA,IAAI,EAAE,QAAP;AAAiBC,IAAAA,KAAK,EAAE,EAAxB;AAA4BC,IAAAA,KAAK,EAAE;AAAnC,GAVD;AAWnBI,EAAAA,eAAe,EAAE,IAXE;AAYnBC,EAAAA,cAAc,EAAE;AAACP,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAEO,CAAC,IAAIA,CAAC,CAACC;AAAjC,GAZG;AAanBC,EAAAA,mBAAmB,EAAE;AAACV,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE;AAA1B,GAbF;AAcnBU,EAAAA,oBAAoB,EAAE;AAACX,IAAAA,IAAI,EAAE,UAAP;AAAmBC,IAAAA,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ;AAA1B;AAdH,CAArB;AAkEA,eAAe,MAAMW,kBAAN,SAAiCjB,cAAjC,CAA2E;AAIxFkB,EAAAA,WAAW,CAAC;AAACJ,IAAAA,OAAO,GAAG;AAAX,MAAwD,EAAzD,EAA6D;AACtE,UAAM;AAACA,MAAAA;AAAD,KAAN;AACD;;AAEDK,EAAAA,SAAS,CAACC,KAAD,EAAiD;AACxD,WAAOA,KAAK,C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KAAL,CAAW0B;AAD5B,KAAzB;AAGD;;AAEDe,EAAAA,aAAa,GAAuC;AAClD,UAAMf,YAAY,GAAG,KAAK1B,KAAL,CAAW0B,YAAhC;AACAA,IAAAA,YAAY,SAAZ,IAAAA,YAAY,WAAZ,YAAAA,YAAY,CAAEgB,MAAd;AACD;;AAED3B,EAAAA,eAAe,CAAuC4B,IAAvC,EAAqD;AAClE,UAAM;AAACvD,MAAAA;AAAD,QAAuB,KAAKwD,eAAL,GAAwBV,KAArD;AACA,UAAMW,GAAG,GAAGzD,kBAAkB,IAAIA,kBAAkB,CAACuD,IAAD,CAApD;AACA,WAAOE,GAAG,GAAG,CAACA,GAAG,CAACC,CAAL,EAAQD,GAAG,CAACE,CAAZ,EAAeF,GAAG,CAACd,KAAnB,EAA0Bc,GAAG,CAACb,MAA9B,CAAH,GAA2C,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAArD;AACD;;AAlHuF;AAArErC,kB,CACZf,Y,GAAeA,Y;AADHe,kB,CAEZqD,a,GAAgB,oB","sourcesContent":["import {LayerExtension} from '@deck.gl/core';\n\nimport {patternShaders} from './shaders.glsl';\n\nimport type {\n Layer,\n LayerContext,\n Accessor,\n AccessorFunction,\n TextureSource,\n UpdateParameters\n} from '@deck.gl/core';\nimport type {Texture} from '@luma.gl/core';\n\nconst defaultProps = {\n fillPatternEnabled: true,\n fillPatternAtlas: {\n type: 'image',\n value: null,\n async: true,\n parameters: {\n minFilter: 'linear'\n }\n },\n fillPatternMapping: {type: 'object', value: {}, async: true},\n fillPatternMask: true,\n getFillPattern: {type: 'accessor', value: d => d.pattern},\n getFillPatternScale: {type: 'accessor', value: 1},\n getFillPatternOffset: {type: 'accessor', value: [0, 0]}\n};\n\nexport type FillStyleExtensionProps<DataT = any> = {\n /** Cheap toggle to enable/disable pattern fill. Requires the `pattern` option to be on.\n * @default true\n */\n fillPatternEnabled?: boolean;\n /** Sprite image url or texture that packs all your patterns into one layout. */\n fillPatternAtlas?: string | TextureSource;\n /** Pattern names mapped to pattern definitions, or a url that points to a JSON file. */\n fillPatternMapping?:\n | string\n | Record<\n string,\n {\n /** Left position of the pattern on the atlas */\n x: number;\n /** Top position of the pattern on the atlas */\n y: number;\n /** Width of the pattern */\n width: number;\n /** Height of the pattern */\n height: number;\n }\n >;\n /**\n * Whether to treat the patterns as transparency masks.\n * @default true\n */\n fillPatternMask?: boolean;\n /** Accessor for the name of the pattern. */\n getFillPattern?: AccessorFunction<DataT, string>;\n /** Accessor for the scale of the pattern, relative to the original size. If the pattern is 24 x 24 pixels, scale `1` roughly yields 24 meters.\n * @default 1\n */\n getFillPatternScale?: Accessor<DataT, number>;\n /**\n * Accessor for the offset of the pattern, relative to the original size. Offset `[0.5, 0.5]` shifts the pattern alignment by half.\n * @default [0, 0]\n */\n getFillPatternOffset?: Accessor<DataT, [number, number]>;\n};\n\ntype FillStyleExtensionOptions = {\n /** If `true`, adds the ability to tile the filled area with a pattern.\n * @default false\n */\n pattern: boolean;\n};\n\n/** Adds selected features to layers that render a \"fill\", such as the `PolygonLayer` and `ScatterplotLayer`. */\nexport default class FillStyleExtension extends LayerExtension<FillStyleExtensionOptions> {\n static defaultProps = defaultProps;\n static extensionName = 'FillStyleExtension';\n\n constructor({pattern = false}: Partial<FillStyleExtensionOptions> = {}) {\n super({pattern});\n }\n\n isEnabled(layer: Layer<FillStyleExtensionProps>): boolean {\n return layer.getAttributeManager() !== null && !('pathTesselator' in layer.state);\n }\n\n getShaders(this: Layer<FillStyleExtensionProps>, extension: this): any {\n if (!extension.isEnabled(this)) {\n return null;\n }\n\n return {\n modules: [extension.opts.pattern && patternShaders].filter(Boolean)\n };\n }\n\n initializeState(this: Layer<FillStyleExtensionProps>, context: LayerContext, extension: this) {\n if (!extension.isEnabled(this)) {\n return;\n }\n\n const attributeManager = this.getAttributeManager();\n\n if (extension.opts.pattern) {\n attributeManager!.add({\n fillPatternFrames: {\n size: 4,\n accessor: 'getFillPattern',\n transform: extension.getPatternFrame.bind(this),\n shaderAttributes: {\n fillPatternFrames: {\n divisor: 0\n },\n instanceFillPatternFrames: {\n divisor: 1\n }\n }\n },\n fillPatternScales: {\n size: 1,\n accessor: 'getFillPatternScale',\n defaultValue: 1,\n shaderAttributes: {\n fillPatternScales: {\n divisor: 0\n },\n instanceFillPatternScales: {\n divisor: 1\n }\n }\n },\n fillPatternOffsets: {\n size: 2,\n accessor: 'getFillPatternOffset',\n shaderAttributes: {\n fillPatternOffsets: {\n divisor: 0\n },\n instanceFillPatternOffsets: {\n divisor: 1\n }\n }\n }\n });\n }\n this.setState({\n emptyTexture: this.context.device.createTexture({\n data: new Uint8Array(4),\n width: 1,\n height: 1\n })\n });\n }\n\n updateState(\n this: Layer<FillStyleExtensionProps>,\n {props, oldProps}: UpdateParameters<Layer<FillStyleExtensionProps>>,\n extension: this\n ) {\n if (!extension.isEnabled(this)) {\n return;\n }\n\n if (props.fillPatternMapping && props.fillPatternMapping !== oldProps.fillPatternMapping) {\n this.getAttributeManager()!.invalidate('getFillPattern');\n }\n }\n\n draw(this: Layer<FillStyleExtensionProps>, params: any, extension: this) {\n if (!extension.isEnabled(this)) {\n return;\n }\n\n const {fillPatternAtlas} = this.props;\n this.setModuleParameters({\n fillPatternTexture: fillPatternAtlas || this.state.emptyTexture\n });\n }\n\n finalizeState(this: Layer<FillStyleExtensionProps>) {\n const emptyTexture = this.state.emptyTexture as Texture;\n emptyTexture?.delete();\n }\n\n getPatternFrame(this: Layer<FillStyleExtensionProps>, name: string) {\n const {fillPatternMapping} = this.getCurrentLayer()!.props;\n const def = fillPatternMapping && fillPatternMapping[name];\n return def ? [def.x, def.y, def.width, def.height] : [0, 0, 0, 0];\n }\n}\n"],"file":"fill-style-extension.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fill-style/shaders.glsl.ts"],"names":["project","fp64LowPart","patternVs","patternFs","inject","getPatternUniforms","opts","uniforms","fillPatternTexture","fill_patternTexture","fill_patternTextureSize","width","height","fillPatternMask","fillPatternEnabled","project_uCommonOrigin","coordinateOriginCommon","coordinateOriginCommon64Low","fill_uvCoordinateOrigin","slice","fill_uvCoordinateOrigin64Low","fill_patternMask","fill_patternEnabled","patternShaders","name","vs","fs","dependencies","getUniforms"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,WAAjB,QAAmC,eAAnC;AAQA,MAAMC,SAAS,GAAI;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CArBA;AAuBA,MAAMC,SAAS,GAAI;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAZA;AAcA,MAAMC,MAAM,GAAG;AACb,kCAAiC;AACnC;AACA,GAHe;AAKb,4BAA2B;AAC7B;AACA;AACA;AACA;AACA;AACA,GAXe;AAab,4BAA2B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA3Be,CAAf;;AAyCA,SAASC,kBAAT,CACEC,IADF,EAEEC,QAFF,EAGuB;AACrB,MAAI,CAACD,IAAL,EAAW;AACT,WAAO,EAAP;AACD;;AACD,MAAI,wBAAwBA,IAA5B,EAAkC;AAChC,UAAM;AAACE,MAAAA;AAAD,QAAuBF,IAA7B;AACA,WAAO;AACLG,MAAAA,mBAAmB,EAAED,kBADhB;AAELE,MAAAA,uBAAuB,EAAE,CAACF,kBAAkB,CAACG,KAApB,EAA2BH,kBAAkB,CAACI,MAA9C;AAFpB,KAAP;AAID;;AACD,MAAI,cAAcN,IAAlB,EAAwB;AACtB,UAAM;AAACO,MAAAA,eAAe,GAAG,IAAnB;AAAyBC,MAAAA,kBAAkB,GAAG;AAA9C,QAAsDR,IAA5D;AACA,UAAM;AAACS,MAAAA,qBAAqB,EAAEC;AAAxB,QAAkDT,QAAxD;AAEA,UAAMU,2BAA2B,GAAG,CAClChB,WAAW,CAACe,sBAAsB,CAAC,CAAD,CAAvB,CADuB,EAElCf,WAAW,CAACe,sBAAsB,CAAC,CAAD,CAAvB,CAFuB,CAApC;AAKA,WAAO;AACLE,MAAAA,uBAAuB,EAAEF,sBAAsB,CAACG,KAAvB,CAA6B,CAA7B,EAAgC,CAAhC,CADpB;AAELC,MAAAA,4BAA4B,EAAEH,2BAFzB;AAGLI,MAAAA,gBAAgB,EAAER,eAHb;AAILS,MAAAA,mBAAmB,EAAER;AAJhB,KAAP;AAMD;;AACD,SAAO,EAAP;AACD;;AAED,OAAO,MAAMS,cAAqD,GAAG;AACnEC,EAAAA,IAAI,EAAE,cAD6D;AAEnEC,EAAAA,EAAE,EAAEvB,SAF+D;AAGnEwB,EAAAA,EAAE,EAAEvB,SAH+D;AAInEC,EAAAA,MAJmE;AAKnEuB,EAAAA,YAAY,EAAE,CAAC3B,OAAD,CALqD;AAMnE4B,EAAAA,WAAW,EAAEvB;AANsD,CAA9D","sourcesContent":["import {project, fp64LowPart} from '@deck.gl/core';\nimport type {Viewport, _ShaderModule as ShaderModule, ProjectUniforms} from '@deck.gl/core';\n\nimport type {Texture2D} from '@luma.gl/webgl';\n\n/*\n * fill pattern shader module\n */\nconst patternVs = `\n#ifdef NON_INSTANCED_MODEL\n #define FILL_PATTERN_FRAME_ATTRIB fillPatternFrames\n #define FILL_PATTERN_SCALE_ATTRIB fillPatternScales\n #define FILL_PATTERN_OFFSET_ATTRIB fillPatternOffsets\n#else\n #define FILL_PATTERN_FRAME_ATTRIB instanceFillPatternFrames\n #define FILL_PATTERN_SCALE_ATTRIB instanceFillPatternScales\n #define FILL_PATTERN_OFFSET_ATTRIB instanceFillPatternOffsets\n#endif\n\nattribute vec4 FILL_PATTERN_FRAME_ATTRIB;\nattribute float FILL_PATTERN_SCALE_ATTRIB;\nattribute vec2 FILL_PATTERN_OFFSET_ATTRIB;\n\nuniform bool fill_patternEnabled;\nuniform vec2 fill_patternTextureSize;\n\nvarying vec2 fill_uv;\nvarying vec4 fill_patternBounds;\nvarying vec4 fill_patternPlacement;\n`;\n\nconst patternFs = `\nuniform bool fill_patternEnabled;\nuniform bool fill_patternMask;\nuniform sampler2D fill_patternTexture;\nuniform vec2 fill_uvCoordinateOrigin;\nuniform vec2 fill_uvCoordinateOrigin64Low;\n\nvarying vec4 fill_patternBounds;\nvarying vec4 fill_patternPlacement;\nvarying vec2 fill_uv;\n\nconst float FILL_UV_SCALE = 512.0 / 40000000.0;\n`;\n\nconst inject = {\n 'vs:DECKGL_FILTER_GL_POSITION': `\n fill_uv = geometry.position.xy;\n `,\n\n 'vs:DECKGL_FILTER_COLOR': `\n if (fill_patternEnabled) {\n fill_patternBounds = FILL_PATTERN_FRAME_ATTRIB / vec4(fill_patternTextureSize, fill_patternTextureSize);\n fill_patternPlacement.xy = FILL_PATTERN_OFFSET_ATTRIB;\n fill_patternPlacement.zw = FILL_PATTERN_SCALE_ATTRIB * FILL_PATTERN_FRAME_ATTRIB.zw;\n }\n `,\n\n 'fs:DECKGL_FILTER_COLOR': `\n if (fill_patternEnabled) {\n vec2 scale = FILL_UV_SCALE * fill_patternPlacement.zw;\n vec2 patternUV = mod(mod(fill_uvCoordinateOrigin, scale) + fill_uvCoordinateOrigin64Low + fill_uv, scale) / scale;\n patternUV = mod(fill_patternPlacement.xy + patternUV, 1.0);\n\n vec2 texCoords = fill_patternBounds.xy + fill_patternBounds.zw * patternUV;\n\n vec4 patternColor = texture2D(fill_patternTexture, texCoords);\n color.a *= patternColor.a;\n if (!fill_patternMask) {\n color.rgb = patternColor.rgb;\n }\n }\n `\n};\n\ntype FillStyleModuleSettings =\n | {\n viewport: Viewport;\n fillPatternEnabled?: boolean;\n fillPatternMask?: boolean;\n }\n | {\n fillPatternTexture: Texture2D;\n };\n\n/* eslint-disable camelcase */\nfunction getPatternUniforms(\n opts: FillStyleModuleSettings | {},\n uniforms: Record<string, any>\n): Record<string, any> {\n if (!opts) {\n return {};\n }\n if ('fillPatternTexture' in opts) {\n const {fillPatternTexture} = opts;\n return {\n fill_patternTexture: fillPatternTexture,\n fill_patternTextureSize: [fillPatternTexture.width, fillPatternTexture.height]\n };\n }\n if ('viewport' in opts) {\n const {fillPatternMask = true, fillPatternEnabled = true} = opts;\n const {project_uCommonOrigin: coordinateOriginCommon} = uniforms as ProjectUniforms;\n\n const coordinateOriginCommon64Low = [\n fp64LowPart(coordinateOriginCommon[0]),\n fp64LowPart(coordinateOriginCommon[1])\n ];\n\n return {\n fill_uvCoordinateOrigin: coordinateOriginCommon.slice(0, 2),\n fill_uvCoordinateOrigin64Low: coordinateOriginCommon64Low,\n fill_patternMask: fillPatternMask,\n fill_patternEnabled: fillPatternEnabled\n };\n }\n return {};\n}\n\nexport const patternShaders: ShaderModule<FillStyleModuleSettings> = {\n name: 'fill-pattern',\n vs: patternVs,\n fs: patternFs,\n inject,\n dependencies: [project],\n getUniforms: getPatternUniforms\n};\n"],"file":"shaders.glsl.js"}
1
+ {"version":3,"sources":["../../../src/fill-style/shaders.glsl.ts"],"names":["project","fp64LowPart","patternVs","patternFs","inject","getPatternUniforms","opts","uniforms","fillPatternTexture","fill_patternTexture","fill_patternTextureSize","width","height","fillPatternMask","fillPatternEnabled","project_uCommonOrigin","coordinateOriginCommon","coordinateOriginCommon64Low","fill_uvCoordinateOrigin","slice","fill_uvCoordinateOrigin64Low","fill_patternMask","fill_patternEnabled","patternShaders","name","vs","fs","dependencies","getUniforms"],"mappings":"AAAA,SAAQA,OAAR,EAAiBC,WAAjB,QAAmC,eAAnC;AAQA,MAAMC,SAAS,GAAI;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CArBA;AAuBA,MAAMC,SAAS,GAAI;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAZA;AAcA,MAAMC,MAAM,GAAG;AACb,kCAAiC;AACnC;AACA,GAHe;AAKb,4BAA2B;AAC7B;AACA;AACA;AACA;AACA;AACA,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B,EAAAA,WAAW,EAAEvB;AANsD,CAA9D","sourcesContent":["import {project, fp64LowPart} from '@deck.gl/core';\nimport type {Viewport, _ShaderModule as ShaderModule, ProjectUniforms} from '@deck.gl/core';\n\nimport type {Texture} from '@luma.gl/core';\n\n/*\n * fill pattern shader module\n */\nconst patternVs = `\n#ifdef NON_INSTANCED_MODEL\n #define FILL_PATTERN_FRAME_ATTRIB fillPatternFrames\n #define FILL_PATTERN_SCALE_ATTRIB fillPatternScales\n #define FILL_PATTERN_OFFSET_ATTRIB fillPatternOffsets\n#else\n #define FILL_PATTERN_FRAME_ATTRIB instanceFillPatternFrames\n #define FILL_PATTERN_SCALE_ATTRIB instanceFillPatternScales\n #define FILL_PATTERN_OFFSET_ATTRIB instanceFillPatternOffsets\n#endif\n\nattribute vec4 FILL_PATTERN_FRAME_ATTRIB;\nattribute float FILL_PATTERN_SCALE_ATTRIB;\nattribute vec2 FILL_PATTERN_OFFSET_ATTRIB;\n\nuniform bool fill_patternEnabled;\nuniform vec2 fill_patternTextureSize;\n\nvarying vec2 fill_uv;\nvarying vec4 fill_patternBounds;\nvarying vec4 fill_patternPlacement;\n`;\n\nconst patternFs = `\nuniform bool fill_patternEnabled;\nuniform bool fill_patternMask;\nuniform sampler2D fill_patternTexture;\nuniform vec2 fill_uvCoordinateOrigin;\nuniform vec2 fill_uvCoordinateOrigin64Low;\n\nvarying vec4 fill_patternBounds;\nvarying vec4 fill_patternPlacement;\nvarying vec2 fill_uv;\n\nconst float FILL_UV_SCALE = 512.0 / 40000000.0;\n`;\n\nconst inject = {\n 'vs:DECKGL_FILTER_GL_POSITION': `\n fill_uv = geometry.position.xy;\n `,\n\n 'vs:DECKGL_FILTER_COLOR': `\n if (fill_patternEnabled) {\n fill_patternBounds = FILL_PATTERN_FRAME_ATTRIB / vec4(fill_patternTextureSize, fill_patternTextureSize);\n fill_patternPlacement.xy = FILL_PATTERN_OFFSET_ATTRIB;\n fill_patternPlacement.zw = FILL_PATTERN_SCALE_ATTRIB * FILL_PATTERN_FRAME_ATTRIB.zw;\n }\n `,\n\n 'fs:DECKGL_FILTER_COLOR': `\n if (fill_patternEnabled) {\n vec2 scale = FILL_UV_SCALE * fill_patternPlacement.zw;\n vec2 patternUV = mod(mod(fill_uvCoordinateOrigin, scale) + fill_uvCoordinateOrigin64Low + fill_uv, scale) / scale;\n patternUV = mod(fill_patternPlacement.xy + patternUV, 1.0);\n\n vec2 texCoords = fill_patternBounds.xy + fill_patternBounds.zw * patternUV;\n\n vec4 patternColor = texture2D(fill_patternTexture, texCoords);\n color.a *= patternColor.a;\n if (!fill_patternMask) {\n color.rgb = patternColor.rgb;\n }\n }\n `\n};\n\ntype FillStyleModuleSettings =\n | {\n viewport: Viewport;\n fillPatternEnabled?: boolean;\n fillPatternMask?: boolean;\n }\n | {\n fillPatternTexture: Texture;\n };\n\n/* eslint-disable camelcase */\nfunction getPatternUniforms(\n opts: FillStyleModuleSettings | {},\n uniforms: Record<string, any>\n): Record<string, any> {\n if (!opts) {\n return {};\n }\n if ('fillPatternTexture' in opts) {\n const {fillPatternTexture} = opts;\n return {\n fill_patternTexture: fillPatternTexture,\n fill_patternTextureSize: [fillPatternTexture.width, fillPatternTexture.height]\n };\n }\n if ('viewport' in opts) {\n const {fillPatternMask = true, fillPatternEnabled = true} = opts;\n const {project_uCommonOrigin: coordinateOriginCommon} = uniforms as ProjectUniforms;\n\n const coordinateOriginCommon64Low = [\n fp64LowPart(coordinateOriginCommon[0]),\n fp64LowPart(coordinateOriginCommon[1])\n ];\n\n return {\n fill_uvCoordinateOrigin: coordinateOriginCommon.slice(0, 2),\n fill_uvCoordinateOrigin64Low: coordinateOriginCommon64Low,\n fill_patternMask: fillPatternMask,\n fill_patternEnabled: fillPatternEnabled\n };\n }\n return {};\n}\n\nexport const patternShaders: ShaderModule<FillStyleModuleSettings> = {\n name: 'fill-pattern',\n vs: patternVs,\n fs: patternFs,\n inject,\n dependencies: [project],\n getUniforms: getPatternUniforms\n};\n"],"file":"shaders.glsl.js"}
@@ -1,5 +1,4 @@
1
1
  import { log } from '@deck.gl/core';
2
- import { Texture2D } from '@luma.gl/core';
3
2
  import { equals } from '@math.gl/core';
4
3
  import MaskPass from './mask-pass';
5
4
  import { joinLayerBounds, getRenderBounds, makeViewport } from '../utils/projection-utils';
@@ -17,7 +16,7 @@ export default class MaskEffect {
17
16
  this.lastViewport = void 0;
18
17
  }
19
18
 
20
- preRender(gl, {
19
+ preRender(device, {
21
20
  layers,
22
21
  layerFilter,
23
22
  viewports,
@@ -28,7 +27,7 @@ export default class MaskEffect {
28
27
  let didRender = false;
29
28
 
30
29
  if (!this.dummyMaskMap) {
31
- this.dummyMaskMap = new Texture2D(gl, {
30
+ this.dummyMaskMap = device.createTexture({
32
31
  width: 1,
33
32
  height: 1
34
33
  });
@@ -53,7 +52,7 @@ export default class MaskEffect {
53
52
  this.masks = {};
54
53
 
55
54
  if (!this.maskPass) {
56
- this.maskPass = new MaskPass(gl, {
55
+ this.maskPass = new MaskPass(device, {
57
56
  id: 'default-mask'
58
57
  });
59
58
  this.maskMap = this.maskPass.maskMap;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mask/mask-effect.ts"],"names":["log","Texture2D","equals","MaskPass","joinLayerBounds","getRenderBounds","makeViewport","MaskEffect","id","props","useInPicking","order","dummyMaskMap","channels","masks","maskPass","maskMap","lastViewport","preRender","gl","layers","layerFilter","viewports","onViewportActive","views","isPicking","didRender","width","height","maskLayers","filter","l","visible","operation","includes","length","channelMap","_sortMaskChannels","viewport","viewportChanged","resolution","undefined","warn","maskId","result","_renderChannel","channelInfo","oldChannelInfo","index","maskChanged","some","layer","i","transitions","layerBounds","b","bounds","maskBounds","maskViewport","border","getBounds","render","pass","channel","moduleParameters","devicePixelRatio","coordinateOrigin","coordinateSystem","channelCount","root","findIndex","c","push","getModuleParameters","maskChannels","cleanup","delete"],"mappings":"AAAA,SAAqEA,GAArE,QAA+E,eAA/E;AACA,SAAQC,SAAR,QAAwB,eAAxB;AACA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,IAAnB;AACD;AACF;;AAED,SAAK,MAAMT,MAAX,IAAqBP,UAArB,EAAiC;AAC/B,YAAMU,WAAW,GAAGV,UAAU,CAACO,MAAD,CAA9B;;AAEA,UAAIG,WAAW,CAACE,KAAZ,GAAoB,CAAxB,EAA2B;AACzBF,QAAAA,WAAW,CAACE,KAAZ,GAAoB,KAAKnC,QAAL,CAAcyD,SAAd,CAAwBC,CAAC,IAAI,CAACA,CAA9B,CAApB;AACA,aAAK1D,QAAL,CAAciC,WAAW,CAACE,KAA1B,IAAmCF,WAAnC;AACD;AACF;;AACD,WAAOV,UAAP;AACD;;AAEDqC,EAAAA,mBAAmB,GAGjB;AACA,WAAO;AACLzD,MAAAA,OAAO,EAAE,KAAKF,KAAL,GAAa,KAAKE,OAAlB,GAA4B,KAAKJ,YADrC;AAEL8D,MAAAA,YAAY,EAAE,KAAK5D;AAFd,KAAP;AAID;;AAED6D,EAAAA,OAAO,GAAS;AACd,QAAI,KAAK/D,YAAT,EAAuB;AACrB,WAAKA,YAAL,CAAkBgE,MAAlB;AACA,WAAKhE,YAAL,GAAoB6B,SAApB;AACD;;AAED,QAAI,KAAK1B,QAAT,EAAmB;AACjB,WAAKA,QAAL,CAAc6D,MAAd;AACA,WAAK7D,QAAL,GAAgB0B,SAAhB;AACA,WAAKzB,OAAL,GAAeyB,SAAf;AACD;;AAED,SAAKxB,YAAL,GAAoBwB,SAApB;AACA,SAAK3B,KAAL,GAAa,IAAb;AACA,SAAKD,QAAL,CAAcsB,MAAd,GAAuB,CAAvB;AACD;;AAlP+C","sourcesContent":["import {Layer, Viewport, Effect, PreRenderOptions, CoordinateSystem, log} from '@deck.gl/core';\nimport {Texture2D} from '@luma.gl/core';\nimport {equals} from '@math.gl/core';\nimport MaskPass from './mask-pass';\nimport {joinLayerBounds, getRenderBounds, makeViewport, Bounds} from '../utils/projection-utils';\n// import {debugFBO} from '../utils/debug';\n\ntype Mask = {\n /** The channel index */\n index: number;\n bounds: Bounds;\n coordinateOrigin: [number, number, number];\n coordinateSystem: CoordinateSystem;\n};\n\ntype Channel = {\n id: string;\n index: number;\n layers: Layer[];\n bounds: Bounds | null;\n maskBounds: Bounds;\n layerBounds: Bounds[];\n coordinateOrigin: [number, number, number];\n coordinateSystem: CoordinateSystem;\n};\n\nexport type MaskPreRenderStats = {\n didRender: boolean;\n};\n\n// Class to manage mask effect\nexport default class MaskEffect implements Effect {\n id = 'mask-effect';\n props = null;\n useInPicking = true;\n order = 0;\n\n private dummyMaskMap?: Texture2D;\n private channels: (Channel | null)[] = [];\n private masks: Record<string, Mask> | null = null;\n private maskPass?: MaskPass;\n private maskMap?: Texture2D;\n private lastViewport?: Viewport;\n\n preRender(\n gl: WebGLRenderingContext,\n {layers, layerFilter, viewports, onViewportActive, views, isPicking}: PreRenderOptions\n ): MaskPreRenderStats {\n let didRender = false;\n if (!this.dummyMaskMap) {\n this.dummyMaskMap = new Texture2D(gl, {\n width: 1,\n height: 1\n });\n }\n\n if (isPicking) {\n // Do not update on picking pass\n return {didRender};\n }\n\n const maskLayers = layers.filter(l => l.props.visible && l.props.operation.includes('mask'));\n if (maskLayers.length === 0) {\n this.masks = null;\n this.channels.length = 0;\n return {didRender};\n }\n this.masks = {};\n\n if (!this.maskPass) {\n this.maskPass = new MaskPass(gl, {id: 'default-mask'});\n this.maskMap = this.maskPass.maskMap;\n }\n\n // Map layers to channels\n const channelMap = this._sortMaskChannels(maskLayers);\n // TODO - support multiple views\n const viewport = viewports[0];\n const viewportChanged = !this.lastViewport || !this.lastViewport.equals(viewport);\n\n if (viewport.resolution !== undefined) {\n log.warn('MaskExtension is not supported in GlobeView')();\n return {didRender};\n }\n\n for (const maskId in channelMap) {\n const result = this._renderChannel(channelMap[maskId], {\n layerFilter,\n onViewportActive,\n views,\n viewport,\n viewportChanged\n });\n didRender ||= result;\n }\n\n // debugFBO(this.maskMap, {opaque: true});\n return {didRender};\n }\n\n /* eslint-disable-next-line complexity */\n private _renderChannel(\n channelInfo: Channel,\n {\n layerFilter,\n onViewportActive,\n views,\n viewport,\n viewportChanged\n }: {\n layerFilter: PreRenderOptions['layerFilter'];\n onViewportActive: PreRenderOptions['onViewportActive'];\n views: PreRenderOptions['views'];\n viewport: Viewport;\n viewportChanged: boolean;\n }\n ): boolean {\n let didRender = false;\n const oldChannelInfo = this.channels[channelInfo.index];\n if (!oldChannelInfo) {\n return didRender;\n }\n\n const maskChanged =\n // If a channel is new\n channelInfo === oldChannelInfo ||\n // If sublayers have changed\n channelInfo.layers.length !== oldChannelInfo.layers.length ||\n channelInfo.layers.some(\n (layer, i) =>\n // Layer instance is updated\n // Layer props might have changed\n // Undetermined props could have an effect on the output geometry of a mask layer,\n // for example getRadius+updateTriggers, radiusScale, modelMatrix\n layer !== oldChannelInfo.layers[i] ||\n // Some prop is in transition\n layer.props.transitions\n ) ||\n // If a sublayer's positions have been updated, the cached bounds will change shallowly\n channelInfo.layerBounds.some((b, i) => b !== oldChannelInfo.layerBounds[i]);\n\n channelInfo.bounds = oldChannelInfo.bounds;\n channelInfo.maskBounds = oldChannelInfo.maskBounds;\n this.channels[channelInfo.index] = channelInfo;\n\n if (maskChanged || viewportChanged) {\n // Recalculate mask bounds\n this.lastViewport = viewport;\n\n const layerBounds = joinLayerBounds(channelInfo.layers, viewport);\n channelInfo.bounds = layerBounds && getRenderBounds(layerBounds, viewport);\n\n if (maskChanged || !equals(channelInfo.bounds, oldChannelInfo.bounds)) {\n // Rerender mask FBO\n const {maskPass, maskMap} = this;\n\n const maskViewport =\n layerBounds &&\n makeViewport({\n bounds: channelInfo.bounds!,\n viewport,\n width: maskMap.width,\n height: maskMap.height,\n border: 1\n });\n\n channelInfo.maskBounds = maskViewport ? maskViewport.getBounds() : [0, 0, 1, 1];\n\n // @ts-ignore (2532) This method is only called from preRender where maskPass is defined\n maskPass.render({\n pass: 'mask',\n channel: channelInfo.index,\n layers: channelInfo.layers,\n layerFilter,\n viewports: maskViewport ? [maskViewport] : [],\n onViewportActive,\n views,\n moduleParameters: {\n devicePixelRatio: 1\n }\n });\n\n didRender = true;\n }\n }\n\n // @ts-ignore (2532) This method is only called from preRender where masks is defined\n this.masks[channelInfo.id] = {\n index: channelInfo.index,\n bounds: channelInfo.maskBounds,\n coordinateOrigin: channelInfo.coordinateOrigin,\n coordinateSystem: channelInfo.coordinateSystem\n };\n\n return didRender;\n }\n\n /**\n * Find a channel to render each mask into\n * If a maskId already exists, diff and update the existing channel\n * Otherwise replace a removed mask\n * Otherwise create a new channel\n * Returns a map from mask layer id to channel info\n */\n private _sortMaskChannels(maskLayers: Layer[]): Record<string, Channel> {\n const channelMap = {};\n let channelCount = 0;\n for (const layer of maskLayers) {\n const {id} = layer.root;\n let channelInfo = channelMap[id];\n if (!channelInfo) {\n if (++channelCount > 4) {\n log.warn('Too many mask layers. The max supported is 4')();\n continue; // eslint-disable-line no-continue\n }\n channelInfo = {\n id,\n index: this.channels.findIndex(c => c?.id === id),\n layers: [],\n layerBounds: [],\n coordinateOrigin: layer.root.props.coordinateOrigin,\n coordinateSystem: layer.root.props.coordinateSystem\n };\n channelMap[id] = channelInfo;\n }\n channelInfo.layers.push(layer);\n channelInfo.layerBounds.push(layer.getBounds());\n }\n\n for (let i = 0; i < 4; i++) {\n const channelInfo = this.channels[i];\n if (!channelInfo || !(channelInfo.id in channelMap)) {\n // The mask id at this channel no longer exists\n this.channels[i] = null;\n }\n }\n\n for (const maskId in channelMap) {\n const channelInfo = channelMap[maskId];\n\n if (channelInfo.index < 0) {\n channelInfo.index = this.channels.findIndex(c => !c);\n this.channels[channelInfo.index] = channelInfo;\n }\n }\n return channelMap;\n }\n\n getModuleParameters(): {\n maskMap: Texture2D;\n maskChannels: Record<string, Mask> | null;\n } {\n return {\n maskMap: this.masks ? this.maskMap : this.dummyMaskMap,\n maskChannels: this.masks\n };\n }\n\n cleanup(): void {\n if (this.dummyMaskMap) {\n this.dummyMaskMap.delete();\n this.dummyMaskMap = undefined;\n }\n\n if (this.maskPass) {\n this.maskPass.delete();\n this.maskPass = undefined;\n this.maskMap = undefined;\n }\n\n this.lastViewport = undefined;\n this.masks = null;\n this.channels.length = 0;\n }\n}\n"],"file":"mask-effect.js"}
1
+ {"version":3,"sources":["../../../src/mask/mask-effect.ts"],"names":["log","equals","MaskPass","joinLayerBounds","getRenderBounds","makeViewport","MaskEffect","id","props","useInPicking","order","dummyMaskMap","channels","masks","maskPass","maskMap","lastViewport","preRender","device","layers","layerFilter","viewports","onViewportActive","views","isPicking","didRender","createTexture","width","height","maskLayers","filter","l","visible","operation","includes","length","channelMap","_sortMaskChannels","viewport","viewportChanged","resolution","undefined","warn","maskId","result","_renderChannel","channelInfo","oldChannelInfo","index","maskChanged","some","layer","i","transitions","layerBounds","b","bounds","maskBounds","maskViewport","border","getBounds","render","pass","channel","moduleParameters","devicePixelRatio","coordinateOrigin","coordinateSystem","channelCount","root","findIndex","c","push","getModuleParameters","maskChannels","cleanup","delete"],"mappings":"AAAA,SAAqEA,GAArE,QAA+E,eAA/E;AAGA,SAAQC,MAAR,QAAqB,eAArB;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAAQC,eAAR,EAAyBC,eAAzB,EAA0CC,YAA1C,QAAqE,2BAArE;AA2BA,eAAe,MAAMC,UAAN,CAAmC;AAAA;AAAA,SAChDC,EADgD,GAC3C,aAD2C;AAAA,SAEhDC,KAFgD,GAExC,IAFwC;AAAA,SAGhDC,YAHgD,GAGjC,IAHiC;AAAA,SAIhDC,KAJgD,GAIxC,CAJwC;AAAA,SAMxCC,YANwC;AAAA,SAOxCC,QAPwC,GAOT,EAPS;AAAA,SAQxCC,KARwC,GAQH,IARG;AAAA,SASxCC,QATwC;AAAA,SAUxCC,OAVwC;AAAA,SAWxCC,YAXwC;AAAA;;AAahDC,EAAAA,SAAS,CACPC,MADO,EAEP;AAACC,IAAAA,MAAD;AAASC,IAAAA,WAAT;AAAsBC,IAAAA,SAAtB;AAAiCC,IAAAA,gBAAjC;AAAmDC,IAAAA,KAAnD;AAA0DC,IAAAA;AAA1D,GAF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AkBiE,MAAlB;AACA,WAAKjE,YAAL,GAAoB8B,SAApB;AACD;;AAED,QAAI,KAAK3B,QAAT,EAAmB;AACjB,WAAKA,QAAL,CAAc8D,MAAd;AACA,WAAK9D,QAAL,GAAgB2B,SAAhB;AACA,WAAK1B,OAAL,GAAe0B,SAAf;AACD;;AAED,SAAKzB,YAAL,GAAoByB,SAApB;AACA,SAAK5B,KAAL,GAAa,IAAb;AACA,SAAKD,QAAL,CAAcuB,MAAd,GAAuB,CAAvB;AACD;;AAlP+C","sourcesContent":["import {Layer, Viewport, Effect, PreRenderOptions, CoordinateSystem, log} from '@deck.gl/core';\nimport type {Device, Texture} from '@luma.gl/core';\n// import {readPixelsToArray} from '@luma.gl/webgl-legacy';\nimport {equals} from '@math.gl/core';\nimport MaskPass from './mask-pass';\nimport {joinLayerBounds, getRenderBounds, makeViewport, Bounds} from '../utils/projection-utils';\n// import {debugFBO} from '../utils/debug';\n\ntype Mask = {\n /** The channel index */\n index: number;\n bounds: Bounds;\n coordinateOrigin: [number, number, number];\n coordinateSystem: CoordinateSystem;\n};\n\ntype Channel = {\n id: string;\n index: number;\n layers: Layer[];\n bounds: Bounds | null;\n maskBounds: Bounds;\n layerBounds: Bounds[];\n coordinateOrigin: [number, number, number];\n coordinateSystem: CoordinateSystem;\n};\n\nexport type MaskPreRenderStats = {\n didRender: boolean;\n};\n\n// Class to manage mask effect\nexport default class MaskEffect implements Effect {\n id = 'mask-effect';\n props = null;\n useInPicking = true;\n order = 0;\n\n private dummyMaskMap?: Texture;\n private channels: (Channel | null)[] = [];\n private masks: Record<string, Mask> | null = null;\n private maskPass?: MaskPass;\n private maskMap?: Texture;\n private lastViewport?: Viewport;\n\n preRender(\n device: Device,\n {layers, layerFilter, viewports, onViewportActive, views, isPicking}: PreRenderOptions\n ): MaskPreRenderStats {\n let didRender = false;\n if (!this.dummyMaskMap) {\n this.dummyMaskMap = device.createTexture({\n width: 1,\n height: 1\n });\n }\n\n if (isPicking) {\n // Do not update on picking pass\n return {didRender};\n }\n\n const maskLayers = layers.filter(l => l.props.visible && l.props.operation.includes('mask'));\n if (maskLayers.length === 0) {\n this.masks = null;\n this.channels.length = 0;\n return {didRender};\n }\n this.masks = {};\n\n if (!this.maskPass) {\n this.maskPass = new MaskPass(device, {id: 'default-mask'});\n this.maskMap = this.maskPass.maskMap;\n }\n\n // Map layers to channels\n const channelMap = this._sortMaskChannels(maskLayers);\n // TODO - support multiple views\n const viewport = viewports[0];\n const viewportChanged = !this.lastViewport || !this.lastViewport.equals(viewport);\n\n if (viewport.resolution !== undefined) {\n log.warn('MaskExtension is not supported in GlobeView')();\n return {didRender};\n }\n\n for (const maskId in channelMap) {\n const result = this._renderChannel(channelMap[maskId], {\n layerFilter,\n onViewportActive,\n views,\n viewport,\n viewportChanged\n });\n didRender ||= result;\n }\n\n // debugFBO(this.maskMap, {opaque: true});\n return {didRender};\n }\n\n /* eslint-disable-next-line complexity */\n private _renderChannel(\n channelInfo: Channel,\n {\n layerFilter,\n onViewportActive,\n views,\n viewport,\n viewportChanged\n }: {\n layerFilter: PreRenderOptions['layerFilter'];\n onViewportActive: PreRenderOptions['onViewportActive'];\n views: PreRenderOptions['views'];\n viewport: Viewport;\n viewportChanged: boolean;\n }\n ): boolean {\n let didRender = false;\n const oldChannelInfo = this.channels[channelInfo.index];\n if (!oldChannelInfo) {\n return didRender;\n }\n\n const maskChanged =\n // If a channel is new\n channelInfo === oldChannelInfo ||\n // If sublayers have changed\n channelInfo.layers.length !== oldChannelInfo.layers.length ||\n channelInfo.layers.some(\n (layer, i) =>\n // Layer instance is updated\n // Layer props might have changed\n // Undetermined props could have an effect on the output geometry of a mask layer,\n // for example getRadius+updateTriggers, radiusScale, modelMatrix\n layer !== oldChannelInfo.layers[i] ||\n // Some prop is in transition\n layer.props.transitions\n ) ||\n // If a sublayer's positions have been updated, the cached bounds will change shallowly\n channelInfo.layerBounds.some((b, i) => b !== oldChannelInfo.layerBounds[i]);\n\n channelInfo.bounds = oldChannelInfo.bounds;\n channelInfo.maskBounds = oldChannelInfo.maskBounds;\n this.channels[channelInfo.index] = channelInfo;\n\n if (maskChanged || viewportChanged) {\n // Recalculate mask bounds\n this.lastViewport = viewport;\n\n const layerBounds = joinLayerBounds(channelInfo.layers, viewport);\n channelInfo.bounds = layerBounds && getRenderBounds(layerBounds, viewport);\n\n if (maskChanged || !equals(channelInfo.bounds, oldChannelInfo.bounds)) {\n // Rerender mask FBO\n const {maskPass, maskMap} = this;\n\n const maskViewport =\n layerBounds &&\n makeViewport({\n bounds: channelInfo.bounds!,\n viewport,\n width: maskMap!.width,\n height: maskMap!.height,\n border: 1\n });\n\n channelInfo.maskBounds = maskViewport ? maskViewport.getBounds() : [0, 0, 1, 1];\n\n // @ts-ignore (2532) This method is only called from preRender where maskPass is defined\n maskPass.render({\n pass: 'mask',\n channel: channelInfo.index,\n layers: channelInfo.layers,\n layerFilter,\n viewports: maskViewport ? [maskViewport] : [],\n onViewportActive,\n views,\n moduleParameters: {\n devicePixelRatio: 1\n }\n });\n\n didRender = true;\n }\n }\n\n // @ts-ignore (2532) This method is only called from preRender where masks is defined\n this.masks[channelInfo.id] = {\n index: channelInfo.index,\n bounds: channelInfo.maskBounds,\n coordinateOrigin: channelInfo.coordinateOrigin,\n coordinateSystem: channelInfo.coordinateSystem\n };\n\n return didRender;\n }\n\n /**\n * Find a channel to render each mask into\n * If a maskId already exists, diff and update the existing channel\n * Otherwise replace a removed mask\n * Otherwise create a new channel\n * Returns a map from mask layer id to channel info\n */\n private _sortMaskChannels(maskLayers: Layer[]): Record<string, Channel> {\n const channelMap = {};\n let channelCount = 0;\n for (const layer of maskLayers) {\n const {id} = layer.root;\n let channelInfo = channelMap[id];\n if (!channelInfo) {\n if (++channelCount > 4) {\n log.warn('Too many mask layers. The max supported is 4')();\n continue; // eslint-disable-line no-continue\n }\n channelInfo = {\n id,\n index: this.channels.findIndex(c => c?.id === id),\n layers: [],\n layerBounds: [],\n coordinateOrigin: layer.root.props.coordinateOrigin,\n coordinateSystem: layer.root.props.coordinateSystem\n };\n channelMap[id] = channelInfo;\n }\n channelInfo.layers.push(layer);\n channelInfo.layerBounds.push(layer.getBounds());\n }\n\n for (let i = 0; i < 4; i++) {\n const channelInfo = this.channels[i];\n if (!channelInfo || !(channelInfo.id in channelMap)) {\n // The mask id at this channel no longer exists\n this.channels[i] = null;\n }\n }\n\n for (const maskId in channelMap) {\n const channelInfo = channelMap[maskId];\n\n if (channelInfo.index < 0) {\n channelInfo.index = this.channels.findIndex(c => !c);\n this.channels[channelInfo.index] = channelInfo;\n }\n }\n return channelMap;\n }\n\n getModuleParameters(): {\n maskMap: Texture;\n maskChannels: Record<string, Mask> | null;\n } {\n return {\n maskMap: this.masks ? this.maskMap! : this.dummyMaskMap!,\n maskChannels: this.masks\n };\n }\n\n cleanup(): void {\n if (this.dummyMaskMap) {\n this.dummyMaskMap.delete();\n this.dummyMaskMap = undefined;\n }\n\n if (this.maskPass) {\n this.maskPass.delete();\n this.maskPass = undefined;\n this.maskMap = undefined;\n }\n\n this.lastViewport = undefined;\n this.masks = null;\n this.channels.length = 0;\n }\n}\n"],"file":"mask-effect.js"}
@@ -1,45 +1,45 @@
1
- import { Framebuffer, Texture2D, withParameters } from '@luma.gl/core';
1
+ import { withGLParameters } from '@luma.gl/webgl';
2
+ import { GL } from '@luma.gl/constants';
2
3
  import { _LayersPass as LayersPass } from '@deck.gl/core';
3
4
  export default class MaskPass extends LayersPass {
4
- constructor(gl, props) {
5
- super(gl, props);
5
+ constructor(device, props) {
6
+ super(device, props);
6
7
  this.maskMap = void 0;
7
8
  this.fbo = void 0;
8
9
  const {
9
10
  mapSize = 2048
10
11
  } = props;
11
- this.maskMap = new Texture2D(gl, {
12
+ this.maskMap = device.createTexture({
13
+ format: 'rgba8unorm',
12
14
  width: mapSize,
13
15
  height: mapSize,
14
- parameters: {
15
- [10241]: 9729,
16
- [10240]: 9729,
17
- [10242]: 33071,
18
- [10243]: 33071
16
+ sampler: {
17
+ minFilter: 'linear',
18
+ magFilter: 'linear',
19
+ addressModeU: 'clamp-to-edge',
20
+ addressModeV: 'clamp-to-edge'
19
21
  }
20
22
  });
21
- this.fbo = new Framebuffer(gl, {
23
+ this.fbo = device.createFramebuffer({
22
24
  id: 'maskmap',
23
25
  width: mapSize,
24
26
  height: mapSize,
25
- attachments: {
26
- [36064]: this.maskMap
27
- }
27
+ colorAttachments: [this.maskMap]
28
28
  });
29
29
  }
30
30
 
31
31
  render(options) {
32
- const gl = this.gl;
33
32
  const colorMask = [false, false, false, false];
34
33
  colorMask[options.channel] = true;
35
- return withParameters(gl, {
36
- clearColor: [255, 255, 255, 255],
34
+ const clearColor = [255, 255, 255, 255];
35
+ return withGLParameters(this.device, {
37
36
  blend: true,
38
37
  blendFunc: [0, 1],
39
38
  blendEquation: 32778,
40
39
  colorMask,
41
40
  depthTest: false
42
41
  }, () => super.render({ ...options,
42
+ clearColor,
43
43
  target: this.fbo,
44
44
  pass: 'mask'
45
45
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mask/mask-pass.ts"],"names":["Framebuffer","Texture2D","withParameters","_LayersPass","LayersPass","MaskPass","constructor","gl","props","maskMap","fbo","mapSize","width","height","parameters","id","attachments","render","options","colorMask","channel","clearColor","blend","blendFunc","blendEquation","depthTest","target","pass","shouldDrawLayer","layer","operation","includes","delete"],"mappings":"AAAA,SAAQA,WAAR,EAAqBC,SAArB,EAAgCC,cAAhC,QAAqD,eAArD;AACA,SAAQC,WAAW,IAAIC,UAAvB,QAAiE,eAAjE;AAOA,eAAe,MAAMC,QAAN,SAAuBD,UAAvB,CAAkC;AAI/CE,EAAAA,WAAW,CAACC,EAAD,EAAKC,KAAL,EAA4C;AACrD,UAAMD,EAAN,EAAUC,KAAV;AADqD,SAHvDC,OAGuD;AAAA,SAFvDC,GAEuD;AAGrD,UAAM;AAACC,MAAAA,OAAO,GAAG;AAAX,QAAmBH,KAAzB;AAEA,SAAKC,OAAL,GAAe,IAAIR,SAAJ,CAAcM,EAA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,GAAG;AACP,SAAKtB,GAAL,CAASsB,MAAT;AACA,SAAKvB,OAAL,CAAauB,MAAb;AACD;;AAzD8C","sourcesContent":["import {Framebuffer, Texture2D, withParameters} from '@luma.gl/core';\nimport {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';\n\ntype MaskPassRenderOptions = LayersPassRenderOptions & {\n /** The channel to render into, 0:red, 1:green, 2:blue, 3:alpha */\n channel: number;\n};\n\nexport default class MaskPass extends LayersPass {\n maskMap: Texture2D;\n fbo: Framebuffer;\n\n constructor(gl, props: {id: string; mapSize?: number}) {\n super(gl, props);\n\n const {mapSize = 2048} = props;\n\n this.maskMap = new Texture2D(gl, {\n width: mapSize,\n height: mapSize,\n parameters: {\n [gl.TEXTURE_MIN_FILTER]: gl.LINEAR,\n [gl.TEXTURE_MAG_FILTER]: gl.LINEAR,\n [gl.TEXTURE_WRAP_S]: gl.CLAMP_TO_EDGE,\n [gl.TEXTURE_WRAP_T]: gl.CLAMP_TO_EDGE\n }\n });\n\n this.fbo = new Framebuffer(gl, {\n id: 'maskmap',\n width: mapSize,\n height: mapSize,\n attachments: {\n [gl.COLOR_ATTACHMENT0]: this.maskMap\n }\n });\n }\n\n render(options: MaskPassRenderOptions) {\n const gl = this.gl;\n\n const colorMask = [false, false, false, false];\n colorMask[options.channel] = true;\n\n return withParameters(\n gl,\n {\n clearColor: [255, 255, 255, 255],\n blend: true,\n blendFunc: [gl.ZERO, gl.ONE],\n blendEquation: gl.FUNC_SUBTRACT,\n colorMask,\n depthTest: false\n },\n () => super.render({...options, target: this.fbo, pass: 'mask'})\n );\n }\n\n shouldDrawLayer(layer) {\n return layer.props.operation.includes('mask');\n }\n\n delete() {\n this.fbo.delete();\n this.maskMap.delete();\n }\n}\n"],"file":"mask-pass.js"}
1
+ {"version":3,"sources":["../../../src/mask/mask-pass.ts"],"names":["withGLParameters","GL","_LayersPass","LayersPass","MaskPass","constructor","device","props","maskMap","fbo","mapSize","createTexture","format","width","height","sampler","minFilter","magFilter","addressModeU","addressModeV","createFramebuffer","id","colorAttachments","render","options","colorMask","channel","clearColor","blend","blendFunc","blendEquation","depthTest","target","pass","shouldDrawLayer","layer","operation","includes","delete"],"mappings":"AACA,SAAQA,gBAAR,QAA+B,gBAA/B;AACA,SAAQC,EAAR,QAAiB,oBAAjB;AACA,SAAQC,WAAW,IAAIC,UAAvB,QAAiE,eAAjE;AAOA,eAAe,MAAMC,QAAN,SAAuBD,UAAvB,CAAkC;AAI/CE,EAAAA,WAAW,CAACC,MAAD,EAAiBC,KAAjB,EAAwD;AACjE,UAAMD,MAAN,EAAcC,KAAd;AADiE,SAHnEC,OAGmE;AAAA,SAFnEC,GAEmE;AAGjE,UAAM;AAACC,MAAAA,OAAO,GAAG;AAAX,QAAmBH,KAAzB;AAEA,SAAKC,OAAL,GAAeF,MAAM,CAACK,aAAP,CAAqB;AAClCC,MAAAA,MAAM,EAAE,YAD0B;AAElCC,MAAAA,KAAK,EAAEH,OAF2B;AAGlCI,MAAAA,MAAM,EAAEJ,OAH0B;AAIlCK,MAAAA,OAAO,EAAE;AACPC,QAAAA,SAAS,EAAE,QADJ;AAEPC,QAAAA,SAAS,EAAE,QAFJ;AAGPC,QAAAA,YAAY,EAAE,eAHP;AAIPC,QAAAA,YAAY,EAAE;AAJP;AAJyB,KAArB,CAAf;AAYA,SAAKV,GAAL,GAAWH,MAAM,CAACc,iBAAP,CAAyB;AAClCC,MAAAA,EAAE,EAAE,SAD8B;AAElCR,MAAAA,KAAK,EAAEH,OAF2B;AAGlCI,MAAAA,MAAM,EAAEJ,OAH0B;AAIlCY,MAAAA,gBAAgB,EAAE,CAAC,KAAKd,OAAN;AAJgB,KAAzB,CAAX;AAMD;;AAEDe,EAAAA,MAAM,CAACC,OAAD,EAAiC;AACrC,UAAMC,SAAS,GAAG,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf,EAAsB,KAAtB,CAAlB;AACAA,IAAAA,SAAS,CAACD,OAAO,CAACE,OAAT,CAAT,GAA6B,IAA7B;AACA,UAAMC,UAAU,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,EAAgB,GAAhB,CAAnB;AAEA,WAAO3B,gBAAgB,CACrB,KAAKM,MADgB,EAErB;AACEsB,MAAAA,KAAK,EAAE,IADT;AAEEC,MAAAA,SAAS,EAAE,MAFb;AAGEC,MAAAA,aAAa,OAHf;AAIEL,MAAAA,SAJF;AAKEM,MAAAA,SAAS,EAAE;AALb,KAFqB,EASrB,MAAM,MAAMR,MAAN,CAAa,EAAC,GAAGC,OAAJ;AAAaG,MAAAA,UAAb;AAAyBK,MAAAA,MAAM,EAAE,KAAKvB,GAAtC;AAA2CwB,MAAAA,IAAI,EAAE;AAAjD,KAAb,CATe,CAAvB;AAWD;;AAEDC,EAAAA,eAAe,CAACC,KAAD,EAAQ;AACrB,WAAOA,KAAK,CAAC5B,KAAN,CAAY6B,SAAZ,CAAsBC,QAAtB,CAA+B,MAA/B,CAAP;AACD;;AAEDC,EAAAA,MAAM,GAAG;AACP,SAAK7B,GAAL,CAAS6B,MAAT;AACA,SAAK9B,OAAL,CAAa8B,MAAb;AACD;;AAtD8C","sourcesContent":["import type {Device, Framebuffer, Texture} from '@luma.gl/core';\nimport {withGLParameters} from '@luma.gl/webgl';\nimport {GL} from '@luma.gl/constants';\nimport {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';\n\ntype MaskPassRenderOptions = LayersPassRenderOptions & {\n /** The channel to render into, 0:red, 1:green, 2:blue, 3:alpha */\n channel: number;\n};\n\nexport default class MaskPass extends LayersPass {\n maskMap: Texture;\n fbo: Framebuffer;\n\n constructor(device: Device, props: {id: string; mapSize?: number}) {\n super(device, props);\n\n const {mapSize = 2048} = props;\n\n this.maskMap = device.createTexture({\n format: 'rgba8unorm',\n width: mapSize,\n height: mapSize,\n sampler: {\n minFilter: 'linear',\n magFilter: 'linear',\n addressModeU: 'clamp-to-edge',\n addressModeV: 'clamp-to-edge'\n }\n });\n\n this.fbo = device.createFramebuffer({\n id: 'maskmap',\n width: mapSize,\n height: mapSize,\n colorAttachments: [this.maskMap]\n });\n }\n\n render(options: MaskPassRenderOptions) {\n const colorMask = [false, false, false, false];\n colorMask[options.channel] = true;\n const clearColor = [255, 255, 255, 255];\n\n return withGLParameters(\n this.device,\n {\n blend: true,\n blendFunc: [GL.ZERO, GL.ONE],\n blendEquation: GL.FUNC_SUBTRACT,\n colorMask,\n depthTest: false\n },\n () => super.render({...options, clearColor, target: this.fbo, pass: 'mask'})\n );\n }\n\n shouldDrawLayer(layer) {\n return layer.props.operation.includes('mask');\n }\n\n delete() {\n this.fbo.delete();\n this.maskMap.delete();\n }\n}\n"],"file":"mask-pass.js"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/mask/shader-module.ts"],"names":["project","vs","fs","inject","getMaskUniforms","opts","mask_texture","maskMap","name","dependencies","getUniforms"],"mappings":"AAAA,SAAQA,OAAR,QAAsB,eAAtB;AAIA,MAAMC,EAAE,GAAI;AACZ;AACA;AACA;AACA;AACA;AACA,CANA;AAQA,MAAMC,EAAE,GAAI;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CA3BA;AA6BA,MAAMC,MAAM,GAAG;AACb,cAAa;AACf;AACA,CAHe;AAIb,kBAAiB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAZe;AAab,cAAa;AACf;AACA,CAfe;AAgBb,oBAAmB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA1Be,CAAf;;AAkCA,MAAMC,eAAe,GAAIC,IAAD,IAAyD;AAC/E,MAAIA,IAAI,IAAI,aAAaA,IAAzB,EAA+B;AAC7B,WAAO;AACLC,MAAAA,YAAY,EAAED,IAAI,CAACE;AADd,KAAP;AAGD;;AACD,SAAO,EAAP;AACD,CAPD;;AASA,eAAe;AACbC,EAAAA,IAAI,EAAE,MADO;AAEbC,EAAAA,YAAY,EAAE,CAACT,OAAD,CAFD;AAGbC,EAAAA,EAHa;AAIbC,EAAAA,EAJa;AAKbC,EAAAA,MALa;AAMbO,EAAAA,WAAW,EAAEN;AANA,CAAf","sourcesContent":["import {project} from '@deck.gl/core';\nimport type {_ShaderModule as ShaderModule} from '@deck.gl/core';\nimport type {Texture2D} from '@luma.gl/webgl';\n\nconst vs = `\nuniform vec4 mask_bounds;\nuniform bool mask_maskByInstance;\nvec2 mask_getCoords(vec4 position) {\n return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);\n}\n`;\n\nconst fs = `\nuniform sampler2D mask_texture;\nuniform int mask_channel;\nuniform bool mask_enabled;\nuniform bool mask_inverted;\nbool mask_isInBounds(vec2 texCoords) {\n if (!mask_enabled) {\n return true;\n }\n vec4 maskColor = texture2D(mask_texture, texCoords);\n float maskValue = 1.0;\n if (mask_channel == 0) {\n maskValue = maskColor.r;\n } else if (mask_channel == 1) {\n maskValue = maskColor.g;\n } else if (mask_channel == 2) {\n maskValue = maskColor.b;\n } else if (mask_channel == 3) {\n maskValue = maskColor.a;\n }\n\n if (mask_inverted) {\n return maskValue >= 0.5;\n } else {\n return maskValue < 0.5;\n }\n}\n`;\n\nconst inject = {\n 'vs:#decl': `\nvarying vec2 mask_texCoords;\n`,\n 'vs:#main-end': `\n vec4 mask_common_position;\n if (mask_maskByInstance) {\n mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n } else {\n mask_common_position = geometry.position;\n }\n mask_texCoords = mask_getCoords(mask_common_position);\n`,\n 'fs:#decl': `\nvarying vec2 mask_texCoords;\n`,\n 'fs:#main-start': `\n if (mask_enabled) {\n bool mask = mask_isInBounds(mask_texCoords);\n\n // Debug: show extent of render target\n // gl_FragColor = vec4(mask_texCoords, 0.0, 1.0);\n gl_FragColor = texture2D(mask_texture, mask_texCoords);\n\n if (!mask) discard;\n }\n`\n};\n\ntype MaskModuleSettings = {\n maskMap?: Texture2D;\n};\n\n/* eslint-disable camelcase */\nconst getMaskUniforms = (opts?: MaskModuleSettings | {}): Record<string, any> => {\n if (opts && 'maskMap' in opts) {\n return {\n mask_texture: opts.maskMap\n };\n }\n return {};\n};\n\nexport default {\n name: 'mask',\n dependencies: [project],\n vs,\n fs,\n inject,\n getUniforms: getMaskUniforms\n} as ShaderModule<MaskModuleSettings>;\n"],"file":"shader-module.js"}
1
+ {"version":3,"sources":["../../../src/mask/shader-module.ts"],"names":["project","vs","fs","inject","getMaskUniforms","opts","mask_texture","maskMap","name","dependencies","getUniforms"],"mappings":"AAAA,SAAQA,OAAR,QAAsB,eAAtB;AAIA,MAAMC,EAAE,GAAI;AACZ;AACA;AACA;AACA;AACA;AACA,CANA;AAQA,MAAMC,EAAE,GAAI;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CA3BA;AA6BA,MAAMC,MAAM,GAAG;AACb,cAAa;AACf;AACA,CAHe;AAIb,kBAAiB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAZe;AAab,cAAa;AACf;AACA,CAfe;AAgBb,oBAAmB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA1Be,CAAf;;AAkCA,MAAMC,eAAe,GAAIC,IAAD,IAAyD;AAC/E,MAAIA,IAAI,IAAI,aAAaA,IAAzB,EAA+B;AAC7B,WAAO;AACLC,MAAAA,YAAY,EAAED,IAAI,CAACE;AADd,KAAP;AAGD;;AACD,SAAO,EAAP;AACD,CAPD;;AASA,eAAe;AACbC,EAAAA,IAAI,EAAE,MADO;AAEbC,EAAAA,YAAY,EAAE,CAACT,OAAD,CAFD;AAGbC,EAAAA,EAHa;AAIbC,EAAAA,EAJa;AAKbC,EAAAA,MALa;AAMbO,EAAAA,WAAW,EAAEN;AANA,CAAf","sourcesContent":["import {project} from '@deck.gl/core';\nimport type {_ShaderModule as ShaderModule} from '@deck.gl/core';\nimport type {Texture} from '@luma.gl/core';\n\nconst vs = `\nuniform vec4 mask_bounds;\nuniform bool mask_maskByInstance;\nvec2 mask_getCoords(vec4 position) {\n return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);\n}\n`;\n\nconst fs = `\nuniform sampler2D mask_texture;\nuniform int mask_channel;\nuniform bool mask_enabled;\nuniform bool mask_inverted;\nbool mask_isInBounds(vec2 texCoords) {\n if (!mask_enabled) {\n return true;\n }\n vec4 maskColor = texture2D(mask_texture, texCoords);\n float maskValue = 1.0;\n if (mask_channel == 0) {\n maskValue = maskColor.r;\n } else if (mask_channel == 1) {\n maskValue = maskColor.g;\n } else if (mask_channel == 2) {\n maskValue = maskColor.b;\n } else if (mask_channel == 3) {\n maskValue = maskColor.a;\n }\n\n if (mask_inverted) {\n return maskValue >= 0.5;\n } else {\n return maskValue < 0.5;\n }\n}\n`;\n\nconst inject = {\n 'vs:#decl': `\nvarying vec2 mask_texCoords;\n`,\n 'vs:#main-end': `\n vec4 mask_common_position;\n if (mask_maskByInstance) {\n mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));\n } else {\n mask_common_position = geometry.position;\n }\n mask_texCoords = mask_getCoords(mask_common_position);\n`,\n 'fs:#decl': `\nvarying vec2 mask_texCoords;\n`,\n 'fs:#main-start': `\n if (mask_enabled) {\n bool mask = mask_isInBounds(mask_texCoords);\n\n // Debug: show extent of render target\n // gl_FragColor = vec4(mask_texCoords, 0.0, 1.0);\n gl_FragColor = texture2D(mask_texture, mask_texCoords);\n\n if (!mask) discard;\n }\n`\n};\n\ntype MaskModuleSettings = {\n maskMap?: Texture;\n};\n\n/* eslint-disable camelcase */\nconst getMaskUniforms = (opts?: MaskModuleSettings | {}): Record<string, any> => {\n if (opts && 'maskMap' in opts) {\n return {\n mask_texture: opts.maskMap\n };\n }\n return {};\n};\n\nexport default {\n name: 'mask',\n dependencies: [project],\n vs,\n fs,\n inject,\n getUniforms: getMaskUniforms\n} as ShaderModule<MaskModuleSettings>;\n"],"file":"shader-module.js"}
@@ -60,16 +60,17 @@ export default class PathStyleExtension extends LayerExtension {
60
60
  instanceDashArrays: {
61
61
  size: 2,
62
62
  accessor: 'getDashArray'
63
- }
64
- });
65
- }
66
-
67
- if (extension.opts.highPrecisionDash) {
68
- attributeManager.addInstanced({
69
- instanceDashOffsets: {
63
+ },
64
+ instanceDashOffsets: extension.opts.highPrecisionDash ? {
70
65
  size: 1,
71
66
  accessor: 'getPath',
72
67
  transform: extension.getDashOffsets.bind(this)
68
+ } : {
69
+ size: 1,
70
+ update: attribute => {
71
+ attribute.constant = true;
72
+ attribute.value = [0];
73
+ }
73
74
  }
74
75
  });
75
76
  }
@@ -85,6 +86,8 @@ export default class PathStyleExtension extends LayerExtension {
85
86
  }
86
87
 
87
88
  updateState(params, extension) {
89
+ var _this$state$model;
90
+
88
91
  if (!extension.isEnabled(this)) {
89
92
  return;
90
93
  }
@@ -96,7 +99,7 @@ export default class PathStyleExtension extends LayerExtension {
96
99
  uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
97
100
  }
98
101
 
99
- this.state.model.setUniforms(uniforms);
102
+ (_this$state$model = this.state.model) === null || _this$state$model === void 0 ? void 0 : _this$state$model.setUniforms(uniforms);
100
103
  }
101
104
 
102
105
  getDashOffsets(path) {