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

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,16 @@
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';
11
10
  import { Options } from 'react-use-measure';
12
11
  import * as react_jsx_runtime from 'react/jsx-runtime';
12
+ import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
13
+ import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
13
14
 
14
15
  function _mergeNamespaces(n, m) {
15
16
  m.forEach(function (e) {
@@ -58,1270 +59,1741 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
58
59
  WebGLShadowMap: WebGLShadowMap
59
60
  }, [three_webgpu]);
60
61
 
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
-
62
+ //* Utility Types ==============================
63
+
64
+ type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
65
+ type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
66
+ type Properties<T> = Pick<T, NonFunctionKeys<T>>
67
+ type Mutable<P> = { -readonly [K in keyof P]: P[K] }
68
+ type IsOptional<T> = undefined extends T ? true : false
69
+ type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
70
+ ? IsOptional<First> extends true
71
+ ? IsAllOptional<Rest>
72
+ : false
73
+ : true
74
+
75
+ //* Camera Types ==============================
76
+
77
+ type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
78
+
79
+ //* Act Type ==============================
80
+
81
+ type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
82
+
83
+ //* Bridge & Block Types ==============================
84
+
85
+ type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
86
+
87
+ type SetBlock = false | Promise<null> | null
88
+ type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
89
+
90
+ //* Object Map Type ==============================
91
+
92
+ /* Original version
93
+ export interface ObjectMap {
94
+ nodes: { [name: string]: THREE.Object3D }
95
+ materials: { [name: string]: THREE.Material }
96
+ meshes: { [name: string]: THREE.Mesh }
97
+ }
98
+ */
99
+ /* This version is an expansion found in a PR by itsdouges that seems abandoned but looks useful.
100
+ It allows expansion but falls back to the original shape. (deleted due to stale, but If it doesnt conflict
101
+ I will keep the use here)
102
+ https://github.com/pmndrs/react-three-fiber/commits/generic-object-map/
103
+ His description is:
104
+ The object map type is now generic and can optionally declare the available properties for nodes, materials, and meshes.
105
+ */
106
+ interface ObjectMap<
107
+ T extends { nodes?: string; materials?: string; meshes?: string } = {
108
+ nodes: string
109
+ materials: string
110
+ meshes: string
111
+ },
112
+ > {
113
+ nodes: Record<T['nodes'] extends string ? T['nodes'] : string, THREE$1.Object3D>
114
+ materials: Record<T['materials'] extends string ? T['materials'] : string, THREE$1.Material>
115
+ meshes: Record<T['meshes'] extends string ? T['meshes'] : string, THREE$1.Mesh>
116
+ }
117
+
118
+ //* Equality Config ==============================
119
+
120
+ interface EquConfig {
121
+ /** Compare arrays by reference equality a === b (default), or by shallow equality */
122
+ arrays?: 'reference' | 'shallow'
123
+ /** Compare objects by reference equality a === b (default), or by shallow equality */
124
+ objects?: 'reference' | 'shallow'
125
+ /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
126
+ strict?: boolean
127
+ }
128
+
129
+ //* Disposable Type ==============================
130
+
131
+ interface Disposable {
132
+ type?: string
133
+ dispose?: () => void
134
+ }
135
+
136
+ //* Event-related Types =====================================
137
+
138
+ interface Intersection extends THREE$1.Intersection {
139
+ /** The event source (the object which registered the handler) */
140
+ eventObject: THREE$1.Object3D
141
+ }
142
+
143
+ type Camera = THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera
144
+
145
+ interface IntersectionEvent<TSourceEvent> extends Intersection {
146
+ /** The event source (the object which registered the handler) */
147
+ eventObject: THREE$1.Object3D
148
+ /** An array of intersections */
149
+ intersections: Intersection[]
150
+ /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
151
+ unprojectedPoint: THREE$1.Vector3
152
+ /** Normalized event coordinates */
153
+ pointer: THREE$1.Vector2
154
+ /** pointerId of the original event for multiple pointer events */
155
+ pointerId: number
156
+ /** Delta between first click and this event */
157
+ delta: number
158
+ /** The ray that pierced it */
159
+ ray: THREE$1.Ray
160
+ /** The camera that was used by the raycaster */
161
+ camera: Camera
162
+ /** stopPropagation will stop underlying handlers from firing */
163
+ stopPropagation: () => void
164
+ /** The original host event */
165
+ nativeEvent: TSourceEvent
166
+ /** If the event was stopped by calling stopPropagation */
167
+ stopped: boolean
168
+ }
169
+
170
+ type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>
171
+ type DomEvent = PointerEvent | MouseEvent | WheelEvent
172
+
173
+ /** DOM event handlers registered on the canvas element */
174
+ interface Events {
175
+ onClick: EventListener
176
+ onContextMenu: EventListener
177
+ onDoubleClick: EventListener
178
+ onWheel: EventListener
179
+ onPointerDown: EventListener
180
+ onPointerUp: EventListener
181
+ onPointerLeave: EventListener
182
+ onPointerMove: EventListener
183
+ onPointerCancel: EventListener
184
+ onLostPointerCapture: EventListener
185
+ onDragEnter: EventListener
186
+ onDragLeave: EventListener
187
+ onDragOver: EventListener
188
+ onDrop: EventListener
189
+ }
190
+
191
+ /** Event handlers that can be attached to R3F objects (meshes, groups, etc.) */
192
+ interface EventHandlers {
193
+ onClick?: (event: ThreeEvent<MouseEvent>) => void
194
+ onContextMenu?: (event: ThreeEvent<MouseEvent>) => void
195
+ onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void
196
+ /** Fires continuously while dragging over the object */
197
+ onDragOver?: (event: ThreeEvent<DragEvent>) => void
198
+ /** Fires once when drag enters the object */
199
+ onDragOverEnter?: (event: ThreeEvent<DragEvent>) => void
200
+ /** Fires once when drag leaves the object */
201
+ onDragOverLeave?: (event: ThreeEvent<DragEvent>) => void
202
+ /** Fires when drag misses this object (for objects that have drag handlers) */
203
+ onDragOverMissed?: (event: DragEvent) => void
204
+ /** Fires when a drop occurs on this object */
205
+ onDrop?: (event: ThreeEvent<DragEvent>) => void
206
+ /** Fires when a drop misses this object (for objects that have drop handlers) */
207
+ onDropMissed?: (event: DragEvent) => void
208
+ onPointerUp?: (event: ThreeEvent<PointerEvent>) => void
209
+ onPointerDown?: (event: ThreeEvent<PointerEvent>) => void
210
+ onPointerOver?: (event: ThreeEvent<PointerEvent>) => void
211
+ onPointerOut?: (event: ThreeEvent<PointerEvent>) => void
212
+ onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void
213
+ onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void
214
+ onPointerMove?: (event: ThreeEvent<PointerEvent>) => void
215
+ onPointerMissed?: (event: MouseEvent) => void
216
+ onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
217
+ onWheel?: (event: ThreeEvent<WheelEvent>) => void
218
+ onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
219
+
220
+ //* Visibility Events --------------------------------
221
+ /** Fires when object enters/exits camera frustum. Receives true when in view, false when out. */
222
+ onFramed?: (inView: boolean) => void
223
+ /** Fires when object occlusion state changes (WebGPU only, requires occlusionTest=true on object) */
224
+ onOccluded?: (occluded: boolean) => void
225
+ /** Fires when combined visibility changes (frustum + occlusion + visible prop) */
226
+ onVisible?: (visible: boolean) => void
227
+ }
228
+
229
+ type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
230
+ type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
231
+
232
+ /** Configuration for XR pointer registration (controllers/hands) */
233
+ interface XRPointerConfig {
234
+ /** Ray origin (updated each frame by XR system) */
235
+ ray: THREE$1.Ray
236
+ /** Optional: custom compute function for this pointer */
237
+ compute?: (state: RootState) => void
238
+ /** Pointer type identifier */
239
+ type: 'controller' | 'hand' | 'gaze'
240
+ /** Which hand (for controller/hand types) */
241
+ handedness?: 'left' | 'right'
242
+ }
243
+
244
+ interface EventManager<TTarget> {
245
+ /** Determines if the event layer is active */
246
+ enabled: boolean
247
+ /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
248
+ priority: number
249
+ /** The compute function needs to set up the raycaster and an xy- pointer */
250
+ compute?: ComputeFunction
251
+ /** The filter can re-order or re-structure the intersections */
252
+ filter?: FilterFunction
253
+ /** The target node the event layer is tied to */
254
+ connected?: TTarget
255
+ /** All the pointer event handlers through which the host forwards native events */
256
+ handlers?: Events
257
+ /** Allows re-connecting to another target */
258
+ connect?: (target: TTarget) => void
259
+ /** Removes all existing events handlers from the target */
260
+ disconnect?: () => void
261
+ /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
262
+ * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
263
+ * @param pointerId - Optional pointer ID to update specific pointer only
264
+ */
265
+ update?: (pointerId?: number) => void
266
+ /** Defer pointer move raycasting to frame start (default: true) */
267
+ frameTimedRaycasts?: boolean
268
+ /** Always fire raycaster immediately on scroll events (default: true) */
269
+ alwaysFireOnScroll?: boolean
270
+ /** Automatically re-raycast every frame to detect hover changes from moving objects/camera (default: false) */
271
+ updateOnFrame?: boolean
272
+ /** Flush deferred pointer raycasts. Called by scheduler at frame start (input phase). */
273
+ flush?: () => void
274
+ /** Register an XR pointer (controller/hand). Returns assigned pointerId */
275
+ registerPointer?: (config: XRPointerConfig) => number
276
+ /** Unregister an XR pointer */
277
+ unregisterPointer?: (pointerId: number) => void
278
+ }
279
+
280
+ interface PointerCaptureTarget {
281
+ intersection: Intersection
282
+ target: Element
283
+ }
284
+
285
+ //* Visibility System Types =====================================
286
+
287
+ /** Entry in the visibility registry for tracking object visibility state */
288
+ interface VisibilityEntry {
289
+ object: THREE$1.Object3D
290
+ handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
291
+ lastFramedState: boolean | null
292
+ lastOccludedState: boolean | null
293
+ lastVisibleState: boolean | null
294
+ }
295
+
296
+ //* Scheduler Types (useFrame) ==============================
297
+
298
+
299
+
300
+ // Public Options --------------------------------
301
+
302
+ /**
303
+ * Options for useFrame hook
304
+ */
305
+ interface UseFrameNextOptions {
306
+ /** Optional stable id for the job. Auto-generated if not provided */
307
+ id?: string
308
+ /** Named phase to run in. Default: 'update' */
309
+ phase?: string
310
+ /** Run before this phase or job id */
311
+ before?: string | string[]
312
+ /** Run after this phase or job id */
313
+ after?: string | string[]
314
+ /** Priority within phase. Higher runs first. Default: 0 */
315
+ priority?: number
316
+ /** Max frames per second for this job */
317
+ fps?: number
318
+ /** If true, skip frames when behind. If false, try to catch up. Default: true */
319
+ drop?: boolean
320
+ /** Enable/disable without unregistering. Default: true */
321
+ enabled?: boolean
322
+ }
323
+
324
+ /** Alias for UseFrameNextOptions */
325
+ type UseFrameOptions = UseFrameNextOptions
326
+
327
+ /**
328
+ * Options for addPhase
329
+ */
330
+ interface AddPhaseOptions {
331
+ /** Insert this phase before the specified phase */
332
+ before?: string
333
+ /** Insert this phase after the specified phase */
334
+ after?: string
335
+ }
336
+
337
+ // Frame State --------------------------------
338
+
339
+ /**
340
+ * Timing-only state for independent/outside mode (no RootState)
341
+ */
342
+ interface FrameTimingState {
343
+ /** High-resolution timestamp from RAF (ms) */
344
+ time: number
345
+ /** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
346
+ delta: number
347
+ /** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
348
+ elapsed: number
349
+ /** Incrementing frame counter */
350
+ frame: number
351
+ }
352
+
353
+ /**
354
+ * State passed to useFrame callbacks (extends RootState with timing)
355
+ */
356
+ interface FrameNextState extends RootState, FrameTimingState {}
357
+
358
+ /** Alias for FrameNextState */
359
+ type FrameState = FrameNextState
360
+
361
+ // Root Options --------------------------------
362
+
363
+ /**
364
+ * Options for registerRoot
365
+ */
366
+ interface RootOptions {
367
+ /** State provider for callbacks. Optional in independent mode. */
368
+ getState?: () => any
369
+ /** Error handler for job errors. Falls back to console.error if not provided. */
370
+ onError?: (error: Error) => void
371
+ }
372
+
373
+ // Callback Types --------------------------------
374
+
375
+ /**
376
+ * Callback function for useFrame
377
+ */
378
+ type FrameNextCallback = (state: FrameNextState, delta: number) => void
379
+
380
+ /** Alias for FrameNextCallback */
381
+ type FrameCallback = FrameNextCallback
382
+
383
+ // Controls returned from useFrame --------------------------------
384
+
385
+ /**
386
+ * Controls object returned from useFrame hook
387
+ */
388
+ interface FrameNextControls {
389
+ /** The job's unique ID */
390
+ id: string
391
+ /** Access to the global scheduler for frame loop control */
392
+ scheduler: SchedulerApi
393
+ /** Manually step this job only (bypasses FPS limiting) */
394
+ step(timestamp?: number): void
395
+ /** Manually step ALL jobs in the scheduler */
396
+ stepAll(timestamp?: number): void
397
+ /** Pause this job (set enabled=false) */
398
+ pause(): void
399
+ /** Resume this job (set enabled=true) */
400
+ resume(): void
401
+ /** Reactive paused state - automatically triggers re-render when changed */
402
+ isPaused: boolean
403
+ }
404
+
405
+ /** Alias for FrameNextControls */
406
+ type FrameControls = FrameNextControls
407
+
408
+ // Scheduler Interface --------------------------------
409
+
410
+ /**
411
+ * Public interface for the global Scheduler
412
+ */
413
+ interface SchedulerApi {
414
+ //* Phase Management --------------------------------
415
+
416
+ /** Add a named phase to the scheduler */
417
+ addPhase(name: string, options?: AddPhaseOptions): void
418
+ /** Get the ordered list of phase names */
419
+ readonly phases: string[]
420
+ /** Check if a phase exists */
421
+ hasPhase(name: string): boolean
422
+
423
+ //* Root Management --------------------------------
424
+
425
+ /** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
426
+ registerRoot(id: string, options?: RootOptions): () => void
427
+ /** Unregister a root */
428
+ unregisterRoot(id: string): void
429
+ /** Generate a unique root ID */
430
+ generateRootId(): string
431
+ /** Get the number of registered roots */
432
+ getRootCount(): number
433
+ /** Check if any root is registered and ready */
434
+ readonly isReady: boolean
435
+ /** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
436
+ onRootReady(callback: () => void): () => void
437
+
438
+ //* Job Registration --------------------------------
439
+
440
+ /** Register a job with the scheduler (returns unsubscribe function) */
441
+ register(
442
+ callback: FrameNextCallback,
443
+ options?: {
444
+ id?: string
445
+ rootId?: string
446
+ phase?: string
447
+ before?: string | string[]
448
+ after?: string | string[]
449
+ priority?: number
450
+ fps?: number
451
+ drop?: boolean
452
+ enabled?: boolean
453
+ },
454
+ ): () => void
455
+ /** Update a job's options */
456
+ updateJob(
457
+ id: string,
458
+ options: {
459
+ priority?: number
460
+ fps?: number
461
+ drop?: boolean
462
+ enabled?: boolean
463
+ phase?: string
464
+ before?: string | string[]
465
+ after?: string | string[]
466
+ },
467
+ ): void
468
+ /** Unregister a job by ID */
469
+ unregister(id: string, rootId?: string): void
470
+ /** Get the number of registered jobs */
471
+ getJobCount(): number
472
+ /** Get all job IDs */
473
+ getJobIds(): string[]
474
+
475
+ //* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
476
+
477
+ /** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
478
+ registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
479
+
480
+ //* Idle Callbacks (for legacy addTail) --------------------------------
481
+
482
+ /** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
483
+ onIdle(callback: (timestamp: number) => void): () => void
484
+
485
+ //* Frame Loop Control --------------------------------
486
+
487
+ /** Start the scheduler loop */
488
+ start(): void
489
+ /** Stop the scheduler loop */
490
+ stop(): void
491
+ /** Check if the scheduler is running */
492
+ readonly isRunning: boolean
493
+ /** Get/set the frameloop mode ('always', 'demand', 'never') */
494
+ frameloop: Frameloop
495
+ /** Independent mode - runs without Canvas, callbacks receive timing-only state */
496
+ independent: boolean
497
+
498
+ //* Manual Stepping --------------------------------
499
+
500
+ /** Manually step all jobs once (for frameloop='never' or testing) */
501
+ step(timestamp?: number): void
502
+ /** Manually step a single job by ID */
503
+ stepJob(id: string, timestamp?: number): void
504
+ /** Request frame(s) to be rendered (for frameloop='demand') */
505
+ invalidate(frames?: number): void
506
+
507
+ //* Per-Job Control --------------------------------
508
+
509
+ /** Check if a job is paused */
510
+ isJobPaused(id: string): boolean
511
+ /** Pause a job */
512
+ pauseJob(id: string): void
513
+ /** Resume a job */
514
+ resumeJob(id: string): void
515
+ /** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
516
+ subscribeJobState(id: string, listener: () => void): () => void
517
+ }
518
+
519
+ //* Buffer Types (useBuffers) ========================================
520
+
521
+ /**
522
+ * Buffer-like types for GPU compute and storage operations.
523
+ * Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
524
+ *
525
+ * @example
526
+ * ```tsx
527
+ * const { positions, velocities } = useBuffers(() => ({
528
+ * positions: instancedArray(count, 'vec3'), // StorageBufferNode
529
+ * velocities: new Float32Array(count * 3), // TypedArray
530
+ * }), 'particles')
531
+ * ```
532
+ */
533
+ type BufferLike =
534
+ | Float32Array
535
+ | Uint32Array
536
+ | Int32Array
537
+ | Float64Array
538
+ | Uint8Array
539
+ | Int8Array
540
+ | Uint16Array
541
+ | Int16Array
542
+ | THREE$1.BufferAttribute // Base class for all buffer attributes
543
+ | Node // TSL buffer nodes (instancedArray, storage)
544
+
545
+ /** Flat record of buffer-like values (no nested scopes) */
546
+ type BufferRecord = Record<string, BufferLike>
547
+
548
+ /**
549
+ * Buffer store that can contain both root-level buffers and scoped buffer objects.
550
+ * Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
551
+ */
552
+ type BufferStore = Record<string, BufferLike | BufferRecord>
553
+
554
+ //* Storage Types (useGPUStorage) ========================================
555
+
556
+ /**
557
+ * GPU storage types for texture-based storage operations.
558
+ * Includes Three.js storage textures and TSL storage texture nodes.
559
+ *
560
+ * @example
561
+ * ```tsx
562
+ * const { heightMap } = useGPUStorage(() => ({
563
+ * heightMap: new StorageTexture(512, 512),
564
+ * }), 'terrain')
565
+ * ```
566
+ */
567
+ type StorageLike =
568
+ | StorageTexture // GPU storage texture
569
+ | Data3DTexture // 3D texture (can be used as storage)
570
+ | Node // TSL storage texture nodes (storageTexture)
571
+
572
+ /** Flat record of storage-like values (no nested scopes) */
573
+ type StorageRecord = Record<string, StorageLike>
574
+
575
+ /**
576
+ * Storage store that can contain both root-level storage and scoped storage objects.
577
+ * Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
578
+ */
579
+ type StorageStore = Record<string, StorageLike | StorageRecord>
580
+
581
+ //* Renderer Types ========================================
582
+
583
+ /** Default renderer type - union of WebGL and WebGPU renderers */
584
+ type R3FRenderer = THREE$1.WebGLRenderer | WebGPURenderer
585
+
586
+ //* Core Store Types ========================================
587
+
588
+ type Subscription = {
589
+ ref: React$1.RefObject<RenderCallback>
590
+ priority: number
591
+ store: RootStore
592
+ }
593
+
594
+ /** Per-pointer state for multi-touch and XR support */
595
+ type PointerState = {
596
+ /** Objects currently hovered by this pointer */
597
+ hovered: Map<string, ThreeEvent<DomEvent>>
598
+ /** Objects capturing this pointer */
599
+ captured: Map<THREE$1.Object3D, PointerCaptureTarget>
600
+ /** Initial click position [x, y] */
601
+ initialClick: [x: number, y: number]
602
+ /** Objects hit on initial click */
603
+ initialHits: THREE$1.Object3D[]
604
+ }
605
+
606
+ type Dpr = number | [min: number, max: number]
607
+
608
+ interface Size {
609
+ width: number
610
+ height: number
611
+ top: number
612
+ left: number
613
+ }
614
+
615
+ type Frameloop = 'always' | 'demand' | 'never'
616
+
617
+ interface Viewport extends Size {
618
+ /** The initial pixel ratio */
619
+ initialDpr: number
620
+ /** Current pixel ratio */
621
+ dpr: number
622
+ /** size.width / viewport.width */
623
+ factor: number
624
+ /** Camera distance */
625
+ distance: number
626
+ /** Camera aspect ratio: width / height */
627
+ aspect: number
628
+ }
629
+
630
+ type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void
631
+
632
+ interface Performance {
633
+ /** Current performance normal, between min and max */
634
+ current: number
635
+ /** How low the performance can go, between 0 and max */
636
+ min: number
637
+ /** How high the performance can go, between min and max */
638
+ max: number
639
+ /** Time until current returns to max in ms */
640
+ debounce: number
641
+ /** Sets current to min, puts the system in regression */
642
+ regress: () => void
643
+ }
644
+
645
+ interface InternalState {
646
+ interaction: THREE$1.Object3D[]
647
+ subscribers: Subscription[]
648
+ /** Per-pointer state (hover, capture, click tracking) - replaces hovered, capturedMap, initialClick, initialHits */
649
+ pointerMap: Map<number, PointerState>
650
+ /** Pointers needing raycast this frame (used with frameTimedRaycasts) */
651
+ pointerDirty: Map<number, DomEvent>
652
+ /** Last event received (for events.update() compatibility) */
653
+ lastEvent: React$1.RefObject<DomEvent | null>
654
+ /** @deprecated Use pointerMap.get(pointerId).hovered instead */
655
+ hovered: Map<string, ThreeEvent<DomEvent>>
656
+ /** @deprecated Use pointerMap.get(pointerId).captured instead */
657
+ capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
658
+ /** @deprecated Use pointerMap.get(pointerId).initialClick instead */
659
+ initialClick: [x: number, y: number]
660
+ /** @deprecated Use pointerMap.get(pointerId).initialHits instead */
661
+ initialHits: THREE$1.Object3D[]
662
+ /** Visibility event registry (onFramed, onOccluded, onVisible) */
663
+ visibilityRegistry: Map<string, VisibilityEntry>
664
+ /** Whether occlusion queries are enabled (WebGPU only) */
665
+ occlusionEnabled: boolean
666
+ /** Reference to the invisible occlusion observer mesh */
667
+ occlusionObserver: THREE$1.Mesh | null
668
+ /** Cached occlusion results from render pass - keyed by Object3D */
669
+ occlusionCache: Map<THREE$1.Object3D, boolean | null>
670
+ /** Internal helper group for R3F system objects (occlusion observer, etc.) */
671
+ helperGroup: THREE$1.Group | null
672
+ active: boolean
673
+ priority: number
674
+ frames: number
675
+ subscribe: (callback: React$1.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
676
+ /** Internal renderer storage - use state.renderer or state.gl to access */
677
+ actualRenderer: R3FRenderer
678
+ /** Global scheduler reference (for useFrame hook) */
679
+ scheduler: SchedulerApi | null
680
+ /** This root's unique ID in the global scheduler */
681
+ rootId?: string
682
+ /** Function to unregister this root from the global scheduler */
683
+ unregisterRoot?: () => void
684
+ /** Container for child attachment (scene for root, original container for portals) */
685
+ container?: THREE$1.Object3D
686
+ /**
687
+ * CanvasTarget for multi-canvas WebGPU rendering.
688
+ * Created for all WebGPU canvases to support renderer sharing.
689
+ * @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
690
+ */
691
+ canvasTarget?: CanvasTarget
692
+ /**
693
+ * Whether multi-canvas rendering is active.
694
+ * True when any canvas uses `target` prop to share a renderer.
695
+ * When true, setCanvasTarget is called before each render.
696
+ */
697
+ isMultiCanvas?: boolean
698
+ /**
699
+ * Whether this canvas is a secondary canvas sharing another's renderer.
700
+ * True when `target` prop is used.
701
+ */
702
+ isSecondary?: boolean
703
+ /**
704
+ * The id of the primary canvas this secondary canvas targets.
705
+ * Only set when isSecondary is true.
706
+ */
707
+ targetId?: string
708
+ /**
709
+ * Function to unregister this primary canvas from the registry.
710
+ * Only set when this canvas has an `id` prop.
711
+ */
712
+ unregisterPrimary?: () => void
713
+ /** Whether canvas dimensions are forced to even numbers */
714
+ forceEven?: boolean
715
+ }
716
+
717
+ interface XRManager {
718
+ connect: () => void
719
+ disconnect: () => void
720
+ }
721
+
722
+ //* Root State Interface ====================================
723
+
724
+ interface RootState {
725
+ /** Set current state */
726
+ set: StoreApi<RootState>['setState']
727
+ /** Get current state */
728
+ get: StoreApi<RootState>['getState']
729
+ /**
730
+ * Reference to the authoritative store for shared TSL resources (uniforms, nodes, etc).
731
+ * - For primary/independent canvases: points to its own store (self-reference)
732
+ * - For secondary canvases: points to the primary canvas's store
733
+ *
734
+ * Hooks like useNodes/useUniforms should read from primaryStore to ensure
735
+ * consistent shared state across all canvases sharing a renderer.
736
+ */
737
+ primaryStore: RootStore
738
+ /** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
739
+ gl: THREE$1.WebGLRenderer
740
+ /** The renderer instance - type depends on entry point (WebGPU, Legacy, or union for default) */
741
+ renderer: R3FRenderer
742
+ /** Inspector of the webGPU Renderer. Init in the canvas */
743
+ inspector: any // Inspector type from three/webgpu
744
+
745
+ /** Default camera */
746
+ camera: ThreeCamera
747
+ /** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
748
+ frustum: THREE$1.Frustum
749
+ /** Whether to automatically update the frustum each frame (default: true) */
750
+ autoUpdateFrustum: boolean
751
+ /** Default scene (may be overridden in portals to point to the portal container) */
752
+ scene: THREE$1.Scene
753
+ /** The actual root THREE.Scene - always points to the true scene, even inside portals */
754
+ rootScene: THREE$1.Scene
755
+ /** Default raycaster */
756
+ raycaster: THREE$1.Raycaster
757
+ /** Event layer interface, contains the event handler and the node they're connected to */
758
+ events: EventManager<any>
759
+ /** XR interface */
760
+ xr: XRManager
761
+ /** Currently used controls */
762
+ controls: THREE$1.EventDispatcher | null
763
+ /** Normalized event coordinates */
764
+ pointer: THREE$1.Vector2
765
+ /** @deprecated Normalized event coordinates, use "pointer" instead! */
766
+ mouse: THREE$1.Vector2
767
+ /** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
768
+ textureColorSpace: THREE$1.ColorSpace
769
+ /** Render loop flags */
770
+ frameloop: Frameloop
771
+ performance: Performance
772
+ /** Reactive pixel-size of the canvas */
773
+ size: Size
774
+ /** Reactive size of the viewport in threejs units */
775
+ viewport: Viewport & {
776
+ getCurrentViewport: (
777
+ camera?: ThreeCamera,
778
+ target?: THREE$1.Vector3 | Parameters<THREE$1.Vector3['set']>,
779
+ size?: Size,
780
+ ) => Omit<Viewport, 'dpr' | 'initialDpr'>
781
+ }
782
+ /** Flags the canvas for render, but doesn't render in itself */
783
+ invalidate: (frames?: number, stackFrames?: boolean) => void
784
+ /** Advance (render) one step */
785
+ advance: (timestamp: number, runGlobalEffects?: boolean) => void
786
+ /** Shortcut to setting the event layer */
787
+ setEvents: (events: Partial<EventManager<any>>) => void
788
+ /** Shortcut to manual sizing. No args resets to props/container. Single arg creates square. */
789
+ setSize: (width?: number, height?: number, top?: number, left?: number) => void
790
+ /** Shortcut to manual setting the pixel ratio */
791
+ setDpr: (dpr: Dpr) => void
792
+ /** Shortcut to setting frameloop flags */
793
+ setFrameloop: (frameloop: Frameloop) => void
794
+ /** Set error state to propagate to error boundary */
795
+ setError: (error: Error | null) => void
796
+ /** Current error state (null when no error) */
797
+ error: Error | null
798
+ /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
799
+ uniforms: UniformStore
800
+ /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
801
+ nodes: Record<string, any>
802
+ /** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
803
+ buffers: BufferStore
804
+ /** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
805
+ gpuStorage: StorageStore
806
+ /** Global TSL texture nodes - use useTextures() hook for operations */
807
+ textures: Map<string, any>
808
+ /** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
809
+ renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
810
+ /** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
811
+ passes: Record<string, any>
812
+ /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
813
+ _hmrVersion: number
814
+ /** Internal: whether setSize() has taken ownership of canvas dimensions */
815
+ _sizeImperative: boolean
816
+ /** Internal: stored size props from Canvas for reset functionality */
817
+ _sizeProps: { width?: number; height?: number } | null
818
+ /** When the canvas was clicked but nothing was hit */
819
+ onPointerMissed?: (event: MouseEvent) => void
820
+ /** When a dragover event has missed any target */
821
+ onDragOverMissed?: (event: DragEvent) => void
822
+ /** When a drop event has missed any target */
823
+ onDropMissed?: (event: DragEvent) => void
824
+ /** If this state model is layered (via createPortal) then this contains the previous layer */
825
+ previousRoot?: RootStore
826
+ /** Internals */
827
+ internal: InternalState
828
+ // flags for triggers
829
+ // if we are using the webGl renderer, this will be true
830
+ isLegacy: boolean
831
+ // regardless of renderer, if the system supports webGpu, this will be true
832
+ webGPUSupported: boolean
833
+ //if we are on native
834
+ isNative: boolean
835
+ }
836
+
659
837
  type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
660
838
 
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
- }
839
+ //* Base Renderer Types =====================================
840
+
841
+ // Shim for OffscreenCanvas since it was removed from DOM types
842
+ interface OffscreenCanvas$1 extends EventTarget {}
843
+
844
+ interface BaseRendererProps {
845
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
846
+ powerPreference?: 'high-performance' | 'low-power' | 'default'
847
+ antialias?: boolean
848
+ alpha?: boolean
849
+ }
850
+
851
+ type RendererFactory<TRenderer, TParams> =
852
+ | TRenderer
853
+ | ((defaultProps: TParams) => TRenderer)
854
+ | ((defaultProps: TParams) => Promise<TRenderer>)
855
+
856
+ interface Renderer {
857
+ render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
858
+ }
859
+
860
+ //* Color Management Config ==============================
861
+
862
+ /**
863
+ * Color management configuration shared by both WebGL and WebGPU renderers.
864
+ */
865
+ interface ColorManagementConfig {
866
+ /**
867
+ * Color space assigned to 8-bit input textures (color maps).
868
+ * Defaults to sRGB. Most textures are authored in sRGB.
869
+ * @default THREE.SRGBColorSpace
870
+ */
871
+ textureColorSpace?: THREE$1.ColorSpace
872
+ }
873
+
874
+ //* WebGL Renderer Props ==============================
875
+
876
+ type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
877
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
878
+ }
879
+
880
+ type GLProps =
881
+ | Renderer
882
+ | ((defaultProps: DefaultGLProps) => Renderer)
883
+ | ((defaultProps: DefaultGLProps) => Promise<Renderer>)
884
+ | (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
885
+
886
+ //* WebGPU Renderer Props ==============================
887
+
888
+ type DefaultRendererProps = {
889
+ canvas: HTMLCanvasElement | OffscreenCanvas$1
890
+ [key: string]: any
891
+ }
892
+
893
+ /**
894
+ * Canvas-level scheduler configuration.
895
+ * Controls render timing relative to other canvases.
896
+ */
897
+ interface CanvasSchedulerConfig {
898
+ /**
899
+ * Render this canvas after another canvas completes.
900
+ * Pass the `id` of another canvas.
901
+ */
902
+ after?: string
903
+ /**
904
+ * Limit this canvas's render rate (frames per second).
905
+ */
906
+ fps?: number
907
+ }
908
+
909
+ /**
910
+ * Extended renderer configuration for multi-canvas support and color management.
911
+ */
912
+ interface RendererConfigExtended extends ColorManagementConfig {
913
+ /** Share renderer from another canvas (WebGPU only) */
914
+ primaryCanvas?: string
915
+ /** Canvas-level scheduler options */
916
+ scheduler?: CanvasSchedulerConfig
917
+ }
918
+
919
+ type RendererProps =
920
+ | any // WebGPURenderer
921
+ | ((defaultProps: DefaultRendererProps) => any)
922
+ | ((defaultProps: DefaultRendererProps) => Promise<any>)
923
+ | (Partial<Properties<any> | Record<string, any>> & RendererConfigExtended)
924
+
925
+ //* Camera Props ==============================
926
+
927
+ type CameraProps = (
928
+ | THREE$1.Camera
929
+ | Partial<
930
+ ThreeElement<typeof THREE$1.Camera> &
931
+ ThreeElement<typeof THREE$1.PerspectiveCamera> &
932
+ ThreeElement<typeof THREE$1.OrthographicCamera>
933
+ >
934
+ ) & {
935
+ /** Flags the camera as manual, putting projection into your own hands */
936
+ manual?: boolean
937
+ }
938
+
939
+ //* Render Props ==============================
940
+
941
+ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
942
+ /**
943
+ * Unique identifier for multi-canvas renderer sharing.
944
+ * Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
945
+ * Also sets the HTML `id` attribute on the canvas element.
946
+ * @example <Canvas id="main-viewer">...</Canvas>
947
+ */
948
+ id?: string
949
+ /**
950
+ * Share the renderer from another canvas instead of creating a new one.
951
+ * Pass the `id` of the primary canvas to share its WebGPURenderer.
952
+ * Only available with WebGPU (not legacy WebGL).
953
+ *
954
+ * Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
955
+ * @internal
956
+ */
957
+ primaryCanvas?: string
958
+ /**
959
+ * Canvas-level scheduler options. Controls render timing relative to other canvases.
960
+ *
961
+ * Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
962
+ * @internal
963
+ */
964
+ scheduler?: CanvasSchedulerConfig
965
+ /** A threejs renderer instance or props that go into the default renderer */
966
+ gl?: GLProps
967
+ /** A WebGPU renderer instance or props that go into the default renderer */
968
+ renderer?: RendererProps
969
+ /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
970
+ size?: Size
971
+ /**
972
+ * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
973
+ * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
974
+ * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
975
+ */
976
+ shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
977
+ /** Creates an orthographic camera */
978
+ orthographic?: boolean
979
+ /**
980
+ * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
981
+ * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
982
+ */
983
+ frameloop?: Frameloop
984
+ /**
985
+ * R3F performance options for adaptive performance.
986
+ * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
987
+ */
988
+ performance?: Partial<Omit<Performance, 'regress'>>
989
+ /** Target pixel ratio. Can clamp between a range: `[min, max]` */
990
+ dpr?: Dpr
991
+ /** Props that go into the default raycaster */
992
+ raycaster?: Partial<THREE$1.Raycaster>
993
+ /** A `THREE.Scene` instance or props that go into the default scene */
994
+ scene?: THREE$1.Scene | Partial<THREE$1.Scene>
995
+ /** A `THREE.Camera` instance or props that go into the default camera */
996
+ camera?: CameraProps
997
+ /** An R3F event manager to manage elements' pointer events */
998
+ events?: (store: RootStore) => EventManager<HTMLElement>
999
+ /** Callback after the canvas has rendered (but not yet committed) */
1000
+ onCreated?: (state: RootState) => void
1001
+ /** Response for pointer clicks that have missed any target */
1002
+ onPointerMissed?: (event: MouseEvent) => void
1003
+ /** Response for dragover events that have missed any target */
1004
+ onDragOverMissed?: (event: DragEvent) => void
1005
+ /** Response for drop events that have missed any target */
1006
+ onDropMissed?: (event: DragEvent) => void
1007
+ /** Whether to automatically update the frustum each frame (default: true) */
1008
+ autoUpdateFrustum?: boolean
1009
+ /**
1010
+ * Enable WebGPU occlusion queries for onOccluded/onVisible events.
1011
+ * Auto-enabled when any object uses onOccluded or onVisible handlers.
1012
+ * Only works with WebGPU renderer - WebGL will log a warning.
1013
+ */
1014
+ occlusion?: boolean
1015
+ /** Internal: stored size props from Canvas for reset functionality */
1016
+ _sizeProps?: { width?: number; height?: number } | null
1017
+ /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
1018
+ forceEven?: boolean
1019
+ }
1020
+
1021
+ //* Reconciler Root ==============================
1022
+
1023
+ interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
1024
+ configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
1025
+ render: (element: ReactNode) => RootStore
1026
+ unmount: () => void
1027
+ }
1028
+
1029
+ //* Inject State ==============================
1030
+
1031
+ type InjectState = Partial<
1032
+ Omit<RootState, 'events'> & {
1033
+ events?: {
1034
+ enabled?: boolean
1035
+ priority?: number
1036
+ compute?: ComputeFunction
1037
+ connected?: any
1038
+ }
1039
+ /**
1040
+ * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
1041
+ * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
1042
+ * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
1043
+ */
1044
+ injectScene?: boolean
1045
+ }
813
1046
  >
