@deck.gl/aggregation-layers 9.3.7 → 9.4.0-alpha.2
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/common/aggregation-layer.d.ts.map +1 -1
- package/dist/common/aggregation-layer.js +1 -3
- package/dist/common/aggregation-layer.js.map +1 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.d.ts.map +1 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js +1 -3
- package/dist/common/aggregator/gpu-aggregator/webgl-aggregation-transform.js.map +1 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js +0 -1
- package/dist/common/aggregator/gpu-aggregator/webgl-bin-sorter.js.map +1 -1
- package/dist/dist.dev.js +502 -32
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts +1 -1
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.d.ts.map +1 -1
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.js +1 -2
- package/dist/grid-layer/grid-cell-layer-vertex.glsl.js.map +1 -1
- package/dist/grid-layer/grid-cell-layer.d.ts.map +1 -1
- package/dist/grid-layer/grid-cell-layer.js +2 -1
- package/dist/grid-layer/grid-cell-layer.js.map +1 -1
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts +2 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer-uniforms.js +19 -0
- package/dist/heatmap-layer/heatmap-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/heatmap-layer.js +59 -12
- package/dist/heatmap-layer/heatmap-layer.js.map +1 -1
- package/dist/heatmap-layer/max.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/max.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/max.wgsl.js +48 -0
- package/dist/heatmap-layer/max.wgsl.js.map +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts +1 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer-uniforms.js +16 -0
- package/dist/heatmap-layer/triangle-layer-uniforms.js.map +1 -1
- package/dist/heatmap-layer/triangle-layer.d.ts.map +1 -1
- package/dist/heatmap-layer/triangle-layer.js +3 -2
- package/dist/heatmap-layer/triangle-layer.js.map +1 -1
- package/dist/heatmap-layer/triangle-layer.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.js +65 -0
- package/dist/heatmap-layer/triangle-layer.wgsl.js.map +1 -0
- package/dist/heatmap-layer/weights.wgsl.d.ts +3 -0
- package/dist/heatmap-layer/weights.wgsl.d.ts.map +1 -0
- package/dist/heatmap-layer/weights.wgsl.js +64 -0
- package/dist/heatmap-layer/weights.wgsl.js.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js +1 -2
- package/dist/hexagon-layer/hexagon-cell-layer-vertex.glsl.js.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer.js +2 -1
- package/dist/hexagon-layer/hexagon-cell-layer.js.map +1 -1
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts +3 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js +120 -0
- package/dist/hexagon-layer/hexagon-cell-layer.wgsl.js.map +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts +1 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.d.ts.map +1 -1
- package/dist/hexagon-layer/hexagon-layer-uniforms.js +13 -0
- package/dist/hexagon-layer/hexagon-layer-uniforms.js.map +1 -1
- package/dist/index.cjs +502 -32
- package/dist/index.cjs.map +4 -4
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts +1 -6
- package/dist/screen-grid-layer/screen-grid-cell-layer.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.js +3 -2
- package/dist/screen-grid-layer/screen-grid-cell-layer.js.map +1 -1
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts +3 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.d.ts.map +1 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js +76 -0
- package/dist/screen-grid-layer/screen-grid-cell-layer.wgsl.js.map +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts +1 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js +12 -0
- package/dist/screen-grid-layer/screen-grid-layer-uniforms.js.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.d.ts.map +1 -1
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js +1 -2
- package/dist/screen-grid-layer/screen-grid-layer-vertex.glsl.js.map +1 -1
- package/dist.min.js +428 -40
- package/package.json +11 -7
- package/src/common/aggregation-layer.ts +1 -3
- package/src/common/aggregator/gpu-aggregator/webgl-aggregation-transform.ts +1 -3
- package/src/common/aggregator/gpu-aggregator/webgl-bin-sorter.ts +0 -1
- package/src/grid-layer/grid-cell-layer-vertex.glsl.ts +1 -2
- package/src/grid-layer/grid-cell-layer.ts +2 -1
- package/src/heatmap-layer/heatmap-layer-uniforms.ts +20 -0
- package/src/heatmap-layer/heatmap-layer.ts +67 -13
- package/src/heatmap-layer/max.wgsl.ts +48 -0
- package/src/heatmap-layer/triangle-layer-uniforms.ts +17 -0
- package/src/heatmap-layer/triangle-layer.ts +3 -2
- package/src/heatmap-layer/triangle-layer.wgsl.ts +65 -0
- package/src/heatmap-layer/weights.wgsl.ts +64 -0
- package/src/hexagon-layer/hexagon-cell-layer-vertex.glsl.ts +1 -2
- package/src/hexagon-layer/hexagon-cell-layer.ts +2 -1
- package/src/hexagon-layer/hexagon-cell-layer.wgsl.ts +120 -0
- package/src/hexagon-layer/hexagon-layer-uniforms.ts +14 -0
- package/src/screen-grid-layer/screen-grid-cell-layer.ts +4 -4
- package/src/screen-grid-layer/screen-grid-cell-layer.wgsl.ts +76 -0
- package/src/screen-grid-layer/screen-grid-layer-uniforms.ts +13 -0
- package/src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts +1 -2
package/dist/dist.dev.js
CHANGED
|
@@ -631,7 +631,6 @@ void main() {
|
|
|
631
631
|
const model = new import_engine.Model(device, {
|
|
632
632
|
bufferLayout: props.bufferLayout,
|
|
633
633
|
modules: [...props.modules || [], binSorterUniforms],
|
|
634
|
-
// @ts-expect-error TODO fix luma type
|
|
635
634
|
defines: { ...props.defines, NON_INSTANCED_MODEL: 1, NUM_CHANNELS: props.channelCount },
|
|
636
635
|
isInstanced: false,
|
|
637
636
|
vs,
|
|
@@ -745,6 +744,7 @@ void main() {
|
|
|
745
744
|
transform.run({
|
|
746
745
|
id: "gpu-aggregation-domain",
|
|
747
746
|
framebuffer: target,
|
|
747
|
+
discard: false,
|
|
748
748
|
parameters: {
|
|
749
749
|
viewport: [0, 0, 2, 1]
|
|
750
750
|
},
|
|
@@ -872,11 +872,8 @@ void main() {
|
|
|
872
872
|
blendAlphaOperation: "max"
|
|
873
873
|
},
|
|
874
874
|
defines: {
|
|
875
|
-
// @ts-expect-error TODO fix luma type
|
|
876
875
|
NUM_DIMS: props.dimensions,
|
|
877
|
-
// @ts-expect-error TODO fix luma type
|
|
878
876
|
NUM_CHANNELS: props.channelCount,
|
|
879
|
-
// @ts-expect-error TODO fix luma type
|
|
880
877
|
SAMPLER_WIDTH: TEXTURE_WIDTH
|
|
881
878
|
},
|
|
882
879
|
varyings: ["binIds", "values"],
|
|
@@ -1077,7 +1074,6 @@ void main() {
|
|
|
1077
1074
|
return true;
|
|
1078
1075
|
}
|
|
1079
1076
|
initializeState() {
|
|
1080
|
-
this.getAttributeManager().remove(["instancePickingColors"]);
|
|
1081
1077
|
}
|
|
1082
1078
|
// Extend Layer.updateState to update the Aggregator instance
|
|
1083
1079
|
// returns true if aggregator is changed
|
|
@@ -1147,11 +1143,11 @@ void main() {
|
|
|
1147
1143
|
flatArray = new ArrayType(colorRange.length * 4);
|
|
1148
1144
|
let index = 0;
|
|
1149
1145
|
for (let i = 0; i < colorRange.length; i++) {
|
|
1150
|
-
const
|
|
1151
|
-
flatArray[index++] =
|
|
1152
|
-
flatArray[index++] =
|
|
1153
|
-
flatArray[index++] =
|
|
1154
|
-
flatArray[index++] = Number.isFinite(
|
|
1146
|
+
const color3 = colorRange[i];
|
|
1147
|
+
flatArray[index++] = color3[0];
|
|
1148
|
+
flatArray[index++] = color3[1];
|
|
1149
|
+
flatArray[index++] = color3[2];
|
|
1150
|
+
flatArray[index++] = Number.isFinite(color3[3]) ? color3[3] : 255;
|
|
1155
1151
|
}
|
|
1156
1152
|
}
|
|
1157
1153
|
if (normalize) {
|
|
@@ -1189,6 +1185,83 @@ void main() {
|
|
|
1189
1185
|
});
|
|
1190
1186
|
}
|
|
1191
1187
|
|
|
1188
|
+
// src/screen-grid-layer/screen-grid-cell-layer.wgsl.ts
|
|
1189
|
+
var screen_grid_cell_layer_wgsl_default = (
|
|
1190
|
+
/* wgsl */
|
|
1191
|
+
`
|
|
1192
|
+
struct Attributes {
|
|
1193
|
+
@builtin(instance_index) instanceIndex: u32,
|
|
1194
|
+
@location(0) positions: vec2<f32>,
|
|
1195
|
+
@location(1) instancePositions: vec2<f32>,
|
|
1196
|
+
@location(2) instanceWeights: f32,
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
struct Varyings {
|
|
1200
|
+
@builtin(position) position: vec4<f32>,
|
|
1201
|
+
@location(0) color: vec4<f32>,
|
|
1202
|
+
@location(1) pickingColor: vec3<f32>,
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
|
|
1206
|
+
let ratio = (value - domain.x) / (domain.y - domain.x);
|
|
1207
|
+
return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
@vertex
|
|
1211
|
+
fn vertexMain(attributes: Attributes) -> Varyings {
|
|
1212
|
+
var output: Varyings;
|
|
1213
|
+
output.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
|
|
1214
|
+
|
|
1215
|
+
if (attributes.instanceWeights != attributes.instanceWeights) {
|
|
1216
|
+
output.position = vec4<f32>(0.0);
|
|
1217
|
+
output.color = vec4<f32>(0.0);
|
|
1218
|
+
return output;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
var position =
|
|
1222
|
+
attributes.instancePositions * screenGrid.gridSizeClipspace +
|
|
1223
|
+
attributes.positions * screenGrid.cellSizeClipspace;
|
|
1224
|
+
position.x -= 1.0;
|
|
1225
|
+
position.y = 1.0 - position.y;
|
|
1226
|
+
|
|
1227
|
+
output.position = vec4<f32>(position, 0.0, 1.0);
|
|
1228
|
+
let colorValue = sampleColorRange(attributes.instanceWeights, screenGrid.colorDomain);
|
|
1229
|
+
output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
|
|
1230
|
+
return output;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
@fragment
|
|
1234
|
+
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
|
1235
|
+
if (picking.isActive > 0.5) {
|
|
1236
|
+
if (!picking_isColorValid(varyings.pickingColor)) {
|
|
1237
|
+
discard;
|
|
1238
|
+
}
|
|
1239
|
+
return vec4<f32>(varyings.pickingColor, 1.0);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
var color = varyings.color;
|
|
1243
|
+
if (picking.isHighlightActive > 0.5) {
|
|
1244
|
+
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
|
1245
|
+
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
|
|
1246
|
+
let highLightAlpha = picking.highlightColor.a;
|
|
1247
|
+
let blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
|
|
1248
|
+
if (blendedAlpha > 0.0) {
|
|
1249
|
+
let highLightRatio = highLightAlpha / blendedAlpha;
|
|
1250
|
+
color = vec4<f32>(
|
|
1251
|
+
mix(color.rgb, picking.highlightColor.rgb, highLightRatio),
|
|
1252
|
+
blendedAlpha
|
|
1253
|
+
);
|
|
1254
|
+
} else {
|
|
1255
|
+
color = vec4<f32>(color.rgb, 0.0);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
return deckgl_premultiplied_alpha(color);
|
|
1261
|
+
}
|
|
1262
|
+
`
|
|
1263
|
+
);
|
|
1264
|
+
|
|
1192
1265
|
// src/screen-grid-layer/screen-grid-layer-vertex.glsl.ts
|
|
1193
1266
|
var screen_grid_layer_vertex_glsl_default = (
|
|
1194
1267
|
/* glsl */
|
|
@@ -1199,7 +1272,6 @@ void main() {
|
|
|
1199
1272
|
in vec2 positions;
|
|
1200
1273
|
in vec2 instancePositions;
|
|
1201
1274
|
in float instanceWeights;
|
|
1202
|
-
in vec3 instancePickingColors;
|
|
1203
1275
|
|
|
1204
1276
|
uniform sampler2D colorRange;
|
|
1205
1277
|
|
|
@@ -1226,7 +1298,7 @@ void main(void) {
|
|
|
1226
1298
|
vColor.a *= layer.opacity;
|
|
1227
1299
|
|
|
1228
1300
|
// Set color to be rendered to picking fbo (also used to check for selection highlight).
|
|
1229
|
-
|
|
1301
|
+
picking_setPickingColorFromInstanceID();
|
|
1230
1302
|
}
|
|
1231
1303
|
`
|
|
1232
1304
|
);
|
|
@@ -1252,6 +1324,20 @@ void main(void) {
|
|
|
1252
1324
|
);
|
|
1253
1325
|
|
|
1254
1326
|
// src/screen-grid-layer/screen-grid-layer-uniforms.ts
|
|
1327
|
+
var uniformBlockWGSL = (
|
|
1328
|
+
/* wgsl */
|
|
1329
|
+
`
|
|
1330
|
+
struct ScreenGridUniforms {
|
|
1331
|
+
cellSizeClipspace: vec2<f32>,
|
|
1332
|
+
gridSizeClipspace: vec2<f32>,
|
|
1333
|
+
colorDomain: vec2<f32>,
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1336
|
+
@group(0) @binding(auto) var<uniform> screenGrid: ScreenGridUniforms;
|
|
1337
|
+
@group(0) @binding(auto) var colorRange: texture_2d<f32>;
|
|
1338
|
+
@group(0) @binding(auto) var colorRangeSampler: sampler;
|
|
1339
|
+
`
|
|
1340
|
+
);
|
|
1255
1341
|
var uniformBlock3 = (
|
|
1256
1342
|
/* glsl */
|
|
1257
1343
|
`layout(std140) uniform screenGridUniforms {
|
|
@@ -1263,6 +1349,7 @@ void main(void) {
|
|
|
1263
1349
|
);
|
|
1264
1350
|
var screenGridUniforms = {
|
|
1265
1351
|
name: "screenGrid",
|
|
1352
|
+
source: uniformBlockWGSL,
|
|
1266
1353
|
vs: uniformBlock3,
|
|
1267
1354
|
uniformTypes: {
|
|
1268
1355
|
cellSizeClipspace: "vec2<f32>",
|
|
@@ -1274,7 +1361,7 @@ void main(void) {
|
|
|
1274
1361
|
// src/screen-grid-layer/screen-grid-cell-layer.ts
|
|
1275
1362
|
var ScreenGridCellLayer = class extends import_core4.Layer {
|
|
1276
1363
|
getShaders() {
|
|
1277
|
-
return super.getShaders({ vs: screen_grid_layer_vertex_glsl_default, fs: screen_grid_layer_fragment_glsl_default, modules: [import_core4.picking, screenGridUniforms] });
|
|
1364
|
+
return super.getShaders({ source: screen_grid_cell_layer_wgsl_default, vs: screen_grid_layer_vertex_glsl_default, fs: screen_grid_layer_fragment_glsl_default, modules: [import_core4.color, import_core4.picking, screenGridUniforms] });
|
|
1278
1365
|
}
|
|
1279
1366
|
initializeState() {
|
|
1280
1367
|
this.getAttributeManager().addInstanced({
|
|
@@ -1742,6 +1829,126 @@ void main(void) {
|
|
|
1742
1829
|
// src/hexagon-layer/hexagon-cell-layer.ts
|
|
1743
1830
|
var import_layers2 = __toESM(require_layers(), 1);
|
|
1744
1831
|
|
|
1832
|
+
// src/hexagon-layer/hexagon-cell-layer.wgsl.ts
|
|
1833
|
+
var hexagon_cell_layer_wgsl_default = (
|
|
1834
|
+
/* wgsl */
|
|
1835
|
+
`const HEXBIN_DISTANCE: vec2<f32> = vec2<f32>(1.7320508, 1.5);
|
|
1836
|
+
|
|
1837
|
+
struct Attributes {
|
|
1838
|
+
@builtin(instance_index) instanceIndex: u32,
|
|
1839
|
+
@location(0) positions: vec3<f32>,
|
|
1840
|
+
@location(1) normals: vec3<f32>,
|
|
1841
|
+
@location(2) instancePositions: vec2<f32>,
|
|
1842
|
+
@location(3) instanceColorValues: f32,
|
|
1843
|
+
@location(4) instanceElevationValues: f32,
|
|
1844
|
+
};
|
|
1845
|
+
|
|
1846
|
+
struct Varyings {
|
|
1847
|
+
@builtin(position) position: vec4<f32>,
|
|
1848
|
+
@location(0) color: vec4<f32>,
|
|
1849
|
+
@location(1) pickingColor: vec3<f32>,
|
|
1850
|
+
};
|
|
1851
|
+
|
|
1852
|
+
fn hexbinCentroid(binId: vec2<f32>, radius: f32) -> vec2<f32> {
|
|
1853
|
+
var adjustedBinId = binId;
|
|
1854
|
+
adjustedBinId.x += fract(adjustedBinId.y * 0.5);
|
|
1855
|
+
return adjustedBinId * HEXBIN_DISTANCE * radius;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
fn interpolate(value: f32, domain: vec2<f32>, range: vec2<f32>) -> f32 {
|
|
1859
|
+
let ratio = clamp((value - domain.x) / (domain.y - domain.x), 0.0, 1.0);
|
|
1860
|
+
return mix(range.x, range.y, ratio);
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
fn sampleColorRange(value: f32, domain: vec2<f32>) -> vec4<f32> {
|
|
1864
|
+
let ratio = (value - domain.x) / (domain.y - domain.x);
|
|
1865
|
+
return textureSampleLevel(colorRange, colorRangeSampler, vec2<f32>(ratio, 0.5), 0.0);
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
@vertex
|
|
1869
|
+
fn vertexMain(attributes: Attributes) -> Varyings {
|
|
1870
|
+
var output: Varyings;
|
|
1871
|
+
geometry.pickingColor = picking_getPickingColorFromIndex(attributes.instanceIndex);
|
|
1872
|
+
output.pickingColor = geometry.pickingColor;
|
|
1873
|
+
|
|
1874
|
+
if (
|
|
1875
|
+
attributes.instanceColorValues != attributes.instanceColorValues ||
|
|
1876
|
+
attributes.instanceColorValues < hexagon.colorDomain.z ||
|
|
1877
|
+
attributes.instanceColorValues > hexagon.colorDomain.w ||
|
|
1878
|
+
attributes.instanceElevationValues < hexagon.elevationDomain.z ||
|
|
1879
|
+
attributes.instanceElevationValues > hexagon.elevationDomain.w
|
|
1880
|
+
) {
|
|
1881
|
+
output.position = vec4<f32>(0.0);
|
|
1882
|
+
output.color = vec4<f32>(0.0);
|
|
1883
|
+
return output;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
var commonPosition =
|
|
1887
|
+
hexbinCentroid(attributes.instancePositions, column.radius) +
|
|
1888
|
+
(hexagon.originCommon - project.commonOrigin.xy);
|
|
1889
|
+
commonPosition += attributes.positions.xy * column.radius * column.coverage;
|
|
1890
|
+
geometry.position = vec4<f32>(commonPosition, 0.0, 1.0);
|
|
1891
|
+
geometry.normal = project_normal(attributes.normals);
|
|
1892
|
+
|
|
1893
|
+
if (column.extruded > 0.5) {
|
|
1894
|
+
var elevation = interpolate(
|
|
1895
|
+
attributes.instanceElevationValues,
|
|
1896
|
+
hexagon.elevationDomain.xy,
|
|
1897
|
+
hexagon.elevationRange
|
|
1898
|
+
);
|
|
1899
|
+
elevation = project_size_float(elevation);
|
|
1900
|
+
geometry.position.z = (attributes.positions.z + 1.0) / 2.0 * elevation;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
output.position = project_common_position_to_clipspace(geometry.position);
|
|
1904
|
+
var colorValue = sampleColorRange(attributes.instanceColorValues, hexagon.colorDomain.xy);
|
|
1905
|
+
if (column.extruded > 0.5) {
|
|
1906
|
+
colorValue = vec4<f32>(
|
|
1907
|
+
lighting_getLightColor2(
|
|
1908
|
+
colorValue.rgb,
|
|
1909
|
+
project.cameraPosition,
|
|
1910
|
+
geometry.position.xyz,
|
|
1911
|
+
geometry.normal
|
|
1912
|
+
),
|
|
1913
|
+
colorValue.a
|
|
1914
|
+
);
|
|
1915
|
+
}
|
|
1916
|
+
output.color = vec4<f32>(colorValue.rgb, colorValue.a * layer.opacity);
|
|
1917
|
+
return output;
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
@fragment
|
|
1921
|
+
fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> {
|
|
1922
|
+
if (picking.isActive > 0.5) {
|
|
1923
|
+
if (!picking_isColorValid(varyings.pickingColor)) {
|
|
1924
|
+
discard;
|
|
1925
|
+
}
|
|
1926
|
+
return vec4<f32>(varyings.pickingColor, 1.0);
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
var color = varyings.color;
|
|
1930
|
+
if (picking.isHighlightActive > 0.5) {
|
|
1931
|
+
let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);
|
|
1932
|
+
if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) {
|
|
1933
|
+
let highLightAlpha = picking.highlightColor.a;
|
|
1934
|
+
let blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);
|
|
1935
|
+
if (blendedAlpha > 0.0) {
|
|
1936
|
+
let highLightRatio = highLightAlpha / blendedAlpha;
|
|
1937
|
+
color = vec4<f32>(
|
|
1938
|
+
mix(color.rgb, picking.highlightColor.rgb, highLightRatio),
|
|
1939
|
+
blendedAlpha
|
|
1940
|
+
);
|
|
1941
|
+
} else {
|
|
1942
|
+
color = vec4<f32>(color.rgb, 0.0);
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
|
|
1947
|
+
return deckgl_premultiplied_alpha(color);
|
|
1948
|
+
}
|
|
1949
|
+
`
|
|
1950
|
+
);
|
|
1951
|
+
|
|
1745
1952
|
// src/hexagon-layer/hexbin.ts
|
|
1746
1953
|
var THIRD_PI = Math.PI / 3;
|
|
1747
1954
|
var DIST_X = 2 * Math.sin(THIRD_PI);
|
|
@@ -1817,7 +2024,6 @@ in vec3 normals;
|
|
|
1817
2024
|
in vec2 instancePositions;
|
|
1818
2025
|
in float instanceElevationValues;
|
|
1819
2026
|
in float instanceColorValues;
|
|
1820
|
-
in vec3 instancePickingColors;
|
|
1821
2027
|
|
|
1822
2028
|
uniform sampler2D colorRange;
|
|
1823
2029
|
|
|
@@ -1837,7 +2043,7 @@ vec4 interp(float value, vec2 domain, sampler2D range) {
|
|
|
1837
2043
|
}
|
|
1838
2044
|
|
|
1839
2045
|
void main(void) {
|
|
1840
|
-
geometry.pickingColor =
|
|
2046
|
+
geometry.pickingColor = picking_getPickingColorFromInstanceID();
|
|
1841
2047
|
|
|
1842
2048
|
if (isnan(instanceColorValues) ||
|
|
1843
2049
|
instanceColorValues < hexagon.colorDomain.z ||
|
|
@@ -1877,6 +2083,20 @@ void main(void) {
|
|
|
1877
2083
|
);
|
|
1878
2084
|
|
|
1879
2085
|
// src/hexagon-layer/hexagon-layer-uniforms.ts
|
|
2086
|
+
var uniformBlockWGSL2 = (
|
|
2087
|
+
/* wgsl */
|
|
2088
|
+
`struct HexagonUniforms {
|
|
2089
|
+
colorDomain: vec4<f32>,
|
|
2090
|
+
elevationDomain: vec4<f32>,
|
|
2091
|
+
elevationRange: vec2<f32>,
|
|
2092
|
+
originCommon: vec2<f32>,
|
|
2093
|
+
};
|
|
2094
|
+
|
|
2095
|
+
@group(0) @binding(auto) var<uniform> hexagon: HexagonUniforms;
|
|
2096
|
+
@group(0) @binding(auto) var colorRange: texture_2d<f32>;
|
|
2097
|
+
@group(0) @binding(auto) var colorRangeSampler: sampler;
|
|
2098
|
+
`
|
|
2099
|
+
);
|
|
1880
2100
|
var uniformBlock5 = (
|
|
1881
2101
|
/* glsl */
|
|
1882
2102
|
`layout(std140) uniform hexagonUniforms {
|
|
@@ -1889,6 +2109,7 @@ void main(void) {
|
|
|
1889
2109
|
);
|
|
1890
2110
|
var hexagonUniforms = {
|
|
1891
2111
|
name: "hexagon",
|
|
2112
|
+
source: uniformBlockWGSL2,
|
|
1892
2113
|
vs: uniformBlock5,
|
|
1893
2114
|
uniformTypes: {
|
|
1894
2115
|
colorDomain: "vec4<f32>",
|
|
@@ -1903,7 +2124,7 @@ void main(void) {
|
|
|
1903
2124
|
getShaders() {
|
|
1904
2125
|
const shaders = super.getShaders();
|
|
1905
2126
|
shaders.modules.push(hexagonUniforms);
|
|
1906
|
-
return { ...shaders, vs: hexagon_cell_layer_vertex_glsl_default };
|
|
2127
|
+
return { ...shaders, source: hexagon_cell_layer_wgsl_default, vs: hexagon_cell_layer_vertex_glsl_default };
|
|
1907
2128
|
}
|
|
1908
2129
|
initializeState() {
|
|
1909
2130
|
super.initializeState();
|
|
@@ -4875,7 +5096,6 @@ in vec3 normals;
|
|
|
4875
5096
|
in vec2 instancePositions;
|
|
4876
5097
|
in float instanceElevationValues;
|
|
4877
5098
|
in float instanceColorValues;
|
|
4878
|
-
in vec3 instancePickingColors;
|
|
4879
5099
|
|
|
4880
5100
|
uniform sampler2D colorRange;
|
|
4881
5101
|
|
|
@@ -4893,7 +5113,7 @@ vec4 interp(float value, vec2 domain, sampler2D range) {
|
|
|
4893
5113
|
}
|
|
4894
5114
|
|
|
4895
5115
|
void main(void) {
|
|
4896
|
-
geometry.pickingColor =
|
|
5116
|
+
geometry.pickingColor = picking_getPickingColorFromInstanceID();
|
|
4897
5117
|
|
|
4898
5118
|
if (isnan(instanceColorValues) ||
|
|
4899
5119
|
instanceColorValues < grid.colorDomain.z ||
|
|
@@ -5012,7 +5232,8 @@ void main(void) {
|
|
|
5012
5232
|
}
|
|
5013
5233
|
_updateGeometry() {
|
|
5014
5234
|
const geometry = new import_engine4.CubeGeometry();
|
|
5015
|
-
this.
|
|
5235
|
+
this._setFillGeometry(geometry);
|
|
5236
|
+
this._setWireframeGeometry(geometry);
|
|
5016
5237
|
}
|
|
5017
5238
|
draw({ uniforms }) {
|
|
5018
5239
|
const {
|
|
@@ -5498,6 +5719,71 @@ void main(void) {
|
|
|
5498
5719
|
var import_engine5 = __toESM(require_engine(), 1);
|
|
5499
5720
|
var import_core10 = __toESM(require_core(), 1);
|
|
5500
5721
|
|
|
5722
|
+
// src/heatmap-layer/triangle-layer.wgsl.ts
|
|
5723
|
+
var triangle_layer_wgsl_default = (
|
|
5724
|
+
/* wgsl */
|
|
5725
|
+
`struct TriangleAttributes {
|
|
5726
|
+
@location(0) positions: vec3<f32>,
|
|
5727
|
+
@location(1) texCoords: vec2<f32>,
|
|
5728
|
+
};
|
|
5729
|
+
|
|
5730
|
+
struct TriangleVaryings {
|
|
5731
|
+
@builtin(position) position: vec4<f32>,
|
|
5732
|
+
@location(0) textureCoordinates: vec2<f32>,
|
|
5733
|
+
@location(1) intensityMinimum: f32,
|
|
5734
|
+
@location(2) intensityMaximum: f32,
|
|
5735
|
+
};
|
|
5736
|
+
|
|
5737
|
+
@vertex
|
|
5738
|
+
fn vertexMain(attributes: TriangleAttributes) -> TriangleVaryings {
|
|
5739
|
+
var output: TriangleVaryings;
|
|
5740
|
+
output.position = project_position_to_clipspace(
|
|
5741
|
+
attributes.positions,
|
|
5742
|
+
vec3<f32>(0.0),
|
|
5743
|
+
vec3<f32>(0.0)
|
|
5744
|
+
);
|
|
5745
|
+
// WebGPU render-target textures use a top-left origin.
|
|
5746
|
+
output.textureCoordinates = vec2<f32>(attributes.texCoords.x, 1.0 - attributes.texCoords.y);
|
|
5747
|
+
|
|
5748
|
+
let maxWeights = textureLoad(maxTexture, vec2<i32>(0), 0);
|
|
5749
|
+
var maximumValue = select(maxWeights.r, maxWeights.g, triangle.aggregationMode > 0.5);
|
|
5750
|
+
var minimumValue = maximumValue * triangle.threshold;
|
|
5751
|
+
|
|
5752
|
+
if (triangle.colorDomain.y > 0.0) {
|
|
5753
|
+
maximumValue = triangle.colorDomain.y;
|
|
5754
|
+
minimumValue = triangle.colorDomain.x;
|
|
5755
|
+
}
|
|
5756
|
+
|
|
5757
|
+
output.intensityMaximum = triangle.intensity / maximumValue;
|
|
5758
|
+
output.intensityMinimum = triangle.intensity / minimumValue;
|
|
5759
|
+
return output;
|
|
5760
|
+
}
|
|
5761
|
+
|
|
5762
|
+
@fragment
|
|
5763
|
+
fn fragmentMain(varyings: TriangleVaryings) -> @location(0) vec4<f32> {
|
|
5764
|
+
let weights = textureSample(weightsTexture, weightsTextureSampler, varyings.textureCoordinates);
|
|
5765
|
+
var weight = weights.r;
|
|
5766
|
+
|
|
5767
|
+
if (triangle.aggregationMode > 0.5) {
|
|
5768
|
+
weight /= max(1.0, weights.a);
|
|
5769
|
+
}
|
|
5770
|
+
|
|
5771
|
+
let colorCoordinates = vec2<f32>(
|
|
5772
|
+
clamp(weight * varyings.intensityMaximum, 0.0, 1.0),
|
|
5773
|
+
0.5
|
|
5774
|
+
);
|
|
5775
|
+
var color = textureSample(colorTexture, colorTextureSampler, colorCoordinates);
|
|
5776
|
+
|
|
5777
|
+
if (weight <= 0.0) {
|
|
5778
|
+
discard;
|
|
5779
|
+
}
|
|
5780
|
+
|
|
5781
|
+
color.a *= min(weight * varyings.intensityMinimum, 1.0) * layer.opacity;
|
|
5782
|
+
return deckgl_premultiplied_alpha(color);
|
|
5783
|
+
}
|
|
5784
|
+
`
|
|
5785
|
+
);
|
|
5786
|
+
|
|
5501
5787
|
// src/heatmap-layer/triangle-layer-vertex.glsl.ts
|
|
5502
5788
|
var triangle_layer_vertex_glsl_default = `#version 300 es
|
|
5503
5789
|
#define SHADER_NAME heatp-map-layer-vertex-shader
|
|
@@ -5569,6 +5855,23 @@ void main(void) {
|
|
|
5569
5855
|
`;
|
|
5570
5856
|
|
|
5571
5857
|
// src/heatmap-layer/triangle-layer-uniforms.ts
|
|
5858
|
+
var uniformBlockWGSL3 = (
|
|
5859
|
+
/* wgsl */
|
|
5860
|
+
`struct triangleUniforms {
|
|
5861
|
+
aggregationMode: f32,
|
|
5862
|
+
colorDomain: vec2<f32>,
|
|
5863
|
+
intensity: f32,
|
|
5864
|
+
threshold: f32,
|
|
5865
|
+
};
|
|
5866
|
+
|
|
5867
|
+
@group(0) @binding(auto) var<uniform> triangle: triangleUniforms;
|
|
5868
|
+
@group(0) @binding(auto) var colorTexture: texture_2d<f32>;
|
|
5869
|
+
@group(0) @binding(auto) var colorTextureSampler: sampler;
|
|
5870
|
+
@group(0) @binding(auto) var maxTexture: texture_2d<f32>;
|
|
5871
|
+
@group(0) @binding(auto) var weightsTexture: texture_2d<f32>;
|
|
5872
|
+
@group(0) @binding(auto) var weightsTextureSampler: sampler;
|
|
5873
|
+
`
|
|
5874
|
+
);
|
|
5572
5875
|
var uniformBlock10 = `layout(std140) uniform triangleUniforms {
|
|
5573
5876
|
float aggregationMode;
|
|
5574
5877
|
vec2 colorDomain;
|
|
@@ -5578,6 +5881,7 @@ void main(void) {
|
|
|
5578
5881
|
`;
|
|
5579
5882
|
var triangleUniforms = {
|
|
5580
5883
|
name: "triangle",
|
|
5884
|
+
source: uniformBlockWGSL3,
|
|
5581
5885
|
vs: uniformBlock10,
|
|
5582
5886
|
fs: uniformBlock10,
|
|
5583
5887
|
uniformTypes: {
|
|
@@ -5591,7 +5895,7 @@ void main(void) {
|
|
|
5591
5895
|
// src/heatmap-layer/triangle-layer.ts
|
|
5592
5896
|
var TriangleLayer = class extends import_core10.Layer {
|
|
5593
5897
|
getShaders() {
|
|
5594
|
-
return super.getShaders({ vs: triangle_layer_vertex_glsl_default, fs: triangle_layer_fragment_glsl_default, modules: [import_core10.project32, triangleUniforms] });
|
|
5898
|
+
return super.getShaders({ source: triangle_layer_wgsl_default, vs: triangle_layer_vertex_glsl_default, fs: triangle_layer_fragment_glsl_default, modules: [import_core10.project32, import_core10.color, triangleUniforms] });
|
|
5595
5899
|
}
|
|
5596
5900
|
initializeState({ device }) {
|
|
5597
5901
|
this.setState({ model: this._getModel(device) });
|
|
@@ -5844,7 +6148,131 @@ void main() {
|
|
|
5844
6148
|
}
|
|
5845
6149
|
`;
|
|
5846
6150
|
|
|
6151
|
+
// src/heatmap-layer/max.wgsl.ts
|
|
6152
|
+
var max_wgsl_default = (
|
|
6153
|
+
/* wgsl */
|
|
6154
|
+
`struct MaxWeightVaryings {
|
|
6155
|
+
@builtin(position) position: vec4<f32>,
|
|
6156
|
+
@location(0) weights: vec4<f32>,
|
|
6157
|
+
};
|
|
6158
|
+
|
|
6159
|
+
const MAX_WEIGHT_REDUCTION_SIZE: u32 = 16u;
|
|
6160
|
+
|
|
6161
|
+
@vertex
|
|
6162
|
+
fn vertexMain(@builtin(vertex_index) vertexIndex: u32) -> MaxWeightVaryings {
|
|
6163
|
+
var output: MaxWeightVaryings;
|
|
6164
|
+
let textureSize = u32(maxWeight.textureSize);
|
|
6165
|
+
let reducedTextureSize =
|
|
6166
|
+
(textureSize + MAX_WEIGHT_REDUCTION_SIZE - 1u) / MAX_WEIGHT_REDUCTION_SIZE;
|
|
6167
|
+
let blockCoordinates = vec2<u32>(
|
|
6168
|
+
vertexIndex % reducedTextureSize,
|
|
6169
|
+
vertexIndex / reducedTextureSize
|
|
6170
|
+
);
|
|
6171
|
+
var maximumWeights = vec4<f32>(0.0);
|
|
6172
|
+
|
|
6173
|
+
for (var y = 0u; y < MAX_WEIGHT_REDUCTION_SIZE; y++) {
|
|
6174
|
+
for (var x = 0u; x < MAX_WEIGHT_REDUCTION_SIZE; x++) {
|
|
6175
|
+
let textureCoordinates = blockCoordinates * MAX_WEIGHT_REDUCTION_SIZE + vec2<u32>(x, y);
|
|
6176
|
+
|
|
6177
|
+
if (textureCoordinates.x < textureSize && textureCoordinates.y < textureSize) {
|
|
6178
|
+
let weights = textureLoad(inTexture, vec2<i32>(textureCoordinates), 0);
|
|
6179
|
+
maximumWeights.r = max(maximumWeights.r, weights.r);
|
|
6180
|
+
maximumWeights.g = max(maximumWeights.g, weights.r / max(1.0, weights.a));
|
|
6181
|
+
maximumWeights.b = max(maximumWeights.b, weights.b);
|
|
6182
|
+
maximumWeights.a = max(maximumWeights.a, weights.a);
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
}
|
|
6186
|
+
|
|
6187
|
+
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
|
6188
|
+
output.weights = maximumWeights;
|
|
6189
|
+
return output;
|
|
6190
|
+
}
|
|
6191
|
+
|
|
6192
|
+
@fragment
|
|
6193
|
+
fn fragmentMain(varyings: MaxWeightVaryings) -> @location(0) vec4<f32> {
|
|
6194
|
+
return varyings.weights;
|
|
6195
|
+
}
|
|
6196
|
+
`
|
|
6197
|
+
);
|
|
6198
|
+
|
|
6199
|
+
// src/heatmap-layer/weights.wgsl.ts
|
|
6200
|
+
var weights_wgsl_default = (
|
|
6201
|
+
/* wgsl */
|
|
6202
|
+
`struct WeightAttributes {
|
|
6203
|
+
@builtin(vertex_index) vertexIndex: u32,
|
|
6204
|
+
@location(0) instancePositions: vec3<f32>,
|
|
6205
|
+
@location(1) instancePositions64Low: vec3<f32>,
|
|
6206
|
+
@location(2) instanceWeights: f32,
|
|
6207
|
+
};
|
|
6208
|
+
|
|
6209
|
+
struct WeightVaryings {
|
|
6210
|
+
@builtin(position) position: vec4<f32>,
|
|
6211
|
+
@location(0) pointCoordinates: vec2<f32>,
|
|
6212
|
+
@location(1) weights: vec4<f32>,
|
|
6213
|
+
};
|
|
6214
|
+
|
|
6215
|
+
const WEIGHT_QUAD_POSITIONS = array<vec2<f32>, 6>(
|
|
6216
|
+
vec2<f32>(-1.0, -1.0),
|
|
6217
|
+
vec2<f32>(1.0, -1.0),
|
|
6218
|
+
vec2<f32>(-1.0, 1.0),
|
|
6219
|
+
vec2<f32>(-1.0, 1.0),
|
|
6220
|
+
vec2<f32>(1.0, -1.0),
|
|
6221
|
+
vec2<f32>(1.0, 1.0)
|
|
6222
|
+
);
|
|
6223
|
+
|
|
6224
|
+
@vertex
|
|
6225
|
+
fn vertexMain(attributes: WeightAttributes) -> WeightVaryings {
|
|
6226
|
+
var output: WeightVaryings;
|
|
6227
|
+
let commonPosition = project_position_vec3_f64(
|
|
6228
|
+
attributes.instancePositions,
|
|
6229
|
+
attributes.instancePositions64Low
|
|
6230
|
+
);
|
|
6231
|
+
let clipPosition =
|
|
6232
|
+
(commonPosition.xy - weight.commonBounds.xy) /
|
|
6233
|
+
(weight.commonBounds.zw - weight.commonBounds.xy) * 2.0 - vec2<f32>(1.0);
|
|
6234
|
+
let radiusTexels =
|
|
6235
|
+
project_pixel_size_float(weight.radiusPixels) * weight.textureWidth /
|
|
6236
|
+
(weight.commonBounds.z - weight.commonBounds.x);
|
|
6237
|
+
let offset = WEIGHT_QUAD_POSITIONS[attributes.vertexIndex];
|
|
6238
|
+
|
|
6239
|
+
output.position = vec4<f32>(
|
|
6240
|
+
clipPosition + offset * radiusTexels * 2.0 / weight.textureWidth,
|
|
6241
|
+
0.0,
|
|
6242
|
+
1.0
|
|
6243
|
+
);
|
|
6244
|
+
output.pointCoordinates = (offset + vec2<f32>(1.0)) * 0.5;
|
|
6245
|
+
output.weights = vec4<f32>(attributes.instanceWeights * weight.weightsScale, 0.0, 0.0, 1.0);
|
|
6246
|
+
return output;
|
|
6247
|
+
}
|
|
6248
|
+
|
|
6249
|
+
@fragment
|
|
6250
|
+
fn fragmentMain(varyings: WeightVaryings) -> @location(0) vec4<f32> {
|
|
6251
|
+
let distanceFromCenter = length(varyings.pointCoordinates - vec2<f32>(0.5));
|
|
6252
|
+
if (distanceFromCenter > 0.5) {
|
|
6253
|
+
discard;
|
|
6254
|
+
}
|
|
6255
|
+
|
|
6256
|
+
let gaussian = exp(-pow(2.0 * distanceFromCenter, 2.0) / 0.05555) /
|
|
6257
|
+
(1.77245385 * 0.166666);
|
|
6258
|
+
return varyings.weights * gaussian;
|
|
6259
|
+
}
|
|
6260
|
+
`
|
|
6261
|
+
);
|
|
6262
|
+
|
|
5847
6263
|
// src/heatmap-layer/heatmap-layer-uniforms.ts
|
|
6264
|
+
var uniformBlockWGSL4 = (
|
|
6265
|
+
/* wgsl */
|
|
6266
|
+
`struct weightUniforms {
|
|
6267
|
+
commonBounds: vec4<f32>,
|
|
6268
|
+
radiusPixels: f32,
|
|
6269
|
+
textureWidth: f32,
|
|
6270
|
+
weightsScale: f32,
|
|
6271
|
+
};
|
|
6272
|
+
|
|
6273
|
+
@group(0) @binding(auto) var<uniform> weight: weightUniforms;
|
|
6274
|
+
`
|
|
6275
|
+
);
|
|
5848
6276
|
var uniformBlock11 = `layout(std140) uniform weightUniforms {
|
|
5849
6277
|
vec4 commonBounds;
|
|
5850
6278
|
float radiusPixels;
|
|
@@ -5854,6 +6282,7 @@ void main() {
|
|
|
5854
6282
|
`;
|
|
5855
6283
|
var weightUniforms = {
|
|
5856
6284
|
name: "weight",
|
|
6285
|
+
source: uniformBlockWGSL4,
|
|
5857
6286
|
vs: uniformBlock11,
|
|
5858
6287
|
uniformTypes: {
|
|
5859
6288
|
commonBounds: "vec4<f32>",
|
|
@@ -5864,6 +6293,16 @@ void main() {
|
|
|
5864
6293
|
};
|
|
5865
6294
|
var maxWeightUniforms = {
|
|
5866
6295
|
name: "maxWeight",
|
|
6296
|
+
source: (
|
|
6297
|
+
/* wgsl */
|
|
6298
|
+
`struct maxWeightUniforms {
|
|
6299
|
+
textureSize: f32,
|
|
6300
|
+
};
|
|
6301
|
+
|
|
6302
|
+
@group(0) @binding(auto) var<uniform> maxWeight: maxWeightUniforms;
|
|
6303
|
+
@group(0) @binding(auto) var inTexture: texture_2d<f32>;
|
|
6304
|
+
`
|
|
6305
|
+
),
|
|
5867
6306
|
vs: `layout(std140) uniform maxWeightUniforms {
|
|
5868
6307
|
float textureSize;
|
|
5869
6308
|
} maxWeight;
|
|
@@ -5875,6 +6314,7 @@ void main() {
|
|
|
5875
6314
|
|
|
5876
6315
|
// src/heatmap-layer/heatmap-layer.ts
|
|
5877
6316
|
var RESOLUTION = 2;
|
|
6317
|
+
var MAX_WEIGHT_REDUCTION_SIZE = 16;
|
|
5878
6318
|
var TEXTURE_PROPS = {
|
|
5879
6319
|
format: "rgba8unorm",
|
|
5880
6320
|
dimension: "2d",
|
|
@@ -6066,18 +6506,33 @@ void main() {
|
|
|
6066
6506
|
}
|
|
6067
6507
|
_setupAttributes() {
|
|
6068
6508
|
const attributeManager = this.getAttributeManager();
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6509
|
+
if (this.context.device.type === "webgpu") {
|
|
6510
|
+
attributeManager.addInstanced({
|
|
6511
|
+
instancePositions: {
|
|
6512
|
+
size: 3,
|
|
6513
|
+
type: "float64",
|
|
6514
|
+
accessor: "getPosition",
|
|
6515
|
+
// Normalize binary XY positions into the packed XYZ high/low layout WebGPU requires.
|
|
6516
|
+
transform: (position) => [position[0], position[1], position[2] ?? 0]
|
|
6517
|
+
},
|
|
6518
|
+
instanceWeights: { size: 1, accessor: "getWeight" }
|
|
6519
|
+
});
|
|
6520
|
+
this.setState({ positionAttributeName: "instancePositions" });
|
|
6521
|
+
} else {
|
|
6522
|
+
attributeManager.add({
|
|
6523
|
+
positions: { size: 3, type: "float64", accessor: "getPosition" },
|
|
6524
|
+
weights: { size: 1, accessor: "getWeight" }
|
|
6525
|
+
});
|
|
6526
|
+
this.setState({ positionAttributeName: "positions" });
|
|
6527
|
+
}
|
|
6074
6528
|
}
|
|
6075
6529
|
_setupTextureParams() {
|
|
6076
6530
|
const { device } = this.context;
|
|
6077
6531
|
const { weightsTextureSize } = this.props;
|
|
6078
6532
|
const textureSize = Math.min(weightsTextureSize, device.limits.maxTextureDimension2D);
|
|
6079
|
-
const
|
|
6080
|
-
const
|
|
6533
|
+
const isWebGPU = device.type === "webgpu";
|
|
6534
|
+
const floatTargetSupport = isWebGPU ? device.getTextureFormatCapabilities("rgba16float").blend : FLOAT_TARGET_FEATURES.every((feature) => device.features.has(feature));
|
|
6535
|
+
const format = floatTargetSupport ? isWebGPU ? "rgba16float" : "rgba32float" : "rgba8unorm";
|
|
6081
6536
|
const weightsScale = floatTargetSupport ? 1 : 1 / 255;
|
|
6082
6537
|
this.setState({ textureSize, format, weightsScale });
|
|
6083
6538
|
if (!floatTargetSupport) {
|
|
@@ -6089,13 +6544,20 @@ void main() {
|
|
|
6089
6544
|
_createWeightsTransform(shaders) {
|
|
6090
6545
|
let { weightsTransform } = this.state;
|
|
6091
6546
|
const { weightsTexture } = this.state;
|
|
6547
|
+
const isWebGPU = this.context.device.type === "webgpu";
|
|
6092
6548
|
const attributeManager = this.getAttributeManager();
|
|
6093
6549
|
weightsTransform?.destroy();
|
|
6094
6550
|
weightsTransform = new import_engine6.TextureTransform(this.context.device, {
|
|
6095
6551
|
id: `${this.id}-weights-transform`,
|
|
6096
6552
|
...shaders,
|
|
6097
|
-
|
|
6098
|
-
|
|
6553
|
+
source: weights_wgsl_default,
|
|
6554
|
+
bufferLayout: attributeManager.getBufferLayouts({ isInstanced: isWebGPU }),
|
|
6555
|
+
vertexCount: isWebGPU ? 6 : 1,
|
|
6556
|
+
...isWebGPU ? {
|
|
6557
|
+
colorAttachmentFormats: [weightsTexture.format],
|
|
6558
|
+
isInstanced: true,
|
|
6559
|
+
instanceCount: this.getNumInstances()
|
|
6560
|
+
} : {},
|
|
6099
6561
|
targetTexture: weightsTexture,
|
|
6100
6562
|
parameters: {
|
|
6101
6563
|
depthWriteEnabled: false,
|
|
@@ -6106,7 +6568,7 @@ void main() {
|
|
|
6106
6568
|
blendAlphaSrcFactor: "one",
|
|
6107
6569
|
blendAlphaDstFactor: "one"
|
|
6108
6570
|
},
|
|
6109
|
-
topology: "point-list",
|
|
6571
|
+
topology: isWebGPU ? "triangle-list" : "point-list",
|
|
6110
6572
|
modules: [...shaders.modules, weightUniforms]
|
|
6111
6573
|
});
|
|
6112
6574
|
this.setState({ weightsTransform });
|
|
@@ -6121,6 +6583,7 @@ void main() {
|
|
|
6121
6583
|
});
|
|
6122
6584
|
this._createWeightsTransform(weightsTransformShaders);
|
|
6123
6585
|
const maxWeightsTransformShaders = this.getShaders({
|
|
6586
|
+
source: max_wgsl_default,
|
|
6124
6587
|
vs: max_vs_glsl_default,
|
|
6125
6588
|
fs: max_fs_glsl_default,
|
|
6126
6589
|
modules: [maxWeightUniforms]
|
|
@@ -6129,7 +6592,8 @@ void main() {
|
|
|
6129
6592
|
id: `${this.id}-max-weights-transform`,
|
|
6130
6593
|
targetTexture: maxWeightsTexture,
|
|
6131
6594
|
...maxWeightsTransformShaders,
|
|
6132
|
-
|
|
6595
|
+
...device.type === "webgpu" ? { colorAttachmentFormats: [maxWeightsTexture.format] } : {},
|
|
6596
|
+
vertexCount: device.type === "webgpu" ? Math.ceil(textureSize / MAX_WEIGHT_REDUCTION_SIZE) ** 2 : textureSize * textureSize,
|
|
6133
6597
|
topology: "point-list",
|
|
6134
6598
|
parameters: {
|
|
6135
6599
|
depthWriteEnabled: false,
|
|
@@ -6243,7 +6707,13 @@ void main() {
|
|
|
6243
6707
|
const attributes = attributeManager.getAttributes();
|
|
6244
6708
|
const moduleSettings = this.getModuleSettings();
|
|
6245
6709
|
this._setModelAttributes(weightsTransform.model, attributes);
|
|
6246
|
-
|
|
6710
|
+
if (this.context.device.type === "webgpu") {
|
|
6711
|
+
const instanceCount = this.getNumInstances();
|
|
6712
|
+
weightsTransform.model.setVertexCount(instanceCount > 0 ? 6 : 0);
|
|
6713
|
+
weightsTransform.model.setInstanceCount(instanceCount);
|
|
6714
|
+
} else {
|
|
6715
|
+
weightsTransform.model.setVertexCount(this.getNumInstances());
|
|
6716
|
+
}
|
|
6247
6717
|
const weightProps = {
|
|
6248
6718
|
radiusPixels,
|
|
6249
6719
|
commonBounds,
|