mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: lighting toggler no longer fires on unload
This commit is contained in:
1 parent
e7fe3a4baf
commit
889a92e98b
1 file changed
+10
-2
+10
-2
@@ -19,6 +19,7 @@ const TARGET_FRAME_RATE = 30;
|
|||||||
export function Lighting() {
|
export function Lighting() {
|
||||||
const [cast, setCast] = useState(true);
|
const [cast, setCast] = useState(true);
|
||||||
|
|
||||||
|
const t0 = useRef(0);
|
||||||
const topLight = useRef<SpotLight>(null!);
|
const topLight = useRef<SpotLight>(null!);
|
||||||
const frontLight = useRef<SpotLight>(null!);
|
const frontLight = useRef<SpotLight>(null!);
|
||||||
|
|
||||||
@@ -28,8 +29,15 @@ export function Lighting() {
|
|||||||
const last = useRef<number>(0);
|
const last = useRef<number>(0);
|
||||||
const samples = useRef<number[]>([]);
|
const samples = useRef<number[]>([]);
|
||||||
|
|
||||||
useFrame(({ clock }) => {
|
useFrame(({ clock, frameloop }) => {
|
||||||
if (!cast || clock.elapsedTime < TARGET_FRAME_RATE * N) return;
|
if (frameloop === "never") {
|
||||||
|
t0.current = clock.elapsedTime;
|
||||||
|
samples.current = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!cast || clock.elapsedTime - t0.current < TARGET_FRAME_RATE * N) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const dt = clock.elapsedTime - last.current;
|
const dt = clock.elapsedTime - last.current;
|
||||||
last.current = clock.elapsedTime;
|
last.current = clock.elapsedTime;
|
||||||
|
|||||||
Reference in new issue
Block a user