@react-three/fiber 10.0.0-alpha.2 → 10.0.0-canary.0f8db17

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.
@@ -1,14 +1,17 @@
1
1
  import * as three_webgpu from 'three/webgpu';
2
- import { RenderTarget, Node, ShaderNodeObject, Euler as Euler$1, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Quaternion as Quaternion$1, Matrix3 as Matrix3$1, Matrix4 as Matrix4$1, Object3D, Texture as Texture$1, Frustum, OrthographicCamera } from 'three/webgpu';
2
+ import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera, WebGPURendererParameters } from 'three/webgpu';
3
3
  import { Inspector } from 'three/addons/inspector/Inspector.js';
4
4
  import * as THREE$1 from 'three';
5
- import { Color as Color$1, ColorRepresentation, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
5
+ import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
6
6
  import * as React$1 from 'react';
7
7
  import { ReactNode, Component, RefObject, JSX } from 'react';
8
8
  import { StoreApi } from 'zustand';
9
9
  import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
10
+ import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
11
+ export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
10
12
  import { Options } from 'react-use-measure';
11
13
  import * as react_jsx_runtime from 'react/jsx-runtime';
14
+ import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
12
15
 
13
16
  function _mergeNamespaces(n, m) {
14
17
  m.forEach(function (e) {
@@ -45,1294 +48,1434 @@ type WebGLShadowMap = never;
45
48
 
46
49
  declare const WebGLRenderTarget: any;
47
50
 
51
+ declare const WebGLCubeRenderTarget: any;
52
+
48
53
  var THREE = /*#__PURE__*/_mergeNamespaces({
49
54
  __proto__: null,
55
+ CubeRenderTargetCompat: CubeRenderTarget,
50
56
  Inspector: Inspector,
51
57
  R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
52
58
  R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
53
59
  RenderTargetCompat: RenderTarget,
60
+ WebGLCubeRenderTarget: WebGLCubeRenderTarget,
54
61
  WebGLRenderTarget: WebGLRenderTarget,
55
62
  WebGLRenderer: WebGLRenderer,
56
63
  WebGLRendererParameters: WebGLRendererParameters,
57
64
  WebGLShadowMap: WebGLShadowMap
58
65
  }, [three_webgpu]);
59
66
 
60
- //* Utility Types ==============================
61
-
62
- type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
63
- type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
64
- type Properties<T> = Pick<T, NonFunctionKeys<T>>
65
- type Mutable<P> = { [K in keyof P]: P[K] | Readonly<P[K]> }
66
- type IsOptional<T> = undefined extends T ? true : false
67
- type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
68
- ? IsOptional<First> extends true
69
- ? IsAllOptional<Rest>
70
- : false
71
- : true
72
-
73
- //* Camera Types ==============================
74
-
75
- type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
76
-
77
- //* Act Type ==============================
78
-
79
- type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
80
-
81
- //* Bridge & Block Types ==============================
82
-
83
- type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
84
-
85
- type SetBlock = false | Promise<null> | null
86
- type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
87
-
88
- //* Object Map Type ==============================
89
-
90
- interface ObjectMap {
91
- nodes: { [name: string]: THREE$1.Object3D }
92
- materials: { [name: string]: THREE$1.Material }
93
- meshes: { [name: string]: THREE$1.Mesh }
94
- }
95
-
96
- //* Equality Config ==============================
97
-
98
- interface EquConfig {
99
- /** Compare arrays by reference equality a === b (default), or by shallow equality */
100
- arrays?: 'reference' | 'shallow'
101
- /** Compare objects by reference equality a === b (default), or by shallow equality */
102
- objects?: 'reference' | 'shallow'
103
- /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
104
- strict?: boolean
105
- }
106
-
107
- //* Disposable Type ==============================
108
-
109
- interface Disposable {
110
- type?: string
111
- dispose?: () => void
112
- }
113
-
114
- //* Event-related Types =====================================
115
-
116
- interface Intersection extends THREE$1.Intersection {
117
- /** The event source (the object which registered the handler) */
118
- eventObject: THREE$1.Object3D
119
- }
120
-
121
- type Camera = THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera
122
-
123
- interface IntersectionEvent<TSourceEvent> extends Intersection {
124
- /** The event source (the object which registered the handler) */
125
- eventObject: THREE$1.Object3D
126
- /** An array of intersections */
127
- intersections: Intersection[]
128
- /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
129
- unprojectedPoint: THREE$1.Vector3
130
- /** Normalized event coordinates */
131
- pointer: THREE$1.Vector2
132
- /** Delta between first click and this event */
133
- delta: number
134
- /** The ray that pierced it */
135
- ray: THREE$1.Ray
136
- /** The camera that was used by the raycaster */
137
- camera: Camera
138
- /** stopPropagation will stop underlying handlers from firing */
139
- stopPropagation: () => void
140
- /** The original host event */
141
- nativeEvent: TSourceEvent
142
- /** If the event was stopped by calling stopPropagation */
143
- stopped: boolean
144
- }
145
-
146
- type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>
147
- type DomEvent = PointerEvent | MouseEvent | WheelEvent
148
-
149
- /** DOM event handlers registered on the canvas element */
150
- interface Events {
151
- onClick: EventListener
152
- onContextMenu: EventListener
153
- onDoubleClick: EventListener
154
- onWheel: EventListener
155
- onPointerDown: EventListener
156
- onPointerUp: EventListener
157
- onPointerLeave: EventListener
158
- onPointerMove: EventListener
159
- onPointerCancel: EventListener
160
- onLostPointerCapture: EventListener
161
- onDragEnter: EventListener
162
- onDragLeave: EventListener
163
- onDragOver: EventListener
164
- onDrop: EventListener
165
- }
166
-
167
- /** Event handlers that can be attached to R3F objects (meshes, groups, etc.) */
168
- interface EventHandlers {
169
- onClick?: (event: ThreeEvent<MouseEvent>) => void
170
- onContextMenu?: (event: ThreeEvent<MouseEvent>) => void
171
- onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void
172
- /** Fires continuously while dragging over the object */
173
- onDragOver?: (event: ThreeEvent<DragEvent>) => void
174
- /** Fires once when drag enters the object */
175
- onDragOverEnter?: (event: ThreeEvent<DragEvent>) => void
176
- /** Fires once when drag leaves the object */
177
- onDragOverLeave?: (event: ThreeEvent<DragEvent>) => void
178
- /** Fires when drag misses this object (for objects that have drag handlers) */
179
- onDragOverMissed?: (event: DragEvent) => void
180
- /** Fires when a drop occurs on this object */
181
- onDrop?: (event: ThreeEvent<DragEvent>) => void
182
- /** Fires when a drop misses this object (for objects that have drop handlers) */
183
- onDropMissed?: (event: DragEvent) => void
184
- onPointerUp?: (event: ThreeEvent<PointerEvent>) => void
185
- onPointerDown?: (event: ThreeEvent<PointerEvent>) => void
186
- onPointerOver?: (event: ThreeEvent<PointerEvent>) => void
187
- onPointerOut?: (event: ThreeEvent<PointerEvent>) => void
188
- onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void
189
- onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void
190
- onPointerMove?: (event: ThreeEvent<PointerEvent>) => void
191
- onPointerMissed?: (event: MouseEvent) => void
192
- onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
193
- onWheel?: (event: ThreeEvent<WheelEvent>) => void
194
- onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
195
-
196
- //* Visibility Events --------------------------------
197
- /** Fires when object enters/exits camera frustum. Receives true when in view, false when out. */
198
- onFramed?: (inView: boolean) => void
199
- /** Fires when object occlusion state changes (WebGPU only, requires occlusionTest=true on object) */
200
- onOccluded?: (occluded: boolean) => void
201
- /** Fires when combined visibility changes (frustum + occlusion + visible prop) */
202
- onVisible?: (visible: boolean) => void
203
- }
204
-
205
- type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
206
- type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
207
-
208
- interface EventManager<TTarget> {
209
- /** Determines if the event layer is active */
210
- enabled: boolean
211
- /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
212
- priority: number
213
- /** The compute function needs to set up the raycaster and an xy- pointer */
214
- compute?: ComputeFunction
215
- /** The filter can re-order or re-structure the intersections */
216
- filter?: FilterFunction
217
- /** The target node the event layer is tied to */
218
- connected?: TTarget
219
- /** All the pointer event handlers through which the host forwards native events */
220
- handlers?: Events
221
- /** Allows re-connecting to another target */
222
- connect?: (target: TTarget) => void
223
- /** Removes all existing events handlers from the target */
224
- disconnect?: () => void
225
- /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
226
- * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
227
- */
228
- update?: () => void
229
- }
230
-
231
- interface PointerCaptureTarget {
232
- intersection: Intersection
233
- target: Element
234
- }
235
-
236
- //* Visibility System Types =====================================
237
-
238
- /** Entry in the visibility registry for tracking object visibility state */
239
- interface VisibilityEntry {
240
- object: THREE$1.Object3D
241
- handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
242
- lastFramedState: boolean | null
243
- lastOccludedState: boolean | null
244
- lastVisibleState: boolean | null
245
- }
246
-
247
- //* Scheduler Types (useFrame) ==============================
248
-
249
-
250
-
251
- // Public Options --------------------------------
252
-
253
- /**
254
- * Options for useFrame hook
255
- */
256
- interface UseFrameNextOptions {
257
- /** Optional stable id for the job. Auto-generated if not provided */
258
- id?: string
259
- /** Named phase to run in. Default: 'update' */
260
- phase?: string
261
- /** Run before this phase or job id */
262
- before?: string | string[]
263
- /** Run after this phase or job id */
264
- after?: string | string[]
265
- /** Priority within phase. Higher runs first. Default: 0 */
266
- priority?: number
267
- /** Max frames per second for this job */
268
- fps?: number
269
- /** If true, skip frames when behind. If false, try to catch up. Default: true */
270
- drop?: boolean
271
- /** Enable/disable without unregistering. Default: true */
272
- enabled?: boolean
273
- }
274
-
275
- /** Alias for UseFrameNextOptions */
276
- type UseFrameOptions = UseFrameNextOptions
277
-
278
- /**
279
- * Options for addPhase
280
- */
281
- interface AddPhaseOptions {
282
- /** Insert this phase before the specified phase */
283
- before?: string
284
- /** Insert this phase after the specified phase */
285
- after?: string
286
- }
287
-
288
- // Frame State --------------------------------
289
-
290
- /**
291
- * Timing-only state for independent/outside mode (no RootState)
292
- */
293
- interface FrameTimingState {
294
- /** High-resolution timestamp from RAF (ms) */
295
- time: number
296
- /** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
297
- delta: number
298
- /** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
299
- elapsed: number
300
- /** Incrementing frame counter */
301
- frame: number
302
- }
303
-
304
- /**
305
- * State passed to useFrame callbacks (extends RootState with timing)
306
- */
307
- interface FrameNextState extends RootState, FrameTimingState {}
308
-
309
- /** Alias for FrameNextState */
310
- type FrameState = FrameNextState
311
-
312
- // Root Options --------------------------------
313
-
314
- /**
315
- * Options for registerRoot
316
- */
317
- interface RootOptions {
318
- /** State provider for callbacks. Optional in independent mode. */
319
- getState?: () => any
320
- /** Error handler for job errors. Falls back to console.error if not provided. */
321
- onError?: (error: Error) => void
322
- }
323
-
324
- // Callback Types --------------------------------
325
-
326
- /**
327
- * Callback function for useFrame
328
- */
329
- type FrameNextCallback = (state: FrameNextState, delta: number) => void
330
-
331
- /** Alias for FrameNextCallback */
332
- type FrameCallback = FrameNextCallback
333
-
334
- // Controls returned from useFrame --------------------------------
335
-
336
- /**
337
- * Controls object returned from useFrame hook
338
- */
339
- interface FrameNextControls {
340
- /** The job's unique ID */
341
- id: string
342
- /** Access to the global scheduler for frame loop control */
343
- scheduler: SchedulerApi
344
- /** Manually step this job only (bypasses FPS limiting) */
345
- step(timestamp?: number): void
346
- /** Manually step ALL jobs in the scheduler */
347
- stepAll(timestamp?: number): void
348
- /** Pause this job (set enabled=false) */
349
- pause(): void
350
- /** Resume this job (set enabled=true) */
351
- resume(): void
352
- /** Reactive paused state - automatically triggers re-render when changed */
353
- isPaused: boolean
354
- }
355
-
356
- /** Alias for FrameNextControls */
357
- type FrameControls = FrameNextControls
358
-
359
- // Scheduler Interface --------------------------------
360
-
361
- /**
362
- * Public interface for the global Scheduler
363
- */
364
- interface SchedulerApi {
365
- //* Phase Management --------------------------------
366
-
367
- /** Add a named phase to the scheduler */
368
- addPhase(name: string, options?: AddPhaseOptions): void
369
- /** Get the ordered list of phase names */
370
- readonly phases: string[]
371
- /** Check if a phase exists */
372
- hasPhase(name: string): boolean
373
-
374
- //* Root Management --------------------------------
375
-
376
- /** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
377
- registerRoot(id: string, options?: RootOptions): () => void
378
- /** Unregister a root */
379
- unregisterRoot(id: string): void
380
- /** Generate a unique root ID */
381
- generateRootId(): string
382
- /** Get the number of registered roots */
383
- getRootCount(): number
384
- /** Check if any root is registered and ready */
385
- readonly isReady: boolean
386
- /** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
387
- onRootReady(callback: () => void): () => void
388
-
389
- //* Job Registration --------------------------------
390
-
391
- /** Register a job with the scheduler (returns unsubscribe function) */
392
- register(
393
- callback: FrameNextCallback,
394
- options?: {
395
- id?: string
396
- rootId?: string
397
- phase?: string
398
- before?: string | string[]
399
- after?: string | string[]
400
- priority?: number
401
- fps?: number
402
- drop?: boolean
403
- enabled?: boolean
404
- },
405
- ): () => void
406
- /** Update a job's options */
407
- updateJob(
408
- id: string,
409
- options: {
410
- priority?: number
411
- fps?: number
412
- drop?: boolean
413
- enabled?: boolean
414
- phase?: string
415
- before?: string | string[]
416
- after?: string | string[]
417
- },
418
- ): void
419
- /** Unregister a job by ID */
420
- unregister(id: string, rootId?: string): void
421
- /** Get the number of registered jobs */
422
- getJobCount(): number
423
- /** Get all job IDs */
424
- getJobIds(): string[]
425
-
426
- //* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
427
-
428
- /** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
429
- registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
430
-
431
- //* Idle Callbacks (for legacy addTail) --------------------------------
432
-
433
- /** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
434
- onIdle(callback: (timestamp: number) => void): () => void
435
-
436
- //* Frame Loop Control --------------------------------
437
-
438
- /** Start the scheduler loop */
439
- start(): void
440
- /** Stop the scheduler loop */
441
- stop(): void
442
- /** Check if the scheduler is running */
443
- readonly isRunning: boolean
444
- /** Get/set the frameloop mode ('always', 'demand', 'never') */
445
- frameloop: Frameloop
446
- /** Independent mode - runs without Canvas, callbacks receive timing-only state */
447
- independent: boolean
448
-
449
- //* Manual Stepping --------------------------------
450
-
451
- /** Manually step all jobs once (for frameloop='never' or testing) */
452
- step(timestamp?: number): void
453
- /** Manually step a single job by ID */
454
- stepJob(id: string, timestamp?: number): void
455
- /** Request frame(s) to be rendered (for frameloop='demand') */
456
- invalidate(frames?: number): void
457
-
458
- //* Per-Job Control --------------------------------
459
-
460
- /** Check if a job is paused */
461
- isJobPaused(id: string): boolean
462
- /** Pause a job */
463
- pauseJob(id: string): void
464
- /** Resume a job */
465
- resumeJob(id: string): void
466
- /** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
467
- subscribeJobState(id: string, listener: () => void): () => void
468
- }
469
-
470
- //* Core Store Types ========================================
471
-
472
- type Subscription = {
473
- ref: React$1.RefObject<RenderCallback>
474
- priority: number
475
- store: RootStore
476
- }
477
-
478
- type Dpr = number | [min: number, max: number]
479
-
480
- interface Size {
481
- width: number
482
- height: number
483
- top: number
484
- left: number
485
- }
486
-
487
- type Frameloop = 'always' | 'demand' | 'never'
488
-
489
- interface Viewport extends Size {
490
- /** The initial pixel ratio */
491
- initialDpr: number
492
- /** Current pixel ratio */
493
- dpr: number
494
- /** size.width / viewport.width */
495
- factor: number
496
- /** Camera distance */
497
- distance: number
498
- /** Camera aspect ratio: width / height */
499
- aspect: number
500
- }
501
-
502
- type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void
503
-
504
- interface Performance {
505
- /** Current performance normal, between min and max */
506
- current: number
507
- /** How low the performance can go, between 0 and max */
508
- min: number
509
- /** How high the performance can go, between min and max */
510
- max: number
511
- /** Time until current returns to max in ms */
512
- debounce: number
513
- /** Sets current to min, puts the system in regression */
514
- regress: () => void
515
- }
516
-
517
- interface InternalState {
518
- interaction: THREE$1.Object3D[]
519
- hovered: Map<string, ThreeEvent<DomEvent>>
520
- subscribers: Subscription[]
521
- capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
522
- initialClick: [x: number, y: number]
523
- initialHits: THREE$1.Object3D[]
524
- lastEvent: React$1.RefObject<DomEvent | null>
525
- /** Visibility event registry (onFramed, onOccluded, onVisible) */
526
- visibilityRegistry: Map<string, VisibilityEntry>
527
- /** Whether occlusion queries are enabled (WebGPU only) */
528
- occlusionEnabled: boolean
529
- /** Reference to the invisible occlusion observer mesh */
530
- occlusionObserver: THREE$1.Mesh | null
531
- /** Cached occlusion results from render pass - keyed by Object3D */
532
- occlusionCache: Map<THREE$1.Object3D, boolean | null>
533
- /** Internal helper group for R3F system objects (occlusion observer, etc.) */
534
- helperGroup: THREE$1.Group | null
535
- active: boolean
536
- priority: number
537
- frames: number
538
- subscribe: (callback: React$1.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
539
- /** Internal renderer storage - use state.renderer or state.gl to access */
540
- actualRenderer: THREE$1.WebGLRenderer | any // WebGPURenderer when available
541
- /** Global scheduler reference (for useFrame hook) */
542
- scheduler: SchedulerApi | null
543
- /** This root's unique ID in the global scheduler */
544
- rootId?: string
545
- /** Function to unregister this root from the global scheduler */
546
- unregisterRoot?: () => void
547
- /** Container for child attachment (scene for root, original container for portals) */
548
- container?: THREE$1.Object3D
549
- }
550
-
551
- interface XRManager {
552
- connect: () => void
553
- disconnect: () => void
554
- }
555
-
556
- //* Root State Interface ====================================
557
-
558
- interface RootState {
559
- /** Set current state */
560
- set: StoreApi<RootState>['setState']
561
- /** Get current state */
562
- get: StoreApi<RootState>['getState']
563
- /** (deprecated) The instance of the WebGLrenderer */
564
- gl: THREE$1.WebGLRenderer
565
- /** The instance of the WebGPU renderer, the fallback, OR the default renderer as a mask of gl */
566
- renderer: THREE$1.WebGLRenderer | any // WebGPURenderer when available
567
- /** Inspector of the webGPU Renderer. Init in the canvas */
568
- inspector: any // Inspector type from three/webgpu
569
-
570
- /** Default camera */
571
- camera: ThreeCamera
572
- /** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
573
- frustum: THREE$1.Frustum
574
- /** Whether to automatically update the frustum each frame (default: true) */
575
- autoUpdateFrustum: boolean
576
- /** Default scene (may be overridden in portals to point to the portal container) */
577
- scene: THREE$1.Scene
578
- /** The actual root THREE.Scene - always points to the true scene, even inside portals */
579
- rootScene: THREE$1.Scene
580
- /** Default raycaster */
581
- raycaster: THREE$1.Raycaster
582
- /** Event layer interface, contains the event handler and the node they're connected to */
583
- events: EventManager<any>
584
- /** XR interface */
585
- xr: XRManager
586
- /** Currently used controls */
587
- controls: THREE$1.EventDispatcher | null
588
- /** Normalized event coordinates */
589
- pointer: THREE$1.Vector2
590
- /** @deprecated Normalized event coordinates, use "pointer" instead! */
591
- mouse: THREE$1.Vector2
592
- /* Whether to enable r139's THREE.ColorManagement */
593
- legacy: boolean
594
- /** Shortcut to gl.outputColorSpace = THREE.LinearSRGBColorSpace */
595
- linear: boolean
596
- /** Shortcut to gl.toneMapping = NoTonemapping */
597
- flat: boolean
598
- /** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
599
- textureColorSpace: THREE$1.ColorSpace
600
- /** Render loop flags */
601
- frameloop: Frameloop
602
- performance: Performance
603
- /** Reactive pixel-size of the canvas */
604
- size: Size
605
- /** Reactive size of the viewport in threejs units */
606
- viewport: Viewport & {
607
- getCurrentViewport: (
608
- camera?: ThreeCamera,
609
- target?: THREE$1.Vector3 | Parameters<THREE$1.Vector3['set']>,
610
- size?: Size,
611
- ) => Omit<Viewport, 'dpr' | 'initialDpr'>
612
- }
613
- /** Flags the canvas for render, but doesn't render in itself */
614
- invalidate: (frames?: number, stackFrames?: boolean) => void
615
- /** Advance (render) one step */
616
- advance: (timestamp: number, runGlobalEffects?: boolean) => void
617
- /** Shortcut to setting the event layer */
618
- setEvents: (events: Partial<EventManager<any>>) => void
619
- /** Shortcut to manual sizing. No args resets to props/container. Single arg creates square. */
620
- setSize: (width?: number, height?: number, top?: number, left?: number) => void
621
- /** Shortcut to manual setting the pixel ratio */
622
- setDpr: (dpr: Dpr) => void
623
- /** Shortcut to setting frameloop flags */
624
- setFrameloop: (frameloop: Frameloop) => void
625
- /** Set error state to propagate to error boundary */
626
- setError: (error: Error | null) => void
627
- /** Current error state (null when no error) */
628
- error: Error | null
629
- /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
630
- uniforms: UniformStore
631
- /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
632
- nodes: Record<string, any>
633
- /** Global TSL texture nodes - use useTextures() hook for operations */
634
- textures: Map<string, any>
635
- /** WebGPU PostProcessing instance - use usePostProcessing() hook */
636
- postProcessing: any | null // THREE.PostProcessing when available
637
- /** Global TSL pass nodes for post-processing - use usePostProcessing() hook */
638
- passes: Record<string, any>
639
- /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
640
- _hmrVersion: number
641
- /** Internal: whether setSize() has taken ownership of canvas dimensions */
642
- _sizeImperative: boolean
643
- /** Internal: stored size props from Canvas for reset functionality */
644
- _sizeProps: { width?: number; height?: number } | null
645
- /** When the canvas was clicked but nothing was hit */
646
- onPointerMissed?: (event: MouseEvent) => void
647
- /** When a dragover event has missed any target */
648
- onDragOverMissed?: (event: DragEvent) => void
649
- /** When a drop event has missed any target */
650
- onDropMissed?: (event: DragEvent) => void
651
- /** If this state model is layered (via createPortal) then this contains the previous layer */
652
- previousRoot?: RootStore
653
- /** Internals */
654
- internal: InternalState
655
- // flags for triggers
656
- // if we are using the webGl renderer, this will be true
657
- isLegacy: boolean
658
- // regardless of renderer, if the system supports webGpu, this will be true
659
- webGPUSupported: boolean
660
- //if we are on native
661
- isNative: boolean
662
- }
663
-
67
+ //* Utility Types ==============================
68
+
69
+ type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
70
+ type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
71
+ type Properties<T> = Pick<T, NonFunctionKeys<T>>
72
+ type Mutable<P> = { -readonly [K in keyof P]: P[K] }
73
+ type IsOptional<T> = undefined extends T ? true : false
74
+ type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
75
+ ? IsOptional<First> extends true
76
+ ? IsAllOptional<Rest>
77
+ : false
78
+ : true
79
+
80
+ //* Camera Types ==============================
81
+
82
+ type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
83
+
84
+ //* Act Type ==============================
85
+
86
+ type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
87
+
88
+ //* Bridge & Block Types ==============================
89
+
90
+ type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
91
+
92
+ type SetBlock = false | Promise<null> | null
93
+ type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
94
+
95
+ //* Object Map Type ==============================
96
+
97
+ /* Original version
98
+ export interface ObjectMap {
99
+ nodes: { [name: string]: THREE.Object3D }
100
+ materials: { [name: string]: THREE.Material }
101
+ meshes: { [name: string]: THREE.Mesh }
102
+ }
103
+ */
104
+ /* This version is an expansion found in a PR by itsdouges that seems abandoned but looks useful.
105
+ It allows expansion but falls back to the original shape. (deleted due to stale, but If it doesnt conflict
106
+ I will keep the use here)
107
+ https://github.com/pmndrs/react-three-fiber/commits/generic-object-map/
108
+ His description is:
109
+ The object map type is now generic and can optionally declare the available properties for nodes, materials, and meshes.
110
+ */
111
+ interface ObjectMap<
112
+ T extends { nodes?: string; materials?: string; meshes?: string } = {
113
+ nodes: string
114
+ materials: string
115
+ meshes: string
116
+ },
117
+ > {
118
+ nodes: Record<T['nodes'] extends string ? T['nodes'] : string, THREE$1.Object3D>
119
+ materials: Record<T['materials'] extends string ? T['materials'] : string, THREE$1.Material>
120
+ meshes: Record<T['meshes'] extends string ? T['meshes'] : string, THREE$1.Mesh>
121
+ }
122
+
123
+ //* Equality Config ==============================
124
+
125
+ interface EquConfig {
126
+ /** Compare arrays by reference equality a === b (default), or by shallow equality */
127
+ arrays?: 'reference' | 'shallow'
128
+ /** Compare objects by reference equality a === b (default), or by shallow equality */
129
+ objects?: 'reference' | 'shallow'
130
+ /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
131
+ strict?: boolean
132
+ }
133
+
134
+ //* Disposable Type ==============================
135
+
136
+ interface Disposable {
137
+ type?: string
138
+ dispose?: () => void
139
+ }
140
+
141
+ //* Event-related Types =====================================
142
+
143
+ interface Intersection extends THREE$1.Intersection {
144
+ /** The event source (the object which registered the handler) */
145
+ eventObject: THREE$1.Object3D
146
+ }
147
+
148
+ type Camera = THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera
149
+
150
+ interface IntersectionEvent<TSourceEvent> extends Intersection {
151
+ /** The event source (the object which registered the handler) */
152
+ eventObject: THREE$1.Object3D
153
+ /** An array of intersections */
154
+ intersections: Intersection[]
155
+ /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
156
+ unprojectedPoint: THREE$1.Vector3
157
+ /** Normalized event coordinates */
158
+ pointer: THREE$1.Vector2
159
+ /** pointerId of the original event for multiple pointer events */
160
+ pointerId: number
161
+ /** Delta between first click and this event */
162
+ delta: number
163
+ /** The ray that pierced it */
164
+ ray: THREE$1.Ray
165
+ /** The camera that was used by the raycaster */
166
+ camera: Camera
167
+ /** stopPropagation will stop underlying handlers from firing */
168
+ stopPropagation: () => void
169
+ /** The original host event */
170
+ nativeEvent: TSourceEvent
171
+ /** If the event was stopped by calling stopPropagation */
172
+ stopped: boolean
173
+ }
174
+
175
+ type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>
176
+ type DomEvent = PointerEvent | MouseEvent | WheelEvent
177
+
178
+ /** DOM event handlers registered on the canvas element */
179
+ interface Events {
180
+ onClick: EventListener
181
+ onContextMenu: EventListener
182
+ onDoubleClick: EventListener
183
+ onWheel: EventListener
184
+ onPointerDown: EventListener
185
+ onPointerUp: EventListener
186
+ onPointerLeave: EventListener
187
+ onPointerMove: EventListener
188
+ onPointerCancel: EventListener
189
+ onLostPointerCapture: EventListener
190
+ onDragEnter: EventListener
191
+ onDragLeave: EventListener
192
+ onDragOver: EventListener
193
+ onDrop: EventListener
194
+ }
195
+
196
+ /** Event handlers that can be attached to R3F objects (meshes, groups, etc.) */
197
+ interface EventHandlers {
198
+ onClick?: (event: ThreeEvent<MouseEvent>) => void
199
+ onContextMenu?: (event: ThreeEvent<MouseEvent>) => void
200
+ onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void
201
+ /** Fires continuously while dragging over the object */
202
+ onDragOver?: (event: ThreeEvent<DragEvent>) => void
203
+ /** Fires once when drag enters the object */
204
+ onDragOverEnter?: (event: ThreeEvent<DragEvent>) => void
205
+ /** Fires once when drag leaves the object */
206
+ onDragOverLeave?: (event: ThreeEvent<DragEvent>) => void
207
+ /** Fires when drag misses this object (for objects that have drag handlers) */
208
+ onDragOverMissed?: (event: DragEvent) => void
209
+ /** Fires when a drop occurs on this object */
210
+ onDrop?: (event: ThreeEvent<DragEvent>) => void
211
+ /** Fires when a drop misses this object (for objects that have drop handlers) */
212
+ onDropMissed?: (event: DragEvent) => void
213
+ onPointerUp?: (event: ThreeEvent<PointerEvent>) => void
214
+ onPointerDown?: (event: ThreeEvent<PointerEvent>) => void
215
+ onPointerOver?: (event: ThreeEvent<PointerEvent>) => void
216
+ onPointerOut?: (event: ThreeEvent<PointerEvent>) => void
217
+ onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void
218
+ onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void
219
+ onPointerMove?: (event: ThreeEvent<PointerEvent>) => void
220
+ onPointerMissed?: (event: MouseEvent) => void
221
+ onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
222
+ onWheel?: (event: ThreeEvent<WheelEvent>) => void
223
+ onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
224
+
225
+ //* Visibility Events --------------------------------
226
+ /** Fires when object enters/exits camera frustum. Receives true when in view, false when out. */
227
+ onFramed?: (inView: boolean) => void
228
+ /** Fires when object occlusion state changes (WebGPU only, requires occlusionTest=true on object) */
229
+ onOccluded?: (occluded: boolean) => void
230
+ /** Fires when combined visibility changes (frustum + occlusion + visible prop) */
231
+ onVisible?: (visible: boolean) => void
232
+ }
233
+
234
+ type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
235
+ type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
236
+
237
+ /** Configuration for XR pointer registration (controllers/hands) */
238
+ interface XRPointerConfig {
239
+ /** Ray origin (updated each frame by XR system) */
240
+ ray: THREE$1.Ray
241
+ /** Optional: custom compute function for this pointer */
242
+ compute?: (state: RootState) => void
243
+ /** Pointer type identifier */
244
+ type: 'controller' | 'hand' | 'gaze'
245
+ /** Which hand (for controller/hand types) */
246
+ handedness?: 'left' | 'right'
247
+ }
248
+
249
+ interface EventManager<TTarget> {
250
+ /** Determines if the event layer is active */
251
+ enabled: boolean
252
+ /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
253
+ priority: number
254
+ /** The compute function needs to set up the raycaster and an xy- pointer */
255
+ compute?: ComputeFunction
256
+ /** The filter can re-order or re-structure the intersections */
257
+ filter?: FilterFunction
258
+ /** The target node the event layer is tied to */
259
+ connected?: TTarget
260
+ /** All the pointer event handlers through which the host forwards native events */
261
+ handlers?: Events
262
+ /** Allows re-connecting to another target */
263
+ connect?: (target: TTarget) => void
264
+ /** Removes all existing events handlers from the target */
265
+ disconnect?: () => void
266
+ /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
267
+ * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
268
+ * @param pointerId - Optional pointer ID to update specific pointer only
269
+ */
270
+ update?: (pointerId?: number) => void
271
+ /** Defer pointer move raycasting to frame start (default: true) */
272
+ frameTimedRaycasts?: boolean
273
+ /** Always fire raycaster immediately on scroll events (default: true) */
274
+ alwaysFireOnScroll?: boolean
275
+ /** Automatically re-raycast every frame to detect hover changes from moving objects/camera (default: false) */
276
+ updateOnFrame?: boolean
277
+ /** Flush deferred pointer raycasts. Called by scheduler at frame start (input phase). */
278
+ flush?: () => void
279
+ /** Register an XR pointer (controller/hand). Returns assigned pointerId */
280
+ registerPointer?: (config: XRPointerConfig) => number
281
+ /** Unregister an XR pointer */
282
+ unregisterPointer?: (pointerId: number) => void
283
+ }
284
+
285
+ interface PointerCaptureTarget {
286
+ intersection: Intersection
287
+ target: Element
288
+ }
289
+
290
+ //* Visibility System Types =====================================
291
+
292
+ /** Entry in the visibility registry for tracking object visibility state */
293
+ interface VisibilityEntry {
294
+ object: THREE$1.Object3D
295
+ handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
296
+ lastFramedState: boolean | null
297
+ lastOccludedState: boolean | null
298
+ lastVisibleState: boolean | null
299
+ }
300
+
301
+ //* Scheduler Types (useFrame) ==============================
302
+ //
303
+ // The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
304
+ // This file re-exports them and layers r3f's RootState-aware frame state on top,
305
+ // so existing `#types` imports across the codebase keep resolving unchanged.
306
+
307
+
308
+
309
+ // Frame State (r3f-specific) --------------------------------
310
+
311
+ /**
312
+ * State passed to useFrame callbacks (extends RootState with timing).
313
+ */
314
+ interface FrameNextState extends RootState, FrameTimingState {}
315
+
316
+ /** Alias for FrameNextState */
317
+ type FrameState = FrameNextState
318
+
319
+ // Callback Types (r3f-specific) --------------------------------
320
+
321
+ /**
322
+ * Callback function for useFrame. Receives the full r3f RootState plus timing.
323
+ */
324
+ type FrameNextCallback = FrameCallback$1<RootState>
325
+
326
+ /** Alias for FrameNextCallback */
327
+ type FrameCallback = FrameNextCallback
328
+
329
+ //* Buffer Types (useBuffers) ========================================
330
+
331
+ /**
332
+ * Buffer-like types for GPU compute and storage operations.
333
+ * Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
334
+ *
335
+ * @example
336
+ * ```tsx
337
+ * const { positions, velocities } = useBuffers(() => ({
338
+ * positions: instancedArray(count, 'vec3'), // StorageBufferNode
339
+ * velocities: new Float32Array(count * 3), // TypedArray
340
+ * }), 'particles')
341
+ * ```
342
+ */
343
+ type BufferLike =
344
+ | Float32Array
345
+ | Uint32Array
346
+ | Int32Array
347
+ | Float64Array
348
+ | Uint8Array
349
+ | Int8Array
350
+ | Uint16Array
351
+ | Int16Array
352
+ | THREE$1.BufferAttribute // Base class for all buffer attributes
353
+ | Node // TSL buffer nodes (instancedArray, storage)
354
+
355
+ /** Flat record of buffer-like values (no nested scopes) */
356
+ type BufferRecord = Record<string, BufferLike>
357
+
358
+ /**
359
+ * Buffer store that can contain both root-level buffers and scoped buffer objects.
360
+ * Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
361
+ */
362
+ type BufferStore = Record<string, BufferLike | BufferRecord>
363
+
364
+ //* Storage Types (useGPUStorage) ========================================
365
+
366
+ /**
367
+ * GPU storage types for texture-based storage operations.
368
+ * Includes Three.js storage textures and TSL storage texture nodes.
369
+ *
370
+ * @example
371
+ * ```tsx
372
+ * const { heightMap } = useGPUStorage(() => ({
373
+ * heightMap: new StorageTexture(512, 512),
374
+ * }), 'terrain')
375
+ * ```
376
+ */
377
+ type StorageLike =
378
+ | StorageTexture // GPU storage texture
379
+ | Data3DTexture // 3D texture (can be used as storage)
380
+ | Node // TSL storage texture nodes (storageTexture)
381
+
382
+ /** Flat record of storage-like values (no nested scopes) */
383
+ type StorageRecord = Record<string, StorageLike>
384
+
385
+ /**
386
+ * Storage store that can contain both root-level storage and scoped storage objects.
387
+ * Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
388
+ */
389
+ type StorageStore = Record<string, StorageLike | StorageRecord>
390
+
391
+ //* Renderer Types ========================================
392
+
393
+ /** Default renderer type - union of WebGL and WebGPU renderers */
394
+ type R3FRenderer = THREE$1.WebGLRenderer | WebGPURenderer
395
+
396
+ //* Core Store Types ========================================
397
+
398
+ type Subscription = {
399
+ ref: React$1.RefObject<RenderCallback>
400
+ priority: number
401
+ store: RootStore
402
+ }
403
+
404
+ /** Per-pointer state for multi-touch and XR support */
405
+ type PointerState = {
406
+ /** Objects currently hovered by this pointer */
407
+ hovered: Map<string, ThreeEvent<DomEvent>>
408
+ /** Objects capturing this pointer */
409
+ captured: Map<THREE$1.Object3D, PointerCaptureTarget>
410
+ /** Initial click position [x, y] */
411
+ initialClick: [x: number, y: number]
412
+ /** Objects hit on initial click */
413
+ initialHits: THREE$1.Object3D[]
414
+ }
415
+
416
+ type Dpr = number | [min: number, max: number]
417
+
418
+ interface Size {
419
+ width: number
420
+ height: number
421
+ top: number
422
+ left: number
423
+ }
424
+
425
+ type Frameloop = 'always' | 'demand' | 'never'
426
+
427
+ interface Viewport extends Size {
428
+ /** The initial pixel ratio */
429
+ initialDpr: number
430
+ /** Current pixel ratio */
431
+ dpr: number
432
+ /** size.width / viewport.width */
433
+ factor: number
434
+ /** Camera distance */
435
+ distance: number
436
+ /** Camera aspect ratio: width / height */
437
+ aspect: number
438
+ }
439
+
440
+ type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void
441
+
442
+ interface Performance {
443
+ /** Current performance normal, between min and max */
444
+ current: number
445
+ /** How low the performance can go, between 0 and max */
446
+ min: number
447
+ /** How high the performance can go, between min and max */
448
+ max: number
449
+ /** Time until current returns to max in ms */
450
+ debounce: number
451
+ /** Sets current to min, puts the system in regression */
452
+ regress: () => void
453
+ }
454
+
455
+ interface InternalState {
456
+ interaction: THREE$1.Object3D[]
457
+ subscribers: Subscription[]
458
+ /** Per-pointer state (hover, capture, click tracking) - replaces hovered, capturedMap, initialClick, initialHits */
459
+ pointerMap: Map<number, PointerState>
460
+ /** Pointers needing raycast this frame (used with frameTimedRaycasts) */
461
+ pointerDirty: Map<number, DomEvent>
462
+ /** Last event received (for events.update() compatibility) */
463
+ lastEvent: React$1.RefObject<DomEvent | null>
464
+ /** @deprecated Use pointerMap.get(pointerId).hovered instead */
465
+ hovered: Map<string, ThreeEvent<DomEvent>>
466
+ /** @deprecated Use pointerMap.get(pointerId).captured instead */
467
+ capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
468
+ /** @deprecated Use pointerMap.get(pointerId).initialClick instead */
469
+ initialClick: [x: number, y: number]
470
+ /** @deprecated Use pointerMap.get(pointerId).initialHits instead */
471
+ initialHits: THREE$1.Object3D[]
472
+ /** Visibility event registry (onFramed, onOccluded, onVisible) */
473
+ visibilityRegistry: Map<string, VisibilityEntry>
474
+ /** Whether occlusion queries are enabled (WebGPU only) */
475
+ occlusionEnabled: boolean
476
+ /** Reference to the invisible occlusion observer mesh */
477
+ occlusionObserver: THREE$1.Mesh | null
478
+ /** Cached occlusion results from render pass - keyed by Object3D */
479
+ occlusionCache: Map<THREE$1.Object3D, boolean | null>
480
+ /** Internal helper group for R3F system objects (occlusion observer, etc.) */
481
+ helperGroup: THREE$1.Group | null
482
+ active: boolean
483
+ priority: number
484
+ frames: number
485
+ subscribe: (callback: React$1.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
486
+ /** Internal renderer storage - use state.renderer or state.gl to access */
487
+ actualRenderer: R3FRenderer
488
+ /** Global scheduler reference (for useFrame hook) */
489
+ scheduler: SchedulerApi | null
490
+ /** This root's unique ID in the global scheduler */
491
+ rootId?: string
492
+ /** Function to unregister this root from the global scheduler */
493
+ unregisterRoot?: () => void
494
+ /** Container for child attachment (scene for root, original container for portals) */
495
+ container?: THREE$1.Object3D
496
+ /**
497
+ * CanvasTarget for multi-canvas WebGPU rendering.
498
+ * Created for all WebGPU canvases to support renderer sharing.
499
+ * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
500
+ */
501
+ canvasTarget?: CanvasTarget
502
+ /**
503
+ * Whether multi-canvas rendering is active.
504
+ * True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
505
+ * When true, setCanvasTarget is called before each render.
506
+ */
507
+ isMultiCanvas?: boolean
508
+ /**
509
+ * Whether this canvas is a secondary canvas sharing another's renderer.
510
+ * True when `target` prop is used.
511
+ */
512
+ isSecondary?: boolean
513
+ /**
514
+ * The id of the primary canvas this secondary canvas targets.
515
+ * Only set when isSecondary is true.
516
+ */
517
+ targetId?: string
518
+ /**
519
+ * Function to unregister this primary canvas from the registry.
520
+ * Only set when this canvas has an `id` prop.
521
+ */
522
+ unregisterPrimary?: () => void
523
+ /** Whether canvas dimensions are forced to even numbers */
524
+ forceEven?: boolean
525
+ }
526
+
527
+ interface XRManager {
528
+ connect: () => void
529
+ disconnect: () => void
530
+ }
531
+
532
+ //* Root State Interface ====================================
533
+
534
+ interface RootState {
535
+ /** Set current state */
536
+ set: StoreApi<RootState>['setState']
537
+ /** Get current state */
538
+ get: StoreApi<RootState>['getState']
539
+ /**
540
+ * Reference to the authoritative store for shared TSL resources (uniforms, nodes, etc).
541
+ * - For primary/independent canvases: points to its own store (self-reference)
542
+ * - For secondary canvases: points to the primary canvas's store
543
+ *
544
+ * Hooks like useNodes/useUniforms should read from primaryStore to ensure
545
+ * consistent shared state across all canvases sharing a renderer.
546
+ */
547
+ primaryStore: RootStore
548
+ /** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
549
+ gl: THREE$1.WebGLRenderer
550
+ /** The renderer instance - type depends on entry point (WebGPU, Legacy, or union for default) */
551
+ renderer: R3FRenderer
552
+ /** Inspector of the webGPU Renderer. Init in the canvas */
553
+ inspector: any // Inspector type from three/webgpu
554
+
555
+ /** Default camera */
556
+ camera: ThreeCamera
557
+ /** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
558
+ frustum: THREE$1.Frustum
559
+ /** Whether to automatically update the frustum each frame (default: true) */
560
+ autoUpdateFrustum: boolean
561
+ /** Default scene (may be overridden in portals to point to the portal container) */
562
+ scene: THREE$1.Scene
563
+ /** The actual root THREE.Scene - always points to the true scene, even inside portals */
564
+ rootScene: THREE$1.Scene
565
+ /** Default raycaster */
566
+ raycaster: THREE$1.Raycaster
567
+ /** Event layer interface, contains the event handler and the node they're connected to */
568
+ events: EventManager<any>
569
+ /** XR interface */
570
+ xr: XRManager
571
+ /** Currently used controls */
572
+ controls: THREE$1.EventDispatcher | null
573
+ /** Normalized event coordinates */
574
+ pointer: THREE$1.Vector2
575
+ /** @deprecated Normalized event coordinates, use "pointer" instead! */
576
+ mouse: THREE$1.Vector2
577
+ /** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
578
+ textureColorSpace: THREE$1.ColorSpace
579
+ /** Render loop flags */
580
+ frameloop: Frameloop
581
+ performance: Performance
582
+ /** Reactive pixel-size of the canvas */
583
+ size: Size
584
+ /** Reactive size of the viewport in threejs units */
585
+ viewport: Viewport & {
586
+ getCurrentViewport: (
587
+ camera?: ThreeCamera,
588
+ target?: THREE$1.Vector3 | Parameters<THREE$1.Vector3['set']>,
589
+ size?: Size,
590
+ ) => Omit<Viewport, 'dpr' | 'initialDpr'>
591
+ }
592
+ /** Flags the canvas for render, but doesn't render in itself */
593
+ invalidate: (frames?: number, stackFrames?: boolean) => void
594
+ /** Advance (render) one step */
595
+ advance: (timestamp: number, runGlobalEffects?: boolean) => void
596
+ /** Shortcut to setting the event layer */
597
+ setEvents: (events: Partial<EventManager<any>>) => void
598
+ /** Shortcut to manual sizing. No args resets to props/container. Single arg creates square. */
599
+ setSize: (width?: number, height?: number, top?: number, left?: number) => void
600
+ /** Shortcut to manual setting the pixel ratio */
601
+ setDpr: (dpr: Dpr) => void
602
+ /** Shortcut to setting frameloop flags. No args resets to 'always'. */
603
+ setFrameloop: (frameloop?: Frameloop) => void
604
+ /** Set error state to propagate to error boundary */
605
+ setError: (error: Error | null) => void
606
+ /** Current error state (null when no error) */
607
+ error: Error | null
608
+ /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
609
+ uniforms: UniformStore
610
+ /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
611
+ nodes: Record<string, any>
612
+ /** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
613
+ buffers: BufferStore
614
+ /** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
615
+ gpuStorage: StorageStore
616
+ /** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
617
+ textures: Map<string, THREE$1.Texture>
618
+ /** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
619
+ _textureRefs: Map<string, number>
620
+ /** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
621
+ renderPipeline: ThreeRenderPipeline | null
622
+ /** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
623
+ passes: Record<string, any>
624
+ /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
625
+ _hmrVersion: number
626
+ /** Internal: whether setSize() has taken ownership of canvas dimensions */
627
+ _sizeImperative: boolean
628
+ /** Internal: stored size props from Canvas for reset functionality */
629
+ _sizeProps: { width?: number; height?: number } | null
630
+ /** When the canvas was clicked but nothing was hit */
631
+ onPointerMissed?: (event: MouseEvent) => void
632
+ /** When a dragover event has missed any target */
633
+ onDragOverMissed?: (event: DragEvent) => void
634
+ /** When a drop event has missed any target */
635
+ onDropMissed?: (event: DragEvent) => void
636
+ /** If this state model is layered (via createPortal) then this contains the previous layer */
637
+ previousRoot?: RootStore
638
+ /** Internals */
639
+ internal: InternalState
640
+ // flags for triggers
641
+ // if we are using the webGl renderer, this will be true
642
+ isLegacy: boolean
643
+ // regardless of renderer, if the system supports webGpu, this will be true
644
+ webGPUSupported: boolean
645
+ //if we are on native
646
+ isNative: boolean
647
+ }
648
+
664
649
  type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
665
650
 
666
- //* Base Renderer Types =====================================
667
-
668
- // Shim for OffscreenCanvas since it was removed from DOM types
669
- interface OffscreenCanvas$1 extends EventTarget {}
670
-
671
- interface BaseRendererProps {
672
- canvas: HTMLCanvasElement | OffscreenCanvas$1
673
- powerPreference?: 'high-performance' | 'low-power' | 'default'
674
- antialias?: boolean
675
- alpha?: boolean
676
- }
677
-
678
- type RendererFactory<TRenderer, TParams> =
679
- | TRenderer
680
- | ((defaultProps: TParams) => TRenderer)
681
- | ((defaultProps: TParams) => Promise<TRenderer>)
682
-
683
- interface Renderer {
684
- render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
685
- }
686
-
687
- //* WebGL Renderer Props ==============================
688
-
689
- type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
690
- canvas: HTMLCanvasElement | OffscreenCanvas$1
691
- }
692
-
693
- type GLProps =
694
- | Renderer
695
- | ((defaultProps: DefaultGLProps) => Renderer)
696
- | ((defaultProps: DefaultGLProps) => Promise<Renderer>)
697
- | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
698
-
699
- //* WebGPU Renderer Props ==============================
700
-
701
- type DefaultRendererProps = {
702
- canvas: HTMLCanvasElement | OffscreenCanvas$1
703
- [key: string]: any
704
- }
705
-
706
- type RendererProps =
707
- | any // WebGPURenderer
708
- | ((defaultProps: DefaultRendererProps) => any)
709
- | ((defaultProps: DefaultRendererProps) => Promise<any>)
710
- | Partial<Properties<any> | Record<string, any>>
711
-
712
- //* Camera Props ==============================
713
-
714
- type CameraProps = (
715
- | THREE$1.Camera
716
- | Partial<
717
- ThreeElement<typeof THREE$1.Camera> &
718
- ThreeElement<typeof THREE$1.PerspectiveCamera> &
719
- ThreeElement<typeof THREE$1.OrthographicCamera>
720
- >
721
- ) & {
722
- /** Flags the camera as manual, putting projection into your own hands */
723
- manual?: boolean
724
- }
725
-
726
- //* Render Props ==============================
727
-
728
- interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
729
- /** A threejs renderer instance or props that go into the default renderer */
730
- gl?: GLProps
731
- /** A WebGPU renderer instance or props that go into the default renderer */
732
- renderer?: RendererProps
733
- /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
734
- size?: Size
735
- /**
736
- * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
737
- * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
738
- * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
739
- */
740
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
741
- /**
742
- * Disables three r139 color management.
743
- * @see https://threejs.org/docs/#manual/en/introduction/Color-management
744
- */
745
- legacy?: boolean
746
- /** Switch off automatic sRGB encoding and gamma correction */
747
- linear?: boolean
748
- /** Use `THREE.NoToneMapping` instead of `THREE.ACESFilmicToneMapping` */
749
- flat?: boolean
750
- /** Working color space for automatic texture colorspace assignment. Defaults to THREE.SRGBColorSpace */
751
- /** Color space assigned to 8-bit input textures (color maps). Defaults to sRGB. Most textures are authored in sRGB. */
752
- textureColorSpace?: THREE$1.ColorSpace
753
- /** Creates an orthographic camera */
754
- orthographic?: boolean
755
- /**
756
- * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
757
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
758
- */
759
- frameloop?: Frameloop
760
- /**
761
- * R3F performance options for adaptive performance.
762
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
763
- */
764
- performance?: Partial<Omit<Performance, 'regress'>>
765
- /** Target pixel ratio. Can clamp between a range: `[min, max]` */
766
- dpr?: Dpr
767
- /** Props that go into the default raycaster */
768
- raycaster?: Partial<THREE$1.Raycaster>
769
- /** A `THREE.Scene` instance or props that go into the default scene */
770
- scene?: THREE$1.Scene | Partial<THREE$1.Scene>
771
- /** A `THREE.Camera` instance or props that go into the default camera */
772
- camera?: CameraProps
773
- /** An R3F event manager to manage elements' pointer events */
774
- events?: (store: RootStore) => EventManager<HTMLElement>
775
- /** Callback after the canvas has rendered (but not yet committed) */
776
- onCreated?: (state: RootState) => void
777
- /** Response for pointer clicks that have missed any target */
778
- onPointerMissed?: (event: MouseEvent) => void
779
- /** Response for dragover events that have missed any target */
780
- onDragOverMissed?: (event: DragEvent) => void
781
- /** Response for drop events that have missed any target */
782
- onDropMissed?: (event: DragEvent) => void
783
- /** Whether to automatically update the frustum each frame (default: true) */
784
- autoUpdateFrustum?: boolean
785
- /**
786
- * Enable WebGPU occlusion queries for onOccluded/onVisible events.
787
- * Auto-enabled when any object uses onOccluded or onVisible handlers.
788
- * Only works with WebGPU renderer - WebGL will log a warning.
789
- */
790
- occlusion?: boolean
791
- /** Internal: stored size props from Canvas for reset functionality */
792
- _sizeProps?: { width?: number; height?: number } | null
793
- }
794
-
795
- //* Reconciler Root ==============================
796
-
797
- interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
798
- configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
799
- render: (element: ReactNode) => RootStore
800
- unmount: () => void
801
- }
802
-
803
- //* Inject State ==============================
804
-
805
- type InjectState = Partial<
806
- Omit<RootState, 'events'> & {
807
- events?: {
808
- enabled?: boolean
809
- priority?: number
810
- compute?: ComputeFunction
811
- connected?: any
812
- }
813
- /**
814
- * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
815
- * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
816
- * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
817
- */
818
- injectScene?: boolean
819
- }
651
+ //* Base Renderer Types =====================================
652
+
653
+ // Shim for OffscreenCanvas since it was removed from DOM types
654
+ interface OffscreenCanvas$1 extends EventTarget {}
655
+
656
+ interface BaseRendererProps {
657
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
658
+ powerPreference?: 'high-performance' | 'low-power' | 'default'
659
+ antialias?: boolean
660
+ alpha?: boolean
661
+ }
662
+
663
+ type RendererFactory<TRenderer, TParams> =
664
+ | TRenderer
665
+ | ((defaultProps: TParams) => TRenderer)
666
+ | ((defaultProps: TParams) => Promise<TRenderer>)
667
+
668
+ interface Renderer {
669
+ render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
670
+ }
671
+
672
+ //* Color Management Config ==============================
673
+
674
+ /**
675
+ * Color management configuration shared by both WebGL and WebGPU renderers.
676
+ */
677
+ interface ColorManagementConfig {
678
+ /**
679
+ * Color space assigned to 8-bit input textures (color maps).
680
+ * Defaults to sRGB. Most textures are authored in sRGB.
681
+ * @default THREE.SRGBColorSpace
682
+ */
683
+ textureColorSpace?: THREE$1.ColorSpace
684
+ }
685
+
686
+ //* WebGL Renderer Props ==============================
687
+
688
+ type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
689
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
690
+ }
691
+
692
+ type GLProps =
693
+ | Renderer
694
+ | ((defaultProps: DefaultGLProps) => Renderer)
695
+ | ((defaultProps: DefaultGLProps) => Promise<Renderer>)
696
+ | (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
697
+
698
+ //* WebGPU Renderer Props ==============================
699
+
700
+ type DefaultRendererProps = {
701
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
702
+ [key: string]: any
703
+ }
704
+
705
+ /**
706
+ * Canvas-level scheduler configuration.
707
+ * Controls render timing relative to other canvases.
708
+ */
709
+ interface CanvasSchedulerConfig {
710
+ /**
711
+ * Render this canvas after another canvas completes.
712
+ * Pass the `id` of another canvas.
713
+ */
714
+ after?: string
715
+ /**
716
+ * Limit this canvas's render rate (frames per second).
717
+ */
718
+ fps?: number
719
+ }
720
+
721
+ /**
722
+ * Extended renderer configuration for multi-canvas support and color management.
723
+ */
724
+ interface RendererConfigExtended extends ColorManagementConfig {
725
+ /** Share renderer from another canvas (WebGPU only) */
726
+ primaryCanvas?: string
727
+ /** Canvas-level scheduler options */
728
+ scheduler?: CanvasSchedulerConfig
729
+ }
730
+
731
+ type RendererProps =
732
+ | any // WebGPURenderer
733
+ | ((defaultProps: DefaultRendererProps) => any)
734
+ | ((defaultProps: DefaultRendererProps) => Promise<any>)
735
+ | (Partial<Properties<any> | Record<string, any>> & RendererConfigExtended)
736
+
737
+ //* Camera Props ==============================
738
+
739
+ type CameraProps = (
740
+ | THREE$1.Camera
741
+ | Partial<
742
+ ThreeElement<typeof THREE$1.Camera> &
743
+ ThreeElement<typeof THREE$1.PerspectiveCamera> &
744
+ ThreeElement<typeof THREE$1.OrthographicCamera>
745
+ >
746
+ ) & {
747
+ /** Flags the camera as manual, putting projection into your own hands */
748
+ manual?: boolean
749
+ }
750
+
751
+ //* Render Props ==============================
752
+
753
+ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
754
+ /**
755
+ * Unique identifier for multi-canvas renderer sharing.
756
+ * Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
757
+ * Also sets the HTML `id` attribute on the canvas element.
758
+ * @example <Canvas id="main-viewer">...</Canvas>
759
+ */
760
+ id?: string
761
+ /**
762
+ * Share the renderer from another canvas instead of creating a new one.
763
+ * Pass the `id` of the primary canvas to share its WebGPURenderer.
764
+ * Only available with WebGPU (not legacy WebGL).
765
+ *
766
+ * Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
767
+ * @internal
768
+ */
769
+ primaryCanvas?: string
770
+ /**
771
+ * Canvas-level scheduler options. Controls render timing relative to other canvases.
772
+ *
773
+ * Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
774
+ * @internal
775
+ */
776
+ scheduler?: CanvasSchedulerConfig
777
+ /** A threejs renderer instance or props that go into the default renderer */
778
+ gl?: GLProps
779
+ /** A WebGPU renderer instance or props that go into the default renderer */
780
+ renderer?: RendererProps
781
+ /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
782
+ size?: Size
783
+ /**
784
+ * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
785
+ * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
786
+ * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
787
+ */
788
+ shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
789
+ /** Creates an orthographic camera */
790
+ orthographic?: boolean
791
+ /**
792
+ * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
793
+ * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
794
+ */
795
+ frameloop?: Frameloop
796
+ /**
797
+ * R3F performance options for adaptive performance.
798
+ * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
799
+ */
800
+ performance?: Partial<Omit<Performance, 'regress'>>
801
+ /** Target pixel ratio. Can clamp between a range: `[min, max]` */
802
+ dpr?: Dpr
803
+ /** Props that go into the default raycaster */
804
+ raycaster?: Partial<THREE$1.Raycaster>
805
+ /** A `THREE.Scene` instance or props that go into the default scene */
806
+ scene?: THREE$1.Scene | Partial<THREE$1.Scene>
807
+ /** A `THREE.Camera` instance or props that go into the default camera */
808
+ camera?: CameraProps
809
+ /** An R3F event manager to manage elements' pointer events */
810
+ events?: (store: RootStore) => EventManager<HTMLElement>
811
+ /** Callback after the canvas has rendered (but not yet committed) */
812
+ onCreated?: (state: RootState) => void
813
+ /** Response for pointer clicks that have missed any target */
814
+ onPointerMissed?: (event: MouseEvent) => void
815
+ /** Response for dragover events that have missed any target */
816
+ onDragOverMissed?: (event: DragEvent) => void
817
+ /** Response for drop events that have missed any target */
818
+ onDropMissed?: (event: DragEvent) => void
819
+ /** Whether to automatically update the frustum each frame (default: true) */
820
+ autoUpdateFrustum?: boolean
821
+ /**
822
+ * Enable WebGPU occlusion queries for onOccluded/onVisible events.
823
+ * Auto-enabled when any object uses onOccluded or onVisible handlers.
824
+ * Only works with WebGPU renderer - WebGL will log a warning.
825
+ */
826
+ occlusion?: boolean
827
+ /** Internal: stored size props from Canvas for reset functionality */
828
+ _sizeProps?: { width?: number; height?: number } | null
829
+ /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
830
+ forceEven?: boolean
831
+ }
832
+
833
+ //* Reconciler Root ==============================
834
+
835
+ interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
836
+ configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
837
+ render: (element: ReactNode) => RootStore
838
+ unmount: () => void
839
+ }
840
+
841
+ //* Inject State ==============================
842
+
843
+ type InjectState = Partial<
844
+ Omit<RootState, 'events'> & {
845
+ events?: {
846
+ enabled?: boolean
847
+ priority?: number
848
+ compute?: ComputeFunction
849
+ connected?: any
850
+ }
851
+ /**
852
+ * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
853
+ * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
854
+ * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
855
+ */
856
+ injectScene?: boolean
857
+ }
820
858
  >
821
859
 
822
- //* Reconciler Types ==============================
823
-
824
- // FiberRoot is an opaque internal React type - we define it locally
825
- // to avoid bundling @types/react-reconciler which causes absolute path issues
826
- type FiberRoot = any
827
-
828
- interface Root {
829
- fiber: FiberRoot
830
- store: RootStore
831
- }
832
-
833
- type AttachFnType<O = any> = (parent: any, self: O) => () => void
834
- type AttachType<O = any> = string | AttachFnType<O>
835
-
836
- type ConstructorRepresentation<T = any> = new (...args: any[]) => T
837
-
838
- interface Catalogue {
839
- [name: string]: ConstructorRepresentation
840
- }
841
-
842
- // TODO: handle constructor overloads
843
- // https://github.com/pmndrs/react-three-fiber/pull/2931
844
- // https://github.com/microsoft/TypeScript/issues/37079
845
- type Args<T> = T extends ConstructorRepresentation
846
- ? T extends typeof Color$1
847
- ? [r: number, g: number, b: number] | [color: ColorRepresentation]
848
- : ConstructorParameters<T>
849
- : any[]
850
-
851
- type ArgsProp<P> = P extends ConstructorRepresentation
852
- ? IsAllOptional<ConstructorParameters<P>> extends true
853
- ? { args?: Args<P> }
854
- : { args: Args<P> }
855
- : { args: unknown[] }
856
-
857
- type InstanceProps<T = any, P = any> = ArgsProp<P> & {
858
- object?: T
859
- dispose?: null
860
- attach?: AttachType<T>
861
- onUpdate?: (self: T) => void
862
- }
863
-
864
- interface Instance<O = any> {
865
- root: RootStore
866
- type: string
867
- parent: Instance | null
868
- children: Instance[]
869
- props: InstanceProps<O> & Record<string, unknown>
870
- object: O & { __r3f?: Instance<O> }
871
- eventCount: number
872
- handlers: Partial<EventHandlers>
873
- attach?: AttachType<O>
874
- previousAttach?: any
875
- isHidden: boolean
876
- }
877
-
878
- interface HostConfig {
879
- type: string
880
- props: Instance['props']
881
- container: RootStore
882
- instance: Instance
883
- textInstance: void
884
- suspenseInstance: Instance
885
- hydratableInstance: never
886
- formInstance: never
887
- publicInstance: Instance['object']
888
- hostContext: {}
889
- childSet: never
890
- timeoutHandle: number | undefined
891
- noTimeout: -1
892
- TransitionStatus: null
893
- }
894
- declare global {
895
- var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
896
- }
897
-
898
- //* Loop Types ==============================
899
-
900
- type GlobalRenderCallback = (timestamp: number) => void
901
-
860
+ //* Reconciler Types ==============================
861
+
862
+ // FiberRoot is an opaque internal React type - we define it locally
863
+ // to avoid bundling @types/react-reconciler which causes absolute path issues
864
+ type FiberRoot = any
865
+
866
+ interface Root {
867
+ fiber: FiberRoot
868
+ store: RootStore
869
+ }
870
+
871
+ type AttachFnType<O = any> = (parent: any, self: O) => () => void
872
+ type AttachType<O = any> = string | AttachFnType<O>
873
+
874
+ type ConstructorRepresentation<T = any> = new (...args: any[]) => T
875
+
876
+ interface Catalogue {
877
+ [name: string]: ConstructorRepresentation
878
+ }
879
+
880
+ // TODO: handle constructor overloads
881
+ // https://github.com/pmndrs/react-three-fiber/pull/2931
882
+ // https://github.com/microsoft/TypeScript/issues/37079
883
+ type Args<T> = T extends ConstructorRepresentation
884
+ ? T extends typeof Color$1
885
+ ? [r: number, g: number, b: number] | [color: ColorRepresentation]
886
+ : ConstructorParameters<T>
887
+ : any[]
888
+
889
+ type ArgsProp<P> = P extends ConstructorRepresentation
890
+ ? IsAllOptional<ConstructorParameters<P>> extends true
891
+ ? { args?: Args<P> }
892
+ : { args: Args<P> }
893
+ : { args: unknown[] }
894
+
895
+ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
896
+ object?: T
897
+ dispose?: null
898
+ attach?: AttachType<T>
899
+ onUpdate?: (self: T) => void
900
+ }
901
+
902
+ interface Instance<O = any> {
903
+ root: RootStore
904
+ type: string
905
+ parent: Instance | null
906
+ children: Instance[]
907
+ props: InstanceProps<O> & Record<string, unknown>
908
+ object: O & { __r3f?: Instance<O> }
909
+ eventCount: number
910
+ handlers: Partial<EventHandlers>
911
+ attach?: AttachType<O>
912
+ previousAttach?: any
913
+ isHidden: boolean
914
+ /** Set of props that have been applied via once() */
915
+ appliedOnce?: Set<string>
916
+ }
917
+
918
+ interface HostConfig {
919
+ type: string
920
+ props: Instance['props']
921
+ container: RootStore
922
+ instance: Instance
923
+ textInstance: void
924
+ suspenseInstance: Instance
925
+ hydratableInstance: never
926
+ formInstance: never
927
+ publicInstance: Instance['object']
928
+ hostContext: {}
929
+ childSet: never
930
+ timeoutHandle: number | undefined
931
+ noTimeout: -1
932
+ TransitionStatus: null
933
+ }
934
+ declare global {
935
+ var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
936
+ }
937
+
938
+ //* Loop Types ==============================
939
+
940
+ type GlobalRenderCallback = (timestamp: number) => void
941
+
902
942
  type GlobalEffectType = 'before' | 'after' | 'tail'
