Skip to content

Commit

Permalink
Re-adjusted path smoothing coefficient and revised method for higher …
Browse files Browse the repository at this point in the history
…default camera altitude on mobile. Also fixed the control positioning on mobile, which was colliding with the footer.
  • Loading branch information
sdl60660 committed Jun 3, 2021
1 parent ebad341 commit 68f6a1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Controls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
z-index: 30;
position: absolute;
left: 50%;
bottom: 5vh;
bottom: 6vh;
transform: translate(-50%, 50%);
gap: 1.5rem;
/* display: none; */
Expand Down
9 changes: 5 additions & 4 deletions src/components/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
let totalLength;
let phaseJump;
let altitudeMultiplier = 1;
// Zoom level won't be adjustable on mobile, but it will be set slightly higher to avoid jiterriness
let altitudeMultiplier = window.innerWidth > 600 ? 1 : 1.1;
let altitudeChange = false;
let paused = false;
let playbackSpeed = 1;
Expand Down Expand Up @@ -204,7 +205,7 @@
combinedFlowlines.geometry.coordinates = flowlinesData.features.map(a => a.geometry.coordinates).flat();
drawFlowPath({ map, featureData: [combinedFlowlines], lineWidth: 3 });
const cameraBaseAltitude = window.innerWidth < 600 ? 4800 : 4300;
const cameraBaseAltitude = 4300;
const elevationArrayStep = Math.min((coordinatePath.length/2) - 1, 100);
const elevations = await getElevations(coordinatePath, elevationArrayStep);
// Take base altitude and then adjust up based on the elevation of the first coordinate
Expand All @@ -214,7 +215,7 @@
const distanceGap = initialElevation*Math.tan(targetPitch * Math.PI/180) / 1000;
// Create smoothed path by averaging coordinates with their neighbors. This helps reduce horizontal movement with bendy rivers.
const smoothedPath = pathSmoother(coordinatePath, Math.min(8, Math.floor(coordinatePath.length / 2)));
const smoothedPath = pathSmoother(coordinatePath, Math.min(9, Math.floor(coordinatePath.length / 2)));
const routeDistance = pathDistance(smoothedPath);
const trueRouteDistance = pathDistance(coordinatePath);
Expand Down Expand Up @@ -610,7 +611,7 @@
let stopPoint = stopPoints[0];
activeFeatureIndex = 0;
let route = pathSmoother(coordinatePath, Math.min(Math.floor(8*altitudeMultiplier), Math.floor(coordinatePath.length / 2)));
let route = pathSmoother(coordinatePath, Math.min(Math.floor(9*altitudeMultiplier), Math.floor(coordinatePath.length / 2)));
let routeDistance = pathDistance(route);
let phase = 0;
Expand Down

1 comment on commit 68f6a1f

@vercel
Copy link

@vercel vercel bot commented on 68f6a1f Jun 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.