Skip to content

Commit 95c4e2a

Browse files
donmccurdyPessimistress
authored andcommitted
fix(layers): Fix MVTLayer + pickMultipleObjects (#9246)
1 parent 5db714f commit 95c4e2a

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

modules/layers/src/geojson-layer/geojson-binary.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ export function calculatePickingColors(
7070
};
7171
for (const key in pickingColors) {
7272
const featureIds = geojsonBinary[key].globalFeatureIds.value;
73-
pickingColors[key] = new Uint8ClampedArray(featureIds.length * 3);
73+
pickingColors[key] = new Uint8ClampedArray(featureIds.length * 4);
7474
const pickingColor = [];
7575
for (let i = 0; i < featureIds.length; i++) {
7676
encodePickingColor(featureIds[i], pickingColor);
77-
pickingColors[key]![i * 3 + 0] = pickingColor[0];
78-
pickingColors[key]![i * 3 + 1] = pickingColor[1];
79-
pickingColors[key]![i * 3 + 2] = pickingColor[2];
77+
pickingColors[key][i * 4 + 0] = pickingColor[0];
78+
pickingColors[key][i * 4 + 1] = pickingColor[1];
79+
pickingColors[key][i * 4 + 2] = pickingColor[2];
80+
pickingColors[key][i * 4 + 3] = 255;
8081
}
8182
}
8283

modules/layers/src/geojson-layer/geojson-layer-props.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export function createLayerPropsFromBinary(
7474
...points.attributes,
7575
getPosition: points.positions,
7676
instancePickingColors: {
77-
size: 3,
77+
size: 4,
7878
value: customPickingColors.points!
7979
}
8080
},
@@ -90,7 +90,7 @@ export function createLayerPropsFromBinary(
9090
...lines.attributes,
9191
getPath: lines.positions,
9292
instancePickingColors: {
93-
size: 3,
93+
size: 4,
9494
value: customPickingColors.lines!
9595
}
9696
},
@@ -107,7 +107,7 @@ export function createLayerPropsFromBinary(
107107
...polygons.attributes,
108108
getPolygon: polygons.positions,
109109
pickingColors: {
110-
size: 3,
110+
size: 4,
111111
value: customPickingColors.polygons!
112112
}
113113
},
@@ -127,7 +127,7 @@ export function createLayerPropsFromBinary(
127127
...polygons.attributes,
128128
getPath: polygons.positions,
129129
instancePickingColors: {
130-
size: 3,
130+
size: 4,
131131
value: customPickingColors.polygons!
132132
}
133133
},

test/bench/layer.bench.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ export default function layerBench(suite) {
127127
})
128128
.add('calculate instance picking colors', () => {
129129
const numInstances = 1e6;
130-
const target = new Uint8ClampedArray(numInstances * 3);
130+
const target = new Uint8ClampedArray(numInstances * 4);
131131
testLayer.internalState = {};
132-
testLayer.calculateInstancePickingColors({value: target, size: 3}, {numInstances});
132+
testLayer.calculateInstancePickingColors({value: target, size: 4}, {numInstances});
133133
});
134134
}

test/modules/layers/data/fixtures.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ export const geoJSONData = [
4040
];
4141

4242
// prettier-ignore
43-
export const pickingColorsSample = Uint8ClampedArray.from([
44-
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0
43+
export const pickingColorsSample = Uint8ClampedArray.from([
44+
1, 0, 0, 255,
45+
1, 0, 0, 255,
46+
1, 0, 0, 255,
47+
1, 0, 0, 255,
48+
2, 0, 0, 255,
49+
2, 0, 0, 255,
50+
2, 0, 0, 255,
51+
2, 0, 0, 255,
4552
]);

0 commit comments

Comments
 (0)