@react-three/fiber 10.0.0-canary.4f316e6 → 10.0.0-canary.4f9f64c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
2
2
  import * as three_webgpu from 'three/webgpu';
3
- import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera } from 'three/webgpu';
3
+ import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Object3D, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera } from 'three/webgpu';
4
4
  import * as THREE$1 from 'three';
5
5
  import { WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
6
6
  import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
@@ -15,20 +15,6 @@ import { Options } from 'react-use-measure';
15
15
  import * as react_jsx_runtime from 'react/jsx-runtime';
16
16
  import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
17
17
 
18
- function _mergeNamespaces(n, m) {
19
- m.forEach(function (e) {
20
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
21
- if (k !== 'default' && !(k in n)) {
22
- var d = Object.getOwnPropertyDescriptor(e, k);
23
- Object.defineProperty(n, k, d.get ? d : {
24
- enumerable: true,
25
- get: function () { return e[k]; }
26
- });
27
- }
28
- });
29
- });
30
- return Object.freeze(n);
31
- }
32
18
 
33
19
  /**
34
20
  * @fileoverview Internal Three.js re-exports - DEFAULT ENTRY
@@ -51,20 +37,6 @@ declare const R3F_BUILD_WEBGPU = true;
51
37
  /** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
52
38
  declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
53
39
 
54
- var THREE = /*#__PURE__*/_mergeNamespaces({
55
- __proto__: null,
56
- CubeRenderTarget: CubeRenderTarget,
57
- CubeRenderTargetCompat: CubeRenderTarget,
58
- Inspector: Inspector,
59
- R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
60
- R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
61
- RenderTargetCompat: RenderTarget,
62
- WebGLCubeRenderTarget: WebGLCubeRenderTarget,
63
- WebGLRenderTarget: WebGLRenderTarget,
64
- WebGLRenderer: WebGLRenderer,
65
- WebGLRendererParameters: WebGLRendererParameters,
66
- loadInspector: loadInspector
67
- }, [three_webgpu]);
68
40
 
69
41
  //* Utility Types ==============================
70
42
 
@@ -352,6 +324,7 @@ type BufferLike =
352
324
  | Uint16Array
353
325
  | Int16Array
354
326
  | THREE$1.BufferAttribute // Base class for all buffer attributes
327
+ | THREE$1.InterleavedBufferAttribute
355
328
  | Node // TSL buffer nodes (instancedArray, storage)
356
329
 
357
330
  /** Flat record of buffer-like values (no nested scopes) */
@@ -366,23 +339,15 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
366
339
  //* Node Types (useNodes) ========================================
367
340
 
368
341
  /**
369
- * Structural shape of a TSL node as stored on `state.nodes`.
370
- *
371
- * Deliberately minimal rather than three's nominal `Node`: in @types/three several node classes
372
- * TSL hands back (OperatorNode, ConstNode, ...) do not extend `Node` cleanly, so a `Node` bound
373
- * would reject values `useNodes` creators legitimately return. This is the same shape
374
- * `useNodes` already constrains creators to (`TSLNodeLike`).
342
+ * Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
343
+ * the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
344
+ * code passes through. Creators are constrained to this same type, so the shape a creator returns
345
+ * and the shape the store holds are one type by construction.
375
346
  */
376
- interface NodeLike {
377
- uuid?: string
378
- nodeType?: string | null
379
- /** label method for chaining - sets the node's label and returns self */
380
- label?: ((label: string) => NodeLike) | string
381
- setName?: (name: string) => this
382
- }
347
+ type NodeLike = TSLNodeType | LegacyTSLNodeLike
383
348
 
384
349
  /** Flat record of TSL nodes (no nested scopes) */
385
- type NodeRecord = Record<string, NodeLike>
350
+ type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
386
351
 
387
352
  /**
388
353
  * Node store that can contain both root-level nodes and scoped node objects.
@@ -404,7 +369,9 @@ type NodeStore = Record<string, NodeLike | NodeRecord>
404
369
  * ```
405
370
  */
