@react-three/fiber 10.0.0-canary.4bc4a97 → 10.0.0-canary.4bf885a
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 +1675 -0
- package/dist/extension.d.mts +1675 -0
- package/dist/extension.d.ts +1647 -0
- package/dist/extension.mjs +258 -0
- package/dist/index.cjs +984 -899
- package/dist/index.d.cts +337 -156
- package/dist/index.d.mts +337 -156
- package/dist/index.d.ts +335 -182
- package/dist/index.mjs +985 -902
- package/dist/legacy.cjs +997 -913
- package/dist/legacy.d.cts +358 -209
- package/dist/legacy.d.mts +358 -209
- package/dist/legacy.d.ts +356 -233
- package/dist/legacy.mjs +998 -916
- package/dist/webgpu/index.cjs +899 -736
- package/dist/webgpu/index.d.cts +412 -262
- package/dist/webgpu/index.d.mts +412 -262
- package/dist/webgpu/index.d.ts +410 -288
- package/dist/webgpu/index.mjs +900 -739
- package/package.json +7 -2
package/dist/webgpu/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
|
|
1
2
|
import * as three_webgpu from 'three/webgpu';
|
|
2
|
-
import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget,
|
|
3
|
+
import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Object3D, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera, Matrix2, 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';
|
|
@@ -40,6 +41,8 @@ function _mergeNamespaces(n, m) {
|
|
|
40
41
|
declare const R3F_BUILD_LEGACY = false;
|
|
41
42
|
declare const R3F_BUILD_WEBGPU = true;
|
|
42
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>;
|
|
43
46
|
declare const WebGLRenderer: {
|
|
44
47
|
new (): {};
|
|
45
48
|
};
|
|
@@ -61,7 +64,8 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
61
64
|
WebGLRenderTarget: WebGLRenderTarget,
|
|
62
65
|
WebGLRenderer: WebGLRenderer,
|
|
63
66
|
WebGLRendererParameters: WebGLRendererParameters,
|
|
64
|
-
WebGLShadowMap: WebGLShadowMap
|
|
67
|
+
WebGLShadowMap: WebGLShadowMap,
|
|
68
|
+
loadInspector: loadInspector
|
|
65
69
|
}, [three_webgpu]);
|
|
66
70
|
|
|
67
71
|
//* Utility Types ==============================
|
|
@@ -350,6 +354,7 @@ type BufferLike =
|
|
|
350
354
|
| Uint16Array
|
|
351
355
|
| Int16Array
|
|
352
356
|
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
357
|
+
| THREE$1.InterleavedBufferAttribute
|
|
353
358
|
| Node // TSL buffer nodes (instancedArray, storage)
|
|
354
359
|
|
|
355
360
|
/** Flat record of buffer-like values (no nested scopes) */
|
|
@@ -361,6 +366,25 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
361
366
|
*/
|
|
362
367
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
363
368
|
|
|
369
|
+
//* Node Types (useNodes) ========================================
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
373
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
374
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
375
|
+
* and the shape the store holds are one type by construction.
|
|
376
|
+
*/
|
|
377
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
378
|
+
|
|
379
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
380
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
384
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
385
|
+
*/
|
|
386
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
387
|
+
|
|
364
388
|
//* Storage Types (useGPUStorage) ========================================
|
|
365
389
|
|
|
366
390
|
/**
|
|
@@ -375,7 +399,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
|
375
399
|
* ```
|
|
376
400
|
*/
|
|
377
401
|
type StorageLike =
|
|
378
|
-
| StorageTexture // GPU storage texture
|
|
402
|
+
| StorageTexture // 2D GPU storage texture
|
|
403
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
404
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
379
405
|
| Data3DTexture // 3D texture (can be used as storage)
|
|
380
406
|
| Node // TSL storage texture nodes (storageTexture)
|
|
381
407
|
|
|
@@ -487,6 +513,12 @@ interface InternalState {
|
|
|
487
513
|
actualRenderer: R3FRenderer
|
|
488
514
|
/** Global scheduler reference (for useFrame hook) */
|
|
489
515
|
scheduler: SchedulerApi | null
|
|
516
|
+
/**
|
|
517
|
+
* Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
|
|
518
|
+
* `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
|
|
519
|
+
* render-phase takeover. Used by `useRenderPipeline`.
|
|
520
|
+
*/
|
|
521
|
+
renderOverride?: (() => void) | null
|
|
490
522
|
/** This root's unique ID in the global scheduler */
|
|
491
523
|
rootId?: string
|
|
492
524
|
/** Function to unregister this root from the global scheduler */
|
|
@@ -494,11 +526,28 @@ interface InternalState {
|
|
|
494
526
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
495
527
|
container?: THREE$1.Object3D
|
|
496
528
|
/**
|
|
497
|
-
* CanvasTarget
|
|
498
|
-
*
|
|
529
|
+
* The CanvasTarget this root sizes and renders through.
|
|
530
|
+
*
|
|
531
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
532
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
533
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
534
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
535
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
499
536
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
500
537
|
*/
|
|
501
538
|
canvasTarget?: CanvasTarget
|
|
539
|
+
/**
|
|
540
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
541
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
542
|
+
*
|
|
543
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
544
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
545
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
546
|
+
* invalidate some other canvas's descriptor instead.
|
|
547
|
+
*
|
|
548
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
549
|
+
*/
|
|
550
|
+
canvasTargetSizeDirty?: boolean
|
|
502
551
|
/**
|
|
503
552
|
* Whether multi-canvas rendering is active.
|
|
504
553
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -608,7 +657,7 @@ interface RootState {
|
|
|
608
657
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
609
658
|
uniforms: UniformStore
|
|
610
659
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
611
|
-
nodes:
|
|
660
|
+
nodes: NodeStore
|
|
612
661
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
613
662
|
buffers: BufferStore
|
|
614
663
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -620,7 +669,7 @@ interface RootState {
|
|
|
620
669
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
621
670
|
renderPipeline: ThreeRenderPipeline | null
|
|
622
671
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
623
|
-
passes:
|
|
672
|
+
passes: PassRecord
|
|
624
673
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
625
674
|
_hmrVersion: number
|
|
626
675
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -708,12 +757,19 @@ type DefaultRendererProps = {
|
|
|
708
757
|
*/
|
|
709
758
|
interface CanvasSchedulerConfig {
|
|
710
759
|
/**
|
|
711
|
-
*
|
|
712
|
-
|
|
760
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
761
|
+
*/
|
|
762
|
+
before?: string | string[]
|
|
763
|
+
/**
|
|
764
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
765
|
+
*/
|
|
766
|
+
after?: string | string[]
|
|
767
|
+
/**
|
|
768
|
+
* Numeric root order. Lower values run first.
|
|
713
769
|
*/
|
|
714
|
-
|
|
770
|
+
order?: number
|
|
715
771
|
/**
|
|
716
|
-
* Limit this
|
|
772
|
+
* Limit this Canvas's default render job (frames per second).
|
|
717
773
|
*/
|
|
718
774
|
fps?: number
|
|
719
775
|
}
|
|
@@ -800,14 +856,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
800
856
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
801
857
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
802
858
|
dpr?: Dpr
|
|
803
|
-
/**
|
|
804
|
-
|
|
859
|
+
/**
|
|
860
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
861
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
862
|
+
*/
|
|
863
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
805
864
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
806
865
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
807
866
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
808
867
|
camera?: CameraProps
|
|
809
868
|
/** An R3F event manager to manage elements' pointer events */
|
|
810
|
-
events?: (store: RootStore) => EventManager<
|
|
869
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
811
870
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
812
871
|
onCreated?: (state: RootState) => void
|
|
813
872
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -896,7 +955,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
896
955
|
object?: T
|
|
897
956
|
dispose?: null
|
|
898
957
|
attach?: AttachType<T>
|
|
899
|
-
onUpdate?: (self: T) => void
|
|
900
958
|
}
|
|
901
959
|
|
|
902
960
|
interface Instance<O = any> {
|
|
@@ -1036,7 +1094,7 @@ interface CanvasProps
|
|
|
1036
1094
|
*/
|
|
1037
1095
|
resize?: Options
|
|
1038
1096
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1039
|
-
eventSource?:
|
|
1097
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1040
1098
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1041
1099
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1042
1100
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1144,81 +1202,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1144
1202
|
|
|
1145
1203
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1146
1204
|
|
|
1147
|
-
//* Global Types ==============================
|
|
1205
|
+
//* Global TSL Types ==============================
|
|
1148
1206
|
|
|
1149
1207
|
declare global {
|
|
1150
1208
|
/**
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1154
|
-
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1155
|
-
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1156
|
-
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1157
|
-
* arity when three made `UniformNode` two-parameter.
|
|
1158
|
-
*
|
|
1159
|
-
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1160
|
-
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1161
|
-
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1162
|
-
* installed three instead of needing to be mirrored by hand.
|
|
1209
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1210
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1163
1211
|
*/
|
|
1164
|
-
type
|
|
1212
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1213
|
+
readonly shaderNode: unknown
|
|
1214
|
+
readonly id: number
|
|
1215
|
+
}
|
|
1165
1216
|
|
|
1166
|
-
/**
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
* @example
|
|
1172
|
-
* ```tsx
|
|
1173
|
-
* // Define a shader function
|
|
1174
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1175
|
-
* return mix(color1, color2, factor)
|
|
1176
|
-
* })
|
|
1177
|
-
*
|
|
1178
|
-
* // Type when retrieving from nodes store
|
|
1179
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1180
|
-
*
|
|
1181
|
-
* // Or with specific return type
|
|
1182
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1183
|
-
* ```
|
|
1184
|
-
*/
|
|
1185
|
-
type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
|
|
1217
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1218
|
+
type LegacyTSLNodeLike = {
|
|
1219
|
+
label?: ((label: string) => unknown) | string
|
|
1220
|
+
setName?: (name: string) => unknown
|
|
1221
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1186
1222
|
|
|
1187
|
-
/**
|
|
1188
|
-
|
|
1189
|
-
* This is the common return type for TSL operations (add, mul, sin, etc.)
|
|
1190
|
-
*
|
|
1191
|
-
* @example
|
|
1192
|
-
* ```tsx
|
|
1193
|
-
* const { wobble } = nodes as { wobble: ShaderNodeRef }
|
|
1194
|
-
* ```
|
|
1195
|
-
*/
|
|
1196
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1223
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1224
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1197
1225
|
|
|
1198
1226
|
/**
|
|
1199
|
-
*
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1203
|
-
* - Node: base Three.js node type
|
|
1204
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1205
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1206
|
-
*
|
|
1207
|
-
* @example
|
|
1208
|
-
* ```tsx
|
|
1209
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1210
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1211
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1212
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1213
|
-
* }))
|
|
1214
|
-
*
|
|
1215
|
-
* // Can narrow with type guard or assertion when needed
|
|
1216
|
-
* if (typeof blendColorFn === 'function') {
|
|
1217
|
-
* blendColorFn(someColor, 0.5)
|
|
1218
|
-
* }
|
|
1219
|
-
* ```
|
|
1227
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1228
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1229
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1230
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1220
1231
|
*/
|
|
1221
|
-
type
|
|
1232
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1233
|
+
? TNodeType
|
|
1234
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1235
|
+
? TNodeType
|
|
1236
|
+
: T extends number
|
|
1237
|
+
? 'float'
|
|
1238
|
+
: T extends boolean
|
|
1239
|
+
? 'bool'
|
|
1240
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1241
|
+
? 'color'
|
|
1242
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1243
|
+
? 'vec4'
|
|
1244
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1245
|
+
? 'vec3'
|
|
1246
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1247
|
+
? 'vec2'
|
|
1248
|
+
: T extends three_webgpu.Matrix4
|
|
1249
|
+
? 'mat4'
|
|
1250
|
+
: T extends three_webgpu.Matrix3
|
|
1251
|
+
? 'mat3'
|
|
1252
|
+
: T extends three_webgpu.Matrix2
|
|
1253
|
+
? 'mat2'
|
|
1254
|
+
: unknown
|
|
1255
|
+
|
|
1256
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1257
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1258
|
+
? TValue
|
|
1259
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1260
|
+
? TValue
|
|
1261
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1262
|
+
? three_webgpu.Color
|
|
1263
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1264
|
+
? three_webgpu.Vector4
|
|
1265
|
+
: T extends { x: number; y: number; z: number }
|
|
1266
|
+
? three_webgpu.Vector3
|
|
1267
|
+
: T extends { x: number; y: number }
|
|
1268
|
+
? three_webgpu.Vector2
|
|
1269
|
+
: T extends number
|
|
1270
|
+
? number
|
|
1271
|
+
: T extends boolean
|
|
1272
|
+
? boolean
|
|
1273
|
+
: T
|
|
1274
|
+
|
|
1275
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1276
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1277
|
+
|
|
1278
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1279
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1280
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1284
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1222
1285
|
|
|
1223
1286
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1224
1287
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1243,7 +1306,7 @@ declare global {
|
|
|
1243
1306
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1244
1307
|
* Supports:
|
|
1245
1308
|
* - Primitives: number, string (color), boolean
|
|
1246
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1309
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1247
1310
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1248
1311
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1249
1312
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1256,88 +1319,124 @@ declare global {
|
|
|
1256
1319
|
| three_webgpu.Vector2
|
|
1257
1320
|
| three_webgpu.Vector3
|
|
1258
1321
|
| three_webgpu.Vector4
|
|
1322
|
+
| three_webgpu.Matrix2
|
|
1259
1323
|
| three_webgpu.Matrix3
|
|
1260
1324
|
| three_webgpu.Matrix4
|
|
1261
|
-
|
|
|
1262
|
-
|
|
|
1263
|
-
| { x: number; y
|
|
1325
|
+
| { x: number; y: number }
|
|
1326
|
+
| { x: number; y: number; z: number }
|
|
1327
|
+
| { x: number; y: number; z: number; w: number }
|
|
1264
1328
|
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1265
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1329
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1266
1330
|
| UniformNode
|
|
1267
1331
|
|
|
1268
1332
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1269
1333
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1270
1334
|
}
|
|
1271
1335
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
declare module 'three/tsl' {
|
|
1336
|
+
declare global {
|
|
1275
1337
|
/**
|
|
1276
|
-
*
|
|
1277
|
-
*
|
|
1338
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1339
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1340
|
+
* is r185, so the new name is the only one.
|
|
1278
1341
|
*/
|
|
1279
|
-
|
|
1280
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1281
|
-
): ShaderCallable<R>
|
|
1342
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1282
1343
|
|
|
1283
1344
|
/**
|
|
1284
|
-
*
|
|
1285
|
-
*
|
|
1345
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1346
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1347
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1286
1348
|
*/
|
|
1287
|
-
|
|
1288
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1289
|
-
): ShaderCallable<R>
|
|
1349
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1290
1350
|
|
|
1291
1351
|
/**
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1352
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1353
|
+
*
|
|
1354
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1355
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1356
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1357
|
+
* {@link RenderPipelineCallbackState}.
|
|
1358
|
+
*
|
|
1359
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1360
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1361
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1362
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1363
|
+
*
|
|
1364
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1365
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1366
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1367
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1294
1368
|
*/
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1369
|
+
interface PassRecord {
|
|
1370
|
+
scenePass?: ScenePassNode
|
|
1371
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1372
|
+
}
|
|
1299
1373
|
|
|
1300
1374
|
/**
|
|
1301
|
-
*
|
|
1375
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1376
|
+
*
|
|
1377
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1378
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1379
|
+
*
|
|
1380
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1381
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1302
1382
|
*/
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1383
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1384
|
+
renderPipeline: ThreeRenderPipeline
|
|
1385
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1386
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1387
|
+
isLegacy: false
|
|
1388
|
+
}
|
|
1308
1389
|
|
|
1309
|
-
declare global {
|
|
1310
1390
|
/**
|
|
1311
|
-
*
|
|
1312
|
-
*
|
|
1313
|
-
* is
|
|
1391
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1392
|
+
*
|
|
1393
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1394
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1395
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1396
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1314
1397
|
*/
|
|
1315
|
-
type
|
|
1316
|
-
|
|
1317
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1318
|
-
type PassRecord = Record<string, any>
|
|
1398
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1319
1399
|
|
|
1320
1400
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1321
|
-
type RenderPipelineSetupCallback = (state:
|
|
1401
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1322
1402
|
|
|
1323
1403
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1324
|
-
type RenderPipelineMainCallback = (state:
|
|
1404
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1325
1405
|
|
|
1326
|
-
/**
|
|
1327
|
-
interface
|
|
1406
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1407
|
+
interface UseRenderPipelineActions {
|
|
1328
1408
|
/** Current passes from state */
|
|
1329
1409
|
passes: PassRecord
|
|
1330
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1331
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1332
1410
|
/** Clear all passes from state */
|
|
1333
1411
|
clearPasses: () => void
|
|
1334
1412
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1335
1413
|
reset: () => void
|
|
1336
1414
|
/** Re-run setup/main callbacks with current closure values */
|
|
1337
1415
|
rebuild: () => void
|
|
1338
|
-
/** True when RenderPipeline is configured and ready */
|
|
1339
|
-
isReady: boolean
|
|
1340
1416
|
}
|
|
1417
|
+
|
|
1418
|
+
/**
|
|
1419
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1420
|
+
*
|
|
1421
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1422
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1423
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1424
|
+
*/
|
|
1425
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1426
|
+
(
|
|
1427
|
+
| {
|
|
1428
|
+
/** True when RenderPipeline is configured and ready */
|
|
1429
|
+
isReady: true
|
|
1430
|
+
/** RenderPipeline instance */
|
|
1431
|
+
renderPipeline: ThreeRenderPipeline
|
|
1432
|
+
}
|
|
1433
|
+
| {
|
|
1434
|
+
/** False until the pipeline has been created */
|
|
1435
|
+
isReady: false
|
|
1436
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1437
|
+
renderPipeline: null
|
|
1438
|
+
}
|
|
1439
|
+
)
|
|
1341
1440
|
}
|
|
1342
1441
|
|
|
1343
1442
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1416,10 +1515,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1416
1515
|
|
|
1417
1516
|
/**
|
|
1418
1517
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1419
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1518
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1519
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1420
1520
|
*/
|
|
1421
1521
|
type NodeProps<P> = {
|
|
1422
|
-
[K in keyof P as P[K] extends
|
|
1522
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1423
1523
|
}
|
|
1424
1524
|
|
|
1425
1525
|
interface ReactProps<P> {
|
|
@@ -1440,11 +1540,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1440
1540
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1441
1541
|
}
|
|
1442
1542
|
|
|
1543
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1544
|
+
type Object3DMethod = NonNullable<
|
|
1545
|
+
{
|
|
1546
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1547
|
+
}[keyof Object3D]
|
|
1548
|
+
>
|
|
1549
|
+
|
|
1443
1550
|
type ThreeExports = typeof THREE
|
|
1444
1551
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1445
1552
|
|
|
1446
1553
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1447
|
-
|
|
1554
|
+
/**
|
|
1555
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1556
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1557
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1558
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1559
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1560
|
+
*/
|
|
1561
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1562
|
+
object: object
|
|
1563
|
+
ref?: React.Ref<any>
|
|
1564
|
+
[prop: string]: unknown
|
|
1565
|
+
}
|
|
1448
1566
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1449
1567
|
threeAudio: ThreeElementsImpl['audio']
|
|
1450
1568
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1485,6 +1603,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1485
1603
|
type three_d_Matrix4 = Matrix4;
|
|
1486
1604
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1487
1605
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1606
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1488
1607
|
type three_d_Quaternion = Quaternion;
|
|
1489
1608
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1490
1609
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1499,7 +1618,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1499
1618
|
type three_d_Vector4 = Vector4;
|
|
1500
1619
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1501
1620
|
declare namespace three_d {
|
|
1502
|
-
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 };
|
|
1621
|
+
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 };
|
|
1503
1622
|
}
|
|
1504
1623
|
|
|
1505
1624
|
/**
|
|
@@ -1848,7 +1967,43 @@ declare function createEvents(store: RootStore): {
|
|
|
1848
1967
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1849
1968
|
};
|
|
1850
1969
|
/** Default R3F event manager for web */
|
|
1851
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1970
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1971
|
+
|
|
1972
|
+
interface RootExtension {
|
|
1973
|
+
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
1974
|
+
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
1975
|
+
name: string;
|
|
1976
|
+
/**
|
|
1977
|
+
* Called once per root, after its renderer exists and before `onCreated` and the first frame.
|
|
1978
|
+
* `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
|
|
1979
|
+
* to the primary canvas. Return fields to merge into the root's state, or nothing.
|
|
1980
|
+
*/
|
|
1981
|
+
setup?(store: RootStore): Partial<RootState> | void;
|
|
1982
|
+
/** Called when a root this extension set up unmounts. */
|
|
1983
|
+
dispose?(store: RootStore): void;
|
|
1984
|
+
/** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
|
|
1985
|
+
hmr?(store: RootStore): void;
|
|
1986
|
+
}
|
|
1987
|
+
/**
|
|
1988
|
+
* Register an extension. It is set up on every live root immediately, and on every root created
|
|
1989
|
+
* afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
|
|
1990
|
+
* it already set up keep its state and still get its dispose when they unmount.
|
|
1991
|
+
*/
|
|
1992
|
+
declare function registerRootExtension(extension: RootExtension): () => void;
|
|
1993
|
+
/**
|
|
1994
|
+
* Point a root's default render job at a different render function, or back at
|
|
1995
|
+
* `renderer.render(scene, camera)` with `null`.
|
|
1996
|
+
*
|
|
1997
|
+
* The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
|
|
1998
|
+
* boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
|
|
1999
|
+
*/
|
|
2000
|
+
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
2001
|
+
|
|
2002
|
+
/**
|
|
2003
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2004
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2005
|
+
*/
|
|
2006
|
+
declare function useStore(): RootStore;
|
|
1852
2007
|
|
|
1853
2008
|
/**
|
|
1854
2009
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -1868,50 +2023,6 @@ declare namespace useLoader {
|
|
|
1868
2023
|
var loader: typeof getLoader;
|
|
1869
2024
|
}
|
|
1870
2025
|
|
|
1871
|
-
/**
|
|
1872
|
-
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
1873
|
-
*
|
|
1874
|
-
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1875
|
-
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1876
|
-
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1877
|
-
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1878
|
-
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
1879
|
-
*
|
|
1880
|
-
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
1881
|
-
*
|
|
1882
|
-
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1883
|
-
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1884
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1885
|
-
*
|
|
1886
|
-
* @example
|
|
1887
|
-
* // Simple priority (backwards compat)
|
|
1888
|
-
* useFrame((state, delta) => { ... }, 5)
|
|
1889
|
-
*
|
|
1890
|
-
* @example
|
|
1891
|
-
* // With phase-based ordering
|
|
1892
|
-
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
1893
|
-
*
|
|
1894
|
-
* @example
|
|
1895
|
-
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
1896
|
-
* function UI() {
|
|
1897
|
-
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
1898
|
-
* return <button>...</button>;
|
|
1899
|
-
* }
|
|
1900
|
-
*
|
|
1901
|
-
* @example
|
|
1902
|
-
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
1903
|
-
* import { getScheduler } from '@pmndrs/scheduler'
|
|
1904
|
-
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
1905
|
-
*
|
|
1906
|
-
* @example
|
|
1907
|
-
* // Scheduler-only access (no callback)
|
|
1908
|
-
* const { scheduler } = useFrame()
|
|
1909
|
-
* scheduler.pauseJob('some-job-id')
|
|
1910
|
-
*
|
|
1911
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1912
|
-
*/
|
|
1913
|
-
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
1914
|
-
|
|
1915
2026
|
declare const IsObject: (url: unknown) => url is Record<string, string>;
|
|
1916
2027
|
type TextureArray<T> = T extends string[] ? Texture$1[] : never;
|
|
1917
2028
|
type TextureRecord<T> = T extends Record<string, string> ? {
|
|
@@ -2092,16 +2203,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
|
|
|
2092
2203
|
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
|
|
2093
2204
|
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
|
|
2094
2205
|
|
|
2095
|
-
/**
|
|
2096
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2097
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2098
|
-
*/
|
|
2099
|
-
declare function useStore(): RootStore;
|
|
2100
|
-
/**
|
|
2101
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2102
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2103
|
-
*/
|
|
2104
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2105
2206
|
/**
|
|
2106
2207
|
* Exposes an object's {@link Instance}.
|
|
2107
2208
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2177,7 +2278,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2177
2278
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2178
2279
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2179
2280
|
*
|
|
2180
|
-
*
|
|
2281
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2282
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2283
|
+
*
|
|
2284
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2181
2285
|
* @param frames - Number of frames to request (default: 1)
|
|
2182
2286
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2183
2287
|
*
|
|
@@ -2188,14 +2292,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2188
2292
|
* Advances the frameloop and runs render effects.
|
|
2189
2293
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2190
2294
|
*
|
|
2295
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2296
|
+
* registered root is stepped for backwards compatibility.
|
|
2297
|
+
*
|
|
2191
2298
|
* @param timestamp - The timestamp to use for this frame
|
|
2192
2299
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2193
|
-
* @param state -
|
|
2194
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2300
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2195
2301
|
*
|
|
2196
2302
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2197
2303
|
*/
|
|
2198
|
-
declare function advance(timestamp: number): void;
|
|
2304
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2199
2305
|
|
|
2200
2306
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2201
2307
|
declare function ReactReconciler<
|
|
@@ -3240,6 +3346,7 @@ declare namespace ReactReconciler {
|
|
|
3240
3346
|
|
|
3241
3347
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3242
3348
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3349
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3243
3350
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3244
3351
|
|
|
3245
3352
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3264,6 +3371,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
3264
3371
|
declare function flushSync<R>(fn: () => R): R;
|
|
3265
3372
|
|
|
3266
3373
|
declare const context: React$1.Context<RootStore>;
|
|
3374
|
+
|
|
3267
3375
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3268
3376
|
|
|
3269
3377
|
/**
|
|
@@ -3517,7 +3625,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
3517
3625
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
3518
3626
|
/**
|
|
3519
3627
|
* Triggers an update for an instance.
|
|
3520
|
-
*
|
|
3628
|
+
* Invalidates the frame if the root is in demand mode.
|
|
3521
3629
|
*
|
|
3522
3630
|
* @param instance - Instance to invalidate
|
|
3523
3631
|
*/
|
|
@@ -3683,29 +3791,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3683
3791
|
* Used to identify values that should be resolved from refs after mount.
|
|
3684
3792
|
*/
|
|
3685
3793
|
declare const FROM_REF: unique symbol;
|
|
3794
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3795
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3796
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3797
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3798
|
+
transform?: (value: T) => R;
|
|
3799
|
+
}
|
|
3686
3800
|
/**
|
|
3687
3801
|
* Defers prop application until the referenced object is available.
|
|
3688
3802
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3689
3803
|
*
|
|
3804
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3805
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3806
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3807
|
+
* what gets assigned.
|
|
3808
|
+
*
|
|
3690
3809
|
* @param ref - React ref object to resolve at mount time
|
|
3691
|
-
* @
|
|
3810
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3811
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3692
3812
|
*
|
|
3693
3813
|
* @example
|
|
3694
3814
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3695
3815
|
*
|
|
3696
3816
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3697
3817
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3818
|
+
*
|
|
3819
|
+
* @example
|
|
3820
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3821
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3698
3822
|
*/
|
|
3699
3823
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3824
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3700
3825
|
/**
|
|
3701
3826
|
* Type guard to check if a value is a fromRef marker.
|
|
3702
3827
|
*
|
|
3703
3828
|
* @param value - Value to check
|
|
3704
3829
|
* @returns True if value is a fromRef marker
|
|
3705
3830
|
*/
|
|
3706
|
-
declare function isFromRef(value: unknown): value is
|
|
3707
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3708
|
-
};
|
|
3831
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3709
3832
|
|
|
3710
3833
|
/**
|
|
3711
3834
|
* Symbol marker for mount-only method calls.
|
|
@@ -3732,7 +3855,15 @@ declare const ONCE: unique symbol;
|
|
|
3732
3855
|
* // No arguments
|
|
3733
3856
|
* <geometry center={once()} />
|
|
3734
3857
|
*/
|
|
3735
|
-
declare function once<
|
|
3858
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3859
|
+
/**
|
|
3860
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3861
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3862
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3863
|
+
*
|
|
3864
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3865
|
+
*/
|
|
3866
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3736
3867
|
/**
|
|
3737
3868
|
* Type guard to check if a value is a once marker.
|
|
3738
3869
|
*
|
|
@@ -3743,11 +3874,8 @@ declare function isOnce(value: unknown): value is {
|
|
|
3743
3874
|
[ONCE]: any[] | true;
|
|
3744
3875
|
};
|
|
3745
3876
|
|
|
3746
|
-
/**
|
|
3747
|
-
|
|
3748
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
3749
|
-
*/
|
|
3750
|
-
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3877
|
+
/** Distinguishes a resource leaf from a nested resource scope. */
|
|
3878
|
+
type ResourceLeafGuard<T> = (value: unknown) => value is T;
|
|
3751
3879
|
|
|
3752
3880
|
/**
|
|
3753
3881
|
* ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
|
|
@@ -3769,33 +3897,30 @@ declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
|
3769
3897
|
* ```
|
|
3770
3898
|
*/
|
|
3771
3899
|
|
|
3772
|
-
/** Keys reserved for methods (excluded from index signature) */
|
|
3773
|
-
type MethodKeys = 'scope' | 'has' | 'keys';
|
|
3774
3900
|
/**
|
|
3775
3901
|
* Type-safe wrapper interface for accessing nested store data.
|
|
3776
3902
|
* Property access returns `T` (assumes leaf node).
|
|
3777
3903
|
* Use `.scope(key)` for nested object access.
|
|
3778
3904
|
*
|
|
3779
|
-
* Uses mapped type with key filtering to exclude method names from index signature,
|
|
3780
|
-
* allowing methods to have their correct return types.
|
|
3781
3905
|
*/
|
|
3782
|
-
type
|
|
3783
|
-
/** Direct property access returns the leaf type T (method keys excluded) */
|
|
3784
|
-
readonly [K in string as K extends MethodKeys ? never : K]: T;
|
|
3785
|
-
} & {
|
|
3906
|
+
type ScopedStoreMethods<TLeaf> = {
|
|
3786
3907
|
/** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
|
|
3787
|
-
scope(key: string): ScopedStoreType<
|
|
3908
|
+
scope<TScope extends Record<string, TLeaf> = Record<string, TLeaf>>(key: string): ScopedStoreType<TLeaf, TScope>;
|
|
3788
3909
|
/** Check if a key exists in the store */
|
|
3789
3910
|
has(key: string): boolean;
|
|
3790
3911
|
/** Get all keys in the store */
|
|
3791
3912
|
keys(): string[];
|
|
3792
3913
|
};
|
|
3914
|
+
type ScopedStoreType<TLeaf, TEntries extends Record<string, TLeaf> = Record<string, TLeaf>> = Readonly<TEntries> & ScopedStoreMethods<TLeaf>;
|
|
3915
|
+
interface ScopedStoreData<TLeaf> {
|
|
3916
|
+
[key: string]: TLeaf | ScopedStoreData<TLeaf>;
|
|
3917
|
+
}
|
|
3793
3918
|
/**
|
|
3794
3919
|
* Create a type-safe ScopedStore wrapper around store data.
|
|
3795
3920
|
* @param data - The raw store data (uniforms or nodes from RootState)
|
|
3796
3921
|
* @returns A ScopedStoreType wrapper with type-safe access
|
|
3797
3922
|
*/
|
|
3798
|
-
declare function createScopedStore<
|
|
3923
|
+
declare function createScopedStore<TLeaf>(data: ScopedStoreData<TLeaf>, isLeaf: ResourceLeafGuard<TLeaf>): ScopedStoreType<TLeaf>;
|
|
3799
3924
|
/**
|
|
3800
3925
|
* State type passed to creator functions with ScopedStore wrappers.
|
|
3801
3926
|
* Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
|
|
@@ -3803,8 +3928,8 @@ declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreTyp
|
|
|
3803
3928
|
type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
|
|
3804
3929
|
/** Type-safe uniform access - property access returns UniformNode */
|
|
3805
3930
|
uniforms: ScopedStoreType<UniformNode>;
|
|
3806
|
-
/** Type-safe node access
|
|
3807
|
-
nodes: ScopedStoreType<
|
|
3931
|
+
/** Type-safe node access for real, callable, and legacy structural nodes */
|
|
3932
|
+
nodes: ScopedStoreType<NodeLike>;
|
|
3808
3933
|
/** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
|
|
3809
3934
|
buffers: ScopedStoreType<BufferLike>;
|
|
3810
3935
|
/** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
|
|
@@ -3820,17 +3945,18 @@ type ClearUniformsFn = (scope?: string) => void;
|
|
|
3820
3945
|
/** Function signature for rebuildUniforms util */
|
|
3821
3946
|
type RebuildUniformsFn = (scope?: string) => void;
|
|
3822
3947
|
/** Return type with utils included */
|
|
3823
|
-
type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
|
|
3948
|
+
type UniformsWithUtils<T extends UniformRecord | UniformStore = UniformRecord> = T & {
|
|
3824
3949
|
removeUniforms: RemoveUniformsFn;
|
|
3825
3950
|
clearUniforms: ClearUniformsFn;
|
|
3826
3951
|
rebuildUniforms: RebuildUniformsFn;
|
|
3827
3952
|
};
|
|
3828
|
-
declare function useUniforms(): UniformsWithUtils<
|
|
3953
|
+
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3954
|
+
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3955
|
+
declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3956
|
+
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3957
|
+
declare function useUniforms(): UniformsWithUtils<UniformStore>;
|
|
3829
3958
|
declare function useUniforms(scope: string): UniformsWithUtils;
|
|
3830
|
-
declare function useUniforms<T extends UniformInputRecord>(
|
|
3831
|
-
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3832
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3833
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3959
|
+
declare function useUniforms<T extends UniformInputRecord>(scope?: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3834
3960
|
/**
|
|
3835
3961
|
* Global rebuildUniforms function for HMR integration.
|
|
3836
3962
|
* Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
|
|
@@ -3861,47 +3987,28 @@ declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState'])
|
|
|
3861
3987
|
|
|
3862
3988
|
/**
|
|
3863
3989
|
* Supported uniform value types:
|
|
3864
|
-
* - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
|
|
3990
|
+
* - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix2, Matrix3, Matrix4
|
|
3865
3991
|
* - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
|
|
3866
3992
|
* - TSL nodes: color(), vec3(), float(), etc. (for type casting)
|
|
3867
3993
|
* - UniformNode: existing uniforms (reused as-is)
|
|
3868
3994
|
*/
|
|
3869
|
-
type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
* - 0 → number
|
|
3873
|
-
* - true → boolean
|
|
3874
|
-
* - '#ff0000' → Color (string colors are converted to Color objects)
|
|
3875
|
-
* - Node → Node (TSL nodes passed through for uniform type casting)
|
|
3876
|
-
*/
|
|
3877
|
-
type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
|
|
3878
|
-
declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
|
|
3879
|
-
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
|
|
3995
|
+
type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
|
|
3996
|
+
declare function useUniform<T extends UniformValue = UniformValue>(name: string): UniformNodeFor<T>;
|
|
3997
|
+
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNodeFor<T>;
|
|
3880
3998
|
|
|
3881
3999
|
/**
|
|
3882
|
-
*
|
|
3883
|
-
*
|
|
3884
|
-
*
|
|
3885
|
-
*
|
|
4000
|
+
* Every node representation a creator may return. The definition lives with the store types as
|
|
4001
|
+
* `NodeLike`, so the shape creators return and the shape `state.nodes` holds are one type by
|
|
4002
|
+
* construction: three's real `Node`, the callable proxy `Fn()` returns, or the legacy structural
|
|
4003
|
+
* `{ uuid, nodeType }` shape.
|
|
3886
4004
|
*/
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
/** label method for chaining - sets the node's label and returns self */
|
|
3891
|
-
label?: ((label: string) => TSLNodeLike) | string;
|
|
3892
|
-
setName?: (name: string) => this;
|
|
3893
|
-
}
|
|
3894
|
-
/** TSL node type - alias for compatibility */
|
|
4005
|
+
type TSLNodeLike = NodeLike;
|
|
4006
|
+
|
|
4007
|
+
/** Backward-compatible alias covering every accepted node representation. */
|
|
3895
4008
|
type TSLNode = TSLNodeLike;
|
|
3896
|
-
/**
|
|
3897
|
-
* A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
|
|
3898
|
-
* Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
|
|
3899
|
-
*/
|
|
3900
|
-
type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
|
|
3901
4009
|
/**
|
|
3902
4010
|
* Creator function that returns a record of nodes.
|
|
3903
|
-
*
|
|
3904
|
-
* (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
|
|
4011
|
+
* Exact creator return inference is preserved within the compatible node constraint.
|
|
3905
4012
|
*/
|
|
3906
4013
|
type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
|
|
3907
4014
|
/** Function signature for removeNodes util */
|
|
@@ -3911,15 +4018,17 @@ type ClearNodesFn = (scope?: string) => void;
|
|
|
3911
4018
|
/** Function signature for rebuildNodes util */
|
|
3912
4019
|
type RebuildNodesFn = (scope?: string) => void;
|
|
3913
4020
|
/** Return type with utils included */
|
|
3914
|
-
type NodesWithUtils<T extends Record<string,
|
|
4021
|
+
type NodesWithUtils<T extends Record<string, unknown> = NodeRecord> = T & {
|
|
3915
4022
|
removeNodes: RemoveNodesFn;
|
|
3916
4023
|
clearNodes: ClearNodesFn;
|
|
3917
4024
|
rebuildNodes: RebuildNodesFn;
|
|
3918
4025
|
};
|
|
3919
|
-
declare function useNodes(): NodesWithUtils<
|
|
3920
|
-
declare function useNodes(scope: string): NodesWithUtils<
|
|
3921
|
-
declare function useNodes<T extends
|
|
3922
|
-
declare function useNodes<T extends
|
|
4026
|
+
declare function useNodes(): NodesWithUtils<NodeStore>;
|
|
4027
|
+
declare function useNodes(scope: string): NodesWithUtils<NodeRecord>;
|
|
4028
|
+
declare function useNodes<T extends NodeRecord>(scope?: string): NodesWithUtils<T>;
|
|
4029
|
+
declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>): NodesWithUtils<T>;
|
|
4030
|
+
declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
|
|
4031
|
+
declare function useNodes(creatorOrScope?: NodeCreator<NodeRecord> | string, scope?: string): NodesWithUtils<Record<string, unknown>>;
|
|
3923
4032
|
/**
|
|
3924
4033
|
* Global rebuildNodes function for HMR integration.
|
|
3925
4034
|
* Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
|
|
@@ -3978,6 +4087,10 @@ type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState)
|
|
|
3978
4087
|
*/
|
|
3979
4088
|
declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
|
|
3980
4089
|
|
|
4090
|
+
/**
|
|
4091
|
+
* A record of buffer-like values - allows mixed types (TypedArrays, BufferAttributes, TSL nodes)
|
|
4092
|
+
*/
|
|
4093
|
+
type BufferRecordType<T extends BufferLike = BufferLike> = Record<string, T>;
|
|
3981
4094
|
/**
|
|
3982
4095
|
* Creator function that returns a record of buffers.
|
|
3983
4096
|
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
@@ -3992,14 +4105,15 @@ type RebuildBuffersFn = (scope?: string) => void;
|
|
|
3992
4105
|
/** Function signature for disposeBuffers util - releases GPU resources */
|
|
3993
4106
|
type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
|
|
3994
4107
|
/** Return type with utils included */
|
|
3995
|
-
type BuffersWithUtils<T extends
|
|
4108
|
+
type BuffersWithUtils<T extends BufferRecordType | BufferStore = BufferRecordType> = T & {
|
|
3996
4109
|
removeBuffers: RemoveBuffersFn;
|
|
3997
4110
|
clearBuffers: ClearBuffersFn;
|
|
3998
4111
|
rebuildBuffers: RebuildBuffersFn;
|
|
3999
4112
|
disposeBuffers: DisposeBuffersFn;
|
|
4000
4113
|
};
|
|
4001
|
-
declare function useBuffers(): BuffersWithUtils<
|
|
4114
|
+
declare function useBuffers(): BuffersWithUtils<BufferStore>;
|
|
4002
4115
|
declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
|
|
4116
|
+
declare function useBuffers<T extends Record<string, BufferLike>>(scope?: string): BuffersWithUtils<T>;
|
|
4003
4117
|
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
|
|
4004
4118
|
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
|
|
4005
4119
|
/**
|
|
@@ -4015,6 +4129,10 @@ declare function useBuffers<T extends Record<string, BufferLike>>(creator: Buffe
|
|
|
4015
4129
|
*/
|
|
4016
4130
|
declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4017
4131
|
|
|
4132
|
+
/**
|
|
4133
|
+
* A record of storage-like values - allows mixed types (StorageTexture, Storage3DTexture, TSL nodes)
|
|
4134
|
+
*/
|
|
4135
|
+
type StorageRecordType<T extends StorageLike = StorageLike> = Record<string, T>;
|
|
4018
4136
|
/**
|
|
4019
4137
|
* Creator function that returns a record of GPU storage objects.
|
|
4020
4138
|
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
@@ -4029,14 +4147,15 @@ type RebuildStorageFn = (scope?: string) => void;
|
|
|
4029
4147
|
/** Function signature for disposeStorage util - releases GPU resources */
|
|
4030
4148
|
type DisposeStorageFn = (names: string | string[], scope?: string) => void;
|
|
4031
4149
|
/** Return type with utils included */
|
|
4032
|
-
type StorageWithUtils<T extends
|
|
4150
|
+
type StorageWithUtils<T extends StorageRecordType | StorageStore = StorageRecordType> = T & {
|
|
4033
4151
|
removeStorage: RemoveStorageFn;
|
|
4034
4152
|
clearStorage: ClearStorageFn;
|
|
4035
4153
|
rebuildStorage: RebuildStorageFn;
|
|
4036
4154
|
disposeStorage: DisposeStorageFn;
|
|
4037
4155
|
};
|
|
4038
|
-
declare function useGPUStorage(): StorageWithUtils<
|
|
4156
|
+
declare function useGPUStorage(): StorageWithUtils<StorageStore>;
|
|
4039
4157
|
declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
|
|
4158
|
+
declare function useGPUStorage<T extends Record<string, StorageLike>>(scope?: string): StorageWithUtils<T>;
|
|
4040
4159
|
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
|
|
4041
4160
|
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
|
|
4042
4161
|
/**
|
|
@@ -4086,6 +4205,10 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
|
|
|
4086
4205
|
* - Callbacks receive full RootState for flexibility
|
|
4087
4206
|
* - No auto-cleanup on unmount - use reset() for explicit cleanup
|
|
4088
4207
|
* - Scene/camera changes trigger scenePass recreation
|
|
4208
|
+
* - A replaced scenePass is disposed once the new graph is installed, so rebuild() does not
|
|
4209
|
+
* strand its render target (and MRT attachments) on the GPU
|
|
4210
|
+
* - Any run that changes the output node sets RenderPipeline.needsUpdate, so rebuild() actually
|
|
4211
|
+
* recompiles instead of silently keeping the first compiled graph
|
|
4089
4212
|
*
|
|
4090
4213
|
* @param mainCB - Main callback to configure outputNode and create effect passes
|
|
4091
4214
|
* @param setupCB - Optional setup callback to configure MRT on scenePass
|
|
@@ -4163,5 +4286,32 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
|
|
|
4163
4286
|
internal: WebGPUInternalState
|
|
4164
4287
|
}
|
|
4165
4288
|
|
|
4166
|
-
|
|
4167
|
-
|
|
4289
|
+
/**
|
|
4290
|
+
* @fileoverview WebGPU entry point - WebGPU only, no legacy WebGL
|
|
4291
|
+
*
|
|
4292
|
+
* This entry point is for apps that want to use ONLY WebGPURenderer.
|
|
4293
|
+
* Includes WebGPU-specific hooks (useUniforms, useNodes, useTextures).
|
|
4294
|
+
* Auto-extends THREE with WebGPU node materials (MeshBasicNodeMaterial, etc.)
|
|
4295
|
+
*
|
|
4296
|
+
* Usage:
|
|
4297
|
+
* import { Canvas, useFrame, useUniforms } from '@react-three/fiber/webgpu'
|
|
4298
|
+
*/
|
|
4299
|
+
|
|
4300
|
+
/** `useThree` narrowed to WebGPU state — `state.renderer` is a `WebGPURenderer`. */
|
|
4301
|
+
type UseThreeWebGPU = <T = WebGPURootState>(selector?: (state: WebGPURootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
|
|
4302
|
+
/** `useFrame` narrowed to WebGPU state — the callback's `state.renderer` is a `WebGPURenderer`. */
|
|
4303
|
+
type UseFrameWebGPU = (callback?: FrameCallback$1<WebGPURootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
|
|
4304
|
+
declare const useThree: UseThreeWebGPU;
|
|
4305
|
+
declare const useFrame: UseFrameWebGPU;
|
|
4306
|
+
|
|
4307
|
+
/** Canvas props on the WebGPU entry: `onCreated` receives `WebGPURootState`. */
|
|
4308
|
+
type WebGPUCanvasProps = Omit<CanvasProps, 'onCreated'> & {
|
|
4309
|
+
/** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGPURenderer` */
|
|
4310
|
+
onCreated?: (state: WebGPURootState) => void;
|
|
4311
|
+
};
|
|
4312
|
+
|
|
4313
|
+
/** `Canvas` narrowed to WebGPU state — the same component, `onCreated` typed against `WebGPURootState`. */
|
|
4314
|
+
declare const Canvas: (props: WebGPUCanvasProps) => JSX.Element;
|
|
4315
|
+
|
|
4316
|
+
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, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, 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, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, reconciler, registerPrimary, registerRootExtension, removeInteractivity, removeNodes, removeUniforms, resolve, setRenderOverride, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useBuffers, useEnvironment, useFrame, useGPUStorage, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, useRenderPipeline, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
|
|
4317
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, Camera, CameraProps, WebGPUCanvasProps as CanvasProps, CanvasSchedulerConfig, Catalogue, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DisposeBuffersFn, DisposeOptions, DisposeStorageFn, 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, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeLike, NodeProps, NodeRecord, NodeStore, NodesWithUtils, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, RebuildBuffersFn, RebuildNodesFn, RebuildStorageFn, RebuildUniformsFn, ReconcilerRoot, RemoveBuffersFn, RemoveNodesFn, RemoveStorageFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootExtension, WebGPURootState as RootState, RootStore, ScopedStoreType, SetBlock, Size, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, Subscription, TSLNode, TSLNodeInput, TSLNodeLike, TextureEntry, TextureInput, TextureNode, TextureOperations, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameWebGPU, UseTextureOptions, UseTexturesReturn, UseThreeWebGPU, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUCanvasProps, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };
|