@react-three/fiber 10.0.0-canary.da7a768 → 10.0.0-canary.dc0ec15
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 +994 -898
- package/dist/index.d.cts +331 -155
- package/dist/index.d.mts +331 -155
- package/dist/index.d.ts +331 -183
- package/dist/index.mjs +995 -901
- package/dist/legacy.cjs +1345 -1245
- package/dist/legacy.d.cts +353 -205
- package/dist/legacy.d.mts +353 -205
- package/dist/legacy.d.ts +353 -231
- package/dist/legacy.mjs +1346 -1248
- package/dist/webgpu/index.cjs +908 -713
- package/dist/webgpu/index.d.cts +389 -212
- package/dist/webgpu/index.d.mts +389 -212
- package/dist/webgpu/index.d.ts +389 -240
- package/dist/webgpu/index.mjs +910 -717
- package/package.json +7 -2
package/dist/webgpu/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
|
|
2
2
|
import * as three_webgpu from 'three/webgpu';
|
|
3
|
-
import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget,
|
|
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';
|
|
4
4
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
5
5
|
import * as THREE$1 from 'three';
|
|
6
6
|
import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
@@ -14,20 +14,6 @@ import { Options } from 'react-use-measure';
|
|
|
14
14
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
15
15
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
16
16
|
|
|
17
|
-
function _mergeNamespaces(n, m) {
|
|
18
|
-
m.forEach(function (e) {
|
|
19
|
-
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
20
|
-
if (k !== 'default' && !(k in n)) {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return e[k]; }
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
return Object.freeze(n);
|
|
30
|
-
}
|
|
31
17
|
|
|
32
18
|
/**
|
|
33
19
|
* @fileoverview Internal Three.js re-exports - WEBGPU ONLY ENTRY
|
|
@@ -53,20 +39,6 @@ declare const WebGLRenderTarget: any;
|
|
|
53
39
|
|
|
54
40
|
declare const WebGLCubeRenderTarget: any;
|
|
55
41
|
|
|
56
|
-
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
57
|
-
__proto__: null,
|
|
58
|
-
CubeRenderTargetCompat: CubeRenderTarget,
|
|
59
|
-
Inspector: Inspector,
|
|
60
|
-
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
61
|
-
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
62
|
-
RenderTargetCompat: RenderTarget,
|
|
63
|
-
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
64
|
-
WebGLRenderTarget: WebGLRenderTarget,
|
|
65
|
-
WebGLRenderer: WebGLRenderer,
|
|
66
|
-
WebGLRendererParameters: WebGLRendererParameters,
|
|
67
|
-
WebGLShadowMap: WebGLShadowMap,
|
|
68
|
-
loadInspector: loadInspector
|
|
69
|
-
}, [three_webgpu]);
|
|
70
42
|
|
|
71
43
|
//* Utility Types ==============================
|
|
72
44
|
|
|
@@ -354,6 +326,7 @@ type BufferLike =
|
|
|
354
326
|
| Uint16Array
|
|
355
327
|
| Int16Array
|
|
356
328
|
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
329
|
+
| THREE$1.InterleavedBufferAttribute
|
|
357
330
|
| Node // TSL buffer nodes (instancedArray, storage)
|
|
358
331
|
|
|
359
332
|
/** Flat record of buffer-like values (no nested scopes) */
|
|
@@ -365,6 +338,25 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
365
338
|
*/
|
|
366
339
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
367
340
|
|
|
341
|
+
//* Node Types (useNodes) ========================================
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
345
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
346
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
347
|
+
* and the shape the store holds are one type by construction.
|
|
348
|
+
*/
|
|
349
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
350
|
+
|
|
351
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
352
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
356
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
357
|
+
*/
|
|
358
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
359
|
+
|
|
368
360
|
//* Storage Types (useGPUStorage) ========================================
|
|
369
361
|
|
|
370
362
|
/**
|
|
@@ -379,7 +371,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
|
379
371
|
* ```
|
|
380
372
|
*/
|
|
381
373
|
type StorageLike =
|
|
382
|
-
| StorageTexture // GPU storage texture
|
|
374
|
+
| StorageTexture // 2D GPU storage texture
|
|
375
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
376
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
383
377
|
| Data3DTexture // 3D texture (can be used as storage)
|
|
384
378
|
| Node // TSL storage texture nodes (storageTexture)
|
|
385
379
|
|
|
@@ -491,6 +485,12 @@ interface InternalState {
|
|
|
491
485
|
actualRenderer: R3FRenderer
|
|
492
486
|
/** Global scheduler reference (for useFrame hook) */
|
|
493
487
|
scheduler: SchedulerApi | null
|
|
488
|
+
/**
|
|
489
|
+
* Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
|
|
490
|
+
* `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
|
|
491
|
+
* render-phase takeover. Used by `useRenderPipeline`.
|
|
492
|
+
*/
|
|
493
|
+
renderOverride?: (() => void) | null
|
|
494
494
|
/** This root's unique ID in the global scheduler */
|
|
495
495
|
rootId?: string
|
|
496
496
|
/** Function to unregister this root from the global scheduler */
|
|
@@ -498,11 +498,28 @@ interface InternalState {
|
|
|
498
498
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
499
499
|
container?: THREE$1.Object3D
|
|
500
500
|
/**
|
|
501
|
-
* CanvasTarget
|
|
502
|
-
*
|
|
501
|
+
* The CanvasTarget this root sizes and renders through.
|
|
502
|
+
*
|
|
503
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
504
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
505
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
506
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
507
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
503
508
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
504
509
|
*/
|
|
505
510
|
canvasTarget?: CanvasTarget
|
|
511
|
+
/**
|
|
512
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
513
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
514
|
+
*
|
|
515
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
516
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
517
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
518
|
+
* invalidate some other canvas's descriptor instead.
|
|
519
|
+
*
|
|
520
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
521
|
+
*/
|
|
522
|
+
canvasTargetSizeDirty?: boolean
|
|
506
523
|
/**
|
|
507
524
|
* Whether multi-canvas rendering is active.
|
|
508
525
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -612,7 +629,7 @@ interface RootState {
|
|
|
612
629
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
613
630
|
uniforms: UniformStore
|
|
614
631
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
615
|
-
nodes:
|
|
632
|
+
nodes: NodeStore
|
|
616
633
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
617
634
|
buffers: BufferStore
|
|
618
635
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -624,7 +641,7 @@ interface RootState {
|
|
|
624
641
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
625
642
|
renderPipeline: ThreeRenderPipeline | null
|
|
626
643
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
627
|
-
passes:
|
|
644
|
+
passes: PassRecord
|
|
628
645
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
629
646
|
_hmrVersion: number
|
|
630
647
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -712,12 +729,19 @@ type DefaultRendererProps = {
|
|
|
712
729
|
*/
|
|
713
730
|
interface CanvasSchedulerConfig {
|
|
714
731
|
/**
|
|
715
|
-
*
|
|
716
|
-
|
|
732
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
733
|
+
*/
|
|
734
|
+
before?: string | string[]
|
|
735
|
+
/**
|
|
736
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
717
737
|
*/
|
|
718
|
-
after?: string
|
|
738
|
+
after?: string | string[]
|
|
719
739
|
/**
|
|
720
|
-
*
|
|
740
|
+
* Numeric root order. Lower values run first.
|
|
741
|
+
*/
|
|
742
|
+
order?: number
|
|
743
|
+
/**
|
|
744
|
+
* Limit this Canvas's default render job (frames per second).
|
|
721
745
|
*/
|
|
722
746
|
fps?: number
|
|
723
747
|
}
|
|
@@ -804,14 +828,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
804
828
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
805
829
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
806
830
|
dpr?: Dpr
|
|
807
|
-
/**
|
|
808
|
-
|
|
831
|
+
/**
|
|
832
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
833
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
834
|
+
*/
|
|
835
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
809
836
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
810
837
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
811
838
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
812
839
|
camera?: CameraProps
|
|
813
840
|
/** An R3F event manager to manage elements' pointer events */
|
|
814
|
-
events?: (store: RootStore) => EventManager<
|
|
841
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
815
842
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
816
843
|
onCreated?: (state: RootState) => void
|
|
817
844
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -900,7 +927,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
900
927
|
object?: T
|
|
901
928
|
dispose?: null
|
|
902
929
|
attach?: AttachType<T>
|
|
903
|
-
onUpdate?: (self: T) => void
|
|
904
930
|
}
|
|
905
931
|
|
|
906
932
|
interface Instance<O = any> {
|
|
@@ -1040,7 +1066,7 @@ interface CanvasProps
|
|
|
1040
1066
|
*/
|
|
1041
1067
|
resize?: Options
|
|
1042
1068
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1043
|
-
eventSource?:
|
|
1069
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1044
1070
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1045
1071
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1046
1072
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1148,81 +1174,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1148
1174
|
|
|
1149
1175
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1150
1176
|
|
|
1151
|
-
//* Global Types ==============================
|
|
1177
|
+
//* Global TSL Types ==============================
|
|
1152
1178
|
|
|
1153
1179
|
declare global {
|
|
1154
1180
|
/**
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1158
|
-
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1159
|
-
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1160
|
-
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1161
|
-
* arity when three made `UniformNode` two-parameter.
|
|
1162
|
-
*
|
|
1163
|
-
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1164
|
-
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1165
|
-
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1166
|
-
* installed three instead of needing to be mirrored by hand.
|
|
1181
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1182
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1167
1183
|
*/
|
|
1168
|
-
type
|
|
1184
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1185
|
+
readonly shaderNode: unknown
|
|
1186
|
+
readonly id: number
|
|
1187
|
+
}
|
|
1169
1188
|
|
|
1170
|
-
/**
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
* @example
|
|
1176
|
-
* ```tsx
|
|
1177
|
-
* // Define a shader function
|
|
1178
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1179
|
-
* return mix(color1, color2, factor)
|
|
1180
|
-
* })
|
|
1181
|
-
*
|
|
1182
|
-
* // Type when retrieving from nodes store
|
|
1183
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1184
|
-
*
|
|
1185
|
-
* // Or with specific return type
|
|
1186
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1187
|
-
* ```
|
|
1188
|
-
*/
|
|
1189
|
-
type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
|
|
1189
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1190
|
+
type LegacyTSLNodeLike = {
|
|
1191
|
+
label?: ((label: string) => unknown) | string
|
|
1192
|
+
setName?: (name: string) => unknown
|
|
1193
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1190
1194
|
|
|
1191
|
-
/**
|
|
1192
|
-
|
|
1193
|
-
* This is the common return type for TSL operations (add, mul, sin, etc.)
|
|
1194
|
-
*
|
|
1195
|
-
* @example
|
|
1196
|
-
* ```tsx
|
|
1197
|
-
* const { wobble } = nodes as { wobble: ShaderNodeRef }
|
|
1198
|
-
* ```
|
|
1199
|
-
*/
|
|
1200
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1195
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1196
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1201
1197
|
|
|
1202
1198
|
/**
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1207
|
-
* - Node: base Three.js node type
|
|
1208
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1209
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1210
|
-
*
|
|
1211
|
-
* @example
|
|
1212
|
-
* ```tsx
|
|
1213
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1214
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1215
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1216
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1217
|
-
* }))
|
|
1218
|
-
*
|
|
1219
|
-
* // Can narrow with type guard or assertion when needed
|
|
1220
|
-
* if (typeof blendColorFn === 'function') {
|
|
1221
|
-
* blendColorFn(someColor, 0.5)
|
|
1222
|
-
* }
|
|
1223
|
-
* ```
|
|
1199
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1200
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1201
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1202
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1224
1203
|
*/
|
|
1225
|
-
type
|
|
1204
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1205
|
+
? TNodeType
|
|
1206
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1207
|
+
? TNodeType
|
|
1208
|
+
: T extends number
|
|
1209
|
+
? 'float'
|
|
1210
|
+
: T extends boolean
|
|
1211
|
+
? 'bool'
|
|
1212
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1213
|
+
? 'color'
|
|
1214
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1215
|
+
? 'vec4'
|
|
1216
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1217
|
+
? 'vec3'
|
|
1218
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1219
|
+
? 'vec2'
|
|
1220
|
+
: T extends three_webgpu.Matrix4
|
|
1221
|
+
? 'mat4'
|
|
1222
|
+
: T extends three_webgpu.Matrix3
|
|
1223
|
+
? 'mat3'
|
|
1224
|
+
: T extends three_webgpu.Matrix2
|
|
1225
|
+
? 'mat2'
|
|
1226
|
+
: unknown
|
|
1227
|
+
|
|
1228
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1229
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1230
|
+
? TValue
|
|
1231
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1232
|
+
? TValue
|
|
1233
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1234
|
+
? three_webgpu.Color
|
|
1235
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1236
|
+
? three_webgpu.Vector4
|
|
1237
|
+
: T extends { x: number; y: number; z: number }
|
|
1238
|
+
? three_webgpu.Vector3
|
|
1239
|
+
: T extends { x: number; y: number }
|
|
1240
|
+
? three_webgpu.Vector2
|
|
1241
|
+
: T extends number
|
|
1242
|
+
? number
|
|
1243
|
+
: T extends boolean
|
|
1244
|
+
? boolean
|
|
1245
|
+
: T
|
|
1246
|
+
|
|
1247
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1248
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1249
|
+
|
|
1250
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1251
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1252
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1256
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1226
1257
|
|
|
1227
1258
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1228
1259
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1247,7 +1278,7 @@ declare global {
|
|
|
1247
1278
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1248
1279
|
* Supports:
|
|
1249
1280
|
* - Primitives: number, string (color), boolean
|
|
1250
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1281
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1251
1282
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1252
1283
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1253
1284
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1260,88 +1291,124 @@ declare global {
|
|
|
1260
1291
|
| three_webgpu.Vector2
|
|
1261
1292
|
| three_webgpu.Vector3
|
|
1262
1293
|
| three_webgpu.Vector4
|
|
1294
|
+
| three_webgpu.Matrix2
|
|
1263
1295
|
| three_webgpu.Matrix3
|
|
1264
1296
|
| three_webgpu.Matrix4
|
|
1265
|
-
|
|
|
1266
|
-
|
|
|
1267
|
-
| { x: number; y
|
|
1297
|
+
| { x: number; y: number }
|
|
1298
|
+
| { x: number; y: number; z: number }
|
|
1299
|
+
| { x: number; y: number; z: number; w: number }
|
|
1268
1300
|
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1269
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1301
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1270
1302
|
| UniformNode
|
|
1271
1303
|
|
|
1272
1304
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1273
1305
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1274
1306
|
}
|
|
1275
1307
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
declare module 'three/tsl' {
|
|
1308
|
+
declare global {
|
|
1279
1309
|
/**
|
|
1280
|
-
*
|
|
1281
|
-
*
|
|
1310
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1311
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1312
|
+
* is r185, so the new name is the only one.
|
|
1282
1313
|
*/
|
|
1283
|
-
|
|
1284
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1285
|
-
): ShaderCallable<R>
|
|
1314
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1286
1315
|
|
|
1287
1316
|
/**
|
|
1288
|
-
*
|
|
1289
|
-
*
|
|
1317
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1318
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1319
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1290
1320
|
*/
|
|
1291
|
-
|
|
1292
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1293
|
-
): ShaderCallable<R>
|
|
1321
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1294
1322
|
|
|
1295
1323
|
/**
|
|
1296
|
-
*
|
|
1297
|
-
*
|
|
1324
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1325
|
+
*
|
|
1326
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1327
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1328
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1329
|
+
* {@link RenderPipelineCallbackState}.
|
|
1330
|
+
*
|
|
1331
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1332
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1333
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1334
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1335
|
+
*
|
|
1336
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1337
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1338
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1339
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1298
1340
|
*/
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1341
|
+
interface PassRecord {
|
|
1342
|
+
scenePass?: ScenePassNode
|
|
1343
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1344
|
+
}
|
|
1303
1345
|
|
|
1304
1346
|
/**
|
|
1305
|
-
*
|
|
1347
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1348
|
+
*
|
|
1349
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1350
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1351
|
+
*
|
|
1352
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1353
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1306
1354
|
*/
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1355
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1356
|
+
renderPipeline: ThreeRenderPipeline
|
|
1357
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1358
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1359
|
+
isLegacy: false
|
|
1360
|
+
}
|
|
1312
1361
|
|
|
1313
|
-
declare global {
|
|
1314
1362
|
/**
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
* is
|
|
1363
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1364
|
+
*
|
|
1365
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1366
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1367
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1368
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1318
1369
|
*/
|
|
1319
|
-
type
|
|
1320
|
-
|
|
1321
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1322
|
-
type PassRecord = Record<string, any>
|
|
1370
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1323
1371
|
|
|
1324
1372
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1325
|
-
type RenderPipelineSetupCallback = (state:
|
|
1373
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1326
1374
|
|
|
1327
1375
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1328
|
-
type RenderPipelineMainCallback = (state:
|
|
1376
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1329
1377
|
|
|
1330
|
-
/**
|
|
1331
|
-
interface
|
|
1378
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1379
|
+
interface UseRenderPipelineActions {
|
|
1332
1380
|
/** Current passes from state */
|
|
1333
1381
|
passes: PassRecord
|
|
1334
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1335
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1336
1382
|
/** Clear all passes from state */
|
|
1337
1383
|
clearPasses: () => void
|
|
1338
1384
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1339
1385
|
reset: () => void
|
|
1340
1386
|
/** Re-run setup/main callbacks with current closure values */
|
|
1341
1387
|
rebuild: () => void
|
|
1342
|
-
/** True when RenderPipeline is configured and ready */
|
|
1343
|
-
isReady: boolean
|
|
1344
1388
|
}
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1392
|
+
*
|
|
1393
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1394
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1395
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1396
|
+
*/
|
|
1397
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1398
|
+
(
|
|
1399
|
+
| {
|
|
1400
|
+
/** True when RenderPipeline is configured and ready */
|
|
1401
|
+
isReady: true
|
|
1402
|
+
/** RenderPipeline instance */
|
|
1403
|
+
renderPipeline: ThreeRenderPipeline
|
|
1404
|
+
}
|
|
1405
|
+
| {
|
|
1406
|
+
/** False until the pipeline has been created */
|
|
1407
|
+
isReady: false
|
|
1408
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1409
|
+
renderPipeline: null
|
|
1410
|
+
}
|
|
1411
|
+
)
|
|
1345
1412
|
}
|
|
1346
1413
|
|
|
1347
1414
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1420,10 +1487,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1420
1487
|
|
|
1421
1488
|
/**
|
|
1422
1489
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1423
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1490
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1491
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1424
1492
|
*/
|
|
1425
1493
|
type NodeProps<P> = {
|
|
1426
|
-
[K in keyof P as P[K] extends
|
|
1494
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1427
1495
|
}
|
|
1428
1496
|
|
|
1429
1497
|
interface ReactProps<P> {
|
|
@@ -1444,11 +1512,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1444
1512
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1445
1513
|
}
|
|
1446
1514
|
|
|
1515
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1516
|
+
type Object3DMethod = NonNullable<
|
|
1517
|
+
{
|
|
1518
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1519
|
+
}[keyof Object3D]
|
|
1520
|
+
>
|
|
1521
|
+
|
|
1447
1522
|
type ThreeExports = typeof import('three/webgpu')
|
|
1448
1523
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1449
1524
|
|
|
1450
1525
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1451
|
-
|
|
1526
|
+
/**
|
|
1527
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1528
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1529
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1530
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1531
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1532
|
+
*/
|
|
1533
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1534
|
+
object: object
|
|
1535
|
+
ref?: React.Ref<any>
|
|
1536
|
+
[prop: string]: unknown
|
|
1537
|
+
}
|
|
1452
1538
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1453
1539
|
threeAudio: ThreeElementsImpl['audio']
|
|
1454
1540
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1489,6 +1575,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1489
1575
|
type three_d_Matrix4 = Matrix4;
|
|
1490
1576
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1491
1577
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1578
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1492
1579
|
type three_d_Quaternion = Quaternion;
|
|
1493
1580
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1494
1581
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1503,7 +1590,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1503
1590
|
type three_d_Vector4 = Vector4;
|
|
1504
1591
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1505
1592
|
declare namespace three_d {
|
|
1506
|
-
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 };
|
|
1593
|
+
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 };
|
|
1507
1594
|
}
|
|
1508
1595
|
|
|
1509
1596
|
/**
|
|
@@ -1852,7 +1939,43 @@ declare function createEvents(store: RootStore): {
|
|
|
1852
1939
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1853
1940
|
};
|
|
1854
1941
|
/** Default R3F event manager for web */
|
|
1855
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1942
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1943
|
+
|
|
1944
|
+
interface RootExtension {
|
|
1945
|
+
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
1946
|
+
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
1947
|
+
name: string;
|
|
1948
|
+
/**
|
|
1949
|
+
* Called once per root, after its renderer exists and before `onCreated` and the first frame.
|
|
1950
|
+
* `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
|
|
1951
|
+
* to the primary canvas. Return fields to merge into the root's state, or nothing.
|
|
1952
|
+
*/
|
|
1953
|
+
setup?(store: RootStore): Partial<RootState> | void;
|
|
1954
|
+
/** Called when a root this extension set up unmounts. */
|
|
1955
|
+
dispose?(store: RootStore): void;
|
|
1956
|
+
/** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
|
|
1957
|
+
hmr?(store: RootStore): void;
|
|
1958
|
+
}
|
|
1959
|
+
/**
|
|
1960
|
+
* Register an extension. It is set up on every live root immediately, and on every root created
|
|
1961
|
+
* afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
|
|
1962
|
+
* it already set up keep its state and still get its dispose when they unmount.
|
|
1963
|
+
*/
|
|
1964
|
+
declare function registerRootExtension(extension: RootExtension): () => void;
|
|
1965
|
+
/**
|
|
1966
|
+
* Point a root's default render job at a different render function, or back at
|
|
1967
|
+
* `renderer.render(scene, camera)` with `null`.
|
|
1968
|
+
*
|
|
1969
|
+
* The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
|
|
1970
|
+
* boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
|
|
1971
|
+
*/
|
|
1972
|
+
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
1973
|
+
|
|
1974
|
+
/**
|
|
1975
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
1976
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
1977
|
+
*/
|
|
1978
|
+
declare function useStore(): RootStore;
|
|
1856
1979
|
|
|
1857
1980
|
/**
|
|
1858
1981
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -2052,11 +2175,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
|
|
|
2052
2175
|
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
|
|
2053
2176
|
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
|
|
2054
2177
|
|
|
2055
|
-
/**
|
|
2056
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2057
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2058
|
-
*/
|
|
2059
|
-
declare function useStore(): RootStore;
|
|
2060
2178
|
/**
|
|
2061
2179
|
* Exposes an object's {@link Instance}.
|
|
2062
2180
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2132,7 +2250,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2132
2250
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2133
2251
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2134
2252
|
*
|
|
2135
|
-
*
|
|
2253
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2254
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2255
|
+
*
|
|
2256
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2136
2257
|
* @param frames - Number of frames to request (default: 1)
|
|
2137
2258
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2138
2259
|
*
|
|
@@ -2143,14 +2264,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2143
2264
|
* Advances the frameloop and runs render effects.
|
|
2144
2265
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2145
2266
|
*
|
|
2267
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2268
|
+
* registered root is stepped for backwards compatibility.
|
|
2269
|
+
*
|
|
2146
2270
|
* @param timestamp - The timestamp to use for this frame
|
|
2147
2271
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2148
|
-
* @param state -
|
|
2149
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2272
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2150
2273
|
*
|
|
2151
2274
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2152
2275
|
*/
|
|
2153
|
-
declare function advance(timestamp: number): void;
|
|
2276
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2154
2277
|
|
|
2155
2278
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2156
2279
|
declare function ReactReconciler<
|
|
@@ -3195,6 +3318,7 @@ declare namespace ReactReconciler {
|
|
|
3195
3318
|
|
|
3196
3319
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3197
3320
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3321
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3198
3322
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3199
3323
|
|
|
3200
3324
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3219,6 +3343,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
3219
3343
|
declare function flushSync<R>(fn: () => R): R;
|
|
3220
3344
|
|
|
3221
3345
|
declare const context: React$1.Context<RootStore>;
|
|
3346
|
+
|
|
3222
3347
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3223
3348
|
|
|
3224
3349
|
/**
|
|
@@ -3472,7 +3597,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
3472
3597
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
3473
3598
|
/**
|
|
3474
3599
|
* Triggers an update for an instance.
|
|
3475
|
-
*
|
|
3600
|
+
* Invalidates the frame if the root is in demand mode.
|
|
3476
3601
|
*
|
|
3477
3602
|
* @param instance - Instance to invalidate
|
|
3478
3603
|
*/
|
|
@@ -3638,29 +3763,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3638
3763
|
* Used to identify values that should be resolved from refs after mount.
|
|
3639
3764
|
*/
|
|
3640
3765
|
declare const FROM_REF: unique symbol;
|
|
3766
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3767
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3768
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3769
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3770
|
+
transform?: (value: T) => R;
|
|
3771
|
+
}
|
|
3641
3772
|
/**
|
|
3642
3773
|
* Defers prop application until the referenced object is available.
|
|
3643
3774
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3644
3775
|
*
|
|
3776
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3777
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3778
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3779
|
+
* what gets assigned.
|
|
3780
|
+
*
|
|
3645
3781
|
* @param ref - React ref object to resolve at mount time
|
|
3646
|
-
* @
|
|
3782
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3783
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3647
3784
|
*
|
|
3648
3785
|
* @example
|
|
3649
3786
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3650
3787
|
*
|
|
3651
3788
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3652
3789
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3790
|
+
*
|
|
3791
|
+
* @example
|
|
3792
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3793
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3653
3794
|
*/
|
|
3654
3795
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3796
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3655
3797
|
/**
|
|
3656
3798
|
* Type guard to check if a value is a fromRef marker.
|
|
3657
3799
|
*
|
|
3658
3800
|
* @param value - Value to check
|
|
3659
3801
|
* @returns True if value is a fromRef marker
|
|
3660
3802
|
*/
|
|
3661
|
-
declare function isFromRef(value: unknown): value is
|
|
3662
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3663
|
-
};
|
|
3803
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3664
3804
|
|
|
3665
3805
|
/**
|
|
3666
3806
|
* Symbol marker for mount-only method calls.
|
|
@@ -3687,7 +3827,15 @@ declare const ONCE: unique symbol;
|
|
|
3687
3827
|
* // No arguments
|
|
3688
3828
|
* <geometry center={once()} />
|
|
3689
3829
|
*/
|
|
3690
|
-
declare function once<
|
|
3830
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3831
|
+
/**
|
|
3832
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3833
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3834
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3835
|
+
*
|
|
3836
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3837
|
+
*/
|
|
3838
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3691
3839
|
/**
|
|
3692
3840
|
* Type guard to check if a value is a once marker.
|
|
3693
3841
|
*
|
|
@@ -3698,11 +3846,8 @@ declare function isOnce(value: unknown): value is {
|
|
|
3698
3846
|
[ONCE]: any[] | true;
|
|
3699
3847
|
};
|
|
3700
3848
|
|
|
3701
|
-
/**
|
|
3702
|
-
|
|
3703
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
3704
|
-
*/
|
|
3705
|
-
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3849
|
+
/** Distinguishes a resource leaf from a nested resource scope. */
|
|
3850
|
+
type ResourceLeafGuard<T> = (value: unknown) => value is T;
|
|
3706
3851
|
|
|
3707
3852
|
/**
|
|
3708
3853
|
* ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
|
|
@@ -3724,33 +3869,30 @@ declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
|
3724
3869
|
* ```
|
|
3725
3870
|
*/
|
|
3726
3871
|
|
|
3727
|
-
/** Keys reserved for methods (excluded from index signature) */
|
|
3728
|
-
type MethodKeys = 'scope' | 'has' | 'keys';
|
|
3729
3872
|
/**
|
|
3730
3873
|
* Type-safe wrapper interface for accessing nested store data.
|
|
3731
3874
|
* Property access returns `T` (assumes leaf node).
|
|
3732
3875
|
* Use `.scope(key)` for nested object access.
|
|
3733
3876
|
*
|
|
3734
|
-
* Uses mapped type with key filtering to exclude method names from index signature,
|
|
3735
|
-
* allowing methods to have their correct return types.
|
|
3736
3877
|
*/
|
|
3737
|
-
type
|
|
3738
|
-
/** Direct property access returns the leaf type T (method keys excluded) */
|
|
3739
|
-
readonly [K in string as K extends MethodKeys ? never : K]: T;
|
|
3740
|
-
} & {
|
|
3878
|
+
type ScopedStoreMethods<TLeaf> = {
|
|
3741
3879
|
/** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
|
|
3742
|
-
scope(key: string): ScopedStoreType<
|
|
3880
|
+
scope<TScope extends Record<string, TLeaf> = Record<string, TLeaf>>(key: string): ScopedStoreType<TLeaf, TScope>;
|
|
3743
3881
|
/** Check if a key exists in the store */
|
|
3744
3882
|
has(key: string): boolean;
|
|
3745
3883
|
/** Get all keys in the store */
|
|
3746
3884
|
keys(): string[];
|
|
3747
3885
|
};
|
|
3886
|
+
type ScopedStoreType<TLeaf, TEntries extends Record<string, TLeaf> = Record<string, TLeaf>> = Readonly<TEntries> & ScopedStoreMethods<TLeaf>;
|
|
3887
|
+
interface ScopedStoreData<TLeaf> {
|
|
3888
|
+
[key: string]: TLeaf | ScopedStoreData<TLeaf>;
|
|
3889
|
+
}
|
|
3748
3890
|
/**
|
|
3749
3891
|
* Create a type-safe ScopedStore wrapper around store data.
|
|
3750
3892
|
* @param data - The raw store data (uniforms or nodes from RootState)
|
|
3751
3893
|
* @returns A ScopedStoreType wrapper with type-safe access
|
|
3752
3894
|
*/
|
|
3753
|
-
declare function createScopedStore<
|
|
3895
|
+
declare function createScopedStore<TLeaf>(data: ScopedStoreData<TLeaf>, isLeaf: ResourceLeafGuard<TLeaf>): ScopedStoreType<TLeaf>;
|
|
3754
3896
|
/**
|
|
3755
3897
|
* State type passed to creator functions with ScopedStore wrappers.
|
|
3756
3898
|
* Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
|
|
@@ -3758,8 +3900,8 @@ declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreTyp
|
|
|
3758
3900
|
type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
|
|
3759
3901
|
/** Type-safe uniform access - property access returns UniformNode */
|
|
3760
3902
|
uniforms: ScopedStoreType<UniformNode>;
|
|
3761
|
-
/** Type-safe node access
|
|
3762
|
-
nodes: ScopedStoreType<
|
|
3903
|
+
/** Type-safe node access for real, callable, and legacy structural nodes */
|
|
3904
|
+
nodes: ScopedStoreType<NodeLike>;
|
|
3763
3905
|
/** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
|
|
3764
3906
|
buffers: ScopedStoreType<BufferLike>;
|
|
3765
3907
|
/** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
|
|
@@ -3775,17 +3917,18 @@ type ClearUniformsFn = (scope?: string) => void;
|
|
|
3775
3917
|
/** Function signature for rebuildUniforms util */
|
|
3776
3918
|
type RebuildUniformsFn = (scope?: string) => void;
|
|
3777
3919
|
/** Return type with utils included */
|
|
3778
|
-
type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
|
|
3920
|
+
type UniformsWithUtils<T extends UniformRecord | UniformStore = UniformRecord> = T & {
|
|
3779
3921
|
removeUniforms: RemoveUniformsFn;
|
|
3780
3922
|
clearUniforms: ClearUniformsFn;
|
|
3781
3923
|
rebuildUniforms: RebuildUniformsFn;
|
|
3782
3924
|
};
|
|
3783
|
-
declare function useUniforms(): UniformsWithUtils<
|
|
3925
|
+
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3926
|
+
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3927
|
+
declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3928
|
+
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3929
|
+
declare function useUniforms(): UniformsWithUtils<UniformStore>;
|
|
3784
3930
|
declare function useUniforms(scope: string): UniformsWithUtils;
|
|
3785
|
-
declare function useUniforms<T extends UniformInputRecord>(
|
|
3786
|
-
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3787
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3788
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3931
|
+
declare function useUniforms<T extends UniformInputRecord>(scope?: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3789
3932
|
/**
|
|
3790
3933
|
* Global rebuildUniforms function for HMR integration.
|
|
3791
3934
|
* Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
|
|
@@ -3816,47 +3959,28 @@ declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState'])
|
|
|
3816
3959
|
|
|
3817
3960
|
/**
|
|
3818
3961
|
* Supported uniform value types:
|
|
3819
|
-
* - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
|
|
3962
|
+
* - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix2, Matrix3, Matrix4
|
|
3820
3963
|
* - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
|
|
3821
3964
|
* - TSL nodes: color(), vec3(), float(), etc. (for type casting)
|
|
3822
3965
|
* - UniformNode: existing uniforms (reused as-is)
|
|
3823
3966
|
*/
|
|
3824
|
-
type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
* - 0 → number
|
|
3828
|
-
* - true → boolean
|
|
3829
|
-
* - '#ff0000' → Color (string colors are converted to Color objects)
|
|
3830
|
-
* - Node → Node (TSL nodes passed through for uniform type casting)
|
|
3831
|
-
*/
|
|
3832
|
-
type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
|
|
3833
|
-
declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
|
|
3834
|
-
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
|
|
3967
|
+
type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
|
|
3968
|
+
declare function useUniform<T extends UniformValue = UniformValue>(name: string): UniformNodeFor<T>;
|
|
3969
|
+
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNodeFor<T>;
|
|
3835
3970
|
|
|
3836
3971
|
/**
|
|
3837
|
-
*
|
|
3838
|
-
*
|
|
3839
|
-
*
|
|
3840
|
-
*
|
|
3972
|
+
* Every node representation a creator may return. The definition lives with the store types as
|
|
3973
|
+
* `NodeLike`, so the shape creators return and the shape `state.nodes` holds are one type by
|
|
3974
|
+
* construction: three's real `Node`, the callable proxy `Fn()` returns, or the legacy structural
|
|
3975
|
+
* `{ uuid, nodeType }` shape.
|
|
3841
3976
|
*/
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
/** label method for chaining - sets the node's label and returns self */
|
|
3846
|
-
label?: ((label: string) => TSLNodeLike) | string;
|
|
3847
|
-
setName?: (name: string) => this;
|
|
3848
|
-
}
|
|
3849
|
-
/** TSL node type - alias for compatibility */
|
|
3977
|
+
type TSLNodeLike = NodeLike;
|
|
3978
|
+
|
|
3979
|
+
/** Backward-compatible alias covering every accepted node representation. */
|
|
3850
3980
|
type TSLNode = TSLNodeLike;
|
|
3851
|
-
/**
|
|
3852
|
-
* A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
|
|
3853
|
-
* Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
|
|
3854
|
-
*/
|
|
3855
|
-
type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
|
|
3856
3981
|
/**
|
|
3857
3982
|
* Creator function that returns a record of nodes.
|
|
3858
|
-
*
|
|
3859
|
-
* (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
|
|
3983
|
+
* Exact creator return inference is preserved within the compatible node constraint.
|
|
3860
3984
|
*/
|
|
3861
3985
|
type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
|
|
3862
3986
|
/** Function signature for removeNodes util */
|
|
@@ -3866,15 +3990,17 @@ type ClearNodesFn = (scope?: string) => void;
|
|
|
3866
3990
|
/** Function signature for rebuildNodes util */
|
|
3867
3991
|
type RebuildNodesFn = (scope?: string) => void;
|
|
3868
3992
|
/** Return type with utils included */
|
|
3869
|
-
type NodesWithUtils<T extends Record<string,
|
|
3993
|
+
type NodesWithUtils<T extends Record<string, unknown> = NodeRecord> = T & {
|
|
3870
3994
|
removeNodes: RemoveNodesFn;
|
|
3871
3995
|
clearNodes: ClearNodesFn;
|
|
3872
3996
|
rebuildNodes: RebuildNodesFn;
|
|
3873
3997
|
};
|
|
3874
|
-
declare function useNodes(): NodesWithUtils<
|
|
3875
|
-
declare function useNodes(scope: string): NodesWithUtils<
|
|
3876
|
-
declare function useNodes<T extends
|
|
3877
|
-
declare function useNodes<T extends
|
|
3998
|
+
declare function useNodes(): NodesWithUtils<NodeStore>;
|
|
3999
|
+
declare function useNodes(scope: string): NodesWithUtils<NodeRecord>;
|
|
4000
|
+
declare function useNodes<T extends NodeRecord>(scope?: string): NodesWithUtils<T>;
|
|
4001
|
+
declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>): NodesWithUtils<T>;
|
|
4002
|
+
declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
|
|
4003
|
+
declare function useNodes(creatorOrScope?: NodeCreator<NodeRecord> | string, scope?: string): NodesWithUtils<Record<string, unknown>>;
|
|
3878
4004
|
/**
|
|
3879
4005
|
* Global rebuildNodes function for HMR integration.
|
|
3880
4006
|
* Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
|
|
@@ -3933,6 +4059,10 @@ type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState)
|
|
|
3933
4059
|
*/
|
|
3934
4060
|
declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
|
|
3935
4061
|
|
|
4062
|
+
/**
|
|
4063
|
+
* A record of buffer-like values - allows mixed types (TypedArrays, BufferAttributes, TSL nodes)
|
|
4064
|
+
*/
|
|
4065
|
+
type BufferRecordType<T extends BufferLike = BufferLike> = Record<string, T>;
|
|
3936
4066
|
/**
|
|
3937
4067
|
* Creator function that returns a record of buffers.
|
|
3938
4068
|
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
@@ -3947,14 +4077,15 @@ type RebuildBuffersFn = (scope?: string) => void;
|
|
|
3947
4077
|
/** Function signature for disposeBuffers util - releases GPU resources */
|
|
3948
4078
|
type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
|
|
3949
4079
|
/** Return type with utils included */
|
|
3950
|
-
type BuffersWithUtils<T extends
|
|
4080
|
+
type BuffersWithUtils<T extends BufferRecordType | BufferStore = BufferRecordType> = T & {
|
|
3951
4081
|
removeBuffers: RemoveBuffersFn;
|
|
3952
4082
|
clearBuffers: ClearBuffersFn;
|
|
3953
4083
|
rebuildBuffers: RebuildBuffersFn;
|
|
3954
4084
|
disposeBuffers: DisposeBuffersFn;
|
|
3955
4085
|
};
|
|
3956
|
-
declare function useBuffers(): BuffersWithUtils<
|
|
4086
|
+
declare function useBuffers(): BuffersWithUtils<BufferStore>;
|
|
3957
4087
|
declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
|
|
4088
|
+
declare function useBuffers<T extends Record<string, BufferLike>>(scope?: string): BuffersWithUtils<T>;
|
|
3958
4089
|
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
|
|
3959
4090
|
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
|
|
3960
4091
|
/**
|
|
@@ -3970,6 +4101,10 @@ declare function useBuffers<T extends Record<string, BufferLike>>(creator: Buffe
|
|
|
3970
4101
|
*/
|
|
3971
4102
|
declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
3972
4103
|
|
|
4104
|
+
/**
|
|
4105
|
+
* A record of storage-like values - allows mixed types (StorageTexture, Storage3DTexture, TSL nodes)
|
|
4106
|
+
*/
|
|
4107
|
+
type StorageRecordType<T extends StorageLike = StorageLike> = Record<string, T>;
|
|
3973
4108
|
/**
|
|
3974
4109
|
* Creator function that returns a record of GPU storage objects.
|
|
3975
4110
|
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
@@ -3984,14 +4119,15 @@ type RebuildStorageFn = (scope?: string) => void;
|
|
|
3984
4119
|
/** Function signature for disposeStorage util - releases GPU resources */
|
|
3985
4120
|
type DisposeStorageFn = (names: string | string[], scope?: string) => void;
|
|
3986
4121
|
/** Return type with utils included */
|
|
3987
|
-
type StorageWithUtils<T extends
|
|
4122
|
+
type StorageWithUtils<T extends StorageRecordType | StorageStore = StorageRecordType> = T & {
|
|
3988
4123
|
removeStorage: RemoveStorageFn;
|
|
3989
4124
|
clearStorage: ClearStorageFn;
|
|
3990
4125
|
rebuildStorage: RebuildStorageFn;
|
|
3991
4126
|
disposeStorage: DisposeStorageFn;
|
|
3992
4127
|
};
|
|
3993
|
-
declare function useGPUStorage(): StorageWithUtils<
|
|
4128
|
+
declare function useGPUStorage(): StorageWithUtils<StorageStore>;
|
|
3994
4129
|
declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
|
|
4130
|
+
declare function useGPUStorage<T extends Record<string, StorageLike>>(scope?: string): StorageWithUtils<T>;
|
|
3995
4131
|
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
|
|
3996
4132
|
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
|
|
3997
4133
|
/**
|
|
@@ -4041,6 +4177,10 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
|
|
|
4041
4177
|
* - Callbacks receive full RootState for flexibility
|
|
4042
4178
|
* - No auto-cleanup on unmount - use reset() for explicit cleanup
|
|
4043
4179
|
* - Scene/camera changes trigger scenePass recreation
|
|
4180
|
+
* - A replaced scenePass is disposed once the new graph is installed, so rebuild() does not
|
|
4181
|
+
* strand its render target (and MRT attachments) on the GPU
|
|
4182
|
+
* - Any run that changes the output node sets RenderPipeline.needsUpdate, so rebuild() actually
|
|
4183
|
+
* recompiles instead of silently keeping the first compiled graph
|
|
4044
4184
|
*
|
|
4045
4185
|
* @param mainCB - Main callback to configure outputNode and create effect passes
|
|
4046
4186
|
* @param setupCB - Optional setup callback to configure MRT on scenePass
|
|
@@ -4136,5 +4276,14 @@ type UseFrameWebGPU = (callback?: FrameCallback$1<WebGPURootState>, priorityOrOp
|
|
|
4136
4276
|
declare const useThree: UseThreeWebGPU;
|
|
4137
4277
|
declare const useFrame: UseFrameWebGPU;
|
|
4138
4278
|
|
|
4139
|
-
|
|
4140
|
-
|
|
4279
|
+
/** Canvas props on the WebGPU entry: `onCreated` receives `WebGPURootState`. */
|
|
4280
|
+
type WebGPUCanvasProps = Omit<CanvasProps, 'onCreated'> & {
|
|
4281
|
+
/** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGPURenderer` */
|
|
4282
|
+
onCreated?: (state: WebGPURootState) => void;
|
|
4283
|
+
};
|
|
4284
|
+
|
|
4285
|
+
/** `Canvas` narrowed to WebGPU state — the same component, `onCreated` typed against `WebGPURootState`. */
|
|
4286
|
+
declare const Canvas: (props: WebGPUCanvasProps) => JSX.Element;
|
|
4287
|
+
|
|
4288
|
+
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 };
|
|
4289
|
+
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 };
|