@deck.gl/carto 9.0.36 → 9.0.38

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "CARTO official integration with Deck.gl. Build geospatial applications using CARTO and Deck.gl.",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "version": "9.0.36",
6
+ "version": "9.0.38",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -72,5 +72,5 @@
72
72
  "@deck.gl/layers": "^9.0.0",
73
73
  "@loaders.gl/core": "^4.2.0"
74
74
  },
75
- "gitHead": "9f1a85a66ced70ff35fd404a81f37aaf1c338c62"
75
+ "gitHead": "2e2c23cf0bc3aa2f4921e5b60dafc4b36942debf"
76
76
  }
@@ -1,5 +1,7 @@
1
1
  import {Framebuffer, TextureProps} from '@luma.gl/core';
2
+ import type {ShaderPass} from '@luma.gl/shadertools';
2
3
  import {
4
+ _ConstructorOf,
3
5
  CompositeLayer,
4
6
  Layer,
5
7
  LayerContext,
@@ -59,8 +61,10 @@ class DrawCallbackLayer extends Layer {
59
61
  * Resulting layer must be used as a sublayer of a layer created
60
62
  * with `PostProcessModifier`
61
63
  */
62
- export function RTTModifier(BaseLayer) {
64
+ export function RTTModifier<T extends _ConstructorOf<Layer>>(BaseLayer: T): T {
65
+ // @ts-expect-error initializeState is abstract
63
66
  return class RTTLayer extends BaseLayer {
67
+ // @ts-expect-error typescript doesn't see static property
64
68
  static layerName = `RTT-${BaseLayer.layerName}`;
65
69
 
66
70
  draw(this: RTTLayer, opts: any) {
@@ -176,5 +180,30 @@ export function PostProcessModifier<T extends Constructor<DrawableCompositeLayer
176
180
 
177
181
  this.internalState.renderInProgress = false;
178
182
  }
183
+
184
+ _finalize(): void {
185
+ this.internalState.renderBuffers.forEach((fbo: Framebuffer) => {
186
+ fbo.destroy();
187
+ });
188
+ this.internalState.renderBuffers = null;
189
+ this.internalState.postProcess.cleanup();
190
+ }
179
191
  };
180
192
  }
193
+
194
+ const fs = /* glsl */ `\
195
+ vec4 copy_filterColor(vec4 color, vec2 texSize, vec2 texCoord) {
196
+ return color;
197
+ }
198
+ `;
199
+
200
+ /**
201
+ * Copy
202
+ * Simple module that just copies input color to output
203
+ */
204
+ export const copy = {
205
+ name: 'copy',
206
+ fs,
207
+ getUniforms: () => ({}),
208
+ passes: [{filter: true}]
209
+ } as const satisfies ShaderPass<{}>;
@@ -29,12 +29,14 @@ out vec4 position_commonspace;
29
29
 
30
30
  void main(void) {
31
31
  // Rather than positioning using attribute, layout pixel grid using gl_InstanceID
32
- vec2 common_position = offset.xy;
32
+ vec2 tileOrigin = offset.xy;
33
33
  float scale = offset.z;
34
34
 
35
35
  int yIndex = - (gl_InstanceID / BLOCK_WIDTH);
36
36
  int xIndex = gl_InstanceID + (yIndex * BLOCK_WIDTH);
37
- common_position += scale * vec2(float(xIndex), float(yIndex - 1));
37
+
38
+ // Avoid precision issues by applying 0.5 offset here, rather than when laying out vertices
39
+ vec2 cellCenter = scale * vec2(float(xIndex) + 0.5, float(yIndex) - 0.5);
38
40
 
39
41
  vec4 color = isStroke ? instanceLineColors : instanceFillColors;
40
42
 
@@ -45,7 +47,7 @@ void main(void) {
45
47
  // Get position directly from quadbin, rather than projecting
46
48
  // Important to set geometry.position before using project_ methods below
47
49
  // as geometry.worldPosition is not set (we don't know our lat/long)
48
- geometry.position = vec4(common_position, 0.0, 1.0);
50
+ geometry.position = vec4(tileOrigin + cellCenter, 0.0, 1.0);
49
51
  if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {
50
52
  geometry.position.xyz -= project_uCommonOrigin;
51
53
  }
@@ -69,12 +71,12 @@ void main(void) {
69
71
 
70
72
  geometry.pickingColor = instancePickingColors;
71
73
 
72
- // project center of column
73
- vec2 offset = (vec2(0.5) + positions.xy * strokeOffsetRatio) * cellWidth * shouldRender;
74
- vec3 pos = vec3(offset, project_size(elevation));
75
- DECKGL_FILTER_SIZE(pos, geometry);
74
+ // Cell coordinates centered on origin
75
+ vec2 base = positions.xy * scale * strokeOffsetRatio * coverage * shouldRender;
76
+ vec3 cell = vec3(base, project_size(elevation));
77
+ DECKGL_FILTER_SIZE(cell, geometry);
76
78
 
77
- geometry.position.xyz += pos;
79
+ geometry.position.xyz += cell;
78
80
  gl_Position = project_common_position_to_clipspace(geometry.position);
79
81
 
80
82
  geometry.normal = project_normal(normals);
@@ -12,6 +12,7 @@ import {quadbinToOffset} from './quadbin-utils';
12
12
  import {Raster} from './schema/carto-raster-tile-loader';
13
13
  import vs from './raster-layer-vertex.glsl';
14
14
  import {createBinaryProxy} from '../utils';
15
+ import {RTTModifier} from './post-process-utils';
15
16
 
16
17
  const defaultProps: DefaultProps<RasterLayerProps> = {
17
18
  ...ColumnLayer.defaultProps,
@@ -26,7 +27,8 @@ const defaultProps: DefaultProps<RasterLayerProps> = {
26
27
  };
27
28
 
28
29
  // Modified ColumnLayer with custom vertex shader
29
- class RasterColumnLayer extends ColumnLayer {
30
+ // Use RTT to avoid inter-tile seams
31
+ class RasterColumnLayer extends RTTModifier(ColumnLayer) {
30
32
  static layerName = 'RasterColumnLayer';
31
33
 
32
34
  getShaders() {
@@ -137,7 +139,18 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
137
139
  dataComparator: wrappedDataComparator,
138
140
  offset,
139
141
  highlightedObjectIndex,
140
- highlightColor
142
+ highlightColor,
143
+
144
+ // RTT requires blending otherwise opacity < 1 blends with black
145
+ // render target
146
+ parameters: {
147
+ blendColorSrcFactor: 'one',
148
+ blendAlphaSrcFactor: 'one',
149
+ blendColorDstFactor: 'zero',
150
+ blendAlphaDstFactor: 'zero',
151
+ blendColorOperation: 'add',
152
+ blendAlphaOperation: 'add'
153
+ }
141
154
  }
142
155
  );
143
156
  }
@@ -1,10 +1,18 @@
1
- import {CompositeLayer, CompositeLayerProps, DefaultProps, Layer, LayersList} from '@deck.gl/core';
1
+ import {
2
+ CompositeLayer,
3
+ CompositeLayerProps,
4
+ DefaultProps,
5
+ FilterContext,
6
+ Layer,
7
+ LayersList
8
+ } from '@deck.gl/core';
2
9
  import RasterLayer, {RasterLayerProps} from './raster-layer';
3
10
  import QuadbinTileset2D from './quadbin-tileset-2d';
4
11
  import type {TilejsonResult} from '../sources/types';
5
12
  import {injectAccessToken, TilejsonPropType} from './utils';
6
13
  import {DEFAULT_TILE_SIZE} from '../constants';
7
14
  import {TileLayer, TileLayerProps} from '@deck.gl/geo-layers';
15
+ import {copy, PostProcessModifier} from './post-process-utils';
8
16
 
9
17
  export const renderSubLayers = props => {
10
18
  const tileIndex = props.tile?.index?.q;
@@ -14,6 +22,7 @@ export const renderSubLayers = props => {
14
22
 
15
23
  const defaultProps: DefaultProps<RasterTileLayerProps> = {
16
24
  data: TilejsonPropType,
25
+ refinementStrategy: 'no-overlap',
17
26
  tileSize: DEFAULT_TILE_SIZE
18
27
  };
19
28
 
@@ -27,6 +36,16 @@ type _RasterTileLayerProps<DataT> = Omit<RasterLayerProps<DataT>, 'data'> &
27
36
  data: null | TilejsonResult | Promise<TilejsonResult>;
28
37
  };
29
38
 
39
+ class PostProcessTileLayer extends PostProcessModifier(TileLayer, copy) {
40
+ filterSubLayer(context: FilterContext) {
41
+ // Handle DrawCallbackLayer
42
+ const {tile} = (context.layer as Layer<{tile: any}>).props;
43
+ if (!tile) return true;
44
+
45
+ return super.filterSubLayer(context);
46
+ }
47
+ }
48
+
30
49
  export default class RasterTileLayer<
31
50
  DataT = any,
32
51
  ExtraProps extends {} = {}
@@ -46,7 +65,7 @@ export default class RasterTileLayer<
46
65
  if (!tileJSON) return null;
47
66
 
48
67
  const {tiles: data, minzoom: minZoom, maxzoom: maxZoom} = tileJSON;
49
- const SubLayerClass = this.getSubLayerClass('tile', TileLayer);
68
+ const SubLayerClass = this.getSubLayerClass('tile', PostProcessTileLayer);
50
69
  return new SubLayerClass(this.props, {
51
70
  id: `raster-tile-layer-${this.props.id}`,
52
71
  data,