Skip to content

Instantly share code, notes, and snippets.

@verekia
Last active April 25, 2025 13:20
Show Gist options
  • Save verekia/2e512cab8c1d263837e86da5afde964c to your computer and use it in GitHub Desktop.
Save verekia/2e512cab8c1d263837e86da5afde964c to your computer and use it in GitHub Desktop.
diff --git a/dist/declarations/src/core/loop.d.ts b/dist/declarations/src/core/loop.d.ts
index 843f389ffb5a52cb4116ec24d449d5d1a41458f9..e2ebdb09b7eb67c805ba9cfc39da8661ccefd2b1 100644
--- a/dist/declarations/src/core/loop.d.ts
+++ b/dist/declarations/src/core/loop.d.ts
@@ -28,4 +28,4 @@ export declare function invalidate(state?: RootState, frames?: number): void;
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
*/
-export declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame): void;
+export declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame, shouldRender?: boolean): void;
diff --git a/dist/declarations/src/core/store.d.ts b/dist/declarations/src/core/store.d.ts
index 1ecd82e88efeeefd9633c4304cd8ca7929d76e67..fe09adb374583b9b4e5394a3ca3bade053732b0b 100644
--- a/dist/declarations/src/core/store.d.ts
+++ b/dist/declarations/src/core/store.d.ts
@@ -109,7 +109,7 @@ export interface RootState {
/** Flags the canvas for render, but doesn't render in itself */
invalidate: (frames?: number) => void;
/** Advance (render) one step */
- advance: (timestamp: number, runGlobalEffects?: boolean) => void;
+ advance: (timestamp: number, runGlobalEffects?: boolean, shouldRender?: boolean) => void;
/** Shortcut to setting the event layer */
setEvents: (events: Partial<EventManager<any>>) => void;
/** Shortcut to manual sizing */
@@ -127,4 +127,4 @@ export interface RootState {
}
export type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>;
export declare const context: React.Context<RootStore>;
-export declare const createStore: (invalidate: (state?: RootState, frames?: number) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
+export declare const createStore: (invalidate: (state?: RootState, frames?: number) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame, shouldRender?: boolean) => void) => RootStore;
diff --git a/dist/events-dc44c1b8.esm.js b/dist/events-dc44c1b8.esm.js
index 00d8ff62e61ae5f5cad8b9cb079e82a0983c4901..2fc4f5ffbdf6f7f0b4ba719b4d8dcdf6fafab586 100644
--- a/dist/events-dc44c1b8.esm.js
+++ b/dist/events-dc44c1b8.esm.js
@@ -938,7 +938,7 @@ const createStore = (invalidate, advance) => {
scene: null,
xr: null,
invalidate: (frames = 1) => invalidate(get(), frames),
- advance: (timestamp, runGlobalEffects) => advance(timestamp, runGlobalEffects, get()),
+ advance: (timestamp, runGlobalEffects, shouldRender) => advance(timestamp, runGlobalEffects, get(), undefined, shouldRender),
legacy: false,
linear: false,
flat: false,
@@ -2189,7 +2189,7 @@ function flushGlobalEffects(type, timestamp) {
}
let subscribers;
let subscription;
-function update(timestamp, state, frame) {
+function update(timestamp, state, frame, shouldRender = true) {
// Run local effects
let delta = state.clock.getDelta();
@@ -2208,7 +2208,7 @@ function update(timestamp, state, frame) {
}
// Render content
- if (!state.internal.priority && state.gl.render) state.gl.render(state.scene, state.camera);
+ if (!state.internal.priority && state.gl.render && shouldRender) state.gl.render(state.scene, state.camera);
// Decrease frame count
state.internal.frames = Math.max(0, state.internal.frames - 1);
@@ -2287,9 +2287,9 @@ function invalidate(state, frames = 1) {
* Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
*/
-function advance(timestamp, runGlobalEffects = true, state, frame) {
+function advance(timestamp, runGlobalEffects = true, state, frame, shouldRender = true) {
if (runGlobalEffects) flushGlobalEffects('before', timestamp);
- if (!state) for (const root of _roots.values()) update(timestamp, root.store.getState());else update(timestamp, state, frame);
+ if (!state) for (const root of _roots.values()) update(timestamp, root.store.getState(), undefined, shouldRender);else update(timestamp, state, frame, shouldRender);
if (runGlobalEffects) flushGlobalEffects('after', timestamp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment