@react-three/fiber 10.0.0-alpha.2 → 10.0.0-canary.604355a

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.ts CHANGED
@@ -1,7 +1,7 @@
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';
@@ -10,6 +10,8 @@ import { StoreApi } from 'zustand';
10
10
  import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
11
11
  import { Options } from 'react-use-measure';
12
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';
13
15
 
14
16
  function _mergeNamespaces(n, m) {
15
17
  m.forEach(function (e) {
@@ -55,1282 +57,1614 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
55
57
  WebGLRendererParameters: WebGLRendererParameters
56
58
  }, [three_webgpu]);
57
59
 
58
- //* Utility Types ==============================
59
-
60
- type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends Function ? never : K }[keyof P]
61
- type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O
62
- type Properties<T> = Pick<T, NonFunctionKeys<T>>
63
- type Mutable<P> = { [K in keyof P]: P[K] | Readonly<P[K]> }
64
- type IsOptional<T> = undefined extends T ? true : false
65
- type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
66
- ? IsOptional<First> extends true
67
- ? IsAllOptional<Rest>
68
- : false
69
- : true
70
-
71
- //* Camera Types ==============================
72
-
73
- type ThreeCamera = (THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera) & { manual?: boolean }
74
-
75
- //* Act Type ==============================
76
-
77
- type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
78
-
79
- //* Bridge & Block Types ==============================
80
-
81
- type Bridge = React$1.FC<{ children?: React$1.ReactNode }>
82
-
83
- type SetBlock = false | Promise<null> | null
84
- type UnblockProps = { set: React$1.Dispatch<React$1.SetStateAction<SetBlock>>; children: React$1.ReactNode }
85
-
86
- //* Object Map Type ==============================
87
-
88
- interface ObjectMap {
89
- nodes: { [name: string]: THREE$1.Object3D }
90
- materials: { [name: string]: THREE$1.Material }
91
- meshes: { [name: string]: THREE$1.Mesh }
92
- }
93
-
94
- //* Equality Config ==============================
95
-
96
- interface EquConfig {
97
- /** Compare arrays by reference equality a === b (default), or by shallow equality */
98
- arrays?: 'reference' | 'shallow'
99
- /** Compare objects by reference equality a === b (default), or by shallow equality */
100
- objects?: 'reference' | 'shallow'
101
- /** If true the keys in both a and b must match 1:1 (default), if false a's keys must intersect b's */
102
- strict?: boolean
103
- }
104
-
105
- //* Disposable Type ==============================
106
-
107
- interface Disposable {
108
- type?: string
109
- dispose?: () => void
110
- }
111
-
112
- //* Event-related Types =====================================
113
-
114
- interface Intersection extends THREE$1.Intersection {
115
- /** The event source (the object which registered the handler) */
116
- eventObject: THREE$1.Object3D
117
- }
118
-
119
- type Camera = THREE$1.OrthographicCamera | THREE$1.PerspectiveCamera
120
-
121
- interface IntersectionEvent<TSourceEvent> extends Intersection {
122
- /** The event source (the object which registered the handler) */
123
- eventObject: THREE$1.Object3D
124
- /** An array of intersections */
125
- intersections: Intersection[]
126
- /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
127
- unprojectedPoint: THREE$1.Vector3
128
- /** Normalized event coordinates */
129
- pointer: THREE$1.Vector2
130
- /** Delta between first click and this event */
131
- delta: number
132
- /** The ray that pierced it */
133
- ray: THREE$1.Ray
134
- /** The camera that was used by the raycaster */
135
- camera: Camera
136
- /** stopPropagation will stop underlying handlers from firing */
137
- stopPropagation: () => void
138
- /** The original host event */
139
- nativeEvent: TSourceEvent
140
- /** If the event was stopped by calling stopPropagation */
141
- stopped: boolean
142
- }
143
-
144
- type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>
145
- type DomEvent = PointerEvent | MouseEvent | WheelEvent
146
-
147
- /** DOM event handlers registered on the canvas element */
148
- interface Events {
149
- onClick: EventListener
150
- onContextMenu: EventListener
151
- onDoubleClick: EventListener
152
- onWheel: EventListener
153
- onPointerDown: EventListener
154
- onPointerUp: EventListener
155
- onPointerLeave: EventListener
156
- onPointerMove: EventListener
157
- onPointerCancel: EventListener
158
- onLostPointerCapture: EventListener
159
- onDragEnter: EventListener
160
- onDragLeave: EventListener
161
- onDragOver: EventListener
162
- onDrop: EventListener
163
- }
164
-
165
- /** Event handlers that can be attached to R3F objects (meshes, groups, etc.) */
166
- interface EventHandlers {
167
- onClick?: (event: ThreeEvent<MouseEvent>) => void
168
- onContextMenu?: (event: ThreeEvent<MouseEvent>) => void
169
- onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void
170
- /** Fires continuously while dragging over the object */
171
- onDragOver?: (event: ThreeEvent<DragEvent>) => void
172
- /** Fires once when drag enters the object */
173
- onDragOverEnter?: (event: ThreeEvent<DragEvent>) => void
174
- /** Fires once when drag leaves the object */
175
- onDragOverLeave?: (event: ThreeEvent<DragEvent>) => void
176
- /** Fires when drag misses this object (for objects that have drag handlers) */
177
- onDragOverMissed?: (event: DragEvent) => void
178
- /** Fires when a drop occurs on this object */
179
- onDrop?: (event: ThreeEvent<DragEvent>) => void
180
- /** Fires when a drop misses this object (for objects that have drop handlers) */
181
- onDropMissed?: (event: DragEvent) => void
182
- onPointerUp?: (event: ThreeEvent<PointerEvent>) => void
183
- onPointerDown?: (event: ThreeEvent<PointerEvent>) => void
184
- onPointerOver?: (event: ThreeEvent<PointerEvent>) => void
185
- onPointerOut?: (event: ThreeEvent<PointerEvent>) => void
186
- onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void
187
- onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void
188
- onPointerMove?: (event: ThreeEvent<PointerEvent>) => void
189
- onPointerMissed?: (event: MouseEvent) => void
190
- onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
191
- onWheel?: (event: ThreeEvent<WheelEvent>) => void
192
- onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
193
-
194
- //* Visibility Events --------------------------------
195
- /** Fires when object enters/exits camera frustum. Receives true when in view, false when out. */
196
- onFramed?: (inView: boolean) => void
197
- /** Fires when object occlusion state changes (WebGPU only, requires occlusionTest=true on object) */
198
- onOccluded?: (occluded: boolean) => void
199
- /** Fires when combined visibility changes (frustum + occlusion + visible prop) */
200
- onVisible?: (visible: boolean) => void
201
- }
202
-
203
- type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
204
- type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
205
-
206
- interface EventManager<TTarget> {
207
- /** Determines if the event layer is active */
208
- enabled: boolean
209
- /** Event layer priority, higher prioritized layers come first and may stop(-propagate) lower layer */
210
- priority: number
211
- /** The compute function needs to set up the raycaster and an xy- pointer */
212
- compute?: ComputeFunction
213
- /** The filter can re-order or re-structure the intersections */
214
- filter?: FilterFunction
215
- /** The target node the event layer is tied to */
216
- connected?: TTarget
217
- /** All the pointer event handlers through which the host forwards native events */
218
- handlers?: Events
219
- /** Allows re-connecting to another target */
220
- connect?: (target: TTarget) => void
221
- /** Removes all existing events handlers from the target */
222
- disconnect?: () => void
223
- /** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
224
- * explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
225
- */
226
- update?: () => void
227
- }
228
-
229
- interface PointerCaptureTarget {
230
- intersection: Intersection
231
- target: Element
232
- }
233
-
234
- //* Visibility System Types =====================================
235
-
236
- /** Entry in the visibility registry for tracking object visibility state */
237
- interface VisibilityEntry {
238
- object: THREE$1.Object3D
239
- handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
240
- lastFramedState: boolean | null
241
- lastOccludedState: boolean | null
242
- lastVisibleState: boolean | null
243
- }
244
-
245
- //* Scheduler Types (useFrame) ==============================
246
-
247
-
248
-
249
- // Public Options --------------------------------
250
-
251
- /**
252
- * Options for useFrame hook
253
- */
254
- interface UseFrameNextOptions {
255
- /** Optional stable id for the job. Auto-generated if not provided */
256
- id?: string
257
- /** Named phase to run in. Default: 'update' */
258
- phase?: string
259
- /** Run before this phase or job id */
260
- before?: string | string[]
261
- /** Run after this phase or job id */
262
- after?: string | string[]
263
- /** Priority within phase. Higher runs first. Default: 0 */
264
- priority?: number
265
- /** Max frames per second for this job */
266
- fps?: number
267
- /** If true, skip frames when behind. If false, try to catch up. Default: true */
268
- drop?: boolean
269
- /** Enable/disable without unregistering. Default: true */
270
- enabled?: boolean
271
- }
272
-
273
- /** Alias for UseFrameNextOptions */
274
- type UseFrameOptions = UseFrameNextOptions
275
-
276
- /**
277
- * Options for addPhase
278
- */
279
- interface AddPhaseOptions {
280
- /** Insert this phase before the specified phase */
281
- before?: string
282
- /** Insert this phase after the specified phase */
283
- after?: string
284
- }
285
-
286
- // Frame State --------------------------------
287
-
288
- /**
289
- * Timing-only state for independent/outside mode (no RootState)
290
- */
291
- interface FrameTimingState {
292
- /** High-resolution timestamp from RAF (ms) */
293
- time: number
294
- /** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
295
- delta: number
296
- /** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
297
- elapsed: number
298
- /** Incrementing frame counter */
299
- frame: number
300
- }
301
-
302
- /**
303
- * State passed to useFrame callbacks (extends RootState with timing)
304
- */
305
- interface FrameNextState extends RootState, FrameTimingState {}
306
-
307
- /** Alias for FrameNextState */
308
- type FrameState = FrameNextState
309
-
310
- // Root Options --------------------------------
311
-
312
- /**
313
- * Options for registerRoot
314
- */
315
- interface RootOptions {
316
- /** State provider for callbacks. Optional in independent mode. */
317
- getState?: () => any
318
- /** Error handler for job errors. Falls back to console.error if not provided. */
319
- onError?: (error: Error) => void
320
- }
321
-
322
- // Callback Types --------------------------------
323
-
324
- /**
325
- * Callback function for useFrame
326
- */
327
- type FrameNextCallback = (state: FrameNextState, delta: number) => void
328
-
329
- /** Alias for FrameNextCallback */
330
- type FrameCallback = FrameNextCallback
331
-
332
- // Controls returned from useFrame --------------------------------
333
-
334
- /**
335
- * Controls object returned from useFrame hook
336
- */
337
- interface FrameNextControls {
338
- /** The job's unique ID */
339
- id: string
340
- /** Access to the global scheduler for frame loop control */
341
- scheduler: SchedulerApi
342
- /** Manually step this job only (bypasses FPS limiting) */
343
- step(timestamp?: number): void
344
- /** Manually step ALL jobs in the scheduler */
345
- stepAll(timestamp?: number): void
346
- /** Pause this job (set enabled=false) */
347
- pause(): void
348
- /** Resume this job (set enabled=true) */
349
- resume(): void
350
- /** Reactive paused state - automatically triggers re-render when changed */
351
- isPaused: boolean
352
- }
353
-
354
- /** Alias for FrameNextControls */
355
- type FrameControls = FrameNextControls
356
-
357
- // Scheduler Interface --------------------------------
358
-
359
- /**
360
- * Public interface for the global Scheduler
361
- */
362
- interface SchedulerApi {
363
- //* Phase Management --------------------------------
364
-
365
- /** Add a named phase to the scheduler */
366
- addPhase(name: string, options?: AddPhaseOptions): void
367
- /** Get the ordered list of phase names */
368
- readonly phases: string[]
369
- /** Check if a phase exists */
370
- hasPhase(name: string): boolean
371
-
372
- //* Root Management --------------------------------
373
-
374
- /** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
375
- registerRoot(id: string, options?: RootOptions): () => void
376
- /** Unregister a root */
377
- unregisterRoot(id: string): void
378
- /** Generate a unique root ID */
379
- generateRootId(): string
380
- /** Get the number of registered roots */
381
- getRootCount(): number
382
- /** Check if any root is registered and ready */
383
- readonly isReady: boolean
384
- /** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
385
- onRootReady(callback: () => void): () => void
386
-
387
- //* Job Registration --------------------------------
388
-
389
- /** Register a job with the scheduler (returns unsubscribe function) */
390
- register(
391
- callback: FrameNextCallback,
392
- options?: {
393
- id?: string
394
- rootId?: string
395
- phase?: string
396
- before?: string | string[]
397
- after?: string | string[]
398
- priority?: number
399
- fps?: number
400
- drop?: boolean
401
- enabled?: boolean
402
- },
403
- ): () => void
404
- /** Update a job's options */
405
- updateJob(
406
- id: string,
407
- options: {
408
- priority?: number
409
- fps?: number
410
- drop?: boolean
411
- enabled?: boolean
412
- phase?: string
413
- before?: string | string[]
414
- after?: string | string[]
415
- },
416
- ): void
417
- /** Unregister a job by ID */
418
- unregister(id: string, rootId?: string): void
419
- /** Get the number of registered jobs */
420
- getJobCount(): number
421
- /** Get all job IDs */
422
- getJobIds(): string[]
423
-
424
- //* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
425
-
426
- /** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
427
- registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
428
-
429
- //* Idle Callbacks (for legacy addTail) --------------------------------
430
-
431
- /** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
432
- onIdle(callback: (timestamp: number) => void): () => void
433
-
434
- //* Frame Loop Control --------------------------------
435
-
436
- /** Start the scheduler loop */
437
- start(): void
438
- /** Stop the scheduler loop */
439
- stop(): void
440
- /** Check if the scheduler is running */
441
- readonly isRunning: boolean
442
- /** Get/set the frameloop mode ('always', 'demand', 'never') */
443
- frameloop: Frameloop
444
- /** Independent mode - runs without Canvas, callbacks receive timing-only state */
445
- independent: boolean
446
-
447
- //* Manual Stepping --------------------------------
448
-
449
- /** Manually step all jobs once (for frameloop='never' or testing) */
450
- step(timestamp?: number): void
451
- /** Manually step a single job by ID */
452
- stepJob(id: string, timestamp?: number): void
453
- /** Request frame(s) to be rendered (for frameloop='demand') */
454
- invalidate(frames?: number): void
455
-
456
- //* Per-Job Control --------------------------------
457
-
458
- /** Check if a job is paused */
459
- isJobPaused(id: string): boolean
460
- /** Pause a job */
461
- pauseJob(id: string): void
462
- /** Resume a job */
463
- resumeJob(id: string): void
464
- /** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
465
- subscribeJobState(id: string, listener: () => void): () => void
466
- }
467
-
468
- //* Core Store Types ========================================
469
-
470
- type Subscription = {
471
- ref: React$1.RefObject<RenderCallback>
472
- priority: number
473
- store: RootStore
474
- }
475
-
476
- type Dpr = number | [min: number, max: number]
477
-
478
- interface Size {
479
- width: number
480
- height: number
481
- top: number
482
- left: number
483
- }
484
-
485
- type Frameloop = 'always' | 'demand' | 'never'
486
-
487
- interface Viewport extends Size {
488
- /** The initial pixel ratio */
489
- initialDpr: number
490
- /** Current pixel ratio */
491
- dpr: number
492
- /** size.width / viewport.width */
493
- factor: number
494
- /** Camera distance */
495
- distance: number
496
- /** Camera aspect ratio: width / height */
497
- aspect: number
498
- }
499
-
500
- type RenderCallback = (state: RootState, delta: number, frame?: XRFrame) => void
501
-
502
- interface Performance {
503
- /** Current performance normal, between min and max */
504
- current: number
505
- /** How low the performance can go, between 0 and max */
506
- min: number
507
- /** How high the performance can go, between min and max */
508
- max: number
509
- /** Time until current returns to max in ms */
510
- debounce: number
511
- /** Sets current to min, puts the system in regression */
512
- regress: () => void
513
- }
514
-
515
- interface InternalState {
516
- interaction: THREE$1.Object3D[]
517
- hovered: Map<string, ThreeEvent<DomEvent>>
518
- subscribers: Subscription[]
519
- capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
520
- initialClick: [x: number, y: number]
521
- initialHits: THREE$1.Object3D[]
522
- lastEvent: React$1.RefObject<DomEvent | null>
523
- /** Visibility event registry (onFramed, onOccluded, onVisible) */
524
- visibilityRegistry: Map<string, VisibilityEntry>
525
- /** Whether occlusion queries are enabled (WebGPU only) */
526
- occlusionEnabled: boolean
527
- /** Reference to the invisible occlusion observer mesh */
528
- occlusionObserver: THREE$1.Mesh | null
529
- /** Cached occlusion results from render pass - keyed by Object3D */
530
- occlusionCache: Map<THREE$1.Object3D, boolean | null>
531
- /** Internal helper group for R3F system objects (occlusion observer, etc.) */
532
- helperGroup: THREE$1.Group | null
533
- active: boolean
534
- priority: number
535
- frames: number
536
- subscribe: (callback: React$1.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
537
- /** Internal renderer storage - use state.renderer or state.gl to access */
538
- actualRenderer: THREE$1.WebGLRenderer | any // WebGPURenderer when available
539
- /** Global scheduler reference (for useFrame hook) */
540
- scheduler: SchedulerApi | null
541
- /** This root's unique ID in the global scheduler */
542
- rootId?: string
543
- /** Function to unregister this root from the global scheduler */
544
- unregisterRoot?: () => void
545
- /** Container for child attachment (scene for root, original container for portals) */
546
- container?: THREE$1.Object3D
547
- }
548
-
549
- interface XRManager {
550
- connect: () => void
551
- disconnect: () => void
552
- }
553
-
554
- //* Root State Interface ====================================
555
-
556
- interface RootState {
557
- /** Set current state */
558
- set: StoreApi<RootState>['setState']
559
- /** Get current state */
560
- get: StoreApi<RootState>['getState']
561
- /** (deprecated) The instance of the WebGLrenderer */
562
- gl: THREE$1.WebGLRenderer
563
- /** The instance of the WebGPU renderer, the fallback, OR the default renderer as a mask of gl */
564
- renderer: THREE$1.WebGLRenderer | any // WebGPURenderer when available
565
- /** Inspector of the webGPU Renderer. Init in the canvas */
566
- inspector: any // Inspector type from three/webgpu
567
-
568
- /** Default camera */
569
- camera: ThreeCamera
570
- /** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
571
- frustum: THREE$1.Frustum
572
- /** Whether to automatically update the frustum each frame (default: true) */
573
- autoUpdateFrustum: boolean
574
- /** Default scene (may be overridden in portals to point to the portal container) */
575
- scene: THREE$1.Scene
576
- /** The actual root THREE.Scene - always points to the true scene, even inside portals */
577
- rootScene: THREE$1.Scene
578
- /** Default raycaster */
579
- raycaster: THREE$1.Raycaster
580
- /** Event layer interface, contains the event handler and the node they're connected to */
581
- events: EventManager<any>
582
- /** XR interface */
583
- xr: XRManager
584
- /** Currently used controls */
585
- controls: THREE$1.EventDispatcher | null
586
- /** Normalized event coordinates */
587
- pointer: THREE$1.Vector2
588
- /** @deprecated Normalized event coordinates, use "pointer" instead! */
589
- mouse: THREE$1.Vector2
590
- /* Whether to enable r139's THREE.ColorManagement */
591
- legacy: boolean
592
- /** Shortcut to gl.outputColorSpace = THREE.LinearSRGBColorSpace */
593
- linear: boolean
594
- /** Shortcut to gl.toneMapping = NoTonemapping */
595
- flat: boolean
596
- /** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
597
- textureColorSpace: THREE$1.ColorSpace
598
- /** Render loop flags */
599
- frameloop: Frameloop
600
- performance: Performance
601
- /** Reactive pixel-size of the canvas */
602
- size: Size
603
- /** Reactive size of the viewport in threejs units */
604
- viewport: Viewport & {
605
- getCurrentViewport: (
606
- camera?: ThreeCamera,
607
- target?: THREE$1.Vector3 | Parameters<THREE$1.Vector3['set']>,
608
- size?: Size,
609
- ) => Omit<Viewport, 'dpr' | 'initialDpr'>
610
- }
611
- /** Flags the canvas for render, but doesn't render in itself */
612
- invalidate: (frames?: number, stackFrames?: boolean) => void
613
- /** Advance (render) one step */
614
- advance: (timestamp: number, runGlobalEffects?: boolean) => void
615
- /** Shortcut to setting the event layer */
616
- setEvents: (events: Partial<EventManager<any>>) => void
617
- /** Shortcut to manual sizing. No args resets to props/container. Single arg creates square. */
618
- setSize: (width?: number, height?: number, top?: number, left?: number) => void
619
- /** Shortcut to manual setting the pixel ratio */
620
- setDpr: (dpr: Dpr) => void
621
- /** Shortcut to setting frameloop flags */
622
- setFrameloop: (frameloop: Frameloop) => void
623
- /** Set error state to propagate to error boundary */
624
- setError: (error: Error | null) => void
625
- /** Current error state (null when no error) */
626
- error: Error | null
627
- /** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
628
- uniforms: UniformStore
629
- /** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
630
- nodes: Record<string, any>
631
- /** Global TSL texture nodes - use useTextures() hook for operations */
632
- textures: Map<string, any>
633
- /** WebGPU PostProcessing instance - use usePostProcessing() hook */
634
- postProcessing: any | null // THREE.PostProcessing when available
635
- /** Global TSL pass nodes for post-processing - use usePostProcessing() hook */
636
- passes: Record<string, any>
637
- /** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
638
- _hmrVersion: number
639
- /** Internal: whether setSize() has taken ownership of canvas dimensions */
640
- _sizeImperative: boolean
641
- /** Internal: stored size props from Canvas for reset functionality */
642
- _sizeProps: { width?: number; height?: number } | null
643
- /** When the canvas was clicked but nothing was hit */
644
- onPointerMissed?: (event: MouseEvent) => void
645
- /** When a dragover event has missed any target */
646
- onDragOverMissed?: (event: DragEvent) => void
647
- /** When a drop event has missed any target */
648
- onDropMissed?: (event: DragEvent) => void
649
- /** If this state model is layered (via createPortal) then this contains the previous layer */
650
- previousRoot?: RootStore
651
- /** Internals */
652
- internal: InternalState
653
- // flags for triggers
654
- // if we are using the webGl renderer, this will be true
655
- isLegacy: boolean
656
- // regardless of renderer, if the system supports webGpu, this will be true
657
- webGPUSupported: boolean
658
- //if we are on native
659
- isNative: boolean
660
- }
661
-
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
+
662
721
  type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
663
722
 
664
- //* Base Renderer Types =====================================
665
-
666
- // Shim for OffscreenCanvas since it was removed from DOM types
667
- interface OffscreenCanvas$1 extends EventTarget {}
668
-
669
- interface BaseRendererProps {
670
- canvas: HTMLCanvasElement | OffscreenCanvas$1
671
- powerPreference?: 'high-performance' | 'low-power' | 'default'
672
- antialias?: boolean
673
- alpha?: boolean
674
- }
675
-
676
- type RendererFactory<TRenderer, TParams> =
677
- | TRenderer
678
- | ((defaultProps: TParams) => TRenderer)
679
- | ((defaultProps: TParams) => Promise<TRenderer>)
680
-
681
- interface Renderer {
682
- render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
683
- }
684
-
685
- //* WebGL Renderer Props ==============================
686
-
687
- type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
688
- canvas: HTMLCanvasElement | OffscreenCanvas$1
689
- }
690
-
691
- type GLProps =
692
- | Renderer
693
- | ((defaultProps: DefaultGLProps) => Renderer)
694
- | ((defaultProps: DefaultGLProps) => Promise<Renderer>)
695
- | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
696
-
697
- //* WebGPU Renderer Props ==============================
698
-
699
- type DefaultRendererProps = {
700
- canvas: HTMLCanvasElement | OffscreenCanvas$1
701
- [key: string]: any
702
- }
703
-
704
- type RendererProps =
705
- | any // WebGPURenderer
706
- | ((defaultProps: DefaultRendererProps) => any)
707
- | ((defaultProps: DefaultRendererProps) => Promise<any>)
708
- | Partial<Properties<any> | Record<string, any>>
709
-
710
- //* Camera Props ==============================
711
-
712
- type CameraProps = (
713
- | THREE$1.Camera
714
- | Partial<
715
- ThreeElement<typeof THREE$1.Camera> &
716
- ThreeElement<typeof THREE$1.PerspectiveCamera> &
717
- ThreeElement<typeof THREE$1.OrthographicCamera>
718
- >
719
- ) & {
720
- /** Flags the camera as manual, putting projection into your own hands */
721
- manual?: boolean
722
- }
723
-
724
- //* Render Props ==============================
725
-
726
- interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
727
- /** A threejs renderer instance or props that go into the default renderer */
728
- gl?: GLProps
729
- /** A WebGPU renderer instance or props that go into the default renderer */
730
- renderer?: RendererProps
731
- /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
732
- size?: Size
733
- /**
734
- * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
735
- * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
736
- * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
737
- */
738
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
739
- /**
740
- * Disables three r139 color management.
741
- * @see https://threejs.org/docs/#manual/en/introduction/Color-management
742
- */
743
- legacy?: boolean
744
- /** Switch off automatic sRGB encoding and gamma correction */
745
- linear?: boolean
746
- /** Use `THREE.NoToneMapping` instead of `THREE.ACESFilmicToneMapping` */
747
- flat?: boolean
748
- /** Working color space for automatic texture colorspace assignment. Defaults to THREE.SRGBColorSpace */
749
- /** Color space assigned to 8-bit input textures (color maps). Defaults to sRGB. Most textures are authored in sRGB. */
750
- textureColorSpace?: THREE$1.ColorSpace
751
- /** Creates an orthographic camera */
752
- orthographic?: boolean
753
- /**
754
- * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
755
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
756
- */
757
- frameloop?: Frameloop
758
- /**
759
- * R3F performance options for adaptive performance.
760
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
761
- */
762
- performance?: Partial<Omit<Performance, 'regress'>>
763
- /** Target pixel ratio. Can clamp between a range: `[min, max]` */
764
- dpr?: Dpr
765
- /** Props that go into the default raycaster */
766
- raycaster?: Partial<THREE$1.Raycaster>
767
- /** A `THREE.Scene` instance or props that go into the default scene */
768
- scene?: THREE$1.Scene | Partial<THREE$1.Scene>
769
- /** A `THREE.Camera` instance or props that go into the default camera */
770
- camera?: CameraProps
771
- /** An R3F event manager to manage elements' pointer events */
772
- events?: (store: RootStore) => EventManager<HTMLElement>
773
- /** Callback after the canvas has rendered (but not yet committed) */
774
- onCreated?: (state: RootState) => void
775
- /** Response for pointer clicks that have missed any target */
776
- onPointerMissed?: (event: MouseEvent) => void
777
- /** Response for dragover events that have missed any target */
778
- onDragOverMissed?: (event: DragEvent) => void
779
- /** Response for drop events that have missed any target */
780
- onDropMissed?: (event: DragEvent) => void
781
- /** Whether to automatically update the frustum each frame (default: true) */
782
- autoUpdateFrustum?: boolean
783
- /**
784
- * Enable WebGPU occlusion queries for onOccluded/onVisible events.
785
- * Auto-enabled when any object uses onOccluded or onVisible handlers.
786
- * Only works with WebGPU renderer - WebGL will log a warning.
787
- */
788
- occlusion?: boolean
789
- /** Internal: stored size props from Canvas for reset functionality */
790
- _sizeProps?: { width?: number; height?: number } | null
791
- }
792
-
793
- //* Reconciler Root ==============================
794
-
795
- interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
796
- configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
797
- render: (element: ReactNode) => RootStore
798
- unmount: () => void
799
- }
800
-
801
- //* Inject State ==============================
802
-
803
- type InjectState = Partial<
804
- Omit<RootState, 'events'> & {
805
- events?: {
806
- enabled?: boolean
807
- priority?: number
808
- compute?: ComputeFunction
809
- connected?: any
810
- }
811
- /**
812
- * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
813
- * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
814
- * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
815
- */
816
- injectScene?: boolean
817
- }
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
+ }
818
918
  >