903
943
 
904
- //* Canvas Types ==============================
905
-
906
- interface CanvasProps
907
- extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React$1.HTMLAttributes<HTMLDivElement> {
908
- children?: React$1.ReactNode
909
- ref?: React$1.Ref<HTMLCanvasElement>
910
- /** Canvas fallback content, similar to img's alt prop */
911
- fallback?: React$1.ReactNode
912
- /**
913
- * Options to pass to useMeasure.
914
- * @see https://github.com/pmndrs/react-use-measure#api
915
- */
916
- resize?: Options
917
- /** The target where events are being subscribed to, default: the div that wraps canvas */
918
- eventSource?: HTMLElement | React$1.RefObject<HTMLElement>
919
- /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
920
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
921
- /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
922
- hmr?: boolean
923
- /** Canvas resolution width in pixels. If omitted, uses container width. */
924
- width?: number
925
- /** Canvas resolution height in pixels. If omitted, uses container height. */
926
- height?: number
927
- }
928
-
929
- //* Loader Types ==============================
930
-
931
- type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
932
-
933
- // Define a loader-like interface that matches THREE.Loader's load signature
934
- // This works for both generic and non-generic THREE.Loader instances
935
- interface LoaderLike {
936
- load(
937
- url: InputLike,
938
- onLoad?: (result: any) => void,
939
- onProgress?: (event: ProgressEvent<EventTarget>) => void,
940
- onError?: (error: unknown) => void,
941
- ): any
942
- }
943
-
944
- type GLTFLike = { scene: THREE$1.Object3D }
945
-
946
- type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
947
- T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
948
-
949
- // Infer result type from the load method's callback parameter
950
- type InferLoadResult<T> = T extends {
951
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
952
- }
953
- ? R
954
- : T extends ConstructorRepresentation<any>
955
- ? InstanceType<T> extends {
956
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
957
- }
958
- ? R
959
- : any
960
- : any
961
-
962
- type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
963
- InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
964
-
965
- type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
966
- loader: LoaderInstance<T>,
944
+ declare const presetsObj: {
945
+ apartment: string;
946
+ city: string;
947
+ dawn: string;
948
+ forest: string;
949
+ lobby: string;
950
+ night: string;
951
+ park: string;
952
+ studio: string;
953
+ sunset: string;
954
+ warehouse: string;
955
+ };
956
+ type PresetsType = keyof typeof presetsObj;
957
+
958
+ //* Background Types ==============================
959
+
960
+ /**
961
+ * Expanded object form for background configuration.
962
+ * Allows separate textures for background (visual backdrop) and environment (PBR lighting).
963
+ */
964
+ interface BackgroundConfig {
965
+ /** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
966
+ preset?: PresetsType
967
+ /** Files for cube texture (6 faces) or single HDR/EXR */
968
+ files?: string | string[]
969
+ /** Separate files for scene.background (visual backdrop) */
970
+ backgroundMap?: string | string[]
971
+ backgroundRotation?: Euler$1 | [number, number, number]
972
+ backgroundBlurriness?: number
973
+ backgroundIntensity?: number
974
+ /** Separate files for scene.environment (PBR lighting/reflections) */
975
+ envMap?: string | string[]
976
+ environmentRotation?: Euler$1 | [number, number, number]
977
+ environmentIntensity?: number
978
+ path?: string
979
+ extensions?: (loader: Loader) => void
980
+ }
981
+
982
+ /**
983
+ * Background prop type for Canvas.
984
+ *
985
+ * String detection priority:
986
+ * 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
987
+ * 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
988
+ * 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
989
+ *
990
+ * @example Color
991
+ * ```tsx
992
+ * <Canvas background="red" />
993
+ * <Canvas background="#ff0000" />
994
+ * <Canvas background={0xff0000} />
995
+ * ```
996
+ *
997
+ * @example Preset
998
+ * ```tsx
999
+ * <Canvas background="city" />
1000
+ * ```
1001
+ *
1002
+ * @example URL
1003
+ * ```tsx
1004
+ * <Canvas background="/path/to/env.hdr" />
1005
+ * <Canvas background="./sky.jpg" />
1006
+ * ```
1007
+ *
1008
+ * @example Object form
1009
+ * ```tsx
1010
+ * <Canvas background={{
1011
+ * files: ['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'],
1012
+ * backgroundMap: 'path/to/sky.jpg',
1013
+ * envMap: 'path/to/lighting.hdr',
1014
+ * backgroundBlurriness: 0.5,
1015
+ * }} />
1016
+ * ```
1017
+ */
1018
+ type BackgroundProp =
1019
+ | ColorRepresentation // "red", "#ff0000", 0xff0000
1020
+ | string // URL or preset
1021
+ | BackgroundConfig // Expanded object form
1022
+
1023
+ //* Canvas Types ==============================
1024
+
1025
+ interface CanvasProps
1026
+ extends
1027
+ Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
1028
+ React$1.HTMLAttributes<HTMLDivElement> {
1029
+ children?: React$1.ReactNode
1030
+ ref?: React$1.Ref<HTMLCanvasElement>
1031
+ /** Canvas fallback content, similar to img's alt prop */
1032
+ fallback?: React$1.ReactNode
1033
+ /**
1034
+ * Options to pass to useMeasure.
1035
+ * @see https://github.com/pmndrs/react-use-measure#api
1036
+ */
1037
+ resize?: Options
1038
+ /** The target where events are being subscribed to, default: the div that wraps canvas */
1039
+ eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
1040
+ /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1041
+ eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1042
+ /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
1043
+ hmr?: boolean
1044
+ /** Canvas resolution width in pixels. If omitted, uses container width. */
1045
+ width?: number
1046
+ /** Canvas resolution height in pixels. If omitted, uses container height. */
1047
+ height?: number
1048
+ /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
1049
+ forceEven?: boolean
1050
+ /**
1051
+ * Scene background configuration.
1052
+ * Accepts colors, URLs, presets, or an expanded object for separate background/environment.
1053
+ * @see BackgroundProp for full documentation and examples
1054
+ */
1055
+ background?: BackgroundProp
1056
+ }
1057
+
1058
+ //* Loader Types ==============================
1059
+
1060
+ type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
1061
+
1062
+ // Define a loader-like interface that matches THREE.Loader's load signature
1063
+ // This works for both generic and non-generic THREE.Loader instances
1064
+ interface LoaderLike {
1065
+ load(
1066
+ url: InputLike,
1067
+ onLoad?: (result: any) => void,
1068
+ onProgress?: (event: ProgressEvent<EventTarget>) => void,
1069
+ onError?: (error: unknown) => void,
1070
+ ): any
1071
+ }
1072
+
1073
+ type GLTFLike = { scene: THREE$1.Object3D }
1074
+
1075
+ type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1076
+ T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
1077
+
1078
+ // Infer result type from the load method's callback parameter
1079
+ type InferLoadResult<T> = T extends {
1080
+ load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1081
+ }
1082
+ ? R
1083
+ : T extends ConstructorRepresentation<any>
1084
+ ? InstanceType<T> extends {
1085
+ load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1086
+ }
1087
+ ? R
1088
+ : any
1089
+ : any
1090
+
1091
+ type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1092
+ InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
1093
+
1094
+ type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
1095
+ loader: LoaderInstance<T>,
967
1096
  ) => void
