@deck.gl-community/infovis-layers 9.3.8 → 9.4.0-alpha.1
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/dist/index.cjs +1840 -1420
- package/dist/index.cjs.map +4 -4
- package/dist/layers/block-layer/block-layer-uniforms.d.ts +4 -3
- package/dist/layers/block-layer/block-layer-uniforms.d.ts.map +1 -1
- package/dist/layers/block-layer/block-layer-uniforms.js +4 -3
- package/dist/layers/block-layer/block-layer-uniforms.js.map +1 -1
- package/dist/layers/block-layer/block-layer-vertex.glsl.d.ts +1 -1
- package/dist/layers/block-layer/block-layer-vertex.glsl.js +4 -4
- package/dist/layers/block-layer/block-layer.d.ts +2 -0
- package/dist/layers/block-layer/block-layer.d.ts.map +1 -1
- package/dist/layers/block-layer/block-layer.js +23 -2
- package/dist/layers/block-layer/block-layer.js.map +1 -1
- package/dist/layers/block-layer/block-layer.wgsl.d.ts +4 -0
- package/dist/layers/block-layer/block-layer.wgsl.d.ts.map +1 -0
- package/dist/layers/block-layer/block-layer.wgsl.js +134 -0
- package/dist/layers/block-layer/block-layer.wgsl.js.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layer.d.ts +47 -0
- package/dist/layers/fast-text-layer/fast-text-layer.d.ts.map +1 -1
- package/dist/layers/fast-text-layer/fast-text-layer.js +5 -1
- package/dist/layers/fast-text-layer/fast-text-layer.js.map +1 -1
- package/dist/layers/fast-text-layer/fast-text-layer.wgsl.d.ts +4 -0
- package/dist/layers/fast-text-layer/fast-text-layer.wgsl.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layer.wgsl.js +247 -0
- package/dist/layers/fast-text-layer/fast-text-layer.wgsl.js.map +1 -0
- package/dist/layers/time-delta-layer.d.ts.map +1 -1
- package/dist/layers/time-delta-layer.js +34 -17
- package/dist/layers/time-delta-layer.js.map +1 -1
- package/package.json +12 -12
- package/src/layers/block-layer/block-layer-uniforms.ts +4 -3
- package/src/layers/block-layer/block-layer-vertex.glsl.ts +4 -4
- package/src/layers/block-layer/block-layer.ts +24 -2
- package/src/layers/block-layer/block-layer.wgsl.ts +134 -0
- package/src/layers/fast-text-layer/fast-text-layer.ts +5 -1
- package/src/layers/fast-text-layer/fast-text-layer.wgsl.ts +247 -0
- package/src/layers/time-delta-layer.ts +34 -17
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/** WebGPU shaders for packed glyphs, following luma.gl's text-rendering conventions. */
|
|
5
|
+
export default /* wgsl */ `
|
|
6
|
+
struct FastTextUniforms {
|
|
7
|
+
fontAtlasSize: vec2<f32>,
|
|
8
|
+
fontSize: f32,
|
|
9
|
+
size: f32,
|
|
10
|
+
sizeScale: f32,
|
|
11
|
+
sizeMinPixels: f32,
|
|
12
|
+
sizeMaxPixels: f32,
|
|
13
|
+
pixelOffset: vec2<f32>,
|
|
14
|
+
billboard: f32,
|
|
15
|
+
sizeUnits: i32,
|
|
16
|
+
alphaCutoff: f32,
|
|
17
|
+
sdfEnabled: f32,
|
|
18
|
+
sdfBuffer: f32,
|
|
19
|
+
sdfGamma: f32,
|
|
20
|
+
contentCutoffPixels: vec2<f32>,
|
|
21
|
+
contentAlign: vec2<i32>,
|
|
22
|
+
flipY: f32,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
@group(0) @binding(auto) var<uniform> fastText: FastTextUniforms;
|
|
26
|
+
@group(0) @binding(auto) var fontAtlasTexture: texture_2d<f32>;
|
|
27
|
+
@group(0) @binding(auto) var fontAtlasTextureSampler: sampler;
|
|
28
|
+
|
|
29
|
+
struct FastTextAttributes {
|
|
30
|
+
@location(0) positions: vec2<f32>,
|
|
31
|
+
@location(1) instancePositions: vec2<f32>,
|
|
32
|
+
@location(2) instanceGlyphOffsets: vec2<i32>,
|
|
33
|
+
@location(3) instanceGlyphFrames: vec4<u32>,
|
|
34
|
+
@location(4) instanceClipRects: vec4<i32>,
|
|
35
|
+
@location(5) instanceColors: vec4<f32>,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
struct FastTextVaryings {
|
|
39
|
+
@builtin(position) position: vec4<f32>,
|
|
40
|
+
@location(0) color: vec4<f32>,
|
|
41
|
+
@location(1) textureCoords: vec2<f32>,
|
|
42
|
+
@location(2) uv: vec2<f32>,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
struct FastTextClipResult {
|
|
46
|
+
position: vec4<f32>,
|
|
47
|
+
pixelOffset: vec2<f32>,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
fn fast_text_alignment_pixel_offset(
|
|
51
|
+
anchor: f32,
|
|
52
|
+
extent: f32,
|
|
53
|
+
clipStart: f32,
|
|
54
|
+
clipEnd: f32,
|
|
55
|
+
mode: i32
|
|
56
|
+
) -> f32 {
|
|
57
|
+
if (clipEnd < clipStart) {
|
|
58
|
+
return 0.0;
|
|
59
|
+
}
|
|
60
|
+
if (mode == 1) {
|
|
61
|
+
return max(-(anchor + clipStart), 0.0);
|
|
62
|
+
}
|
|
63
|
+
if (mode == 2) {
|
|
64
|
+
let visibleMin = max(0.0, anchor + clipStart);
|
|
65
|
+
let visibleMax = min(extent, anchor + clipEnd);
|
|
66
|
+
return select(0.0, (visibleMin + visibleMax) * 0.5 - anchor, visibleMin < visibleMax);
|
|
67
|
+
}
|
|
68
|
+
if (mode == 3) {
|
|
69
|
+
return min(extent - (anchor + clipEnd), 0.0);
|
|
70
|
+
}
|
|
71
|
+
return 0.0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
fn fast_text_clip_glyph_vertex(
|
|
75
|
+
initialPixelOffset: vec2<f32>,
|
|
76
|
+
anchorPositionScreen: vec2<f32>,
|
|
77
|
+
clipRect: vec4<i32>,
|
|
78
|
+
initialPosition: vec4<f32>
|
|
79
|
+
) -> FastTextClipResult {
|
|
80
|
+
var result: FastTextClipResult;
|
|
81
|
+
result.position = initialPosition;
|
|
82
|
+
result.pixelOffset = initialPixelOffset;
|
|
83
|
+
|
|
84
|
+
let clipRectFloat = vec4<f32>(clipRect);
|
|
85
|
+
var clipXY = project_size_vec2(clipRectFloat.xy) * project.scale;
|
|
86
|
+
let clipWH = project_size_vec2(clipRectFloat.zw) * project.scale;
|
|
87
|
+
|
|
88
|
+
if (fastText.flipY > 0.5) {
|
|
89
|
+
clipXY.y = -clipXY.y - clipWH.y;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (fastText.contentAlign.x > 0 || fastText.contentAlign.y > 0) {
|
|
93
|
+
let viewportPixels = project.viewportSize / project.devicePixelRatio;
|
|
94
|
+
let scrollPixels = vec2<f32>(
|
|
95
|
+
fast_text_alignment_pixel_offset(
|
|
96
|
+
anchorPositionScreen.x,
|
|
97
|
+
viewportPixels.x,
|
|
98
|
+
clipXY.x,
|
|
99
|
+
clipXY.x + clipWH.x,
|
|
100
|
+
fastText.contentAlign.x
|
|
101
|
+
),
|
|
102
|
+
-fast_text_alignment_pixel_offset(
|
|
103
|
+
anchorPositionScreen.y,
|
|
104
|
+
viewportPixels.y,
|
|
105
|
+
-clipXY.y - clipWH.y,
|
|
106
|
+
-clipXY.y,
|
|
107
|
+
fastText.contentAlign.y
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
result.pixelOffset += scrollPixels;
|
|
111
|
+
result.position = vec4<f32>(
|
|
112
|
+
result.position.xy + project_pixel_size_to_clipspace(scrollPixels),
|
|
113
|
+
result.position.zw
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (clipRectFloat.z >= 0.0) {
|
|
118
|
+
if (result.pixelOffset.x < clipXY.x || result.pixelOffset.x > clipXY.x + clipWH.x) {
|
|
119
|
+
result.position = vec4<f32>(0.0);
|
|
120
|
+
} else if (fastText.contentCutoffPixels.x > 0.0) {
|
|
121
|
+
let viewportWidth = project.viewportSize.x / project.devicePixelRatio;
|
|
122
|
+
let left = max(anchorPositionScreen.x + clipXY.x, 0.0);
|
|
123
|
+
let right = min(anchorPositionScreen.x + clipXY.x + clipWH.x, viewportWidth);
|
|
124
|
+
if (right - left < fastText.contentCutoffPixels.x) {
|
|
125
|
+
result.position = vec4<f32>(0.0);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (clipRectFloat.w >= 0.0) {
|
|
131
|
+
if (result.pixelOffset.y < clipXY.y || result.pixelOffset.y > clipXY.y + clipWH.y) {
|
|
132
|
+
result.position = vec4<f32>(0.0);
|
|
133
|
+
} else if (fastText.contentCutoffPixels.y > 0.0) {
|
|
134
|
+
let viewportHeight = project.viewportSize.y / project.devicePixelRatio;
|
|
135
|
+
let top = max(anchorPositionScreen.y - clipXY.y - clipWH.y, 0.0);
|
|
136
|
+
let bottom = min(anchorPositionScreen.y - clipXY.y, viewportHeight);
|
|
137
|
+
if (bottom - top < fastText.contentCutoffPixels.y) {
|
|
138
|
+
result.position = vec4<f32>(0.0);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@vertex
|
|
147
|
+
fn vertexMain(attributes: FastTextAttributes) -> FastTextVaryings {
|
|
148
|
+
let worldPosition = vec3<f32>(attributes.instancePositions, 0.0);
|
|
149
|
+
geometry.worldPosition = worldPosition;
|
|
150
|
+
geometry.uv = attributes.positions;
|
|
151
|
+
|
|
152
|
+
let glyphFrame = vec4<f32>(attributes.instanceGlyphFrames);
|
|
153
|
+
let glyphSize = glyphFrame.zw;
|
|
154
|
+
let sizePixels = clamp(
|
|
155
|
+
project_unit_size_to_pixel(fastText.size * fastText.sizeScale, fastText.sizeUnits),
|
|
156
|
+
fastText.sizeMinPixels,
|
|
157
|
+
fastText.sizeMaxPixels
|
|
158
|
+
);
|
|
159
|
+
let instanceScale = select(sizePixels / fastText.fontSize, 0.0, fastText.fontSize == 0.0);
|
|
160
|
+
var pixelOffset = vec2<f32>(attributes.instanceGlyphOffsets) + attributes.positions * glyphSize;
|
|
161
|
+
pixelOffset = pixelOffset * instanceScale + fastText.pixelOffset;
|
|
162
|
+
pixelOffset.y = -pixelOffset.y;
|
|
163
|
+
|
|
164
|
+
var clipPosition: vec4<f32>;
|
|
165
|
+
var anchorPositionClip: vec4<f32>;
|
|
166
|
+
|
|
167
|
+
if (fastText.billboard > 0.5) {
|
|
168
|
+
let projected = project_position_to_clipspace_and_commonspace(
|
|
169
|
+
worldPosition,
|
|
170
|
+
vec3<f32>(0.0),
|
|
171
|
+
vec3<f32>(0.0)
|
|
172
|
+
);
|
|
173
|
+
geometry.position = projected.commonPosition;
|
|
174
|
+
anchorPositionClip = projected.clipPosition;
|
|
175
|
+
clipPosition = vec4<f32>(
|
|
176
|
+
projected.clipPosition.xy + project_pixel_size_to_clipspace(pixelOffset),
|
|
177
|
+
projected.clipPosition.zw
|
|
178
|
+
);
|
|
179
|
+
} else {
|
|
180
|
+
var offsetCommon = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0);
|
|
181
|
+
if (fastText.flipY > 0.5) {
|
|
182
|
+
offsetCommon.y = -offsetCommon.y;
|
|
183
|
+
}
|
|
184
|
+
let projected = project_position_to_clipspace_and_commonspace(
|
|
185
|
+
worldPosition,
|
|
186
|
+
vec3<f32>(0.0),
|
|
187
|
+
offsetCommon
|
|
188
|
+
);
|
|
189
|
+
geometry.position = projected.commonPosition;
|
|
190
|
+
anchorPositionClip = project_position_to_clipspace(
|
|
191
|
+
worldPosition,
|
|
192
|
+
vec3<f32>(0.0),
|
|
193
|
+
vec3<f32>(0.0)
|
|
194
|
+
);
|
|
195
|
+
clipPosition = projected.clipPosition;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
let anchorPositionNdc = anchorPositionClip.xy / anchorPositionClip.w;
|
|
199
|
+
let anchorPositionScreen = vec2<f32>(
|
|
200
|
+
anchorPositionNdc.x + 1.0,
|
|
201
|
+
1.0 - anchorPositionNdc.y
|
|
202
|
+
) * 0.5 * project.viewportSize / project.devicePixelRatio;
|
|
203
|
+
let clipped = fast_text_clip_glyph_vertex(
|
|
204
|
+
pixelOffset,
|
|
205
|
+
anchorPositionScreen,
|
|
206
|
+
attributes.instanceClipRects,
|
|
207
|
+
clipPosition
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
var varyings: FastTextVaryings;
|
|
211
|
+
varyings.position = clipped.position;
|
|
212
|
+
varyings.color = attributes.instanceColors;
|
|
213
|
+
varyings.textureCoords =
|
|
214
|
+
(glyphFrame.xy + attributes.positions * glyphSize) / fastText.fontAtlasSize;
|
|
215
|
+
varyings.uv = attributes.positions;
|
|
216
|
+
return varyings;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
@fragment
|
|
220
|
+
fn fragmentMain(varyings: FastTextVaryings) -> @location(0) vec4<f32> {
|
|
221
|
+
geometry.uv = varyings.uv;
|
|
222
|
+
|
|
223
|
+
var alpha = textureSample(
|
|
224
|
+
fontAtlasTexture,
|
|
225
|
+
fontAtlasTextureSampler,
|
|
226
|
+
varyings.textureCoords
|
|
227
|
+
).a;
|
|
228
|
+
|
|
229
|
+
if (fastText.sdfEnabled > 0.5) {
|
|
230
|
+
alpha = smoothstep(
|
|
231
|
+
fastText.sdfBuffer - fastText.sdfGamma,
|
|
232
|
+
fastText.sdfBuffer + fastText.sdfGamma,
|
|
233
|
+
alpha
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
let outputAlpha = alpha * varyings.color.a;
|
|
238
|
+
if (outputAlpha < fastText.alphaCutoff) {
|
|
239
|
+
discard;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return deckgl_premultiplied_alpha(
|
|
243
|
+
vec4<f32>(varyings.color.rgb, outputAlpha * layer.opacity)
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
`;
|
|
247
|
+
//# sourceMappingURL=fast-text-layer.wgsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fast-text-layer.wgsl.js","sourceRoot":"","sources":["../../../src/layers/fast-text-layer/fast-text-layer.wgsl.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC,wFAAwF;AACxF,eAAe,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiPzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-delta-layer.d.ts","sourceRoot":"","sources":["../../src/layers/time-delta-layer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAC,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAuB,KAAK,cAAc,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"time-delta-layer.d.ts","sourceRoot":"","sources":["../../src/layers/time-delta-layer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAC,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAuB,KAAK,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAO1E,sDAAsD;AACtD,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,oBAAoB,CAAC;AAEpE,KAAK,oBAAoB,GAAG,IAAI,CAAC,cAAc,EAAE,YAAY,GAAG,cAAc,GAAG,YAAY,CAAC,GAAG;IAC/F,mFAAmF;IACnF,IAAI,EAAE,WAAW,GAAG,cAAc,CAAC;IACnC,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,yGAAyG;IACzG,MAAM,EAAE,OAAO,CAAC;IAEhB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,0EAA0E;AAC1E,qBAAa,cAAe,SAAQ,cAAc,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAChF,OAAgB,SAAS,SAAoB;IAC7C,OAAgB,YAAY,EAAE,YAAY,CAAC,oBAAoB,CAAC,CAe9D;IAEO,YAAY,IAAI,KAAK,EAAE;CA6GjC"}
|
|
@@ -5,6 +5,7 @@ import { CompositeLayer } from '@deck.gl/core';
|
|
|
5
5
|
import { LineLayer, TextLayer } from '@deck.gl/layers';
|
|
6
6
|
// import {PathStyleExtension} from '@deck.gl/extensions';
|
|
7
7
|
import { formatTimeMs } from "../utils/format-utils.js";
|
|
8
|
+
import { FastTextLayer } from "./fast-text-layer/fast-text-layer.js";
|
|
8
9
|
/** Renders a selected time interval as header or viewport guide lines. */
|
|
9
10
|
export class TimeDeltaLayer extends CompositeLayer {
|
|
10
11
|
static layerName = 'TimeDeltaLayer';
|
|
@@ -54,6 +55,7 @@ export class TimeDeltaLayer extends CompositeLayer {
|
|
|
54
55
|
const timeDeltaPosition = [(startTimeMs + endTimeMs) / 2, y - 10];
|
|
55
56
|
const timeDeltaMs = Math.abs(endTimeMs - startTimeMs);
|
|
56
57
|
const timeDeltaLabel = formatTimeMs(timeDeltaMs, { space: false });
|
|
58
|
+
const labelData = [{ position: timeDeltaPosition, text: timeDeltaLabel }];
|
|
57
59
|
const timeLines = [
|
|
58
60
|
{
|
|
59
61
|
sourcePosition: [startTimeMs, y],
|
|
@@ -91,23 +93,38 @@ export class TimeDeltaLayer extends CompositeLayer {
|
|
|
91
93
|
widthUnits: 'pixels'
|
|
92
94
|
}),
|
|
93
95
|
// Label
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
96
|
+
this.context?.device?.type === 'webgpu'
|
|
97
|
+
? new FastTextLayer({
|
|
98
|
+
id: 'header-time-delta-label',
|
|
99
|
+
data: labelData,
|
|
100
|
+
getPosition: d => d.position,
|
|
101
|
+
getText: d => d.text,
|
|
102
|
+
characterSet: '-0123456789.dhmsµ',
|
|
103
|
+
size: fontSize,
|
|
104
|
+
fontFamily,
|
|
105
|
+
fontSettings,
|
|
106
|
+
fontWeight,
|
|
107
|
+
getColor: color,
|
|
108
|
+
textAnchor: 'middle',
|
|
109
|
+
alignmentBaseline: 'center'
|
|
110
|
+
})
|
|
111
|
+
: new TextLayer({
|
|
112
|
+
id: 'header-time-delta-label',
|
|
113
|
+
data: labelData,
|
|
114
|
+
getPosition: d => d.position,
|
|
115
|
+
getText: d => d.text,
|
|
116
|
+
characterSet: '-0123456789.dhmsµ',
|
|
117
|
+
getSize: fontSize,
|
|
118
|
+
fontFamily,
|
|
119
|
+
fontSettings,
|
|
120
|
+
fontWeight,
|
|
121
|
+
getColor: color,
|
|
122
|
+
getTextAnchor: 'middle',
|
|
123
|
+
getAlignmentBaseline: 'center',
|
|
124
|
+
background: true,
|
|
125
|
+
getBackgroundColor: [255 - color[0], 255 - color[1], 255 - color[2], 255],
|
|
126
|
+
backgroundPadding: [4, 2]
|
|
127
|
+
})
|
|
111
128
|
];
|
|
112
129
|
}
|
|
113
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-delta-layer.js","sourceRoot":"","sources":["../../src/layers/time-delta-layer.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,cAAc,EAAiD,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAC,SAAS,EAAE,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAE1E,0DAA0D;AAE1D,OAAO,EAAC,YAAY,EAAC,iCAA8B;
|
|
1
|
+
{"version":3,"file":"time-delta-layer.js","sourceRoot":"","sources":["../../src/layers/time-delta-layer.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,cAAc,EAAiD,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAC,SAAS,EAAE,SAAS,EAAsB,MAAM,iBAAiB,CAAC;AAE1E,0DAA0D;AAE1D,OAAO,EAAC,YAAY,EAAC,iCAA8B;AACnD,OAAO,EAAC,aAAa,EAAC,6CAA0C;AAgChE,0EAA0E;AAC1E,MAAM,OAAO,cAAe,SAAQ,cAA8C;IAChF,MAAM,CAAU,SAAS,GAAG,gBAAgB,CAAC;IAC7C,MAAM,CAAU,YAAY,GAAuC;QACjE,MAAM,EAAE,KAAK;QACb,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,GAAG;QACd,CAAC,EAAE,CAAC;QACJ,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC;QACrB,IAAI,EAAE,WAAW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BACzE,iBAAiB,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;iBAC1B,CAAC;SACP,CAAC;IACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deck.gl-community/infovis-layers",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0-alpha.1",
|
|
4
4
|
"description": "Infovis layers (non-geospatial) for deck.gl",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"test-watch": "vitest"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@luma.gl/shadertools": "~9.
|
|
36
|
+
"@luma.gl/shadertools": "~9.4.0-alpha.1",
|
|
37
37
|
"@probe.gl/log": "^4.1.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@deck.gl/core": "~9.
|
|
41
|
-
"@deck.gl/layers": "~9.
|
|
42
|
-
"@luma.gl/core": "~9.
|
|
43
|
-
"@luma.gl/engine": "~9.
|
|
40
|
+
"@deck.gl/core": "~9.4.0-alpha.2",
|
|
41
|
+
"@deck.gl/layers": "~9.4.0-alpha.2",
|
|
42
|
+
"@luma.gl/core": "~9.4.0-alpha.1",
|
|
43
|
+
"@luma.gl/engine": "~9.4.0-alpha.1",
|
|
44
44
|
"apache-arrow": ">=17"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@deck.gl/core": "~9.
|
|
53
|
-
"@deck.gl/test-utils": "~9.
|
|
54
|
-
"@luma.gl/core": "~9.
|
|
55
|
-
"@luma.gl/engine": "~9.
|
|
56
|
-
"@luma.gl/webgpu": "~9.
|
|
52
|
+
"@deck.gl/core": "~9.4.0-alpha.2",
|
|
53
|
+
"@deck.gl/test-utils": "~9.4.0-alpha.2",
|
|
54
|
+
"@luma.gl/core": "~9.4.0-alpha.1",
|
|
55
|
+
"@luma.gl/engine": "~9.4.0-alpha.1",
|
|
56
|
+
"@luma.gl/webgpu": "~9.4.0-alpha.1",
|
|
57
57
|
"@probe.gl/test-utils": "^4.1.1"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "410922945889b5202c7fd72e19c2aafaf10fea1b"
|
|
60
60
|
}
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
6
6
|
|
|
7
7
|
const glslUniformBlock = `\
|
|
8
|
-
uniform
|
|
8
|
+
uniform blockLayerUniforms {
|
|
9
9
|
highp int sizeUnits;
|
|
10
10
|
highp float widthMinPixels;
|
|
11
11
|
highp float heightMinPixels;
|
|
12
12
|
highp float sizeMaxPixels;
|
|
13
13
|
highp int lineWidthUnits;
|
|
14
|
-
}
|
|
14
|
+
} blockLayer;
|
|
15
15
|
`;
|
|
16
16
|
|
|
17
17
|
/** Shader uniform values used by {@link BlockLayer}. */
|
|
@@ -30,7 +30,8 @@ export type BlockProps = {
|
|
|
30
30
|
|
|
31
31
|
/** Shader module that defines uniforms consumed by {@link BlockLayer}. */
|
|
32
32
|
export const blockUniforms = {
|
|
33
|
-
name: '
|
|
33
|
+
name: 'blockLayer',
|
|
34
|
+
source: '',
|
|
34
35
|
vs: glslUniformBlock,
|
|
35
36
|
fs: glslUniformBlock,
|
|
36
37
|
uniformTypes: {
|
|
@@ -43,12 +43,12 @@ void main(void) {
|
|
|
43
43
|
geometry.pickingColor = instancePickingColors;
|
|
44
44
|
geometry.uv = positions.xy;
|
|
45
45
|
|
|
46
|
-
vec2 pixelSize = project_size_to_pixel(instanceSizes,
|
|
47
|
-
pixelSize.x = clamp_signed_size(pixelSize.x,
|
|
48
|
-
pixelSize.y = clamp_signed_size(pixelSize.y,
|
|
46
|
+
vec2 pixelSize = project_size_to_pixel(instanceSizes, blockLayer.sizeUnits);
|
|
47
|
+
pixelSize.x = clamp_signed_size(pixelSize.x, blockLayer.widthMinPixels, blockLayer.sizeMaxPixels);
|
|
48
|
+
pixelSize.y = clamp_signed_size(pixelSize.y, blockLayer.heightMinPixels, blockLayer.sizeMaxPixels);
|
|
49
49
|
unitPosition = positions.xy;
|
|
50
50
|
size = pixelSize;
|
|
51
|
-
lineWidth = project_size_to_pixel(vec2(instanceLineWidths, 0.0),
|
|
51
|
+
lineWidth = project_size_to_pixel(vec2(instanceLineWidths, 0.0), blockLayer.lineWidthUnits).x;
|
|
52
52
|
|
|
53
53
|
// Find the center of the point and add the current vertex
|
|
54
54
|
vec3 offset = vec3(unitPosition * project_pixel_size(pixelSize), 0.0);
|
|
@@ -23,6 +23,7 @@ import {Geometry, Model} from '@luma.gl/engine';
|
|
|
23
23
|
import fs from './block-layer-fragment.glsl';
|
|
24
24
|
import {BlockProps, blockUniforms} from './block-layer-uniforms';
|
|
25
25
|
import vs from './block-layer-vertex.glsl';
|
|
26
|
+
import source from './block-layer.wgsl';
|
|
26
27
|
|
|
27
28
|
const DEFAULT_COLOR: [number, number, number, number] = [0, 0, 0, 255];
|
|
28
29
|
|
|
@@ -114,12 +115,18 @@ export class BlockLayer<DataT = any, ExtraPropsT extends {} = {}> extends Layer<
|
|
|
114
115
|
|
|
115
116
|
override getShaders() {
|
|
116
117
|
return super.getShaders({
|
|
118
|
+
source,
|
|
117
119
|
vs,
|
|
118
120
|
fs,
|
|
119
121
|
modules: [project32, color, picking, blockUniforms]
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
|
|
125
|
+
/** WebGPU consumes float32 positions directly, including external binary attributes. */
|
|
126
|
+
override use64bitPositions(): boolean {
|
|
127
|
+
return this.context?.device?.type !== 'webgpu' && super.use64bitPositions();
|
|
128
|
+
}
|
|
129
|
+
|
|
123
130
|
initializeState() {
|
|
124
131
|
this.getAttributeManager()!.addInstanced({
|
|
125
132
|
instancePositions: {
|
|
@@ -176,17 +183,32 @@ export class BlockLayer<DataT = any, ExtraPropsT extends {} = {}> extends Layer<
|
|
|
176
183
|
sizeMaxPixels,
|
|
177
184
|
lineWidthUnits: UNIT[lineWidthUnits]
|
|
178
185
|
};
|
|
179
|
-
model.shaderInputs.setProps({
|
|
186
|
+
model.shaderInputs.setProps({blockLayer: blockProps});
|
|
180
187
|
model.draw(this.context.renderPass);
|
|
181
188
|
}
|
|
182
189
|
|
|
183
190
|
protected _getModel(): Model {
|
|
184
191
|
// a square
|
|
185
192
|
const positions = [0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0];
|
|
193
|
+
const bufferLayout = this.getAttributeManager()!.getBufferLayouts();
|
|
194
|
+
const webgpuAttributes = new Set([
|
|
195
|
+
'instancePositions',
|
|
196
|
+
'instanceSizes',
|
|
197
|
+
'instanceLineWidths',
|
|
198
|
+
'instanceLineColors',
|
|
199
|
+
'instanceFillColors',
|
|
200
|
+
'instancePickingColors'
|
|
201
|
+
]);
|
|
202
|
+
const webgpuBufferLayout = bufferLayout
|
|
203
|
+
.map(layout => ({
|
|
204
|
+
...layout,
|
|
205
|
+
attributes: layout.attributes?.filter(({attribute}) => webgpuAttributes.has(attribute))
|
|
206
|
+
}))
|
|
207
|
+
.filter(layout => !layout.attributes || layout.attributes.length > 0);
|
|
186
208
|
return new Model(this.context.device, {
|
|
187
209
|
...this.getShaders(),
|
|
188
210
|
id: this.props.id,
|
|
189
|
-
bufferLayout: this.
|
|
211
|
+
bufferLayout: this.context.device.type === 'webgpu' ? webgpuBufferLayout : bufferLayout,
|
|
190
212
|
geometry: new Geometry({
|
|
191
213
|
topology: 'triangle-strip',
|
|
192
214
|
attributes: {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// deck.gl-community
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/** WebGPU vertex and fragment shaders for {@link BlockLayer}. */
|
|
6
|
+
export default /* wgsl */ `
|
|
7
|
+
struct BlockUniforms {
|
|
8
|
+
sizeUnits: i32,
|
|
9
|
+
widthMinPixels: f32,
|
|
10
|
+
heightMinPixels: f32,
|
|
11
|
+
sizeMaxPixels: f32,
|
|
12
|
+
lineWidthUnits: i32,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
@group(0) @binding(auto) var<uniform> blockLayer: BlockUniforms;
|
|
16
|
+
|
|
17
|
+
struct BlockAttributes {
|
|
18
|
+
@location(0) positions: vec3<f32>,
|
|
19
|
+
@location(1) instancePositions: vec3<f32>,
|
|
20
|
+
@location(2) instanceSizes: vec2<f32>,
|
|
21
|
+
@location(3) instanceLineWidths: f32,
|
|
22
|
+
@location(4) instanceLineColors: vec4<f32>,
|
|
23
|
+
@location(5) instanceFillColors: vec4<f32>,
|
|
24
|
+
@location(6) instancePickingColors: vec3<f32>,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
struct BlockVaryings {
|
|
28
|
+
@builtin(position) position: vec4<f32>,
|
|
29
|
+
@location(0) unitPosition: vec2<f32>,
|
|
30
|
+
@location(1) @interpolate(flat) fillColor: vec4<f32>,
|
|
31
|
+
@location(2) @interpolate(flat) lineColor: vec4<f32>,
|
|
32
|
+
@location(3) @interpolate(flat) lineWidth: f32,
|
|
33
|
+
@location(4) @interpolate(flat) size: vec2<f32>,
|
|
34
|
+
@location(5) @interpolate(flat) pickingColor: vec3<f32>,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
fn block_size_to_pixels(size: vec2<f32>, unit: i32) -> vec2<f32> {
|
|
38
|
+
return vec2<f32>(
|
|
39
|
+
project_unit_size_to_pixel(size.x, unit),
|
|
40
|
+
project_unit_size_to_pixel(size.y, unit)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
fn block_clamp_signed_size(size: f32, minimum: f32, maximum: f32) -> f32 {
|
|
45
|
+
return select(1.0, -1.0, size < 0.0) * clamp(abs(size), minimum, maximum);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@vertex
|
|
49
|
+
fn vertexMain(attributes: BlockAttributes) -> BlockVaryings {
|
|
50
|
+
geometry.worldPosition = attributes.instancePositions;
|
|
51
|
+
geometry.pickingColor = attributes.instancePickingColors;
|
|
52
|
+
geometry.uv = attributes.positions.xy;
|
|
53
|
+
|
|
54
|
+
var pixelSize = block_size_to_pixels(attributes.instanceSizes, blockLayer.sizeUnits);
|
|
55
|
+
pixelSize.x = block_clamp_signed_size(
|
|
56
|
+
pixelSize.x,
|
|
57
|
+
blockLayer.widthMinPixels,
|
|
58
|
+
blockLayer.sizeMaxPixels
|
|
59
|
+
);
|
|
60
|
+
pixelSize.y = block_clamp_signed_size(
|
|
61
|
+
pixelSize.y,
|
|
62
|
+
blockLayer.heightMinPixels,
|
|
63
|
+
blockLayer.sizeMaxPixels
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
let offset = vec3<f32>(
|
|
67
|
+
attributes.positions.xy * project_pixel_size_vec2(pixelSize),
|
|
68
|
+
0.0
|
|
69
|
+
);
|
|
70
|
+
let projected = project_position_to_clipspace_and_commonspace(
|
|
71
|
+
attributes.instancePositions,
|
|
72
|
+
vec3<f32>(0.0),
|
|
73
|
+
offset
|
|
74
|
+
);
|
|
75
|
+
geometry.position = projected.commonPosition;
|
|
76
|
+
|
|
77
|
+
var varyings: BlockVaryings;
|
|
78
|
+
varyings.position = projected.clipPosition;
|
|
79
|
+
varyings.unitPosition = attributes.positions.xy;
|
|
80
|
+
varyings.fillColor = vec4<f32>(
|
|
81
|
+
attributes.instanceFillColors.rgb,
|
|
82
|
+
attributes.instanceFillColors.a * layer.opacity
|
|
83
|
+
);
|
|
84
|
+
varyings.lineColor = vec4<f32>(
|
|
85
|
+
attributes.instanceLineColors.rgb,
|
|
86
|
+
attributes.instanceLineColors.a * layer.opacity
|
|
87
|
+
);
|
|
88
|
+
varyings.lineWidth = project_unit_size_to_pixel(
|
|
89
|
+
attributes.instanceLineWidths,
|
|
90
|
+
blockLayer.lineWidthUnits
|
|
91
|
+
);
|
|
92
|
+
varyings.size = pixelSize;
|
|
93
|
+
varyings.pickingColor = attributes.instancePickingColors;
|
|
94
|
+
return varyings;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@fragment
|
|
98
|
+
fn fragmentMain(varyings: BlockVaryings) -> @location(0) vec4<f32> {
|
|
99
|
+
let relativePosition = varyings.unitPosition * varyings.size;
|
|
100
|
+
let distanceToBorder = min(
|
|
101
|
+
min(relativePosition.x, relativePosition.y),
|
|
102
|
+
min(varyings.size.x - relativePosition.x, varyings.size.y - relativePosition.y)
|
|
103
|
+
);
|
|
104
|
+
var fragColor = select(
|
|
105
|
+
varyings.fillColor,
|
|
106
|
+
varyings.lineColor,
|
|
107
|
+
varyings.lineWidth > 0.0 && distanceToBorder <= varyings.lineWidth
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
if (picking.isActive > 0.5) {
|
|
111
|
+
if (!picking_isColorValid(varyings.pickingColor)) {
|
|
112
|
+
discard;
|
|
113
|
+
}
|
|
114
|
+
return vec4<f32>(picking_normalizeColor(varyings.pickingColor), 1.0);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (picking.isHighlightActive > 0.5) {
|
|
118
|
+
let highlightedColor = picking_normalizeColor(picking.highlightedObjectColor);
|
|
119
|
+
let objectColor = picking_normalizeColor(varyings.pickingColor);
|
|
120
|
+
if (picking_isColorZero(abs(objectColor - highlightedColor))) {
|
|
121
|
+
let highlightAlpha = picking.highlightColor.a;
|
|
122
|
+
let blendedAlpha = highlightAlpha + fragColor.a * (1.0 - highlightAlpha);
|
|
123
|
+
if (blendedAlpha > 0.0) {
|
|
124
|
+
fragColor = vec4<f32>(
|
|
125
|
+
mix(fragColor.rgb, picking.highlightColor.rgb, highlightAlpha / blendedAlpha),
|
|
126
|
+
blendedAlpha
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return deckgl_premultiplied_alpha(fragColor);
|
|
133
|
+
}
|
|
134
|
+
`;
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
updateFastTextDynamicGlyphAttributes
|
|
15
15
|
} from './fast-text-layout';
|
|
16
16
|
import {DEFAULT_FAST_TEXT_FONT_SETTINGS, FastTextFontAtlasManager} from './font-atlas';
|
|
17
|
+
import FAST_TEXT_WGSL from './fast-text-layer.wgsl';
|
|
17
18
|
|
|
18
19
|
import type {
|
|
19
20
|
FastTextAlignmentBaseline,
|
|
@@ -158,6 +159,7 @@ export class FastTextLayer<DataT = any, ExtraPropsT extends {} = {}> extends Lay
|
|
|
158
159
|
/** Return the shader set used by the direct glyph instance model. */
|
|
159
160
|
override getShaders() {
|
|
160
161
|
return super.getShaders({
|
|
162
|
+
source: FAST_TEXT_WGSL,
|
|
161
163
|
vs: FAST_TEXT_VS,
|
|
162
164
|
fs: FAST_TEXT_FS,
|
|
163
165
|
modules: [project32, color, fastTextUniforms]
|
|
@@ -535,8 +537,10 @@ const fastTextLog = new Log({id: 'trace-layers'});
|
|
|
535
537
|
const FAST_TEXT_PROBE_LABEL_STYLE =
|
|
536
538
|
'background:#f59e0b;color:#111827;font-weight:700;padding:2px 8px;border-radius:6px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;';
|
|
537
539
|
|
|
538
|
-
|
|
540
|
+
/** Shader module shared by the GLSL and WGSL packed-glyph renderers. */
|
|
541
|
+
export const fastTextUniforms = {
|
|
539
542
|
name: 'fastText',
|
|
543
|
+
source: '',
|
|
540
544
|
vs: `\
|
|
541
545
|
layout(std140) uniform fastTextUniforms {
|
|
542
546
|
vec2 fontAtlasSize;
|