@react-three/fiber 10.0.0-canary.f75fbf6 → 10.0.0-canary.fbc659b

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 (36) hide show
  1. package/dist/extension.cjs +8 -8
  2. package/dist/extension.d.cts +4 -4
  3. package/dist/extension.d.mts +4 -4
  4. package/dist/extension.d.ts +4 -4
  5. package/dist/extension.mjs +1 -1
  6. package/dist/index.cjs +14 -15
  7. package/dist/index.d.cts +11 -10
  8. package/dist/index.d.mts +11 -10
  9. package/dist/index.d.ts +11 -10
  10. package/dist/index.mjs +4 -5
  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.BgxhptM_.mjs → fiber.BdIbKbh7.mjs} +2066 -1497
  17. package/dist/shared/{fiber.B0oukOFO.mjs → fiber.Biz9olEe.mjs} +181 -64
  18. package/dist/shared/{fiber.BcX0-yko.d.mts → fiber.C6hitYDY.d.cts} +1 -1
  19. package/dist/shared/{fiber.Dh8K6RJr.d.cts → fiber.C_MFx7We.d.cts} +472 -20
  20. package/dist/shared/{fiber.Dh8K6RJr.d.mts → fiber.C_MFx7We.d.mts} +472 -20
  21. package/dist/shared/{fiber.Dh8K6RJr.d.ts → fiber.C_MFx7We.d.ts} +472 -20
  22. package/dist/shared/{fiber.DH-VJXM_.d.ts → fiber.CtivZ3IY.d.ts} +89 -464
  23. package/dist/shared/{fiber.cO-9hDzr.d.cts → fiber.CvlK0a1Z.d.mts} +89 -464
  24. package/dist/shared/{fiber.BgP4izaL.d.cts → fiber.D4fD6H74.d.mts} +1 -1
  25. package/dist/shared/{fiber.khFlPHPf.cjs → fiber.DfiCufha.cjs} +186 -62
  26. package/dist/shared/{fiber.AN9kOS0N.d.mts → fiber.VTTQNnlj.d.cts} +89 -464
  27. package/dist/shared/{fiber.BIhZnMzg.d.ts → fiber.YgTUGbja.d.ts} +1 -1
  28. package/dist/shared/{fiber.EDf0d92E.cjs → fiber.nDnBf1np.cjs} +2092 -1523
  29. package/dist/webgpu/index.cjs +13 -13
  30. package/dist/webgpu/index.d.cts +12 -6
  31. package/dist/webgpu/index.d.mts +12 -6
  32. package/dist/webgpu/index.d.ts +12 -6
  33. package/dist/webgpu/index.mjs +4 -4
  34. package/package.json +3 -3
  35. package/dist/chunks/webgl.cjs +0 -27
  36. package/dist/chunks/webgl.mjs +0 -11
