@react-three/fiber 10.0.0-canary.6eb9584 → 10.0.0-canary.777b94d
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/extension.cjs +278 -0
- package/dist/extension.d.cts +629 -0
- package/dist/extension.d.mts +629 -0
- package/dist/extension.d.ts +629 -0
- package/dist/extension.mjs +258 -0
- package/dist/index.cjs +885 -795
- package/dist/index.d.cts +159 -317
- package/dist/index.d.mts +159 -317
- package/dist/index.d.ts +158 -344
- package/dist/index.mjs +886 -798
- package/dist/legacy.cjs +901 -807
- package/dist/legacy.d.cts +179 -366
- package/dist/legacy.d.mts +179 -366
- package/dist/legacy.d.ts +179 -392
- package/dist/legacy.mjs +902 -810
- package/dist/webgpu/index.cjs +558 -1297
- package/dist/webgpu/index.d.cts +165 -661
- package/dist/webgpu/index.d.mts +165 -661
- package/dist/webgpu/index.d.ts +164 -688
- package/dist/webgpu/index.mjs +559 -1282
- package/package.json +7 -2
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
|
-
import * as
|
|
3
|
-
import { CubeRenderTarget, RenderTarget, WebGPURenderer,
|
|
2
|
+
import * as webgpu from 'three/webgpu';
|
|
3
|
+
import { CubeRenderTarget, RenderTarget, WebGPURenderer, 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
|
|
|
@@ -328,68 +300,6 @@ type FrameNextCallback = FrameCallback$1<RootState>
|
|
|
328
300
|
/** Alias for FrameNextCallback */
|
|
329
301
|
type FrameCallback = FrameNextCallback
|
|
330
302
|
|
|
331
|
-
//* Buffer Types (useBuffers) ========================================
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Buffer-like types for GPU compute and storage operations.
|
|
335
|
-
* Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
|
|
336
|
-
*
|
|
337
|
-
* @example
|
|
338
|
-
* ```tsx
|
|
339
|
-
* const { positions, velocities } = useBuffers(() => ({
|
|
340
|
-
* positions: instancedArray(count, 'vec3'), // StorageBufferNode
|
|
341
|
-
* velocities: new Float32Array(count * 3), // TypedArray
|
|
342
|
-
* }), 'particles')
|
|
343
|
-
* ```
|
|
344
|
-
*/
|
|
345
|
-
type BufferLike =
|
|
346
|
-
| Float32Array
|
|
347
|
-
| Uint32Array
|
|
348
|
-
| Int32Array
|
|
349
|
-
| Float64Array
|
|
350
|
-
| Uint8Array
|
|
351
|
-
| Int8Array
|
|
352
|
-
| Uint16Array
|
|
353
|
-
| Int16Array
|
|
354
|
-
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
355
|
-
| Node // TSL buffer nodes (instancedArray, storage)
|
|
356
|
-
|
|
357
|
-
/** Flat record of buffer-like values (no nested scopes) */
|
|
358
|
-
type BufferRecord = Record<string, BufferLike>
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Buffer store that can contain both root-level buffers and scoped buffer objects.
|
|
362
|
-
* Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
|
|
363
|
-
*/
|
|
364
|
-
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
365
|
-
|
|
366
|
-
//* Storage Types (useGPUStorage) ========================================
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* GPU storage types for texture-based storage operations.
|
|
370
|
-
* Includes Three.js storage textures and TSL storage texture nodes.
|
|
371
|
-
*
|
|
372
|
-
* @example
|
|
373
|
-
* ```tsx
|
|
374
|
-
* const { heightMap } = useGPUStorage(() => ({
|
|
375
|
-
* heightMap: new StorageTexture(512, 512),
|
|
376
|
-
* }), 'terrain')
|
|
377
|
-
* ```
|
|
378
|
-
*/
|
|
379
|
-
type StorageLike =
|
|
380
|
-
| StorageTexture // GPU storage texture
|
|
381
|
-
| Data3DTexture // 3D texture (can be used as storage)
|
|
382
|
-
| Node // TSL storage texture nodes (storageTexture)
|
|
383
|
-
|
|
384
|
-
/** Flat record of storage-like values (no nested scopes) */
|
|
385
|
-
type StorageRecord = Record<string, StorageLike>
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Storage store that can contain both root-level storage and scoped storage objects.
|
|
389
|
-
* Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
|
|
390
|
-
*/
|
|
391
|
-
type StorageStore = Record<string, StorageLike | StorageRecord>
|
|
392
|
-
|
|
393
303
|
//* Renderer Types ========================================
|
|
394
304
|
|
|
395
305
|
/** Default renderer type - union of WebGL and WebGPU renderers */
|
|
@@ -489,6 +399,12 @@ interface InternalState {
|
|
|
489
399
|
actualRenderer: R3FRenderer
|
|
490
400
|
/** Global scheduler reference (for useFrame hook) */
|
|
491
401
|
scheduler: SchedulerApi | null
|
|
402
|
+
/**
|
|
403
|
+
* Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
|
|
404
|
+
* `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
|
|
405
|
+
* render-phase takeover. Used by `useRenderPipeline`.
|
|
406
|
+
*/
|
|
407
|
+
renderOverride?: (() => void) | null
|
|
492
408
|
/** This root's unique ID in the global scheduler */
|
|
493
409
|
rootId?: string
|
|
494
410
|
/** Function to unregister this root from the global scheduler */
|
|
@@ -496,11 +412,28 @@ interface InternalState {
|
|
|
496
412
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
497
413
|
container?: THREE$1.Object3D
|
|
498
414
|
/**
|
|
499
|
-
* CanvasTarget
|
|
500
|
-
*
|
|
415
|
+
* The CanvasTarget this root sizes and renders through.
|
|
416
|
+
*
|
|
417
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
418
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
419
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
420
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
421
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
501
422
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
502
423
|
*/
|
|
503
424
|
canvasTarget?: CanvasTarget
|
|
425
|
+
/**
|
|
426
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
427
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
428
|
+
*
|
|
429
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
430
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
431
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
432
|
+
* invalidate some other canvas's descriptor instead.
|
|
433
|
+
*
|
|
434
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
435
|
+
*/
|
|
436
|
+
canvasTargetSizeDirty?: boolean
|
|
504
437
|
/**
|
|
505
438
|
* Whether multi-canvas rendering is active.
|
|
506
439
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -539,12 +472,13 @@ interface RootState {
|
|
|
539
472
|
/** Get current state */
|
|
540
473
|
get: StoreApi<RootState>['getState']
|
|
541
474
|
/**
|
|
542
|
-
*
|
|
475
|
+
* The store of the canvas that owns this root's renderer.
|
|
543
476
|
* - For primary/independent canvases: points to its own store (self-reference)
|
|
544
477
|
* - For secondary canvases: points to the primary canvas's store
|
|
478
|
+
* - Portals copy it from their parent
|
|
545
479
|
*
|
|
546
|
-
*
|
|
547
|
-
*
|
|
480
|
+
* Anything shared per renderer rather than per canvas (e.g. @react-three/tsl's resources)
|
|
481
|
+
* resolves through it.
|
|
548
482
|
*/
|
|
549
483
|
primaryStore: RootStore
|
|
550
484
|
/** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
|
|
@@ -607,24 +541,10 @@ interface RootState {
|
|
|
607
541
|
setError: (error: Error | null) => void
|
|
608
542
|
/** Current error state (null when no error) */
|
|
609
543
|
error: Error | null
|
|
610
|
-
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
611
|
-
uniforms: UniformStore
|
|
612
|
-
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
613
|
-
nodes: Record<string, any>
|
|
614
|
-
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
615
|
-
buffers: BufferStore
|
|
616
|
-
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
617
|
-
gpuStorage: StorageStore
|
|
618
544
|
/** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
|
|
619
545
|
textures: Map<string, THREE$1.Texture>
|
|
620
546
|
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
621
547
|
_textureRefs: Map<string, number>
|
|
622
|
-
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
623
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
624
|
-
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
625
|
-
passes: Record<string, any>
|
|
626
|
-
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
627
|
-
_hmrVersion: number
|
|
628
548
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
629
549
|
_sizeImperative: boolean
|
|
630
550
|
/** Internal: stored size props from Canvas for reset functionality */
|
|
@@ -710,12 +630,19 @@ type DefaultRendererProps = {
|
|
|
710
630
|
*/
|
|
711
631
|
interface CanvasSchedulerConfig {
|
|
712
632
|
/**
|
|
713
|
-
*
|
|
714
|
-
|
|
633
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
634
|
+
*/
|
|
635
|
+
before?: string | string[]
|
|
636
|
+
/**
|
|
637
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
638
|
+
*/
|
|
639
|
+
after?: string | string[]
|
|
640
|
+
/**
|
|
641
|
+
* Numeric root order. Lower values run first.
|
|
715
642
|
*/
|
|
716
|
-
|
|
643
|
+
order?: number
|
|
717
644
|
/**
|
|
718
|
-
* Limit this
|
|
645
|
+
* Limit this Canvas's default render job (frames per second).
|
|
719
646
|
*/
|
|
720
647
|
fps?: number
|
|
721
648
|
}
|
|
@@ -802,14 +729,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
802
729
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
803
730
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
804
731
|
dpr?: Dpr
|
|
805
|
-
/**
|
|
806
|
-
|
|
732
|
+
/**
|
|
733
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
734
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
735
|
+
*/
|
|
736
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
807
737
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
808
738
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
809
739
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
810
740
|
camera?: CameraProps
|
|
811
741
|
/** An R3F event manager to manage elements' pointer events */
|
|
812
|
-
events?: (store: RootStore) => EventManager<
|
|
742
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
813
743
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
814
744
|
onCreated?: (state: RootState) => void
|
|
815
745
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -898,7 +828,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
898
828
|
object?: T
|
|
899
829
|
dispose?: null
|
|
900
830
|
attach?: AttachType<T>
|
|
901
|
-
onUpdate?: (self: T) => void
|
|
902
831
|
}
|
|
903
832
|
|
|
904
833
|
interface Instance<O = any> {
|
|
@@ -1038,7 +967,7 @@ interface CanvasProps
|
|
|
1038
967
|
*/
|
|
1039
968
|
resize?: Options
|
|
1040
969
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1041
|
-
eventSource?:
|
|
970
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1042
971
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1043
972
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1044
973
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1146,202 +1075,6 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1146
1075
|
|
|
1147
1076
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1148
1077
|
|
|
1149
|
-
//* Global Types ==============================
|
|
1150
|
-
|
|
1151
|
-
declare global {
|
|
1152
|
-
/**
|
|
1153
|
-
* Uniform node type.
|
|
1154
|
-
*
|
|
1155
|
-
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1156
|
-
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1157
|
-
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1158
|
-
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1159
|
-
* arity when three made `UniformNode` two-parameter.
|
|
1160
|
-
*
|
|
1161
|
-
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1162
|
-
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1163
|
-
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1164
|
-
* installed three instead of needing to be mirrored by hand.
|
|
1165
|
-
*/
|
|
1166
|
-
type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
|
|
1167
|
-
|
|
1168
|
-
/**
|
|
1169
|
-
* ShaderCallable - the return type of Fn()
|
|
1170
|
-
* A callable shader function node that can be invoked with parameters.
|
|
1171
|
-
* The function returns a ShaderNodeObject when called.
|
|
1172
|
-
*
|
|
1173
|
-
* @example
|
|
1174
|
-
* ```tsx
|
|
1175
|
-
* // Define a shader function
|
|
1176
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1177
|
-
* return mix(color1, color2, factor)
|
|
1178
|
-
* })
|
|
1179
|
-
*
|
|
1180
|
-
* // Type when retrieving from nodes store
|
|
1181
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1182
|
-
*
|
|
1183
|
-
* // Or with specific return type
|
|
1184
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1185
|
-
* ```
|
|
1186
|
-
*/
|
|
1187
|
-
type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
|
|
1188
|
-
|
|
1189
|
-
/**
|
|
1190
|
-
* ShaderNodeRef - a ShaderNodeObject wrapper around a Node
|
|
1191
|
-
* This is the common return type for TSL operations (add, mul, sin, etc.)
|
|
1192
|
-
*
|
|
1193
|
-
* @example
|
|
1194
|
-
* ```tsx
|
|
1195
|
-
* const { wobble } = nodes as { wobble: ShaderNodeRef }
|
|
1196
|
-
* ```
|
|
1197
|
-
*/
|
|
1198
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
* TSLNodeType - Union of all common TSL node types
|
|
1202
|
-
* Used by ScopedStore to properly type node access from the store.
|
|
1203
|
-
*
|
|
1204
|
-
* Includes:
|
|
1205
|
-
* - Node: base Three.js node type
|
|
1206
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1207
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1208
|
-
*
|
|
1209
|
-
* @example
|
|
1210
|
-
* ```tsx
|
|
1211
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1212
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1213
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1214
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1215
|
-
* }))
|
|
1216
|
-
*
|
|
1217
|
-
* // Can narrow with type guard or assertion when needed
|
|
1218
|
-
* if (typeof blendColorFn === 'function') {
|
|
1219
|
-
* blendColorFn(someColor, 0.5)
|
|
1220
|
-
* }
|
|
1221
|
-
* ```
|
|
1222
|
-
*/
|
|
1223
|
-
type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
|
|
1224
|
-
|
|
1225
|
-
/** Flat record of uniform nodes (no nested scopes) */
|
|
1226
|
-
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
1227
|
-
|
|
1228
|
-
/**
|
|
1229
|
-
* Uniform store that can contain both root-level uniforms and scoped uniform objects
|
|
1230
|
-
* Used by state.uniforms which has structure like:
|
|
1231
|
-
* { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
|
|
1232
|
-
*/
|
|
1233
|
-
type UniformStore = Record<string, UniformNode | UniformRecord>
|
|
1234
|
-
|
|
1235
|
-
/**
|
|
1236
|
-
* Helper to safely access a uniform node from the store.
|
|
1237
|
-
* Use this when accessing state.uniforms to get proper typing.
|
|
1238
|
-
* @example
|
|
1239
|
-
* const uTime = uniforms.uTime as UniformNode<number>
|
|
1240
|
-
* const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
|
|
1241
|
-
*/
|
|
1242
|
-
type GetUniform<T = unknown> = UniformNode<T>
|
|
1243
|
-
|
|
1244
|
-
/**
|
|
1245
|
-
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1246
|
-
* Supports:
|
|
1247
|
-
* - Primitives: number, string (color), boolean
|
|
1248
|
-
* - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
|
|
1249
|
-
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1250
|
-
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1251
|
-
* - UniformNode: existing uniforms (reused as-is)
|
|
1252
|
-
*/
|
|
1253
|
-
type UniformValue =
|
|
1254
|
-
| number
|
|
1255
|
-
| string
|
|
1256
|
-
| boolean
|
|
1257
|
-
| three_webgpu.Color
|
|
1258
|
-
| three_webgpu.Vector2
|
|
1259
|
-
| three_webgpu.Vector3
|
|
1260
|
-
| three_webgpu.Vector4
|
|
1261
|
-
| three_webgpu.Matrix3
|
|
1262
|
-
| three_webgpu.Matrix4
|
|
1263
|
-
| three_webgpu.Euler
|
|
1264
|
-
| three_webgpu.Quaternion
|
|
1265
|
-
| { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
|
|
1266
|
-
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1267
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1268
|
-
| UniformNode
|
|
1269
|
-
|
|
1270
|
-
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1271
|
-
type UniformInputRecord = Record<string, UniformValue>
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
//* Module Augmentation ==============================
|
|
1275
|
-
|
|
1276
|
-
declare module 'three/tsl' {
|
|
1277
|
-
/**
|
|
1278
|
-
* Fn with array parameter destructuring
|
|
1279
|
-
* @example Fn(([uv, skew]) => { ... })
|
|
1280
|
-
*/
|
|
1281
|
-
export function Fn<R extends Node = Node>(
|
|
1282
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1283
|
-
): ShaderCallable<R>
|
|
1284
|
-
|
|
1285
|
-
/**
|
|
1286
|
-
* Fn with object parameter destructuring
|
|
1287
|
-
* @example Fn(({ color, intensity }) => { ... })
|
|
1288
|
-
*/
|
|
1289
|
-
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1290
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1291
|
-
): ShaderCallable<R>
|
|
1292
|
-
|
|
1293
|
-
/**
|
|
1294
|
-
* Fn with array params + layout
|
|
1295
|
-
* @example Fn(([a, b]) => { ... }, { layout: [...] })
|
|
1296
|
-
*/
|
|
1297
|
-
export function Fn<R extends Node = Node>(
|
|
1298
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1299
|
-
layout: { layout?: unknown },
|
|
1300
|
-
): ShaderCallable<R>
|
|
1301
|
-
|
|
1302
|
-
/**
|
|
1303
|
-
* Fn with object params + layout
|
|
1304
|
-
*/
|
|
1305
|
-
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1306
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1307
|
-
layout: { layout?: unknown },
|
|
1308
|
-
): ShaderCallable<R>
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
declare global {
|
|
1312
|
-
/**
|
|
1313
|
-
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1314
|
-
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1315
|
-
* is r185, so the new name is the only one.
|
|
1316
|
-
*/
|
|
1317
|
-
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1318
|
-
|
|
1319
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1320
|
-
type PassRecord = Record<string, any>
|
|
1321
|
-
|
|
1322
|
-
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1323
|
-
type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
|
|
1324
|
-
|
|
1325
|
-
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1326
|
-
type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
|
|
1327
|
-
|
|
1328
|
-
/** Return type for useRenderPipeline hook */
|
|
1329
|
-
interface UseRenderPipelineReturn {
|
|
1330
|
-
/** Current passes from state */
|
|
1331
|
-
passes: PassRecord
|
|
1332
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1333
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1334
|
-
/** Clear all passes from state */
|
|
1335
|
-
clearPasses: () => void
|
|
1336
|
-
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1337
|
-
reset: () => void
|
|
1338
|
-
/** Re-run setup/main callbacks with current closure values */
|
|
1339
|
-
rebuild: () => void
|
|
1340
|
-
/** True when RenderPipeline is configured and ready */
|
|
1341
|
-
isReady: boolean
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
1078
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
1346
1079
|
|
|
1347
1080
|
interface MathRepresentation {
|
|
@@ -1418,10 +1151,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1418
1151
|
|
|
1419
1152
|
/**
|
|
1420
1153
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1421
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1154
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1155
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1422
1156
|
*/
|
|
1423
1157
|
type NodeProps<P> = {
|
|
1424
|
-
[K in keyof P as P[K] extends
|
|
1158
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1425
1159
|
}
|
|
1426
1160
|
|
|
1427
1161
|
interface ReactProps<P> {
|
|
@@ -1442,11 +1176,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1442
1176
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1443
1177
|
}
|
|
1444
1178
|
|
|
1179
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1180
|
+
type Object3DMethod = NonNullable<
|
|
1181
|
+
{
|
|
1182
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1183
|
+
}[keyof Object3D]
|
|
1184
|
+
>
|
|
1185
|
+
|
|
1445
1186
|
type ThreeExports = typeof import('three') & typeof import('three/webgpu')
|
|
1446
1187
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1447
1188
|
|
|
1448
1189
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1449
|
-
|
|
1190
|
+
/**
|
|
1191
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1192
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1193
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1194
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1195
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1196
|
+
*/
|
|
1197
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1198
|
+
object: object
|
|
1199
|
+
ref?: React.Ref<any>
|
|
1200
|
+
[prop: string]: unknown
|
|
1201
|
+
}
|
|
1450
1202
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1451
1203
|
threeAudio: ThreeElementsImpl['audio']
|
|
1452
1204
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1487,6 +1239,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1487
1239
|
type three_d_Matrix4 = Matrix4;
|
|
1488
1240
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1489
1241
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1242
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1490
1243
|
type three_d_Quaternion = Quaternion;
|
|
1491
1244
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1492
1245
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1501,7 +1254,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1501
1254
|
type three_d_Vector4 = Vector4;
|
|
1502
1255
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1503
1256
|
declare namespace three_d {
|
|
1504
|
-
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 };
|
|
1257
|
+
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 };
|
|
1505
1258
|
}
|
|
1506
1259
|
|
|
1507
1260
|
/**
|
|
@@ -1850,7 +1603,48 @@ declare function createEvents(store: RootStore): {
|
|
|
1850
1603
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1851
1604
|
};
|
|
1852
1605
|
/** Default R3F event manager for web */
|
|
1853
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1606
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1607
|
+
|
|
1608
|
+
interface RootExtension {
|
|
1609
|
+
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
1610
|
+
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
1611
|
+
name: string;
|
|
1612
|
+
/**
|
|
1613
|
+
* Called once per root, after its renderer exists and before `onCreated` and the first frame.
|
|
1614
|
+
* `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
|
|
1615
|
+
* to the primary canvas. Return fields to merge into the root's state, or nothing.
|
|
1616
|
+
*/
|
|
1617
|
+
setup?(store: RootStore): Partial<RootState> | void;
|
|
1618
|
+
/** Called when a root this extension set up unmounts. */
|
|
1619
|
+
dispose?(store: RootStore): void;
|
|
1620
|
+
/** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
|
|
1621
|
+
hmr?(store: RootStore): void;
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* Register an extension. It is set up on every live root immediately, and on every root created
|
|
1625
|
+
* afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
|
|
1626
|
+
* it already set up keep its state and still get its dispose when they unmount.
|
|
1627
|
+
*/
|
|
1628
|
+
declare function registerRootExtension(extension: RootExtension): () => void;
|
|
1629
|
+
/**
|
|
1630
|
+
* Point a root's default render job at a different render function, or back at
|
|
1631
|
+
* `renderer.render(scene, camera)` with `null`.
|
|
1632
|
+
*
|
|
1633
|
+
* The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
|
|
1634
|
+
* boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
|
|
1635
|
+
*/
|
|
1636
|
+
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
1637
|
+
|
|
1638
|
+
/**
|
|
1639
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
1640
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
1641
|
+
*/
|
|
1642
|
+
declare function useStore(): RootStore;
|
|
1643
|
+
/**
|
|
1644
|
+
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1645
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1646
|
+
*/
|
|
1647
|
+
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
1854
1648
|
|
|
1855
1649
|
/**
|
|
1856
1650
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -1883,7 +1677,7 @@ declare namespace useLoader {
|
|
|
1883
1677
|
*
|
|
1884
1678
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1885
1679
|
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1886
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1680
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
1887
1681
|
*
|
|
1888
1682
|
* @example
|
|
1889
1683
|
* // Simple priority (backwards compat)
|
|
@@ -2094,16 +1888,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
|
|
|
2094
1888
|
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
|
|
2095
1889
|
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
|
|
2096
1890
|
|
|
2097
|
-
/**
|
|
2098
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2099
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2100
|
-
*/
|
|
2101
|
-
declare function useStore(): RootStore;
|
|
2102
|
-
/**
|
|
2103
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2104
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2105
|
-
*/
|
|
2106
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2107
1891
|
/**
|
|
2108
1892
|
* Exposes an object's {@link Instance}.
|
|
2109
1893
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2179,7 +1963,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2179
1963
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2180
1964
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2181
1965
|
*
|
|
2182
|
-
*
|
|
1966
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
1967
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
1968
|
+
*
|
|
1969
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2183
1970
|
* @param frames - Number of frames to request (default: 1)
|
|
2184
1971
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2185
1972
|
*
|
|
@@ -2190,14 +1977,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2190
1977
|
* Advances the frameloop and runs render effects.
|
|
2191
1978
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2192
1979
|
*
|
|
1980
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
1981
|
+
* registered root is stepped for backwards compatibility.
|
|
1982
|
+
*
|
|
2193
1983
|
* @param timestamp - The timestamp to use for this frame
|
|
2194
1984
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2195
|
-
* @param state -
|
|
2196
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
1985
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2197
1986
|
*
|
|
2198
1987
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2199
1988
|
*/
|
|
2200
|
-
declare function advance(timestamp: number): void;
|
|
1989
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2201
1990
|
|
|
2202
1991
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2203
1992
|
declare function ReactReconciler<
|
|
@@ -3242,6 +3031,7 @@ declare namespace ReactReconciler {
|
|
|
3242
3031
|
|
|
3243
3032
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3244
3033
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3034
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3245
3035
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3246
3036
|
|
|
3247
3037
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3266,6 +3056,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
3266
3056
|
declare function flushSync<R>(fn: () => R): R;
|
|
3267
3057
|
|
|
3268
3058
|
declare const context: React$1.Context<RootStore>;
|
|
3059
|
+
|
|
3269
3060
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3270
3061
|
|
|
3271
3062
|
/**
|
|
@@ -3519,7 +3310,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
3519
3310
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
3520
3311
|
/**
|
|
3521
3312
|
* Triggers an update for an instance.
|
|
3522
|
-
*
|
|
3313
|
+
* Invalidates the frame if the root is in demand mode.
|
|
3523
3314
|
*
|
|
3524
3315
|
* @param instance - Instance to invalidate
|
|
3525
3316
|
*/
|
|
@@ -3685,29 +3476,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3685
3476
|
* Used to identify values that should be resolved from refs after mount.
|
|
3686
3477
|
*/
|
|
3687
3478
|
declare const FROM_REF: unique symbol;
|
|
3479
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3480
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3481
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3482
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3483
|
+
transform?: (value: T) => R;
|
|
3484
|
+
}
|
|
3688
3485
|
/**
|
|
3689
3486
|
* Defers prop application until the referenced object is available.
|
|
3690
3487
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3691
3488
|
*
|
|
3489
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3490
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3491
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3492
|
+
* what gets assigned.
|
|
3493
|
+
*
|
|
3692
3494
|
* @param ref - React ref object to resolve at mount time
|
|
3693
|
-
* @
|
|
3495
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3496
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3694
3497
|
*
|
|
3695
3498
|
* @example
|
|
3696
3499
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3697
3500
|
*
|
|
3698
3501
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3699
3502
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3503
|
+
*
|
|
3504
|
+
* @example
|
|
3505
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3506
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3700
3507
|
*/
|
|
3701
3508
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3509
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3702
3510
|
/**
|
|
3703
3511
|
* Type guard to check if a value is a fromRef marker.
|
|
3704
3512
|
*
|
|
3705
3513
|
* @param value - Value to check
|
|
3706
3514
|
* @returns True if value is a fromRef marker
|
|
3707
3515
|
*/
|
|
3708
|
-
declare function isFromRef(value: unknown): value is
|
|
3709
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3710
|
-
};
|
|
3516
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3711
3517
|
|
|
3712
3518
|
/**
|
|
3713
3519
|
* Symbol marker for mount-only method calls.
|
|
@@ -3734,7 +3540,15 @@ declare const ONCE: unique symbol;
|
|
|
3734
3540
|
* // No arguments
|
|
3735
3541
|
* <geometry center={once()} />
|
|
3736
3542
|
*/
|
|
3737
|
-
declare function once<
|
|
3543
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3544
|
+
/**
|
|
3545
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3546
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3547
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3548
|
+
*
|
|
3549
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3550
|
+
*/
|
|
3551
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3738
3552
|
/**
|
|
3739
3553
|
* Type guard to check if a value is a once marker.
|
|
3740
3554
|
*
|
|
@@ -3751,5 +3565,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
3751
3565
|
*/
|
|
3752
3566
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3753
3567
|
|
|
3754
|
-
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 };
|
|
3755
|
-
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge,
|
|
3568
|
+
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, registerRootExtension, removeInteractivity, resolve, setRenderOverride, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3569
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, 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, NodeProps, 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, RootExtension, RootState, RootStore, SetBlock, Size, 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 };
|