@react-three/fiber 10.0.0-alpha.1 → 10.0.0-canary.0706a92

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