* Der Deckel: der Canvas laeuft auf `never` und wird von hier getaktet. * * Der Weg ueber `advance()` und nicht ueber ein Ueberspringen in `useFrame`: * ein uebersprungenes `useFrame` spart nichts, denn der Canvas hat das Bild * schon gezeichnet, bevor der Rueckruf laeuft. Erst ein Renderloop, d
({ cap, active }: { cap: number; active: boolean })
| 614 | * haben, fuer eine Einstellung, die niemand eingeschaltet hat. |
| 615 | */ |
| 616 | function FrameCapDriver({ cap, active }: { cap: number; active: boolean }): null { |
| 617 | const advance = useThree((state) => state.advance); |
| 618 | |
| 619 | useEffect(() => { |
| 620 | if (!active || cap <= 0 || typeof requestAnimationFrame !== 'function') { |
| 621 | return; |
| 622 | } |
| 623 | const interval = 1000 / cap; |
| 624 | let last = 0; |
| 625 | let handle = 0; |
| 626 | const tick = (time: number): void => { |
| 627 | handle = requestAnimationFrame(tick); |
| 628 | if (time - last < interval - FRAME_CAP_TOLERANCE_MS) { |
| 629 | return; |
| 630 | } |
| 631 | last = time; |
| 632 | advance(time); |
| 633 | }; |
| 634 | handle = requestAnimationFrame(tick); |
| 635 | return () => cancelAnimationFrame(handle); |
| 636 | }, [advance, active, cap]); |
| 637 | |
| 638 | return null; |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * Die flache Ansicht: eine orthografische Kamera die z-Achse hinunter. |
nothing calls this directly
no outgoing calls
no test coverage detected