814
1047
 
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
-
1048
+ //* Reconciler Types ==============================
1049
+
1050
+ // FiberRoot is an opaque internal React type - we define it locally
1051
+ // to avoid bundling @types/react-reconciler which causes absolute path issues
1052
+ type FiberRoot = any
1053
+
1054
+ interface Root {
1055
+ fiber: FiberRoot
1056
+ store: RootStore
1057
+ }
1058
+
1059
+ type AttachFnType<O = any> = (parent: any, self: O) => () => void
1060
+ type AttachType<O = any> = string | AttachFnType<O>
1061
+
1062
+ type ConstructorRepresentation<T = any> = new (...args: any[]) => T
1063
+
1064
+ interface Catalogue {
1065
+ [name: string]: ConstructorRepresentation
1066
+ }
1067
+
1068
+ // TODO: handle constructor overloads
1069
+ // https://github.com/pmndrs/react-three-fiber/pull/2931
1070
+ // https://github.com/microsoft/TypeScript/issues/37079
1071
+ type Args<T> = T extends ConstructorRepresentation
1072
+ ? T extends typeof Color$1
1073
+ ? [r: number, g: number, b: number] | [color: ColorRepresentation]
1074
+ : ConstructorParameters<T>
1075
+ : any[]
1076
+
1077
+ type ArgsProp<P> = P extends ConstructorRepresentation
1078
+ ? IsAllOptional<ConstructorParameters<P>> extends true
1079
+ ? { args?: Args<P> }
1080
+ : { args: Args<P> }
1081
+ : { args: unknown[] }
1082
+
1083
+ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
1084
+ object?: T
1085
+ dispose?: null
1086
+ attach?: AttachType<T>
1087
+ onUpdate?: (self: T) => void
1088
+ }
1089
+
1090
+ interface Instance<O = any> {
1091
+ root: RootStore
1092
+ type: string
1093
+ parent: Instance | null
1094
+ children: Instance[]
1095
+ props: InstanceProps<O> & Record<string, unknown>
1096
+ object: O & { __r3f?: Instance<O> }
1097
+ eventCount: number
1098
+ handlers: Partial<EventHandlers>
1099
+ attach?: AttachType<O>
1100
+ previousAttach?: any
1101
+ isHidden: boolean
1102
+ /** Deferred ref props to apply in commitMount */
1103
+ deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
1104
+ /** Set of props that have been applied via once() */
1105
+ appliedOnce?: Set<string>
1106
+ }
1107
+
1108
+ interface HostConfig {
1109
+ type: string
1110
+ props: Instance['props']
1111
+ container: RootStore
1112
+ instance: Instance
1113
+ textInstance: void
1114
+ suspenseInstance: Instance
1115
+ hydratableInstance: never
1116
+ formInstance: never
1117
+ publicInstance: Instance['object']
1118
+ hostContext: {}
1119
+ childSet: never
1120
+ timeoutHandle: number | undefined
1121
+ noTimeout: -1
1122
+ TransitionStatus: null
1123
+ }
1124
+ declare global {
1125
+ var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
1126
+ }
1127
+
1128
+ //* Loop Types ==============================
1129
+
1130
+ type GlobalRenderCallback = (timestamp: number) => void
1131
+
891
1132
  type GlobalEffectType = 'before' | 'after' | 'tail'