968
1097
 
969
- type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
970
-
971
- type WebGLProps =
972
- | RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
973
- | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
974
-
975
- interface WebGLShadowConfig {
976
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
1098
+ //* Renderer Props ========================================
1099
+
1100
+ type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
1101
+
1102
+ type WebGLProps =
1103
+ | RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
1104
+ | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
1105
+
1106
+ interface WebGLShadowConfig {
1107
+ shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
1108
+ }
1109
+
1110
+ //* Legacy-specific Types ========================================
1111
+
1112
+ /** Legacy (WebGL) renderer type - re-exported as R3FRenderer from @react-three/fiber/legacy */
1113
+ type LegacyRenderer = THREE$1.WebGLRenderer
1114
+
1115
+ /** Legacy internal state with narrowed renderer type */
1116
+ interface LegacyInternalState extends Omit<InternalState, 'actualRenderer'> {
1117
+ actualRenderer: THREE$1.WebGLRenderer
1118
+ }
1119
+
1120
+ /**
1121
+ * Legacy-specific RootState with narrowed renderer type.
1122
+ * Automatically used when importing from `@react-three/fiber/legacy`.
1123
+ *
1124
+ * @example
1125
+ * ```tsx
1126
+ * import { useThree } from '@react-three/fiber/legacy'
1127
+ *
1128
+ * function MyComponent() {
1129
+ * const { renderer } = useThree()
1130
+ * // renderer is typed as THREE.WebGLRenderer
1131
+ * renderer.shadowMap.enabled = true
1132
+ * }
1133
+ * ```
1134
+ */
1135
+ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1136
+ /** The WebGL renderer instance */
1137
+ renderer: THREE$1.WebGLRenderer
1138
+ /** Internals with WebGL renderer */
1139
+ internal: LegacyInternalState
977
1140
  }
