@react-three/fiber 10.0.0-canary.9b237a7 → 10.0.0-canary.a1c1d93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension.cjs +2 -1
- package/dist/extension.d.cts +9 -46
- package/dist/extension.d.mts +9 -46
- package/dist/extension.d.ts +9 -46
- package/dist/extension.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +7 -8
- package/dist/index.d.mts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.mjs +3 -3
- package/dist/legacy.cjs +2 -2
- package/dist/legacy.d.cts +4 -4
- package/dist/legacy.d.mts +4 -4
- package/dist/legacy.d.ts +4 -4
- package/dist/legacy.mjs +4 -4
- package/dist/shared/fiber.-1JhXWEC.d.cts +48 -0
- package/dist/shared/{fiber.DAg-9ieU.d.ts → fiber.Bkpap4yF.d.mts} +124 -101
- package/dist/shared/{fiber.Ddgoyqql.d.mts → fiber.BnIfHyTk.d.cts} +124 -101
- package/dist/shared/{fiber.Bw8YnGg5.d.cts → fiber.CLTHZhZp.d.cts} +109 -4
- package/dist/shared/{fiber.Bw8YnGg5.d.mts → fiber.CLTHZhZp.d.mts} +109 -4
- package/dist/shared/{fiber.Bw8YnGg5.d.ts → fiber.CLTHZhZp.d.ts} +109 -4
- package/dist/shared/fiber.CTEAJNmg.d.ts +48 -0
- package/dist/shared/{fiber.D9zziEOb.mjs → fiber.CUKAa7Rv.mjs} +28 -1
- package/dist/shared/fiber.CksZuiOV.d.mts +48 -0
- package/dist/shared/{fiber.COTqIf4o.mjs → fiber.Dl_2kSXg.mjs} +6379 -5238
- package/dist/shared/{fiber.DiPB625B.d.cts → fiber.NwhGYEh-.d.ts} +124 -101
- package/dist/shared/{fiber.D9dtW9DT.cjs → fiber.khFlPHPf.cjs} +30 -0
- package/dist/shared/{fiber.COk97oyZ.cjs → fiber.nPYZB2AE.cjs} +6388 -5247
- package/dist/webgpu/index.cjs +2 -2
- package/dist/webgpu/index.d.cts +4 -5
- package/dist/webgpu/index.d.mts +4 -5
- package/dist/webgpu/index.d.ts +4 -5
- package/dist/webgpu/index.mjs +4 -4
- package/package.json +6 -6
- package/readme.md +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi } from '@pmndrs/scheduler';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import * as THREE from 'three';
|
|
4
|
-
import { WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
3
|
+
import { WebGLRenderer, WebGLRenderTarget, Color, ColorRepresentation } from 'three';
|
|
4
|
+
import * as React from 'react';
|
|
5
5
|
import * as ThreeWebGPU from 'three/webgpu';
|
|
6
6
|
import { WebGPURenderer, RenderTarget, CanvasTarget } from 'three/webgpu';
|
|
7
7
|
import { StoreApi } from 'zustand';
|
|
@@ -477,6 +477,11 @@ interface InternalState {
|
|
|
477
477
|
* Selected once, from the entry's provider, and copied into portals with the rest of `internal`.
|
|
478
478
|
*/
|
|
479
479
|
support: R3FRendererSupport
|
|
480
|
+
/**
|
|
481
|
+
* Releases this root's lease on its renderer. The last release disposes a renderer R3F created;
|
|
482
|
+
* a renderer passed in as an instance is never disposed by R3F.
|
|
483
|
+
*/
|
|
484
|
+
releaseRenderer?: () => void | Promise<void>
|
|
480
485
|
/** Global scheduler reference (for useFrame hook) */
|
|
481
486
|
scheduler: SchedulerApi | null
|
|
482
487
|
/**
|
|
@@ -489,6 +494,8 @@ interface InternalState {
|
|
|
489
494
|
rootId?: string
|
|
490
495
|
/** Function to unregister this root from the global scheduler */
|
|
491
496
|
unregisterRoot?: () => void
|
|
497
|
+
/** Function to stop following devicePixelRatio changes */
|
|
498
|
+
unwatchDpr?: () => void
|
|
492
499
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
493
500
|
container?: THREE.Object3D
|
|
494
501
|
/**
|
|
@@ -530,6 +537,12 @@ interface InternalState {
|
|
|
530
537
|
* Only set when isSecondary is true.
|
|
531
538
|
*/
|
|
532
539
|
targetId?: string
|
|
540
|
+
/**
|
|
541
|
+
* This secondary stopped sharing because the primary's renderer fell back to its
|
|
542
|
+
* WebGL2 backend (#3965): it owns the renderer it constructed, so it is not
|
|
543
|
+
* `isSecondary` (which marks a canvas borrowing another's renderer).
|
|
544
|
+
*/
|
|
545
|
+
sharedRendererFallback?: boolean
|
|
533
546
|
/**
|
|
534
547
|
* Function to unregister this primary canvas from the registry.
|
|
535
548
|
* Only set when this canvas has an `id` prop.
|
|
@@ -654,6 +667,91 @@ interface RootState {
|
|
|
654
667
|
|
|
655
668
|
type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
|
|
656
669
|
|
|
670
|
+
//* Reconciler Types ==============================
|
|
671
|
+
|
|
672
|
+
// FiberRoot is an opaque internal React type - we define it locally
|
|
673
|
+
// to avoid bundling @types/react-reconciler which causes absolute path issues
|
|
674
|
+
type FiberRoot = any
|
|
675
|
+
|
|
676
|
+
/** A promise tagged with its state, the protocol React's `use` reads */
|
|
677
|
+
type TrackedPromise<T> = Promise<T> &
|
|
678
|
+
({ status: 'pending' } | { status: 'fulfilled'; value: T } | { status: 'rejected'; reason: unknown })
|
|
679
|
+
|
|
680
|
+
interface Root {
|
|
681
|
+
fiber: FiberRoot
|
|
682
|
+
store: RootStore
|
|
683
|
+
/** Set while a teardown waits on React. Configure and render clear it, which cancels the teardown */
|
|
684
|
+
unmountClaim: symbol | null
|
|
685
|
+
/** Pending only while a renderer is being created */
|
|
686
|
+
ready: TrackedPromise<unknown>
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
type AttachFnType<O = any> = (parent: any, self: O) => () => void
|
|
690
|
+
type AttachType<O = any> = string | AttachFnType<O>
|
|
691
|
+
|
|
692
|
+
type ConstructorRepresentation<T = any> = new (...args: any[]) => T
|
|
693
|
+
|
|
694
|
+
interface Catalogue {
|
|
695
|
+
[name: string]: ConstructorRepresentation
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// TODO: handle constructor overloads
|
|
699
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2931
|
|
700
|
+
// https://github.com/microsoft/TypeScript/issues/37079
|
|
701
|
+
type Args<T> = T extends ConstructorRepresentation
|
|
702
|
+
? T extends typeof Color
|
|
703
|
+
? [r: number, g: number, b: number] | [color: ColorRepresentation]
|
|
704
|
+
: ConstructorParameters<T>
|
|
705
|
+
: any[]
|
|
706
|
+
|
|
707
|
+
type ArgsProp<P> = P extends ConstructorRepresentation
|
|
708
|
+
? IsAllOptional<ConstructorParameters<P>> extends true
|
|
709
|
+
? { args?: Args<P> }
|
|
710
|
+
: { args: Args<P> }
|
|
711
|
+
: { args: unknown[] }
|
|
712
|
+
|
|
713
|
+
type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
714
|
+
object?: T
|
|
715
|
+
dispose?: null
|
|
716
|
+
attach?: AttachType<T>
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
interface Instance<O = any> {
|
|
720
|
+
root: RootStore
|
|
721
|
+
type: string
|
|
722
|
+
parent: Instance | null
|
|
723
|
+
children: Instance[]
|
|
724
|
+
props: InstanceProps<O> & Record<string, unknown>
|
|
725
|
+
object: O & { __r3f?: Instance<O> }
|
|
726
|
+
eventCount: number
|
|
727
|
+
handlers: Partial<EventHandlers>
|
|
728
|
+
attach?: AttachType<O>
|
|
729
|
+
previousAttach?: any
|
|
730
|
+
isHidden: boolean
|
|
731
|
+
/** Set of props that have been applied via once() */
|
|
732
|
+
appliedOnce?: Set<string>
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
interface HostConfig {
|
|
736
|
+
type: string
|
|
737
|
+
props: Instance['props']
|
|
738
|
+
container: RootStore
|
|
739
|
+
instance: Instance
|
|
740
|
+
textInstance: void
|
|
741
|
+
suspenseInstance: Instance
|
|
742
|
+
hydratableInstance: never
|
|
743
|
+
formInstance: never
|
|
744
|
+
publicInstance: Instance['object']
|
|
745
|
+
hostContext: {}
|
|
746
|
+
childSet: never
|
|
747
|
+
timeoutHandle: number | undefined
|
|
748
|
+
noTimeout: -1
|
|
749
|
+
TransitionStatus: null
|
|
750
|
+
}
|
|
751
|
+
declare global {
|
|
752
|
+
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
|
|
753
|
+
}
|
|
754
|
+
|
|
657
755
|
interface RootExtension {
|
|
658
756
|
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
659
757
|
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
@@ -695,7 +793,14 @@ declare function useStore(): RootStore;
|
|
|
695
793
|
*/
|
|
696
794
|
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
697
795
|
|
|
796
|
+
/**
|
|
797
|
+
* React context that carries the current root's {@link RootStore}. Each root provides its store and
|
|
798
|
+
* each portal provides its own scoped one; `useStore`, and every hook built on it, reads it.
|
|
799
|
+
*
|
|
800
|
+
* Stored on `globalThis` under `Symbol.for('@react-three/fiber.context')`, so every copy and entry
|
|
801
|
+
* of fiber shares a single context.
|
|
802
|
+
*/
|
|
698
803
|
declare const context: React.Context<RootStore>;
|
|
699
804
|
|
|
700
|
-
export { useStore as
|
|
701
|
-
export type {
|
|
805
|
+
export { useStore as ah, useThree as ai, context as aj, registerRootExtension as r, setRenderOverride as s };
|
|
806
|
+
export type { ObjectMap as $, AttachFnType as A, ArgsProp as B, ConstructorRepresentation as C, Dpr as D, Events as E, Frameloop as F, InstanceProps as G, Instance as H, InternalState as I, HostConfig as J, Properties as K, IsOptional as L, Mutable as M, NonFunctionKeys as N, Overwrite as O, PointerState as P, IsAllOptional as Q, R3FRenderTarget as R, Subscription as S, ThreeEvent as T, ThreeCamera as U, Viewport as V, Act as W, XRManager as X, Bridge as Y, SetBlock as Z, UnblockProps as _, RootExtension as a, EquConfig as a0, Disposable as a1, FrameNextState as a2, FrameState as a3, FrameNextCallback as a4, FrameCallback as a5, ThreeNamespace as a6, ThreeCore as a7, OcclusionSupport as a8, WebGLSupport as a9, WebGPUSupport as aa, RendererSupport as ab, RendererProvider as ac, Register as ad, RegisteredRenderer as ae, ForRegisteredRenderer as af, R3FRendererSupport as ag, R3FRenderer as b, Size as c, RenderCallback as d, Performance as e, RootState as f, RootStore as g, Intersection as h, Camera as i, IntersectionEvent as j, DomEvent as k, EventHandlers as l, FilterFunction as m, ComputeFunction as n, XRPointerConfig as o, EventManager as p, PointerCaptureTarget as q, VisibilityEntry as t, FiberRoot as u, TrackedPromise as v, Root as w, AttachType as x, Catalogue as y, Args as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi } from '@pmndrs/scheduler';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import * as THREE from 'three';
|
|
4
|
-
import { WebGLRenderer, WebGLRenderTarget } from 'three';
|
|
3
|
+
import { WebGLRenderer, WebGLRenderTarget, Color, ColorRepresentation } from 'three';
|
|
4
|
+
import * as React from 'react';
|
|
5
5
|
import * as ThreeWebGPU from 'three/webgpu';
|
|
6
6
|
import { WebGPURenderer, RenderTarget, CanvasTarget } from 'three/webgpu';
|
|
7
7
|
import { StoreApi } from 'zustand';
|
|
@@ -477,6 +477,11 @@ interface InternalState {
|
|
|
477
477
|
* Selected once, from the entry's provider, and copied into portals with the rest of `internal`.
|
|
478
478
|
*/
|
|
479
479
|
support: R3FRendererSupport
|
|
480
|
+
/**
|
|
481
|
+
* Releases this root's lease on its renderer. The last release disposes a renderer R3F created;
|
|
482
|
+
* a renderer passed in as an instance is never disposed by R3F.
|
|
483
|
+
*/
|
|
484
|
+
releaseRenderer?: () => void | Promise<void>
|
|
480
485
|
/** Global scheduler reference (for useFrame hook) */
|
|
481
486
|
scheduler: SchedulerApi | null
|
|
482
487
|
/**
|
|
@@ -489,6 +494,8 @@ interface InternalState {
|
|
|
489
494
|
rootId?: string
|
|
490
495
|
/** Function to unregister this root from the global scheduler */
|
|
491
496
|
unregisterRoot?: () => void
|
|
497
|
+
/** Function to stop following devicePixelRatio changes */
|
|
498
|
+
unwatchDpr?: () => void
|
|
492
499
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
493
500
|
container?: THREE.Object3D
|
|
494
501
|
/**
|
|
@@ -530,6 +537,12 @@ interface InternalState {
|
|
|
530
537
|
* Only set when isSecondary is true.
|
|
531
538
|
*/
|
|
532
539
|
targetId?: string
|
|
540
|
+
/**
|
|
541
|
+
* This secondary stopped sharing because the primary's renderer fell back to its
|
|
542
|
+
* WebGL2 backend (#3965): it owns the renderer it constructed, so it is not
|
|
543
|
+
* `isSecondary` (which marks a canvas borrowing another's renderer).
|
|
544
|
+
*/
|
|
545
|
+
sharedRendererFallback?: boolean
|
|
533
546
|
/**
|
|
534
547
|
* Function to unregister this primary canvas from the registry.
|
|
535
548
|
* Only set when this canvas has an `id` prop.
|
|
@@ -654,6 +667,91 @@ interface RootState {
|
|
|
654
667
|
|
|
655
668
|
type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
|
|
656
669
|
|
|
670
|
+
//* Reconciler Types ==============================
|
|
671
|
+
|
|
672
|
+
// FiberRoot is an opaque internal React type - we define it locally
|
|
673
|
+
// to avoid bundling @types/react-reconciler which causes absolute path issues
|
|
674
|
+
type FiberRoot = any
|
|
675
|
+
|
|
676
|
+
/** A promise tagged with its state, the protocol React's `use` reads */
|
|
677
|
+
type TrackedPromise<T> = Promise<T> &
|
|
678
|
+
({ status: 'pending' } | { status: 'fulfilled'; value: T } | { status: 'rejected'; reason: unknown })
|
|
679
|
+
|
|
680
|
+
interface Root {
|
|
681
|
+
fiber: FiberRoot
|
|
682
|
+
store: RootStore
|
|
683
|
+
/** Set while a teardown waits on React. Configure and render clear it, which cancels the teardown */
|
|
684
|
+
unmountClaim: symbol | null
|
|
685
|
+
/** Pending only while a renderer is being created */
|
|
686
|
+
ready: TrackedPromise<unknown>
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
type AttachFnType<O = any> = (parent: any, self: O) => () => void
|
|
690
|
+
type AttachType<O = any> = string | AttachFnType<O>
|
|
691
|
+
|
|
692
|
+
type ConstructorRepresentation<T = any> = new (...args: any[]) => T
|
|
693
|
+
|
|
694
|
+
interface Catalogue {
|
|
695
|
+
[name: string]: ConstructorRepresentation
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// TODO: handle constructor overloads
|
|
699
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2931
|
|
700
|
+
// https://github.com/microsoft/TypeScript/issues/37079
|
|
701
|
+
type Args<T> = T extends ConstructorRepresentation
|
|
702
|
+
? T extends typeof Color
|
|
703
|
+
? [r: number, g: number, b: number] | [color: ColorRepresentation]
|
|
704
|
+
: ConstructorParameters<T>
|
|
705
|
+
: any[]
|
|
706
|
+
|
|
707
|
+
type ArgsProp<P> = P extends ConstructorRepresentation
|
|
708
|
+
? IsAllOptional<ConstructorParameters<P>> extends true
|
|
709
|
+
? { args?: Args<P> }
|
|
710
|
+
: { args: Args<P> }
|
|
711
|
+
: { args: unknown[] }
|
|
712
|
+
|
|
713
|
+
type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
714
|
+
object?: T
|
|
715
|
+
dispose?: null
|
|
716
|
+
attach?: AttachType<T>
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
interface Instance<O = any> {
|
|
720
|
+
root: RootStore
|
|
721
|
+
type: string
|
|
722
|
+
parent: Instance | null
|
|
723
|
+
children: Instance[]
|
|
724
|
+
props: InstanceProps<O> & Record<string, unknown>
|
|
725
|
+
object: O & { __r3f?: Instance<O> }
|
|
726
|
+
eventCount: number
|
|
727
|
+
handlers: Partial<EventHandlers>
|
|
728
|
+
attach?: AttachType<O>
|
|
729
|
+
previousAttach?: any
|
|
730
|
+
isHidden: boolean
|
|
731
|
+
/** Set of props that have been applied via once() */
|
|
732
|
+
appliedOnce?: Set<string>
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
interface HostConfig {
|
|
736
|
+
type: string
|
|
737
|
+
props: Instance['props']
|
|
738
|
+
container: RootStore
|
|
739
|
+
instance: Instance
|
|
740
|
+
textInstance: void
|
|
741
|
+
suspenseInstance: Instance
|
|
742
|
+
hydratableInstance: never
|
|
743
|
+
formInstance: never
|
|
744
|
+
publicInstance: Instance['object']
|
|
745
|
+
hostContext: {}
|
|
746
|
+
childSet: never
|
|
747
|
+
timeoutHandle: number | undefined
|
|
748
|
+
noTimeout: -1
|
|
749
|
+
TransitionStatus: null
|
|
750
|
+
}
|
|
751
|
+
declare global {
|
|
752
|
+
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
|
|
753
|
+
}
|
|
754
|
+
|
|
657
755
|
interface RootExtension {
|
|
658
756
|
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
659
757
|
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
@@ -695,7 +793,14 @@ declare function useStore(): RootStore;
|
|
|
695
793
|
*/
|
|
696
794
|
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
697
795
|
|
|
796
|
+
/**
|
|
797
|
+
* React context that carries the current root's {@link RootStore}. Each root provides its store and
|
|
798
|
+
* each portal provides its own scoped one; `useStore`, and every hook built on it, reads it.
|
|
799
|
+
*
|
|
800
|
+
* Stored on `globalThis` under `Symbol.for('@react-three/fiber.context')`, so every copy and entry
|
|
801
|
+
* of fiber shares a single context.
|
|
802
|
+
*/
|
|
698
803
|
declare const context: React.Context<RootStore>;
|
|
699
804
|
|
|
700
|
-
export { useStore as
|
|
701
|
-
export type {
|
|
805
|
+
export { useStore as ah, useThree as ai, context as aj, registerRootExtension as r, setRenderOverride as s };
|
|
806
|
+
export type { ObjectMap as $, AttachFnType as A, ArgsProp as B, ConstructorRepresentation as C, Dpr as D, Events as E, Frameloop as F, InstanceProps as G, Instance as H, InternalState as I, HostConfig as J, Properties as K, IsOptional as L, Mutable as M, NonFunctionKeys as N, Overwrite as O, PointerState as P, IsAllOptional as Q, R3FRenderTarget as R, Subscription as S, ThreeEvent as T, ThreeCamera as U, Viewport as V, Act as W, XRManager as X, Bridge as Y, SetBlock as Z, UnblockProps as _, RootExtension as a, EquConfig as a0, Disposable as a1, FrameNextState as a2, FrameState as a3, FrameNextCallback as a4, FrameCallback as a5, ThreeNamespace as a6, ThreeCore as a7, OcclusionSupport as a8, WebGLSupport as a9, WebGPUSupport as aa, RendererSupport as ab, RendererProvider as ac, Register as ad, RegisteredRenderer as ae, ForRegisteredRenderer as af, R3FRendererSupport as ag, R3FRenderer as b, Size as c, RenderCallback as d, Performance as e, RootState as f, RootStore as g, Intersection as h, Camera as i, IntersectionEvent as j, DomEvent as k, EventHandlers as l, FilterFunction as m, ComputeFunction as n, XRPointerConfig as o, EventManager as p, PointerCaptureTarget as q, VisibilityEntry as t, FiberRoot as u, TrackedPromise as v, Root as w, AttachType as x, Catalogue as y, Args as z };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { a4 as FrameNextCallback } from './fiber.CLTHZhZp.js';
|
|
2
|
+
import { UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
6
|
+
*
|
|
7
|
+
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
8
|
+
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
9
|
+
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
10
|
+
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
11
|
+
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
12
|
+
*
|
|
13
|
+
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
14
|
+
*
|
|
15
|
+
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
16
|
+
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
17
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Simple priority (backwards compat)
|
|
21
|
+
* useFrame((state, delta) => { ... }, 5)
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // With phase-based ordering
|
|
25
|
+
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
29
|
+
* function UI() {
|
|
30
|
+
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
31
|
+
* return <button>...</button>;
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
36
|
+
* import { getScheduler } from '@pmndrs/scheduler'
|
|
37
|
+
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Scheduler-only access (no callback)
|
|
41
|
+
* const { scheduler } = useFrame()
|
|
42
|
+
* scheduler.pauseJob('some-job-id')
|
|
43
|
+
*
|
|
44
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
45
|
+
*/
|
|
46
|
+
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
47
|
+
|
|
48
|
+
export { useFrame as u };
|
|
@@ -284,6 +284,33 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
284
284
|
return controls;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
+
const R3F_STAGED_TEXTURES = Symbol.for("@react-three/fiber.stagedTextures");
|
|
288
|
+
const globalStaging = globalThis;
|
|
289
|
+
const staging = globalStaging[R3F_STAGED_TEXTURES] ?? (globalStaging[R3F_STAGED_TEXTURES] = /* @__PURE__ */ new WeakMap());
|
|
290
|
+
function stageTextures(store, entries) {
|
|
291
|
+
const registered = store.getState().textures;
|
|
292
|
+
let staged = staging.get(store);
|
|
293
|
+
for (const [url, texture] of entries) {
|
|
294
|
+
if (registered.has(url)) continue;
|
|
295
|
+
if (!staged) staging.set(store, staged = /* @__PURE__ */ new Map());
|
|
296
|
+
staged.set(url, texture);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function unstageTextures(store, urls) {
|
|
300
|
+
const staged = staging.get(store);
|
|
301
|
+
if (!staged) return;
|
|
302
|
+
for (const url of urls) staged.delete(url);
|
|
303
|
+
if (staged.size === 0) staging.delete(store);
|
|
304
|
+
}
|
|
305
|
+
function getTextureView(store) {
|
|
306
|
+
const registered = store.getState().textures;
|
|
307
|
+
const staged = staging.get(store);
|
|
308
|
+
if (!staged) return registered;
|
|
309
|
+
const view = new Map(registered);
|
|
310
|
+
for (const [url, texture] of staged) if (!view.has(url)) view.set(url, texture);
|
|
311
|
+
return view;
|
|
312
|
+
}
|
|
313
|
+
|
|
287
314
|
const R3F_EXTENSIONS = Symbol.for("@react-three/fiber.extensions");
|
|
288
315
|
function getRegistry() {
|
|
289
316
|
return globalThis[R3F_EXTENSIONS] ?? (globalThis[R3F_EXTENSIONS] = {
|
|
@@ -334,4 +361,4 @@ function notifyRootExtensionsHmr(store) {
|
|
|
334
361
|
for (const setUpBy of applied.values()) current(registry, setUpBy).hmr?.(store);
|
|
335
362
|
}
|
|
336
363
|
|
|
337
|
-
export { Block as B, ErrorBoundary as E, useThree as a, useFrame as b, context as c, useIsomorphicLayoutEffect as d, useMutableCallback as e, useBridge as f,
|
|
364
|
+
export { Block as B, ErrorBoundary as E, useThree as a, useFrame as b, context as c, useIsomorphicLayoutEffect as d, useMutableCallback as e, useBridge as f, getTextureView as g, unstageTextures as h, stageTextures as i, attachRootExtensions as j, detachRootExtensions as k, notifyAlpha as l, notifyRootExtensionsHmr as m, notifyDepreciated as n, registerRootExtension as r, setRenderOverride as s, useStore as u };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { a4 as FrameNextCallback } from './fiber.CLTHZhZp.mjs';
|
|
2
|
+
import { UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
6
|
+
*
|
|
7
|
+
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
8
|
+
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
9
|
+
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
10
|
+
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
11
|
+
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
12
|
+
*
|
|
13
|
+
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
14
|
+
*
|
|
15
|
+
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
16
|
+
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
17
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Simple priority (backwards compat)
|
|
21
|
+
* useFrame((state, delta) => { ... }, 5)
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // With phase-based ordering
|
|
25
|
+
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
29
|
+
* function UI() {
|
|
30
|
+
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
31
|
+
* return <button>...</button>;
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
36
|
+
* import { getScheduler } from '@pmndrs/scheduler'
|
|
37
|
+
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Scheduler-only access (no callback)
|
|
41
|
+
* const { scheduler } = useFrame()
|
|
42
|
+
* scheduler.pauseJob('some-job-id')
|
|
43
|
+
*
|
|
44
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
45
|
+
*/
|
|
46
|
+
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
47
|
+
|
|
48
|
+
export { useFrame as u };
|