@react-three/fiber 10.0.0-canary.76d2134 → 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 +2803 -2706
- package/dist/index.d.cts +168 -322
- package/dist/index.d.mts +168 -322
- package/dist/index.d.ts +165 -347
- package/dist/index.mjs +2575 -2480
- package/dist/legacy.cjs +2558 -2462
- package/dist/legacy.d.cts +187 -374
- package/dist/legacy.d.mts +187 -374
- package/dist/legacy.d.ts +185 -398
- package/dist/legacy.mjs +2825 -2731
- package/dist/webgpu/index.cjs +2595 -3321
- package/dist/webgpu/index.d.cts +189 -713
- package/dist/webgpu/index.d.mts +189 -713
- package/dist/webgpu/index.d.ts +186 -738
- package/dist/webgpu/index.mjs +2592 -3302
- package/package.json +9 -4
- package/readme.md +1 -1
- package/react-reconciler/constants.d.ts +0 -7
- package/react-reconciler/constants.js +0 -1
- package/react-reconciler/index.d.ts +0 -1044
- package/react-reconciler/index.js +0 -208
package/dist/webgpu/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
|
|
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, WebGPURendererParameters } from 'three/webgpu';
|
|
3
4
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
4
5
|
import * as THREE$1 from 'three';
|
|
5
6
|
import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
@@ -11,7 +12,6 @@ import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFr
|
|
|
11
12
|
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
12
13
|
import { Options } from 'react-use-measure';
|
|
13
14
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
14
|
-
import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
|
|
15
15
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
16
16
|
|
|
17
17
|
function _mergeNamespaces(n, m) {
|
|
@@ -41,6 +41,8 @@ function _mergeNamespaces(n, m) {
|
|
|
41
41
|
declare const R3F_BUILD_LEGACY = false;
|
|
42
42
|
declare const R3F_BUILD_WEBGPU = true;
|
|
43
43
|
|
|
44
|
+
/** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
|
|
45
|
+
declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
|
|
44
46
|
declare const WebGLRenderer: {
|
|
45
47
|
new (): {};
|
|
46
48
|
};
|
|
@@ -62,8 +64,9 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
62
64
|
WebGLRenderTarget: WebGLRenderTarget,
|
|
63
65
|
WebGLRenderer: WebGLRenderer,
|
|
64
66
|
WebGLRendererParameters: WebGLRendererParameters,
|
|
65
|
-
WebGLShadowMap: WebGLShadowMap
|
|
66
|
-
|
|
67
|
+
WebGLShadowMap: WebGLShadowMap,
|
|
68
|
+
loadInspector: loadInspector
|
|
69
|
+
}, [webgpu]);
|
|
67
70
|
|
|
68
71
|
//* Utility Types ==============================
|
|
69
72
|
|
|
@@ -327,68 +330,6 @@ type FrameNextCallback = FrameCallback$1<RootState>
|
|
|
327
330
|
/** Alias for FrameNextCallback */
|
|
328
331
|
type FrameCallback = FrameNextCallback
|
|
329
332
|
|
|
330
|
-
//* Buffer Types (useBuffers) ========================================
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Buffer-like types for GPU compute and storage operations.
|
|
334
|
-
* Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* ```tsx
|
|
338
|
-
* const { positions, velocities } = useBuffers(() => ({
|
|
339
|
-
* positions: instancedArray(count, 'vec3'), // StorageBufferNode
|
|
340
|
-
* velocities: new Float32Array(count * 3), // TypedArray
|
|
341
|
-
* }), 'particles')
|
|
342
|
-
* ```
|
|
343
|
-
*/
|
|
344
|
-
type BufferLike =
|
|
345
|
-
| Float32Array
|
|
346
|
-
| Uint32Array
|
|
347
|
-
| Int32Array
|
|
348
|
-
| Float64Array
|
|
349
|
-
| Uint8Array
|
|
350
|
-
| Int8Array
|
|
351
|
-
| Uint16Array
|
|
352
|
-
| Int16Array
|
|
353
|
-
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
354
|
-
| Node // TSL buffer nodes (instancedArray, storage)
|
|
355
|
-
|
|
356
|
-
/** Flat record of buffer-like values (no nested scopes) */
|
|
357
|
-
type BufferRecord = Record<string, BufferLike>
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Buffer store that can contain both root-level buffers and scoped buffer objects.
|
|
361
|
-
* Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
|
|
362
|
-
*/
|
|
363
|
-
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
364
|
-
|
|
365
|
-
//* Storage Types (useGPUStorage) ========================================
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* GPU storage types for texture-based storage operations.
|
|
369
|
-
* Includes Three.js storage textures and TSL storage texture nodes.
|
|
370
|
-
*
|
|
371
|
-
* @example
|
|
372
|
-
* ```tsx
|
|
373
|
-
* const { heightMap } = useGPUStorage(() => ({
|
|
374
|
-
* heightMap: new StorageTexture(512, 512),
|
|
375
|
-
* }), 'terrain')
|
|
376
|
-
* ```
|
|
377
|
-
*/
|
|
378
|
-
type StorageLike =
|
|
379
|
-
| StorageTexture // GPU storage texture
|
|
380
|
-
| Data3DTexture // 3D texture (can be used as storage)
|
|
381
|
-
| Node // TSL storage texture nodes (storageTexture)
|
|
382
|
-
|
|
383
|
-
/** Flat record of storage-like values (no nested scopes) */
|
|
384
|
-
type StorageRecord = Record<string, StorageLike>
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Storage store that can contain both root-level storage and scoped storage objects.
|
|
388
|
-
* Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
|
|
389
|
-
*/
|
|
390
|
-
type StorageStore = Record<string, StorageLike | StorageRecord>
|
|
391
|
-
|
|
392
333
|
//* Renderer Types ========================================
|
|
393
334
|
|
|
394
335
|
/** Default renderer type - union of WebGL and WebGPU renderers */
|
|
@@ -488,6 +429,12 @@ interface InternalState {
|
|
|
488
429
|
actualRenderer: R3FRenderer
|
|
489
430
|
/** Global scheduler reference (for useFrame hook) */
|
|
490
431
|
scheduler: SchedulerApi | null
|
|
432
|
+
/**
|
|
433
|
+
* Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
|
|
434
|
+
* `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
|
|
435
|
+
* render-phase takeover. Used by `useRenderPipeline`.
|
|
436
|
+
*/
|
|
437
|
+
renderOverride?: (() => void) | null
|
|
491
438
|
/** This root's unique ID in the global scheduler */
|
|
492
439
|
rootId?: string
|
|
493
440
|
/** Function to unregister this root from the global scheduler */
|
|
@@ -495,11 +442,28 @@ interface InternalState {
|
|
|
495
442
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
496
443
|
container?: THREE$1.Object3D
|
|
497
444
|
/**
|
|
498
|
-
* CanvasTarget
|
|
499
|
-
*
|
|
445
|
+
* The CanvasTarget this root sizes and renders through.
|
|
446
|
+
*
|
|
447
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
448
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
449
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
450
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
451
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
500
452
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
501
453
|
*/
|
|
502
454
|
canvasTarget?: CanvasTarget
|
|
455
|
+
/**
|
|
456
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
457
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
458
|
+
*
|
|
459
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
460
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
461
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
462
|
+
* invalidate some other canvas's descriptor instead.
|
|
463
|
+
*
|
|
464
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
465
|
+
*/
|
|
466
|
+
canvasTargetSizeDirty?: boolean
|
|
503
467
|
/**
|
|
504
468
|
* Whether multi-canvas rendering is active.
|
|
505
469
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -538,12 +502,13 @@ interface RootState {
|
|
|
538
502
|
/** Get current state */
|
|
539
503
|
get: StoreApi<RootState>['getState']
|
|
540
504
|
/**
|
|
541
|
-
*
|
|
505
|
+
* The store of the canvas that owns this root's renderer.
|
|
542
506
|
* - For primary/independent canvases: points to its own store (self-reference)
|
|
543
507
|
* - For secondary canvases: points to the primary canvas's store
|
|
508
|
+
* - Portals copy it from their parent
|
|
544
509
|
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
510
|
+
* Anything shared per renderer rather than per canvas (e.g. @react-three/tsl's resources)
|
|
511
|
+
* resolves through it.
|
|
547
512
|
*/
|
|
548
513
|
primaryStore: RootStore
|
|
549
514
|
/** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
|
|
@@ -606,24 +571,10 @@ interface RootState {
|
|
|
606
571
|
setError: (error: Error | null) => void
|
|
607
572
|
/** Current error state (null when no error) */
|
|
608
573
|
error: Error | null
|
|
609
|
-
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
610
|
-
uniforms: UniformStore
|
|
611
|
-
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
612
|
-
nodes: Record<string, any>
|
|
613
|
-
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
614
|
-
buffers: BufferStore
|
|
615
|
-
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
616
|
-
gpuStorage: StorageStore
|
|
617
574
|
/** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
|
|
618
575
|
textures: Map<string, THREE$1.Texture>
|
|
619
576
|
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
620
577
|
_textureRefs: Map<string, number>
|
|
621
|
-
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
622
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
623
|
-
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
624
|
-
passes: Record<string, any>
|
|
625
|
-
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
626
|
-
_hmrVersion: number
|
|
627
578
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
628
579
|
_sizeImperative: boolean
|
|
629
580
|
/** Internal: stored size props from Canvas for reset functionality */
|
|
@@ -709,12 +660,19 @@ type DefaultRendererProps = {
|
|
|
709
660
|
*/
|
|
710
661
|
interface CanvasSchedulerConfig {
|
|
711
662
|
/**
|
|
712
|
-
*
|
|
713
|
-
|
|
663
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
664
|
+
*/
|
|
665
|
+
before?: string | string[]
|
|
666
|
+
/**
|
|
667
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
714
668
|
*/
|
|
715
|
-
after?: string
|
|
669
|
+
after?: string | string[]
|
|
716
670
|
/**
|
|
717
|
-
*
|
|
671
|
+
* Numeric root order. Lower values run first.
|
|
672
|
+
*/
|
|
673
|
+
order?: number
|
|
674
|
+
/**
|
|
675
|
+
* Limit this Canvas's default render job (frames per second).
|
|
718
676
|
*/
|
|
719
677
|
fps?: number
|
|
720
678
|
}
|
|
@@ -801,14 +759,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
801
759
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
802
760
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
803
761
|
dpr?: Dpr
|
|
804
|
-
/**
|
|
805
|
-
|
|
762
|
+
/**
|
|
763
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
764
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
765
|
+
*/
|
|
766
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
806
767
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
807
768
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
808
769
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
809
770
|
camera?: CameraProps
|
|
810
771
|
/** An R3F event manager to manage elements' pointer events */
|
|
811
|
-
events?: (store: RootStore) => EventManager<
|
|
772
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
812
773
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
813
774
|
onCreated?: (state: RootState) => void
|
|
814
775
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -897,7 +858,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
897
858
|
object?: T
|
|
898
859
|
dispose?: null
|
|
899
860
|
attach?: AttachType<T>
|
|
900
|
-
onUpdate?: (self: T) => void
|
|
901
861
|
}
|
|
902
862
|
|
|
903
863
|
interface Instance<O = any> {
|
|
@@ -1037,7 +997,7 @@ interface CanvasProps
|
|
|
1037
997
|
*/
|
|
1038
998
|
resize?: Options
|
|
1039
999
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1040
|
-
eventSource?:
|
|
1000
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1041
1001
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1042
1002
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1043
1003
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1145,202 +1105,6 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1145
1105
|
|
|
1146
1106
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1147
1107
|
|
|
1148
|
-
//* Global Types ==============================
|
|
1149
|
-
|
|
1150
|
-
declare global {
|
|
1151
|
-
/**
|
|
1152
|
-
* Uniform node type.
|
|
1153
|
-
*
|
|
1154
|
-
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1155
|
-
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1156
|
-
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1157
|
-
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1158
|
-
* arity when three made `UniformNode` two-parameter.
|
|
1159
|
-
*
|
|
1160
|
-
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1161
|
-
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1162
|
-
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1163
|
-
* installed three instead of needing to be mirrored by hand.
|
|
1164
|
-
*/
|
|
1165
|
-
type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
|
|
1166
|
-
|
|
1167
|
-
/**
|
|
1168
|
-
* ShaderCallable - the return type of Fn()
|
|
1169
|
-
* A callable shader function node that can be invoked with parameters.
|
|
1170
|
-
* The function returns a ShaderNodeObject when called.
|
|
1171
|
-
*
|
|
1172
|
-
* @example
|
|
1173
|
-
* ```tsx
|
|
1174
|
-
* // Define a shader function
|
|
1175
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1176
|
-
* return mix(color1, color2, factor)
|
|
1177
|
-
* })
|
|
1178
|
-
*
|
|
1179
|
-
* // Type when retrieving from nodes store
|
|
1180
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1181
|
-
*
|
|
1182
|
-
* // Or with specific return type
|
|
1183
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1184
|
-
* ```
|
|
1185
|
-
*/
|
|
1186
|
-
type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
|
|
1187
|
-
|
|
1188
|
-
/**
|
|
1189
|
-
* ShaderNodeRef - a ShaderNodeObject wrapper around a Node
|
|
1190
|
-
* This is the common return type for TSL operations (add, mul, sin, etc.)
|
|
1191
|
-
*
|
|
1192
|
-
* @example
|
|
1193
|
-
* ```tsx
|
|
1194
|
-
* const { wobble } = nodes as { wobble: ShaderNodeRef }
|
|
1195
|
-
* ```
|
|
1196
|
-
*/
|
|
1197
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1198
|
-
|
|
1199
|
-
/**
|
|
1200
|
-
* TSLNodeType - Union of all common TSL node types
|
|
1201
|
-
* Used by ScopedStore to properly type node access from the store.
|
|
1202
|
-
*
|
|
1203
|
-
* Includes:
|
|
1204
|
-
* - Node: base Three.js node type
|
|
1205
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1206
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1207
|
-
*
|
|
1208
|
-
* @example
|
|
1209
|
-
* ```tsx
|
|
1210
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1211
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1212
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1213
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1214
|
-
* }))
|
|
1215
|
-
*
|
|
1216
|
-
* // Can narrow with type guard or assertion when needed
|
|
1217
|
-
* if (typeof blendColorFn === 'function') {
|
|
1218
|
-
* blendColorFn(someColor, 0.5)
|
|
1219
|
-
* }
|
|
1220
|
-
* ```
|
|
1221
|
-
*/
|
|
1222
|
-
type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
|
|
1223
|
-
|
|
1224
|
-
/** Flat record of uniform nodes (no nested scopes) */
|
|
1225
|
-
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
1226
|
-
|
|
1227
|
-
/**
|
|
1228
|
-
* Uniform store that can contain both root-level uniforms and scoped uniform objects
|
|
1229
|
-
* Used by state.uniforms which has structure like:
|
|
1230
|
-
* { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
|
|
1231
|
-
*/
|
|
1232
|
-
type UniformStore = Record<string, UniformNode | UniformRecord>
|
|
1233
|
-
|
|
1234
|
-
/**
|
|
1235
|
-
* Helper to safely access a uniform node from the store.
|
|
1236
|
-
* Use this when accessing state.uniforms to get proper typing.
|
|
1237
|
-
* @example
|
|
1238
|
-
* const uTime = uniforms.uTime as UniformNode<number>
|
|
1239
|
-
* const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
|
|
1240
|
-
*/
|
|
1241
|
-
type GetUniform<T = unknown> = UniformNode<T>
|
|
1242
|
-
|
|
1243
|
-
/**
|
|
1244
|
-
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1245
|
-
* Supports:
|
|
1246
|
-
* - Primitives: number, string (color), boolean
|
|
1247
|
-
* - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
|
|
1248
|
-
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1249
|
-
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1250
|
-
* - UniformNode: existing uniforms (reused as-is)
|
|
1251
|
-
*/
|
|
1252
|
-
type UniformValue =
|
|
1253
|
-
| number
|
|
1254
|
-
| string
|
|
1255
|
-
| boolean
|
|
1256
|
-
| three_webgpu.Color
|
|
1257
|
-
| three_webgpu.Vector2
|
|
1258
|
-
| three_webgpu.Vector3
|
|
1259
|
-
| three_webgpu.Vector4
|
|
1260
|
-
| three_webgpu.Matrix3
|
|
1261
|
-
| three_webgpu.Matrix4
|
|
1262
|
-
| three_webgpu.Euler
|
|
1263
|
-
| three_webgpu.Quaternion
|
|
1264
|
-
| { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
|
|
1265
|
-
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1266
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1267
|
-
| UniformNode
|
|
1268
|
-
|
|
1269
|
-
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1270
|
-
type UniformInputRecord = Record<string, UniformValue>
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
//* Module Augmentation ==============================
|
|
1274
|
-
|
|
1275
|
-
declare module 'three/tsl' {
|
|
1276
|
-
/**
|
|
1277
|
-
* Fn with array parameter destructuring
|
|
1278
|
-
* @example Fn(([uv, skew]) => { ... })
|
|
1279
|
-
*/
|
|
1280
|
-
export function Fn<R extends Node = Node>(
|
|
1281
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1282
|
-
): ShaderCallable<R>
|
|
1283
|
-
|
|
1284
|
-
/**
|
|
1285
|
-
* Fn with object parameter destructuring
|
|
1286
|
-
* @example Fn(({ color, intensity }) => { ... })
|
|
1287
|
-
*/
|
|
1288
|
-
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1289
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1290
|
-
): ShaderCallable<R>
|
|
1291
|
-
|
|
1292
|
-
/**
|
|
1293
|
-
* Fn with array params + layout
|
|
1294
|
-
* @example Fn(([a, b]) => { ... }, { layout: [...] })
|
|
1295
|
-
*/
|
|
1296
|
-
export function Fn<R extends Node = Node>(
|
|
1297
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1298
|
-
layout: { layout?: unknown },
|
|
1299
|
-
): ShaderCallable<R>
|
|
1300
|
-
|
|
1301
|
-
/**
|
|
1302
|
-
* Fn with object params + layout
|
|
1303
|
-
*/
|
|
1304
|
-
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1305
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1306
|
-
layout: { layout?: unknown },
|
|
1307
|
-
): ShaderCallable<R>
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
declare global {
|
|
1311
|
-
/**
|
|
1312
|
-
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1313
|
-
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1314
|
-
* is r185, so the new name is the only one.
|
|
1315
|
-
*/
|
|
1316
|
-
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1317
|
-
|
|
1318
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1319
|
-
type PassRecord = Record<string, any>
|
|
1320
|
-
|
|
1321
|
-
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1322
|
-
type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
|
|
1323
|
-
|
|
1324
|
-
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1325
|
-
type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
|
|
1326
|
-
|
|
1327
|
-
/** Return type for useRenderPipeline hook */
|
|
1328
|
-
interface UseRenderPipelineReturn {
|
|
1329
|
-
/** Current passes from state */
|
|
1330
|
-
passes: PassRecord
|
|
1331
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1332
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1333
|
-
/** Clear all passes from state */
|
|
1334
|
-
clearPasses: () => void
|
|
1335
|
-
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1336
|
-
reset: () => void
|
|
1337
|
-
/** Re-run setup/main callbacks with current closure values */
|
|
1338
|
-
rebuild: () => void
|
|
1339
|
-
/** True when RenderPipeline is configured and ready */
|
|
1340
|
-
isReady: boolean
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
1108
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
1345
1109
|
|
|
1346
1110
|
interface MathRepresentation {
|
|
@@ -1417,10 +1181,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1417
1181
|
|
|
1418
1182
|
/**
|
|
1419
1183
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1420
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1184
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1185
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1421
1186
|
*/
|
|
1422
1187
|
type NodeProps<P> = {
|
|
1423
|
-
[K in keyof P as P[K] extends
|
|
1188
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1424
1189
|
}
|
|
1425
1190
|
|
|
1426
1191
|
interface ReactProps<P> {
|
|
@@ -1441,11 +1206,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1441
1206
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1442
1207
|
}
|
|
1443
1208
|
|
|
1209
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1210
|
+
type Object3DMethod = NonNullable<
|
|
1211
|
+
{
|
|
1212
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1213
|
+
}[keyof Object3D]
|
|
1214
|
+
>
|
|
1215
|
+
|
|
1444
1216
|
type ThreeExports = typeof THREE
|
|
1445
1217
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1446
1218
|
|
|
1447
1219
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1448
|
-
|
|
1220
|
+
/**
|
|
1221
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1222
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1223
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1224
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1225
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1226
|
+
*/
|
|
1227
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1228
|
+
object: object
|
|
1229
|
+
ref?: React.Ref<any>
|
|
1230
|
+
[prop: string]: unknown
|
|
1231
|
+
}
|
|
1449
1232
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1450
1233
|
threeAudio: ThreeElementsImpl['audio']
|
|
1451
1234
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1486,6 +1269,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1486
1269
|
type three_d_Matrix4 = Matrix4;
|
|
1487
1270
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1488
1271
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1272
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1489
1273
|
type three_d_Quaternion = Quaternion;
|
|
1490
1274
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1491
1275
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1500,7 +1284,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1500
1284
|
type three_d_Vector4 = Vector4;
|
|
1501
1285
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1502
1286
|
declare namespace three_d {
|
|
1503
|
-
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 };
|
|
1287
|
+
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 };
|
|
1504
1288
|
}
|
|
1505
1289
|
|
|
1506
1290
|
/**
|
|
@@ -1638,9 +1422,9 @@ type EnvironmentProps = {
|
|
|
1638
1422
|
blur?: number;
|
|
1639
1423
|
backgroundBlurriness?: number;
|
|
1640
1424
|
backgroundIntensity?: number;
|
|
1641
|
-
backgroundRotation?: Euler
|
|
1425
|
+
backgroundRotation?: Euler;
|
|
1642
1426
|
environmentIntensity?: number;
|
|
1643
|
-
environmentRotation?: Euler
|
|
1427
|
+
environmentRotation?: Euler;
|
|
1644
1428
|
map?: Texture$1;
|
|
1645
1429
|
preset?: PresetsType;
|
|
1646
1430
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -1724,7 +1508,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
1724
1508
|
declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
1725
1509
|
declare module '@react-three/fiber' {
|
|
1726
1510
|
interface ThreeElements {
|
|
1727
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1511
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
1728
1512
|
}
|
|
1729
1513
|
}
|
|
1730
1514
|
/**
|
|
@@ -1849,7 +1633,43 @@ declare function createEvents(store: RootStore): {
|
|
|
1849
1633
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1850
1634
|
};
|
|
1851
1635
|
/** Default R3F event manager for web */
|
|
1852
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1636
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1637
|
+
|
|
1638
|
+
interface RootExtension {
|
|
1639
|
+
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
1640
|
+
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
1641
|
+
name: string;
|
|
1642
|
+
/**
|
|
1643
|
+
* Called once per root, after its renderer exists and before `onCreated` and the first frame.
|
|
1644
|
+
* `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
|
|
1645
|
+
* to the primary canvas. Return fields to merge into the root's state, or nothing.
|
|
1646
|
+
*/
|
|
1647
|
+
setup?(store: RootStore): Partial<RootState> | void;
|
|
1648
|
+
/** Called when a root this extension set up unmounts. */
|
|
1649
|
+
dispose?(store: RootStore): void;
|
|
1650
|
+
/** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
|
|
1651
|
+
hmr?(store: RootStore): void;
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Register an extension. It is set up on every live root immediately, and on every root created
|
|
1655
|
+
* afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
|
|
1656
|
+
* it already set up keep its state and still get its dispose when they unmount.
|
|
1657
|
+
*/
|
|
1658
|
+
declare function registerRootExtension(extension: RootExtension): () => void;
|
|
1659
|
+
/**
|
|
1660
|
+
* Point a root's default render job at a different render function, or back at
|
|
1661
|
+
* `renderer.render(scene, camera)` with `null`.
|
|
1662
|
+
*
|
|
1663
|
+
* The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
|
|
1664
|
+
* boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
|
|
1665
|
+
*/
|
|
1666
|
+
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
1667
|
+
|
|
1668
|
+
/**
|
|
1669
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
1670
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
1671
|
+
*/
|
|
1672
|
+
declare function useStore(): RootStore;
|
|
1853
1673
|
|
|
1854
1674
|
/**
|
|
1855
1675
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -1869,50 +1689,6 @@ declare namespace useLoader {
|
|
|
1869
1689
|
var loader: typeof getLoader;
|
|
1870
1690
|
}
|
|
1871
1691
|
|
|
1872
|
-
/**
|
|
1873
|
-
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
1874
|
-
*
|
|
1875
|
-
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1876
|
-
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1877
|
-
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1878
|
-
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1879
|
-
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
1880
|
-
*
|
|
1881
|
-
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
1882
|
-
*
|
|
1883
|
-
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1884
|
-
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1885
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1886
|
-
*
|
|
1887
|
-
* @example
|
|
1888
|
-
* // Simple priority (backwards compat)
|
|
1889
|
-
* useFrame((state, delta) => { ... }, 5)
|
|
1890
|
-
*
|
|
1891
|
-
* @example
|
|
1892
|
-
* // With phase-based ordering
|
|
1893
|
-
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
1894
|
-
*
|
|
1895
|
-
* @example
|
|
1896
|
-
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
1897
|
-
* function UI() {
|
|
1898
|
-
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
1899
|
-
* return <button>...</button>;
|
|
1900
|
-
* }
|
|
1901
|
-
*
|
|
1902
|
-
* @example
|
|
1903
|
-
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
1904
|
-
* import { getScheduler } from '@pmndrs/scheduler'
|
|
1905
|
-
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
1906
|
-
*
|
|
1907
|
-
* @example
|
|
1908
|
-
* // Scheduler-only access (no callback)
|
|
1909
|
-
* const { scheduler } = useFrame()
|
|
1910
|
-
* scheduler.pauseJob('some-job-id')
|
|
1911
|
-
*
|
|
1912
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1913
|
-
*/
|
|
1914
|
-
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
1915
|
-
|
|
1916
1692
|
declare const IsObject: (url: unknown) => url is Record<string, string>;
|
|
1917
1693
|
type TextureArray<T> = T extends string[] ? Texture$1[] : never;
|
|
1918
1694
|
type TextureRecord<T> = T extends Record<string, string> ? {
|
|
@@ -2093,16 +1869,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
|
|
|
2093
1869
|
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
|
|
2094
1870
|
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
|
|
2095
1871
|
|
|
2096
|
-
/**
|
|
2097
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2098
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2099
|
-
*/
|
|
2100
|
-
declare function useStore(): RootStore;
|
|
2101
|
-
/**
|
|
2102
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2103
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2104
|
-
*/
|
|
2105
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2106
1872
|
/**
|
|
2107
1873
|
* Exposes an object's {@link Instance}.
|
|
2108
1874
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2178,7 +1944,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2178
1944
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2179
1945
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2180
1946
|
*
|
|
2181
|
-
*
|
|
1947
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
1948
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
1949
|
+
*
|
|
1950
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2182
1951
|
* @param frames - Number of frames to request (default: 1)
|
|
2183
1952
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2184
1953
|
*
|
|
@@ -2189,14 +1958,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2189
1958
|
* Advances the frameloop and runs render effects.
|
|
2190
1959
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2191
1960
|
*
|
|
1961
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
1962
|
+
* registered root is stepped for backwards compatibility.
|
|
1963
|
+
*
|
|
2192
1964
|
* @param timestamp - The timestamp to use for this frame
|
|
2193
1965
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2194
|
-
* @param state -
|
|
2195
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
1966
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2196
1967
|
*
|
|
2197
1968
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2198
1969
|
*/
|
|
2199
|
-
declare function advance(timestamp: number): void;
|
|
1970
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2200
1971
|
|
|
2201
1972
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2202
1973
|
declare function ReactReconciler<
|
|
@@ -3241,6 +3012,7 @@ declare namespace ReactReconciler {
|
|
|
3241
3012
|
|
|
3242
3013
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3243
3014
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3015
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3244
3016
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3245
3017
|
|
|
3246
3018
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3265,6 +3037,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
3265
3037
|
declare function flushSync<R>(fn: () => R): R;
|
|
3266
3038
|
|
|
3267
3039
|
declare const context: React$1.Context<RootStore>;
|
|
3040
|
+
|
|
3268
3041
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3269
3042
|
|
|
3270
3043
|
/**
|
|
@@ -3518,7 +3291,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
3518
3291
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
3519
3292
|
/**
|
|
3520
3293
|
* Triggers an update for an instance.
|
|
3521
|
-
*
|
|
3294
|
+
* Invalidates the frame if the root is in demand mode.
|
|
3522
3295
|
*
|
|
3523
3296
|
* @param instance - Instance to invalidate
|
|
3524
3297
|
*/
|
|
@@ -3684,29 +3457,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3684
3457
|
* Used to identify values that should be resolved from refs after mount.
|
|
3685
3458
|
*/
|
|
3686
3459
|
declare const FROM_REF: unique symbol;
|
|
3460
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3461
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3462
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3463
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3464
|
+
transform?: (value: T) => R;
|
|
3465
|
+
}
|
|
3687
3466
|
/**
|
|
3688
3467
|
* Defers prop application until the referenced object is available.
|
|
3689
3468
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3690
3469
|
*
|
|
3470
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3471
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3472
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3473
|
+
* what gets assigned.
|
|
3474
|
+
*
|
|
3691
3475
|
* @param ref - React ref object to resolve at mount time
|
|
3692
|
-
* @
|
|
3476
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3477
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3693
3478
|
*
|
|
3694
3479
|
* @example
|
|
3695
3480
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3696
3481
|
*
|
|
3697
3482
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3698
3483
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3484
|
+
*
|
|
3485
|
+
* @example
|
|
3486
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3487
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3699
3488
|
*/
|
|
3700
3489
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3490
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3701
3491
|
/**
|
|
3702
3492
|
* Type guard to check if a value is a fromRef marker.
|
|
3703
3493
|
*
|
|
3704
3494
|
* @param value - Value to check
|
|
3705
3495
|
* @returns True if value is a fromRef marker
|
|
3706
3496
|
*/
|
|
3707
|
-
declare function isFromRef(value: unknown): value is
|
|
3708
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3709
|
-
};
|
|
3497
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3710
3498
|
|
|
3711
3499
|
/**
|
|
3712
3500
|
* Symbol marker for mount-only method calls.
|
|
@@ -3733,7 +3521,15 @@ declare const ONCE: unique symbol;
|
|
|
3733
3521
|
* // No arguments
|
|
3734
3522
|
* <geometry center={once()} />
|
|
3735
3523
|
*/
|
|
3736
|
-
declare function once<
|
|
3524
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3525
|
+
/**
|
|
3526
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3527
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3528
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3529
|
+
*
|
|
3530
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3531
|
+
*/
|
|
3532
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3737
3533
|
/**
|
|
3738
3534
|
* Type guard to check if a value is a once marker.
|
|
3739
3535
|
*
|
|
@@ -3744,315 +3540,6 @@ declare function isOnce(value: unknown): value is {
|
|
|
3744
3540
|
[ONCE]: any[] | true;
|
|
3745
3541
|
};
|
|
3746
3542
|
|
|
3747
|
-
/**
|
|
3748
|
-
* A DOM canvas which accepts threejs elements as children.
|
|
3749
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
3750
|
-
*/
|
|
3751
|
-
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3752
|
-
|
|
3753
|
-
/**
|
|
3754
|
-
* ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
|
|
3755
|
-
*
|
|
3756
|
-
* Provides TypeScript-friendly access to uniform/node stores where the runtime
|
|
3757
|
-
* structure is `Record<string, T | Record<string, T>>` (leaf nodes or nested scopes).
|
|
3758
|
-
*
|
|
3759
|
-
* The wrapper uses a Proxy to:
|
|
3760
|
-
* 1. Return `T` for property access (type assumption: assumes leaf node)
|
|
3761
|
-
* 2. Provide `.scope(key)` method for explicit nested access
|
|
3762
|
-
* 3. Support iteration methods: has(), keys(), Object.keys(), for...in
|
|
3763
|
-
*
|
|
3764
|
-
* @example
|
|
3765
|
-
* ```tsx
|
|
3766
|
-
* useLocalNodes(({ uniforms }) => ({
|
|
3767
|
-
* wobble: sin(uniforms.uTime.mul(2)), // No cast needed!
|
|
3768
|
-
* playerHealth: uniforms.scope('player').uHealth // Explicit scope access
|
|
3769
|
-
* }))
|
|
3770
|
-
* ```
|
|
3771
|
-
*/
|
|
3772
|
-
|
|
3773
|
-
/** Keys reserved for methods (excluded from index signature) */
|
|
3774
|
-
type MethodKeys = 'scope' | 'has' | 'keys';
|
|
3775
|
-
/**
|
|
3776
|
-
* Type-safe wrapper interface for accessing nested store data.
|
|
3777
|
-
* Property access returns `T` (assumes leaf node).
|
|
3778
|
-
* Use `.scope(key)` for nested object access.
|
|
3779
|
-
*
|
|
3780
|
-
* Uses mapped type with key filtering to exclude method names from index signature,
|
|
3781
|
-
* allowing methods to have their correct return types.
|
|
3782
|
-
*/
|
|
3783
|
-
type ScopedStoreType<T> = {
|
|
3784
|
-
/** Direct property access returns the leaf type T (method keys excluded) */
|
|
3785
|
-
readonly [K in string as K extends MethodKeys ? never : K]: T;
|
|
3786
|
-
} & {
|
|
3787
|
-
/** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
|
|
3788
|
-
scope(key: string): ScopedStoreType<T>;
|
|
3789
|
-
/** Check if a key exists in the store */
|
|
3790
|
-
has(key: string): boolean;
|
|
3791
|
-
/** Get all keys in the store */
|
|
3792
|
-
keys(): string[];
|
|
3793
|
-
};
|
|
3794
|
-
/**
|
|
3795
|
-
* Create a type-safe ScopedStore wrapper around store data.
|
|
3796
|
-
* @param data - The raw store data (uniforms or nodes from RootState)
|
|
3797
|
-
* @returns A ScopedStoreType wrapper with type-safe access
|
|
3798
|
-
*/
|
|
3799
|
-
declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreType<T>;
|
|
3800
|
-
/**
|
|
3801
|
-
* State type passed to creator functions with ScopedStore wrappers.
|
|
3802
|
-
* Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
|
|
3803
|
-
*/
|
|
3804
|
-
type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
|
|
3805
|
-
/** Type-safe uniform access - property access returns UniformNode */
|
|
3806
|
-
uniforms: ScopedStoreType<UniformNode>;
|
|
3807
|
-
/** Type-safe node access - property access returns TSLNodeType (Node | ShaderCallable | ShaderNodeObject) */
|
|
3808
|
-
nodes: ScopedStoreType<TSLNodeType>;
|
|
3809
|
-
/** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
|
|
3810
|
-
buffers: ScopedStoreType<BufferLike>;
|
|
3811
|
-
/** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
|
|
3812
|
-
gpuStorage: ScopedStoreType<StorageLike>;
|
|
3813
|
-
};
|
|
3814
|
-
|
|
3815
|
-
/** Creator function that returns uniform inputs (can be raw values or UniformNodes) */
|
|
3816
|
-
type UniformCreator<T extends UniformInputRecord = UniformInputRecord> = (state: CreatorState) => T;
|
|
3817
|
-
/** Function signature for removeUniforms util */
|
|
3818
|
-
type RemoveUniformsFn = (names: string | string[], scope?: string) => void;
|
|
3819
|
-
/** Function signature for clearUniforms util */
|
|
3820
|
-
type ClearUniformsFn = (scope?: string) => void;
|
|
3821
|
-
/** Function signature for rebuildUniforms util */
|
|
3822
|
-
type RebuildUniformsFn = (scope?: string) => void;
|
|
3823
|
-
/** Return type with utils included */
|
|
3824
|
-
type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
|
|
3825
|
-
removeUniforms: RemoveUniformsFn;
|
|
3826
|
-
clearUniforms: ClearUniformsFn;
|
|
3827
|
-
rebuildUniforms: RebuildUniformsFn;
|
|
3828
|
-
};
|
|
3829
|
-
declare function useUniforms(): UniformsWithUtils<UniformRecord & Record<string, UniformRecord>>;
|
|
3830
|
-
declare function useUniforms(scope: string): UniformsWithUtils;
|
|
3831
|
-
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3832
|
-
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3833
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3834
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3835
|
-
/**
|
|
3836
|
-
* Global rebuildUniforms function for HMR integration.
|
|
3837
|
-
* Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
|
|
3838
|
-
* Call this when HMR is detected to refresh all uniform creators.
|
|
3839
|
-
*
|
|
3840
|
-
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3841
|
-
* authoritative store.
|
|
3842
|
-
*
|
|
3843
|
-
* @param store - The R3F store (from useStore or context)
|
|
3844
|
-
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
3845
|
-
*/
|
|
3846
|
-
declare function rebuildAllUniforms(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
3847
|
-
/**
|
|
3848
|
-
* Remove uniforms by name from root level or a scope
|
|
3849
|
-
* @deprecated Use `const { removeUniforms } = useUniforms()` instead
|
|
3850
|
-
*/
|
|
3851
|
-
declare function removeUniforms(set: ReturnType<typeof useStore>['setState'], names: string[], scope?: string): void;
|
|
3852
|
-
/**
|
|
3853
|
-
* Clear all uniforms from a scope (removes the entire scope object)
|
|
3854
|
-
* @deprecated Use `const { clearUniforms } = useUniforms()` instead
|
|
3855
|
-
*/
|
|
3856
|
-
declare function clearScope(set: ReturnType<typeof useStore>['setState'], scope: string): void;
|
|
3857
|
-
/**
|
|
3858
|
-
* Clear all root-level uniforms (preserves scopes)
|
|
3859
|
-
* @deprecated Use `const { clearUniforms } = useUniforms()` with `clearUniforms('root')` instead
|
|
3860
|
-
*/
|
|
3861
|
-
declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState']): void;
|
|
3862
|
-
|
|
3863
|
-
/**
|
|
3864
|
-
* Supported uniform value types:
|
|
3865
|
-
* - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
|
|
3866
|
-
* - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
|
|
3867
|
-
* - TSL nodes: color(), vec3(), float(), etc. (for type casting)
|
|
3868
|
-
* - UniformNode: existing uniforms (reused as-is)
|
|
3869
|
-
*/
|
|
3870
|
-
type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
|
|
3871
|
-
/**
|
|
3872
|
-
* Widen literal types to their base types:
|
|
3873
|
-
* - 0 → number
|
|
3874
|
-
* - true → boolean
|
|
3875
|
-
* - '#ff0000' → Color (string colors are converted to Color objects)
|
|
3876
|
-
* - Node → Node (TSL nodes passed through for uniform type casting)
|
|
3877
|
-
*/
|
|
3878
|
-
type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
|
|
3879
|
-
declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
|
|
3880
|
-
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
|
|
3881
|
-
|
|
3882
|
-
/**
|
|
3883
|
-
* Minimal interface for TSL nodes.
|
|
3884
|
-
* Used instead of Three.js's Node type because the @types/three definitions
|
|
3885
|
-
* have inconsistencies where OperatorNode, ConstNode, etc. don't properly
|
|
3886
|
-
* extend Node with all required properties.
|
|
3887
|
-
*/
|
|
3888
|
-
interface TSLNodeLike {
|
|
3889
|
-
uuid?: string;
|
|
3890
|
-
nodeType?: string | null;
|
|
3891
|
-
/** label method for chaining - sets the node's label and returns self */
|
|
3892
|
-
label?: ((label: string) => TSLNodeLike) | string;
|
|
3893
|
-
setName?: (name: string) => this;
|
|
3894
|
-
}
|
|
3895
|
-
/** TSL node type - alias for compatibility */
|
|
3896
|
-
type TSLNode = TSLNodeLike;
|
|
3897
|
-
/**
|
|
3898
|
-
* A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
|
|
3899
|
-
* Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
|
|
3900
|
-
*/
|
|
3901
|
-
type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
|
|
3902
|
-
/**
|
|
3903
|
-
* Creator function that returns a record of nodes.
|
|
3904
|
-
* Uses TSLNodeLike constraint to allow mixed node types
|
|
3905
|
-
* (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
|
|
3906
|
-
*/
|
|
3907
|
-
type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
|
|
3908
|
-
/** Function signature for removeNodes util */
|
|
3909
|
-
type RemoveNodesFn = (names: string | string[], scope?: string) => void;
|
|
3910
|
-
/** Function signature for clearNodes util */
|
|
3911
|
-
type ClearNodesFn = (scope?: string) => void;
|
|
3912
|
-
/** Function signature for rebuildNodes util */
|
|
3913
|
-
type RebuildNodesFn = (scope?: string) => void;
|
|
3914
|
-
/** Return type with utils included */
|
|
3915
|
-
type NodesWithUtils<T extends Record<string, TSLNodeLike> = Record<string, TSLNodeLike>> = T & {
|
|
3916
|
-
removeNodes: RemoveNodesFn;
|
|
3917
|
-
clearNodes: ClearNodesFn;
|
|
3918
|
-
rebuildNodes: RebuildNodesFn;
|
|
3919
|
-
};
|
|
3920
|
-
declare function useNodes(): NodesWithUtils<Record<string, TSLNodeLike> & Record<string, Record<string, TSLNodeLike>>>;
|
|
3921
|
-
declare function useNodes(scope: string): NodesWithUtils<Record<string, TSLNodeLike>>;
|
|
3922
|
-
declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>): NodesWithUtils<T>;
|
|
3923
|
-
declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
|
|
3924
|
-
/**
|
|
3925
|
-
* Global rebuildNodes function for HMR integration.
|
|
3926
|
-
* Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
|
|
3927
|
-
* Call this when HMR is detected to refresh all node creators.
|
|
3928
|
-
*
|
|
3929
|
-
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3930
|
-
* authoritative store.
|
|
3931
|
-
*
|
|
3932
|
-
* @param store - The R3F store (from useStore or context)
|
|
3933
|
-
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
3934
|
-
*/
|
|
3935
|
-
declare function rebuildAllNodes(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
3936
|
-
/**
|
|
3937
|
-
* Remove nodes by name from root level or a scope
|
|
3938
|
-
* @deprecated Use `const { removeNodes } = useNodes()` instead
|
|
3939
|
-
*/
|
|
3940
|
-
declare function removeNodes(set: ReturnType<typeof useStore>['setState'], names: string[], scope?: string): void;
|
|
3941
|
-
/**
|
|
3942
|
-
* Clear all nodes from a scope (removes the entire scope object)
|
|
3943
|
-
* @deprecated Use `const { clearNodes } = useNodes()` instead
|
|
3944
|
-
*/
|
|
3945
|
-
declare function clearNodeScope(set: ReturnType<typeof useStore>['setState'], scope: string): void;
|
|
3946
|
-
/**
|
|
3947
|
-
* Clear all root-level nodes (preserves scopes)
|
|
3948
|
-
* @deprecated Use `const { clearNodes } = useNodes()` with `clearNodes('root')` instead
|
|
3949
|
-
*/
|
|
3950
|
-
declare function clearRootNodes(set: ReturnType<typeof useStore>['setState']): void;
|
|
3951
|
-
|
|
3952
|
-
/** Creator receives CreatorState with ScopedStore wrappers for type-safe access. Returns any record. */
|
|
3953
|
-
type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState) => T;
|
|
3954
|
-
/**
|
|
3955
|
-
* Creates local values that rebuild when uniforms, nodes, or textures change.
|
|
3956
|
-
*
|
|
3957
|
-
* Unlike `useNodes`, this does NOT register to the global store.
|
|
3958
|
-
* Use for component-specific nodes/values that depend on shared resources.
|
|
3959
|
-
*
|
|
3960
|
-
* @example
|
|
3961
|
-
* ```tsx
|
|
3962
|
-
* // Destructure what you need from state
|
|
3963
|
-
* const { wobble, uTime } = useLocalNodes(({ uniforms, nodes }) => ({
|
|
3964
|
-
* wobble: sin(uniforms.uTime.mul(2)),
|
|
3965
|
-
* uTime: uniforms.uTime, // can return uniforms too
|
|
3966
|
-
* }))
|
|
3967
|
-
*
|
|
3968
|
-
* // Or access anything else from RootState
|
|
3969
|
-
* const { scaled } = useLocalNodes(({ camera, nodes }) => ({
|
|
3970
|
-
* scaled: nodes.basePos.mul(camera.zoom),
|
|
3971
|
-
* }))
|
|
3972
|
-
*
|
|
3973
|
-
* // Type-safe uniform access
|
|
3974
|
-
* const { colorNode } = useLocalNodes(({ uniforms }) => {
|
|
3975
|
-
* const uValue = uniforms.myUniform as UniformNode<number>
|
|
3976
|
-
* return { colorNode: mix(colorA, colorB, uValue) }
|
|
3977
|
-
* })
|
|
3978
|
-
* ```
|
|
3979
|
-
*/
|
|
3980
|
-
declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
|
|
3981
|
-
|
|
3982
|
-
/**
|
|
3983
|
-
* Creator function that returns a record of buffers.
|
|
3984
|
-
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
3985
|
-
*/
|
|
3986
|
-
type BufferCreator<T extends Record<string, BufferLike>> = (state: CreatorState) => T;
|
|
3987
|
-
/** Function signature for removeBuffers util */
|
|
3988
|
-
type RemoveBuffersFn = (names: string | string[], scope?: string) => void;
|
|
3989
|
-
/** Function signature for clearBuffers util */
|
|
3990
|
-
type ClearBuffersFn = (scope?: string) => void;
|
|
3991
|
-
/** Function signature for rebuildBuffers util */
|
|
3992
|
-
type RebuildBuffersFn = (scope?: string) => void;
|
|
3993
|
-
/** Function signature for disposeBuffers util - releases GPU resources */
|
|
3994
|
-
type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
|
|
3995
|
-
/** Return type with utils included */
|
|
3996
|
-
type BuffersWithUtils<T extends Record<string, BufferLike> = Record<string, BufferLike>> = T & {
|
|
3997
|
-
removeBuffers: RemoveBuffersFn;
|
|
3998
|
-
clearBuffers: ClearBuffersFn;
|
|
3999
|
-
rebuildBuffers: RebuildBuffersFn;
|
|
4000
|
-
disposeBuffers: DisposeBuffersFn;
|
|
4001
|
-
};
|
|
4002
|
-
declare function useBuffers(): BuffersWithUtils<Record<string, BufferLike> & Record<string, Record<string, BufferLike>>>;
|
|
4003
|
-
declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
|
|
4004
|
-
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
|
|
4005
|
-
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
|
|
4006
|
-
/**
|
|
4007
|
-
* Global rebuildBuffers function for HMR integration.
|
|
4008
|
-
* Invalidates cached buffers and increments _hmrVersion to trigger re-creation.
|
|
4009
|
-
* Call this when HMR is detected to refresh all buffer creators.
|
|
4010
|
-
*
|
|
4011
|
-
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
4012
|
-
* authoritative store.
|
|
4013
|
-
*
|
|
4014
|
-
* @param store - The R3F store (from useStore or context)
|
|
4015
|
-
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4016
|
-
*/
|
|
4017
|
-
declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4018
|
-
|
|
4019
|
-
/**
|
|
4020
|
-
* Creator function that returns a record of GPU storage objects.
|
|
4021
|
-
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
4022
|
-
*/
|
|
4023
|
-
type StorageCreator<T extends Record<string, StorageLike>> = (state: CreatorState) => T;
|
|
4024
|
-
/** Function signature for removeStorage util */
|
|
4025
|
-
type RemoveStorageFn = (names: string | string[], scope?: string) => void;
|
|
4026
|
-
/** Function signature for clearStorage util */
|
|
4027
|
-
type ClearStorageFn = (scope?: string) => void;
|
|
4028
|
-
/** Function signature for rebuildStorage util */
|
|
4029
|
-
type RebuildStorageFn = (scope?: string) => void;
|
|
4030
|
-
/** Function signature for disposeStorage util - releases GPU resources */
|
|
4031
|
-
type DisposeStorageFn = (names: string | string[], scope?: string) => void;
|
|
4032
|
-
/** Return type with utils included */
|
|
4033
|
-
type StorageWithUtils<T extends Record<string, StorageLike> = Record<string, StorageLike>> = T & {
|
|
4034
|
-
removeStorage: RemoveStorageFn;
|
|
4035
|
-
clearStorage: ClearStorageFn;
|
|
4036
|
-
rebuildStorage: RebuildStorageFn;
|
|
4037
|
-
disposeStorage: DisposeStorageFn;
|
|
4038
|
-
};
|
|
4039
|
-
declare function useGPUStorage(): StorageWithUtils<Record<string, StorageLike> & Record<string, Record<string, StorageLike>>>;
|
|
4040
|
-
declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
|
|
4041
|
-
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
|
|
4042
|
-
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
|
|
4043
|
-
/**
|
|
4044
|
-
* Global rebuildStorage function for HMR integration.
|
|
4045
|
-
* Invalidates cached storage and increments _hmrVersion to trigger re-creation.
|
|
4046
|
-
* Call this when HMR is detected to refresh all storage creators.
|
|
4047
|
-
*
|
|
4048
|
-
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
4049
|
-
* authoritative store.
|
|
4050
|
-
*
|
|
4051
|
-
* @param store - The R3F store (from useStore or context)
|
|
4052
|
-
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4053
|
-
*/
|
|
4054
|
-
declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4055
|
-
|
|
4056
3543
|
/**
|
|
4057
3544
|
* Re-export from core - useTextures is now a core R3F hook (a reactive Texture registry).
|
|
4058
3545
|
*
|
|
@@ -4078,45 +3565,6 @@ interface TextureOperations {
|
|
|
4078
3565
|
}
|
|
4079
3566
|
declare function createTextureOperations(set: StoreApi<RootState>['setState']): TextureOperations;
|
|
4080
3567
|
|
|
4081
|
-
/**
|
|
4082
|
-
* Hook for managing WebGPU RenderPipeline with automatic scenePass setup.
|
|
4083
|
-
*
|
|
4084
|
-
* Features:
|
|
4085
|
-
* - Creates RenderPipeline instance if not exists
|
|
4086
|
-
* - Creates default scenePass (no MRT) automatically
|
|
4087
|
-
* - Callbacks receive full RootState for flexibility
|
|
4088
|
-
* - No auto-cleanup on unmount - use reset() for explicit cleanup
|
|
4089
|
-
* - Scene/camera changes trigger scenePass recreation
|
|
4090
|
-
*
|
|
4091
|
-
* @param mainCB - Main callback to configure outputNode and create effect passes
|
|
4092
|
-
* @param setupCB - Optional setup callback to configure MRT on scenePass
|
|
4093
|
-
* @returns { passes, renderPipeline, clearPasses, reset, rebuild }
|
|
4094
|
-
*
|
|
4095
|
-
* @example
|
|
4096
|
-
* ```tsx
|
|
4097
|
-
* // Simple effect
|
|
4098
|
-
* useRenderPipeline(({ renderPipeline, passes }) => {
|
|
4099
|
-
* renderPipeline.outputNode = bloom(passes.scenePass.getTextureNode())
|
|
4100
|
-
* })
|
|
4101
|
-
*
|
|
4102
|
-
* // With MRT setup
|
|
4103
|
-
* useRenderPipeline(
|
|
4104
|
-
* ({ renderPipeline, passes }) => {
|
|
4105
|
-
* const beauty = passes.scenePass.getTextureNode().toInspector('Color')
|
|
4106
|
-
* const vel = passes.scenePass.getTextureNode('velocity')
|
|
4107
|
-
* renderPipeline.outputNode = motionBlur(beauty, vel)
|
|
4108
|
-
* },
|
|
4109
|
-
* ({ passes }) => {
|
|
4110
|
-
* passes.scenePass.setMRT(mrt({ output, velocity }))
|
|
4111
|
-
* }
|
|
4112
|
-
* )
|
|
4113
|
-
*
|
|
4114
|
-
* // Read-only access
|
|
4115
|
-
* const { renderPipeline, passes } = useRenderPipeline()
|
|
4116
|
-
* ```
|
|
4117
|
-
*/
|
|
4118
|
-
declare function useRenderPipeline(mainCB?: RenderPipelineMainCallback, setupCB?: RenderPipelineSetupCallback): UseRenderPipelineReturn;
|
|
4119
|
-
|
|
4120
3568
|
//* Renderer Props ========================================
|
|
4121
3569
|
|
|
4122
3570
|
type WebGPUDefaultProps = Omit<WebGPURendererParameters, 'canvas'> & BaseRendererProps
|
|
@@ -4164,5 +3612,33 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
|
|
|
4164
3612
|
internal: WebGPUInternalState
|
|
4165
3613
|
}
|
|
4166
3614
|
|
|
4167
|
-
|
|
4168
|
-
|
|
3615
|
+
/**
|
|
3616
|
+
* @fileoverview WebGPU entry point - WebGPU only, no legacy WebGL
|
|
3617
|
+
*
|
|
3618
|
+
* This entry point is for apps that want to use ONLY WebGPURenderer.
|
|
3619
|
+
* Auto-extends THREE with WebGPU node materials (MeshBasicNodeMaterial, etc.)
|
|
3620
|
+
* The TSL resource hooks (useUniforms, useNodes, useRenderPipeline, ...) are in @react-three/tsl.
|
|
3621
|
+
*
|
|
3622
|
+
* Usage:
|
|
3623
|
+
* import { Canvas, useFrame } from '@react-three/fiber/webgpu'
|
|
3624
|
+
* import { useUniforms } from '@react-three/tsl'
|
|
3625
|
+
*/
|
|
3626
|
+
|
|
3627
|
+
/** `useThree` narrowed to WebGPU state — `state.renderer` is a `WebGPURenderer`. */
|
|
3628
|
+
type UseThreeWebGPU = <T = WebGPURootState>(selector?: (state: WebGPURootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
|
|
3629
|
+
/** `useFrame` narrowed to WebGPU state — the callback's `state.renderer` is a `WebGPURenderer`. */
|
|
3630
|
+
type UseFrameWebGPU = (callback?: FrameCallback$1<WebGPURootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
|
|
3631
|
+
declare const useThree: UseThreeWebGPU;
|
|
3632
|
+
declare const useFrame: UseFrameWebGPU;
|
|
3633
|
+
|
|
3634
|
+
/** Canvas props on the WebGPU entry: `onCreated` receives `WebGPURootState`. */
|
|
3635
|
+
type WebGPUCanvasProps = Omit<CanvasProps, 'onCreated'> & {
|
|
3636
|
+
/** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGPURenderer` */
|
|
3637
|
+
onCreated?: (state: WebGPURootState) => void;
|
|
3638
|
+
};
|
|
3639
|
+
|
|
3640
|
+
/** `Canvas` narrowed to WebGPU state — the same component, `onCreated` typed against `WebGPURootState`. */
|
|
3641
|
+
declare const Canvas: (props: WebGPUCanvasProps) => JSX.Element;
|
|
3642
|
+
|
|
3643
|
+
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, createTextureOperations, 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 };
|
|
3644
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, RootState as BaseRootState, Bridge, Camera, CameraProps, WebGPUCanvasProps as 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, WebGPUInternalState as 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, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootExtension, WebGPURootState as RootState, RootStore, SetBlock, Size, Subscription, TSLNodeInput, TextureEntry, TextureInput, TextureNode, TextureOperations, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameWebGPU, UseTextureOptions, UseTexturesReturn, UseThreeWebGPU, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUCanvasProps, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };
|