978
1141
 
979
- //* RenderTarget Types ==============================
980
-
981
-
1142
+ //* RenderTarget Types ==============================
1143
+
1144
+
982
1145
  type RenderTargetOptions = RenderTargetOptions$1
983
1146
 
984
- //* Global Types ==============================
985
-
986
- declare global {
987
- /** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
988
- interface UniformNode<T = unknown> extends Node {
989
- value: T
990
- }
991
-
992
- /** Flat record of uniform nodes (no nested scopes) */
993
- type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
994
-
995
- /**
996
- * Uniform store that can contain both root-level uniforms and scoped uniform objects
997
- * Used by state.uniforms which has structure like:
998
- * { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
999
- */
1000
- type UniformStore = Record<string, UniformNode | UniformRecord>
1001
-
1002
- /**
1003
- * Helper to safely access a uniform node from the store.
1004
- * Use this when accessing state.uniforms to get proper typing.
1005
- * @example
1006
- * const uTime = uniforms.uTime as UniformNode<number>
1007
- * const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
1008
- */
1009
- type GetUniform<T = unknown> = UniformNode<T>
1010
-
1011
- /**
1012
- * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1013
- * Supports: primitives, Three.js types, plain objects (converted to vectors), and UniformNodes
1014
- */
1015
- type UniformValue =
1016
- | number
1017
- | string
1018
- | boolean
1019
- | three_webgpu.Color
1020
- | three_webgpu.Vector2
1021
- | three_webgpu.Vector3
1022
- | three_webgpu.Vector4
1023
- | three_webgpu.Matrix3
1024
- | three_webgpu.Matrix4
1025
- | three_webgpu.Euler
1026
- | three_webgpu.Quaternion
1027
- | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1028
- | UniformNode
1029
-
1030
- /** Input record for useUniforms - accepts raw values or UniformNodes */
1031
- type UniformInputRecord = Record<string, UniformValue>
1032
- }
1033
-
1034
- //* Fn Return Type ==============================
1035
-
1036
- /** The return type of Fn() - a callable shader function node */
1037
- type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1038
-
1039
- //* Module Augmentation ==============================
1040
-
1041
- declare module 'three/tsl' {
1042
- /**
1043
- * Fn with array parameter destructuring
1044
- * @example Fn(([uv, skew]) => { ... })
1045
- */
1046
- export function Fn<R extends Node = Node>(
1047
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1048
- ): ShaderCallable<R>
1049
-
1050
- /**
1051
- * Fn with object parameter destructuring
1052
- * @example Fn(({ color, intensity }) => { ... })
1053
- */
1054
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1055
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1056
- ): ShaderCallable<R>
1057
-
1058
- /**
1059
- * Fn with array params + layout
1060
- * @example Fn(([a, b]) => { ... }, { layout: [...] })
1061
- */
1062
- export function Fn<R extends Node = Node>(
1063
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1064
- layout: { layout?: unknown },
1065
- ): ShaderCallable<R>
1066
-
1067
- /**
1068
- * Fn with object params + layout
1069
- */
1070
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1071
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1072
- layout: { layout?: unknown },
1073
- ): ShaderCallable<R>
1074
- }
1075
-
1076
- /**
1077
- * PostProcessing Types for usePostProcessing hook (WebGPU only)
1078
- */
1079
-
1080
-
1081
-
1082
- declare global {
1083
- /** Pass record - stores TSL pass nodes for post-processing */
1084
- type PassRecord = Record<string, any>
1085
-
1086
- /** Setup callback - runs first to configure MRT, create additional passes */
1087
- type PostProcessingSetupCallback = (state: RootState) => PassRecord | void
1088
-
1089
- /** Main callback - runs second to configure outputNode, create effect passes */
1090
- type PostProcessingMainCallback = (state: RootState) => PassRecord | void
1091
-
1092
- /** Return type for usePostProcessing hook */
1093
- interface UsePostProcessingReturn {
1094
- /** Current passes from state */
1095
- passes: PassRecord
1096
- /** PostProcessing instance (null if not initialized) */
1097
- postProcessing: any | null // THREE.PostProcessing
1098
- /** Clear all passes from state */
1099
- clearPasses: () => void
1100
- /** Reset PostProcessing entirely (clears PP + passes) */
1101
- reset: () => void
1102
- /** Re-run setup/main callbacks with current closure values */
1103
- rebuild: () => void
1104
- /** True when PostProcessing is configured and ready */
1105
- isReady: boolean
1106
- }
1107
- }
1108
-
1109
- //* useFrameNext Types ==============================
1110
-
1111
-
1112
-
1113
- //* Global Type Declarations ==============================
1114
-
1115
- declare global {
1116
- // Job --------------------------------
1117
-
1118
- /**
1119
- * Internal job representation in the scheduler
1120
- */
1121
- interface Job {
1122
- /** Unique identifier */
1123
- id: string
1124
- /** The callback to execute */
1125
- callback: FrameNextCallback
1126
- /** Phase this job belongs to */
1127
- phase: string
1128
- /** Run before these phases/job ids */
1129
- before: Set<string>
1130
- /** Run after these phases/job ids */
1131
- after: Set<string>
1132
- /** Priority within phase (higher first) */
1133
- priority: number
1134
- /** Insertion order for deterministic tie-breaking */
1135
- index: number
1136
- /** Max FPS for this job (undefined = no limit) */
1137
- fps?: number
1138
- /** Drop frames when behind (true) or catch up (false) */
1139
- drop: boolean
1140
- /** Last run timestamp (ms) */
1141
- lastRun?: number
1142
- /** Whether job is enabled */
1143
- enabled: boolean
1144
- /** Internal flag: system jobs (like default render) don't block user render takeover */
1145
- system?: boolean
1146
- }
1147
-
1148
- // Phase Graph --------------------------------
1149
-
1150
- /**
1151
- * A node in the phase graph
1152
- */
1153
- interface PhaseNode {
1154
- /** Phase name */
1155
- name: string
1156
- /** Whether this was auto-generated from a before/after constraint */
1157
- isAutoGenerated: boolean
1158
- }
1159
-
1160
- /**
1161
- * Options for creating a job from hook options
1162
- */
1163
- interface JobOptions {
1164
- id?: string
1165
- phase?: string
1166
- before?: string | string[]
1167
- after?: string | string[]
1168
- priority?: number
1169
- fps?: number
1170
- drop?: boolean
1171
- enabled?: boolean
1172
- }
1173
-
1174
- // Frame Loop State --------------------------------
1175
-
1176
- /**
1177
- * Internal frame loop state
1178
- */
1179
- interface FrameLoopState {
1180
- /** Whether the loop is running */
1181
- running: boolean
1182
- /** Current RAF handle */
1183
- rafHandle: number | null
1184
- /** Last frame timestamp in ms (null = uninitialized) */
1185
- lastTime: number | null
1186
- /** Frame counter */
1187
- frameCount: number
1188
- /** Elapsed time since first frame in ms */
1189
- elapsedTime: number
1190
- /** createdAt timestamp in ms */
1191
- createdAt: number
1192
- }
1193
-
1194
- // Root Entry --------------------------------
1195
-
1196
- /**
1197
- * Internal representation of a registered root (Canvas).
1198
- * Tracks jobs and manages rebuild state for this root.
1199
- * @internal
1200
- */
1201
- interface RootEntry {
1202
- /** Unique identifier for this root */
1203
- id: string
1204
- /** Function to get the root's current state. Returns any to support independent mode. */
1205
- getState: () => any
1206
- /** Map of job IDs to Job objects */
1207
- jobs: Map<string, Job>
1208
- /** Cached sorted job list for execution order */
1209
- sortedJobs: Job[]
1210
- /** Whether sortedJobs needs rebuilding */
1211
- needsRebuild: boolean
1212
- }
1213
-
1214
- /**
1215
- * Internal representation of a global job (deprecated API).
1216
- * Global jobs run once per frame, not per-root.
1217
- * Used by legacy addEffect/addAfterEffect APIs.
1218
- * @internal
1219
- * @deprecated Use useFrame with phases instead
1220
- */
1221
- interface GlobalJob {
1222
- /** Unique identifier for this global job */
1223
- id: string
1224
- /** Callback invoked with RAF timestamp in ms */
1225
- callback: (timestamp: number) => void
1226
- }
1227
-
1228
- // HMR Support --------------------------------
1229
-
1230
- /**
1231
- * Hot Module Replacement data structure for preserving scheduler state
1232
- * @internal
1233
- */
1234
- interface HMRData {
1235
- /** Shared data object for storing values across reloads */
1236
- data: Record<string, any>
1237
- /** Optional function to accept HMR updates */
1238
- accept?: () => void
1239
- }
1240
-
1241
- // Default Phases --------------------------------
1242
-
1243
- /**
1244
- * Default phase names for the scheduler
1245
- */
1246
- type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
1247
- }
1248
-
1249
- type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
1250
-
1251
- interface MathRepresentation {
1252
- set(...args: number[]): any
1253
- }
1254
- interface VectorRepresentation extends MathRepresentation {
1255
- setScalar(value: number): any
1256
- }
1257
- type MathTypes = MathRepresentation | Euler$1 | Color$2
1258
-
1259
- type MathType<T extends MathTypes> = T extends Color$2
1260
- ? Args<typeof Color$2> | ColorRepresentation$1
1261
- : T extends VectorRepresentation | Layers$1 | Euler$1
1262
- ? T | MutableOrReadonlyParameters<T['set']> | number
1263
- : T | MutableOrReadonlyParameters<T['set']>
1264
-
1265
- type MathProps<P> = {
1266
- [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
1267
- }
1268
-
1269
- type Vector2 = MathType<Vector2$1>
1270
- type Vector3 = MathType<Vector3$1>
1271
- type Vector4 = MathType<Vector4$1>
1272
- type Color = MathType<Color$2>
1273
- type Layers = MathType<Layers$1>
1274
- type Quaternion = MathType<Quaternion$1>
1275
- type Euler = MathType<Euler$1>
1276
- type Matrix3 = MathType<Matrix3$1>
1277
- type Matrix4 = MathType<Matrix4$1>
1278
-
1279
- interface RaycastableRepresentation {
1280
- raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
1281
- }
1282
- type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
1283
-
1284
- interface ReactProps<P> {
1285
- children?: React.ReactNode
1286
- ref?: React.Ref<P>
1287
- key?: React.Key
1288
- }
1289
-
1290
- type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
1291
- Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P>>
1292
- >
1293
-
1294
- type ThreeElement<T extends ConstructorRepresentation> = Mutable<
1295
- Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
1296
- >
1297
-
1298
- type ThreeToJSXElements<T extends Record<string, any>> = {
1299
- [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1300
- }
1301
-
1302
- type ThreeExports = typeof THREE
1303
- type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1304
-
1305
- interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1306
- primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1307
- // Conflicts with DOM types can be accessed through a three* prefix
1308
- threeAudio: ThreeElementsImpl['audio']
1309
- threeSource: ThreeElementsImpl['source']
1310
- threeLine: ThreeElementsImpl['line']
1311
- threePath: ThreeElementsImpl['path']
1312
- }
1313
-
1314
- declare module 'react' {
1315
- namespace JSX {
1316
- interface IntrinsicElements extends ThreeElements {}
1317
- }
1318
- }
1319
-
1320
- declare module 'react/jsx-runtime' {
1321
- namespace JSX {
1322
- interface IntrinsicElements extends ThreeElements {}
1323
- }
1324
- }
1325
-
1326
- declare module 'react/jsx-dev-runtime' {
1327
- namespace JSX {
1328
- interface IntrinsicElements extends ThreeElements {}
1329
- }
1147
+ //* Global Types ==============================
1148
+
1149
+ declare global {
1150
+ /**
1151
+ * Uniform node type.
1152
+ *
1153
+ * This is three's own `UniformNode`, not a re-declaration of it. It previously was a
1154
+ * hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
1155
+ * exported type globally — so R3F's ~58 references resolved to an approximation that was
1156
+ * missing members three actually ships (`setName` among them) and had drifted to the wrong
1157
+ * arity when three made `UniformNode` two-parameter.
1158
+ *
1159
+ * three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
1160
+ * so the node type is fixed to `unknown` and the single parameter is kept for call-site
1161
+ * ergonomics. The result is three's structural type, so members stay in sync with the
1162
+ * installed three instead of needing to be mirrored by hand.
1163
+ */
1164
+ type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
1165
+
1166
+ /**
1167
+ * ShaderCallable - the return type of Fn()
1168
+ * A callable shader function node that can be invoked with parameters.
1169
+ * The function returns a ShaderNodeObject when called.
1170
+ *
1171
+ * @example
1172
+ * ```tsx
1173
+ * // Define a shader function
1174
+ * const blendColorFn = Fn(([color1, color2, factor]) => {
1175
+ * return mix(color1, color2, factor)
1176
+ * })
1177
+ *
1178
+ * // Type when retrieving from nodes store
1179
+ * const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
1180
+ *
1181
+ * // Or with specific return type
1182
+ * const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
1183
+ * ```
1184
+ */
1185
+ type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1186
+
1187
+ /**
1188
+ * ShaderNodeRef - a ShaderNodeObject wrapper around a Node
1189
+ * This is the common return type for TSL operations (add, mul, sin, etc.)
1190
+ *
1191
+ * @example
1192
+ * ```tsx
1193
+ * const { wobble } = nodes as { wobble: ShaderNodeRef }
1194
+ * ```
1195
+ */
1196
+ type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
1197
+
1198
+ /**
1199
+ * TSLNodeType - Union of all common TSL node types
1200
+ * Used by ScopedStore to properly type node access from the store.
1201
+ *
1202
+ * Includes:
1203
+ * - Node: base Three.js node type
1204
+ * - ShaderCallable: function nodes created with Fn()
1205
+ * - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
1206
+ *
1207
+ * @example
1208
+ * ```tsx
1209
+ * // In useLocalNodes, nodes are typed as TSLNodeType
1210
+ * const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
1211
+ * positionNode: nodes.myPosition, // Works - Node is in union
1212
+ * blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
1213
+ * }))
1214
+ *
1215
+ * // Can narrow with type guard or assertion when needed
1216
+ * if (typeof blendColorFn === 'function') {
1217
+ * blendColorFn(someColor, 0.5)
1218
+ * }
1219
+ * ```
1220
+ */
1221
+ type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1222
+
1223
+ /** Flat record of uniform nodes (no nested scopes) */
1224
+ type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
1225
+
1226
+ /**
1227
+ * Uniform store that can contain both root-level uniforms and scoped uniform objects
1228
+ * Used by state.uniforms which has structure like:
1229
+ * { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
1230
+ */
1231
+ type UniformStore = Record<string, UniformNode | UniformRecord>
1232
+
1233
+ /**
1234
+ * Helper to safely access a uniform node from the store.
1235
+ * Use this when accessing state.uniforms to get proper typing.
1236
+ * @example
1237
+ * const uTime = uniforms.uTime as UniformNode<number>
1238
+ * const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
1239
+ */
1240
+ type GetUniform<T = unknown> = UniformNode<T>
1241
+
1242
+ /**
1243
+ * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1244
+ * Supports:
1245
+ * - Primitives: number, string (color), boolean
1246
+ * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1247
+ * - Plain objects: { x, y, z, w } converted to vectors
1248
+ * - TSL nodes: color(), vec3(), float() for type casting
1249
+ * - UniformNode: existing uniforms (reused as-is)
1250
+ */
1251
+ type UniformValue =
1252
+ | number
1253
+ | string
1254
+ | boolean
1255
+ | three_webgpu.Color
1256
+ | three_webgpu.Vector2
1257
+ | three_webgpu.Vector3
1258
+ | three_webgpu.Vector4
1259
+ | three_webgpu.Matrix3
1260
+ | three_webgpu.Matrix4
1261
+ | three_webgpu.Euler
1262
+ | three_webgpu.Quaternion
1263
+ | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1264
+ | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1265
+ | Node // TSL nodes like color(), vec3(), float() for type casting
1266
+ | UniformNode
1267
+
1268
+ /** Input record for useUniforms - accepts raw values or UniformNodes */
1269
+ type UniformInputRecord = Record<string, UniformValue>
1270
+ }
1271
+
1272
+ //* Module Augmentation ==============================
1273
+
1274
+ declare module 'three/tsl' {
1275
+ /**
1276
+ * Fn with array parameter destructuring
1277
+ * @example Fn(([uv, skew]) => { ... })
1278
+ */
1279
+ export function Fn<R extends Node = Node>(
1280
+ jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1281
+ ): ShaderCallable<R>
1282
+
1283
+ /**
1284
+ * Fn with object parameter destructuring
1285
+ * @example Fn(({ color, intensity }) => { ... })
1286
+ */
1287
+ export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1288
+ jsFunc: (inputs: T) => ShaderNodeObject<R>,
1289
+ ): ShaderCallable<R>
1290
+
1291
+ /**
1292
+ * Fn with array params + layout
1293
+ * @example Fn(([a, b]) => { ... }, { layout: [...] })
1294
+ */
1295
+ export function Fn<R extends Node = Node>(
1296
+ jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1297
+ layout: { layout?: unknown },
1298
+ ): ShaderCallable<R>
1299
+
1300
+ /**
1301
+ * Fn with object params + layout
1302
+ */
1303
+ export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1304
+ jsFunc: (inputs: T) => ShaderNodeObject<R>,
1305
+ layout: { layout?: unknown },
1306
+ ): ShaderCallable<R>
1307
+ }
1308
+
1309
+ declare global {
1310
+ /**
1311
+ * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
1312
+ * rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
1313
+ * is r185, so the new name is the only one.
1314
+ */
1315
+ type ThreeRenderPipeline = three_webgpu.RenderPipeline
1316
+
1317
+ /** Pass record - stores TSL pass nodes for render pipeline */
1318
+ type PassRecord = Record<string, any>
1319
+
1320
+ /** Setup callback - runs first to configure MRT, create additional passes */
1321
+ type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
1322
+
1323
+ /** Main callback - runs second to configure outputNode, create effect passes */
1324
+ type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
1325
+
1326
+ /** Return type for useRenderPipeline hook */
1327
+ interface UseRenderPipelineReturn {
1328
+ /** Current passes from state */
1329
+ passes: PassRecord
1330
+ /** RenderPipeline instance (null if not initialized) */
1331
+ renderPipeline: ThreeRenderPipeline | null
1332
+ /** Clear all passes from state */
1333
+ clearPasses: () => void
1334
+ /** Reset RenderPipeline entirely (clears PP + passes) */
1335
+ reset: () => void
1336
+ /** Re-run setup/main callbacks with current closure values */
1337
+ rebuild: () => void
1338
+ /** True when RenderPipeline is configured and ready */
1339
+ isReady: boolean
1340
+ }
1341
+ }
1342
+
1343
+ type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
1344
+
1345
+ interface MathRepresentation {
1346
+ set(...args: number[]): any
1347
+ }
1348
+ interface VectorRepresentation extends MathRepresentation {
1349
+ setScalar(value: number): any
1350
+ }
1351
+ type MathTypes = MathRepresentation | Euler$2 | Color$2
1352
+
1353
+ type MathType<T extends MathTypes> = T extends Color$2
1354
+ ? Args<typeof Color$2> | ColorRepresentation$1
1355
+ : T extends VectorRepresentation | Layers$1 | Euler$2
1356
+ ? T | MutableOrReadonlyParameters<T['set']> | number
1357
+ : T | MutableOrReadonlyParameters<T['set']>
1358
+
1359
+ type MathProps<P> = {
1360
+ [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
1361
+ }
1362
+
1363
+ type Vector2 = MathType<Vector2$1>
1364
+ type Vector3 = MathType<Vector3$1>
1365
+ type Vector4 = MathType<Vector4$1>
1366
+ type Color = MathType<Color$2>
1367
+ type Layers = MathType<Layers$1>
1368
+ type Quaternion = MathType<Quaternion$1>
1369
+ type Euler = MathType<Euler$2>
1370
+ type Matrix3 = MathType<Matrix3$1>
1371
+ type Matrix4 = MathType<Matrix4$1>
1372
+
1373
+ interface RaycastableRepresentation {
1374
+ raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
1375
+ }
1376
+ type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
1377
+
1378
+ /**
1379
+ * Props for geometry transform methods that can be called with `once()`.
1380
+ * These methods modify the geometry in-place and only make sense to call once on mount.
1381
+ *
1382
+ * @example
1383
+ * import { once } from '@react-three/fiber'
1384
+ *
1385
+ * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
1386
+ * <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
1387
+ * <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
1388
+ */
1389
+ interface GeometryTransformProps {
1390
+ /** Rotate the geometry about the X axis (radians). Use with once(). */
1391
+ rotateX?: number
1392
+ /** Rotate the geometry about the Y axis (radians). Use with once(). */
1393
+ rotateY?: number
1394
+ /** Rotate the geometry about the Z axis (radians). Use with once(). */
1395
+ rotateZ?: number
1396
+ /** Translate the geometry (x, y, z). Use with once(). */
1397
+ translate?: [x: number, y: number, z: number]
1398
+ /** Scale the geometry (x, y, z). Use with once(). */
1399
+ scale?: [x: number, y: number, z: number]
1400
+ /** Center the geometry based on bounding box. Use with once(). */
1401
+ center?: true
1402
+ /** Apply a Matrix4 transformation. Use with once(). */
1403
+ applyMatrix4?: Matrix4$1
1404
+ /** Apply a Quaternion rotation. Use with once(). */
1405
+ applyQuaternion?: Quaternion$1
1406
+ }
1407
+
1408
+ type GeometryProps<P> = P extends BufferGeometry ? GeometryTransformProps : {}
1409
+
1410
+ /**
1411
+ * Workaround for @types/three TSL node type issues.
1412
+ * The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
1413
+ * This transforms `Node | null` properties to accept any object with node-like shape.
1414
+ */
1415
+ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1416
+
1417
+ /**
1418
+ * For node material properties (colorNode, positionNode, etc.), accept broader types
1419
+ * since @types/three has broken inheritance for TSL node subclasses.
1420
+ */
1421
+ type NodeProps<P> = {
1422
+ [K in keyof P as P[K] extends Node | null ? K : never]?: TSLNodeInput
1423
+ }
1424
+
1425
+ interface ReactProps<P> {
1426
+ children?: React.ReactNode
1427
+ ref?: React.Ref<P>
1428
+ key?: React.Key
1429
+ }
1430
+
1431
+ type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
1432
+ Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
1433
+ >
1434
+
1435
+ type ThreeElement<T extends ConstructorRepresentation> = Mutable<
1436
+ Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
1437
+ >
1438
+
1439
+ type ThreeToJSXElements<T extends Record<string, any>> = {
1440
+ [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1441
+ }
1442
+
1443
+ type ThreeExports = typeof THREE
1444
+ type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1445
+
1446
+ interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1447
+ primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1448
+ // Conflicts with DOM types can be accessed through a three* prefix
1449
+ threeAudio: ThreeElementsImpl['audio']
1450
+ threeSource: ThreeElementsImpl['source']
1451
+ threeLine: ThreeElementsImpl['line']
1452
+ threePath: ThreeElementsImpl['path']
1453
+ }
1454
+
1455
+ declare module 'react' {
1456
+ namespace JSX {
1457
+ interface IntrinsicElements extends ThreeElements {}
1458
+ }
1459
+ }
1460
+
1461
+ declare module 'react/jsx-runtime' {
1462
+ namespace JSX {
1463
+ interface IntrinsicElements extends ThreeElements {}
1464
+ }
1465
+ }
1466
+
1467
+ declare module 'react/jsx-dev-runtime' {
1468
+ namespace JSX {
1469
+ interface IntrinsicElements extends ThreeElements {}
1470
+ }
1330
1471
  }
1331
1472
 
1332
1473
  type three_d_Color = Color;
1333
1474
  type three_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
1334
1475
  type three_d_Euler = Euler;
1335
1476
  type three_d_EventProps<P> = EventProps<P>;
1477
+ type three_d_GeometryProps<P> = GeometryProps<P>;
1478
+ type three_d_GeometryTransformProps = GeometryTransformProps;
1336
1479
  type three_d_Layers = Layers;
1337
1480
  type three_d_MathProps<P> = MathProps<P>;
1338
1481
  type three_d_MathRepresentation = MathRepresentation;
@@ -1341,9 +1484,11 @@ type three_d_MathTypes = MathTypes;
1341
1484
  type three_d_Matrix3 = Matrix3;
1342
1485
  type three_d_Matrix4 = Matrix4;
1343
1486
  type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1487
+ type three_d_NodeProps<P> = NodeProps<P>;
1344
1488
  type three_d_Quaternion = Quaternion;
1345
1489
  type three_d_RaycastableRepresentation = RaycastableRepresentation;
1346
1490
  type three_d_ReactProps<P> = ReactProps<P>;
1491
+ type three_d_TSLNodeInput = TSLNodeInput;
1347
1492
  type three_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
1348
1493
  type three_d_ThreeElements = ThreeElements;
1349
1494
  type three_d_ThreeElementsImpl = ThreeElementsImpl;
@@ -1354,12 +1499,353 @@ type three_d_Vector3 = Vector3;
1354
1499
  type three_d_Vector4 = Vector4;
1355
1500
  type three_d_VectorRepresentation = VectorRepresentation;
1356
1501
  declare namespace three_d {
1357
- export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
1502
+ export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
1503
+ }
1504
+
1505
+ /**
1506
+ * @fileoverview Registry for primary canvases that can be targeted by secondary canvases
1507
+ *
1508
+ * Enables multi-canvas WebGPU rendering where multiple Canvas components share
1509
+ * a single WebGPURenderer using Three.js CanvasTarget API.
1510
+ *
1511
+ * Primary canvas: Has `id` prop, creates its own renderer, registers here
1512
+ * Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
1513
+ */
1514
+
1515
+ interface PrimaryCanvasEntry {
1516
+ /** The WebGPURenderer instance owned by this primary canvas */
1517
+ renderer: WebGPURenderer;
1518
+ /** The zustand store for this canvas */
1519
+ store: RootStore;
1520
+ }
1521
+ /**
1522
+ * Register a primary canvas that can be targeted by secondary canvases.
1523
+ *
1524
+ * @param id - Unique identifier for this primary canvas
1525
+ * @param renderer - The WebGPURenderer owned by this canvas
1526
+ * @param store - The zustand store for this canvas
1527
+ * @returns Cleanup function to unregister on unmount
1528
+ */
1529
+ declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
1530
+ /**
1531
+ * Get a registered primary canvas by id.
1532
+ *
1533
+ * @param id - The id of the primary canvas to look up
1534
+ * @returns The primary canvas entry or undefined if not found
1535
+ */
1536
+ declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
1537
+ /**
1538
+ * Wait for a primary canvas to be registered.
1539
+ * Returns immediately if already registered, otherwise waits.
1540
+ *
1541
+ * @param id - The id of the primary canvas to wait for
1542
+ * @param timeout - Optional timeout in ms (default: 5000)
1543
+ * @returns Promise that resolves with the primary canvas entry
1544
+ */
1545
+ declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
1546
+ /**
1547
+ * Check if a primary canvas with the given id exists.
1548
+ *
1549
+ * @param id - The id to check
1550
+ * @returns True if a primary canvas with this id is registered
1551
+ */
1552
+ declare function hasPrimary(id: string): boolean;
1553
+ /**
1554
+ * Unregister a primary canvas. Called on unmount.
1555
+ *
1556
+ * @param id - The id of the primary canvas to unregister
1557
+ */
1558
+ declare function unregisterPrimary(id: string): void;
1559
+ /**
1560
+ * Get all registered primary canvas ids. Useful for debugging.
1561
+ */
1562
+ declare function getPrimaryIds(): string[];
1563
+
1564
+ type EnvironmentLoaderProps = {
1565
+ files?: string | string[];
1566
+ path?: string;
1567
+ preset?: PresetsType;
1568
+ extensions?: (loader: Loader$1) => void;
1569
+ colorSpace?: ColorSpace;
1570
+ };
1571
+ /**
1572
+ * Loads environment textures for reflections and lighting.
1573
+ * Supports HDR files, presets, and cubemaps.
1574
+ *
1575
+ * @example Basic usage
1576
+ * ```jsx
1577
+ * const texture = useEnvironment({ preset: 'sunset' })
1578
+ * ```
1579
+ */
1580
+ declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
1581
+ declare namespace useEnvironment {
1582
+ var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
1583
+ var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
1584
+ }
1585
+ /**
1586
+ * Options accepted by `useEnvironment.preload`.
1587
+ *
1588
+ * `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
1589
+ * applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
1590
+ * advertise an option this function silently ignores.
1591
+ *
1592
+ * This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
1593
+ * `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
1594
+ * type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
1595
+ */
1596
+ type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
1597
+ type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
1598
+
1599
+ /**
1600
+ * Props for Environment component that sets up global cubemap for PBR materials and backgrounds.
1601
+ *
1602
+ * @property children - React children to render into custom environment portal
1603
+ * @property frames - Number of frames to render the environment. Use 1 for static, Infinity for animated (default: 1)
1604
+ * @property near - Near clipping plane for cube camera (default: 0.1)
1605
+ * @property far - Far clipping plane for cube camera (default: 1000)
1606
+ * @property resolution - Resolution of the cube render target (default: 256)
1607
+ * @property background - Whether to set scene.background. Can be true, false, or "only" (which only sets background) (default: false)
1608
+ *
1609
+ * @property blur - @deprecated Use backgroundBlurriness instead
1610
+ * @property backgroundBlurriness - Blur factor between 0 and 1 for background (default: 0, requires three.js 0.146+)
1611
+ * @property backgroundIntensity - Intensity factor for background (default: 1, requires three.js 0.163+)
1612
+ * @property backgroundRotation - Rotation for background as Euler angles (default: [0,0,0], requires three.js 0.163+)
1613
+ * @property environmentIntensity - Intensity factor for environment lighting (default: 1, requires three.js 0.163+)
1614
+ * @property environmentRotation - Rotation for environment as Euler angles (default: [0,0,0], requires three.js 0.163+)
1615
+ *
1616
+ * @property map - Pre-existing texture to use as environment map
1617
+ * @property preset - HDRI Haven preset: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse'. Not for production use.
1618
+ * @property scene - Custom THREE.Scene or ref to apply environment to (default: uses default scene)
1619
+ * @property ground - Ground projection settings. Use true for defaults or object with:
1620
+ * - height: Height of camera used to create env map (default: 15)
1621
+ * - radius: Radius of the world (default: 60)
1622
+ * - scale: Scale of backside projected sphere (default: 1000)
1623
+ *
1624
+ * Additional loader props:
1625
+ * @property files - File path(s) for environment. Supports .hdr, .exr, gainmap .jpg/.webp, or array of 6 cube faces
1626
+ * @property path - Base path for file loading
1627
+ * @property extensions - Texture extensions override
1628
+ */
1629
+ type EnvironmentProps = {
1630
+ children?: React$1.ReactNode;
1631
+ frames?: number;
1632
+ near?: number;
1633
+ far?: number;
1634
+ resolution?: number;
1635
+ background?: boolean | 'only';
1636
+ /** deprecated, use backgroundBlurriness */
1637
+ blur?: number;
1638
+ backgroundBlurriness?: number;
1639
+ backgroundIntensity?: number;
1640
+ backgroundRotation?: Euler;
1641
+ environmentIntensity?: number;
1642
+ environmentRotation?: Euler;
1643
+ map?: Texture$1;
1644
+ preset?: PresetsType;
1645
+ scene?: Scene | React$1.RefObject<Scene>;
1646
+ ground?: boolean | {
1647
+ radius?: number;
1648
+ height?: number;
1649
+ scale?: number;
1650
+ };
1651
+ /** Solid color for background (alternative to files/preset) */
1652
+ color?: ColorRepresentation$1;
1653
+ /** Separate files for background (when different from environment files) */
1654
+ backgroundFiles?: string | string[];
1655
+ } & EnvironmentLoaderProps;
1656
+ /**
1657
+ * Internal component that applies a pre-existing texture as environment map.
1658
+ * Sets scene.environment and optionally scene.background.
1659
+ *
1660
+ * @example
1661
+ * ```jsx
1662
+ * <CubeCamera>{(texture) => <EnvironmentMap map={texture} />}</CubeCamera>
1663
+ * ```
1664
+ */
1665
+ declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
1666
+ /**
1667
+ * Internal component that loads environment textures from files or presets.
1668
+ * Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg HDR,
1669
+ * GainMapLoader for gainmap .webp, or CubeTextureLoader for arrays of images.
1670
+ *
1671
+ * @example With preset
1672
+ * ```jsx
1673
+ * <EnvironmentCube preset="sunset" />
1674
+ * ```
1675
+ *
1676
+ * @example From HDR file
1677
+ * ```jsx
1678
+ * <EnvironmentCube files="environment.hdr" />
1679
+ * ```
1680
+ *
1681
+ * @example From gainmap (smallest footprint)
1682
+ * ```jsx
1683
+ * <EnvironmentCube files={['file.webp', 'file-gainmap.webp', 'file.json']} />
1684
+ * ```
1685
+ *
1686
+ * @example From cube faces
1687
+ * ```jsx
1688
+ * <EnvironmentCube files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']} />
1689
+ * ```
1690
+ */
1691
+ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, ...rest }: EnvironmentProps): null;
1692
+ /**
1693
+ * Internal component that renders custom environment using a portal and cube camera.
1694
+ * Renders children into an off-buffer and films with a cube camera to create environment map.
1695
+ * Can be static (frames=1) or animated (frames=Infinity).
1696
+ *
1697
+ * @example Custom environment with sphere
1698
+ * ```jsx
1699
+ * <EnvironmentPortal background near={1} far={1000} resolution={256}>
1700
+ * <mesh scale={100}>
1701
+ * <sphereGeometry args={[1, 64, 64]} />
1702
+ * <meshBasicMaterial map={texture} side={THREE.BackSide} />
1703
+ * </mesh>
1704
+ * </EnvironmentPortal>
1705
+ * ```
1706
+ *
1707
+ * @example Animated environment
1708
+ * ```jsx
1709
+ * <EnvironmentPortal frames={Infinity} resolution={256}>
1710
+ * <Float>
1711
+ * <mesh />
1712
+ * </Float>
1713
+ * </EnvironmentPortal>
1714
+ * ```
1715
+ *
1716
+ * @example Mixed with preset
1717
+ * ```jsx
1718
+ * <EnvironmentPortal preset="warehouse">
1719
+ * <mesh />
1720
+ * </EnvironmentPortal>
1721
+ * ```
1722
+ */
1723
+ declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): react_jsx_runtime.JSX.Element;
1724
+ declare module '@react-three/fiber' {
1725
+ interface ThreeElements {
1726
+ groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
1727
+ }
1358
1728
  }