892
1133
 
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>,
1134
+ declare const presetsObj: {
1135
+ apartment: string;
1136
+ city: string;
1137
+ dawn: string;
1138
+ forest: string;
1139
+ lobby: string;
1140
+ night: string;
1141
+ park: string;
1142
+ studio: string;
1143
+ sunset: string;
1144
+ warehouse: string;
1145
+ };
1146
+ type PresetsType = keyof typeof presetsObj;
1147
+
1148
+ //* Background Types ==============================
1149
+
1150
+ /**
1151
+ * Expanded object form for background configuration.
1152
+ * Allows separate textures for background (visual backdrop) and environment (PBR lighting).
1153
+ */
1154
+ interface BackgroundConfig {
1155
+ /** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
1156
+ preset?: PresetsType
1157
+ /** Files for cube texture (6 faces) or single HDR/EXR */
1158
+ files?: string | string[]
1159
+ /** Separate files for scene.background (visual backdrop) */
1160
+ backgroundMap?: string | string[]
1161
+ backgroundRotation?: Euler$1 | [number, number, number]
1162
+ backgroundBlurriness?: number
1163
+ backgroundIntensity?: number
1164
+ /** Separate files for scene.environment (PBR lighting/reflections) */
1165
+ envMap?: string | string[]
1166
+ environmentRotation?: Euler$1 | [number, number, number]
1167
+ environmentIntensity?: number
1168
+ path?: string
1169
+ extensions?: (loader: Loader) => void
1170
+ }
1171
+
1172
+ /**
1173
+ * Background prop type for Canvas.
1174
+ *
1175
+ * String detection priority:
1176
+ * 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
1177
+ * 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
1178
+ * 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
1179
+ *
1180
+ * @example Color
1181
+ * ```tsx
1182
+ * <Canvas background="red" />
1183
+ * <Canvas background="#ff0000" />
1184
+ * <Canvas background={0xff0000} />
1185
+ * ```
1186
+ *
1187
+ * @example Preset
1188
+ * ```tsx
1189
+ * <Canvas background="city" />
1190
+ * ```
1191
+ *
1192
+ * @example URL
1193
+ * ```tsx
1194
+ * <Canvas background="/path/to/env.hdr" />
1195
+ * <Canvas background="./sky.jpg" />
1196
+ * ```
1197
+ *
1198
+ * @example Object form
1199
+ * ```tsx
1200
+ * <Canvas background={{
1201
+ * files: ['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'],
1202
+ * backgroundMap: 'path/to/sky.jpg',
1203
+ * envMap: 'path/to/lighting.hdr',
1204
+ * backgroundBlurriness: 0.5,
1205
+ * }} />
1206
+ * ```
1207
+ */
1208
+ type BackgroundProp =
1209
+ | ColorRepresentation // "red", "#ff0000", 0xff0000
1210
+ | string // URL or preset
1211
+ | BackgroundConfig // Expanded object form
1212
+
1213
+ //* Canvas Types ==============================
1214
+
1215
+ interface CanvasProps
1216
+ extends
1217
+ Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
1218
+ React$1.HTMLAttributes<HTMLDivElement> {
1219
+ children?: React$1.ReactNode
1220
+ ref?: React$1.Ref<HTMLCanvasElement>
1221
+ /** Canvas fallback content, similar to img's alt prop */
1222
+ fallback?: React$1.ReactNode
1223
+ /**
1224
+ * Options to pass to useMeasure.
1225
+ * @see https://github.com/pmndrs/react-use-measure#api
1226
+ */
1227
+ resize?: Options
1228
+ /** The target where events are being subscribed to, default: the div that wraps canvas */
1229
+ eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
1230
+ /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1231
+ eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1232
+ /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
1233
+ hmr?: boolean
1234
+ /** Canvas resolution width in pixels. If omitted, uses container width. */
1235
+ width?: number
1236
+ /** Canvas resolution height in pixels. If omitted, uses container height. */
1237
+ height?: number
1238
+ /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
1239
+ forceEven?: boolean
1240
+ /**
1241
+ * Scene background configuration.
1242
+ * Accepts colors, URLs, presets, or an expanded object for separate background/environment.
1243
+ * @see BackgroundProp for full documentation and examples
1244
+ */
1245
+ background?: BackgroundProp
1246
+ }
1247
+
1248
+ //* Loader Types ==============================
1249
+
1250
+ type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
1251
+
1252
+ // Define a loader-like interface that matches THREE.Loader's load signature
1253
+ // This works for both generic and non-generic THREE.Loader instances
1254
+ interface LoaderLike {
1255
+ load(
1256
+ url: InputLike,
1257
+ onLoad?: (result: any) => void,
1258
+ onProgress?: (event: ProgressEvent<EventTarget>) => void,
1259
+ onError?: (error: unknown) => void,
1260
+ ): any
1261
+ }
1262
+
1263
+ type GLTFLike = { scene: THREE$1.Object3D }
1264
+
1265
+ type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1266
+ T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
1267
+
1268
+ // Infer result type from the load method's callback parameter
1269
+ type InferLoadResult<T> = T extends {
1270
+ load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1271
+ }
1272
+ ? R
1273
+ : T extends ConstructorRepresentation<any>
1274
+ ? InstanceType<T> extends {
1275
+ load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
1276
+ }
1277
+ ? R
1278
+ : any
1279
+ : any
1280
+
1281
+ type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
1282
+ InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
1283
+
1284
+ type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
1285
+ loader: LoaderInstance<T>,
956
1286
  ) => void
957
1287
 
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>
1288
+ //* Renderer Props ========================================
1289
+
1290
+ type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
1291
+
1292
+ type WebGLProps =
1293
+ | RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
1294
+ | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
1295
+
1296
+ interface WebGLShadowConfig {
1297
+ shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
1298
+ }
1299
+
1300
+ //* Legacy-specific Types ========================================
1301
+
1302
+ /** Legacy (WebGL) renderer type - re-exported as R3FRenderer from @react-three/fiber/legacy */
1303
+ type LegacyRenderer = THREE$1.WebGLRenderer
1304
+
1305
+ /** Legacy internal state with narrowed renderer type */
1306
+ interface LegacyInternalState extends Omit<InternalState, 'actualRenderer'> {
1307
+ actualRenderer: THREE$1.WebGLRenderer
1308
+ }
1309
+
1310
+ /**
1311
+ * Legacy-specific RootState with narrowed renderer type.
1312
+ * Automatically used when importing from `@react-three/fiber/legacy`.
1313
+ *
1314
+ * @example
1315
+ * ```tsx
1316
+ * import { useThree } from '@react-three/fiber/legacy'
1317
+ *
1318
+ * function MyComponent() {
1319
+ * const { renderer } = useThree()
1320
+ * // renderer is typed as THREE.WebGLRenderer
1321
+ * renderer.shadowMap.enabled = true
1322
+ * }
1323
+ * ```
1324
+ */
1325
+ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1326
+ /** The WebGL renderer instance */
1327
+ renderer: THREE$1.WebGLRenderer
1328
+ /** Internals with WebGL renderer */
1329
+ internal: LegacyInternalState
966
1330
  }
967
1331
 
968
- //* RenderTarget Types ==============================
969
-
970
-
1332
+ //* RenderTarget Types ==============================
1333
+
1334
+
971
1335
  type RenderTargetOptions = RenderTargetOptions$1
972
1336
 
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
- }
1337
+ //* Global Types ==============================
1338
+
1339
+ declare global {
1340
+ /** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
1341
+ interface UniformNode<T = unknown> extends Node {
1342
+ value: T
1343
+ }
1344
+
1345
+ /**
1346
+ * ShaderCallable - the return type of Fn()
1347
+ * A callable shader function node that can be invoked with parameters.
1348
+ * The function returns a ShaderNodeObject when called.
1349
+ *
1350
+ * @example
1351
+ * ```tsx
1352
+ * // Define a shader function
1353
+ * const blendColorFn = Fn(([color1, color2, factor]) => {
1354
+ * return mix(color1, color2, factor)
1355
+ * })
1356
+ *
1357
+ * // Type when retrieving from nodes store
1358
+ * const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
1359
+ *
1360
+ * // Or with specific return type
1361
+ * const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
1362
+ * ```
1363
+ */
1364
+ type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1365
+
1366
+ /**
1367
+ * ShaderNodeRef - a ShaderNodeObject wrapper around a Node
1368
+ * This is the common return type for TSL operations (add, mul, sin, etc.)
1369
+ *
1370
+ * @example
1371
+ * ```tsx
1372
+ * const { wobble } = nodes as { wobble: ShaderNodeRef }
1373
+ * ```
1374
+ */
1375
+ type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
1376
+
1377
+ /**
1378
+ * TSLNodeType - Union of all common TSL node types
1379
+ * Used by ScopedStore to properly type node access from the store.
1380
+ *
1381
+ * Includes:
1382
+ * - Node: base Three.js node type
1383
+ * - ShaderCallable: function nodes created with Fn()
1384
+ * - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
1385
+ *
1386
+ * @example
1387
+ * ```tsx
1388
+ * // In useLocalNodes, nodes are typed as TSLNodeType
1389
+ * const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
1390
+ * positionNode: nodes.myPosition, // Works - Node is in union
1391
+ * blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
1392
+ * }))
1393
+ *
1394
+ * // Can narrow with type guard or assertion when needed
1395
+ * if (typeof blendColorFn === 'function') {
1396
+ * blendColorFn(someColor, 0.5)
1397
+ * }
1398
+ * ```
1399
+ */
1400
+ type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1401
+
1402
+ /** Flat record of uniform nodes (no nested scopes) */
1403
+ type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
1404
+
1405
+ /**
1406
+ * Uniform store that can contain both root-level uniforms and scoped uniform objects
1407
+ * Used by state.uniforms which has structure like:
1408
+ * { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
1409
+ */
1410
+ type UniformStore = Record<string, UniformNode | UniformRecord>
1411
+
1412
+ /**
1413
+ * Helper to safely access a uniform node from the store.
1414
+ * Use this when accessing state.uniforms to get proper typing.
1415
+ * @example
1416
+ * const uTime = uniforms.uTime as UniformNode<number>
1417
+ * const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
1418
+ */
1419
+ type GetUniform<T = unknown> = UniformNode<T>
1420
+
1421
+ /**
1422
+ * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1423
+ * Supports:
1424
+ * - Primitives: number, string (color), boolean
1425
+ * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1426
+ * - Plain objects: { x, y, z, w } converted to vectors
1427
+ * - TSL nodes: color(), vec3(), float() for type casting
1428
+ * - UniformNode: existing uniforms (reused as-is)
1429
+ */
1430
+ type UniformValue =
1431
+ | number
1432
+ | string
1433
+ | boolean
1434
+ | three_webgpu.Color
1435
+ | three_webgpu.Vector2
1436
+ | three_webgpu.Vector3
1437
+ | three_webgpu.Vector4
1438
+ | three_webgpu.Matrix3
1439
+ | three_webgpu.Matrix4
1440
+ | three_webgpu.Euler
1441
+ | three_webgpu.Quaternion
1442
+ | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1443
+ | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1444
+ | Node // TSL nodes like color(), vec3(), float() for type casting
1445
+ | UniformNode
1446
+
1447
+ /** Input record for useUniforms - accepts raw values or UniformNodes */
1448
+ type UniformInputRecord = Record<string, UniformValue>
1449
+ }
1450
+
1451
+ //* Module Augmentation ==============================
1452
+
1453
+ declare module 'three/tsl' {
1454
+ /**
1455
+ * Fn with array parameter destructuring
1456
+ * @example Fn(([uv, skew]) => { ... })
1457
+ */
1458
+ export function Fn<R extends Node = Node>(
1459
+ jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1460
+ ): ShaderCallable<R>
1461
+
1462
+ /**
1463
+ * Fn with object parameter destructuring
1464
+ * @example Fn(({ color, intensity }) => { ... })
1465
+ */
1466
+ export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1467
+ jsFunc: (inputs: T) => ShaderNodeObject<R>,
1468
+ ): ShaderCallable<R>
1469
+
1470
+ /**
1471
+ * Fn with array params + layout
1472
+ * @example Fn(([a, b]) => { ... }, { layout: [...] })
1473
+ */
1474
+ export function Fn<R extends Node = Node>(
1475
+ jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1476
+ layout: { layout?: unknown },
1477
+ ): ShaderCallable<R>
1478
+
1479
+ /**
1480
+ * Fn with object params + layout
1481
+ */
1482
+ export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1483
+ jsFunc: (inputs: T) => ShaderNodeObject<R>,
1484
+ layout: { layout?: unknown },
1485
+ ): ShaderCallable<R>
1486
+ }
1487
+
1488
+ /**
1489
+ * RenderPipeline Types for useRenderPipeline hook (WebGPU only)
1490
+ */
1491
+
1492
+
1493
+
1494
+ declare global {
1495
+ /** Pass record - stores TSL pass nodes for render pipeline */
1496
+ type PassRecord = Record<string, any>
1497
+
1498
+ /** Setup callback - runs first to configure MRT, create additional passes */
1499
+ type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
1500
+
1501
+ /** Main callback - runs second to configure outputNode, create effect passes */
1502
+ type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
1503
+
1504
+ /** Return type for useRenderPipeline hook */
1505
+ interface UseRenderPipelineReturn {
1506
+ /** Current passes from state */
1507
+ passes: PassRecord
1508
+ /** RenderPipeline instance (null if not initialized) */
1509
+ renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
1510
+ /** Clear all passes from state */
1511
+ clearPasses: () => void
1512
+ /** Reset RenderPipeline entirely (clears PP + passes) */
1513
+ reset: () => void
1514
+ /** Re-run setup/main callbacks with current closure values */
1515
+ rebuild: () => void
1516
+ /** True when RenderPipeline is configured and ready */
1517
+ isReady: boolean
1518
+ }
1519
+ }
1520
+
1521
+ //* useFrameNext Types ==============================
1522
+
1523
+
1524
+
1525
+ //* Global Type Declarations ==============================
1526
+
1527
+ declare global {
1528
+ // Job --------------------------------
1529
+
1530
+ /**
1531
+ * Internal job representation in the scheduler
1532
+ */
1533
+ interface Job {
1534
+ /** Unique identifier */
1535
+ id: string
1536
+ /** The callback to execute */
1537
+ callback: FrameNextCallback
1538
+ /** Phase this job belongs to */
1539
+ phase: string
1540
+ /** Run before these phases/job ids */
1541
+ before: Set<string>
1542
+ /** Run after these phases/job ids */
1543
+ after: Set<string>
1544
+ /** Priority within phase (higher first) */
1545
+ priority: number
1546
+ /** Insertion order for deterministic tie-breaking */
1547
+ index: number
1548
+ /** Max FPS for this job (undefined = no limit) */
1549
+ fps?: number
1550
+ /** Drop frames when behind (true) or catch up (false) */
1551
+ drop: boolean
1552
+ /** Last run timestamp (ms) */
1553
+ lastRun?: number
1554
+ /** Whether job is enabled */
1555
+ enabled: boolean
1556
+ /** Internal flag: system jobs (like default render) don't block user render takeover */
1557
+ system?: boolean
1558
+ }
1559
+
1560
+ // Phase Graph --------------------------------
1561
+
1562
+ /**
1563
+ * A node in the phase graph
1564
+ */
1565
+ interface PhaseNode {
1566
+ /** Phase name */
1567
+ name: string
1568
+ /** Whether this was auto-generated from a before/after constraint */
1569
+ isAutoGenerated: boolean
1570
+ }
1571
+
1572
+ /**
1573
+ * Options for creating a job from hook options
1574
+ */
1575
+ interface JobOptions {
1576
+ id?: string
1577
+ phase?: string
1578
+ before?: string | string[]
1579
+ after?: string | string[]
1580
+ priority?: number
1581
+ fps?: number
1582
+ drop?: boolean
1583
+ enabled?: boolean
1584
+ }
1585
+
1586
+ // Frame Loop State --------------------------------
1587
+
1588
+ /**
1589
+ * Internal frame loop state
1590
+ */
1591
+ interface FrameLoopState {
1592
+ /** Whether the loop is running */
1593
+ running: boolean
1594
+ /** Current RAF handle */
1595
+ rafHandle: number | null
1596
+ /** Last frame timestamp in ms (null = uninitialized) */
1597
+ lastTime: number | null
1598
+ /** Frame counter */
1599
+ frameCount: number
1600
+ /** Elapsed time since first frame in ms */
1601
+ elapsedTime: number
1602
+ /** createdAt timestamp in ms */
1603
+ createdAt: number
1604
+ }
1605
+
1606
+ // Root Entry --------------------------------
1607
+
1608
+ /**
1609
+ * Internal representation of a registered root (Canvas).
1610
+ * Tracks jobs and manages rebuild state for this root.
1611
+ * @internal
1612
+ */
1613
+ interface RootEntry {
1614
+ /** Unique identifier for this root */
1615
+ id: string
1616
+ /** Function to get the root's current state. Returns any to support independent mode. */
1617
+ getState: () => any
1618
+ /** Map of job IDs to Job objects */
1619
+ jobs: Map<string, Job>
1620
+ /** Cached sorted job list for execution order */
1621
+ sortedJobs: Job[]
1622
+ /** Whether sortedJobs needs rebuilding */
1623
+ needsRebuild: boolean
1624
+ }
1625
+
1626
+ /**
1627
+ * Internal representation of a global job (deprecated API).
1628
+ * Global jobs run once per frame, not per-root.
1629
+ * Used by legacy addEffect/addAfterEffect APIs.
1630
+ * @internal
1631
+ * @deprecated Use useFrame with phases instead
1632
+ */
1633
+ interface GlobalJob {
1634
+ /** Unique identifier for this global job */
1635
+ id: string
1636
+ /** Callback invoked with RAF timestamp in ms */
1637
+ callback: (timestamp: number) => void
1638
+ }
1639
+
1640
+ // HMR Support --------------------------------
1641
+
1642
+ /**
1643
+ * Hot Module Replacement data structure for preserving scheduler state
1644
+ * @internal
1645
+ */
1646
+ interface HMRData {
1647
+ /** Shared data object for storing values across reloads */
1648
+ data: Record<string, any>
1649
+ /** Optional function to accept HMR updates */
1650
+ accept?: () => void
1651
+ }
1652
+
1653
+ // Default Phases --------------------------------
1654
+
1655
+ /**
1656
+ * Default phase names for the scheduler
1657
+ */
1658
+ type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
1659
+ }
1660
+
1661
+ type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
1662
+
1663
+ interface MathRepresentation {
1664
+ set(...args: number[]): any
1665
+ }
1666
+ interface VectorRepresentation extends MathRepresentation {
1667
+ setScalar(value: number): any
1668
+ }
1669
+ type MathTypes = MathRepresentation | Euler$2 | Color$2
1670
+
1671
+ type MathType<T extends MathTypes> = T extends Color$2
1672
+ ? Args<typeof Color$2> | ColorRepresentation$1
1673
+ : T extends VectorRepresentation | Layers$1 | Euler$2
1674
+ ? T | MutableOrReadonlyParameters<T['set']> | number
1675
+ : T | MutableOrReadonlyParameters<T['set']>
1676
+
1677
+ type MathProps<P> = {
1678
+ [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
1679
+ }
1680
+
1681
+ type Vector2 = MathType<Vector2$1>
1682
+ type Vector3 = MathType<Vector3$1>
1683
+ type Vector4 = MathType<Vector4$1>
1684
+ type Color = MathType<Color$2>
1685
+ type Layers = MathType<Layers$1>
1686
+ type Quaternion = MathType<Quaternion$1>
1687
+ type Euler = MathType<Euler$2>
1688
+ type Matrix3 = MathType<Matrix3$1>
1689
+ type Matrix4 = MathType<Matrix4$1>
1690
+
1691
+ interface RaycastableRepresentation {
1692
+ raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
1693
+ }
1694
+ type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
1695
+
1696
+ /**
1697
+ * Props for geometry transform methods that can be called with `once()`.
1698
+ * These methods modify the geometry in-place and only make sense to call once on mount.
1699
+ *
1700
+ * @example
1701
+ * import { once } from '@react-three/fiber'
1702
+ *
1703
+ * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
1704
+ * <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
1705
+ * <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
1706
+ */
1707
+ interface GeometryTransformProps {
1708
+ /** Rotate the geometry about the X axis (radians). Use with once(). */
1709
+ rotateX?: number
1710
+ /** Rotate the geometry about the Y axis (radians). Use with once(). */
1711
+ rotateY?: number
1712
+ /** Rotate the geometry about the Z axis (radians). Use with once(). */
1713
+ rotateZ?: number
1714
+ /** Translate the geometry (x, y, z). Use with once(). */
1715
+ translate?: [x: number, y: number, z: number]
1716
+ /** Scale the geometry (x, y, z). Use with once(). */
1717
+ scale?: [x: number, y: number, z: number]
1718
+ /** Center the geometry based on bounding box. Use with once(). */
1719
+ center?: true
1720
+ /** Apply a Matrix4 transformation. Use with once(). */
1721
+ applyMatrix4?: Matrix4$1
1722
+ /** Apply a Quaternion rotation. Use with once(). */
1723
+ applyQuaternion?: Quaternion$1
1724
+ }
1725
+
1726
+ type GeometryProps<P> = P extends BufferGeometry ? GeometryTransformProps : {}
1727
+
1728
+ /**
1729
+ * Workaround for @types/three TSL node type issues.
1730
+ * The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
1731
+ * This transforms `Node | null` properties to accept any object with node-like shape.
1732
+ */
1733
+ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1734
+
1735
+ /**
1736
+ * For node material properties (colorNode, positionNode, etc.), accept broader types
1737
+ * since @types/three has broken inheritance for TSL node subclasses.
1738
+ */
1739
+ type NodeProps<P> = {
1740
+ [K in keyof P as P[K] extends Node | null ? K : never]?: TSLNodeInput
1741
+ }
1742
+
1743
+ interface ReactProps<P> {
1744
+ children?: React.ReactNode
1745
+ ref?: React.Ref<P>
1746
+ key?: React.Key
1747
+ }
1748
+
1749
+ type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
1750
+ Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
1751
+ >
1752
+
1753
+ type ThreeElement<T extends ConstructorRepresentation> = Mutable<
1754
+ Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
1755
+ >
1756
+
1757
+ type ThreeToJSXElements<T extends Record<string, any>> = {
1758
+ [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1759
+ }
1760
+
1761
+ type ThreeExports = typeof THREE
1762
+ type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1763
+
1764
+ interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1765
+ primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1766
+ // Conflicts with DOM types can be accessed through a three* prefix
1767
+ threeAudio: ThreeElementsImpl['audio']
1768
+ threeSource: ThreeElementsImpl['source']
1769
+ threeLine: ThreeElementsImpl['line']
1770
+ threePath: ThreeElementsImpl['path']
1771
+ }
1772
+
1773
+ declare module 'react' {
1774
+ namespace JSX {
1775
+ interface IntrinsicElements extends ThreeElements {}
1776
+ }
1777
+ }
1778
+
1779
+ declare module 'react/jsx-runtime' {
1780
+ namespace JSX {
1781
+ interface IntrinsicElements extends ThreeElements {}
1782
+ }
1783
+ }
1784
+
1785
+ declare module 'react/jsx-dev-runtime' {
1786
+ namespace JSX {
1787
+ interface IntrinsicElements extends ThreeElements {}
1788
+ }
1319
1789
  }
1320
1790
 
1321
1791
  type three_d_Color = Color;
1322
1792
  type three_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
1323
1793
  type three_d_Euler = Euler;
1324
1794
  type three_d_EventProps<P> = EventProps<P>;
1795
+ type three_d_GeometryProps<P> = GeometryProps<P>;
1796
+ type three_d_GeometryTransformProps = GeometryTransformProps;
1325
1797
  type three_d_Layers = Layers;
1326
1798
  type three_d_MathProps<P> = MathProps<P>;
1327
1799
  type three_d_MathRepresentation = MathRepresentation;
@@ -1330,9 +1802,11 @@ type three_d_MathTypes = MathTypes;
1330
1802
  type three_d_Matrix3 = Matrix3;
1331
1803
  type three_d_Matrix4 = Matrix4;
1332
1804
  type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1805
+ type three_d_NodeProps<P> = NodeProps<P>;
1333
1806
  type three_d_Quaternion = Quaternion;
1334
1807
  type three_d_RaycastableRepresentation = RaycastableRepresentation;
1335
1808
  type three_d_ReactProps<P> = ReactProps<P>;
1809
+ type three_d_TSLNodeInput = TSLNodeInput;
1336
1810
  type three_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
1337
1811
  type three_d_ThreeElements = ThreeElements;
1338
1812
  type three_d_ThreeElementsImpl = ThreeElementsImpl;
@@ -1343,12 +1817,324 @@ type three_d_Vector3 = Vector3;
1343
1817
  type three_d_Vector4 = Vector4;
1344
1818
  type three_d_VectorRepresentation = VectorRepresentation;
1345
1819
  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 };
1820
+ 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 };
1821
+ }
1822
+
1823
+ /**
1824
+ * @fileoverview Registry for primary canvases that can be targeted by secondary canvases
1825
+ *
1826
+ * Enables multi-canvas WebGPU rendering where multiple Canvas components share
1827
+ * a single WebGPURenderer using Three.js CanvasTarget API.
1828
+ *
1829
+ * Primary canvas: Has `id` prop, creates its own renderer, registers here
1830
+ * Secondary canvas: Has `target="id"` prop, shares primary's renderer via CanvasTarget
1831
+ */
1832
+
1833
+ interface PrimaryCanvasEntry {
1834
+ /** The WebGPURenderer instance owned by this primary canvas */
1835
+ renderer: WebGPURenderer;
1836
+ /** The zustand store for this canvas */
1837
+ store: RootStore;
1838
+ }
1839
+ /**
1840
+ * Register a primary canvas that can be targeted by secondary canvases.
1841
+ *
1842
+ * @param id - Unique identifier for this primary canvas
1843
+ * @param renderer - The WebGPURenderer owned by this canvas
1844
+ * @param store - The zustand store for this canvas
1845
+ * @returns Cleanup function to unregister on unmount
1846
+ */
1847
+ declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
1848
+ /**
1849
+ * Get a registered primary canvas by id.
1850
+ *
1851
+ * @param id - The id of the primary canvas to look up
1852
+ * @returns The primary canvas entry or undefined if not found
1853
+ */
1854
+ declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
1855
+ /**
1856
+ * Wait for a primary canvas to be registered.
1857
+ * Returns immediately if already registered, otherwise waits.
1858
+ *
1859
+ * @param id - The id of the primary canvas to wait for
1860
+ * @param timeout - Optional timeout in ms (default: 5000)
1861
+ * @returns Promise that resolves with the primary canvas entry
1862
+ */
1863
+ declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
1864
+ /**
1865
+ * Check if a primary canvas with the given id exists.
1866
+ *
1867
+ * @param id - The id to check
1868
+ * @returns True if a primary canvas with this id is registered
1869
+ */
1870
+ declare function hasPrimary(id: string): boolean;
1871
+ /**
1872
+ * Unregister a primary canvas. Called on unmount.
1873
+ *
1874
+ * @param id - The id of the primary canvas to unregister
1875
+ */
1876
+ declare function unregisterPrimary(id: string): void;
1877
+ /**
1878
+ * Get all registered primary canvas ids. Useful for debugging.
1879
+ */
1880
+ declare function getPrimaryIds(): string[];
1881
+
1882
+ type EnvironmentLoaderProps = {
1883
+ files?: string | string[];
1884
+ path?: string;
1885
+ preset?: PresetsType;
1886
+ extensions?: (loader: Loader$1) => void;
1887
+ colorSpace?: ColorSpace;
1888
+ };
1889
+ /**
1890
+ * Loads environment textures for reflections and lighting.
1891
+ * Supports HDR files, presets, and cubemaps.
1892
+ *
1893
+ * @example Basic usage
1894
+ * ```jsx
1895
+ * const texture = useEnvironment({ preset: 'sunset' })
1896
+ * ```
1897
+ */
1898
+ declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture;
1899
+ declare namespace useEnvironment {
1900
+ var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
1901
+ var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
1902
+ }
1903
+ type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'encoding'>;
1904
+ type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
1905
+
1906
+ /**
1907
+ * Props for Environment component that sets up global cubemap for PBR materials and backgrounds.
1908
+ *
1909
+ * @property children - React children to render into custom environment portal
1910
+ * @property frames - Number of frames to render the environment. Use 1 for static, Infinity for animated (default: 1)
1911
+ * @property near - Near clipping plane for cube camera (default: 0.1)
1912
+ * @property far - Far clipping plane for cube camera (default: 1000)
1913
+ * @property resolution - Resolution of the cube render target (default: 256)
1914
+ * @property background - Whether to set scene.background. Can be true, false, or "only" (which only sets background) (default: false)
1915
+ *
1916
+ * @property blur - @deprecated Use backgroundBlurriness instead
1917
+ * @property backgroundBlurriness - Blur factor between 0 and 1 for background (default: 0, requires three.js 0.146+)
1918
+ * @property backgroundIntensity - Intensity factor for background (default: 1, requires three.js 0.163+)
1919
+ * @property backgroundRotation - Rotation for background as Euler angles (default: [0,0,0], requires three.js 0.163+)
1920
+ * @property environmentIntensity - Intensity factor for environment lighting (default: 1, requires three.js 0.163+)
1921
+ * @property environmentRotation - Rotation for environment as Euler angles (default: [0,0,0], requires three.js 0.163+)
1922
+ *
1923
+ * @property map - Pre-existing texture to use as environment map
1924
+ * @property preset - HDRI Haven preset: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse'. Not for production use.
1925
+ * @property scene - Custom THREE.Scene or ref to apply environment to (default: uses default scene)
1926
+ * @property ground - Ground projection settings. Use true for defaults or object with:
1927
+ * - height: Height of camera used to create env map (default: 15)
1928
+ * - radius: Radius of the world (default: 60)
1929
+ * - scale: Scale of backside projected sphere (default: 1000)
1930
+ *
1931
+ * Additional loader props:
1932
+ * @property files - File path(s) for environment. Supports .hdr, .exr, gainmap .jpg/.webp, or array of 6 cube faces
1933
+ * @property path - Base path for file loading
1934
+ * @property extensions - Texture extensions override
1935
+ */
1936
+ type EnvironmentProps = {
1937
+ children?: React$1.ReactNode;
1938
+ frames?: number;
1939
+ near?: number;
1940
+ far?: number;
1941
+ resolution?: number;
1942
+ background?: boolean | 'only';
1943
+ /** deprecated, use backgroundBlurriness */
1944
+ blur?: number;
1945
+ backgroundBlurriness?: number;
1946
+ backgroundIntensity?: number;
1947
+ backgroundRotation?: Euler$3;
1948
+ environmentIntensity?: number;
1949
+ environmentRotation?: Euler$3;
1950
+ map?: Texture$1;
1951
+ preset?: PresetsType;
1952
+ scene?: Scene | React$1.RefObject<Scene>;
1953
+ ground?: boolean | {
1954
+ radius?: number;
1955
+ height?: number;
1956
+ scale?: number;
1957
+ };
1958
+ /** Solid color for background (alternative to files/preset) */
1959
+ color?: ColorRepresentation$1;
1960
+ /** Separate files for background (when different from environment files) */
1961
+ backgroundFiles?: string | string[];
1962
+ } & EnvironmentLoaderProps;
1963
+ /**
1964
+ * Internal component that applies a pre-existing texture as environment map.
1965
+ * Sets scene.environment and optionally scene.background.
1966
+ *
1967
+ * @example
1968
+ * ```jsx
1969
+ * <CubeCamera>{(texture) => <EnvironmentMap map={texture} />}</CubeCamera>
1970
+ * ```
1971
+ */
1972
+ declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
1973
+ /**
1974
+ * Internal component that loads environment textures from files or presets.
1975
+ * Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg HDR,
1976
+ * GainMapLoader for gainmap .webp, or CubeTextureLoader for arrays of images.
1977
+ *
1978
+ * @example With preset
1979
+ * ```jsx
1980
+ * <EnvironmentCube preset="sunset" />
1981
+ * ```
1982
+ *
1983
+ * @example From HDR file
1984
+ * ```jsx
1985
+ * <EnvironmentCube files="environment.hdr" />
1986
+ * ```
1987
+ *
1988
+ * @example From gainmap (smallest footprint)
1989
+ * ```jsx
1990
+ * <EnvironmentCube files={['file.webp', 'file-gainmap.webp', 'file.json']} />
1991
+ * ```
1992
+ *
1993
+ * @example From cube faces
1994
+ * ```jsx
1995
+ * <EnvironmentCube files={['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']} />
1996
+ * ```
1997
+ */
1998
+ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, ...rest }: EnvironmentProps): null;
1999
+ /**
2000
+ * Internal component that renders custom environment using a portal and cube camera.
2001
+ * Renders children into an off-buffer and films with a cube camera to create environment map.
2002
+ * Can be static (frames=1) or animated (frames=Infinity).
2003
+ *
2004
+ * @example Custom environment with sphere
2005
+ * ```jsx
2006
+ * <EnvironmentPortal background near={1} far={1000} resolution={256}>
2007
+ * <mesh scale={100}>
2008
+ * <sphereGeometry args={[1, 64, 64]} />
2009
+ * <meshBasicMaterial map={texture} side={THREE.BackSide} />
2010
+ * </mesh>
2011
+ * </EnvironmentPortal>
2012
+ * ```
2013
+ *
2014
+ * @example Animated environment
2015
+ * ```jsx
2016
+ * <EnvironmentPortal frames={Infinity} resolution={256}>
2017
+ * <Float>
2018
+ * <mesh />
2019
+ * </Float>
2020
+ * </EnvironmentPortal>
2021
+ * ```
2022
+ *
2023
+ * @example Mixed with preset
2024
+ * ```jsx
2025
+ * <EnvironmentPortal preset="warehouse">
2026
+ * <mesh />
2027
+ * </EnvironmentPortal>
2028
+ * ```
2029
+ */
2030
+ 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;
2031
+ declare module '@react-three/fiber' {
2032
+ interface ThreeElements {
2033
+ groundProjectedEnvImpl: ThreeElement$1<typeof GroundedSkybox>;
2034
+ }
1347
2035
  }
2036
+ /**
2037
+ * Sets up a global environment map for PBR materials and backgrounds.
2038
+ * Affects scene.environment and optionally scene.background unless a custom scene is passed.
2039
+ *
2040
+ * Supports multiple input methods:
2041
+ * - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
2042
+ * - **Files**: HDR (.hdr), EXR (.exr), gainmap JPEG (.jpg), gainmap WebP (.webp), or cube faces (array of 6 images)
2043
+ * - **Texture**: Pre-existing cube texture via `map` prop
2044
+ * - **Custom Scene**: Render children into environment using portal and cube camera
2045
+ * - **Ground Projection**: Project environment onto ground plane
2046
+ *
2047
+ * @remarks
2048
+ * - Preset property is NOT meant for production and may fail (relies on CDNs)
2049
+ * - Gainmap format has the smallest file footprint
2050
+ * - Use `frames={Infinity}` for animated environments with low resolution for performance
2051
+ * - Ground projection places models on the "ground" within the environment map
2052
+ * - Supports self-hosting with @pmndrs/assets using dynamic imports
2053
+ *
2054
+ * @example Basic preset usage
2055
+ * ```jsx
2056
+ * <Environment preset="sunset" />
2057
+ * ```
2058
+ *
2059
+ * @example From HDR file
2060
+ * ```jsx
2061
+ * <Environment files="/hdr/environment.hdr" />
2062
+ * ```
2063
+ *
2064
+ * @example From gainmap (smallest footprint)
2065
+ * ```jsx
2066
+ * <Environment files={['file.webp', 'file-gainmap.webp', 'file.json']} />
2067
+ * ```
2068
+ *
2069
+ * @example With self-hosted assets
2070
+ * ```jsx
2071
+ * import { suspend } from 'suspend-react'
2072
+ * const city = import('@pmndrs/assets/hdri/city.exr').then(m => m.default)
2073
+ *
2074
+ * <Environment files={suspend(city)} />
2075
+ * ```
2076
+ *
2077
+ * @example From existing texture
2078
+ * ```jsx
2079
+ * <CubeCamera>{(texture) => <Environment map={texture} />}</CubeCamera>
2080
+ * ```
2081
+ *
2082
+ * @example Custom environment scene
2083
+ * ```jsx
2084
+ * <Environment background near={1} far={1000} resolution={256}>
2085
+ * <mesh scale={100}>
2086
+ * <sphereGeometry args={[1, 64, 64]} />
2087
+ * <meshBasicMaterial map={texture} side={THREE.BackSide} />
2088
+ * </mesh>
2089
+ * </Environment>
2090
+ * ```
2091
+ *
2092
+ * @example Animated environment
2093
+ * ```jsx
2094
+ * <Environment frames={Infinity} resolution={256}>
2095
+ * <Float>
2096
+ * <mesh />
2097
+ * </Float>
2098
+ * </Environment>
2099
+ * ```
2100
+ *
2101
+ * @example Mixed custom scene with preset
2102
+ * ```jsx
2103
+ * <Environment background preset="warehouse">
2104
+ * <mesh />
2105
+ * </Environment>
2106
+ * ```
2107
+ *
2108
+ * @example With ground projection
2109
+ * ```jsx
2110
+ * <Environment ground={{ height: 15, radius: 60 }} preset="city" />
2111
+ * ```
2112
+ *
2113
+ * @example As background only
2114
+ * ```jsx
2115
+ * <Environment background="only" preset="sunset" />
2116
+ * ```
2117
+ *
2118
+ * @example With rotation and intensity
2119
+ * ```jsx
2120
+ * <Environment
2121
+ * background
2122
+ * backgroundBlurriness={0.5}
2123
+ * backgroundIntensity={0.8}
2124
+ * backgroundRotation={[0, Math.PI / 2, 0]}
2125
+ * environmentIntensity={1.2}
2126
+ * environmentRotation={[0, Math.PI / 4, 0]}
2127
+ * preset="studio"
2128
+ * />
2129
+ * ```
2130
+ */
2131
+ declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
1348
2132
 
1349
2133
  declare function removeInteractivity(store: RootStore, object: Object3D): void;
1350
2134
  declare function createEvents(store: RootStore): {
1351
2135
  handlePointer: (name: string) => (event: DomEvent) => void;
2136
+ flushDeferredPointers: () => void;
2137
+ processDeferredPointer: (event: DomEvent, pointerId: number) => void;
1352
2138
  };
1353
2139
  /** Default R3F event manager for web */
1354
2140
  declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
@@ -1907,31 +2693,30 @@ declare function useTextures(): UseTexturesReturn;
1907
2693
  * - WebGPU build: Returns RenderTarget
1908
2694
  * - Default build: Returns whichever matches the active renderer
1909
2695
  *
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
2696
  * @example
1915
2697
  * ```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
- * }
2698
+ * // Use canvas size
2699
+ * const fbo = useRenderTarget()
2700
+ *
2701
+ * // Use canvas size with options
2702
+ * const fbo = useRenderTarget({ samples: 4 })
2703
+ *
2704
+ * // Square render target
2705
+ * const fbo = useRenderTarget(512)
2706
+ *
2707
+ * // Square render target with options
2708
+ * const fbo = useRenderTarget(512, { depthBuffer: true })
2709
+ *
2710
+ * // Explicit dimensions
2711
+ * const fbo = useRenderTarget(512, 256)
2712
+ *
2713
+ * // Explicit dimensions with options
2714
+ * const fbo = useRenderTarget(512, 256, { samples: 4 })
1932
2715
  * ```
1933
2716
  */
1934
- declare function useRenderTarget(width?: number, height?: number, options?: RenderTargetOptions): RenderTarget<THREE$1.Texture<unknown>>;
2717
+ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
2718
+ declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
2719
+ declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
1935
2720
 
1936
2721
  /**
1937
2722
  * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
@@ -2036,7 +2821,7 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
2036
2821
  *
2037
2822
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2038
2823
  */
2039
- declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame): void;
2824
+ declare function advance(timestamp: number): void;
2040
2825
 
2041
2826
  /* eslint-disable @definitelytyped/no-unnecessary-generics */
2042
2827
  declare function ReactReconciler<
@@ -3090,6 +3875,12 @@ declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
3090
3875
  declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
3091
3876
  declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
3092
3877
  declare function createPortal(children: ReactNode, container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>, state?: InjectState): JSX.Element;
3878
+ interface PortalProps {
3879
+ children: ReactNode;
3880
+ state?: InjectState;
3881
+ container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
3882
+ }
3883
+ declare function Portal({ children, container, state }: PortalProps): JSX.Element;
3093
3884
  /**
3094
3885
  * Force React to flush any updates inside the provided callback synchronously and immediately.
3095
3886
  * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
@@ -3518,22 +4309,152 @@ declare const hasConstructor: (object: unknown) => object is {
3518
4309
  constructor?: Function;
3519
4310
  };
3520
4311
 
4312
+ /**
4313
+ * Symbol marker for deferred ref resolution.
4314
+ * Used to identify values that should be resolved from refs after mount.
4315
+ */
4316
+ declare const FROM_REF: unique symbol;
4317
+ /**
4318
+ * Defers prop application until the referenced object is available.
4319
+ * Useful for props like `target` that need sibling refs to be populated.
4320
+ *
4321
+ * @param ref - React ref object to resolve at mount time
4322
+ * @returns A marker value that applyProps will resolve after mount
4323
+ *
4324
+ * @example
4325
+ * const targetRef = useRef<THREE.Object3D>(null)
4326
+ *
4327
+ * <group ref={targetRef} position={[-3, -2, -15]} />
4328
+ * <spotLight target={fromRef(targetRef)} intensity={100} />
4329
+ */
4330
+ declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
4331
+ /**
4332
+ * Type guard to check if a value is a fromRef marker.
4333
+ *
4334
+ * @param value - Value to check
4335
+ * @returns True if value is a fromRef marker
4336
+ */
4337
+ declare function isFromRef(value: unknown): value is {
4338
+ [FROM_REF]: React$1.RefObject<any>;
4339
+ };
4340
+
4341
+ /**
4342
+ * Symbol marker for mount-only method calls.
4343
+ * Used to identify methods that should only be called once on initial mount.
4344
+ */
4345
+ declare const ONCE: unique symbol;
4346
+ /**
4347
+ * Marks a method call to be executed only on initial mount.
4348
+ * Useful for geometry transforms that should not be reapplied on every render.
4349
+ *
4350
+ * When `args` prop changes (triggering reconstruction), the method will be
4351
+ * called again on the new instance since appliedOnce is not carried over.
4352
+ *
4353
+ * @param args - Arguments to pass to the method
4354
+ * @returns A marker value that applyProps will execute once
4355
+ *
4356
+ * @example
4357
+ * // Rotate geometry on mount
4358
+ * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
4359
+ *
4360
+ * // Multiple arguments
4361
+ * <bufferGeometry applyMatrix4={once(matrix)} />
4362
+ *
4363
+ * // No arguments
4364
+ * <geometry center={once()} />
4365
+ */
4366
+ declare function once<T>(...args: T[]): T;
4367
+ /**
4368
+ * Type guard to check if a value is a once marker.
4369
+ *
4370
+ * @param value - Value to check
4371
+ * @returns True if value is a once marker
4372
+ */
4373
+ declare function isOnce(value: unknown): value is {
4374
+ [ONCE]: any[] | true;
4375
+ };
4376
+
3521
4377
  /**
3522
4378
  * A DOM canvas which accepts threejs elements as children.
3523
4379
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
3524
4380
  */
3525
4381
  declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
3526
4382
 
4383
+ /**
4384
+ * ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
4385
+ *
4386
+ * Provides TypeScript-friendly access to uniform/node stores where the runtime
4387
+ * structure is `Record<string, T | Record<string, T>>` (leaf nodes or nested scopes).
4388
+ *
4389
+ * The wrapper uses a Proxy to:
4390
+ * 1. Return `T` for property access (type assumption: assumes leaf node)
4391
+ * 2. Provide `.scope(key)` method for explicit nested access
4392
+ * 3. Support iteration methods: has(), keys(), Object.keys(), for...in
4393
+ *
4394
+ * @example
4395
+ * ```tsx
4396
+ * useLocalNodes(({ uniforms }) => ({
4397
+ * wobble: sin(uniforms.uTime.mul(2)), // No cast needed!
4398
+ * playerHealth: uniforms.scope('player').uHealth // Explicit scope access
4399
+ * }))
4400
+ * ```
4401
+ */
4402
+
4403
+ /** Keys reserved for methods (excluded from index signature) */
4404
+ type MethodKeys = 'scope' | 'has' | 'keys';
4405
+ /**
4406
+ * Type-safe wrapper interface for accessing nested store data.
4407
+ * Property access returns `T` (assumes leaf node).
4408
+ * Use `.scope(key)` for nested object access.
4409
+ *
4410
+ * Uses mapped type with key filtering to exclude method names from index signature,
4411
+ * allowing methods to have their correct return types.
4412
+ */
4413
+ type ScopedStoreType<T> = {
4414
+ /** Direct property access returns the leaf type T (method keys excluded) */
4415
+ readonly [K in string as K extends MethodKeys ? never : K]: T;
4416
+ } & {
4417
+ /** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
4418
+ scope(key: string): ScopedStoreType<T>;
4419
+ /** Check if a key exists in the store */
4420
+ has(key: string): boolean;
4421
+ /** Get all keys in the store */
4422
+ keys(): string[];
4423
+ };
4424
+ /**
4425
+ * Create a type-safe ScopedStore wrapper around store data.
4426
+ * @param data - The raw store data (uniforms or nodes from RootState)
4427
+ * @returns A ScopedStoreType wrapper with type-safe access
4428
+ */
4429
+ declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreType<T>;
4430
+ /**
4431
+ * State type passed to creator functions with ScopedStore wrappers.
4432
+ * Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
4433
+ */
4434
+ type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
4435
+ /** Type-safe uniform access - property access returns UniformNode */
4436
+ uniforms: ScopedStoreType<UniformNode>;
4437
+ /** Type-safe node access - property access returns TSLNodeType (Node | ShaderCallable | ShaderNodeObject) */
4438
+ nodes: ScopedStoreType<TSLNodeType>;
4439
+ /** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
4440
+ buffers: ScopedStoreType<BufferLike>;
4441
+ /** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
4442
+ gpuStorage: ScopedStoreType<StorageLike>;
4443
+ };
4444
+
3527
4445
  /** Creator function that returns uniform inputs (can be raw values or UniformNodes) */
3528
- type UniformCreator<T extends UniformInputRecord = UniformInputRecord> = (state: RootState) => T;
4446
+ type UniformCreator<T extends UniformInputRecord = UniformInputRecord> = (state: CreatorState) => T;
3529
4447
  /** Function signature for removeUniforms util */
3530
4448
  type RemoveUniformsFn = (names: string | string[], scope?: string) => void;
3531
4449
  /** Function signature for clearUniforms util */
3532
4450
  type ClearUniformsFn = (scope?: string) => void;
4451
+ /** Function signature for rebuildUniforms util */
4452
+ type RebuildUniformsFn = (scope?: string) => void;
3533
4453
  /** Return type with utils included */
3534
4454
  type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
3535
4455
  removeUniforms: RemoveUniformsFn;
3536
4456
  clearUniforms: ClearUniformsFn;
4457
+ rebuildUniforms: RebuildUniformsFn;
3537
4458
  };
3538
4459
  declare function useUniforms(): UniformsWithUtils<UniformRecord & Record<string, UniformRecord>>;
3539
4460
  declare function useUniforms(scope: string): UniformsWithUtils;
@@ -3541,6 +4462,15 @@ declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreat
3541
4462
  declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
3542
4463
  declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformRecord<UniformNode>>;
3543
4464
  declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
4465
+ /**
4466
+ * Global rebuildUniforms function for HMR integration.
4467
+ * Clears cached uniforms and increments _hmrVersion to trigger re-creation.
4468
+ * Call this when HMR is detected to refresh all uniform creators.
4469
+ *
4470
+ * @param store - The R3F store (from useStore or context)
4471
+ * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4472
+ */
4473
+ declare function rebuildAllUniforms(store: ReturnType<typeof useStore>, scope?: string): void;
3544
4474
  /**
3545
4475
  * Remove uniforms by name from root level or a scope
3546
4476
  * @deprecated Use `const { removeUniforms } = useUniforms()` instead
@@ -3557,30 +4487,76 @@ declare function clearScope(set: ReturnType<typeof useStore>['setState'], scope:
3557
4487
  */
3558
4488
  declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState']): void;
3559
4489
 
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;
4490
+ /**
4491
+ * Supported uniform value types:
4492
+ * - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
4493
+ * - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
4494
+ * - TSL nodes: color(), vec3(), float(), etc. (for type casting)
4495
+ * - UniformNode: existing uniforms (reused as-is)
4496
+ */
4497
+ type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
4498
+ /**
4499
+ * Widen literal types to their base types:
4500
+ * - 0 → number
4501
+ * - true → boolean
4502
+ * - '#ff0000' → Color (string colors are converted to Color objects)
4503
+ * - Node → Node (TSL nodes passed through for uniform type casting)
4504
+ */
4505
+ type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
3564
4506
  declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