406
371
  type StorageLike =
407
- | StorageTexture // GPU storage texture
372
+ | StorageTexture // 2D GPU storage texture
373
+ | Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
374
+ | StorageArrayTexture // 2D-array GPU storage texture
408
375
  | Data3DTexture // 3D texture (can be used as storage)
409
376
  | Node // TSL storage texture nodes (storageTexture)
410
377
 
@@ -853,14 +820,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
853
820
  performance?: Partial<Omit<Performance, 'regress'>>
854
821
  /** Target pixel ratio. Can clamp between a range: `[min, max]` */
855
822
  dpr?: Dpr
856
- /** Props that go into the default raycaster */
857
- raycaster?: Partial<THREE$1.Raycaster>
823
+ /**
824
+ * Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
825
+ * so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
826
+ */
827
+ raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
858
828
  /** A `THREE.Scene` instance or props that go into the default scene */
859
829
  scene?: THREE$1.Scene | Partial<THREE$1.Scene>
860
830
  /** A `THREE.Camera` instance or props that go into the default camera */
861
831
  camera?: CameraProps
862
832
  /** An R3F event manager to manage elements' pointer events */
863
- events?: (store: RootStore) => EventManager<HTMLElement>
833
+ events?: (store: RootStore) => EventManager<Element>
864
834
  /** Callback after the canvas has rendered (but not yet committed) */
865
835
  onCreated?: (state: RootState) => void
866
836
  /** Response for pointer clicks that have missed any target */
@@ -1089,7 +1059,7 @@ interface CanvasProps
1089
1059
  */
1090
1060
  resize?: Options
1091
1061
  /** The target where events are being subscribed to, default: the div that wraps canvas */
1092
- eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
1062
+ eventSource?: Element | React$1.RefObject<Element | null>
1093
1063
  /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
1094
1064
  eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
1095
1065
  /** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
@@ -1197,107 +1167,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
1197
1167
 
1198
1168
  type RenderTargetOptions = RenderTargetOptions$1
1199
1169
 
1200
- //* Global Types ==============================
1170
+ //* Global TSL Types ==============================
1201
1171
 
1202
1172
  declare global {
1203
1173
  /**
1204
- * Uniform node type.
1205
- *
1206
- * This is three's own `UniformNode`, not a re-declaration of it. It previously was a
1207
- * hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
1208
- * exported type globally — so R3F's ~58 references resolved to an approximation that was
1209
- * missing members three actually ships (`setName` among them) and had drifted to the wrong
1210
- * arity when three made `UniformNode` two-parameter.
1211
- *
1212
- * three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
1213
- * so the node type is fixed to `unknown` and the single parameter is kept for call-site
1214
- * ergonomics. The result is three's structural type, so members stay in sync with the
1215
- * installed three instead of needing to be mirrored by hand.
1174
+ * Broad callable-node fallback for dynamic store readers.
1175
+ * Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
1216
1176
  */
1217
- type UniformNode<T = unknown> = three_webgpu.UniformNode<UniformNodeTypeFor<T>, T>
1177
+ type CallableTSLNode = ((...params: never[]) => unknown) & {
1178
+ readonly shaderNode: unknown
1179
+ readonly id: number
1180
+ }
1181
+
1182
+ /** Legacy structural node accepted when at least one historical marker exists. */
1183
+ type LegacyTSLNodeLike = {
1184
+ label?: ((label: string) => unknown) | string
1185
+ setName?: (name: string) => unknown
1186
+ } & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
1187
+
1188
+ /** Node type accepted by broad dynamic node-store readers. */
1189
+ type TSLNodeType = three_webgpu.Node | CallableTSLNode
1218
1190
 