819
919
 
820
- //* Reconciler Types ==============================
821
-
822
- // FiberRoot is an opaque internal React type - we define it locally
823
- // to avoid bundling @types/react-reconciler which causes absolute path issues
824
- type FiberRoot = any
825
-
826
- interface Root {
827
- fiber: FiberRoot
828
- store: RootStore
829
- }
830
-
831
- type AttachFnType<O = any> = (parent: any, self: O) => () => void
832
- type AttachType<O = any> = string | AttachFnType<O>
833
-
834
- type ConstructorRepresentation<T = any> = new (...args: any[]) => T
835
-
836
- interface Catalogue {
837
- [name: string]: ConstructorRepresentation
838
- }
839
-
840
- // TODO: handle constructor overloads
841
- // https://github.com/pmndrs/react-three-fiber/pull/2931
842
- // https://github.com/microsoft/TypeScript/issues/37079
843
- type Args<T> = T extends ConstructorRepresentation
844
- ? T extends typeof Color$1
845
- ? [r: number, g: number, b: number] | [color: ColorRepresentation]
846
- : ConstructorParameters<T>
847
- : any[]
848
-
849
- type ArgsProp<P> = P extends ConstructorRepresentation
850
- ? IsAllOptional<ConstructorParameters<P>> extends true
851
- ? { args?: Args<P> }
852
- : { args: Args<P> }
853
- : { args: unknown[] }
854
-
855
- type InstanceProps<T = any, P = any> = ArgsProp<P> & {
856
- object?: T
857
- dispose?: null
858
- attach?: AttachType<T>
859
- onUpdate?: (self: T) => void
860
- }
861
-
862
- interface Instance<O = any> {
863
- root: RootStore
864
- type: string
865
- parent: Instance | null
866
- children: Instance[]
867
- props: InstanceProps<O> & Record<string, unknown>
868
- object: O & { __r3f?: Instance<O> }
869
- eventCount: number
870
- handlers: Partial<EventHandlers>
871
- attach?: AttachType<O>
872
- previousAttach?: any
873
- isHidden: boolean
874
- }
875
-
876
- interface HostConfig {
877
- type: string
878
- props: Instance['props']
879
- container: RootStore
880
- instance: Instance
881
- textInstance: void
882
- suspenseInstance: Instance
883
- hydratableInstance: never
884
- formInstance: never
885
- publicInstance: Instance['object']
886
- hostContext: {}
887
- childSet: never
888
- timeoutHandle: number | undefined
889
- noTimeout: -1
890
- TransitionStatus: null
891
- }
892
- declare global {
893
- var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
894
- }
895
-
896
- //* Loop Types ==============================
897
-
898
- type GlobalRenderCallback = (timestamp: number) => void
899
-
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
+
900
1004
  type GlobalEffectType = 'before' | 'after' | 'tail'
