14 lines
490 B
TypeScript
14 lines
490 B
TypeScript
export const PITCH_ZOOM_MIN = 6;
|
|
export const PITCH_ZOOM_MAX = 12;
|
|
export const MAX_PITCH_DEG = 45;
|
|
|
|
export function smoothstep(edge0: number, edge1: number, x: number): number {
|
|
const t = Math.min(1, Math.max(0, (x - edge0) / (edge1 - edge0)));
|
|
return t * t * (3 - 2 * t);
|
|
}
|
|
|
|
// Pitch is a pure function of zoom so it never fights user pan/zoom gestures.
|
|
export function pitchForZoom(zoom: number): number {
|
|
return smoothstep(PITCH_ZOOM_MIN, PITCH_ZOOM_MAX, zoom) * MAX_PITCH_DEG;
|
|
}
|