Skip to content

Commit 5c2f578

Browse files
jaillnmgermerie
authored andcommitted
fix(picking): fix picking on multiple layers
1 parent 069b2dd commit 5c2f578

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Core/Picking.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ function findLayerInParent(obj) {
9999
}
100100

101101
const raycaster = new THREE.Raycaster();
102+
const normalized = new THREE.Vector2();
102103

103104
/**
104105
* @module Picking
@@ -208,8 +209,9 @@ export default {
208209
} else {
209210
raycaster.layers.enableAll();
210211
}
212+
// Raycaster use NDC coordinate
213+
view.viewToNormalizedCoords(viewCoords, normalized);
211214
if (radius < 0) {
212-
const normalized = view.viewToNormalizedCoords(viewCoords);
213215
raycaster.setFromCamera(normalized, view.camera.camera3D);
214216

215217
const intersects = raycaster.intersectObject(object, true);
@@ -239,8 +241,6 @@ export default {
239241
const clearG = Math.round(255 * clearColor.g);
240242
const clearB = Math.round(255 * clearColor.b);
241243

242-
// Raycaster use NDC coordinate
243-
const normalized = view.viewToNormalizedCoords(viewCoords);
244244
const tmp = normalized.clone();
245245
traversePickingCircle(radius, (x, y) => {
246246
// x, y are offset from the center of the picking circle,

0 commit comments

Comments
 (0)