Skip to content

Commit

Permalink
fix: provide smoother transition of sensor depth when cursor goes int…
Browse files Browse the repository at this point in the history
…o inner radius (#347)
  • Loading branch information
JamesLMilner authored Oct 12, 2024
1 parent 1639015 commit 1255432
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/modes/sensor/sensor.mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ export class TerraDrawSensorMode extends TerraDrawBaseDrawMode<SensorPolygonStyl

const hasLessThanZeroSize = outerRadius < innerRadius;

// We don't need to continue if the users cursor is not in front of the arc
if (hasLessThanZeroSize) {
return;
}
// If the cursor is inside the inner radius, the depth of the sensor is always 0
const radiusCalculationPosition = hasLessThanZeroSize
? webMercatorCoordOne
: webMercatorCursor;

const cursorBearing = webMercatorBearing(
webMercatorCenter,
Expand Down Expand Up @@ -357,7 +357,10 @@ export class TerraDrawSensorMode extends TerraDrawBaseDrawMode<SensorPolygonStyl
const multiplier = this.direction === "anticlockwise" ? 1 : -1;
const bearingStep = (multiplier * deltaBearing) / numberOfPoints;

const radius = cartesianDistance(webMercatorCenter, webMercatorCursor);
const radius = cartesianDistance(
webMercatorCenter,
radiusCalculationPosition,
);

// Add all the arc points
const finalArc = [];
Expand Down

0 comments on commit 1255432

Please sign in to comment.