901
1005
 
902
- //* Canvas Types ==============================
903
-
904
- interface CanvasProps
905
- extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React$1.HTMLAttributes<HTMLDivElement> {
906
- children?: React$1.ReactNode
907
- ref?: React$1.Ref<HTMLCanvasElement>
908
- /** Canvas fallback content, similar to img's alt prop */
909
- fallback?: React$1.ReactNode
910
- /**
911
- * Options to pass to useMeasure.
912
- * @see https://github.com/pmndrs/react-use-measure#api
913
- */
914
- resize?: Options
915
- /** The target where events are being subscribed to, default: the div that wraps canvas */
916
- eventSource?: HTMLElement | React$1.RefObject<HTMLElement>
917
- /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
918
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
919
- /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
920
- hmr?: boolean
921
- /** Canvas resolution width in pixels. If omitted, uses container width. */
922
- width?: number
923
- /** Canvas resolution height in pixels. If omitted, uses container height. */
924
- height?: number
925
- }
926
-
927
- //* Loader Types ==============================
928
-
929
- type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
930
-
931
- // Define a loader-like interface that matches THREE.Loader's load signature
932
- // This works for both generic and non-generic THREE.Loader instances
933
- interface LoaderLike {
934
- load(
935
- url: InputLike,
936
- onLoad?: (result: any) => void,
937
- onProgress?: (event: ProgressEvent<EventTarget>) => void,
938
- onError?: (error: unknown) => void,
939
- ): any
940
- }
941
-
942
- type GLTFLike = { scene: THREE$1.Object3D }
943
-
944
- type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
945
- T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
946
-
947
- // Infer result type from the load method's callback parameter
948
- type InferLoadResult<T> = T extends {
949
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
950
- }
951
- ? R
952
- : T extends ConstructorRepresentation<any>
953
- ? InstanceType<T> extends {
954
- load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
955
- }
956
- ? R
957
- : any
958
- : any
959
-
960
- type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
961
- InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
962
-
963
- type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
964
- 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>,
965
1158
  ) => void
966
1159
 
967
- type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
968
-
969
- type WebGLProps =
970
- | RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
971
- | Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
972
-
973
- interface WebGLShadowConfig {
974
- 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>
975
1170
  }
976
1171
 
977
- //* RenderTarget Types ==============================
978
-
979
-
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
+
980
1207
  type RenderTargetOptions = RenderTargetOptions$1
981
1208
 
982
- //* Global Types ==============================
983
-
984
- declare global {
985
- /** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
986
- interface UniformNode<T = unknown> extends Node {
987
- value: T
988
- }
989
-
990
- /** Flat record of uniform nodes (no nested scopes) */
991
- type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
992
-
993
- /**
994
- * Uniform store that can contain both root-level uniforms and scoped uniform objects
995
- * Used by state.uniforms which has structure like:
996
- * { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
997
- */
998
- type UniformStore = Record<string, UniformNode | UniformRecord>
999
-
1000
- /**
1001
- * Helper to safely access a uniform node from the store.
1002
- * Use this when accessing state.uniforms to get proper typing.
1003
- * @example
1004
- * const uTime = uniforms.uTime as UniformNode<number>
1005
- * const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
1006
- */
1007
- type GetUniform<T = unknown> = UniformNode<T>
1008
-
1009
- /**
1010
- * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1011
- * Supports: primitives, Three.js types, plain objects (converted to vectors), and UniformNodes
1012
- */
1013
- type UniformValue =
1014
- | number
1015
- | string
1016
- | boolean
1017
- | three_webgpu.Color
1018
- | three_webgpu.Vector2
1019
- | three_webgpu.Vector3
1020
- | three_webgpu.Vector4
1021
- | three_webgpu.Matrix3
1022
- | three_webgpu.Matrix4
1023
- | three_webgpu.Euler
1024
- | three_webgpu.Quaternion
1025
- | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1026
- | UniformNode
1027
-
1028
- /** Input record for useUniforms - accepts raw values or UniformNodes */
1029
- type UniformInputRecord = Record<string, UniformValue>
1030
- }
1031
-
1032
- //* Fn Return Type ==============================
1033
-
1034
- /** The return type of Fn() - a callable shader function node */
1035
- type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1036
-
1037
- //* Module Augmentation ==============================
1038
-
1039
- declare module 'three/tsl' {
1040
- /**
1041
- * Fn with array parameter destructuring
1042
- * @example Fn(([uv, skew]) => { ... })
1043
- */
1044
- export function Fn<R extends Node = Node>(
1045
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1046
- ): ShaderCallable<R>
1047
-
1048
- /**
1049
- * Fn with object parameter destructuring
1050
- * @example Fn(({ color, intensity }) => { ... })
1051
- */
1052
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1053
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1054
- ): ShaderCallable<R>
1055
-
1056
- /**
1057
- * Fn with array params + layout
1058
- * @example Fn(([a, b]) => { ... }, { layout: [...] })
1059
- */
1060
- export function Fn<R extends Node = Node>(
1061
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1062
- layout: { layout?: unknown },
1063
- ): ShaderCallable<R>
1064
-
1065
- /**
1066
- * Fn with object params + layout
1067
- */
1068
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1069
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1070
- layout: { layout?: unknown },
1071
- ): ShaderCallable<R>
1072
- }
1073
-
1074
- /**
1075
- * PostProcessing Types for usePostProcessing hook (WebGPU only)
1076
- */
1077
-
1078
-
1079
-
1080
- declare global {
1081
- /** Pass record - stores TSL pass nodes for post-processing */
1082
- type PassRecord = Record<string, any>
1083
-
1084
- /** Setup callback - runs first to configure MRT, create additional passes */
1085
- type PostProcessingSetupCallback = (state: RootState) => PassRecord | void
1086
-
1087
- /** Main callback - runs second to configure outputNode, create effect passes */
1088
- type PostProcessingMainCallback = (state: RootState) => PassRecord | void
1089
-
1090
- /** Return type for usePostProcessing hook */
1091
- interface UsePostProcessingReturn {
1092
- /** Current passes from state */
1093
- passes: PassRecord
1094
- /** PostProcessing instance (null if not initialized) */
1095
- postProcessing: any | null // THREE.PostProcessing
1096
- /** Clear all passes from state */
1097
- clearPasses: () => void
1098
- /** Reset PostProcessing entirely (clears PP + passes) */
1099
- reset: () => void
1100
- /** Re-run setup/main callbacks with current closure values */
1101
- rebuild: () => void
1102
- /** True when PostProcessing is configured and ready */
1103
- isReady: boolean
1104
- }
1105
- }
1106
-
1107
- //* useFrameNext Types ==============================
1108
-
1109
-
1110
-
1111
- //* Global Type Declarations ==============================
1112
-
1113
- declare global {
1114
- // Job --------------------------------
1115
-
1116
- /**
1117
- * Internal job representation in the scheduler
1118
- */
1119
- interface Job {
1120
- /** Unique identifier */
1121
- id: string
1122
- /** The callback to execute */
1123
- callback: FrameNextCallback
1124
- /** Phase this job belongs to */
1125
- phase: string
1126
- /** Run before these phases/job ids */
1127
- before: Set<string>
1128
- /** Run after these phases/job ids */
1129
- after: Set<string>
1130
- /** Priority within phase (higher first) */
1131
- priority: number
1132
- /** Insertion order for deterministic tie-breaking */
1133
- index: number
1134
- /** Max FPS for this job (undefined = no limit) */
1135
- fps?: number
1136
- /** Drop frames when behind (true) or catch up (false) */
1137
- drop: boolean
1138
- /** Last run timestamp (ms) */
1139
- lastRun?: number
1140
- /** Whether job is enabled */
1141
- enabled: boolean
1142
- /** Internal flag: system jobs (like default render) don't block user render takeover */
1143
- system?: boolean
1144
- }
1145
-
1146
- // Phase Graph --------------------------------
1147
-
1148
- /**
1149
- * A node in the phase graph
1150
- */
1151
- interface PhaseNode {
1152
- /** Phase name */
1153
- name: string
1154
- /** Whether this was auto-generated from a before/after constraint */
1155
- isAutoGenerated: boolean
1156
- }
1157
-
1158
- /**
1159
- * Options for creating a job from hook options
1160
- */
1161
- interface JobOptions {
1162
- id?: string
1163
- phase?: string
1164
- before?: string | string[]
1165
- after?: string | string[]
1166
- priority?: number
1167
- fps?: number
1168
- drop?: boolean
1169
- enabled?: boolean
1170
- }
1171
-
1172
- // Frame Loop State --------------------------------
1173
-
1174
- /**
1175
- * Internal frame loop state
1176
- */
1177
- interface FrameLoopState {
1178
- /** Whether the loop is running */
1179
- running: boolean
1180
- /** Current RAF handle */
1181
- rafHandle: number | null
1182
- /** Last frame timestamp in ms (null = uninitialized) */
1183
- lastTime: number | null
1184
- /** Frame counter */
1185
- frameCount: number
1186
- /** Elapsed time since first frame in ms */
1187
- elapsedTime: number
1188
- /** createdAt timestamp in ms */
1189
- createdAt: number
1190
- }
1191
-
1192
- // Root Entry --------------------------------
1193
-
1194
- /**
1195
- * Internal representation of a registered root (Canvas).
1196
- * Tracks jobs and manages rebuild state for this root.
1197
- * @internal
1198
- */
1199
- interface RootEntry {
1200
- /** Unique identifier for this root */
1201
- id: string
1202
- /** Function to get the root's current state. Returns any to support independent mode. */
1203
- getState: () => any
1204
- /** Map of job IDs to Job objects */
1205
- jobs: Map<string, Job>
1206
- /** Cached sorted job list for execution order */
1207
- sortedJobs: Job[]
1208
- /** Whether sortedJobs needs rebuilding */
1209
- needsRebuild: boolean
1210
- }
1211
-
1212
- /**
1213
- * Internal representation of a global job (deprecated API).
1214
- * Global jobs run once per frame, not per-root.
1215
- * Used by legacy addEffect/addAfterEffect APIs.
1216
- * @internal
1217
- * @deprecated Use useFrame with phases instead
1218
- */
1219
- interface GlobalJob {
1220
- /** Unique identifier for this global job */
1221
- id: string
1222
- /** Callback invoked with RAF timestamp in ms */
1223
- callback: (timestamp: number) => void
1224
- }
1225
-
1226
- // HMR Support --------------------------------
1227
-
1228
- /**
1229
- * Hot Module Replacement data structure for preserving scheduler state
1230
- * @internal
1231
- */
1232
- interface HMRData {
1233
- /** Shared data object for storing values across reloads */
1234
- data: Record<string, any>
1235
- /** Optional function to accept HMR updates */
1236
- accept?: () => void
1237
- }
1238
-
1239
- // Default Phases --------------------------------
1240
-
1241
- /**
1242
- * Default phase names for the scheduler
1243
- */
1244
- type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
1245
- }
1246
-
1247
- type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
1248
-
1249
- interface MathRepresentation {
1250
- set(...args: number[]): any
1251
- }
1252
- interface VectorRepresentation extends MathRepresentation {
1253
- setScalar(value: number): any
1254
- }
1255
- type MathTypes = MathRepresentation | Euler$1 | Color$2
1256
-
1257
- type MathType<T extends MathTypes> = T extends Color$2
1258
- ? Args<typeof Color$2> | ColorRepresentation$1
1259
- : T extends VectorRepresentation | Layers$1 | Euler$1
1260
- ? T | MutableOrReadonlyParameters<T['set']> | number
1261
- : T | MutableOrReadonlyParameters<T['set']>
1262
-
1263
- type MathProps<P> = {
1264
- [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
1265
- }
1266
-
1267
- type Vector2 = MathType<Vector2$1>
1268
- type Vector3 = MathType<Vector3$1>
1269
- type Vector4 = MathType<Vector4$1>
1270
- type Color = MathType<Color$2>
1271
- type Layers = MathType<Layers$1>
1272
- type Quaternion = MathType<Quaternion$1>
1273
- type Euler = MathType<Euler$1>
1274
- type Matrix3 = MathType<Matrix3$1>
1275
- type Matrix4 = MathType<Matrix4$1>
1276
-
1277
- interface RaycastableRepresentation {
1278
- raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
1279
- }
1280
- type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
1281
-
1282
- interface ReactProps<P> {
1283
- children?: React.ReactNode
1284
- ref?: React.Ref<P>
1285
- key?: React.Key
1286
- }
1287
-
1288
- type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
1289
- Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P>>
1290
- >
1291
-
1292
- type ThreeElement<T extends ConstructorRepresentation> = Mutable<
1293
- Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
1294
- >
1295
-
1296
- type ThreeToJSXElements<T extends Record<string, any>> = {
1297
- [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1298
- }
1299
-
1300
- type ThreeExports = typeof THREE
1301
- type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1302
-
1303
- interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1304
- primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1305
- // Conflicts with DOM types can be accessed through a three* prefix
1306
- threeAudio: ThreeElementsImpl['audio']
1307
- threeSource: ThreeElementsImpl['source']
1308
- threeLine: ThreeElementsImpl['line']
1309
- threePath: ThreeElementsImpl['path']
1310
- }
1311
-
1312
- declare module 'react' {
1313
- namespace JSX {
1314
- interface IntrinsicElements extends ThreeElements {}
1315
- }
1316
- }
1317
-
1318
- declare module 'react/jsx-runtime' {
1319
- namespace JSX {
1320
- interface IntrinsicElements extends ThreeElements {}
1321
- }
1322
- }
1323
-
1324
- declare module 'react/jsx-dev-runtime' {
1325
- namespace JSX {
1326
- interface IntrinsicElements extends ThreeElements {}
1327
- }
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 import('three') & typeof import('three/webgpu')
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
+ }
1328
1660
  }
