• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / deck.gl / 13375517267

17 Feb 2025 05:14PM UTC coverage: 91.607%. Remained the same
13375517267

Pull #9440

github

web-flow
Merge 4e280d9d2 into 95884c441
Pull Request #9440: chore(deps): bump actions/setup-python from 4.7.1 to 5.4.0

6692 of 7328 branches covered (91.32%)

Branch coverage included in aggregate %.

54112 of 59047 relevant lines covered (91.64%)

14865.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/modules/core/src/types/layer-props.ts
1
// deck.gl
×
2
// SPDX-License-Identifier: MIT
×
3
// Copyright (c) vis.gl contributors
×
4

×
5
import type {CoordinateSystem} from '../lib/constants';
×
6
import type Layer from '../lib/layer';
×
7
import type LayerExtension from '../lib/layer-extension';
×
8
import type {BinaryAttribute} from '../lib/attribute/attribute';
×
9
import type {ConstructorOf, NumericArray, TypedArray} from './types';
×
10
import type {PickingInfo} from '../lib/picking/pick-info';
×
11
import type {MjolnirEvent} from 'mjolnir.js';
×
12

×
13
import type {Texture, TextureProps} from '@luma.gl/core';
×
14
import type {Buffer, Parameters} from '@luma.gl/core';
×
15
import type {Loader} from '@loaders.gl/loader-utils';
×
16
import type {LightingModuleSettings} from '../shaderlib/index';
×
17
import type {Matrix4Like} from '@math.gl/core';
×
18

×
19
export type LayerData<T> =
×
20
  | Iterable<T>
×
21
  | {
×
22
      length: number;
×
23
      attributes?: Record<string, TypedArray | Buffer | BinaryAttribute>;
×
24
    };
×
25

×
26
export type AccessorContext<T> = {
×
27
  /** The index of the current iteration */
×
28
  index: number;
×
29
  /** The value of the `data` prop */
×
30
  data: LayerData<T>;
×
31
  /** A pre-allocated array. The accessor function can optionally fill data into this array and return it,
×
32
   * instead of creating a new array for every object. In some browsers this improves performance significantly
×
33
   * by reducing garbage collection. */
×
34
  target: number[];
×
35
};
×
36

×
37
/** Function that returns a value for each object. */
×
38
export type AccessorFunction<In, Out> = (
×
39
  /**
×
40
   * The current element in the data stream.
×
41
   *
×
42
   * If `data` is an array or an iterable, the element of the current iteration is used.
×
43
   * If `data` is a non-iterable object, this argument is always `null`.
×
44
   * */
×
45
  object: In,
×
46
  /** Contextual information of the current element. */
×
47
  objectInfo: AccessorContext<In>
×
48
) => Out;
×
49

×
50
/** Either a uniform value for all objects, or a function that returns a value for each object. */
×
51
export type Accessor<In, Out> = Out | AccessorFunction<In, Out>;
×
52

×
53
/** A position in the format of `[lng, lat, alt?]` or `[x, y, z?]` depending on the coordinate system.
×
54
 * See https://deck.gl/docs/developer-guide/coordinate-systems#positions
×
55
 */
×
56
export type Position = [number, number] | [number, number, number] | Float32Array | Float64Array;
×
57

×
58
/** A color in the format of `[r, g, b, a?]` */
×
59
export type Color =
×
60
  | [number, number, number]
×
61
  | [number, number, number, number]
×
62
  | Uint8Array
×
63
  | Uint8ClampedArray;
×
64

×
65
export type Material = LightingModuleSettings['material'];
×
66

×
67
/** The unit of dimensions.
×
68
 * See https://deck.gl/docs/developer-guide/coordinate-systems#dimensions
×
69
 */
×
70
export type Unit = 'meters' | 'common' | 'pixels';
×
71

×
72
/** Rendering operation of the layer. */
×
73
export type Operation = 'draw' | 'mask' | 'terrain';
×
74

×
75
export type TextureSource =
×
76
  | Texture
×
77
  | TextureProps
×
78
  | HTMLImageElement
×
79
  | ImageData
×
80
  | HTMLCanvasElement
×
81
  | HTMLVideoElement
×
82
  | ImageBitmap;
×
83

×
84
/**
×
85
 * Typical types that can be supplied to the `data` property. Can be either:
×
86
 * * An `Iterable` - a list of objects to visualize.
×
87
 * * A non-iterable - an object with a `length` field.
×
88
 * * A `Promise` whose resolved value will be used as the value of the `data` prop.
×
89
 * * An `AsyncIterable` that yields data in batches. Each batch is expected to be an array of objects.
×
90
 * * `string` - a URL to load data from
×
91
 * * `null` - empty data
×
92
 */
×
93
export type LayerDataSource<DataType> =
×
94
  | LayerData<DataType>
×
95
  | string
×
96
  | AsyncIterable<DataType[]>
×
97
  | Promise<LayerData<DataType>>
×
98
  | null;
×
99

×
100
/**
×
101
 * Base Layer prop types
×
102
 */
×
103
export type LayerProps = {
×
104
  /**
×
105
   * Unique identifier of the layer.
×
106
   */
×
107
  id: string;
×
108
  /**
×
109
   * The data to visualize.
×
110
   */
×
111
  data?: unknown;
×
112
  /**
×
113
   * Callback to determine if two data values are equal.
×
114
   */
×
115
  dataComparator?:
×
116
    | (<LayerDataT = LayerData<unknown>>(newData: LayerDataT, oldData?: LayerDataT) => boolean)
×
117
    | null;
×
118
  /**
×
119
   * Callback to determine the difference between two data values, in order to perform a partial update.
×
120
   */
×
121
  _dataDiff?:
×
122
    | (<LayerDataT = LayerData<unknown>>(
×
123
        newData: LayerDataT,
×
124
        oldData?: LayerDataT
×
125
      ) => {startRow: number; endRow?: number}[])
×
126
    | null;
×
127
  /**
×
128
   * Callback to manipulate remote data when it's fetched and parsed.
×
129
   */
×
130
  dataTransform?:
×
131
    | (<LayerDataT = LayerData<unknown>>(data: unknown, previousData?: LayerDataT) => LayerDataT)
×
132
    | null;
×
133
  /**
×
134
   * Custom implementation to fetch and parse content from URLs.
×
135
   */
×
136
  fetch?: (
×
137
    url: string,
×
138
    context: {
×
139
      propName: string;
×
140
      layer: Layer;
×
141
      loaders?: Loader[];
×
142
      loadOptions?: any;
×
143
      signal?: AbortSignal;
×
144
    }
×
145
  ) => any;
×
146
  /**
×
147
   * The dependencies used to trigger re-evaluation of functional accessors (get*).
×
148
   */
×
149
  updateTriggers?: Record<string, any>;
×
150
  /**
×
151
   * Rendering operation of the layer. `+` separated list of names.
×
152
   */
×
153
  operation?: Operation | `${Operation}+${Operation}`;
×
154
  /**
×
155
   * If the layer should be rendered. Default true.
×
156
   */
×
157
  visible?: boolean;
×
158
  /**
×
159
   * If the layer can be picked on pointer events. Default false.
×
160
   */
×
161
  pickable?: boolean;
×
162
  /**
×
163
   * Opacity of the layer, between 0 and 1. Default 1.
×
164
   */
×
165
  opacity?: number;
×
166
  /**
×
167
   * The coordinate system of the data. Default to COORDINATE_SYSTEM.LNGLAT in a geospatial view or COORDINATE_SYSTEM.CARTESIAN in a non-geospatial view.
×
168
   */
×
169
  coordinateSystem?: CoordinateSystem;
×
170
  /**
×
171
   * The coordinate origin of the data.
×
172
   */
×
173
  coordinateOrigin?: [number, number, number];
×
174
  /**
×
175
   * A 4x4 matrix to transform local coordianates to the world space.
×
176
   */
×
177
  modelMatrix?: Matrix4Like | null;
×
178
  /**
×
179
   * (Geospatial only) normalize geometries that cross the 180th meridian. Default false.
×
180
   */
×
181
  wrapLongitude?: boolean;
×
182
  /**
×
183
   * The format of positions, default 'XYZ'.
×
184
   */
×
185
  positionFormat?: 'XYZ' | 'XY';
×
186
  /**
×
187
   * The format of colors, default 'RGBA'.
×
188
   */
×
189
  colorFormat?: 'RGBA' | 'RGB';
×
190
  /**
×
191
   * Override the WebGL parameters used to draw this layer. See https://luma.gl/modules/gltools/docs/api-reference/parameter-setting#parameters
×
192
   */
×
193
  parameters?: Parameters;
×
194
  /**
×
195
   * Create smooth transitions when prop values update.
×
196
   */
×
197
  transitions?: Record<string, any> | null;
×
198
  /**
×
199
   * Add additional functionalities to this layer.
×
200
   */
×
201
  extensions?: LayerExtension[];
×
202
  /**
×
203
   * Add support for additional data formats.
×
204
   */
×
205
  loaders?: Loader[];
×
206
  /**
×
207
   * Options to customize the behavior of loaders
×
208
   */
×
209
  loadOptions?: any;
×
210
  /**
×
211
   * Callback to calculate the polygonOffset WebGL parameter.
×
212
   */
×
213
  getPolygonOffset?: ((params: {layerIndex: number}) => [number, number]) | null;
×
214

×
215
  /**
×
216
   * Enable GPU-based object highlighting. Default false.
×
217
   */
×
218
  autoHighlight?: boolean;
×
219
  /**
×
220
   * The index of the data object to highlight. If unspecified, the currently hoverred object is highlighted.
×
221
   */
×
222
  highlightedObjectIndex?: number | null;
×
223
  /**
×
224
   * The color of the highlight.
×
225
   */
×
226
  highlightColor?: number[] | ((pickingInfo: PickingInfo) => number[]);
×
227

×
228
  /**
×
229
   * Called when remote data is fetched and parsed.
×
230
   */
×
231
  onDataLoad?:
×
232
    | (<LayerDataT = LayerData<unknown>>(
×
233
        data: LayerDataT,
×
234
        context: {propName: string; layer: Layer}
×
235
      ) => void)
×
236
    | null;
×
237
  /**
×
238
   * Called when the layer encounters an error.
×
239
   */
×
240
  onError?: ((error: Error) => boolean | void) | null;
×
241
  /**
×
242
   * Called when the mouse enters/leaves an object of this layer.
×
243
   */
×
244
  onHover?: ((pickingInfo: PickingInfo, event: MjolnirEvent) => boolean | void) | null;
×
245
  /**
×
246
   * Called when the mouse clicks over an object of this layer.
×
247
   */
×
248
  onClick?: ((pickingInfo: PickingInfo, event: MjolnirEvent) => boolean | void) | null;
×
249
  /**
×
250
   * Called when the mouse starts dragging an object of this layer.
×
251
   */
×
252
  onDragStart?: ((pickingInfo: PickingInfo, event: MjolnirEvent) => boolean | void) | null;
×
253
  /**
×
254
   * Called when the mouse drags an object of this layer.
×
255
   */
×
256
  onDrag?: ((pickingInfo: PickingInfo, event: MjolnirEvent) => boolean | void) | null;
×
257
  /**
×
258
   * Called when the mouse releases an object of this layer.
×
259
   */
×
260
  onDragEnd?: ((pickingInfo: PickingInfo, event: MjolnirEvent) => boolean | void) | null;
×
261

×
262
  /** (Advanced) supply attribute size externally */
×
263
  numInstances?: number | null;
×
264

×
265
  /** (Advanced) supply variable-width attribute size externally */
×
266
  startIndices?: NumericArray | null;
×
267
};
×
268

×
269
export type CompositeLayerProps = LayerProps & {
×
270
  /** (Experimental) override sub layer props. Only works on a composite layer. */
×
271
  _subLayerProps?: {
×
272
    [subLayerId: string]: {
×
273
      type?: ConstructorOf<Layer>;
×
274
      [propName: string]: any;
×
275
    };
×
276
  } | null;
×
277
};
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc