@react-three/fiber 10.0.0-canary.d202062 → 10.0.0-canary.d46ab63

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.
Files changed (41) hide show
  1. package/dist/extension.cjs +8 -8
  2. package/dist/extension.d.cts +50 -6
  3. package/dist/extension.d.mts +50 -6
  4. package/dist/extension.d.ts +50 -6
  5. package/dist/extension.mjs +1 -1
  6. package/dist/index.cjs +17 -19
  7. package/dist/index.d.cts +15 -47
  8. package/dist/index.d.mts +15 -47
  9. package/dist/index.d.ts +15 -47
  10. package/dist/index.mjs +7 -8
  11. package/dist/legacy.cjs +37 -15
  12. package/dist/legacy.d.cts +10 -7
  13. package/dist/legacy.d.mts +10 -7
  14. package/dist/legacy.d.ts +10 -7
  15. package/dist/legacy.mjs +13 -5
  16. package/dist/shared/{fiber.BY6Yf1h-.d.cts → fiber.34TOMPo3.d.cts} +157 -454
  17. package/dist/shared/fiber.BFuGd7gN.d.cts +90 -0
  18. package/dist/shared/{fiber.tsM9NKZ9.mjs → fiber.BSYBnw8x.mjs} +2177 -1575
  19. package/dist/shared/{fiber.B0oukOFO.mjs → fiber.Biz9olEe.mjs} +181 -64
  20. package/dist/shared/fiber.Bll9fqKA.d.mts +90 -0
  21. package/dist/shared/{fiber.Cu2hX1IM.d.mts → fiber.CjMAAsJy.d.ts} +157 -454
  22. package/dist/shared/{fiber.I5Q4dVvl.d.cts → fiber.DQTSZ24m.d.cts} +488 -26
  23. package/dist/shared/{fiber.I5Q4dVvl.d.mts → fiber.DQTSZ24m.d.mts} +488 -26
  24. package/dist/shared/{fiber.I5Q4dVvl.d.ts → fiber.DQTSZ24m.d.ts} +488 -26
  25. package/dist/shared/fiber.DUgKvaq-.mjs +9 -0
  26. package/dist/shared/{fiber.khFlPHPf.cjs → fiber.DfiCufha.cjs} +186 -62
  27. package/dist/shared/fiber.DuA4F8L5.d.ts +90 -0
  28. package/dist/shared/{fiber.DXw-SLsH.d.ts → fiber.Dy7Uz273.d.mts} +157 -454
  29. package/dist/shared/fiber.X4yI0DId.cjs +14 -0
  30. package/dist/shared/{fiber.oKEFddXj.cjs → fiber.nDnBf1np.cjs} +2222 -1620
  31. package/dist/webgpu/index.cjs +16 -18
  32. package/dist/webgpu/index.d.cts +17 -78
  33. package/dist/webgpu/index.d.mts +17 -78
  34. package/dist/webgpu/index.d.ts +17 -78
  35. package/dist/webgpu/index.mjs +7 -9
  36. package/package.json +3 -3
  37. package/dist/chunks/webgl.cjs +0 -27
  38. package/dist/chunks/webgl.mjs +0 -11
  39. package/dist/shared/fiber.BU0vBHc9.d.mts +0 -48
  40. package/dist/shared/fiber.Cx-UAmMb.d.ts +0 -48
  41. package/dist/shared/fiber.DAl4H27x.d.cts +0 -48
@@ -1,238 +1,10 @@
1
1
  import * as React$1 from 'react';
2
2
  import { ReactNode, Component, RefObject, JSX } from 'react';
3
3
  import { Options } from 'react-use-measure';
4
+ import { ak as RenderProps, m as ConstructorRepresentation, aI as ObjectMap, a7 as BaseRendererProps, a8 as RendererFactory, az as Properties, I as InternalState, H as RootState, E as Euler$1, J as RootStore, a3 as EventManager, Z as DomEvent, av as Instance, o as ThreeElement, ar as Catalogue, ao as Root, al as InjectState, aQ as ThreeCore, aF as Bridge, aH as UnblockProps, aK as Disposable, D as Dpr, aD as ThreeCamera, y as Size, aJ as EquConfig } from './fiber.DQTSZ24m.js';
4
5
  import * as THREE from 'three';
5
- import { ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D } from 'three';
6
- import { J as Properties, c as Size, F as Frameloop, e as Performance, D as Dpr, g as RootStore, p as EventManager, f as RootState, n as ComputeFunction, C as ConstructorRepresentation, _ as ObjectMap, I as InternalState, M as Mutable, O as Overwrite, y as Args, l as EventHandlers, B as InstanceProps, k as DomEvent, G as Instance, x as Catalogue, v as Root, a6 as ThreeCore, W as Bridge, Z as UnblockProps, a0 as Disposable, Q as ThreeCamera, $ as EquConfig } from './fiber.I5Q4dVvl.mjs';
7
- import { WebGPURenderer, WebGPURendererParameters } from 'three/webgpu';
8
-
9
- //* Base Renderer Types =====================================
10
-
11
- // Shim for OffscreenCanvas since it was removed from DOM types
12
- interface OffscreenCanvas$1 extends EventTarget {}
13
-
14
- interface BaseRendererProps {
15
- canvas: HTMLCanvasElement | OffscreenCanvas$1
16
- powerPreference?: 'high-performance' | 'low-power' | 'default'
17
- antialias?: boolean
18
- alpha?: boolean
19
- }
20
-
21
- type RendererFactory<TRenderer, TParams> =
22
- | TRenderer
23
- | ((defaultProps: TParams) => TRenderer)
24
- | ((defaultProps: TParams) => Promise<TRenderer>)
25
-
26
- interface Renderer {
27
- render: (scene: THREE.Scene, camera: THREE.Camera) => any
28
- }
29
-
30
- //* Color Management Config ==============================
31
-
32
- /**
33
- * Color management configuration shared by both WebGL and WebGPU renderers.
34
- */
35
- interface ColorManagementConfig {
36
- /**
37
- * Color space assigned to 8-bit input textures (color maps).
38
- * Defaults to sRGB. Most textures are authored in sRGB.
39
- * @default THREE.SRGBColorSpace
40
- */
41
- textureColorSpace?: THREE.ColorSpace
42
- }
43
-
44
- //* WebGL Renderer Props ==============================
45
-
46
- type DefaultGLProps = Omit<THREE.WebGLRendererParameters, 'canvas'> & {
47
- canvas: HTMLCanvasElement | OffscreenCanvas$1
48
- }
49
-
50
- type GLProps =
51
- | Renderer
52
- | ((defaultProps: DefaultGLProps) => Renderer)
53
- | ((defaultProps: DefaultGLProps) => Promise<Renderer>)
54
- | (Partial<Properties<THREE.WebGLRenderer> | THREE.WebGLRendererParameters> & ColorManagementConfig)
55
-
56
- //* WebGPU Renderer Props ==============================
57
-
58
- type DefaultRendererProps = {
59
- canvas: HTMLCanvasElement | OffscreenCanvas$1
60
- [key: string]: any
61
- }
62
-
63
- /**
64
- * Canvas-level scheduler configuration.
65
- * Controls render timing relative to other canvases.
66
- */
67
- interface CanvasSchedulerConfig {
68
- /**
69
- * Run this Canvas root before the referenced Canvas root id(s).
70
- */
71
- before?: string | string[]
72
- /**
73
- * Run this Canvas root after the referenced Canvas root id(s).
74
- */
75
- after?: string | string[]
76
- /**
77
- * Numeric root order. Lower values run first.
78
- */
79
- order?: number
80
- /**
81
- * Limit this Canvas's default render job (frames per second).
82
- */
83
- fps?: number
84
- }
85
-
86
- /**
87
- * Extended renderer configuration for multi-canvas support and color management.
88
- */
89
- interface RendererConfigExtended extends ColorManagementConfig {
90
- /** Share renderer from another canvas (WebGPU only) */
91
- primaryCanvas?: string
92
- /** Canvas-level scheduler options */
93
- scheduler?: CanvasSchedulerConfig
94
- }
95
-
96
- /**
97
- * The `renderer` prop: opt into three's WebGPU renderer.
98
- * - `true` (the `<Canvas renderer>` shorthand) or `{}`: a default `WebGPURenderer`
99
- * - a props bag: constructor parameters (`antialias`, `forceWebGL`, ...) and renderer properties
100
- * (`toneMapping`, ...), plus `textureColorSpace`, `primaryCanvas` and `scheduler`
101
- * - a renderer instance, or a sync/async factory receiving the default props. Structural, like
102
- * the `gl` prop: anything with `render()`, so a wrapped or mocked renderer is accepted.
103
- */
104
- type RendererProps =
105
- | boolean
106
- | Renderer
107
- | ((defaultProps: DefaultRendererProps) => Renderer)
108
- | ((defaultProps: DefaultRendererProps) => Promise<Renderer>)
109
- | (Partial<Properties<WebGPURenderer> & WebGPURendererParameters> & RendererConfigExtended)
110
-
111
- //* Camera Props ==============================
112
-
113
- type CameraProps = (
114
- | THREE.Camera
115
- | Partial<
116
- ThreeElement<typeof THREE.Camera> &
117
- ThreeElement<typeof THREE.PerspectiveCamera> &
118
- ThreeElement<typeof THREE.OrthographicCamera>
119
- >
120
- ) & {
121
- /** Flags the camera as manual, putting projection into your own hands */
122
- manual?: boolean
123
- }
124
-
125
- //* Render Props ==============================
126
-
127
- interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
128
- /**
129
- * Unique identifier for multi-canvas renderer sharing.
130
- * Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
131
- * Also sets the HTML `id` attribute on the canvas element.
132
- * @example <Canvas id="main-viewer">...</Canvas>
133
- */
134
- id?: string
135
- /**
136
- * Share the renderer from another canvas instead of creating a new one.
137
- * Pass the `id` of the primary canvas to share its WebGPURenderer.
138
- * Only available with WebGPU (not legacy WebGL).
139
- *
140
- * Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
141
- * @internal
142
- */
143
- primaryCanvas?: string
144
- /**
145
- * Canvas-level scheduler options. Controls render timing relative to other canvases.
146
- *
147
- * Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
148
- * @internal
149
- */
150
- scheduler?: CanvasSchedulerConfig
151
- /** A threejs renderer instance or props that go into the default renderer */
152
- gl?: GLProps
153
- /** A WebGPU renderer instance or props that go into the default renderer */
154
- renderer?: RendererProps
155
- /** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
156
- size?: Size
157
- /**
158
- * Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
159
- * but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
160
- * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
161
- */
162
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>
163
- /** Creates an orthographic camera */
164
- orthographic?: boolean
165
- /**
166
- * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
167
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
168
- */
169
- frameloop?: Frameloop
170
- /**
171
- * R3F performance options for adaptive performance.
172
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
173
- */
174
- performance?: Partial<Omit<Performance, 'regress'>>
175
- /** Target pixel ratio. Can clamp between a range: `[min, max]` */
176
- dpr?: Dpr
177
- /**
178
- * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
179
- * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
180
- */
181
- raycaster?: Partial<Omit<THREE.Raycaster, 'params'>> & { params?: Partial<THREE.RaycasterParameters> }
182
- /** A `THREE.Scene` instance or props that go into the default scene */
183
- scene?: THREE.Scene | Partial<THREE.Scene>
184
- /** A `THREE.Camera` instance or props that go into the default camera */
185
- camera?: CameraProps
186
- /** An R3F event manager to manage elements' pointer events */
187
- events?: (store: RootStore) => EventManager<Element>
188
- /** Callback after the canvas has rendered (but not yet committed) */
189
- onCreated?: (state: RootState) => void
190
- /** Response for pointer clicks that have missed any target */
191
- onPointerMissed?: (event: MouseEvent) => void
192
- /** Response for dragover events that have missed any target */
193
- onDragOverMissed?: (event: DragEvent) => void
194
- /** Response for drop events that have missed any target */
195
- onDropMissed?: (event: DragEvent) => void
196
- /** Whether to automatically update the frustum each frame (default: true) */
197
- autoUpdateFrustum?: boolean
198
- /**
199
- * Enable WebGPU occlusion queries for onOccluded/onVisible events.
200
- * Auto-enabled when any object uses onOccluded or onVisible handlers.
201
- * Only works with WebGPU renderer - WebGL will log a warning.
202
- */
203
- occlusion?: boolean
204
- /** Internal: stored size props from Canvas for reset functionality */
205
- _sizeProps?: { width?: number; height?: number } | null
206
- /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
207
- forceEven?: boolean
208
- }
209
-
210
- //* Reconciler Root ==============================
211
-
212
- interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
213
- configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
214
- render: (element: ReactNode) => RootStore
215
- unmount: () => void
216
- }
217
-
218
- //* Inject State ==============================
219
-
220
- type InjectState = Partial<
221
- Omit<RootState, 'events'> & {
222
- events?: {
223
- enabled?: boolean
224
- priority?: number
225
- compute?: ComputeFunction
226
- connected?: any
227
- }
228
- /**
229
- * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
230
- * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
231
- * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
232
- */
233
- injectScene?: boolean
234
- }
235
- >
6
+ import { ColorRepresentation, Euler, Loader, RenderTargetOptions as RenderTargetOptions$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D } from 'three';
7
+ import { WebGPURenderer } from 'three/webgpu';
236
8
 
