feat: complete transition

This commit is contained in:
TrèsAbhi committed 2025-11-27 13:42:37 -06:00
1 parent cd4fa366a0
commit 1427f61c52
6 files changed
+41 -15

No files matched your search

@@ -1,5 +1,6 @@
import { useFrame, useThree } from "@react-three/fiber";
import { times } from "lodash-es";
import { Quicklime } from "quicklime";
import { useEffect, useRef } from "react";
import { SpotLight, type Group } from "three";
import { clamp, degToRad, lerp } from "three/src/math/MathUtils.js";
@@ -19,6 +20,8 @@ const LIGHT_HEIGHT_1 = 10;
const INTENSITY_0 = 60;
const INTENSITY_1 = 30;
export const transitionEvent = new Quicklime<number>(0);
export function Lighting() {
const wrapper = useRef<Group>(null!);
const t0 = useRef(0);
@@ -50,6 +53,10 @@ export function Lighting() {
);
const t = (0.5 * Math.sin(Math.PI * (x + 0.5)) + 0.5) ** 2;
if (t !== transitionEvent.last) {
transitionEvent.dispatch(t);
}
for (const child of wrapper.current.children) {
if (child instanceof SpotLight) {
child.angle = ANGLE * t;