1219
1191
  /**
1220
- * three's node type name for a uniform value type, mirroring the `uniform()` overloads.
1221
- * A `UniformNode<number>` is a `Node<'float'>`, so TSL math (`.mul`, `.add`, ...) accepts it.
1222
- * Unknown or unlisted value types resolve to `unknown`, which TSL math rejects: narrow with
1223
- * `as UniformNode<number>` (or the matching value type) at the call site.
1192
+ * Derive Three's shader node type from an existing node or a supported raw input.
1193
+ * Existing InputNode generics take precedence over structural value normalization.
1194
+ * Both generics must be inferred because Three's UniformNode intersects an unknown-typed
1195
+ * InputNode base with its concrete InputNode specialization.
1224
1196
  */
1225
- type UniformNodeTypeFor<T> = T extends number
1226
- ? 'float'
1227
- : T extends boolean
1228
- ? 'bool'
1229
- : T extends three_webgpu.Color
1230
- ? 'color'
1231
- : T extends three_webgpu.Vector2
1232
- ? 'vec2'
1233
- : T extends three_webgpu.Vector3
1234
- ? 'vec3'
1235
- : T extends three_webgpu.Vector4
1197
+ type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
1198
+ ? TNodeType
1199
+ : T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
1200
+ ? TNodeType
1201
+ : T extends number
1202
+ ? 'float'
1203
+ : T extends boolean
1204
+ ? 'bool'
1205
+ : T extends string | three_webgpu.Color | { r: number; g: number; b: number }
1206
+ ? 'color'
1207
+ : T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
1236
1208
  ? 'vec4'
1237
- : T extends three_webgpu.Matrix2
1238
- ? 'mat2'
1239
- : T extends three_webgpu.Matrix3
1240
- ? 'mat3'
1209
+ : T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
1210
+ ? 'vec3'
1211
+ : T extends three_webgpu.Vector2 | { x: number; y: number }
1212
+ ? 'vec2'
1241
1213
  : T extends three_webgpu.Matrix4
1242
1214
  ? 'mat4'
1243
- : unknown
1244
-
1245
- /**
1246
- * ShaderCallable - the return type of Fn()
1247
- * A callable shader function node that can be invoked with parameters.
1248
- * The function returns a ShaderNodeObject when called.
1249
- *
1250
- * @example
1251
- * ```tsx
1252
- * // Define a shader function
1253
- * const blendColorFn = Fn(([color1, color2, factor]) => {
1254
- * return mix(color1, color2, factor)
1255
- * })
1256
- *
1257
- * // Type when retrieving from nodes store
1258
- * const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
1259
- *
1260
- * // Or with specific return type
1261
- * const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
1262
- * ```
1263
- */
1264
- type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
1265
-
1266
- /**
1267
- * ShaderNodeRef - a ShaderNodeObject wrapper around a Node
1268
- * This is the common return type for TSL operations (add, mul, sin, etc.)
1269
- *
1270
- * @example
1271
- * ```tsx
1272
- * const { wobble } = nodes as { wobble: ShaderNodeRef }
1273
- * ```
1274
- */
1275
- type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
1215
+ : T extends three_webgpu.Matrix3
1216
+ ? 'mat3'
1217
+ : T extends three_webgpu.Matrix2
1218
+ ? 'mat2'
1219
+ : unknown
1220
+
1221
+ /** Derive the normalized JavaScript value stored by a uniform node. */
1222
+ type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
1223
+ ? TValue
1224
+ : T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
1225
+ ? TValue
1226
+ : T extends string | { r: number; g: number; b: number }
1227
+ ? three_webgpu.Color
1228
+ : T extends { x: number; y: number; z: number; w: number }
1229
+ ? three_webgpu.Vector4
1230
+ : T extends { x: number; y: number; z: number }
1231
+ ? three_webgpu.Vector3
1232
+ : T extends { x: number; y: number }
1233
+ ? three_webgpu.Vector2
1234
+ : T extends number
1235
+ ? number
1236
+ : T extends boolean
1237
+ ? boolean
1238
+ : T
1239
+
1240
+ /** Three's exact UniformNode with shader and value generics derived from an input. */
1241
+ type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
1242
+
1243
+ /** Preserve every input key while mapping values to exact Three uniform nodes. */
1244
+ type UniformNodesFor<T extends UniformInputRecord> = {
1245
+ [K in keyof T]: UniformNodeFor<T[K]>
1246
+ }
1276
1247
 
