Skip to content

Commit

Permalink
fix(picking): fix picking on multiple layers
Browse files Browse the repository at this point in the history
  • Loading branch information
jailln authored and mgermerie committed Sep 12, 2022
1 parent 069b2dd commit 5c2f578
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Core/Picking.js
Expand Up @@ -99,6 +99,7 @@ function findLayerInParent(obj) {
}

const raycaster = new THREE.Raycaster();
const normalized = new THREE.Vector2();

/**
* @module Picking
Expand Down Expand Up @@ -208,8 +209,9 @@ export default {
} else {
raycaster.layers.enableAll();
}
// Raycaster use NDC coordinate
view.viewToNormalizedCoords(viewCoords, normalized);
if (radius < 0) {
const normalized = view.viewToNormalizedCoords(viewCoords);
raycaster.setFromCamera(normalized, view.camera.camera3D);

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

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

0 comments on commit 5c2f578

Please sign in to comment.