Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tolerance #77

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/objects/Tunnel3D.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ export default class Tunnel3D extends THREE.Object3D implements AbstractTunnel3D
point: THREE.Vector2,
stickDistance = 3,
) {
const newMockStickPosition = this.mockGetStick(point, stickDistance);
const tolerance = Math.max(grout.holeLength / 20, 1);

const newMockStickPosition = this.mockGetStick(point, stickDistance, tolerance);
if (newMockStickPosition == null) return;

// This is the position at the end of the stick!
Expand Down Expand Up @@ -393,10 +395,15 @@ export default class Tunnel3D extends THREE.Object3D implements AbstractTunnel3D
* Given a approximate point at the stick, attempt to find the corresponding point at along the interpolated stick shape.
* @param point Approximate point at the stick
* @param stickDistance Distance, in +Y, between each grout
* @param stickDistance Distance, in +Y, between each grout
* @param tolerance The distance between the each point along the tunnel's shape
* @returns Point along the stick shape, if found
*/
public mockGetStick(point: THREE.Vector2, stickDistance = 3): PointAlongShape | null {
const tolerance = 1;
public mockGetStick(
point: THREE.Vector2,
stickDistance = 3,
tolerance: number = 1,
): PointAlongShape | null {
// Get initial point at the stick shape
const startingPointAtShape = this.mockGetPointAtShape(
this.stickInterpolatedPoints,
Expand Down
Loading