Skip to content

Commit

Permalink
🐞 fix: Fix the bug of snap distance
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangechen committed Dec 9, 2023
1 parent af9e8ce commit dce55c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/chili-three/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2022-2023 the Chili authors. All rights reserved. AGPL-3.0 license.

export class Constants {
static readonly RaycasterThreshold = 2;
static readonly RaycasterThreshold = 3;
}
4 changes: 2 additions & 2 deletions packages/chili-three/src/threeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ export class ThreeView extends Observable implements IView {

private initRaycaster(mx: number, my: number) {
let ray = this.rayAt(mx, my);
let threshold = Constants.RaycasterThreshold / this.cameraController.scale;
if (threshold < 5) threshold = 5;
let scale = this.cameraController.target.distanceTo(this.camera.position) / 1000.0;
let threshold = Constants.RaycasterThreshold * scale;
let raycaster = new Raycaster(ThreeHelper.fromXYZ(ray.location), ThreeHelper.fromXYZ(ray.direction));
raycaster.params = { Line: { threshold }, Points: { threshold } };
return raycaster;
Expand Down

0 comments on commit dce55c6

Please sign in to comment.