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

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