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

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