1729
+ /**
1730
+ * Sets up a global environment map for PBR materials and backgrounds.
1731
+ * Affects scene.environment and optionally scene.background unless a custom scene is passed.
1732
+ *
1733
+ * Supports multiple input methods:
1734
+ * - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
1735
+ * - **Files**: HDR (.hdr), EXR (.exr), gainmap JPEG (.jpg), gainmap WebP (.webp), or cube faces (array of 6 images)
1736
+ * - **Texture**: Pre-existing cube texture via `map` prop
1737
+ * - **Custom Scene**: Render children into environment using portal and cube camera
1738
+ * - **Ground Projection**: Project environment onto ground plane
1739
+ *
1740
+ * @remarks
1741
+ * - Preset property is NOT meant for production and may fail (relies on CDNs)
1742
+ * - Gainmap format has the smallest file footprint
1743
+ * - Use `frames={Infinity}` for animated environments with low resolution for performance
1744
+ * - Ground projection places models on the "ground" within the environment map
1745
+ * - Supports self-hosting with @pmndrs/assets using dynamic imports
1746
+ *
1747
+ * @example Basic preset usage
1748
+ * ```jsx
1749
+ * <Environment preset="sunset" />
1750
+ * ```
1751
+ *
1752
+ * @example From HDR file
1753
+ * ```jsx
1754
+ * <Environment files="/hdr/environment.hdr" />
1755
+ * ```
1756
+ *
1757
+ * @example From gainmap (smallest footprint)
1758
+ * ```jsx
1759
+ * <Environment files={['file.webp', 'file-gainmap.webp', 'file.json']} />
1760
+ * ```
1761
+ *
1762
+ * @example With self-hosted assets
1763
+ * ```jsx
1764
+ * import { suspend } from 'suspend-react'
1765
+ * const city = import('@pmndrs/assets/hdri/city.exr').then(m => m.default)
1766
+ *
1767
+ * <Environment files={suspend(city)} />
1768
+ * ```
1769
+ *
1770
+ * @example From existing texture
1771
+ * ```jsx
1772
+ * <CubeCamera>{(texture) => <Environment map={texture} />}</CubeCamera>
1773
+ * ```
1774
+ *
1775
+ * @example Custom environment scene
1776
+ * ```jsx
1777
+ * <Environment background near={1} far={1000} resolution={256}>
1778
+ * <mesh scale={100}>
1779
+ * <sphereGeometry args={[1, 64, 64]} />
1780
+ * <meshBasicMaterial map={texture} side={THREE.BackSide} />
1781
+ * </mesh>
1782
+ * </Environment>
1783
+ * ```
1784
+ *
1785
+ * @example Animated environment
1786
+ * ```jsx
1787
+ * <Environment frames={Infinity} resolution={256}>
1788
+ * <Float>
1789
+ * <mesh />
1790
+ * </Float>
1791
+ * </Environment>
1792
+ * ```
1793
+ *
1794
+ * @example Mixed custom scene with preset
1795
+ * ```jsx
1796
+ * <Environment background preset="warehouse">
1797
+ * <mesh />
1798
+ * </Environment>
1799
+ * ```
1800
+ *
1801
+ * @example With ground projection
1802
+ * ```jsx
1803
+ * <Environment ground={{ height: 15, radius: 60 }} preset="city" />
1804
+ * ```
1805
+ *
1806
+ * @example As background only
1807
+ * ```jsx
1808
+ * <Environment background="only" preset="sunset" />
1809
+ * ```
1810
+ *
1811
+ * @example With rotation and intensity
1812
+ * ```jsx
1813
+ * <Environment
1814
+ * background
1815
+ * backgroundBlurriness={0.5}
1816
+ * backgroundIntensity={0.8}
1817
+ * backgroundRotation={[0, Math.PI / 2, 0]}
1818
+ * environmentIntensity={1.2}
1819
+ * environmentRotation={[0, Math.PI / 4, 0]}
1820
+ * preset="studio"
1821
+ * />
1822
+ * ```
1823
+ */
1824
+ declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
1359
1825
 
