(
points: readonly Vector3Like[],
fovDegrees: number,
aspect: number,
margin: number = FRAME_MARGIN,
)
| 425 | * zurueck, negativ heisst vor; ohne brauchbare Punkte bleibt sie stehen. |
| 426 | */ |
| 427 | export function containShift( |
| 428 | points: readonly Vector3Like[], |
| 429 | fovDegrees: number, |
| 430 | aspect: number, |
| 431 | margin: number = FRAME_MARGIN, |
| 432 | ): number { |
| 433 | const fov = (Math.max(1, Math.min(179, fovDegrees)) * Math.PI) / 180; |
| 434 | const scale = Number.isFinite(margin) && margin > 0 ? margin : 1; |
| 435 | const vertical = Math.tan(fov / 2) / scale; |
| 436 | const horizontal = vertical * (Number.isFinite(aspect) && aspect > 0 ? aspect : 1); |
| 437 | let shift = Number.NEGATIVE_INFINITY; |
| 438 | for (const point of points) { |
| 439 | if (!Number.isFinite(point.x) || !Number.isFinite(point.y) || !Number.isFinite(point.z)) { |
| 440 | continue; |
| 441 | } |
| 442 | const needed = Math.max(Math.abs(point.x) / horizontal, Math.abs(point.y) / vertical); |
| 443 | shift = Math.max(shift, needed + point.z); |
| 444 | } |
| 445 | return Number.isFinite(shift) ? shift : 0; |
| 446 | } |
| 447 | |
| 448 | /** Wo die Kamera steht, damit die ganze Wolke im Bild ist. */ |
| 449 | export interface CameraFit { |
no outgoing calls
no test coverage detected