MCPcopy Create free account
hub / github.com/TheOrcDev/github-creature / loop

Function loop

components/plasma.tsx:197–215  ·  view source on GitHub ↗
(t: number)

Source from the content-addressed store, hash-verified

195 let raf = 0;
196 const t0 = performance.now();
197 const loop = (t: number) => {
198 const timeValue = (t - t0) * 0.001;
199 if (direction === "pingpong") {
200 const pingpongDuration = 10;
201 const segmentTime = timeValue % pingpongDuration;
202 const isForward = Math.floor(timeValue / pingpongDuration) % 2 === 0;
203 const u = segmentTime / pingpongDuration;
204 const smooth = u * u * (3 - 2 * u);
205 const pingpongTime = isForward
206 ? smooth * pingpongDuration
207 : (1 - smooth) * pingpongDuration;
208 uDirectionUniform.value = 1.0;
209 iTimeUniform.value = pingpongTime;
210 } else {
211 iTimeUniform.value = timeValue;
212 }
213 renderer.render({ scene: mesh });
214 raf = requestAnimationFrame(loop);
215 };
216 raf = requestAnimationFrame(loop);
217
218 return () => {

Callers

nothing calls this directly

Calls 1

renderMethod · 0.45

Tested by

no test coverage detected