1826
+ /**
1827
+ * Moves every trace of interactivity from one object to its replacement, for reconstruction.
1828
+ *
1829
+ * When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
1830
+ * instance. Removing the old object from the interaction state and registering the new one from
1831
+ * scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
1832
+ * the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
1833
+ * is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
1834
+ * swap the user never asked to see (#3744).
1835
+ *
1836
+ * Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
1837
+ * left alone — releasing and re-acquiring it is precisely the glitch being avoided.
1838
+ *
1839
+ * Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
1840
+ * the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
1841
+ * cannot outlive the object it described.
1842
+ */
1843
+ declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
1360
1844
  declare function removeInteractivity(store: RootStore, object: Object3D): void;
1361
1845
  declare function createEvents(store: RootStore): {
1362
1846
  handlePointer: (name: string) => (event: DomEvent) => void;
1847
+ flushDeferredPointers: () => void;
1848
+ processDeferredPointer: (event: DomEvent, pointerId: number) => void;
1363
1849
  };
1364
1850
  /** Default R3F event manager for web */
1365
1851
  declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
@@ -1375,383 +1861,21 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
1375
1861
  * Note: this hook's caller must be wrapped with `React.Suspense`
1376
1862
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1377
1863
  */
1378
- declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
1864
+ declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
1379
1865
  declare namespace useLoader {
1380
- var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
1381
- var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
1866
+ var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike) => void;
1867
+ var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
1382
1868
  var loader: typeof getLoader;
1383
1869
  }
1384
1870
 