@@ -1,241 +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 { al as RenderProps, m as ConstructorRepresentation, aJ as ObjectMap, a8 as BaseRendererProps, a9 as RendererFactory, aA as Properties, I as InternalState, J as RootState, E as Euler$1, K as RootStore, a4 as EventManager, _ as DomEvent, aw as Instance, o as ThreeElement, as as Catalogue, ap as Root, am as InjectState, aR as ThreeCore, aG as Bridge, aI as UnblockProps, aL as Disposable, D as Dpr, aE as ThreeCamera, z as Size, aK as EquConfig } from './fiber.C_MFx7We.cjs';
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.Dh8K6RJr.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 (`true` uses `THREE.PCFShadowMap`). Can accept `renderer.shadowMap` options for
159
- * fine-tuning, but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
160
- *
161
- * `'soft'` is a deprecated alias of `'percentage'`: both map to `THREE.PCFShadowMap`, because three.js
162
- * deprecated `PCFSoftShadowMap` and made `PCFShadowMap` soft. Using `'soft'` logs a deprecation notice.
163
- * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
164
- */
165
- shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE.WebGLShadowMap>
166
- /** Creates an orthographic camera */
167
- orthographic?: boolean
168
- /**
169
- * R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
170
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
171
- */
172
- frameloop?: Frameloop
173
- /**
174
- * R3F performance options for adaptive performance.
175
- * @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
176
- */
177
- performance?: Partial<Omit<Performance, 'regress'>>
178
- /** Target pixel ratio. Can clamp between a range: `[min, max]` */
179
- dpr?: Dpr
180
- /**
181
- * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
182
- * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
183
- */
184
- raycaster?: Partial<Omit<THREE.Raycaster, 'params'>> & { params?: Partial<THREE.RaycasterParameters> }
185
- /** A `THREE.Scene` instance or props that go into the default scene */
186
- scene?: THREE.Scene | Partial<THREE.Scene>
187
- /** A `THREE.Camera` instance or props that go into the default camera */
188
- camera?: CameraProps
189
- /** An R3F event manager to manage elements' pointer events */
190
- events?: (store: RootStore) => EventManager<Element>
191
- /** Callback after the canvas has rendered (but not yet committed) */
192
- onCreated?: (state: RootState) => void
193
- /** Response for pointer clicks that have missed any target */
194
- onPointerMissed?: (event: MouseEvent) => void
195
- /** Response for dragover events that have missed any target */
196
- onDragOverMissed?: (event: DragEvent) => void
197
- /** Response for drop events that have missed any target */
198
- onDropMissed?: (event: DragEvent) => void
199
- /** Whether to automatically update the frustum each frame (default: true) */
200
- autoUpdateFrustum?: boolean
201
- /**
202
- * Enable WebGPU occlusion queries for onOccluded/onVisible events.
203
- * Auto-enabled when any object uses onOccluded or onVisible handlers.
204
- * Only works with WebGPU renderer - WebGL will log a warning.
205
- */
206
- occlusion?: boolean
207
- /** Internal: stored size props from Canvas for reset functionality */
208
- _sizeProps?: { width?: number; height?: number } | null
209
- /** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
210
- forceEven?: boolean
211
- }
212
-
213
- //* Reconciler Root ==============================
214
-
215
- interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
216
- configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
217
- render: (element: ReactNode) => RootStore
218
- unmount: () => void
219
- }
220
-
221
- //* Inject State ==============================
222
-
223
- type InjectState = Partial<
224
- Omit<RootState, 'events'> & {
225
- events?: {
226
- enabled?: boolean
227
- priority?: number
228
- compute?: ComputeFunction
229
- connected?: any
230
- }
231
- /**
232
- * When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
233
- * This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
234
- * Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
235
- */
236
- injectScene?: boolean
237
- }
238
- >
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';
239
8
 
240
9
  //* Loop Types ==============================
241
10
 
@@ -266,16 +35,16 @@ type PresetsType = keyof typeof presetsObj;
266
35
  interface BackgroundConfig {
267
36
  /** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
268
37
  preset?: PresetsType
269
- /** 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) */
270
39
  files?: string | string[]
271
40
  /** Separate files for scene.background (visual backdrop) */
272
41
  backgroundMap?: string | string[]
273
- backgroundRotation?: Euler$1 | [number, number, number]
42
+ backgroundRotation?: Euler | [number, number, number]
274
43
  backgroundBlurriness?: number
275
44
  backgroundIntensity?: number
276
45
  /** Separate files for scene.environment (PBR lighting/reflections) */
277
46
  envMap?: string | string[]
278
- environmentRotation?: Euler$1 | [number, number, number]
47
+ environmentRotation?: Euler | [number, number, number]
279
48
  environmentIntensity?: number
280
49
  path?: string
281
50
  extensions?: (loader: Loader) => void
@@ -286,7 +55,7 @@ interface BackgroundConfig {
286
55
  *
287
56
  * String detection priority:
288
57
  * 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
289
- * 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)
290
59
  * 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
291
60
  *
292
61
  * @example Color
@@ -325,9 +94,7 @@ type BackgroundProp =
325
94
  //* Canvas Types ==============================
326
95
 
327
96
  interface CanvasProps
328
- extends
329
- Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
330
- React$1.HTMLAttributes<HTMLDivElement> {
97
+ extends Omit<RenderProps<HTMLCanvasElement>, 'size' | '_primaryToken'>, React$1.HTMLAttributes<HTMLDivElement> {
331
98
  children?: React$1.ReactNode
332
99
  ref?: React$1.Ref<HTMLCanvasElement>
333
100
  /** Canvas fallback content, similar to img's alt prop */
@@ -446,211 +213,6 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
446
213
 
447
214
  type RenderTargetOptions = RenderTargetOptions$1
448
215
 
449
- type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
450
-
451
- interface MathRepresentation {
452
- set(...args: number[]): any
453
- }
454
- interface VectorRepresentation extends MathRepresentation {
455
- setScalar(value: number): any
456
- }
457
- type MathTypes = MathRepresentation | THREE.Euler | THREE.Color
458
-
459
- type MathType<T extends MathTypes> = T extends THREE.Color
460
- ? Args<typeof THREE.Color> | THREE.ColorRepresentation
461
- : T extends VectorRepresentation | THREE.Layers | THREE.Euler
462
- ? T | MutableOrReadonlyParameters<T['set']> | number
463
- : T | MutableOrReadonlyParameters<T['set']>
464
-
465
- type MathProps<P> = {
466
- [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
467
- }
468
-
469
- type Vector2 = MathType<THREE.Vector2>
470
- type Vector3 = MathType<THREE.Vector3>
471
- type Vector4 = MathType<THREE.Vector4>
472
- type Color = MathType<THREE.Color>
473
- type Layers = MathType<THREE.Layers>
474
- type Quaternion = MathType<THREE.Quaternion>
475
- type Euler = MathType<THREE.Euler>
476
- type Matrix3 = MathType<THREE.Matrix3>
477
- type Matrix4 = MathType<THREE.Matrix4>
478
-
479
- interface RaycastableRepresentation {
480
- raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void
481
- }
482
- type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
483
-
484
- /**
485
- * Props for geometry transform methods that can be called with `once()`.
486
- * These methods modify the geometry in-place and only make sense to call once on mount.
487
- *
488
- * @example
489
- * import { once } from '@react-three/fiber'
490
- *
491
- * <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
492
- * <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
493
- * <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
494
- */
495
- interface GeometryTransformProps {
496
- /** Rotate the geometry about the X axis (radians). Use with once(). */
497
- rotateX?: number
498
- /** Rotate the geometry about the Y axis (radians). Use with once(). */
499
- rotateY?: number
500
- /** Rotate the geometry about the Z axis (radians). Use with once(). */
501
- rotateZ?: number
502
- /** Translate the geometry (x, y, z). Use with once(). */
503
- translate?: [x: number, y: number, z: number]
504
- /** Scale the geometry (x, y, z). Use with once(). */
505
- scale?: [x: number, y: number, z: number]
506
- /** Center the geometry based on bounding box. Use with once(). */
507
- center?: true
508
- /** Apply a Matrix4 transformation. Use with once(). */
509
- applyMatrix4?: THREE.Matrix4
510
- /** Apply a Quaternion rotation. Use with once(). */
511
- applyQuaternion?: THREE.Quaternion
512
- }
513
-
514
- type GeometryProps<P> = P extends THREE.BufferGeometry ? GeometryTransformProps : {}
515
-
516
- /**
517
- * Workaround for @types/three TSL node type issues.
518
- * The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
519
- * This transforms `Node | null` properties to accept any object with node-like shape.
520
- */
521
- type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
522
-
523
- /**
524
- * For node material properties (colorNode, positionNode, etc.), accept broader types
525
- * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
526
- * `nodeType`, so this structural key test remains neutral to the selected Three entry.
527
- */
528
- type NodeProps<P> = {
529
- [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
530
- }
531
-
532
- interface ReactProps<P> {
533
- children?: React.ReactNode
534
- ref?: React.Ref<P>
535
- key?: React.Key
536
- }
537
-
538
- type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
539
- Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
540
- >
541
-
542
- type ThreeElement<T extends ConstructorRepresentation> = Mutable<
543
- Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
544
- >
545
-
546
- /**
547
- * Every constructor export of a three namespace as an uncapitalized JSX element. Non-constructor
548
- * exports (constants, functions, nested namespaces) are dropped from the keys rather than mapped
549
- * to `never`: a single `never`-valued key in `JSX.IntrinsicElements` collapses the props of any
550
- * tag typed `React.ElementType` (#3898).
551
- */
552
- type ThreeToJSXElements<T extends Record<string, any>> = {
553
- [K in keyof T & string as T[K] extends ConstructorRepresentation ? Uncapitalize<K> : never]: ThreeElement<T[K]>
554
- }
555
-
556
- /** Method names of Object3D, excluded from the `primitive` element's typed props. */
557
- type Object3DMethod = NonNullable<
558
- {
559
- [K in keyof THREE.Object3D]-?: THREE.Object3D[K] extends (...args: any[]) => any ? K : never
560
- }[keyof THREE.Object3D]
561
- >
562
-
563
- /** Look up a key present in a generic element map. */
564
- type ElementOf<E, K extends string> = E[Extract<keyof E, K>]
565
-
566
- /**
567
- * The JSX element map derived from an entry's Three.js exports. Each entry declares its own
568
- * `ThreeElements` from this (`src/index.tsx`, `src/legacy.tsx`, `src/webgpu/index.tsx`) and augments
569
- * react's `IntrinsicElements` with it, so `/legacy` never advertises node materials and `/webgpu`
570
- * never advertises a `<webGLRenderer>`.
571
- */
572
- type ThreeElementsOf<T extends Record<string, any>> = Omit<
573
- ThreeToJSXElements<T>,
574
- 'audio' | 'source' | 'line' | 'path'
575
- > & {
576
- /**
577
- * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
578
- * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
579
- * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
580
- * methods are left out of the typed surface: they return `this`, so a subclass element's
581
- * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
582
- */
583
- primitive: Omit<ThreeElement<typeof THREE.Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
584
- object: object
585
- ref?: React.Ref<any>
586
- [prop: string]: unknown
587
- }
588
- // Conflicts with DOM types can be accessed through a three* prefix
589
- threeAudio: ElementOf<ThreeToJSXElements<T>, 'audio'>
590
- threeSource: ElementOf<ThreeToJSXElements<T>, 'source'>
591
- threeLine: ElementOf<ThreeToJSXElements<T>, 'line'>
592
- threePath: ElementOf<ThreeToJSXElements<T>, 'path'>
593
- }
594
-
595
- /**
596
- * @fileoverview Registry for primary canvases that can be targeted by secondary canvases
597
- *
598
- * Enables multi-canvas WebGPU rendering where multiple Canvas components share
599
- * a single WebGPURenderer using Three.js CanvasTarget API.
600
- *
601
- * Primary canvas: Has `id` prop, creates its own renderer, registers here
602
- * Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
603
- */
604
-
605
- interface PrimaryCanvasEntry {
606
- /** The WebGPURenderer instance owned by this primary canvas */
607
- renderer: WebGPURenderer;
608
- /** The zustand store for this canvas */
609
- store: RootStore;
610
- }
611
- /**
612
- * Register a primary canvas that can be targeted by secondary canvases.
613
- *
614
- * @param id - Unique identifier for this primary canvas
615
- * @param renderer - The WebGPURenderer owned by this canvas
616
- * @param store - The zustand store for this canvas
617
- * @returns Cleanup function to unregister on unmount
618
- */
619
- declare function registerPrimary(id: string, renderer: WebGPURenderer, store: RootStore): () => void;
620
- /**
621
- * Get a registered primary canvas by id.
622
- *
623
- * @param id - The id of the primary canvas to look up
624
- * @returns The primary canvas entry or undefined if not found
625
- */
626
- declare function getPrimary(id: string): PrimaryCanvasEntry | undefined;
627
- /**
628
- * Wait for a primary canvas to be registered.
629
- * Returns immediately if already registered, otherwise waits.
630
- *
631
- * @param id - The id of the primary canvas to wait for
632
- * @param timeout - Optional timeout in ms (default: 5000)
633
- * @returns Promise that resolves with the primary canvas entry
634
- */
635
- declare function waitForPrimary(id: string, timeout?: number): Promise<PrimaryCanvasEntry>;
636
- /**
637
- * Check if a primary canvas with the given id exists.
638
- *
639
- * @param id - The id to check
640
- * @returns True if a primary canvas with this id is registered
641
- */
642
- declare function hasPrimary(id: string): boolean;
643
- /**
644
- * Unregister a primary canvas. Called on unmount.
645
- *
646
- * @param id - The id of the primary canvas to unregister
647
- */
648
- declare function unregisterPrimary(id: string): void;
649
- /**
650
- * Get all registered primary canvas ids. Useful for debugging.
651
- */
652
- declare function getPrimaryIds(): string[];
653
-
654
216
  type EnvironmentLoaderProps = {
655
217
  files?: string | string[];
656
218
  path?: string;
@@ -708,7 +270,7 @@ type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'pre
708
270
  * - scale: Scale of backside projected sphere (default: 1000)
709
271
  *
710
272
  * Additional loader props:
711
- * @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
712
274
  * @property path - Base path for file loading
713
275
  * @property extensions - Texture extensions override
714
276
  */
@@ -723,9 +285,9 @@ type EnvironmentProps = {
723
285
  blur?: number;
724
286
  backgroundBlurriness?: number;
725
287
  backgroundIntensity?: number;
726
- backgroundRotation?: Euler;
288
+ backgroundRotation?: Euler$1;
727
289
  environmentIntensity?: number;
728
- environmentRotation?: Euler;
290
+ environmentRotation?: Euler$1;
729
291
  map?: Texture$1;
730
292
  preset?: PresetsType;
731
293
  scene?: Scene | React$1.RefObject<Scene>;
@@ -751,8 +313,9 @@ type EnvironmentProps = {
751
313
  declare function EnvironmentMap({ scene, background, map, ...config }: EnvironmentProps): null;
752
314
  /**
753
315
  * Internal component that loads environment textures from files or presets.
754
- * Uses HDRLoader for .hdr, EXRLoader for .exr, UltraHDRLoader for .jpg/.jpeg Ultra HDR,
755
- * 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.
756
319
  *
757
320
  * @example With preset
758
321
  * ```jsx
@@ -813,7 +376,7 @@ declare function EnvironmentPortal({ children, near, far, resolution, frames, ma
813
376
  *
814
377
  * Supports multiple input methods:
815
378
  * - **Presets**: Selection of HDRI Haven assets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
816
- * - **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)
817
380
  * - **Texture**: Pre-existing cube texture via `map` prop
818
381
  * - **Custom Scene**: Render children into environment using portal and cube camera
819
382
  * - **Ground Projection**: Project environment onto ground plane
@@ -2305,12 +1868,23 @@ declare function extend(objects: Record<string, unknown>): void;
2305
1868
  * `createRoot`, `createPortal` and `flushSync` drive it; app code rarely needs it directly.
2306
1869
  */
2307
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;
2308
1878
 
2309
- declare const isRenderer: (def: any) => boolean;
2310
- interface OffscreenCanvas extends EventTarget {
2311
- }
2312
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
+ */
2313
1886
  declare function unmountComponentAtNode<TCanvas extends HTMLCanvasElement | OffscreenCanvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
1887
+
2314
1888
  declare function createPortal(children: ReactNode, container: THREE.Object3D | RefObject<THREE.Object3D | null> | RefObject<THREE.Object3D>, state?: InjectState): JSX.Element;
2315
1889
  interface PortalProps {
2316
1890
  children: ReactNode;
@@ -2318,20 +1892,71 @@ interface PortalProps {
2318
1892
  container: Object3D | RefObject<Object3D | null> | RefObject<Object3D>;
2319
1893
  }
2320
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
+ }
2321
1907
  /**
2322
- * Force React to flush any updates inside the provided callback synchronously and immediately.
2323
- * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
2324
- * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
2325
- * 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
2326
1915
  */
2327
- 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[];
2328
1953
 
2329
1954
  /**
2330
1955
  * Creates the Zustand store that holds one root's {@link RootState}.
2331
1956
  *
2332
1957
  * The store starts unconfigured: the renderer, `camera`, `scene`, `raycaster`, `frustum` and `pointer`
2333
1958
  * are `null` placeholders until the root's renderer support has loaded and `configure()` in
2334
- * `renderer.tsx` fills them in. Only core's part of `RootState` is created here; packages building on
1959
+ * `configuration.ts` fills them in. Only core's part of `RootState` is created here; packages building on
2335
1960
  * fiber add their own fields through root extensions.
2336
1961
  *
2337
1962
  * Besides the initial state, the store wires up:
@@ -2382,7 +2007,7 @@ declare const useIsomorphicLayoutEffect: typeof React$1.useLayoutEffect;
2382
2007
  */
2383
2008
  declare function useMutableCallback<T>(fn: T): React$1.RefObject<T>;
2384
2009
  /**
2385
- * Bridges renderer Context and StrictMode from a primary renderer.
2010
+ * Bridges renderer Context, StrictMode, and Activity visibility from a primary renderer.
2386
2011
  * Used to maintain React context when rendering into portals or secondary canvases.
2387
2012
  *
2388
2013
  * @returns A Bridge component that wraps children with the parent renderer's context
@@ -2865,5 +2490,5 @@ declare function isOnce(value: unknown): value is {
2865
2490
  [ONCE]: any[] | true;
2866
2491
  };
2867
2492
 
2868
- 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 };
2869
- 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 { useTexture as $, EnvironmentMap as H, EnvironmentCube as J, EnvironmentPortal as K, Environment as M, presetsObj as N, swapInteractivity as Q, removeInteractivity as S, createEvents as T, useInstanceHandle as U, useGraph as V, useLoader as X, IsObject as Y, addEffect as a, Texture as a0, useTextures as a5, useEnvironment as a7, extend as a8, reconciler as a9, diffProps as aA, applyProps as aB, is as aC, isOrthographicCamera as aD, isRef as aE, isColorRepresentation as aF, isObject3D as aG, isTexture as aH, isLayers as aI, isUniform as aJ, isVectorLike as aK, isCopyable as aL, hasConstructor as aM, FROM_REF as aN, fromRef as aP, isFromRef as aQ, ONCE as aR, once as aS, isOnce as aU, flushSync as aa, _roots as ab, unmountComponentAtNode as ac, createPortal as ad, Portal as ae, useIsomorphicLayoutEffect as af, useMutableCallback as ag, useBridge as ah, Block as ai, ErrorBoundary as aj, calculateDpr as ak, getUuidPrefix as al, updateCamera as am, updateFrustum as an, REACT_INTERNAL_PROPS as ao, findInitialRoot as ap, getRootState as aq, buildGraph as ar, dispose as as, getInstanceProps as at, prepare as au, invalidateInstance as av, RESERVED_PROPS as aw, resolve as ax, attach as ay, detach 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, CanvasProps as C, LegacyRootState as D, Extensions as E, EnvironmentProps as F, GlobalRenderCallback as G, InputLike as I, LoaderLike as L, PresetsType as O, PrimaryCanvasEntry as P, RenderTargetOptions as R, WebGLDefaultProps as W, MappedTextureType as Z, UseTextureOptions as _, TextureInput as a1, TextureResult as a2, DisposeOptions as a3, UseTexturesReturn as a4, EnvironmentLoaderProps as a6, FromRefMarker as aO, OnceValue as aT, 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 };