({
target,
controlsRef,
flat = false,
}: {
target: CameraTarget | null;
controlsRef: RefObject<OrbitControlsImpl | null>;
/* In der flachen Ansicht wird nur in der Ebene geflogen. Siehe useFrame. */
flat?: boolean;
})
| 216 | const FLY_MAX_DELTA = 0.1; |
| 217 | |
| 218 | export function CameraAnimator({ |
| 219 | target, |
| 220 | controlsRef, |
| 221 | flat = false, |
| 222 | }: { |
| 223 | target: CameraTarget | null; |
| 224 | controlsRef: RefObject<OrbitControlsImpl | null>; |
| 225 | /* In der flachen Ansicht wird nur in der Ebene geflogen. Siehe useFrame. */ |
| 226 | flat?: boolean; |
| 227 | }) { |
| 228 | const { camera } = useThree(); |
| 229 | const targetRef = useRef<CameraTarget | null>(null); |
| 230 | const progress = useRef(1); |
| 231 | /* Die Geschwindigkeit der Feder, je Achse, ueber Ziele hinweg. */ |
| 232 | const springVelocity = useRef({ |
| 233 | position: [0, 0, 0] as [number, number, number], |
| 234 | lookAt: [0, 0, 0] as [number, number, number], |
| 235 | }); |
| 236 | /* Das Ziel, das beim Aufsetzen schon dastand. Siehe Aenderung 14. */ |
| 237 | const mountedWith = useRef(target); |
| 238 | |
| 239 | useEffect(() => { |
| 240 | if (!target) { |
| 241 | return; |
| 242 | } |
| 243 | /* |
| 244 | * Aenderung 14: ein Anflug, der schon vor dem Aufsetzen dieser Szene |
| 245 | * gesetzt war, gehoert zum Bild davor. Ihn jetzt abzuspielen hiesse, |
| 246 | * die Kamera zu einem Ziel zu fahren, das niemand mehr meint |
| 247 | * (Review-Befund G1). Eine Einpassung (`immediate`) gilt weiter: sie ist |
| 248 | * die Lage, in der das Bild anfaengt. |
| 249 | */ |
| 250 | if (target === mountedWith.current && target.immediate !== true) { |
| 251 | return; |
| 252 | } |
| 253 | targetRef.current = target; |
| 254 | progress.current = 0; |
| 255 | /* |
| 256 | * Die Oben-Richtung wird SOFORT gesetzt, auch wenn geflogen wird. |
| 257 | * |
| 258 | * Sie ist keine Strecke, sondern die Frage, wo oben ist; sie waehrend |
| 259 | * eines Anflugs zu drehen waere eine zweite Bewegung ueber der ersten. |
| 260 | * OrbitControls liest `object.up` bei jedem `update()` neu (three-stdlib, |
| 261 | * OrbitControls.update), also gilt sie ab dem naechsten Bild auch fuer |
| 262 | * die Steuerung. |
| 263 | */ |
| 264 | if (target.up !== undefined) { |
| 265 | camera.up.copy(target.up).normalize(); |
| 266 | } |
| 267 | if (target.immediate !== true) { |
| 268 | return; |
| 269 | } |
| 270 | // Die Einpassung ist die Lage, in der das Bild anfaengt. Siehe Kopf. |
| 271 | progress.current = 1; |
| 272 | if (flat) { |
| 273 | camera.position.x = target.lookAt.x; |
| 274 | camera.position.y = target.lookAt.y; |
| 275 | } else { |
nothing calls this directly
no test coverage detected