1385
- /**
1386
- * Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
1387
- *
1388
- * Features:
1389
- * - Single RAF loop for entire application
1390
- * - Root registration (multiple Canvas support)
1391
- * - Global phases for addEffect/addAfterEffect (deprecated)
1392
- * - Per-root job management with phases, priorities, FPS throttling
1393
- * - onIdle callbacks for addTail (deprecated)
1394
- * - Demand mode support via invalidate()
1395
- */
1396
- declare class Scheduler {
1397
- private static readonly INSTANCE_KEY;
1398
- private static get instance();
1399
- private static set instance(value);
1400
- /**
1401
- * Get the global scheduler instance (creates if doesn't exist).
1402
- * Uses HMR data to preserve instance across hot reloads.
1403
- * @returns {Scheduler} The singleton scheduler instance
1404
- */
1405
- static get(): Scheduler;
1406
- /**
1407
- * Reset the singleton instance. Stops the loop and clears all state.
1408
- * Primarily used for testing to ensure clean state between tests.
1409
- * @returns {void}
1410
- */
1411
- static reset(): void;
1412
- private roots;
1413
- private phaseGraph;
1414
- private loopState;
1415
- private stoppedTime;
1416
- private nextRootIndex;
1417
- private globalBeforeJobs;
1418
- private globalAfterJobs;
1419
- private nextGlobalIndex;
1420
- private idleCallbacks;
1421
- private nextJobIndex;
1422
- private jobStateListeners;
1423
- private pendingFrames;
1424
- private _frameloop;
1425
- private _independent;
1426
- private errorHandler;
1427
- private rootReadyCallbacks;
1428
- get phases(): string[];
1429
- get frameloop(): Frameloop;
1430
- set frameloop(mode: Frameloop);
1431
- get isRunning(): boolean;
1432
- get isReady(): boolean;
1433
- get independent(): boolean;
1434
- set independent(value: boolean);
1435
- constructor();
1436
- /**
1437
- * Register a root (Canvas) with the scheduler.
1438
- * The first root to register starts the RAF loop (if frameloop='always').
1439
- * @param {string} id - Unique identifier for this root
1440
- * @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
1441
- * @returns {() => void} Unsubscribe function to remove this root
1442
- */
1443
- registerRoot(id: string, options?: RootOptions): () => void;
1444
- /**
1445
- * Unregister a root from the scheduler.
1446
- * Cleans up all job state listeners for this root's jobs.
1447
- * The last root to unregister stops the RAF loop.
1448
- * @param {string} id - The root ID to unregister
1449
- * @returns {void}
1450
- */
1451
- unregisterRoot(id: string): void;
1452
- /**
1453
- * Subscribe to be notified when a root becomes available.
1454
- * Fires immediately if a root already exists.
1455
- * @param {() => void} callback - Function called when first root registers
1456
- * @returns {() => void} Unsubscribe function
1457
- */
1458
- onRootReady(callback: () => void): () => void;
1459
- /**
1460
- * Notify all registered root-ready callbacks.
1461
- * Called when the first root registers.
1462
- * @returns {void}
1463
- * @private
1464
- */
1465
- private notifyRootReady;
1466
- /**
1467
- * Ensure a default root exists for independent mode.
1468
- * Creates a minimal root with no state provider.
1469
- * @returns {void}
1470
- * @private
1471
- */
1472
- private ensureDefaultRoot;
1473
- /**
1474
- * Trigger error handling for job errors.
1475
- * Uses the bound error handler if available, otherwise logs to console.
1476
- * @param {Error} error - The error to handle
1477
- * @returns {void}
1478
- */
1479
- triggerError(error: Error): void;
1480
- /**
1481
- * Add a named phase to the scheduler's execution order.
1482
- * Marks all roots for rebuild to incorporate the new phase.
1483
- * @param {string} name - The phase name (e.g., 'physics', 'postprocess')
1484
- * @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
1485
- * @returns {void}
1486
- * @example
1487
- * scheduler.addPhase('physics', { before: 'update' });
1488
- * scheduler.addPhase('postprocess', { after: 'render' });
1489
- */
1490
- addPhase(name: string, options?: AddPhaseOptions): void;
1491
- /**
1492
- * Check if a phase exists in the scheduler.
1493
- * @param {string} name - The phase name to check
1494
- * @returns {boolean} True if the phase exists
1495
- */
1496
- hasPhase(name: string): boolean;
1497
- /**
1498
- * Register a global job that runs once per frame (not per-root).
1499
- * Used internally by deprecated addEffect/addAfterEffect APIs.
1500
- * @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
1501
- * @param {string} id - Unique identifier for this global job
1502
- * @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
1503
- * @returns {() => void} Unsubscribe function to remove this global job
1504
- * @deprecated Use useFrame with phases instead
1505
- */
1506
- registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
1507
- /**
1508
- * Register an idle callback that fires when the loop stops.
1509
- * Used internally by deprecated addTail API.
1510
- * @param {(timestamp: number) => void} callback - Function called when loop becomes idle
1511
- * @returns {() => void} Unsubscribe function to remove this idle callback
1512
- * @deprecated Use demand mode with invalidate() instead
1513
- */
1514
- onIdle(callback: (timestamp: number) => void): () => void;
1515
- /**
1516
- * Notify all registered idle callbacks.
1517
- * Called when the loop stops in demand mode.
1518
- * @param {number} timestamp - The RAF timestamp when idle occurred
1519
- * @returns {void}
1520
- * @private
1521
- */
1522
- private notifyIdle;
1523
- /**
1524
- * Register a job (frame callback) with a specific root.
1525
- * This is the core registration method used by useFrame internally.
1526
- * @param {FrameNextCallback} callback - The function to call each frame
1527
- * @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
1528
- * @param {string} [options.rootId] - Target root ID (defaults to first registered root)
1529
- * @param {string} [options.id] - Unique job ID (auto-generated if not provided)
1530
- * @param {string} [options.phase] - Execution phase (defaults to 'update')
1531
- * @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
1532
- * @param {number} [options.fps] - FPS throttle limit
1533
- * @param {boolean} [options.drop] - Drop frames when behind (default true)
1534
- * @param {boolean} [options.enabled] - Whether job is active (default true)
1535
- * @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
1536
- * @returns {() => void} Unsubscribe function to remove this job
1537
- */
1538
- register(callback: FrameNextCallback, options?: JobOptions & {
1539
- rootId?: string;
1540
- system?: boolean;
1541
- }): () => void;
1542
- /**
1543
- * Unregister a job by its ID.
1544
- * Searches all roots if rootId is not provided.
1545
- * @param {string} id - The job ID to unregister
1546
- * @param {string} [rootId] - Optional root ID to search (searches all if not provided)
1547
- * @returns {void}
1548
- */
1549
- unregister(id: string, rootId?: string): void;
1550
- /**
1551
- * Update a job's options dynamically.
1552
- * Searches all roots to find the job by ID.
1553
- * Phase/constraint changes trigger a rebuild of the sorted job list.
1554
- * @param {string} id - The job ID to update
1555
- * @param {Partial<JobOptions>} options - The options to update
1556
- * @returns {void}
1557
- */
1558
- updateJob(id: string, options: Partial<JobOptions>): void;
1559
- /**
1560
- * Check if a job is currently paused (disabled).
1561
- * @param {string} id - The job ID to check
1562
- * @returns {boolean} True if the job exists and is paused
1563
- */
1564
- isJobPaused(id: string): boolean;
1565
- /**
1566
- * Subscribe to state changes for a specific job.
1567
- * Listener is called when job is paused or resumed.
1568
- * @param {string} id - The job ID to subscribe to
1569
- * @param {() => void} listener - Callback invoked on state changes
1570
- * @returns {() => void} Unsubscribe function
1571
- */
1572
- subscribeJobState(id: string, listener: () => void): () => void;
1573
- /**
1574
- * Notify all listeners that a job's state has changed.
1575
- * @param {string} id - The job ID that changed
1576
- * @returns {void}
1577
- * @private
1578
- */
1579
- private notifyJobStateChange;
1580
- /**
1581
- * Pause a job by ID (sets enabled=false).
1582
- * Notifies any subscribed state listeners.
1583
- * @param {string} id - The job ID to pause
1584
- * @returns {void}
1585
- */
1586
- pauseJob(id: string): void;
1587
- /**
1588
- * Resume a paused job by ID (sets enabled=true).
1589
- * Resets job timing to prevent frame accumulation.
1590
- * Notifies any subscribed state listeners.
1591
- * @param {string} id - The job ID to resume
1592
- * @returns {void}
1593
- */
1594
- resumeJob(id: string): void;
1595
- /**
1596
- * Start the requestAnimationFrame loop.
1597
- * Resets timing state (elapsedTime, frameCount) on start.
1598
- * No-op if already running.
1599
- * @returns {void}
1600
- */
1601
- start(): void;
1602
- /**
1603
- * Stop the requestAnimationFrame loop.
1604
- * Cancels any pending RAF callback.
1605
- * No-op if not running.
1606
- * @returns {void}
1607
- */
1608
- stop(): void;
1609
- /**
1610
- * Request frames to be rendered in demand mode.
1611
- * Accumulates pending frames (capped at 60) and starts the loop if not running.
1612
- * No-op if frameloop is not 'demand'.
1613
- * @param {number} [frames=1] - Number of frames to request
1614
- * @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
1615
- * - `false` (default): Sets pending frames to the specified value (replaces existing count)
1616
- * - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
1617
- * @returns {void}
1618
- * @example
1619
- * // Request a single frame render
1620
- * scheduler.invalidate();
1621
- *
1622
- * @example
1623
- * // Request 5 frames (e.g., for animations)
1624
- * scheduler.invalidate(5);
1625
- *
1626
- * @example
1627
- * // Set pending frames to exactly 3 (don't stack with existing)
1628
- * scheduler.invalidate(3, false);
1629
- *
1630
- * @example
1631
- * // Add 2 more frames to existing pending count
1632
- * scheduler.invalidate(2, true);
1633
- */
1634
- invalidate(frames?: number, stackFrames?: boolean): void;
1635
- /**
1636
- * Reset timing state for deterministic testing.
1637
- * Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
1638
- * @returns {void}
1639
- */
1640
- resetTiming(): void;
1641
- /**
1642
- * Manually execute a single frame for all roots.
1643
- * Useful for frameloop='never' mode or testing scenarios.
1644
- * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
1645
- * @returns {void}
1646
- * @example
1647
- * // Manual control mode
1648
- * scheduler.frameloop = 'never';
1649
- * scheduler.step(); // Execute one frame
1650
- */
1651
- step(timestamp?: number): void;
1652
- /**
1653
- * Manually execute a single job by its ID.
1654
- * Useful for testing individual job callbacks in isolation.
1655
- * @param {string} id - The job ID to step
1656
- * @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
1657
- * @returns {void}
1658
- */
1659
- stepJob(id: string, timestamp?: number): void;
1660
- /**
1661
- * Main RAF loop callback.
1662
- * Executes frame, handles demand mode, and schedules next frame.
1663
- * @param {number} timestamp - RAF timestamp in milliseconds
1664
- * @returns {void}
1665
- * @private
1666
- */
1667
- private loop;
1668
- /**
1669
- * Execute a single frame across all roots.
1670
- * Order: globalBefore → each root's jobs → globalAfter
1671
- * @param {number} timestamp - RAF timestamp in milliseconds
1672
- * @returns {void}
1673
- * @private
1674
- */
1675
- private executeFrame;
1676
- /**
1677
- * Run all global jobs from a job map.
1678
- * Catches and logs errors without stopping execution.
1679
- * @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
1680
- * @param {number} timestamp - RAF timestamp in milliseconds
1681
- * @returns {void}
1682
- * @private
1683
- */
1684
- private runGlobalJobs;
1685
- /**
1686
- * Execute all jobs for a single root in sorted order.
1687
- * Rebuilds sorted job list if needed, then dispatches each job.
1688
- * Errors are caught and propagated via triggerError.
1689
- * @param {RootEntry} root - The root entry to tick
1690
- * @param {number} timestamp - RAF timestamp in milliseconds
1691
- * @param {number} delta - Time since last frame in seconds
1692
- * @returns {void}
1693
- * @private
1694
- */
1695
- private tickRoot;
1696
- /**
1697
- * Get the total number of registered jobs across all roots.
1698
- * Includes both per-root jobs and global before/after jobs.
1699
- * @returns {number} Total job count
1700
- */
1701
- getJobCount(): number;
1702
- /**
1703
- * Get all registered job IDs across all roots.
1704
- * Includes both per-root jobs and global before/after jobs.
1705
- * @returns {string[]} Array of all job IDs
1706
- */
1707
- getJobIds(): string[];
1708
- /**
1709
- * Get the number of registered roots (Canvas instances).
1710
- * @returns {number} Number of registered roots
1711
- */
1712
- getRootCount(): number;
1713
- /**
1714
- * Check if any user (non-system) jobs are registered in a specific phase.
1715
- * Used by the default render job to know if a user has taken over rendering.
1716
- *
1717
- * @param phase The phase to check
1718
- * @param rootId Optional root ID to check (checks all roots if not provided)
1719
- * @returns true if any user jobs exist in the phase
1720
- */
1721
- hasUserJobsInPhase(phase: string, rootId?: string): boolean;
1722
- /**
1723
- * Generate a unique root ID for automatic root registration.
1724
- * @returns {string} A unique root ID in the format 'root_N'
1725
- */
1726
- generateRootId(): string;
1727
- /**
1728
- * Generate a unique job ID.
1729
- * @returns {string} A unique job ID in the format 'job_N'
1730
- * @private
1731
- */
1732
- private generateJobId;
1733
- /**
1734
- * Normalize before/after constraints to a Set.
1735
- * Handles undefined, single string, or array inputs.
1736
- * @param {string | string[] | undefined} value - The constraint value(s)
1737
- * @returns {Set<string>} Normalized Set of constraint strings
1738
- * @private
1739
- */
1740
- private normalizeConstraints;
1741
- }
1742
- /**
1743
- * Get the global scheduler instance.
1744
- * Creates one if it doesn't exist.
1745
- */
1746
- declare const getScheduler: () => Scheduler;
1747
-
1748
1871
  /**
1749
1872
  * Frame hook with phase-based ordering, priority, and FPS throttling.
1750
1873
  *
1751
- * Works both inside and outside Canvas context:
1752
- * - Inside Canvas: Full RootState (gl, scene, camera, etc.)
1753
- * - Outside Canvas (waiting mode): Waits for Canvas to mount, then gets full state
1754
- * - Outside Canvas (independent mode): Fires immediately with timing-only state
1874
+ * Always delivers full RootState — works both inside and outside Canvas context:
1875
+ * - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
1876
+ * - Outside Canvas: The job registers immediately but the callback is held until a
1877
+ * Canvas adopts it, then runs with full RootState. For hostless / standalone
1878
+ * frame loops with no Canvas, use `@pmndrs/scheduler` directly.
1755
1879
  *
1756
1880
  * Returns a controls object for manual stepping, pausing, and resuming.
1757
1881
  *
@@ -1768,16 +1892,16 @@ declare const getScheduler: () => Scheduler;
1768
1892
  * useFrame((state, delta) => { ... }, { phase: 'physics' })
1769
1893
  *
1770
1894
  * @example
1771
- * // Outside Canvas - waits for Canvas to mount
1895
+ * // Outside Canvas - callback waits for a Canvas, then always has full state
1772
1896
  * function UI() {
1773
1897
  * useFrame((state, delta) => { syncUI(state.camera) });
1774
1898
  * return <button>...</button>;
1775
1899
  * }
1776
1900
  *
1777
1901
  * @example
1778
- * // Independent mode - no Canvas needed
1779
- * getScheduler().independent = true;
1780
- * useFrame((state, delta) => { updateGame(delta) });
1902
+ * // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
1903
+ * import { getScheduler } from '@pmndrs/scheduler'
1904
+ * getScheduler().register((state, delta) => { updateGame(delta) })
1781
1905
  *
1782
1906
  * @example
1783
1907
  * // Scheduler-only access (no callback)
@@ -1800,11 +1924,16 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
1800
1924
  /** Callback when texture(s) finish loading */
1801
1925
  onLoad?: (texture: MappedTextureType<Url>) => void;
1802
1926
  /**
1803
- * Cache the texture in R3F's global state for access via useTextures().
1804
- * When true:
1927
+ * Register the texture(s) in R3F's global texture registry for access via useTextures().
1928
+ * When true (the default):
1805
1929
  * - Textures persist until explicitly disposed
1806
- * - Returns existing cached textures if available (preserving modifications like colorSpace)
1807
- * @default false
1930
+ * - On mount, returns existing registered textures if available (preserving modifications like colorSpace)
1931
+ *
1932
+ * Reads are taken once at mount — a mounted `useTexture` does not re-render when the registry
1933
+ * changes. To react to registry swaps, use `useTextures(s => s.get(key))` instead.
1934
+ *
1935
+ * Pass `false` to opt out of registry enrollment entirely.
1936
+ * @default true
1808
1937
  */
1809
1938
  cache?: boolean;
1810
1939
  };
@@ -1828,15 +1957,18 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
1828
1957
  * normal: '/normal.png'
1829
1958
  * })
1830
1959
  *
1831
- * // With caching - returns same texture object across components
1832
- * // Modifications (colorSpace, wrapS, etc.) are preserved
1833
- * const diffuse = useTexture('/diffuse.png', { cache: true })
1960
+ * // Textures are registered in the global registry by default — the same texture
1961
+ * // object is shared across components and modifications (colorSpace, wrapS, etc.) are preserved
1962
+ * const diffuse = useTexture('/diffuse.png')
1834
1963
  * diffuse.colorSpace = THREE.SRGBColorSpace
1835
1964
  *
1836
1965
  * // Another component gets the SAME texture with colorSpace already set
1837
- * const sameDiffuse = useTexture('/diffuse.png', { cache: true })
1966
+ * const sameDiffuse = useTexture('/diffuse.png')
1838
1967
  *
1839
- * // Access cache directly
1968
+ * // Opt out of registry enrollment for a one-off texture
1969
+ * const scratch = useTexture('/scratch.png', { cache: false })
1970
+ *
1971
+ * // Access the registry directly
1840
1972
  * const { get } = useTextures()
1841
1973
  * const cached = get('/diffuse.png')
1842
1974
  * ```
@@ -1853,63 +1985,80 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
1853
1985
  cache?: boolean;
1854
1986
  }) => react_jsx_runtime.JSX.Element;
1855
1987
 
1856
- type TextureEntry = Texture$1 | {
1857
- value: Texture$1;
1858
- [key: string]: any;
1988
+ /** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
1989
+ type TextureInput = string | string[] | Record<string, string>;
1990
+ /** Result of a `get()` read, mirroring the input shape. */
1991
+ type TextureResult<Input extends TextureInput> = Input extends string ? Texture$1 | undefined : Input extends string[] ? (Texture$1 | undefined)[] : {
1992
+ [K in keyof Input]: Texture$1 | undefined;
1859
1993
  };
1994
+ /** Options for `dispose()`. */
1995
+ interface DisposeOptions {
1996
+ /** Dispose even if the texture still has active references (default false). */
1997
+ force?: boolean;
1998
+ }
1860
1999
  interface UseTexturesReturn {
1861
- /** Map of all textures currently in cache */
1862
- textures: Map<string, TextureEntry>;
1863
- /** Get a specific texture by key (usually URL) */
1864
- get: (key: string) => TextureEntry | undefined;
1865
- /** Check if a texture exists in cache */
1866
- has: (key: string) => boolean;
1867
- /** Add a texture to the cache */
1868
- add: (key: string, value: TextureEntry) => void;
1869
- /** Add multiple textures to the cache */
1870
- addMultiple: (items: Map<string, TextureEntry> | Record<string, TextureEntry>) => void;
1871
- /** Remove a texture from cache (does NOT dispose GPU resources) */
1872
- remove: (key: string) => void;
1873
- /** Remove multiple textures from cache */
1874
- removeMultiple: (keys: string[]) => void;
1875
- /** Dispose a texture's GPU resources and remove from cache */
1876
- dispose: (key: string) => void;
1877
- /** Dispose multiple textures */
1878
- disposeMultiple: (keys: string[]) => void;
1879
- /** Dispose ALL cached textures - use with caution */
1880
- disposeAll: () => void;
2000
+ /** The live registry Map (key → Texture). Treat as read-only. */
2001
+ readonly all: Map<string, Texture$1>;
2002
+ /** Read one texture, an array of textures, or a name→texture record (mirrors the input shape). */
2003
+ get<Input extends TextureInput>(input: Input): TextureResult<Input>;
2004
+ /** Check whether a key exists in the registry. */
2005
+ has(key: string): boolean;
2006
+ /**
2007
+ * Register a texture (or a record of textures) that has no URL — e.g. a render
2008
+ * target or procedural texture. URL-loaded textures are registered automatically
2009
+ * by `useTexture` (registry enrollment is on by default).
2010
+ */
2011
+ add(key: string, texture: Texture$1): void;
2012
+ add(record: Record<string, Texture$1>): void;
2013
+ /**
2014
+ * Dispose a texture's GPU resources and remove it from the registry.
2015
+ * Refcount-aware: if the key is still in use by a mounted `useTexture` consumer it is
2016
+ * skipped (with a warning) unless `{ force: true }` is passed.
2017
+ * @returns true if disposed, false if skipped.
2018
+ */
2019
+ dispose(key: string, options?: DisposeOptions): boolean;
2020
+ /** Dispose every texture in the registry and clear it. Use on scene teardown. */
2021
+ disposeAll(): void;
1881
2022
  }
1882
2023
  /**
1883
- * Hook for managing the global texture cache in R3F state.
2024
+ * Reactive Texture registry — load once with `useTexture`, reach the textures from anywhere.
2025
+ *
2026
+ * This is a registry of plain `Texture` objects (not TSL nodes), so the same texture can feed
2027
+ * a material map, a heightmap sampler, or anything else. It does **not** load — pair it with
2028
+ * `useTexture` for loading (registry enrollment is on by default); `useTextures` is for access and lifecycle.
1884
2029
  *
1885
- * Textures are stored in a Map with URL/path keys for efficient lookup.
1886
- * Useful for sharing texture references across materials and components.
2030
+ * The returned handle is **reactive**: the calling component re-renders when the registry
2031
+ * changes. Pass a selector to scope the subscription to a single read.
1887
2032
  *
1888
2033
  * @example
1889
2034
  * ```tsx