1329
1661
 
1330
1662
  type three_d_Color = Color;
1331
1663
  type three_d_ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = ElementProps<T, P>;
1332
1664
  type three_d_Euler = Euler;
1333
1665
  type three_d_EventProps<P> = EventProps<P>;
1666
+ type three_d_GeometryProps<P> = GeometryProps<P>;
1667
+ type three_d_GeometryTransformProps = GeometryTransformProps;
1334
1668
  type three_d_Layers = Layers;
1335
1669
  type three_d_MathProps<P> = MathProps<P>;
1336
1670
  type three_d_MathRepresentation = MathRepresentation;
@@ -1339,9 +1673,11 @@ type three_d_MathTypes = MathTypes;
1339
1673
  type three_d_Matrix3 = Matrix3;
1340
1674
  type three_d_Matrix4 = Matrix4;
1341
1675
  type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1676
+ type three_d_NodeProps<P> = NodeProps<P>;
1342
1677
  type three_d_Quaternion = Quaternion;
1343
1678
  type three_d_RaycastableRepresentation = RaycastableRepresentation;
1344
1679
  type three_d_ReactProps<P> = ReactProps<P>;
1680
+ type three_d_TSLNodeInput = TSLNodeInput;
1345
1681
  type three_d_ThreeElement<T extends ConstructorRepresentation> = ThreeElement<T>;
1346
1682
  type three_d_ThreeElements = ThreeElements;
1347
1683
  type three_d_ThreeElementsImpl = ThreeElementsImpl;
@@ -1352,8 +1688,318 @@ type three_d_Vector3 = Vector3;
1352
1688
  type three_d_Vector4 = Vector4;
1353
1689
  type three_d_VectorRepresentation = VectorRepresentation;
1354
1690
  declare namespace three_d {
1355
- 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
+ }
1356
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;
1357
2003
 
1358
2004
  declare function removeInteractivity(store: RootStore, object: Object3D): void;
1359
2005
  declare function createEvents(store: RootStore): {
@@ -1916,31 +2562,30 @@ declare function useTextures(): UseTexturesReturn;
1916
2562
  * - WebGPU build: Returns RenderTarget
1917
2563
  * - Default build: Returns whichever matches the active renderer
1918
2564
  *
1919
- * @param width - Target width (defaults to canvas width)
1920
- * @param height - Target height (defaults to canvas height)
1921
- * @param options - Three.js RenderTarget options
1922
- *
1923
2565
  * @example
1924
2566
  * ```tsx
1925
- * function PortalScene() {
1926
- * const fbo = useRenderTarget(512, 512, { depthBuffer: true })
1927
- *
1928
- * useFrame(({ renderer, scene, camera }) => {
1929
- * renderer.setRenderTarget(fbo)
1930
- * renderer.render(scene, camera)
1931
- * renderer.setRenderTarget(null)
1932
- * })
1933
- *
1934
- * return (
1935
- * <mesh>
1936
- * <planeGeometry />
1937
- * <meshBasicMaterial map={fbo.texture} />
1938
- * </mesh>
1939
- * )
1940
- * }
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 })
1941
2584
  * ```
1942
2585
  */
1943
- 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;
1944
2589
 
1945
2590
  /**
1946
2591
  * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
@@ -2045,7 +2690,7 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
2045
2690
  *
2046
2691
  * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2047
2692
  */
2048
- declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame): void;
2693
+ declare function advance(timestamp: number): void;
2049
2694
 
2050
2695
  /* eslint-disable @definitelytyped/no-unnecessary-generics */
2051
2696
  declare function ReactReconciler<
@@ -3099,6 +3744,12 @@ declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
3099
3744
  declare function createRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
3100
3745
  declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
3101
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;
3102
3753
  /**
3103
3754
  * Force React to flush any updates inside the provided callback synchronously and immediately.
3104
3755
  * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
@@ -3527,11 +4178,76 @@ declare const hasConstructor: (object: unknown) => object is {
3527
4178
  constructor?: Function;
3528
4179
  };
3529
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
+
3530
4246
  /**
3531
4247
  * A DOM canvas which accepts threejs elements as children.
3532
4248
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
3533
4249
  */
3534
4250
  declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
3535
4251
 
3536
- 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 };
3537
- 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, FiberRoot, 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 };