@react-three/fiber 10.0.0-canary.e881a4a → 10.0.0-canary.ea31ccd
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2050 -1856
- package/dist/index.d.cts +310 -155
- package/dist/index.d.mts +310 -155
- package/dist/index.d.ts +308 -181
- package/dist/index.mjs +2052 -1858
- package/dist/legacy.cjs +2617 -2427
- package/dist/legacy.d.cts +313 -162
- package/dist/legacy.d.mts +313 -162
- package/dist/legacy.d.ts +311 -186
- package/dist/legacy.mjs +2619 -2429
- package/dist/webgpu/index.cjs +2161 -1942
- package/dist/webgpu/index.d.cts +390 -266
- package/dist/webgpu/index.d.mts +390 -266
- package/dist/webgpu/index.d.ts +388 -292
- package/dist/webgpu/index.mjs +2001 -1782
- package/package.json +4 -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 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';
|
|
@@ -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,7 +64,8 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
62
64
|
WebGLRenderTarget: WebGLRenderTarget,
|
|
63
65
|
WebGLRenderer: WebGLRenderer,
|
|
64
66
|
WebGLRendererParameters: WebGLRendererParameters,
|
|
65
|
-
WebGLShadowMap: WebGLShadowMap
|
|
67
|
+
WebGLShadowMap: WebGLShadowMap,
|
|
68
|
+
loadInspector: loadInspector
|
|
66
69
|
}, [three_webgpu]);
|
|
67
70
|
|
|
68
71
|
//* Utility Types ==============================
|
|
@@ -351,6 +354,7 @@ type BufferLike =
|
|
|
351
354
|
| Uint16Array
|
|
352
355
|
| Int16Array
|
|
353
356
|
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
357
|
+
| THREE$1.InterleavedBufferAttribute
|
|
354
358
|
| Node // TSL buffer nodes (instancedArray, storage)
|
|
355
359
|
|
|
356
360
|
/** Flat record of buffer-like values (no nested scopes) */
|
|
@@ -362,6 +366,25 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
362
366
|
*/
|
|
363
367
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
364
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
|
+
|
|
365
388
|
//* Storage Types (useGPUStorage) ========================================
|
|
366
389
|
|
|
367
390
|
/**
|
|
@@ -376,7 +399,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
|
376
399
|
* ```
|
|
377
400
|
*/
|
|
378
401
|
type StorageLike =
|
|
379
|
-
| 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
|
|
380
405
|
| Data3DTexture // 3D texture (can be used as storage)
|
|
381
406
|
| Node // TSL storage texture nodes (storageTexture)
|
|
382
407
|
|
|
@@ -495,11 +520,28 @@ interface InternalState {
|
|
|
495
520
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
496
521
|
container?: THREE$1.Object3D
|
|
497
522
|
/**
|
|
498
|
-
* CanvasTarget
|
|
499
|
-
*
|
|
523
|
+
* The CanvasTarget this root sizes and renders through.
|
|
524
|
+
*
|
|
525
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
526
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
527
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
528
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
529
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
500
530
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
501
531
|
*/
|
|
502
532
|
canvasTarget?: CanvasTarget
|
|
533
|
+
/**
|
|
534
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
535
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
536
|
+
*
|
|
537
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
538
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
539
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
540
|
+
* invalidate some other canvas's descriptor instead.
|
|
541
|
+
*
|
|
542
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
543
|
+
*/
|
|
544
|
+
canvasTargetSizeDirty?: boolean
|
|
503
545
|
/**
|
|
504
546
|
* Whether multi-canvas rendering is active.
|
|
505
547
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -609,7 +651,7 @@ interface RootState {
|
|
|
609
651
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
610
652
|
uniforms: UniformStore
|
|
611
653
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
612
|
-
nodes:
|
|
654
|
+
nodes: NodeStore
|
|
613
655
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
614
656
|
buffers: BufferStore
|
|
615
657
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -621,7 +663,7 @@ interface RootState {
|
|
|
621
663
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
622
664
|
renderPipeline: ThreeRenderPipeline | null
|
|
623
665
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
624
|
-
passes:
|
|
666
|
+
passes: PassRecord
|
|
625
667
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
626
668
|
_hmrVersion: number
|
|
627
669
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -709,12 +751,19 @@ type DefaultRendererProps = {
|
|
|
709
751
|
*/
|
|
710
752
|
interface CanvasSchedulerConfig {
|
|
711
753
|
/**
|
|
712
|
-
*
|
|
713
|
-
|
|
754
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
755
|
+
*/
|
|
756
|
+
before?: string | string[]
|
|
757
|
+
/**
|
|
758
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
759
|
+
*/
|
|
760
|
+
after?: string | string[]
|
|
761
|
+
/**
|
|
762
|
+
* Numeric root order. Lower values run first.
|
|
714
763
|
*/
|
|
715
|
-
|
|
764
|
+
order?: number
|
|
716
765
|
/**
|
|
717
|
-
* Limit this
|
|
766
|
+
* Limit this Canvas's default render job (frames per second).
|
|
718
767
|
*/
|
|
719
768
|
fps?: number
|
|
720
769
|
}
|
|
@@ -801,14 +850,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
801
850
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
802
851
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
803
852
|
dpr?: Dpr
|
|
804
|
-
/**
|
|
805
|
-
|
|
853
|
+
/**
|
|
854
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
855
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
856
|
+
*/
|
|
857
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
806
858
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
807
859
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
808
860
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
809
861
|
camera?: CameraProps
|
|
810
862
|
/** An R3F event manager to manage elements' pointer events */
|
|
811
|
-
events?: (store: RootStore) => EventManager<
|
|
863
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
812
864
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
813
865
|
onCreated?: (state: RootState) => void
|
|
814
866
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -897,7 +949,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
897
949
|
object?: T
|
|
898
950
|
dispose?: null
|
|
899
951
|
attach?: AttachType<T>
|
|
900
|
-
onUpdate?: (self: T) => void
|
|
901
952
|
}
|
|
902
953
|
|
|
903
954
|
interface Instance<O = any> {
|
|
@@ -1037,7 +1088,7 @@ interface CanvasProps
|
|
|
1037
1088
|
*/
|
|
1038
1089
|
resize?: Options
|
|
1039
1090
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1040
|
-
eventSource?:
|
|
1091
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1041
1092
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1042
1093
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1043
1094
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1145,81 +1196,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1145
1196
|
|
|
1146
1197
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1147
1198
|
|
|
1148
|
-
//* Global Types ==============================
|
|
1199
|
+
//* Global TSL Types ==============================
|
|
1149
1200
|
|
|
1150
1201
|
declare global {
|
|
1151
1202
|
/**
|
|
1152
|
-
*
|
|
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.
|
|
1203
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1204
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1164
1205
|
*/
|
|
1165
|
-
type
|
|
1206
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1207
|
+
readonly shaderNode: unknown
|
|
1208
|
+
readonly id: number
|
|
1209
|
+
}
|
|
1166
1210
|
|
|
1167
|
-
/**
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
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
|
|
1211
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1212
|
+
type LegacyTSLNodeLike = {
|
|
1213
|
+
label?: ((label: string) => unknown) | string
|
|
1214
|
+
setName?: (name: string) => unknown
|
|
1215
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1187
1216
|
|
|
1188
|
-
/**
|
|
1189
|
-
|
|
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>
|
|
1217
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1218
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1198
1219
|
|
|
1199
1220
|
/**
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1203
|
-
*
|
|
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
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1222
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1223
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1224
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1221
1225
|
*/
|
|
1222
|
-
type
|
|
1226
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1227
|
+
? TNodeType
|
|
1228
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1229
|
+
? TNodeType
|
|
1230
|
+
: T extends number
|
|
1231
|
+
? 'float'
|
|
1232
|
+
: T extends boolean
|
|
1233
|
+
? 'bool'
|
|
1234
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1235
|
+
? 'color'
|
|
1236
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1237
|
+
? 'vec4'
|
|
1238
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1239
|
+
? 'vec3'
|
|
1240
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1241
|
+
? 'vec2'
|
|
1242
|
+
: T extends three_webgpu.Matrix4
|
|
1243
|
+
? 'mat4'
|
|
1244
|
+
: T extends three_webgpu.Matrix3
|
|
1245
|
+
? 'mat3'
|
|
1246
|
+
: T extends three_webgpu.Matrix2
|
|
1247
|
+
? 'mat2'
|
|
1248
|
+
: unknown
|
|
1249
|
+
|
|
1250
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1251
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1252
|
+
? TValue
|
|
1253
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1254
|
+
? TValue
|
|
1255
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1256
|
+
? three_webgpu.Color
|
|
1257
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1258
|
+
? three_webgpu.Vector4
|
|
1259
|
+
: T extends { x: number; y: number; z: number }
|
|
1260
|
+
? three_webgpu.Vector3
|
|
1261
|
+
: T extends { x: number; y: number }
|
|
1262
|
+
? three_webgpu.Vector2
|
|
1263
|
+
: T extends number
|
|
1264
|
+
? number
|
|
1265
|
+
: T extends boolean
|
|
1266
|
+
? boolean
|
|
1267
|
+
: T
|
|
1268
|
+
|
|
1269
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1270
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1271
|
+
|
|
1272
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1273
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1274
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1278
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1223
1279
|
|
|
1224
1280
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1225
1281
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1244,7 +1300,7 @@ declare global {
|
|
|
1244
1300
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1245
1301
|
* Supports:
|
|
1246
1302
|
* - Primitives: number, string (color), boolean
|
|
1247
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1303
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1248
1304
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1249
1305
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1250
1306
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1257,88 +1313,124 @@ declare global {
|
|
|
1257
1313
|
| three_webgpu.Vector2
|
|
1258
1314
|
| three_webgpu.Vector3
|
|
1259
1315
|
| three_webgpu.Vector4
|
|
1316
|
+
| three_webgpu.Matrix2
|
|
1260
1317
|
| three_webgpu.Matrix3
|
|
1261
1318
|
| three_webgpu.Matrix4
|
|
1262
|
-
|
|
|
1263
|
-
|
|
|
1264
|
-
| { x: number; y
|
|
1319
|
+
| { x: number; y: number }
|
|
1320
|
+
| { x: number; y: number; z: number }
|
|
1321
|
+
| { x: number; y: number; z: number; w: number }
|
|
1265
1322
|
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1266
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1323
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1267
1324
|
| UniformNode
|
|
1268
1325
|
|
|
1269
1326
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1270
1327
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1271
1328
|
}
|
|
1272
1329
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
declare module 'three/tsl' {
|
|
1330
|
+
declare global {
|
|
1276
1331
|
/**
|
|
1277
|
-
*
|
|
1278
|
-
*
|
|
1332
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1333
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1334
|
+
* is r185, so the new name is the only one.
|
|
1279
1335
|
*/
|
|
1280
|
-
|
|
1281
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1282
|
-
): ShaderCallable<R>
|
|
1336
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1283
1337
|
|
|
1284
1338
|
/**
|
|
1285
|
-
*
|
|
1286
|
-
*
|
|
1339
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1340
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1341
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1287
1342
|
*/
|
|
1288
|
-
|
|
1289
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1290
|
-
): ShaderCallable<R>
|
|
1343
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1291
1344
|
|
|
1292
1345
|
/**
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1346
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1347
|
+
*
|
|
1348
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1349
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1350
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1351
|
+
* {@link RenderPipelineCallbackState}.
|
|
1352
|
+
*
|
|
1353
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1354
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1355
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1356
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1357
|
+
*
|
|
1358
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1359
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1360
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1361
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1295
1362
|
*/
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1363
|
+
interface PassRecord {
|
|
1364
|
+
scenePass?: ScenePassNode
|
|
1365
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1366
|
+
}
|
|
1300
1367
|
|
|
1301
1368
|
/**
|
|
1302
|
-
*
|
|
1369
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1370
|
+
*
|
|
1371
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1372
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1373
|
+
*
|
|
1374
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1375
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1303
1376
|
*/
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1377
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1378
|
+
renderPipeline: ThreeRenderPipeline
|
|
1379
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1380
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1381
|
+
isLegacy: false
|
|
1382
|
+
}
|
|
1309
1383
|
|
|
1310
|
-
declare global {
|
|
1311
1384
|
/**
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
* is
|
|
1385
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1386
|
+
*
|
|
1387
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1388
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1389
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1390
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1315
1391
|
*/
|
|
1316
|
-
type
|
|
1317
|
-
|
|
1318
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1319
|
-
type PassRecord = Record<string, any>
|
|
1392
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1320
1393
|
|
|
1321
1394
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1322
|
-
type RenderPipelineSetupCallback = (state:
|
|
1395
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1323
1396
|
|
|
1324
1397
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1325
|
-
type RenderPipelineMainCallback = (state:
|
|
1398
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1326
1399
|
|
|
1327
|
-
/**
|
|
1328
|
-
interface
|
|
1400
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1401
|
+
interface UseRenderPipelineActions {
|
|
1329
1402
|
/** Current passes from state */
|
|
1330
1403
|
passes: PassRecord
|
|
1331
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1332
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1333
1404
|
/** Clear all passes from state */
|
|
1334
1405
|
clearPasses: () => void
|
|
1335
1406
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1336
1407
|
reset: () => void
|
|
1337
1408
|
/** Re-run setup/main callbacks with current closure values */
|
|
1338
1409
|
rebuild: () => void
|
|
1339
|
-
/** True when RenderPipeline is configured and ready */
|
|
1340
|
-
isReady: boolean
|
|
1341
1410
|
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1414
|
+
*
|
|
1415
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1416
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1417
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1418
|
+
*/
|
|
1419
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1420
|
+
(
|
|
1421
|
+
| {
|
|
1422
|
+
/** True when RenderPipeline is configured and ready */
|
|
1423
|
+
isReady: true
|
|
1424
|
+
/** RenderPipeline instance */
|
|
1425
|
+
renderPipeline: ThreeRenderPipeline
|
|
1426
|
+
}
|
|
1427
|
+
| {
|
|
1428
|
+
/** False until the pipeline has been created */
|
|
1429
|
+
isReady: false
|
|
1430
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1431
|
+
renderPipeline: null
|
|
1432
|
+
}
|
|
1433
|
+
)
|
|
1342
1434
|
}
|
|
1343
1435
|
|
|
1344
1436
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1417,10 +1509,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1417
1509
|
|
|
1418
1510
|
/**
|
|
1419
1511
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1420
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1512
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1513
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1421
1514
|
*/
|
|
1422
1515
|
type NodeProps<P> = {
|
|
1423
|
-
[K in keyof P as P[K] extends
|
|
1516
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1424
1517
|
}
|
|
1425
1518
|
|
|
1426
1519
|
interface ReactProps<P> {
|
|
@@ -1441,11 +1534,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1441
1534
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1442
1535
|
}
|
|
1443
1536
|
|
|
1537
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1538
|
+
type Object3DMethod = NonNullable<
|
|
1539
|
+
{
|
|
1540
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1541
|
+
}[keyof Object3D]
|
|
1542
|
+
>
|
|
1543
|
+
|
|
1444
1544
|
type ThreeExports = typeof THREE
|
|
1445
1545
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1446
1546
|
|
|
1447
1547
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1448
|
-
|
|
1548
|
+
/**
|
|
1549
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1550
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1551
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1552
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1553
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1554
|
+
*/
|
|
1555
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1556
|
+
object: object
|
|
1557
|
+
ref?: React.Ref<any>
|
|
1558
|
+
[prop: string]: unknown
|
|
1559
|
+
}
|
|
1449
1560
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1450
1561
|
threeAudio: ThreeElementsImpl['audio']
|
|
1451
1562
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1486,6 +1597,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1486
1597
|
type three_d_Matrix4 = Matrix4;
|
|
1487
1598
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1488
1599
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1600
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1489
1601
|
type three_d_Quaternion = Quaternion;
|
|
1490
1602
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1491
1603
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1500,7 +1612,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1500
1612
|
type three_d_Vector4 = Vector4;
|
|
1501
1613
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1502
1614
|
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 };
|
|
1615
|
+
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
1616
|
}
|
|
1505
1617
|
|
|
1506
1618
|
/**
|
|
@@ -1638,9 +1750,9 @@ type EnvironmentProps = {
|
|
|
1638
1750
|
blur?: number;
|
|
1639
1751
|
backgroundBlurriness?: number;
|
|
1640
1752
|
backgroundIntensity?: number;
|
|
1641
|
-
backgroundRotation?: Euler
|
|
1753
|
+
backgroundRotation?: Euler;
|
|
1642
1754
|
environmentIntensity?: number;
|
|
1643
|
-
environmentRotation?: Euler
|
|
1755
|
+
environmentRotation?: Euler;
|
|
1644
1756
|
map?: Texture$1;
|
|
1645
1757
|
preset?: PresetsType;
|
|
1646
1758
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -1724,7 +1836,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
1724
1836
|
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
1837
|
declare module '@react-three/fiber' {
|
|
1726
1838
|
interface ThreeElements {
|
|
1727
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1839
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
1728
1840
|
}
|
|
1729
1841
|
}
|
|
1730
1842
|
/**
|
|
@@ -1824,6 +1936,24 @@ declare module '@react-three/fiber' {
|
|
|
1824
1936
|
*/
|
|
1825
1937
|
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
1826
1938
|
|
|
1939
|
+
/**
|
|
1940
|
+
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
1941
|
+
*
|
|
1942
|
+
* When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
|
|
1943
|
+
* instance. Removing the old object from the interaction state and registering the new one from
|
|
1944
|
+
* scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
|
|
1945
|
+
* the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
|
|
1946
|
+
* is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
|
|
1947
|
+
* swap the user never asked to see (#3744).
|
|
1948
|
+
*
|
|
1949
|
+
* Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
|
|
1950
|
+
* left alone — releasing and re-acquiring it is precisely the glitch being avoided.
|
|
1951
|
+
*
|
|
1952
|
+
* Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
|
|
1953
|
+
* the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
|
|
1954
|
+
* cannot outlive the object it described.
|
|
1955
|
+
*/
|
|
1956
|
+
declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
|
|
1827
1957
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
1828
1958
|
declare function createEvents(store: RootStore): {
|
|
1829
1959
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
@@ -1831,7 +1961,7 @@ declare function createEvents(store: RootStore): {
|
|
|
1831
1961
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1832
1962
|
};
|
|
1833
1963
|
/** Default R3F event manager for web */
|
|
1834
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1964
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1835
1965
|
|
|
1836
1966
|
/**
|
|
1837
1967
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -1851,50 +1981,6 @@ declare namespace useLoader {
|
|
|
1851
1981
|
var loader: typeof getLoader;
|
|
1852
1982
|
}
|
|
1853
1983
|
|
|
1854
|
-
/**
|
|
1855
|
-
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
1856
|
-
*
|
|
1857
|
-
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1858
|
-
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1859
|
-
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1860
|
-
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1861
|
-
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
1862
|
-
*
|
|
1863
|
-
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
1864
|
-
*
|
|
1865
|
-
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1866
|
-
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1867
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1868
|
-
*
|
|
1869
|
-
* @example
|
|
1870
|
-
* // Simple priority (backwards compat)
|
|
1871
|
-
* useFrame((state, delta) => { ... }, 5)
|
|
1872
|
-
*
|
|
1873
|
-
* @example
|
|
1874
|
-
* // With phase-based ordering
|
|
1875
|
-
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
1876
|
-
*
|
|
1877
|
-
* @example
|
|
1878
|
-
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
1879
|
-
* function UI() {
|
|
1880
|
-
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
1881
|
-
* return <button>...</button>;
|
|
1882
|
-
* }
|
|
1883
|
-
*
|
|
1884
|
-
* @example
|
|
1885
|
-
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
1886
|
-
* import { getScheduler } from '@pmndrs/scheduler'
|
|
1887
|
-
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
1888
|
-
*
|
|
1889
|
-
* @example
|
|
1890
|
-
* // Scheduler-only access (no callback)
|
|
1891
|
-
* const { scheduler } = useFrame()
|
|
1892
|
-
* scheduler.pauseJob('some-job-id')
|
|
1893
|
-
*
|
|
1894
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1895
|
-
*/
|
|
1896
|
-
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
1897
|
-
|
|
1898
1984
|
declare const IsObject: (url: unknown) => url is Record<string, string>;
|
|
1899
1985
|
type TextureArray<T> = T extends string[] ? Texture$1[] : never;
|
|
1900
1986
|
type TextureRecord<T> = T extends Record<string, string> ? {
|
|
@@ -2080,11 +2166,6 @@ declare function useRenderTarget(width: number, height: number, options?: Render
|
|
|
2080
2166
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2081
2167
|
*/
|
|
2082
2168
|
declare function useStore(): RootStore;
|
|
2083
|
-
/**
|
|
2084
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2085
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2086
|
-
*/
|
|
2087
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2088
2169
|
/**
|
|
2089
2170
|
* Exposes an object's {@link Instance}.
|
|
2090
2171
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2160,7 +2241,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2160
2241
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2161
2242
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2162
2243
|
*
|
|
2163
|
-
*
|
|
2244
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2245
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2246
|
+
*
|
|
2247
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2164
2248
|
* @param frames - Number of frames to request (default: 1)
|
|
2165
2249
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2166
2250
|
*
|
|
@@ -2171,14 +2255,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2171
2255
|
* Advances the frameloop and runs render effects.
|
|
2172
2256
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2173
2257
|
*
|
|
2258
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2259
|
+
* registered root is stepped for backwards compatibility.
|
|
2260
|
+
*
|
|
2174
2261
|
* @param timestamp - The timestamp to use for this frame
|
|
2175
2262
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2176
|
-
* @param state -
|
|
2177
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2263
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2178
2264
|
*
|
|
2179
2265
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2180
2266
|
*/
|
|
2181
|
-
declare function advance(timestamp: number): void;
|
|
2267
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2182
2268
|
|
|
2183
2269
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2184
2270
|
declare function ReactReconciler<
|
|
@@ -3223,6 +3309,7 @@ declare namespace ReactReconciler {
|
|
|
3223
3309
|
|
|
3224
3310
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3225
3311
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3312
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3226
3313
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3227
3314
|
|
|
3228
3315
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3249,11 +3336,6 @@ declare function flushSync<R>(fn: () => R): R;
|
|
|
3249
3336
|
declare const context: React$1.Context<RootStore>;
|
|
3250
3337
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3251
3338
|
|
|
3252
|
-
/**
|
|
3253
|
-
* Safely flush async effects when testing, simulating a legacy root.
|
|
3254
|
-
* @deprecated Import from React instead. import { act } from 'react'
|
|
3255
|
-
*/
|
|
3256
|
-
declare const act: typeof React$1.act;
|
|
3257
3339
|
/**
|
|
3258
3340
|
* An SSR-friendly useLayoutEffect.
|
|
3259
3341
|
*
|
|
@@ -3505,7 +3587,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
3505
3587
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
3506
3588
|
/**
|
|
3507
3589
|
* Triggers an update for an instance.
|
|
3508
|
-
*
|
|
3590
|
+
* Invalidates the frame if the root is in demand mode.
|
|
3509
3591
|
*
|
|
3510
3592
|
* @param instance - Instance to invalidate
|
|
3511
3593
|
*/
|
|
@@ -3671,29 +3753,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3671
3753
|
* Used to identify values that should be resolved from refs after mount.
|
|
3672
3754
|
*/
|
|
3673
3755
|
declare const FROM_REF: unique symbol;
|
|
3756
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3757
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3758
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3759
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3760
|
+
transform?: (value: T) => R;
|
|
3761
|
+
}
|
|
3674
3762
|
/**
|
|
3675
3763
|
* Defers prop application until the referenced object is available.
|
|
3676
3764
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3677
3765
|
*
|
|
3766
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3767
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3768
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3769
|
+
* what gets assigned.
|
|
3770
|
+
*
|
|
3678
3771
|
* @param ref - React ref object to resolve at mount time
|
|
3679
|
-
* @
|
|
3772
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3773
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3680
3774
|
*
|
|
3681
3775
|
* @example
|
|
3682
3776
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3683
3777
|
*
|
|
3684
3778
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3685
3779
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3780
|
+
*
|
|
3781
|
+
* @example
|
|
3782
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3783
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3686
3784
|
*/
|
|
3687
3785
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3786
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3688
3787
|
/**
|
|
3689
3788
|
* Type guard to check if a value is a fromRef marker.
|
|
3690
3789
|
*
|
|
3691
3790
|
* @param value - Value to check
|
|
3692
3791
|
* @returns True if value is a fromRef marker
|
|
3693
3792
|
*/
|
|
3694
|
-
declare function isFromRef(value: unknown): value is
|
|
3695
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3696
|
-
};
|
|
3793
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3697
3794
|
|
|
3698
3795
|
/**
|
|
3699
3796
|
* Symbol marker for mount-only method calls.
|
|
@@ -3720,7 +3817,15 @@ declare const ONCE: unique symbol;
|
|
|
3720
3817
|
* // No arguments
|
|
3721
3818
|
* <geometry center={once()} />
|
|
3722
3819
|
*/
|
|
3723
|
-
declare function once<
|
|
3820
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3821
|
+
/**
|
|
3822
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3823
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3824
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3825
|
+
*
|
|
3826
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3827
|
+
*/
|
|
3828
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3724
3829
|
/**
|
|
3725
3830
|
* Type guard to check if a value is a once marker.
|
|
3726
3831
|
*
|
|
@@ -3731,11 +3836,8 @@ declare function isOnce(value: unknown): value is {
|
|
|
3731
3836
|
[ONCE]: any[] | true;
|
|
3732
3837
|
};
|
|
3733
3838
|
|
|
3734
|
-
/**
|
|
3735
|
-
|
|
3736
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
3737
|
-
*/
|
|
3738
|
-
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3839
|
+
/** Distinguishes a resource leaf from a nested resource scope. */
|
|
3840
|
+
type ResourceLeafGuard<T> = (value: unknown) => value is T;
|
|
3739
3841
|
|
|
3740
3842
|
/**
|
|
3741
3843
|
* ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
|
|
@@ -3757,33 +3859,30 @@ declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
|
3757
3859
|
* ```
|
|
3758
3860
|
*/
|
|
3759
3861
|
|
|
3760
|
-
/** Keys reserved for methods (excluded from index signature) */
|
|
3761
|
-
type MethodKeys = 'scope' | 'has' | 'keys';
|
|
3762
3862
|
/**
|
|
3763
3863
|
* Type-safe wrapper interface for accessing nested store data.
|
|
3764
3864
|
* Property access returns `T` (assumes leaf node).
|
|
3765
3865
|
* Use `.scope(key)` for nested object access.
|
|
3766
3866
|
*
|
|
3767
|
-
* Uses mapped type with key filtering to exclude method names from index signature,
|
|
3768
|
-
* allowing methods to have their correct return types.
|
|
3769
3867
|
*/
|
|
3770
|
-
type
|
|
3771
|
-
/** Direct property access returns the leaf type T (method keys excluded) */
|
|
3772
|
-
readonly [K in string as K extends MethodKeys ? never : K]: T;
|
|
3773
|
-
} & {
|
|
3868
|
+
type ScopedStoreMethods<TLeaf> = {
|
|
3774
3869
|
/** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
|
|
3775
|
-
scope(key: string): ScopedStoreType<
|
|
3870
|
+
scope<TScope extends Record<string, TLeaf> = Record<string, TLeaf>>(key: string): ScopedStoreType<TLeaf, TScope>;
|
|
3776
3871
|
/** Check if a key exists in the store */
|
|
3777
3872
|
has(key: string): boolean;
|
|
3778
3873
|
/** Get all keys in the store */
|
|
3779
3874
|
keys(): string[];
|
|
3780
3875
|
};
|
|
3876
|
+
type ScopedStoreType<TLeaf, TEntries extends Record<string, TLeaf> = Record<string, TLeaf>> = Readonly<TEntries> & ScopedStoreMethods<TLeaf>;
|
|
3877
|
+
interface ScopedStoreData<TLeaf> {
|
|
3878
|
+
[key: string]: TLeaf | ScopedStoreData<TLeaf>;
|
|
3879
|
+
}
|
|
3781
3880
|
/**
|
|
3782
3881
|
* Create a type-safe ScopedStore wrapper around store data.
|
|
3783
3882
|
* @param data - The raw store data (uniforms or nodes from RootState)
|
|
3784
3883
|
* @returns A ScopedStoreType wrapper with type-safe access
|
|
3785
3884
|
*/
|
|
3786
|
-
declare function createScopedStore<
|
|
3885
|
+
declare function createScopedStore<TLeaf>(data: ScopedStoreData<TLeaf>, isLeaf: ResourceLeafGuard<TLeaf>): ScopedStoreType<TLeaf>;
|
|
3787
3886
|
/**
|
|
3788
3887
|
* State type passed to creator functions with ScopedStore wrappers.
|
|
3789
3888
|
* Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
|
|
@@ -3791,8 +3890,8 @@ declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreTyp
|
|
|
3791
3890
|
type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
|
|
3792
3891
|
/** Type-safe uniform access - property access returns UniformNode */
|
|
3793
3892
|
uniforms: ScopedStoreType<UniformNode>;
|
|
3794
|
-
/** Type-safe node access
|
|
3795
|
-
nodes: ScopedStoreType<
|
|
3893
|
+
/** Type-safe node access for real, callable, and legacy structural nodes */
|
|
3894
|
+
nodes: ScopedStoreType<NodeLike>;
|
|
3796
3895
|
/** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
|
|
3797
3896
|
buffers: ScopedStoreType<BufferLike>;
|
|
3798
3897
|
/** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
|
|
@@ -3808,17 +3907,18 @@ type ClearUniformsFn = (scope?: string) => void;
|
|
|
3808
3907
|
/** Function signature for rebuildUniforms util */
|
|
3809
3908
|
type RebuildUniformsFn = (scope?: string) => void;
|
|
3810
3909
|
/** Return type with utils included */
|
|
3811
|
-
type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
|
|
3910
|
+
type UniformsWithUtils<T extends UniformRecord | UniformStore = UniformRecord> = T & {
|
|
3812
3911
|
removeUniforms: RemoveUniformsFn;
|
|
3813
3912
|
clearUniforms: ClearUniformsFn;
|
|
3814
3913
|
rebuildUniforms: RebuildUniformsFn;
|
|
3815
3914
|
};
|
|
3816
|
-
declare function useUniforms(): UniformsWithUtils<
|
|
3915
|
+
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3916
|
+
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3917
|
+
declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3918
|
+
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3919
|
+
declare function useUniforms(): UniformsWithUtils<UniformStore>;
|
|
3817
3920
|
declare function useUniforms(scope: string): UniformsWithUtils;
|
|
3818
|
-
declare function useUniforms<T extends UniformInputRecord>(
|
|
3819
|
-
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3820
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3821
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3921
|
+
declare function useUniforms<T extends UniformInputRecord>(scope?: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3822
3922
|
/**
|
|
3823
3923
|
* Global rebuildUniforms function for HMR integration.
|
|
3824
3924
|
* Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
|
|
@@ -3849,47 +3949,28 @@ declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState'])
|
|
|
3849
3949
|
|
|
3850
3950
|
/**
|
|
3851
3951
|
* Supported uniform value types:
|
|
3852
|
-
* - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
|
|
3952
|
+
* - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix2, Matrix3, Matrix4
|
|
3853
3953
|
* - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
|
|
3854
3954
|
* - TSL nodes: color(), vec3(), float(), etc. (for type casting)
|
|
3855
3955
|
* - UniformNode: existing uniforms (reused as-is)
|
|
3856
3956
|
*/
|
|
3857
|
-
type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
* - 0 → number
|
|
3861
|
-
* - true → boolean
|
|
3862
|
-
* - '#ff0000' → Color (string colors are converted to Color objects)
|
|
3863
|
-
* - Node → Node (TSL nodes passed through for uniform type casting)
|
|
3864
|
-
*/
|
|
3865
|
-
type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
|
|
3866
|
-
declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
|
|
3867
|
-
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
|
|
3957
|
+
type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
|
|
3958
|
+
declare function useUniform<T extends UniformValue = UniformValue>(name: string): UniformNodeFor<T>;
|
|
3959
|
+
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNodeFor<T>;
|
|
3868
3960
|
|
|
3869
3961
|
/**
|
|
3870
|
-
*
|
|
3871
|
-
*
|
|
3872
|
-
*
|
|
3873
|
-
*
|
|
3962
|
+
* Every node representation a creator may return. The definition lives with the store types as
|
|
3963
|
+
* `NodeLike`, so the shape creators return and the shape `state.nodes` holds are one type by
|
|
3964
|
+
* construction: three's real `Node`, the callable proxy `Fn()` returns, or the legacy structural
|
|
3965
|
+
* `{ uuid, nodeType }` shape.
|
|
3874
3966
|
*/
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
/** label method for chaining - sets the node's label and returns self */
|
|
3879
|
-
label?: ((label: string) => TSLNodeLike) | string;
|
|
3880
|
-
setName?: (name: string) => this;
|
|
3881
|
-
}
|
|
3882
|
-
/** TSL node type - alias for compatibility */
|
|
3967
|
+
type TSLNodeLike = NodeLike;
|
|
3968
|
+
|
|
3969
|
+
/** Backward-compatible alias covering every accepted node representation. */
|
|
3883
3970
|
type TSLNode = TSLNodeLike;
|
|
3884
|
-
/**
|
|
3885
|
-
* A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
|
|
3886
|
-
* Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
|
|
3887
|
-
*/
|
|
3888
|
-
type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
|
|
3889
3971
|
/**
|
|
3890
3972
|
* Creator function that returns a record of nodes.
|
|
3891
|
-
*
|
|
3892
|
-
* (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
|
|
3973
|
+
* Exact creator return inference is preserved within the compatible node constraint.
|
|
3893
3974
|
*/
|
|
3894
3975
|
type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
|
|
3895
3976
|
/** Function signature for removeNodes util */
|
|
@@ -3899,15 +3980,17 @@ type ClearNodesFn = (scope?: string) => void;
|
|
|
3899
3980
|
/** Function signature for rebuildNodes util */
|
|
3900
3981
|
type RebuildNodesFn = (scope?: string) => void;
|
|
3901
3982
|
/** Return type with utils included */
|
|
3902
|
-
type NodesWithUtils<T extends Record<string,
|
|
3983
|
+
type NodesWithUtils<T extends Record<string, unknown> = NodeRecord> = T & {
|
|
3903
3984
|
removeNodes: RemoveNodesFn;
|
|
3904
3985
|
clearNodes: ClearNodesFn;
|
|
3905
3986
|
rebuildNodes: RebuildNodesFn;
|
|
3906
3987
|
};
|
|
3907
|
-
declare function useNodes(): NodesWithUtils<
|
|
3908
|
-
declare function useNodes(scope: string): NodesWithUtils<
|
|
3909
|
-
declare function useNodes<T extends
|
|
3910
|
-
declare function useNodes<T extends
|
|
3988
|
+
declare function useNodes(): NodesWithUtils<NodeStore>;
|
|
3989
|
+
declare function useNodes(scope: string): NodesWithUtils<NodeRecord>;
|
|
3990
|
+
declare function useNodes<T extends NodeRecord>(scope?: string): NodesWithUtils<T>;
|
|
3991
|
+
declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>): NodesWithUtils<T>;
|
|
3992
|
+
declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
|
|
3993
|
+
declare function useNodes(creatorOrScope?: NodeCreator<NodeRecord> | string, scope?: string): NodesWithUtils<Record<string, unknown>>;
|
|
3911
3994
|
/**
|
|
3912
3995
|
* Global rebuildNodes function for HMR integration.
|
|
3913
3996
|
* Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
|
|
@@ -3966,6 +4049,10 @@ type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState)
|
|
|
3966
4049
|
*/
|
|
3967
4050
|
declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
|
|
3968
4051
|
|
|
4052
|
+
/**
|
|
4053
|
+
* A record of buffer-like values - allows mixed types (TypedArrays, BufferAttributes, TSL nodes)
|
|
4054
|
+
*/
|
|
4055
|
+
type BufferRecordType<T extends BufferLike = BufferLike> = Record<string, T>;
|
|
3969
4056
|
/**
|
|
3970
4057
|
* Creator function that returns a record of buffers.
|
|
3971
4058
|
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
@@ -3980,14 +4067,15 @@ type RebuildBuffersFn = (scope?: string) => void;
|
|
|
3980
4067
|
/** Function signature for disposeBuffers util - releases GPU resources */
|
|
3981
4068
|
type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
|
|
3982
4069
|
/** Return type with utils included */
|
|
3983
|
-
type BuffersWithUtils<T extends
|
|
4070
|
+
type BuffersWithUtils<T extends BufferRecordType | BufferStore = BufferRecordType> = T & {
|
|
3984
4071
|
removeBuffers: RemoveBuffersFn;
|
|
3985
4072
|
clearBuffers: ClearBuffersFn;
|
|
3986
4073
|
rebuildBuffers: RebuildBuffersFn;
|
|
3987
4074
|
disposeBuffers: DisposeBuffersFn;
|
|
3988
4075
|
};
|
|
3989
|
-
declare function useBuffers(): BuffersWithUtils<
|
|
4076
|
+
declare function useBuffers(): BuffersWithUtils<BufferStore>;
|
|
3990
4077
|
declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
|
|
4078
|
+
declare function useBuffers<T extends Record<string, BufferLike>>(scope?: string): BuffersWithUtils<T>;
|
|
3991
4079
|
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
|
|
3992
4080
|
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
|
|
3993
4081
|
/**
|
|
@@ -4003,6 +4091,10 @@ declare function useBuffers<T extends Record<string, BufferLike>>(creator: Buffe
|
|
|
4003
4091
|
*/
|
|
4004
4092
|
declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4005
4093
|
|
|
4094
|
+
/**
|
|
4095
|
+
* A record of storage-like values - allows mixed types (StorageTexture, Storage3DTexture, TSL nodes)
|
|
4096
|
+
*/
|
|
4097
|
+
type StorageRecordType<T extends StorageLike = StorageLike> = Record<string, T>;
|
|
4006
4098
|
/**
|
|
4007
4099
|
* Creator function that returns a record of GPU storage objects.
|
|
4008
4100
|
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
@@ -4017,14 +4109,15 @@ type RebuildStorageFn = (scope?: string) => void;
|
|
|
4017
4109
|
/** Function signature for disposeStorage util - releases GPU resources */
|
|
4018
4110
|
type DisposeStorageFn = (names: string | string[], scope?: string) => void;
|
|
4019
4111
|
/** Return type with utils included */
|
|
4020
|
-
type StorageWithUtils<T extends
|
|
4112
|
+
type StorageWithUtils<T extends StorageRecordType | StorageStore = StorageRecordType> = T & {
|
|
4021
4113
|
removeStorage: RemoveStorageFn;
|
|
4022
4114
|
clearStorage: ClearStorageFn;
|
|
4023
4115
|
rebuildStorage: RebuildStorageFn;
|
|
4024
4116
|
disposeStorage: DisposeStorageFn;
|
|
4025
4117
|
};
|
|
4026
|
-
declare function useGPUStorage(): StorageWithUtils<
|
|
4118
|
+
declare function useGPUStorage(): StorageWithUtils<StorageStore>;
|
|
4027
4119
|
declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
|
|
4120
|
+
declare function useGPUStorage<T extends Record<string, StorageLike>>(scope?: string): StorageWithUtils<T>;
|
|
4028
4121
|
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
|
|
4029
4122
|
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
|
|
4030
4123
|
/**
|
|
@@ -4074,6 +4167,10 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
|
|
|
4074
4167
|
* - Callbacks receive full RootState for flexibility
|
|
4075
4168
|
* - No auto-cleanup on unmount - use reset() for explicit cleanup
|
|
4076
4169
|
* - Scene/camera changes trigger scenePass recreation
|
|
4170
|
+
* - A replaced scenePass is disposed once the new graph is installed, so rebuild() does not
|
|
4171
|
+
* strand its render target (and MRT attachments) on the GPU
|
|
4172
|
+
* - Any run that changes the output node sets RenderPipeline.needsUpdate, so rebuild() actually
|
|
4173
|
+
* recompiles instead of silently keeping the first compiled graph
|
|
4077
4174
|
*
|
|
4078
4175
|
* @param mainCB - Main callback to configure outputNode and create effect passes
|
|
4079
4176
|
* @param setupCB - Optional setup callback to configure MRT on scenePass
|
|
@@ -4151,5 +4248,32 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
|
|
|
4151
4248
|
internal: WebGPUInternalState
|
|
4152
4249
|
}
|
|
4153
4250
|
|
|
4154
|
-
|
|
4155
|
-
|
|
4251
|
+
/**
|
|
4252
|
+
* @fileoverview WebGPU entry point - WebGPU only, no legacy WebGL
|
|
4253
|
+
*
|
|
4254
|
+
* This entry point is for apps that want to use ONLY WebGPURenderer.
|
|
4255
|
+
* Includes WebGPU-specific hooks (useUniforms, useNodes, useTextures).
|
|
4256
|
+
* Auto-extends THREE with WebGPU node materials (MeshBasicNodeMaterial, etc.)
|
|
4257
|
+
*
|
|
4258
|
+
* Usage:
|
|
4259
|
+
* import { Canvas, useFrame, useUniforms } from '@react-three/fiber/webgpu'
|
|
4260
|
+
*/
|
|
4261
|
+
|
|
4262
|
+
/** `useThree` narrowed to WebGPU state — `state.renderer` is a `WebGPURenderer`. */
|
|
4263
|
+
type UseThreeWebGPU = <T = WebGPURootState>(selector?: (state: WebGPURootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
|
|
4264
|
+
/** `useFrame` narrowed to WebGPU state — the callback's `state.renderer` is a `WebGPURenderer`. */
|
|
4265
|
+
type UseFrameWebGPU = (callback?: FrameCallback$1<WebGPURootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
|
|
4266
|
+
declare const useThree: UseThreeWebGPU;
|
|
4267
|
+
declare const useFrame: UseFrameWebGPU;
|
|
4268
|
+
|
|
4269
|
+
/** Canvas props on the WebGPU entry: `onCreated` receives `WebGPURootState`. */
|
|
4270
|
+
type WebGPUCanvasProps = Omit<CanvasProps, 'onCreated'> & {
|
|
4271
|
+
/** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGPURenderer` */
|
|
4272
|
+
onCreated?: (state: WebGPURootState) => void;
|
|
4273
|
+
};
|
|
4274
|
+
|
|
4275
|
+
/** `Canvas` narrowed to WebGPU state — the same component, `onCreated` typed against `WebGPURootState`. */
|
|
4276
|
+
declare const Canvas: (props: WebGPUCanvasProps) => JSX.Element;
|
|
4277
|
+
|
|
4278
|
+
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, removeInteractivity, removeNodes, removeUniforms, resolve, 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 };
|
|
4279
|
+
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, 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 };
|