237
9
  //* Loop Types ==============================
238
10
 
@@ -263,16 +35,16 @@ type PresetsType = keyof typeof presetsObj;
263
35
  interface BackgroundConfig {
264
36
  /** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
265
37
  preset?: PresetsType
266
- /** Files for cube texture (6 faces) or single HDR/EXR */
38
+ /** Files for cube texture (6 faces) or a single equirect (.hdr, .exr, .jpg, .png, .webp, .avif, .gif) */
267
39
  files?: string | string[]
268
40
  /** Separate files for scene.background (visual backdrop) */
269
41
  backgroundMap?: string | string[]
270
- backgroundRotation?: Euler$1 | [number, number, number]
42
+ backgroundRotation?: Euler | [number, number, number]
271
43
  backgroundBlurriness?: number
272
44
  backgroundIntensity?: number
273
45
  /** Separate files for scene.environment (PBR lighting/reflections) */
274
46
  envMap?: string | string[]
275
- environmentRotation?: Euler$1 | [number, number, number]
47
+ environmentRotation?: Euler | [number, number, number]
276
48
  environmentIntensity?: number
277
49
  path?: string
278
50
  extensions?: (loader: Loader) => void
@@ -283,7 +55,7 @@ interface BackgroundConfig {
283
55
  *
284
56
  * String detection priority:
285
57
  * 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
286
- * 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
58
+ * 2. URL - starts with /, ./, ../, http://, https://, data:, OR has an image extension (a query or hash may follow)
287
59
  * 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
288
60
  *
289
61
  * @example Color
@@ -322,9 +94,7 @@ type BackgroundProp =
322
94
  //* Canvas Types ==============================
323
95
 
324
96
  interface CanvasProps
325
- extends
326
- Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
327
- React$1.HTMLAttributes<HTMLDivElement> {
97
+ extends Omit<RenderProps<HTMLCanvasElement>, 'size' | '_primaryToken'>, React$1.HTMLAttributes<HTMLDivElement> {
328
98
  children?: React$1.ReactNode
329
99
  ref?: React$1.Ref<HTMLCanvasElement>
330
100
  /** Canvas fallback content, similar to img's alt prop */
@@ -443,205 +213,6 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
443
213
 
444
214
  type RenderTargetOptions = RenderTargetOptions$1
445
215
 
446
- type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
447
-
448
- interface MathRepresentation {
449
- set(...args: number[]): any
450
- }
451
- interface VectorRepresentation extends MathRepresentation {
452
- setScalar(value: number): any
453
- }
454
- type MathTypes = MathRepresentation | THREE.Euler | THREE.Color
455
-
456
- type MathType<T extends MathTypes> = T extends THREE.Color
457
- ? Args<typeof THREE.Color> | THREE.ColorRepresentation
458
- : T extends VectorRepresentation | THREE.Layers | THREE.Euler
459
- ? T | MutableOrReadonlyParameters<T['set']> | number
460
- : T | MutableOrReadonlyParameters<T['set']>
461
-
462
- type MathProps<P> = {
463
- [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
464
- }
465
-
466
- type Vector2 = MathType<THREE.Vector2>
467
- type Vector3 = MathType<THREE.Vector3>
468
- type Vector4 = MathType<THREE.Vector4>
469
- type Color = MathType<THREE.Color>
470
- type Layers = MathType<THREE.Layers>
471
- type Quaternion = MathType<THREE.Quaternion>
472
- type Euler = MathType<THREE.Euler>
473
- type Matrix3 = MathType<THREE.Matrix3>
474
- type Matrix4 = MathType<THREE.Matrix4>
475
-
476
- interface RaycastableRepresentation {
477
- raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void
478
- }
479
- type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
480
-
481
- /**
482
- * Props for geometry transform methods that can be called with `once()`.
483
- * These methods modify the geometry in-place and only make sense to call once on mount.
484
- *
485
- * @example
486
- * import { once } from '@react-three/fiber'
487
- *
488
- * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
489
- * <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
490
- * <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
491
- */
492
- interface GeometryTransformProps {
493
- /** Rotate the geometry about the X axis (radians). Use with once(). */
494
- rotateX?: number
495
- /** Rotate the geometry about the Y axis (radians). Use with once(). */
496
- rotateY?: number
497
- /** Rotate the geometry about the Z axis (radians). Use with once(). */
498
- rotateZ?: number
499
- /** Translate the geometry (x, y, z). Use with once(). */
500
- translate?: [x: number, y: number, z: number]
501
- /** Scale the geometry (x, y, z). Use with once(). */
502
- scale?: [x: number, y: number, z: number]
503
- /** Center the geometry based on bounding box. Use with once(). */
504
- center?: true
505
- /** Apply a Matrix4 transformation. Use with once(). */
506
- applyMatrix4?: THREE.Matrix4
507
- /** Apply a Quaternion rotation. Use with once(). */
508
- applyQuaternion?: THREE.Quaternion
509
- }
510
-
511
- type GeometryProps<P> = P extends THREE.BufferGeometry ? GeometryTransformProps : {}
512
-
513
- /**
514
- * Workaround for @types/three TSL node type issues.
515
- * The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
516
- * This transforms `Node | null` properties to accept any object with node-like shape.
517
- */
518
- type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
519
-
520
- /**
521
- * For node material properties (colorNode, positionNode, etc.), accept broader types
522
- * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
523
- * `nodeType`, so this structural key test remains neutral to the selected Three entry.
524
- */
525
- type NodeProps<P> = {
526
- [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
527
- }
528
-
529
- interface ReactProps<P> {
530
- children?: React.ReactNode
531
- ref?: React.Ref<P>
532
- key?: React.Key
533
- }
534
-
535
- type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
536
- Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
537
- >
538
-
539
- type ThreeElement<T extends ConstructorRepresentation> = Mutable<
540
- Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
541
- >
542
-
543
- type ThreeToJSXElements<T extends Record<string, any>> = {
544
- [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
545
- }
546
-
547
- /** Method names of Object3D, excluded from the `primitive` element's typed props. */
548
- type Object3DMethod = NonNullable<
549
- {
550
- [K in keyof THREE.Object3D]-?: THREE.Object3D[K] extends (...args: any[]) => any ? K : never
551
- }[keyof THREE.Object3D]
552
- >
553
-
554
- /** Look up a key present in a generic element map. */
555
- type ElementOf<E, K extends string> = E[Extract<keyof E, K>]
556
-
557
- /**
558
- * The JSX element map derived from an entry's Three.js exports. Each entry declares its own
559
- * `ThreeElements` from this (`src/index.tsx`, `src/legacy.tsx`, `src/webgpu/index.tsx`) and augments
560
- * react's `IntrinsicElements` with it, so `/legacy` never advertises node materials and `/webgpu`
561
- * never advertises a `<webGLRenderer>`.
562
- */
563
- type ThreeElementsOf<T extends Record<string, any>> = Omit<
564
- ThreeToJSXElements<T>,
565
- 'audio' | 'source' | 'line' | 'path'
566
- > & {
567
- /**
568
- * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
569
- * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
570
- * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
571
- * methods are left out of the typed surface: they return `this`, so a subclass element's
572
- * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
573
- */
574
- primitive: Omit<ThreeElement<typeof THREE.Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
575
- object: object
576
- ref?: React.Ref<any>
577
- [prop: string]: unknown
578
- }
579
- // Conflicts with DOM types can be accessed through a three* prefix
580
- threeAudio: ElementOf<ThreeToJSXElements<T>, 'audio'>
581
- threeSource: ElementOf<ThreeToJSXElements<T>, 'source'>
582
- threeLine: ElementOf<ThreeToJSXElements<T>, 'line'>
583
- threePath: ElementOf<ThreeToJSXElements<T>, 'path'>
584
- }
585
-
586
- /**
587
- * @fileoverview Registry for primary canvases that can be targeted by secondary canvases
588
- *
589
- * Enables multi-canvas WebGPU rendering where multiple Canvas components share
590
- * a single WebGPURenderer using Three.js CanvasTarget API.
591
- *
592
- * Primary canvas: Has `id` prop, creates its own renderer, registers here
593
- * Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
594
- */
595
-
596
- interface PrimaryCanvasEntry {
597
- /** The WebGPURenderer instance owned by this primary canvas */
598
- renderer: WebGPURenderer;
599
- /** The zustand store for this canvas */
600
- store: RootStore;
601
- }
602
- /**
603
- * Register a primary canvas that can be targeted by secondary canvases.
604
- *
605
- * @param id - Unique identifier for this primary canvas
606
- * @param renderer - The WebGPURenderer owned by this canvas
607
- * @param store - The zustand store for this canvas
608
- * @returns Cleanup function to unregister on unmount
609
- */
610
- declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
611
- /**
612
- * Get a registered primary canvas by id.
613
- *
614
- * @param id - The id of the primary canvas to look up
615
- * @returns The primary canvas entry or undefined if not found
616
- */
617
- declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
618
- /**
619
- * Wait for a primary canvas to be registered.
620
- * Returns immediately if already registered, otherwise waits.
621
- *
622
- * @param id - The id of the primary canvas to wait for
623
- * @param timeout - Optional timeout in ms (default: 5000)
624
- * @returns Promise that resolves with the primary canvas entry
625
- */
626
- declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
627
- /**
628
- * Check if a primary canvas with the given id exists.
629
- *
630
- * @param id - The id to check
631
- * @returns True if a primary canvas with this id is registered
632
- */
633
- declare function hasPrimary(id: string): boolean;
634
- /**
635
- * Unregister a primary canvas. Called on unmount.
636
- *
637
- * @param id - The id of the primary canvas to unregister
638
- */
639
- declare function unregisterPrimary(id: string): void;
640
- /**
641
- * Get all registered primary canvas ids. Useful for debugging.
642
- */
643
- declare function getPrimaryIds(): string[];
644
-
645
216
  type EnvironmentLoaderProps = {
646
217
  files?: string | string[];
647
218
  path?: string;
@@ -699,7 +270,7 @@ type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'pre
699
270
  * - scale: Scale of backside projected sphere (default: 1000)
700
271
  *
701
272
  * Additional loader props:
702
- * @property files - File path(s) for environment. Supports .hdr, .exr, Ultra HDR .jpg, or array of 6 cube faces
273
+ * @property files - File path(s) for environment. Supports .hdr, .exr, .jpg (Ultra HDR or plain), an LDR .png/.webp/.avif/.gif, or array of 6 cube faces
703
274
  * @property path - Base path for file loading
704
275
  * @property extensions - Texture extensions override
705
276
  */
@@ -714,9 +285,9 @@ type EnvironmentProps = {
714
285
  blur?: number;
715
286
  backgroundBlurriness?: number;
716
287
  backgroundIntensity?: number;
717
- backgroundRotation?: Euler;
288
+ backgroundRotation?: Euler$1;
718
289
  environmentIntensity?: number;
719
- environmentRotation?: Euler;
290
+ environmentRotation?: Euler$1;
720
291
  map?: Texture$1;
721
292
  preset?: PresetsType;
722
293
  scene?: Scene | React$1.RefObject<Scene>;
@@ -742,8 +313,9 @@ type EnvironmentProps = {
742
313
  declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
743
314
  /**
744
315
  * Internal component that loads environment textures from files or presets.
745
- * Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg Ultra HDR,
746
- * or CubeTextureLoader for arrays of images.
316
+ * Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg (a JPEG without a gain
317
+ * map loads as a plain image), TextureLoader for an LDR .png/.webp/.avif/.gif, or CubeTextureLoader
318
+ * for arrays of images.
747
319
  *
748
320
  * @example With preset
749
321
  * ```jsx
@@ -804,7 +376,7 @@ declare function EnvironmentPortal({ children, near, far, resolution, frames, ma
804
376
  *
805
377
  * Supports multiple input methods:
806
378
  * - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
807
- * - **Files**: HDR (.hdr), EXR (.exr), Ultra HDR JPEG (.jpg), or cube faces (array of 6 images)
379
+ * - **Files**: HDR (.hdr), EXR (.exr), JPEG (.jpg, Ultra HDR when it carries a gain map), LDR image (.png, .webp, .avif, .gif), or cube faces (array of 6 images)
808
380
  * - **Texture**: Pre-existing cube texture via `map` prop
809
381
  * - **Custom Scene**: Render children into environment using portal and cube camera
810
382
  * - **Ground Projection**: Project environment onto ground plane
@@ -2246,17 +1818,73 @@ declare namespace ReactReconciler {
2246
1818
  ): void;
2247
1819
  }
2248
1820
 
1821
+ /**
1822
+ * Registers constructors so they can be rendered as JSX elements.
1823
+ *
1824
+ * - `extend({ OrbitControls })` makes each constructor available under its camelCased key
1825
+ * (`<orbitControls />`). Values that are not constructors are skipped, so a whole module
1826
+ * namespace can be passed.
1827
+ * - `extend(MyClass)` registers one constructor and returns a component to render it with.
1828
+ *
1829
+ * Registrations are global, shared by every copy and entry of fiber, and are checked before the
1830
+ * three namespace of a root's renderer when an element name is resolved.
1831
+ *
1832
+ * @example
1833
+ * import { OrbitControls } from 'three/addons/controls/OrbitControls.js'
1834
+ * extend({ OrbitControls })
1835
+ * // <orbitControls args={[camera, gl.domElement]} />
1836
+ *
1837
+ * @example
1838
+ * const Controls = extend(OrbitControls)
1839
+ * // <Controls args={[camera, gl.domElement]} />
1840
+ *
1841
+ * @see https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively
1842
+ */
2249
1843
  declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
1844
+ /** Registers each constructor in `objects` under its key; see the first overload. */
2250
1845
  declare function extend<T extends Catalogue>(objects: T): void;
1846
+ /** Registers every constructor in a module namespace, skipping other exports; see the first overload. */
2251
1847
  declare function extend(objects: Record<string, unknown>): void;
2252
1848
 
1849
+ /**
1850
+ * R3F's React reconciler: a mutation-mode host config that turns JSX elements into three.js objects.
1851
+ * Each root's {@link RootStore} is its container, and children attach to `internal.container`
1852
+ * (a portal's target) or else the root's `scene`.
1853
+ *
1854
+ * - **Element names** resolve through `extend()` registrations first, then the three namespace of
1855
+ * the root's renderer. A `three` prefix (`<threeLine>`) is stripped when no element by the
1856
+ * prefixed name exists. `<primitive object={...}>` wraps an existing object.
1857
+ * - **Construction is deferred** until an instance is attached to a mounted parent, so a tree that
1858
+ * Suspense discards never creates three objects.
1859
+ * - **Updates** apply only changed props. Changing `args` (or a primitive's `object`) reconstructs
1860
+ * the object instead; the swap happens in `resetAfterCommit`, before layout effects, so refs
1861
+ * already point to the new object.
1862
+ * - **Removal** detaches the object and disposes it (at idle priority, or immediately in an `act`
1863
+ * test environment), unless it is a primitive, a `Scene`, or it or an ancestor has `dispose={null}`.
1864
+ * - **Priority**: not the primary renderer, so it runs alongside react-dom, and update priority
1865
+ * follows react-dom's event priorities. View-transition commits are flushed synchronously, since
1866
+ * three has nothing to animate between commits.
1867
+ *
1868
+ * `createRoot`, `createPortal` and `flushSync` drive it; app code rarely needs it directly.
1869
+ */
2253
1870
  declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
1871
+ /**
1872
+ * Force React to flush any updates inside the provided callback synchronously and immediately.
1873
+ * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
1874
+ * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
1875
+ * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
1876
+ */
1877
+ declare function flushSync<R>(fn: () => R): R;
2254
1878
 
2255
- declare const isRenderer: (def: any) => boolean;
2256
- interface OffscreenCanvas extends EventTarget {
2257
- }
2258
1879
  declare const _roots: Map<HTMLCanvasElement | OffscreenCanvas, Root>;
1880
+ /**
1881
+ * Unmount the root on `canvas`. The teardown runs once React has committed the unmount, and waits
1882
+ * for a renderer that is still being created. `callback` runs when the root is gone: after the
1883
+ * teardown, and when it disposed a renderer R3F created whose `dispose()` is async (WebGPURenderer
1884
+ * from three r186), after that dispose has settled.
1885
+ */
2259
1886
  declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
1887
+
2260
1888
  declare function createPortal(children: ReactNode, container: THREE.Object3D | RefObject<THREE.Object3D | null> | RefObject<THREE.Object3D>, state?: InjectState): JSX.Element;
2261
1889
  interface PortalProps {
2262
1890
  children: ReactNode;
@@ -2264,14 +1892,89 @@ interface PortalProps {
2264
1892
  container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
2265
1893
  }
2266
1894
  declare function Portal({ children, container, state }: PortalProps): JSX.Element;
1895
+
1896
+ /** Renderer resources: creation, shared canvas lookup, and ownership through final release. */
1897
+
1898
+ declare const isRenderer: (def: any) => boolean;
1899
+ interface PrimaryCanvasEntry {
1900
+ /** The WebGPURenderer instance owned by this primary canvas */
1901
+ renderer: WebGPURenderer;
1902
+ /** The zustand store for this canvas */
1903
+ store: RootStore;
1904
+ /** The primary's scheduler root id; a sharing canvas renders after it by default */
1905
+ rootId?: string;
1906
+ }
2267
1907
  /**
2268
- * Force React to flush any updates inside the provided callback synchronously and immediately.
2269
- * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
2270
- * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
2271
- * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
1908
+ * Register a primary canvas that can be targeted by secondary canvases.
1909
+ *
1910
+ * @param id - Registry key: the canvas id, or DEFAULT_PRIMARY
1911
+ * @param renderer - The WebGPURenderer owned by this canvas
1912
+ * @param store - The zustand store for this canvas
1913
+ * @param options - The owner token that announced it and its scheduler root id
1914
+ * @returns Cleanup function to unregister on unmount
2272
1915
  */
2273
- declare function flushSync<R>(fn: () => R): R;
1916
+ declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore, options?: {
1917
+ token?: object;
1918
+ rootId?: string;
1919
+ }): () => void;
1920
+ /**
1921
+ * Get a registered primary canvas by id.
1922
+ *
1923
+ * @param id - The id of the primary canvas to look up
1924
+ * @returns The primary canvas entry or undefined if not found
1925
+ */
1926
+ declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
1927
+ /**
1928
+ * Wait for a primary canvas to be registered (`share="id"`).
1929
+ * Returns immediately if already registered, otherwise waits, even through a primary remounting.
1930
+ *
1931
+ * @param id - The id of the primary canvas to wait for
1932
+ * @param timeout - Optional timeout in ms (default: 5000)
1933
+ * @returns Promise that resolves with the primary canvas entry
1934
+ */
1935
+ declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
1936
+ /**
1937
+ * Check if a primary canvas with the given id exists.
1938
+ *
1939
+ * @param id - The id to check
1940
+ * @returns True if a primary canvas with this id is registered
1941
+ */
1942
+ declare function hasPrimary(id: string): boolean;
1943
+ /**
1944
+ * Unregister a primary canvas. Called on unmount.
1945
+ *
1946
+ * @param id - The id of the primary canvas to unregister
1947
+ */
1948
+ declare function unregisterPrimary(id: string): void;
1949
+ /**
1950
+ * Get all registered primary canvas ids. Useful for debugging.
1951
+ */
1952
+ declare function getPrimaryIds(): string[];
2274
1953
 
1954
+ /**
1955
+ * Creates the Zustand store that holds one root's {@link RootState}.
1956
+ *
1957
+ * The store starts unconfigured: the renderer, `camera`, `scene`, `raycaster`, `frustum` and `pointer`
1958
+ * are `null` placeholders until the root's renderer support has loaded and `configure()` in
1959
+ * `configuration.ts` fills them in. Only core's part of `RootState` is created here; packages building on
1960
+ * fiber add their own fields through root extensions.
1961
+ *
1962
+ * Besides the initial state, the store wires up:
1963
+ * - `state.gl` and `state.renderer` as accessors over `internal.actualRenderer`. `gl` reports a
1964
+ * deprecation when user code reads it outside legacy mode.
1965
+ * - `rootScene` following `scene` whenever `scene` is set to a real `THREE.Scene`.
1966
+ * - On a size or DPR change: updating the camera and resizing the root's own canvas target (or the
1967
+ * renderer when there is none).
1968
+ * - On a camera change: adding an unparented camera to `rootScene`, then refreshing the viewport and
1969
+ * (when `autoUpdateFrustum` is set) the frustum.
1970
+ * - Calling `invalidate(state)` after every state change.
1971
+ *
1972
+ * `createRoot` calls this once per canvas.
1973
+ *
1974
+ * @param invalidate - Requests frames for a root. Bound into `state.invalidate` and called on every store change.
1975
+ * @param advance - Steps a root manually. Bound into `state.advance`.
1976
+ * @returns The root's store, which is also the reconciler container for that root.
1977
+ */
2275
1978
  declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
2276
1979
 
2277
1980
  /** Whether any root has loaded a renderer yet. */
@@ -2304,7 +2007,7 @@ declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
2304
2007
  */
2305
2008
  declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
2306
2009
  /**
2307
- * Bridges renderer Context and StrictMode from a primary renderer.
2010
+ * Bridges renderer Context, StrictMode, and Activity visibility from a primary renderer.
2308
2011
  * Used to maintain React context when rendering into portals or secondary canvases.
2309
2012
  *
2310
2013
  * @returns A Bridge component that wraps children with the parent renderer's context
@@ -2787,5 +2490,5 @@ declare function isOnce(value: unknown): value is {
2787
2490
  [ONCE]: any[] | true;
2788
2491
  };
2789
2492
 
2790
- export { REACT_INTERNAL_PROPS as a$, Texture as aA, useTextures as aF, useEnvironment as aH, addEffect as aI, addAfterEffect as aJ, addTail as aK, invalidate as aL, advance as aM, extend as aN, reconciler as aO, isRenderer as aP, _roots as aQ, unmountComponentAtNode as aR, createPortal as aS, Portal as aT, flushSync as aU, createStore as aV, useIsomorphicLayoutEffect as aW, useMutableCallback as aX, useBridge as aY, Block as aZ, ErrorBoundary as a_, registerPrimary as ad, getPrimary as ae, waitForPrimary as af, hasPrimary as ag, unregisterPrimary as ah, getPrimaryIds as ai, EnvironmentMap as ak, EnvironmentCube as al, EnvironmentPortal as am, Environment as an, presetsObj as ao, swapInteractivity as aq, removeInteractivity as ar, createEvents as as, useInstanceHandle as at, useGraph as au, useLoader as av, IsObject as aw, useTexture as az, findInitialRoot as b0, getRootState as b1, buildGraph as b2, dispose as b3, getInstanceProps as b4, prepare as b5, invalidateInstance as b6, RESERVED_PROPS as b7, resolve as b8, attach as b9, detach as ba, diffProps as bb, applyProps as bc, calculateDpr as bd, getUuidPrefix as be, updateCamera as bf, updateFrustum as bg, is as bh, isOrthographicCamera as bi, isRef as bj, isColorRepresentation as bk, isObject3D as bl, isTexture as bm, isLayers as bn, isUniform as bo, isVectorLike as bp, isCopyable as bq, hasConstructor as br, FROM_REF as bs, fromRef as bu, isFromRef as bv, ONCE as bw, once as bx, isOnce as bz, createPointerEvents as u, getThree as v, hasThree as w, whenThree as x };
2791
- export type { InputLike as $, Renderer as A, BaseRendererProps as B, Color as C, ColorManagementConfig as D, Euler as E, DefaultGLProps as F, GeometryTransformProps as G, GLProps as H, DefaultRendererProps as I, CanvasSchedulerConfig as J, RendererConfigExtended as K, Layers as L, MutableOrReadonlyParameters as M, NodeProps as N, Object3DMethod as O, RendererProps as P, Quaternion as Q, RaycastableRepresentation as R, CameraProps as S, TSLNodeInput as T, RenderProps as U, VectorRepresentation as V, InjectState as W, GlobalRenderCallback as X, GlobalEffectType as Y, BackgroundConfig as Z, BackgroundProp as _, MathRepresentation as a, LoaderLike as a0, GLTFLike as a1, LoaderInstance as a2, InferLoadResult as a3, LoaderResult as a4, Extensions as a5, WebGLDefaultProps as a6, WebGLProps as a7, WebGLShadowConfig as a8, LegacyRenderer as a9, TextureInput as aB, TextureResult as aC, DisposeOptions as aD, UseTexturesReturn as aE, EnvironmentLoaderProps as aG, LegacyInternalState as aa, LegacyRootState as ab, PrimaryCanvasEntry as ac, EnvironmentProps as aj, PresetsType as ap, MappedTextureType as ax, UseTextureOptions as ay, MathTypes as b, FromRefMarker as bt, OnceValue as by, MathType as c, MathProps as d, Vector2 as e, Vector3 as f, Vector4 as g, Matrix3 as h, Matrix4 as i, EventProps as j, GeometryProps as k, ReactProps as l, ElementProps as m, ThreeElement as n, ThreeToJSXElements as o, ThreeElementsOf as p, ElementOf as q, RenderTargetOptions as r, ReconcilerRoot as s, CanvasProps as t, OffscreenCanvas$1 as y, RendererFactory as z };
2493
+ export { Texture as $, EnvironmentMap as F, EnvironmentCube as H, EnvironmentPortal as J, Environment as K, presetsObj as M, swapInteractivity as O, removeInteractivity as Q, createEvents as S, useInstanceHandle as T, useGraph as U, useLoader as V, IsObject as X, useTexture as _, addEffect as a, useTextures as a4, useEnvironment as a6, extend as a7, reconciler as a8, flushSync as a9, applyProps as aA, is as aB, isOrthographicCamera as aC, isRef as aD, isColorRepresentation as aE, isObject3D as aF, isTexture as aG, isLayers as aH, isUniform as aI, isVectorLike as aJ, isCopyable as aK, hasConstructor as aL, FROM_REF as aM, fromRef as aO, isFromRef as aP, ONCE as aQ, once as aR, isOnce as aT, _roots as aa, unmountComponentAtNode as ab, createPortal as ac, Portal as ad, useIsomorphicLayoutEffect as ae, useMutableCallback as af, useBridge as ag, Block as ah, ErrorBoundary as ai, calculateDpr as aj, getUuidPrefix as ak, updateCamera as al, updateFrustum as am, REACT_INTERNAL_PROPS as an, findInitialRoot as ao, getRootState as ap, buildGraph as aq, dispose as ar, getInstanceProps as as, prepare as at, invalidateInstance as au, RESERVED_PROPS as av, resolve as aw, attach as ax, detach as ay, diffProps as az, addAfterEffect as b, createPointerEvents as c, addTail as d, advance as e, isRenderer as f, getPrimary as g, hasPrimary as h, invalidate as i, getPrimaryIds as j, createStore as k, getThree as l, hasThree as m, whenThree as n, registerPrimary as r, unregisterPrimary as u, waitForPrimary as w };
2494
+ export type { LegacyInternalState as A, BackgroundConfig as B, LegacyRootState as C, EnvironmentProps as D, Extensions as E, GlobalRenderCallback as G, InputLike as I, LoaderLike as L, PresetsType as N, PrimaryCanvasEntry as P, RenderTargetOptions as R, WebGLDefaultProps as W, MappedTextureType as Y, UseTextureOptions as Z, TextureInput as a0, TextureResult as a1, DisposeOptions as a2, UseTexturesReturn as a3, EnvironmentLoaderProps as a5, FromRefMarker as aN, OnceValue as aS, CanvasProps as aU, GlobalEffectType as o, BackgroundProp as p, GLTFLike as q, LoaderInstance as s, InferLoadResult as t, LoaderResult as v, WebGLProps as x, WebGLShadowConfig as y, LegacyRenderer as z };