1890
- * const { textures, add, get, remove, has, dispose } = useTextures()
2035
+ * // Load + register once (anywhere in the tree) — registered by default
2036
+ * useTexture({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
1891
2037
  *
1892
- * // Check if texture is already cached
1893
- * if (!has('/textures/diffuse.png')) {
1894
- * // Load with useTexture and cache: true, or manually add
1895
- * const tex = useTexture('/textures/diffuse.png', { cache: true })
1896
- * }
1897
- *
1898
- * // Access cached texture from anywhere
1899
- * const diffuse = get('/textures/diffuse.png')
1900
- * if (diffuse) material.map = diffuse
2038
+ * // Reach them from another component — record form lands straight into a material
2039
+ * const { map, normalMap } = useTextures().get({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
2040
+ * return <meshStandardMaterial map={map} normalMap={normalMap} />
1901
2041
  *
1902
- * // Remove from cache only (texture still in GPU memory)
1903
- * remove('/textures/old.png')
2042
+ * // A set of heightmaps at once
2043
+ * const [a, b, c] = useTextures().get(['/h0.png', '/h1.png', '/h2.png'])
1904
2044
  *
1905
- * // Fully dispose (frees GPU memory + removes from cache)
1906
- * dispose('/textures/unused.png')
2045
+ * // Register a non-URL texture (render target / procedural)
2046
+ * useTextures().add('rt-main', renderTarget.texture)
1907
2047
  *
1908
- * // Nuclear option - dispose everything
1909
- * disposeAll()
2048
+ * // Deliberate GPU cleanup (refcount-aware; force to override)
2049
+ * useTextures().dispose('/diffuse.jpg')
2050
+ * useTextures().disposeAll() // scene teardown
1910
2051
  * ```
2052
+ *
2053
+ * @remarks
2054
+ * **Future expansion:** an imperative async loader (e.g. `await useTextures().load('/x.jpg')`) is
2055
+ * intentionally not included yet. It would let non-React code (loading screens, dynamic streaming)
2056
+ * populate the registry without Suspense, at the cost of putting loading back into this hook. It
2057
+ * will be added only if a concrete consumer needs imperative loading; for now, loading lives in
2058
+ * `useTexture`.
1911
2059
  */
1912
2060
  declare function useTextures(): UseTexturesReturn;
2061
+ declare function useTextures<T>(selector: (registry: UseTexturesReturn) => T): T;
1913
2062
 
1914
2063
  /**
1915
2064
  * Creates a render target compatible with the current renderer.
@@ -1918,31 +2067,30 @@ declare function useTextures(): UseTexturesReturn;
1918
2067
  * - WebGPU build: Returns RenderTarget
1919
2068
  * - Default build: Returns whichever matches the active renderer
1920
2069
  *
1921
- * @param width - Target width (defaults to canvas width)
1922
- * @param height - Target height (defaults to canvas height)
1923
- * @param options - Three.js RenderTarget options
1924
- *
1925
2070
  * @example
1926
2071
  * ```tsx
1927
- * function PortalScene() {
1928
- * const fbo = useRenderTarget(512, 512, { depthBuffer: true })
1929
- *
1930
- * useFrame(({ renderer, scene, camera }) => {
1931
- * renderer.setRenderTarget(fbo)
1932
- * renderer.render(scene, camera)
1933
- * renderer.setRenderTarget(null)
1934
- * })
1935
- *
1936
- * return (
1937
- * <mesh>
1938
- * <planeGeometry />
1939
- * <meshBasicMaterial map={fbo.texture} />
1940
- * </mesh>
1941
- * )
1942
- * }
2072
+ * // Use canvas size
2073
+ * const fbo = useRenderTarget()
2074
+ *
2075
+ * // Use canvas size with options
2076
+ * const fbo = useRenderTarget({ samples: 4 })
2077
+ *
2078
+ * // Square render target
2079
+ * const fbo = useRenderTarget(512)
2080
+ *
2081
+ * // Square render target with options
2082
+ * const fbo = useRenderTarget(512, { depthBuffer: true })
2083
+ *
2084
+ * // Explicit dimensions
2085
+ * const fbo = useRenderTarget(512, 256)
2086
+ *
2087
+ * // Explicit dimensions with options
2088
+ * const fbo = useRenderTarget(512, 256, { samples: 4 })
1943
2089
  * ```
1944
2090
  */
1945
- declare function useRenderTarget(width?: number, height?: number, options?: RenderTargetOptions): RenderTarget<THREE$1.Texture<unknown>>;
2091
+ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
2092
+ declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
2093
+ declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
1946
2094
 
1947
2095
  /**
1948
2096
  * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
@@ -2047,7 +2195,7 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
2047
2195
  *
2048
2196
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2049
2197
  */
2050
- declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame): void;
2198
+ declare function advance(timestamp: number): void;
2051
2199
 
2052
2200
  /* eslint-disable @definitelytyped/no-unnecessary-generics */
2053
2201
  declare function ReactReconciler<
@@ -3101,6 +3249,12 @@ declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
3101
3249
  declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
3102
3250
  declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
3103
3251
  declare function createPortal(children: ReactNode, container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>, state?: InjectState): JSX.Element;
3252
+ interface PortalProps {
3253
+ children: ReactNode;
3254
+ state?: InjectState;
3255
+ container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
3256
+ }
3257
+ declare function Portal({ children, container, state }: PortalProps): JSX.Element;
3104
3258
  /**
3105
3259
  * Force React to flush any updates inside the provided callback synchronously and immediately.
3106
3260
  * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
@@ -3112,11 +3266,6 @@ declare function flushSync<R>(fn: () => R): R;
3112
3266
  declare const context: React$1.Context<RootStore>;
3113
3267
  declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
3114
3268
 
3115
- /**
3116
- * Safely flush async effects when testing, simulating a legacy root.
3117
- * @deprecated Import from React instead. import { act } from 'react'
3118
- */
3119
- declare const act: typeof React$1.act;
3120
3269
  /**
3121
3270
  * An SSR-friendly useLayoutEffect.
3122
3271
  *
@@ -3529,6 +3678,71 @@ declare const hasConstructor: (object: unknown) => object is {
3529
3678
  constructor?: Function;
3530
3679
  };
3531
3680
 
3681
+ /**
3682
+ * Symbol marker for deferred ref resolution.
3683
+ * Used to identify values that should be resolved from refs after mount.
3684
+ */
3685
+ declare const FROM_REF: unique symbol;
3686
+ /**
3687
+ * Defers prop application until the referenced object is available.
3688
+ * Useful for props like `target` that need sibling refs to be populated.
3689
+ *
3690
+ * @param ref - React ref object to resolve at mount time
3691
+ * @returns A marker value that applyProps will resolve after mount
3692
+ *
3693
+ * @example
3694
+ * const targetRef = useRef<THREE.Object3D>(null)
3695
+ *
3696
+ * <group ref={targetRef} position={[-3, -2, -15]} />
3697
+ * <spotLight target={fromRef(targetRef)} intensity={100} />
3698
+ */
3699
+ declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
3700
+ /**
3701
+ * Type guard to check if a value is a fromRef marker.
3702
+ *
3703
+ * @param value - Value to check
3704
+ * @returns True if value is a fromRef marker
3705
+ */
3706
+ declare function isFromRef(value: unknown): value is {
3707
+ [FROM_REF]: React$1.RefObject<any>;
3708
+ };
3709
+
3710
+ /**
3711
+ * Symbol marker for mount-only method calls.
3712
+ * Used to identify methods that should only be called once on initial mount.
3713
+ */
3714
+ declare const ONCE: unique symbol;
3715
+ /**
3716
+ * Marks a method call to be executed only on initial mount.
3717
+ * Useful for geometry transforms that should not be reapplied on every render.
3718
+ *
3719
+ * When `args` prop changes (triggering reconstruction), the method will be
3720
+ * called again on the new instance since appliedOnce is not carried over.
3721
+ *
3722
+ * @param args - Arguments to pass to the method
3723
+ * @returns A marker value that applyProps will execute once
3724
+ *
3725
+ * @example
3726
+ * // Rotate geometry on mount
3727
+ * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
3728
+ *
3729
+ * // Multiple arguments
3730
+ * <bufferGeometry applyMatrix4={once(matrix)} />
3731
+ *
3732
+ * // No arguments
3733
+ * <geometry center={once()} />
3734
+ */
3735
+ declare function once<T>(...args: T[]): T;
3736
+ /**
3737
+ * Type guard to check if a value is a once marker.
3738
+ *
3739
+ * @param value - Value to check
3740
+ * @returns True if value is a once marker
3741
+ */
3742
+ declare function isOnce(value: unknown): value is {
3743
+ [ONCE]: any[] | true;
3744
+ };
3745
+
3532
3746
  /**
3533
3747
  * A DOM canvas which accepts threejs elements as children.
3534
3748
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
@@ -3584,13 +3798,17 @@ type ScopedStoreType<T> = {
3584
3798
  declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreType<T>;
3585
3799
  /**
3586
3800
  * State type passed to creator functions with ScopedStore wrappers.
3587
- * Provides type-safe access to uniforms and nodes without manual casting.
3801
+ * Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
3588
3802
  */
3589
- type CreatorState = Omit<RootState, 'uniforms' | 'nodes'> & {
3803
+ type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
3590
3804
  /** Type-safe uniform access - property access returns UniformNode */
3591
3805
  uniforms: ScopedStoreType<UniformNode>;
3592
- /** Type-safe node access - property access returns Node */
3593
- nodes: ScopedStoreType<Node>;
3806
+ /** Type-safe node access - property access returns TSLNodeType (Node | ShaderCallable | ShaderNodeObject) */
3807
+ nodes: ScopedStoreType<TSLNodeType>;
3808
+ /** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
3809
+ buffers: ScopedStoreType<BufferLike>;
3810
+ /** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
3811
+ gpuStorage: ScopedStoreType<StorageLike>;
3594
3812
  };
3595
3813
 
3596
3814
  /** Creator function that returns uniform inputs (can be raw values or UniformNodes) */
@@ -3615,9 +3833,12 @@ declare function useUniforms<T extends UniformInputRecord>(uniforms: T): Uniform
3615
3833
  declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
3616
3834
  /**
3617
3835
  * Global rebuildUniforms function for HMR integration.
3618
- * Clears cached uniforms and increments _hmrVersion to trigger re-creation.
3836
+ * Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
3619
3837
  * Call this when HMR is detected to refresh all uniform creators.
3620
3838
  *
3839
+ * Resolves to the primary store so shared TSL resources rebuild on the
3840
+ * authoritative store.
3841
+ *
3621
3842
  * @param store - The R3F store (from useStore or context)
3622
3843
  * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
3623
3844
  */
@@ -3638,17 +3859,51 @@ declare function clearScope(set: ReturnType<typeof useStore>['setState'], scope:
3638
3859
  */
3639
3860
  declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState']): void;
3640
3861
 
3641
- /** Supported uniform value types */
3642
- type UniformValue = number | boolean | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1;
3643
- /** Widen literal types to their base types (0 → number, true → boolean) */
3644
- type Widen<T> = T extends number ? number : T extends boolean ? boolean : T;
3862
+ /**
3863
+ * Supported uniform value types:
3864
+ * - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
3865
+ * - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
3866
+ * - TSL nodes: color(), vec3(), float(), etc. (for type casting)
3867
+ * - UniformNode: existing uniforms (reused as-is)
3868
+ */
3869
+ type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
3870
+ /**
3871
+ * Widen literal types to their base types:
3872
+ * - 0 → number
3873
+ * - true → boolean
3874
+ * - '#ff0000' → Color (string colors are converted to Color objects)
3875
+ * - Node → Node (TSL nodes passed through for uniform type casting)
3876
+ */
3877
+ type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
3645
3878
  declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
3646
3879
  declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
3647
3880
 
3648
- /** TSL node type - extends Three.js Node for material compatibility */
3649
- type TSLNode = Node;
3650
- type NodeRecord<T extends Node = Node> = Record<string, T>;
3651
- type NodeCreator<T extends NodeRecord> = (state: CreatorState) => T;
3881
+ /**
3882
+ * Minimal interface for TSL nodes.
3883
+ * Used instead of Three.js's Node type because the @types/three definitions
3884
+ * have inconsistencies where OperatorNode, ConstNode, etc. don't properly
3885
+ * extend Node with all required properties.
3886
+ */
3887
+ interface TSLNodeLike {
3888
+ uuid?: string;
3889
+ nodeType?: string | null;
3890
+ /** label method for chaining - sets the node's label and returns self */
3891
+ label?: ((label: string) => TSLNodeLike) | string;
3892
+ setName?: (name: string) => this;
3893
+ }
3894
+ /** TSL node type - alias for compatibility */
3895
+ type TSLNode = TSLNodeLike;
3896
+ /**
3897
+ * A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
3898
+ * Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
3899
+ */
3900
+ type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
3901
+ /**
3902
+ * Creator function that returns a record of nodes.
3903
+ * Uses TSLNodeLike constraint to allow mixed node types
3904
+ * (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
3905
+ */
3906
+ type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
3652
3907
  /** Function signature for removeNodes util */
3653
3908
  type RemoveNodesFn = (names: string | string[], scope?: string) => void;
3654
3909
  /** Function signature for clearNodes util */
@@ -3656,20 +3911,23 @@ type ClearNodesFn = (scope?: string) => void;
3656
3911
  /** Function signature for rebuildNodes util */
3657
3912
  type RebuildNodesFn = (scope?: string) => void;
3658
3913
  /** Return type with utils included */
3659
- type NodesWithUtils<T extends NodeRecord = NodeRecord> = T & {
3914
+ type NodesWithUtils<T extends Record<string, TSLNodeLike> = Record<string, TSLNodeLike>> = T & {
3660
3915
  removeNodes: RemoveNodesFn;
3661
3916
  clearNodes: ClearNodesFn;
3662
3917
  rebuildNodes: RebuildNodesFn;
3663
3918
  };
3664
- declare function useNodes(): NodesWithUtils<NodeRecord & Record<string, NodeRecord>>;
3665
- declare function useNodes(scope: string): NodesWithUtils;
3666
- declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>): NodesWithUtils<T>;
3667
- declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
3919
+ declare function useNodes(): NodesWithUtils<Record<string, TSLNodeLike> & Record<string, Record<string, TSLNodeLike>>>;
3920
+ declare function useNodes(scope: string): NodesWithUtils<Record<string, TSLNodeLike>>;
3921
+ declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>): NodesWithUtils<T>;
3922
+ declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
3668
3923
  /**
3669
3924
  * Global rebuildNodes function for HMR integration.
3670
- * Clears cached nodes and increments _hmrVersion to trigger re-creation.
3925
+ * Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
3671
3926
  * Call this when HMR is detected to refresh all node creators.
3672
3927
  *
3928
+ * Resolves to the primary store so shared TSL resources rebuild on the
3929
+ * authoritative store.
3930
+ *
3673
3931
  * @param store - The R3F store (from useStore or context)
3674
3932
  * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
3675
3933
  */
@@ -3720,6 +3978,97 @@ type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState)
3720
3978
  */
3721
3979
  declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
3722
3980
 
3981
+ /**
3982
+ * Creator function that returns a record of buffers.
3983
+ * Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
3984
+ */
3985
+ type BufferCreator<T extends Record<string, BufferLike>> = (state: CreatorState) => T;
3986
+ /** Function signature for removeBuffers util */
3987
+ type RemoveBuffersFn = (names: string | string[], scope?: string) => void;
3988
+ /** Function signature for clearBuffers util */
3989
+ type ClearBuffersFn = (scope?: string) => void;
3990
+ /** Function signature for rebuildBuffers util */
3991
+ type RebuildBuffersFn = (scope?: string) => void;
3992
+ /** Function signature for disposeBuffers util - releases GPU resources */
3993
+ type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
3994
+ /** Return type with utils included */
3995
+ type BuffersWithUtils<T extends Record<string, BufferLike> = Record<string, BufferLike>> = T & {
3996
+ removeBuffers: RemoveBuffersFn;
3997
+ clearBuffers: ClearBuffersFn;
3998
+ rebuildBuffers: RebuildBuffersFn;
3999
+ disposeBuffers: DisposeBuffersFn;
4000
+ };
4001
+ declare function useBuffers(): BuffersWithUtils<Record<string, BufferLike> & Record<string, Record<string, BufferLike>>>;
4002
+ declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
4003
+ declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
4004
+ declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
4005
+ /**
4006
+ * Global rebuildBuffers function for HMR integration.
4007
+ * Invalidates cached buffers and increments _hmrVersion to trigger re-creation.
4008
+ * Call this when HMR is detected to refresh all buffer creators.
4009
+ *
4010
+ * Resolves to the primary store so shared TSL resources rebuild on the
4011
+ * authoritative store.
4012
+ *
4013
+ * @param store - The R3F store (from useStore or context)
4014
+ * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4015
+ */
4016
+ declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
4017
+
4018
+ /**
4019
+ * Creator function that returns a record of GPU storage objects.
4020
+ * Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
4021
+ */
4022
+ type StorageCreator<T extends Record<string, StorageLike>> = (state: CreatorState) => T;
4023
+ /** Function signature for removeStorage util */
4024
+ type RemoveStorageFn = (names: string | string[], scope?: string) => void;
4025
+ /** Function signature for clearStorage util */
4026
+ type ClearStorageFn = (scope?: string) => void;
4027
+ /** Function signature for rebuildStorage util */
4028
+ type RebuildStorageFn = (scope?: string) => void;
4029
+ /** Function signature for disposeStorage util - releases GPU resources */
4030
+ type DisposeStorageFn = (names: string | string[], scope?: string) => void;
4031
+ /** Return type with utils included */
4032
+ type StorageWithUtils<T extends Record<string, StorageLike> = Record<string, StorageLike>> = T & {
4033
+ removeStorage: RemoveStorageFn;
4034
+ clearStorage: ClearStorageFn;
4035
+ rebuildStorage: RebuildStorageFn;
4036
+ disposeStorage: DisposeStorageFn;
4037
+ };
4038
+ declare function useGPUStorage(): StorageWithUtils<Record<string, StorageLike> & Record<string, Record<string, StorageLike>>>;
4039
+ declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
4040
+ declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
4041
+ declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
4042
+ /**
4043
+ * Global rebuildStorage function for HMR integration.
4044
+ * Invalidates cached storage and increments _hmrVersion to trigger re-creation.
4045
+ * Call this when HMR is detected to refresh all storage creators.
4046
+ *
4047
+ * Resolves to the primary store so shared TSL resources rebuild on the
4048
+ * authoritative store.
4049
+ *
4050
+ * @param store - The R3F store (from useStore or context)
4051
+ * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4052
+ */
4053
+ declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
4054
+
4055
+ /**
4056
+ * Re-export from core - useTextures is now a core R3F hook (a reactive Texture registry).
4057
+ *
4058
+ * This file maintains backwards compatibility for existing webgpu imports.
4059
+ */
4060
+
4061
+ /**
4062
+ * @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
4063
+ * Kept as an alias for backwards compatibility.
4064
+ */
4065
+ type TextureEntry = Texture$1;
4066
+ /**
4067
+ * @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
4068
+ * Kept as an alias for backwards compatibility.
4069
+ */
4070
+ type TextureNode = Texture$1;
4071
+
3723
4072
  interface TextureOperations {
3724
4073
  add: (key: string, value: any) => void;
3725
4074
  addMultiple: (items: Map<string, any> | Record<string, any>) => void;
@@ -3729,10 +4078,10 @@ interface TextureOperations {
3729
4078
  declare function createTextureOperations(set: StoreApi<RootState>['setState']): TextureOperations;
3730
4079
 
3731
4080
  /**
3732
- * Hook for managing WebGPU PostProcessing with automatic scenePass setup.
4081
+ * Hook for managing WebGPU RenderPipeline with automatic scenePass setup.
3733
4082
  *
3734
4083
  * Features:
3735
- * - Creates PostProcessing instance if not exists
4084
+ * - Creates RenderPipeline instance if not exists
3736
4085
  * - Creates default scenePass (no MRT) automatically
3737
4086
  * - Callbacks receive full RootState for flexibility
3738
4087
  * - No auto-cleanup on unmount - use reset() for explicit cleanup
@@ -3740,21 +4089,21 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
3740
4089
  *
3741
4090
  * @param mainCB - Main callback to configure outputNode and create effect passes
3742
4091
  * @param setupCB - Optional setup callback to configure MRT on scenePass
3743
- * @returns { passes, postProcessing, clearPasses, reset, rebuild }
4092
+ * @returns { passes, renderPipeline, clearPasses, reset, rebuild }
3744
4093
  *
3745
4094
  * @example
3746
4095
  * ```tsx
3747
4096
  * // Simple effect
3748
- * usePostProcessing(({ postProcessing, passes }) => {
3749
- * postProcessing.outputNode = bloom(passes.scenePass.getTextureNode())
4097
+ * useRenderPipeline(({ renderPipeline, passes }) => {
4098
+ * renderPipeline.outputNode = bloom(passes.scenePass.getTextureNode())
3750
4099
  * })
3751
4100
  *
3752
4101
  * // With MRT setup
3753
- * usePostProcessing(
3754
- * ({ postProcessing, passes }) => {
4102
+ * useRenderPipeline(
4103
+ * ({ renderPipeline, passes }) => {
3755
4104
  * const beauty = passes.scenePass.getTextureNode().toInspector('Color')
3756
4105
  * const vel = passes.scenePass.getTextureNode('velocity')
3757
- * postProcessing.outputNode = motionBlur(beauty, vel)
4106
+ * renderPipeline.outputNode = motionBlur(beauty, vel)
3758
4107
  * },
3759
4108
  * ({ passes }) => {
3760
4109
  * passes.scenePass.setMRT(mrt({ output, velocity }))
@@ -3762,10 +4111,57 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
3762
4111
  * )
3763
4112
  *
3764
4113
  * // Read-only access
3765
- * const { postProcessing, passes } = usePostProcessing()
4114
+ * const { renderPipeline, passes } = useRenderPipeline()
4115
+ * ```
4116
+ */
4117
+ declare function useRenderPipeline(mainCB?: RenderPipelineMainCallback, setupCB?: RenderPipelineSetupCallback): UseRenderPipelineReturn;
4118
+
4119
+ //* Renderer Props ========================================
4120
+
4121
+ type WebGPUDefaultProps = Omit<WebGPURendererParameters, 'canvas'> & BaseRendererProps
4122
+
4123
+ type WebGPUProps =
4124
+ | RendererFactory<WebGPURenderer, WebGPUDefaultProps>
4125
+ | Partial<Properties<WebGPURenderer> | WebGPURendererParameters>
4126
+
4127
+ // WebGPU doesn't have shadow maps in the same way
4128
+ interface WebGPUShadowConfig {
4129
+ shadows?: boolean // Simplified for WebGPU
4130
+ }
4131
+
4132
+ //* WebGPU-specific Types ========================================
4133
+
4134
+ /** WebGPU renderer type - re-exported as R3FRenderer from @react-three/fiber/webgpu */
4135
+ type WebGPUR3FRenderer = WebGPURenderer
4136
+
4137
+ /** WebGPU internal state with narrowed renderer type */
4138
+ interface WebGPUInternalState extends Omit<InternalState, 'actualRenderer'> {
4139
+ actualRenderer: WebGPURenderer
4140
+ }
4141
+
4142
+ /**
4143
+ * WebGPU-specific RootState with narrowed renderer type.
4144
+ * Automatically used when importing from `@react-three/fiber/webgpu`.
4145
+ *
4146
+ * @example
4147
+ * ```tsx
4148
+ * import { useThree } from '@react-three/fiber/webgpu'
4149
+ *
4150
+ * function MyComponent() {
4151
+ * const { renderer } = useThree()
4152
+ * // renderer is typed as WebGPURenderer
4153
+ * renderer.compute(computePass)
4154
+ * }
3766
4155
  * ```
3767
4156
  */
3768
- declare function usePostProcessing(mainCB?: PostProcessingMainCallback, setupCB?: PostProcessingSetupCallback): UsePostProcessingReturn;
4157
+ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'> {
4158
+ /** @deprecated Use `renderer` instead */
4159
+ gl: WebGPURenderer
4160
+ /** The WebGPU renderer instance */
4161
+ renderer: WebGPURenderer
4162
+ /** Internals with WebGPU renderer */
4163
+ internal: WebGPUInternalState
4164
+ }
3769
4165
 
3770
- export { Block, Canvas, ErrorBoundary, IsObject, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Scheduler, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, getInstanceProps, getRootState, getScheduler, getUuidPrefix, hasConstructor, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isObject3D, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, prepare, rebuildAllNodes, rebuildAllUniforms, reconciler, removeInteractivity, removeNodes, removeUniforms, resolve, unmountComponentAtNode, updateCamera, updateFrustum, useBridge, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, usePostProcessing, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms };
3771
- export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BaseRendererProps, Bridge, Camera, CameraProps, CanvasProps, Catalogue, ClearNodesFn, ClearUniformsFn, Color, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DomEvent, Dpr, ElementProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, FrameTimingState, Frameloop, GLProps, GLTFLike, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeRecord, NodesWithUtils, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, Properties, Quaternion, RaycastableRepresentation, ReactProps, RebuildNodesFn, RebuildUniformsFn, ReconcilerRoot, RemoveNodesFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererFactory, RendererProps, Root, RootOptions, RootState, RootStore, SchedulerApi, ScopedStoreType, SetBlock, Size, Subscription, TSLNode, TextureEntry, TextureOperations, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager };
4166
+ export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useBuffers, useEnvironment, useFrame, useGPUStorage, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, useRenderPipeline, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
4167
+ export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DisposeBuffersFn, DisposeOptions, DisposeStorageFn, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeProps, NodeRecord, NodesWithUtils, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, RebuildBuffersFn, RebuildNodesFn, RebuildStorageFn, RebuildUniformsFn, ReconcilerRoot, RemoveBuffersFn, RemoveNodesFn, RemoveStorageFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, WebGPURootState as RootState, RootStore, ScopedStoreType, SetBlock, Size, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, Subscription, TSLNode, TSLNodeInput, TextureEntry, TextureInput, TextureNode, TextureOperations, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };