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

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