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