1277
- /**
1278
- * TSLNodeType - Union of all common TSL node types
1279
- * Used by ScopedStore to properly type node access from the store.
1280
- *
1281
- * Includes:
1282
- * - Node: base Three.js node type
1283
- * - ShaderCallable: function nodes created with Fn()
1284
- * - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
1285
- *
1286
- * @example
1287
- * ```tsx
1288
- * // In useLocalNodes, nodes are typed as TSLNodeType
1289
- * const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
1290
- * positionNode: nodes.myPosition, // Works - Node is in union
1291
- * blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
1292
- * }))
1293
- *
1294
- * // Can narrow with type guard or assertion when needed
1295
- * if (typeof blendColorFn === 'function') {
1296
- * blendColorFn(someColor, 0.5)
1297
- * }
1298
- * ```
1299
- */
1300
- type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
1248
+ /** Backward-compatible single-parameter uniform alias. */
1249
+ type UniformNode<T = unknown> = UniformNodeFor<T>
1301
1250
 
1302
1251
  /** Flat record of uniform nodes (no nested scopes) */
1303
1252
  type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
@@ -1322,7 +1271,7 @@ declare global {
1322
1271
  * Acceptable input values for useUniforms - raw values that get converted to UniformNodes
1323
1272
  * Supports:
1324
1273
  * - Primitives: number, string (color), boolean
1325
- * - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
1274
+ * - Three.js types: Color, Vector2/3/4, Matrix2/3/4
1326
1275
  * - Plain objects: { x, y, z, w } converted to vectors
1327
1276
  * - TSL nodes: color(), vec3(), float() for type casting
1328
1277
  * - UniformNode: existing uniforms (reused as-is)
@@ -1335,56 +1284,20 @@ declare global {
1335
1284
  | three_webgpu.Vector2
1336
1285
  | three_webgpu.Vector3
1337
1286
  | three_webgpu.Vector4
1287
+ | three_webgpu.Matrix2
1338
1288
  | three_webgpu.Matrix3
1339
1289
  | three_webgpu.Matrix4
1340
- | three_webgpu.Euler
1341
- | three_webgpu.Quaternion
1342
- | { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
1290
+ | { x: number; y: number }
1291
+ | { x: number; y: number; z: number }
1292
+ | { x: number; y: number; z: number; w: number }
1343
1293
  | { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
1344
- | Node // TSL nodes like color(), vec3(), float() for type casting
1294
+ | three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
1345
1295
  | UniformNode
1346
1296
 
1347
1297
  /** Input record for useUniforms - accepts raw values or UniformNodes */
1348
1298
  type UniformInputRecord = Record<string, UniformValue>
1349
1299
  }
1350
1300
 
1351
- //* Module Augmentation ==============================
1352
-
1353
- declare module 'three/tsl' {
1354
- /**
1355
- * Fn with array parameter destructuring
1356
- * @example Fn(([uv, skew]) => { ... })
1357
- */
1358
- export function Fn<R extends Node = Node>(
1359
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1360
- ): ShaderCallable<R>
1361
-
1362
- /**
1363
- * Fn with object parameter destructuring
1364
- * @example Fn(({ color, intensity }) => { ... })
1365
- */
1366
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1367
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1368
- ): ShaderCallable<R>
1369
-
1370
- /**
1371
- * Fn with array params + layout
1372
- * @example Fn(([a, b]) => { ... }, { layout: [...] })
1373
- */
1374
- export function Fn<R extends Node = Node>(
1375
- jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
1376
- layout: { layout?: unknown },
1377
- ): ShaderCallable<R>
1378
-
1379
- /**
1380
- * Fn with object params + layout
1381
- */
1382
- export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
1383
- jsFunc: (inputs: T) => ShaderNodeObject<R>,
1384
- layout: { layout?: unknown },
1385
- ): ShaderCallable<R>
1386
- }
1387
-
1388
1301
  declare global {
1389
1302
  /**
1390
1303
  * three's own render pipeline type. Named here so the rest of R3F refers to three's shape
@@ -1412,10 +1325,15 @@ declare global {
1412
1325
  * any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
1413
1326
  * `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
1414
1327
  * site when you need a member, e.g. `passes.velocity as TextureNode`.
1328
+ *
1329
+ * The index signature admits `undefined` because a key may simply not be registered, and
1330
+ * because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
1331
+ * optional property whose type excludes `undefined` from the index signature is an error
1332
+ * (TS2411) for every consumer compiling these declarations.
1415
1333
  */
1416
1334
  interface PassRecord {
1417
1335
  scenePass?: ScenePassNode
1418
- [key: string]: three_webgpu.Node
1336
+ [key: string]: three_webgpu.Node | undefined
1419
1337
  }
1420
1338
 
1421
1339
  /**
@@ -1562,10 +1480,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
1562
1480
 
1563
1481
  /**
1564
1482
  * For node material properties (colorNode, positionNode, etc.), accept broader types
1565
- * since @types/three has broken inheritance for TSL node subclasses.
1483
+ * since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
1484
+ * `nodeType`, so this structural key test remains neutral to the selected Three entry.
1566
1485
  */
1567
1486
  type NodeProps<P> = {
1568
- [K in keyof P as P[K] extends Node | null ? K : never]?: TSLNodeInput
1487
+ [K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
1569
1488
  }
1570
1489
 
1571
1490
  interface ReactProps<P> {
@@ -1586,11 +1505,30 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
1586
1505
  [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
1587
1506
  }
1588
1507
 
1508
+ /** Method names of Object3D, excluded from the `primitive` element's typed props. */
1509
+ type Object3DMethod = NonNullable<
1510
+ {
1511
+ [K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
1512
+ }[keyof Object3D]
1513
+ >
1514
+
1589
1515
  type ThreeExports = typeof import('three') & typeof import('three/webgpu')
1590
1516
  type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
1591
1517
 
1592
1518
  interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
1593
- primitive: Omit<ThreeElement<any>, 'args'> & { object: object }
1519
+ /**
1520
+ * `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
1521
+ * Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
1522
+ * untyped, and any other prop is accepted and applied to the object by name. Object3D's own
1523
+ * methods are left out of the typed surface: they return `this`, so a subclass element's
1524
+ * props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
1525
+ */
1526
+ primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | 'onUpdate' | Object3DMethod> & {
1527
+ object: object
1528
+ ref?: React.Ref<any>
1529
+ onUpdate?: (self: any) => void
1530
+ [prop: string]: unknown
1531
+ }
1594
1532
  // Conflicts with DOM types can be accessed through a three* prefix
1595
1533
  threeAudio: ThreeElementsImpl['audio']
1596
1534
  threeSource: ThreeElementsImpl['source']
@@ -1631,6 +1569,7 @@ type three_d_Matrix3 = Matrix3;
1631
1569
  type three_d_Matrix4 = Matrix4;
1632
1570
  type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
1633
1571
  type three_d_NodeProps<P> = NodeProps<P>;
1572
+ type three_d_Object3DMethod = Object3DMethod;
1634
1573
  type three_d_Quaternion = Quaternion;
1635
1574
  type three_d_RaycastableRepresentation = RaycastableRepresentation;
1636
1575
  type three_d_ReactProps<P> = ReactProps<P>;
@@ -1645,7 +1584,7 @@ type three_d_Vector3 = Vector3;
1645
1584
  type three_d_Vector4 = Vector4;
1646
1585
  type three_d_VectorRepresentation = VectorRepresentation;
1647
1586
  declare namespace three_d {
1648
- 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 };
1587
+ 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_Object3DMethod as Object3DMethod, 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 };
1649
1588
  }
1650
1589
 
1651
1590
  /**
@@ -1994,7 +1933,7 @@ declare function createEvents(store: RootStore): {
1994
1933
  processDeferredPointer: (event: DomEvent, pointerId: number) => void;
1995
1934
  };
1996
1935
  /** Default R3F event manager for web */
1997
- declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
1936
+ declare function createPointerEvents(store: RootStore): EventManager<Element>;
1998
1937
 
1999
1938
  /**
2000
1939
  * Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
@@ -3391,6 +3330,7 @@ declare namespace ReactReconciler {
3391
3330
 
3392
3331
  declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
3393
3332
  declare function extend<T extends Catalogue>(objects: T): void;
3333
+ declare function extend(objects: Record<string, unknown>): void;
3394
3334
  declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
3395
3335
 
3396
3336
  declare const isRenderer: (def: any) => boolean;
@@ -3834,29 +3774,44 @@ declare const hasConstructor: (object: unknown) => object is {
3834
3774
  * Used to identify values that should be resolved from refs after mount.
3835
3775
  */
3836
3776
  declare const FROM_REF: unique symbol;
3777
+ /** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
3778
+ interface FromRefMarker<T = unknown, R = T> {
3779
+ [FROM_REF]: React$1.RefObject<T | null>;
3780
+ /** Optional transform applied to the resolved ref before assignment. */
3781
+ transform?: (value: T) => R;
3782
+ }
3837
3783
  /**
3838
3784
  * Defers prop application until the referenced object is available.
3839
3785
  * Useful for props like `target` that need sibling refs to be populated.
3840
3786
  *
3787
+ * Only top-level props on a three element are resolved: a marker nested inside another value
3788
+ * (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
3789
+ * than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
3790
+ * what gets assigned.
3791
+ *
3841
3792
  * @param ref - React ref object to resolve at mount time
3842
- * @returns A marker value that applyProps will resolve after mount
3793
+ * @param transform - Optional mapping from the resolved object to the value the prop expects
3794
+ * @returns A marker value that the reconciler resolves after mount
3843
3795
  *
3844
3796
  * @example
3845
3797
  * const targetRef = useRef<THREE.Object3D>(null)
3846
3798
  *
3847
3799
  * <group ref={targetRef} position={[-3, -2, -15]} />
3848
3800
  * <spotLight target={fromRef(targetRef)} intensity={100} />
3801
+ *
3802
+ * @example
3803
+ * // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
3804
+ * <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
3849
3805
  */
3850
3806
  declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
3807
+ declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
3851
3808
  /**
3852
3809
  * Type guard to check if a value is a fromRef marker.
3853
3810
  *
3854
3811
  * @param value - Value to check
3855
3812
  * @returns True if value is a fromRef marker
3856
3813
  */
3857
- declare function isFromRef(value: unknown): value is {
3858
- [FROM_REF]: React$1.RefObject<any>;
3859
- };
3814
+ declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
3860
3815
 
3861
3816
  /**
3862
3817
  * Symbol marker for mount-only method calls.
@@ -3883,7 +3838,15 @@ declare const ONCE: unique symbol;
3883
3838
  * // No arguments
3884
3839
  * <geometry center={once()} />
3885
3840
  */
3886
- declare function once<T>(...args: T[]): T;
3841
+ declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
3842
+ /**
3843
+ * What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
3844
+ * the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
3845
+ * methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
3846
+ *
3847
+ * The runtime value is always the marker object; only the declared type follows the prop.
3848
+ */
3849
+ type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
3887
3850
  /**
3888
3851
  * Type guard to check if a value is a once marker.
3889
3852
  *
@@ -3901,4 +3864,4 @@ declare function isOnce(value: unknown): value is {
3901
3864
  declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
3902
3865
 
3903
3866
  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, Texture, _roots, 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, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
3904
- export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
3867
+ export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, FromRefMarker, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };