@deck.gl/core 9.3.0-alpha.3 → 9.3.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/controllers/terrain-controller.d.ts +7 -6
  2. package/dist/controllers/terrain-controller.d.ts.map +1 -1
  3. package/dist/controllers/terrain-controller.js +58 -39
  4. package/dist/controllers/terrain-controller.js.map +1 -1
  5. package/dist/dist.dev.js +3076 -1197
  6. package/dist/index.cjs +525 -212
  7. package/dist/index.cjs.map +4 -4
  8. package/dist/lib/attribute/gl-utils.d.ts +1 -2
  9. package/dist/lib/attribute/gl-utils.d.ts.map +1 -1
  10. package/dist/lib/attribute/gl-utils.js +2 -2
  11. package/dist/lib/attribute/gl-utils.js.map +1 -1
  12. package/dist/lib/deck-picker.d.ts +3 -2
  13. package/dist/lib/deck-picker.d.ts.map +1 -1
  14. package/dist/lib/deck-picker.js +74 -17
  15. package/dist/lib/deck-picker.js.map +1 -1
  16. package/dist/lib/deck.d.ts +62 -0
  17. package/dist/lib/deck.d.ts.map +1 -1
  18. package/dist/lib/deck.js +219 -77
  19. package/dist/lib/deck.js.map +1 -1
  20. package/dist/lib/init.js +2 -2
  21. package/dist/lib/layer.d.ts.map +1 -1
  22. package/dist/lib/layer.js +60 -9
  23. package/dist/lib/layer.js.map +1 -1
  24. package/dist/lib/view-manager.js +1 -1
  25. package/dist/lib/view-manager.js.map +1 -1
  26. package/dist/passes/pick-layers-pass.d.ts.map +1 -1
  27. package/dist/passes/pick-layers-pass.js +7 -2
  28. package/dist/passes/pick-layers-pass.js.map +1 -1
  29. package/dist/passes/screen-pass-uniforms.d.ts +1 -1
  30. package/dist/passes/screen-pass-uniforms.js +1 -1
  31. package/dist/shaderlib/color/color.d.ts +1 -4
  32. package/dist/shaderlib/color/color.d.ts.map +1 -1
  33. package/dist/shaderlib/color/color.js +0 -12
  34. package/dist/shaderlib/color/color.js.map +1 -1
  35. package/dist/shaderlib/misc/layer-uniforms.d.ts +3 -2
  36. package/dist/shaderlib/misc/layer-uniforms.d.ts.map +1 -1
  37. package/dist/shaderlib/misc/layer-uniforms.js +10 -1
  38. package/dist/shaderlib/misc/layer-uniforms.js.map +1 -1
  39. package/dist/shaderlib/picking/picking.d.ts +3 -2
  40. package/dist/shaderlib/picking/picking.d.ts.map +1 -1
  41. package/dist/shaderlib/picking/picking.js +29 -0
  42. package/dist/shaderlib/picking/picking.js.map +1 -1
  43. package/dist/shaderlib/project/project.glsl.js +1 -1
  44. package/dist/shaderlib/project/project.wgsl.d.ts.map +1 -1
  45. package/dist/shaderlib/project/project.wgsl.js +4 -6
  46. package/dist/shaderlib/project/project.wgsl.js.map +1 -1
  47. package/dist/shaderlib/shadow/shadow.d.ts +2 -2
  48. package/dist/shaderlib/shadow/shadow.js +1 -1
  49. package/dist/transitions/gpu-interpolation-transition.js +2 -2
  50. package/dist/transitions/gpu-interpolation-transition.js.map +1 -1
  51. package/dist/transitions/gpu-spring-transition.js +1 -1
  52. package/dist/transitions/gpu-transition-utils.d.ts.map +1 -1
  53. package/dist/transitions/gpu-transition-utils.js +3 -4
  54. package/dist/transitions/gpu-transition-utils.js.map +1 -1
  55. package/dist/utils/typed-array-manager.js.map +1 -1
  56. package/dist.min.js +506 -234
  57. package/package.json +6 -7
  58. package/src/controllers/terrain-controller.ts +60 -51
  59. package/src/lib/attribute/gl-utils.ts +2 -2
  60. package/src/lib/deck-picker.ts +98 -17
  61. package/src/lib/deck.ts +334 -86
  62. package/src/lib/layer.ts +98 -8
  63. package/src/lib/view-manager.ts +1 -1
  64. package/src/passes/pick-layers-pass.ts +6 -2
  65. package/src/passes/screen-pass-uniforms.ts +1 -1
  66. package/src/shaderlib/color/color.ts +0 -12
  67. package/src/shaderlib/misc/layer-uniforms.ts +11 -1
  68. package/src/shaderlib/picking/picking.ts +30 -0
  69. package/src/shaderlib/project/project.glsl.ts +1 -1
  70. package/src/shaderlib/project/project.wgsl.ts +4 -6
  71. package/src/shaderlib/shadow/shadow.ts +1 -1
  72. package/src/transitions/gpu-interpolation-transition.ts +2 -2
  73. package/src/transitions/gpu-spring-transition.ts +1 -1
  74. package/src/transitions/gpu-transition-utils.ts +4 -5
  75. package/src/utils/typed-array-manager.ts +3 -3
@@ -148,8 +148,12 @@ export default class PickLayersPass extends LayersPass {
148
148
  // Encode pickable layers that include 'draw' operation (including 'terrain+draw')
149
149
  Object.assign(pickParameters, PICKING_BLENDING);
150
150
  pickParameters.blend = true;
151
- // TODO: blendColor no longer part of luma.gl API
152
- pickParameters.blendColor = encodeColor(this._colorEncoderState, layer, viewport);
151
+ if (this.device.type === 'webgpu') {
152
+ // WebGPU uses render-pass dynamic state for constant blending.
153
+ pickParameters.blendConstant = encodeColor(this._colorEncoderState, layer, viewport);
154
+ } else {
155
+ pickParameters.blendColor = encodeColor(this._colorEncoderState, layer, viewport);
156
+ }
153
157
  if (operation.includes('terrain') && layer.state?._hasPickingCover) {
154
158
  // For terrain+draw layers with a valid cover FBO, the terrain shader outputs the
155
159
  // cover FBO pixel which already has correctly encoded alpha from the cover encoder.
@@ -6,7 +6,7 @@ import type {TextureView} from '@luma.gl/core';
6
6
  import type {ShaderModule} from '@luma.gl/shadertools';
7
7
 
8
8
  const uniformBlock = `\
9
- uniform screenUniforms {
9
+ layout(std140) uniform screenUniforms {
10
10
  vec2 texSize;
11
11
  } screen;
12
12
  `;
@@ -7,15 +7,6 @@ import {LayerProps} from '../../types/layer-props';
7
7
 
8
8
  const colorWGSL = /* WGSL */ `
9
9
 
10
- struct ColorUniforms {
11
- opacity: f32,
12
- };
13
-
14
- var<private> color: ColorUniforms = ColorUniforms(1.0);
15
- // TODO (kaapp) avoiding binding index collisions to handle layer opacity
16
- // requires some thought.
17
- // @group(0) @binding(0) var<uniform> color: ColorUniforms;
18
-
19
10
  @must_use
20
11
  fn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {
21
12
  return vec4(fragColor.rgb * fragColor.a, fragColor.a);
@@ -43,9 +34,6 @@ export default {
43
34
  // TODO - v10: use raw opacity?
44
35
  // opacity: Math.pow(props.opacity!, 1 / 2.2)
45
36
  return {};
46
- },
47
- uniformTypes: {
48
- opacity: 'f32'
49
37
  }
50
38
  // @ts-ignore TODO v9.1
51
39
  } as const satisfies ShaderModule<LayerProps, ColorUniforms, {}>;
@@ -5,8 +5,17 @@
5
5
  import type {ShaderModule} from '@luma.gl/shadertools';
6
6
  import type {LayerProps} from '../../types/layer-props';
7
7
 
8
+ const uniformBlockWGSL = /* wgsl */ `\
9
+ struct LayerUniforms {
10
+ opacity: f32,
11
+ };
12
+
13
+ @group(0) @binding(auto)
14
+ var<uniform> layer: LayerUniforms;
15
+ `;
16
+
8
17
  const uniformBlock = `\
9
- uniform layerUniforms {
18
+ layout(std140) uniform layerUniforms {
10
19
  uniform float opacity;
11
20
  } layer;
12
21
  `;
@@ -17,6 +26,7 @@ export type LayerUniforms = {
17
26
 
18
27
  export const layerUniforms = {
19
28
  name: 'layer',
29
+ source: uniformBlockWGSL,
20
30
  vs: uniformBlock,
21
31
  fs: uniformBlock,
22
32
  getUniforms: (props: Partial<LayerProps>) => {
@@ -4,8 +4,38 @@
4
4
 
5
5
  import {picking} from '@luma.gl/shadertools';
6
6
 
7
+ const sourceWGSL = /* wgsl */ `\
8
+ struct pickingUniforms {
9
+ isActive: f32,
10
+ isAttribute: f32,
11
+ isHighlightActive: f32,
12
+ useFloatColors: f32,
13
+ highlightedObjectColor: vec3<f32>,
14
+ highlightColor: vec4<f32>,
15
+ };
16
+
17
+ @group(0) @binding(auto) var<uniform> picking: pickingUniforms;
18
+
19
+ fn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> {
20
+ return select(color / 255.0, color, picking.useFloatColors > 0.5);
21
+ }
22
+
23
+ fn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> {
24
+ return select(color / 255.0, color, picking.useFloatColors > 0.5);
25
+ }
26
+
27
+ fn picking_isColorZero(color: vec3<f32>) -> bool {
28
+ return dot(color, vec3<f32>(1.0)) < 0.00001;
29
+ }
30
+
31
+ fn picking_isColorValid(color: vec3<f32>) -> bool {
32
+ return dot(color, vec3<f32>(1.0)) > 0.00001;
33
+ }
34
+ `;
35
+
7
36
  export default {
8
37
  ...picking,
38
+ source: sourceWGSL,
9
39
  defaultUniforms: {...picking.defaultUniforms, useFloatColors: false},
10
40
  inject: {
11
41
  'vs:DECKGL_FILTER_GL_POSITION': `
@@ -20,7 +20,7 @@ ${COORDINATE_SYSTEM_GLSL_CONSTANTS}
20
20
  ${PROJECTION_MODE_GLSL_CONSTANTS}
21
21
  ${UNIT_GLSL_CONSTANTS}
22
22
 
23
- uniform projectUniforms {
23
+ layout(std140) uniform projectUniforms {
24
24
  bool wrapLongitude;
25
25
  int coordinateSystem;
26
26
  vec3 commonUnitsPerMeter;
@@ -50,14 +50,13 @@ struct ProjectUniforms {
50
50
  pseudoMeters: i32,
51
51
  };
52
52
 
53
- @group(0) @binding(0)
53
+ @group(0) @binding(auto)
54
54
  var<uniform> project: ProjectUniforms;
55
55
 
56
56
  // -----------------------------------------------------------------------------
57
- // Geometry data
58
- // (In your GLSL code, "geometry" was assumed to be available globally. In WGSL,
59
- // you might supply this via vertex attributes or a uniform. Here we define a
60
- // uniform struct for demonstration.)
57
+ // Geometry data shared across the project helpers.
58
+ // The active layer shader is responsible for populating this private module
59
+ // state before calling the project functions below.
61
60
  // -----------------------------------------------------------------------------
62
61
 
63
62
  // Structure to carry additional geometry data used by deck.gl filters.
@@ -70,7 +69,6 @@ struct Geometry {
70
69
  pickingColor: vec3<f32>,
71
70
  };
72
71
 
73
- // @group(0) @binding(1)
74
72
  var<private> geometry: Geometry;
75
73
  `;
76
74
 
@@ -15,7 +15,7 @@ import type Viewport from '../../viewports/viewport';
15
15
  import type {ProjectProps, ProjectUniforms} from '../project/viewport-uniforms';
16
16
 
17
17
  const uniformBlock = /* glsl */ `
18
- uniform shadowUniforms {
18
+ layout(std140) uniform shadowUniforms {
19
19
  bool drawShadowMap;
20
20
  bool useShadowMap;
21
21
  vec4 color;
@@ -6,7 +6,7 @@ import type {Device} from '@luma.gl/core';
6
6
  import {Timeline, BufferTransform} from '@luma.gl/engine';
7
7
  import {fp64arithmetic} from '@luma.gl/shadertools';
8
8
  import type {ShaderModule} from '@luma.gl/shadertools';
9
- import {GL} from '@luma.gl/constants';
9
+ import {GL} from '@luma.gl/webgl/constants';
10
10
  import Attribute from '../lib/attribute/attribute';
11
11
  import {
12
12
  getAttributeTypeFromSize,
@@ -112,7 +112,7 @@ export default class GPUInterpolationTransition extends GPUTransitionBase<Interp
112
112
  }
113
113
 
114
114
  const uniformBlock = `\
115
- uniform interpolationUniforms {
115
+ layout(std140) uniform interpolationUniforms {
116
116
  float time;
117
117
  } interpolation;
118
118
  `;
@@ -116,7 +116,7 @@ export default class GPUSpringTransition extends GPUTransitionBase<SpringTransit
116
116
  }
117
117
 
118
118
  const uniformBlock = `\
119
- uniform springUniforms {
119
+ layout(std140) uniform springUniforms {
120
120
  float damping;
121
121
  float stiffness;
122
122
  } spring;
@@ -6,7 +6,7 @@ import type {Device, Buffer, VertexFormat} from '@luma.gl/core';
6
6
  import {padArray} from '../utils/array-utils';
7
7
  import {NumericArray, TypedArray, TypedArrayConstructor} from '../types/types';
8
8
  import Attribute from '../lib/attribute/attribute';
9
- import {GL} from '@luma.gl/constants';
9
+ import {GL} from '@luma.gl/webgl/constants';
10
10
 
11
11
  /** Create a new empty attribute with the same settings: type, shader layout etc. */
12
12
  export function cloneAttribute(attribute: Attribute): Attribute {
@@ -150,9 +150,8 @@ export function padBuffer({
150
150
  ? (attribute.value as TypedArray)
151
151
  : // TODO(v9.1): Avoid non-portable synchronous reads.
152
152
  new ArrayType(
153
- attribute
154
- .getBuffer()!
155
- .readSyncWebGL(byteOffset, toLength * ArrayType.BYTES_PER_ELEMENT).buffer
153
+ attribute.getBuffer()!.readSyncWebGL(byteOffset, toLength * ArrayType.BYTES_PER_ELEMENT)
154
+ .buffer as ArrayBuffer
156
155
  );
157
156
  if (attribute.settings.normalized && !isConstant) {
158
157
  const getter = getData;
@@ -166,7 +165,7 @@ export function padBuffer({
166
165
 
167
166
  // TODO(v9.1): Avoid non-portable synchronous reads.
168
167
  const source = buffer
169
- ? new Float32Array(buffer.readSyncWebGL(targetByteOffset, fromLength * 4).buffer)
168
+ ? new Float32Array(buffer.readSyncWebGL(targetByteOffset, fromLength * 4).buffer as ArrayBuffer)
170
169
  : new Float32Array(0);
171
170
  const target = new Float32Array(toLength);
172
171
  padArray({
@@ -52,7 +52,7 @@ export class TypedArrayManager {
52
52
  return typedArray;
53
53
  }
54
54
  if (newSize * typedArray.BYTES_PER_ELEMENT <= typedArray.buffer.byteLength) {
55
- return new Type(typedArray.buffer, 0, newSize) as T;
55
+ return new Type(typedArray.buffer as ArrayBuffer, 0, newSize) as T;
56
56
  }
57
57
  }
58
58
 
@@ -119,9 +119,9 @@ export class TypedArrayManager {
119
119
  const {byteLength} = buffer;
120
120
  const i = pool.findIndex(b => b.byteLength >= byteLength);
121
121
  if (i < 0) {
122
- pool.push(buffer);
122
+ pool.push(buffer as ArrayBuffer);
123
123
  } else if (i > 0 || pool.length < this.opts.poolSize) {
124
- pool.splice(i, 0, buffer);
124
+ pool.splice(i, 0, buffer as ArrayBuffer);
125
125
  }
126
126
  if (pool.length > this.opts.poolSize) {
127
127
  // Drop the smallest one