3565
4507
  declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
3566
4508
 
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;
4509
+ /**
4510
+ * Minimal interface for TSL nodes.
4511
+ * Used instead of Three.js's Node type because the @types/three definitions
4512
+ * have inconsistencies where OperatorNode, ConstNode, etc. don't properly
4513
+ * extend Node with all required properties.
4514
+ */
4515
+ interface TSLNodeLike {
4516
+ uuid?: string;
4517
+ nodeType?: string | null;
4518
+ /** label method for chaining - sets the node's label and returns self */
4519
+ label?: ((label: string) => TSLNodeLike) | string;
4520
+ setName?: (name: string) => this;
4521
+ }
4522
+ /** TSL node type - alias for compatibility */
4523
+ type TSLNode = TSLNodeLike;
4524
+ /**
4525
+ * A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
4526
+ * Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
4527
+ */
4528
+ type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
4529
+ /**
4530
+ * Creator function that returns a record of nodes.
4531
+ * Uses TSLNodeLike constraint to allow mixed node types
4532
+ * (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
4533
+ */
4534
+ type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
3571
4535
  /** Function signature for removeNodes util */
3572
4536
  type RemoveNodesFn = (names: string | string[], scope?: string) => void;
3573
4537
  /** Function signature for clearNodes util */
3574
4538
  type ClearNodesFn = (scope?: string) => void;
4539
+ /** Function signature for rebuildNodes util */
4540
+ type RebuildNodesFn = (scope?: string) => void;
3575
4541
  /** Return type with utils included */
3576
- type NodesWithUtils<T extends NodeRecord = NodeRecord> = T & {
4542
+ type NodesWithUtils<T extends Record<string, TSLNodeLike> = Record<string, TSLNodeLike>> = T & {
3577
4543
  removeNodes: RemoveNodesFn;
3578
4544
  clearNodes: ClearNodesFn;
4545
+ rebuildNodes: RebuildNodesFn;
3579
4546
  };
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>;
4547
+ declare function useNodes(): NodesWithUtils<Record<string, TSLNodeLike> & Record<string, Record<string, TSLNodeLike>>>;
4548
+ declare function useNodes(scope: string): NodesWithUtils<Record<string, TSLNodeLike>>;
4549
+ declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>): NodesWithUtils<T>;
4550
+ declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
4551
+ /**
4552
+ * Global rebuildNodes function for HMR integration.
4553
+ * Clears cached nodes and increments _hmrVersion to trigger re-creation.
4554
+ * Call this when HMR is detected to refresh all node creators.
4555
+ *
4556
+ * @param store - The R3F store (from useStore or context)
4557
+ * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4558
+ */
4559
+ declare function rebuildAllNodes(store: ReturnType<typeof useStore>, scope?: string): void;
3584
4560
  /**
3585
4561
  * Remove nodes by name from root level or a scope
3586
4562
  * @deprecated Use `const { removeNodes } = useNodes()` instead
@@ -3597,8 +4573,8 @@ declare function clearNodeScope(set: ReturnType<typeof useStore>['setState'], sc
3597
4573
  */
3598
4574
  declare function clearRootNodes(set: ReturnType<typeof useStore>['setState']): void;
3599
4575
 
3600
- /** Creator receives RootState - destructure what you need. Returns any record. */
3601
- type LocalNodeCreator<T extends Record<string, unknown>> = (state: RootState) => T;
4576
+ /** Creator receives CreatorState with ScopedStore wrappers for type-safe access. Returns any record. */
4577
+ type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState) => T;
3602
4578
  /**
3603
4579
  * Creates local values that rebuild when uniforms, nodes, or textures change.
3604
4580
  *
@@ -3627,6 +4603,74 @@ type LocalNodeCreator<T extends Record<string, unknown>> = (state: RootState) =>
3627
4603
  */
3628
4604
  declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
3629
4605
 
4606
+ /**
4607
+ * Creator function that returns a record of buffers.
4608
+ * Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
4609
+ */
4610
+ type BufferCreator<T extends Record<string, BufferLike>> = (state: CreatorState) => T;
4611
+ /** Function signature for removeBuffers util */
4612
+ type RemoveBuffersFn = (names: string | string[], scope?: string) => void;
4613
+ /** Function signature for clearBuffers util */
4614
+ type ClearBuffersFn = (scope?: string) => void;
4615
+ /** Function signature for rebuildBuffers util */
4616
+ type RebuildBuffersFn = (scope?: string) => void;
4617
+ /** Function signature for disposeBuffers util - releases GPU resources */
4618
+ type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
4619
+ /** Return type with utils included */
4620
+ type BuffersWithUtils<T extends Record<string, BufferLike> = Record<string, BufferLike>> = T & {
4621
+ removeBuffers: RemoveBuffersFn;
4622
+ clearBuffers: ClearBuffersFn;
4623
+ rebuildBuffers: RebuildBuffersFn;
4624
+ disposeBuffers: DisposeBuffersFn;
4625
+ };
4626
+ declare function useBuffers(): BuffersWithUtils<Record<string, BufferLike> & Record<string, Record<string, BufferLike>>>;
4627
+ declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
4628
+ declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
4629
+ declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
4630
+ /**
4631
+ * Global rebuildBuffers function for HMR integration.
4632
+ * Clears cached buffers and increments _hmrVersion to trigger re-creation.
4633
+ * Call this when HMR is detected to refresh all buffer creators.
4634
+ *
4635
+ * @param store - The R3F store (from useStore or context)
4636
+ * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4637
+ */
4638
+ declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
4639
+
4640
+ /**
4641
+ * Creator function that returns a record of GPU storage objects.
4642
+ * Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
4643
+ */
4644
+ type StorageCreator<T extends Record<string, StorageLike>> = (state: CreatorState) => T;
4645
+ /** Function signature for removeStorage util */
4646
+ type RemoveStorageFn = (names: string | string[], scope?: string) => void;
4647
+ /** Function signature for clearStorage util */
4648
+ type ClearStorageFn = (scope?: string) => void;
4649
+ /** Function signature for rebuildStorage util */
4650
+ type RebuildStorageFn = (scope?: string) => void;
4651
+ /** Function signature for disposeStorage util - releases GPU resources */
4652
+ type DisposeStorageFn = (names: string | string[], scope?: string) => void;
4653
+ /** Return type with utils included */
4654
+ type StorageWithUtils<T extends Record<string, StorageLike> = Record<string, StorageLike>> = T & {
4655
+ removeStorage: RemoveStorageFn;
4656
+ clearStorage: ClearStorageFn;
4657
+ rebuildStorage: RebuildStorageFn;
4658
+ disposeStorage: DisposeStorageFn;
4659
+ };
4660
+ declare function useGPUStorage(): StorageWithUtils<Record<string, StorageLike> & Record<string, Record<string, StorageLike>>>;
4661
+ declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
4662
+ declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
4663
+ declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
4664
+ /**
4665
+ * Global rebuildStorage function for HMR integration.
4666
+ * Clears cached storage and increments _hmrVersion to trigger re-creation.
4667
+ * Call this when HMR is detected to refresh all storage creators.
4668
+ *
4669
+ * @param store - The R3F store (from useStore or context)
4670
+ * @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
4671
+ */
4672
+ declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
4673
+
3630
4674
  interface TextureOperations {
3631
4675
  add: (key: string, value: any) => void;
3632
4676
  addMultiple: (items: Map<string, any> | Record<string, any>) => void;
@@ -3636,10 +4680,10 @@ interface TextureOperations {
3636
4680
  declare function createTextureOperations(set: StoreApi<RootState>['setState']): TextureOperations;
3637
4681
 
3638
4682
  /**
3639
- * Hook for managing WebGPU PostProcessing with automatic scenePass setup.
4683
+ * Hook for managing WebGPU RenderPipeline with automatic scenePass setup.
3640
4684
  *
3641
4685
  * Features:
3642
- * - Creates PostProcessing instance if not exists
4686
+ * - Creates RenderPipeline instance if not exists
3643
4687
  * - Creates default scenePass (no MRT) automatically
3644
4688
  * - Callbacks receive full RootState for flexibility
3645
4689
  * - No auto-cleanup on unmount - use reset() for explicit cleanup
@@ -3647,21 +4691,21 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
3647
4691
  *
3648
4692
  * @param mainCB - Main callback to configure outputNode and create effect passes
3649
4693
  * @param setupCB - Optional setup callback to configure MRT on scenePass
3650
- * @returns { passes, postProcessing, clearPasses, reset, rebuild }
4694
+ * @returns { passes, renderPipeline, clearPasses, reset, rebuild }
3651
4695
  *
3652
4696
  * @example
3653
4697
  * ```tsx
3654
4698
  * // Simple effect
3655
- * usePostProcessing(({ postProcessing, passes }) => {
3656
- * postProcessing.outputNode = bloom(passes.scenePass.getTextureNode())
4699
+ * useRenderPipeline(({ renderPipeline, passes }) => {
4700
+ * renderPipeline.outputNode = bloom(passes.scenePass.getTextureNode())
3657
4701
  * })
3658
4702
  *
3659
4703
  * // With MRT setup
3660
- * usePostProcessing(
3661
- * ({ postProcessing, passes }) => {
4704
+ * useRenderPipeline(
4705
+ * ({ renderPipeline, passes }) => {
3662
4706
  * const beauty = passes.scenePass.getTextureNode().toInspector('Color')
3663
4707
  * const vel = passes.scenePass.getTextureNode('velocity')
3664
- * postProcessing.outputNode = motionBlur(beauty, vel)
4708
+ * renderPipeline.outputNode = motionBlur(beauty, vel)
3665
4709
  * },
3666
4710
  * ({ passes }) => {
3667
4711
  * passes.scenePass.setMRT(mrt({ output, velocity }))
@@ -3669,10 +4713,57 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
3669
4713
  * )
3670
4714
  *
3671
4715
  * // Read-only access
3672
- * const { postProcessing, passes } = usePostProcessing()
4716
+ * const { renderPipeline, passes } = useRenderPipeline()
4717
+ * ```
4718
+ */
4719
+ declare function useRenderPipeline(mainCB?: RenderPipelineMainCallback, setupCB?: RenderPipelineSetupCallback): UseRenderPipelineReturn;
4720
+
4721
+ //* Renderer Props ========================================
4722
+
4723
+ type WebGPUDefaultProps = Omit<WebGPURendererParameters, 'canvas'> & BaseRendererProps
4724
+
4725
+ type WebGPUProps =
4726
+ | RendererFactory<WebGPURenderer, WebGPUDefaultProps>
4727
+ | Partial<Properties<WebGPURenderer> | WebGPURendererParameters>
4728
+
4729
+ // WebGPU doesn't have shadow maps in the same way
4730
+ interface WebGPUShadowConfig {
4731
+ shadows?: boolean // Simplified for WebGPU
4732
+ }
4733
+
4734
+ //* WebGPU-specific Types ========================================
4735
+
4736
+ /** WebGPU renderer type - re-exported as R3FRenderer from @react-three/fiber/webgpu */
4737
+ type WebGPUR3FRenderer = WebGPURenderer
4738
+
4739
+ /** WebGPU internal state with narrowed renderer type */
4740
+ interface WebGPUInternalState extends Omit<InternalState, 'actualRenderer'> {
4741
+ actualRenderer: WebGPURenderer
4742
+ }
4743
+
4744
+ /**
4745
+ * WebGPU-specific RootState with narrowed renderer type.
4746
+ * Automatically used when importing from `@react-three/fiber/webgpu`.
4747
+ *
4748
+ * @example
4749
+ * ```tsx
4750
+ * import { useThree } from '@react-three/fiber/webgpu'
4751
+ *
4752
+ * function MyComponent() {
4753
+ * const { renderer } = useThree()
4754
+ * // renderer is typed as WebGPURenderer
4755
+ * renderer.compute(computePass)
4756
+ * }
3673
4757
  * ```
3674
4758
  */
3675
- declare function usePostProcessing(mainCB?: PostProcessingMainCallback, setupCB?: PostProcessingSetupCallback): UsePostProcessingReturn;
4759
+ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'> {
4760
+ /** @deprecated Use `renderer` instead */
4761
+ gl: WebGPURenderer
4762
+ /** The WebGPU renderer instance */
4763
+ renderer: WebGPURenderer
4764
+ /** Internals with WebGPU renderer */
4765
+ internal: WebGPUInternalState
4766
+ }
3676
4767
 
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 };
4768
+ 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, Scheduler, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getScheduler, 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 };
4769
+ export type { Act, AddPhaseOptions, 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, DisposeStorageFn, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, FrameTimingState, 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, RootOptions, WebGPURootState as RootState, RootStore, SchedulerApi, ScopedStoreType, SetBlock, Size, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, Subscription, TSLNode, TSLNodeInput, 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, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };