@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/index.d.cts
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 } from 'three/webgpu';
|
|
4
4
|
import * as THREE$1 from 'three';
|
|
5
5
|
import { WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
6
6
|
import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
|
|
@@ -352,6 +352,7 @@ type BufferLike =
|
|
|
352
352
|
| Uint16Array
|
|
353
353
|
| Int16Array
|
|
354
354
|
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
355
|
+
| THREE$1.InterleavedBufferAttribute
|
|
355
356
|
| Node // TSL buffer nodes (instancedArray, storage)
|
|
356
357
|
|
|
357
358
|
/** Flat record of buffer-like values (no nested scopes) */
|
|
@@ -363,6 +364,25 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
363
364
|
*/
|
|
364
365
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
365
366
|
|
|
367
|
+
//* Node Types (useNodes) ========================================
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
371
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
372
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
373
|
+
* and the shape the store holds are one type by construction.
|
|
374
|
+
*/
|
|
375
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
376
|
+
|
|
377
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
378
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
382
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
383
|
+
*/
|
|
384
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
385
|
+
|
|
366
386
|
//* Storage Types (useGPUStorage) ========================================
|
|
367
387
|
|
|
368
388
|
/**
|
|
@@ -377,7 +397,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
|
377
397
|
* ```
|
|
378
398
|
*/
|
|
379
399
|
type StorageLike =
|
|
380
|
-
| StorageTexture // GPU storage texture
|
|
400
|
+
| StorageTexture // 2D GPU storage texture
|
|
401
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
402
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
381
403
|
| Data3DTexture // 3D texture (can be used as storage)
|
|
382
404
|
| Node // TSL storage texture nodes (storageTexture)
|
|
383
405
|
|
|
@@ -489,6 +511,12 @@ interface InternalState {
|
|
|
489
511
|
actualRenderer: R3FRenderer
|
|
490
512
|
/** Global scheduler reference (for useFrame hook) */
|
|
491
513
|
scheduler: SchedulerApi | null
|
|
514
|
+
/**
|
|
515
|
+
* Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
|
|
516
|
+
* `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
|
|
517
|
+
* render-phase takeover. Used by `useRenderPipeline`.
|
|
518
|
+
*/
|
|
519
|
+
renderOverride?: (() => void) | null
|
|
492
520
|
/** This root's unique ID in the global scheduler */
|
|
493
521
|
rootId?: string
|
|
494
522
|
/** Function to unregister this root from the global scheduler */
|
|
@@ -496,11 +524,28 @@ interface InternalState {
|
|
|
496
524
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
497
525
|
container?: THREE$1.Object3D
|
|
498
526
|
/**
|
|
499
|
-
* CanvasTarget
|
|
500
|
-
*
|
|
527
|
+
* The CanvasTarget this root sizes and renders through.
|
|
528
|
+
*
|
|
529
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
530
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
531
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
532
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
533
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
501
534
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
502
535
|
*/
|
|
503
536
|
canvasTarget?: CanvasTarget
|
|
537
|
+
/**
|
|
538
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
539
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
540
|
+
*
|
|
541
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
542
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
543
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
544
|
+
* invalidate some other canvas's descriptor instead.
|
|
545
|
+
*
|
|
546
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
547
|
+
*/
|
|
548
|
+
canvasTargetSizeDirty?: boolean
|
|
504
549
|
/**
|
|
505
550
|
* Whether multi-canvas rendering is active.
|
|
506
551
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -610,7 +655,7 @@ interface RootState {
|
|
|
610
655
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
611
656
|
uniforms: UniformStore
|
|
612
657
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
613
|
-
nodes:
|
|
658
|
+
nodes: NodeStore
|
|
614
659
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
615
660
|
buffers: BufferStore
|
|
616
661
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -622,7 +667,7 @@ interface RootState {
|
|
|
622
667
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
623
668
|
renderPipeline: ThreeRenderPipeline | null
|
|
624
669
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
625
|
-
passes:
|
|
670
|
+
passes: PassRecord
|
|
626
671
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
627
672
|
_hmrVersion: number
|
|
628
673
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -710,12 +755,19 @@ type DefaultRendererProps = {
|
|
|
710
755
|
*/
|
|
711
756
|
interface CanvasSchedulerConfig {
|
|
712
757
|
/**
|
|
713
|
-
*
|
|
714
|
-
|
|
758
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
759
|
+
*/
|
|
760
|
+
before?: string | string[]
|
|
761
|
+
/**
|
|
762
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
715
763
|
*/
|
|
716
|
-
after?: string
|
|
764
|
+
after?: string | string[]
|
|
717
765
|
/**
|
|
718
|
-
*
|
|
766
|
+
* Numeric root order. Lower values run first.
|
|
767
|
+
*/
|
|
768
|
+
order?: number
|
|
769
|
+
/**
|
|
770
|
+
* Limit this Canvas's default render job (frames per second).
|
|
719
771
|
*/
|
|
720
772
|
fps?: number
|
|
721
773
|
}
|
|
@@ -802,14 +854,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
802
854
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
803
855
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
804
856
|
dpr?: Dpr
|
|
805
|
-
/**
|
|
806
|
-
|
|
857
|
+
/**
|
|
858
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
859
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
860
|
+
*/
|
|
861
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
807
862
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
808
863
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
809
864
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
810
865
|
camera?: CameraProps
|
|
811
866
|
/** An R3F event manager to manage elements' pointer events */
|
|
812
|
-
events?: (store: RootStore) => EventManager<
|
|
867
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
813
868
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
814
869
|
onCreated?: (state: RootState) => void
|
|
815
870
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -898,7 +953,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
898
953
|
object?: T
|
|
899
954
|
dispose?: null
|
|
900
955
|
attach?: AttachType<T>
|
|
901
|
-
onUpdate?: (self: T) => void
|
|
902
956
|
}
|
|
903
957
|
|
|
904
958
|
interface Instance<O = any> {
|
|
@@ -1038,7 +1092,7 @@ interface CanvasProps
|
|
|
1038
1092
|
*/
|
|
1039
1093
|
resize?: Options
|
|
1040
1094
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1041
|
-
eventSource?:
|
|
1095
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1042
1096
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1043
1097
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1044
1098
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1146,81 +1200,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1146
1200
|
|
|
1147
1201
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1148
1202
|
|
|
1149
|
-
//* Global Types ==============================
|
|
1203
|
+
//* Global TSL Types ==============================
|
|
1150
1204
|
|
|
1151
1205
|
declare global {
|
|
1152
1206
|
/**
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1155
|
-
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1156
|
-
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1157
|
-
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1158
|
-
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1159
|
-
* arity when three made `UniformNode` two-parameter.
|
|
1160
|
-
*
|
|
1161
|
-
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1162
|
-
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1163
|
-
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1164
|
-
* installed three instead of needing to be mirrored by hand.
|
|
1207
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1208
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1165
1209
|
*/
|
|
1166
|
-
type
|
|
1210
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1211
|
+
readonly shaderNode: unknown
|
|
1212
|
+
readonly id: number
|
|
1213
|
+
}
|
|
1167
1214
|
|
|
1168
|
-
/**
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
* @example
|
|
1174
|
-
* ```tsx
|
|
1175
|
-
* // Define a shader function
|
|
1176
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1177
|
-
* return mix(color1, color2, factor)
|
|
1178
|
-
* })
|
|
1179
|
-
*
|
|
1180
|
-
* // Type when retrieving from nodes store
|
|
1181
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1182
|
-
*
|
|
1183
|
-
* // Or with specific return type
|
|
1184
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1185
|
-
* ```
|
|
1186
|
-
*/
|
|
1187
|
-
type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
|
|
1215
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1216
|
+
type LegacyTSLNodeLike = {
|
|
1217
|
+
label?: ((label: string) => unknown) | string
|
|
1218
|
+
setName?: (name: string) => unknown
|
|
1219
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1188
1220
|
|
|
1189
|
-
/**
|
|
1190
|
-
|
|
1191
|
-
* This is the common return type for TSL operations (add, mul, sin, etc.)
|
|
1192
|
-
*
|
|
1193
|
-
* @example
|
|
1194
|
-
* ```tsx
|
|
1195
|
-
* const { wobble } = nodes as { wobble: ShaderNodeRef }
|
|
1196
|
-
* ```
|
|
1197
|
-
*/
|
|
1198
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1221
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1222
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1199
1223
|
|
|
1200
1224
|
/**
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
* - Node: base Three.js node type
|
|
1206
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1207
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1208
|
-
*
|
|
1209
|
-
* @example
|
|
1210
|
-
* ```tsx
|
|
1211
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1212
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1213
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1214
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1215
|
-
* }))
|
|
1216
|
-
*
|
|
1217
|
-
* // Can narrow with type guard or assertion when needed
|
|
1218
|
-
* if (typeof blendColorFn === 'function') {
|
|
1219
|
-
* blendColorFn(someColor, 0.5)
|
|
1220
|
-
* }
|
|
1221
|
-
* ```
|
|
1225
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1226
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1227
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1228
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1222
1229
|
*/
|
|
1223
|
-
type
|
|
1230
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1231
|
+
? TNodeType
|
|
1232
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1233
|
+
? TNodeType
|
|
1234
|
+
: T extends number
|
|
1235
|
+
? 'float'
|
|
1236
|
+
: T extends boolean
|
|
1237
|
+
? 'bool'
|
|
1238
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1239
|
+
? 'color'
|
|
1240
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1241
|
+
? 'vec4'
|
|
1242
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1243
|
+
? 'vec3'
|
|
1244
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1245
|
+
? 'vec2'
|
|
1246
|
+
: T extends three_webgpu.Matrix4
|
|
1247
|
+
? 'mat4'
|
|
1248
|
+
: T extends three_webgpu.Matrix3
|
|
1249
|
+
? 'mat3'
|
|
1250
|
+
: T extends three_webgpu.Matrix2
|
|
1251
|
+
? 'mat2'
|
|
1252
|
+
: unknown
|
|
1253
|
+
|
|
1254
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1255
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1256
|
+
? TValue
|
|
1257
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1258
|
+
? TValue
|
|
1259
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1260
|
+
? three_webgpu.Color
|
|
1261
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1262
|
+
? three_webgpu.Vector4
|
|
1263
|
+
: T extends { x: number; y: number; z: number }
|
|
1264
|
+
? three_webgpu.Vector3
|
|
1265
|
+
: T extends { x: number; y: number }
|
|
1266
|
+
? three_webgpu.Vector2
|
|
1267
|
+
: T extends number
|
|
1268
|
+
? number
|
|
1269
|
+
: T extends boolean
|
|
1270
|
+
? boolean
|
|
1271
|
+
: T
|
|
1272
|
+
|
|
1273
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1274
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1275
|
+
|
|
1276
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1277
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1278
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1282
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1224
1283
|
|
|
1225
1284
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1226
1285
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1245,7 +1304,7 @@ declare global {
|
|
|
1245
1304
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1246
1305
|
* Supports:
|
|
1247
1306
|
* - Primitives: number, string (color), boolean
|
|
1248
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1307
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1249
1308
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1250
1309
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1251
1310
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1258,88 +1317,124 @@ declare global {
|
|
|
1258
1317
|
| three_webgpu.Vector2
|
|
1259
1318
|
| three_webgpu.Vector3
|
|
1260
1319
|
| three_webgpu.Vector4
|
|
1320
|
+
| three_webgpu.Matrix2
|
|
1261
1321
|
| three_webgpu.Matrix3
|
|
1262
1322
|
| three_webgpu.Matrix4
|
|
1263
|
-
|
|
|
1264
|
-
|
|
|
1265
|
-
| { x: number; y
|
|
1323
|
+
| { x: number; y: number }
|
|
1324
|
+
| { x: number; y: number; z: number }
|
|
1325
|
+
| { x: number; y: number; z: number; w: number }
|
|
1266
1326
|
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1267
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1327
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1268
1328
|
| UniformNode
|
|
1269
1329
|
|
|
1270
1330
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1271
1331
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1272
1332
|
}
|
|
1273
1333
|
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
declare module 'three/tsl' {
|
|
1334
|
+
declare global {
|
|
1277
1335
|
/**
|
|
1278
|
-
*
|
|
1279
|
-
*
|
|
1336
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1337
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1338
|
+
* is r185, so the new name is the only one.
|
|
1280
1339
|
*/
|
|
1281
|
-
|
|
1282
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1283
|
-
): ShaderCallable<R>
|
|
1340
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1284
1341
|
|
|
1285
1342
|
/**
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1343
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1344
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1345
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1288
1346
|
*/
|
|
1289
|
-
|
|
1290
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1291
|
-
): ShaderCallable<R>
|
|
1347
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1292
1348
|
|
|
1293
1349
|
/**
|
|
1294
|
-
*
|
|
1295
|
-
*
|
|
1350
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1351
|
+
*
|
|
1352
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1353
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1354
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1355
|
+
* {@link RenderPipelineCallbackState}.
|
|
1356
|
+
*
|
|
1357
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1358
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1359
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1360
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1361
|
+
*
|
|
1362
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1363
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1364
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1365
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1296
1366
|
*/
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1367
|
+
interface PassRecord {
|
|
1368
|
+
scenePass?: ScenePassNode
|
|
1369
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1370
|
+
}
|
|
1301
1371
|
|
|
1302
1372
|
/**
|
|
1303
|
-
*
|
|
1373
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1374
|
+
*
|
|
1375
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1376
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1377
|
+
*
|
|
1378
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1379
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1304
1380
|
*/
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1381
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1382
|
+
renderPipeline: ThreeRenderPipeline
|
|
1383
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1384
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1385
|
+
isLegacy: false
|
|
1386
|
+
}
|
|
1310
1387
|
|
|
1311
|
-
declare global {
|
|
1312
1388
|
/**
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
* is
|
|
1389
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1390
|
+
*
|
|
1391
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1392
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1393
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1394
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1316
1395
|
*/
|
|
1317
|
-
type
|
|
1318
|
-
|
|
1319
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1320
|
-
type PassRecord = Record<string, any>
|
|
1396
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1321
1397
|
|
|
1322
1398
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1323
|
-
type RenderPipelineSetupCallback = (state:
|
|
1399
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1324
1400
|
|
|
1325
1401
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1326
|
-
type RenderPipelineMainCallback = (state:
|
|
1402
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1327
1403
|
|
|
1328
|
-
/**
|
|
1329
|
-
interface
|
|
1404
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1405
|
+
interface UseRenderPipelineActions {
|
|
1330
1406
|
/** Current passes from state */
|
|
1331
1407
|
passes: PassRecord
|
|
1332
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1333
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1334
1408
|
/** Clear all passes from state */
|
|
1335
1409
|
clearPasses: () => void
|
|
1336
1410
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1337
1411
|
reset: () => void
|
|
1338
1412
|
/** Re-run setup/main callbacks with current closure values */
|
|
1339
1413
|
rebuild: () => void
|
|
1340
|
-
/** True when RenderPipeline is configured and ready */
|
|
1341
|
-
isReady: boolean
|
|
1342
1414
|
}
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1418
|
+
*
|
|
1419
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1420
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1421
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1422
|
+
*/
|
|
1423
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1424
|
+
(
|
|
1425
|
+
| {
|
|
1426
|
+
/** True when RenderPipeline is configured and ready */
|
|
1427
|
+
isReady: true
|
|
1428
|
+
/** RenderPipeline instance */
|
|
1429
|
+
renderPipeline: ThreeRenderPipeline
|
|
1430
|
+
}
|
|
1431
|
+
| {
|
|
1432
|
+
/** False until the pipeline has been created */
|
|
1433
|
+
isReady: false
|
|
1434
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1435
|
+
renderPipeline: null
|
|
1436
|
+
}
|
|
1437
|
+
)
|
|
1343
1438
|
}
|
|
1344
1439
|
|
|
1345
1440
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1418,10 +1513,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1418
1513
|
|
|
1419
1514
|
/**
|
|
1420
1515
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1421
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1516
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1517
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1422
1518
|
*/
|
|
1423
1519
|
type NodeProps<P> = {
|
|
1424
|
-
[K in keyof P as P[K] extends
|
|
1520
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1425
1521
|
}
|
|
1426
1522
|
|
|
1427
1523
|
interface ReactProps<P> {
|
|
@@ -1442,11 +1538,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1442
1538
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1443
1539
|
}
|
|
1444
1540
|
|
|
1541
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1542
|
+
type Object3DMethod = NonNullable<
|
|
1543
|
+
{
|
|
1544
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1545
|
+
}[keyof Object3D]
|
|
1546
|
+
>
|
|
1547
|
+
|
|
1445
1548
|
type ThreeExports = typeof THREE
|
|
1446
1549
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1447
1550
|
|
|
1448
1551
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1449
|
-
|
|
1552
|
+
/**
|
|
1553
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1554
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1555
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1556
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1557
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1558
|
+
*/
|
|
1559
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1560
|
+
object: object
|
|
1561
|
+
ref?: React.Ref<any>
|
|
1562
|
+
[prop: string]: unknown
|
|
1563
|
+
}
|
|
1450
1564
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1451
1565
|
threeAudio: ThreeElementsImpl['audio']
|
|
1452
1566
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1487,6 +1601,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1487
1601
|
type three_d_Matrix4 = Matrix4;
|
|
1488
1602
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1489
1603
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1604
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1490
1605
|
type three_d_Quaternion = Quaternion;
|
|
1491
1606
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1492
1607
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1501,7 +1616,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1501
1616
|
type three_d_Vector4 = Vector4;
|
|
1502
1617
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1503
1618
|
declare namespace three_d {
|
|
1504
|
-
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1619
|
+
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Object3DMethod as Object3DMethod, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1505
1620
|
}
|
|
1506
1621
|
|
|
1507
1622
|
/**
|
|
@@ -1850,7 +1965,48 @@ declare function createEvents(store: RootStore): {
|
|
|
1850
1965
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1851
1966
|
};
|
|
1852
1967
|
/** Default R3F event manager for web */
|
|
1853
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1968
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1969
|
+
|
|
1970
|
+
interface RootExtension {
|
|
1971
|
+
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
1972
|
+
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
1973
|
+
name: string;
|
|
1974
|
+
/**
|
|
1975
|
+
* Called once per root, after its renderer exists and before `onCreated` and the first frame.
|
|
1976
|
+
* `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
|
|
1977
|
+
* to the primary canvas. Return fields to merge into the root's state, or nothing.
|
|
1978
|
+
*/
|
|
1979
|
+
setup?(store: RootStore): Partial<RootState> | void;
|
|
1980
|
+
/** Called when a root this extension set up unmounts. */
|
|
1981
|
+
dispose?(store: RootStore): void;
|
|
1982
|
+
/** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
|
|
1983
|
+
hmr?(store: RootStore): void;
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Register an extension. It is set up on every live root immediately, and on every root created
|
|
1987
|
+
* afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
|
|
1988
|
+
* it already set up keep its state and still get its dispose when they unmount.
|
|
1989
|
+
*/
|
|
1990
|
+
declare function registerRootExtension(extension: RootExtension): () => void;
|
|
1991
|
+
/**
|
|
1992
|
+
* Point a root's default render job at a different render function, or back at
|
|
1993
|
+
* `renderer.render(scene, camera)` with `null`.
|
|
1994
|
+
*
|
|
1995
|
+
* The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
|
|
1996
|
+
* boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
|
|
1997
|
+
*/
|
|
1998
|
+
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2002
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2003
|
+
*/
|
|
2004
|
+
declare function useStore(): RootStore;
|
|
2005
|
+
/**
|
|
2006
|
+
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2007
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2008
|
+
*/
|
|
2009
|
+
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
1854
2010
|
|
|
1855
2011
|
/**
|
|
1856
2012
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -1883,7 +2039,7 @@ declare namespace useLoader {
|
|
|
1883
2039
|
*
|
|
1884
2040
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1885
2041
|
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1886
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
2042
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
1887
2043
|
*
|
|
1888
2044
|
* @example
|
|
1889
2045
|
* // Simple priority (backwards compat)
|
|
@@ -2094,16 +2250,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
|
|
|
2094
2250
|
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
|
|
2095
2251
|
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
|
|
2096
2252
|
|
|
2097
|
-
/**
|
|
2098
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2099
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2100
|
-
*/
|
|
2101
|
-
declare function useStore(): RootStore;
|
|
2102
|
-
/**
|
|
2103
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2104
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2105
|
-
*/
|
|
2106
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2107
2253
|
/**
|
|
2108
2254
|
* Exposes an object's {@link Instance}.
|
|
2109
2255
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2179,7 +2325,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2179
2325
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2180
2326
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2181
2327
|
*
|
|
2182
|
-
*
|
|
2328
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2329
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2330
|
+
*
|
|
2331
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2183
2332
|
* @param frames - Number of frames to request (default: 1)
|
|
2184
2333
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2185
2334
|
*
|
|
@@ -2190,14 +2339,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2190
2339
|
* Advances the frameloop and runs render effects.
|
|
2191
2340
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2192
2341
|
*
|
|
2342
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2343
|
+
* registered root is stepped for backwards compatibility.
|
|
2344
|
+
*
|
|
2193
2345
|
* @param timestamp - The timestamp to use for this frame
|
|
2194
2346
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2195
|
-
* @param state -
|
|
2196
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2347
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2197
2348
|
*
|
|
2198
2349
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2199
2350
|
*/
|
|
2200
|
-
declare function advance(timestamp: number): void;
|
|
2351
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2201
2352
|
|
|
2202
2353
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2203
2354
|
declare function ReactReconciler<
|
|
@@ -3242,6 +3393,7 @@ declare namespace ReactReconciler {
|
|
|
3242
3393
|
|
|
3243
3394
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3244
3395
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3396
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3245
3397
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3246
3398
|
|
|
3247
3399
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3266,6 +3418,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
3266
3418
|
declare function flushSync<R>(fn: () => R): R;
|
|
3267
3419
|
|
|
3268
3420
|
declare const context: React$1.Context<RootStore>;
|
|
3421
|
+
|
|
3269
3422
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3270
3423
|
|
|
3271
3424
|
/**
|
|
@@ -3519,7 +3672,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
3519
3672
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
3520
3673
|
/**
|
|
3521
3674
|
* Triggers an update for an instance.
|
|
3522
|
-
*
|
|
3675
|
+
* Invalidates the frame if the root is in demand mode.
|
|
3523
3676
|
*
|
|
3524
3677
|
* @param instance - Instance to invalidate
|
|
3525
3678
|
*/
|
|
@@ -3685,29 +3838,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3685
3838
|
* Used to identify values that should be resolved from refs after mount.
|
|
3686
3839
|
*/
|
|
3687
3840
|
declare const FROM_REF: unique symbol;
|
|
3841
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3842
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3843
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3844
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3845
|
+
transform?: (value: T) => R;
|
|
3846
|
+
}
|
|
3688
3847
|
/**
|
|
3689
3848
|
* Defers prop application until the referenced object is available.
|
|
3690
3849
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3691
3850
|
*
|
|
3851
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3852
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3853
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3854
|
+
* what gets assigned.
|
|
3855
|
+
*
|
|
3692
3856
|
* @param ref - React ref object to resolve at mount time
|
|
3693
|
-
* @
|
|
3857
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3858
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3694
3859
|
*
|
|
3695
3860
|
* @example
|
|
3696
3861
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3697
3862
|
*
|
|
3698
3863
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3699
3864
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3865
|
+
*
|
|
3866
|
+
* @example
|
|
3867
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3868
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3700
3869
|
*/
|
|
3701
3870
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3871
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3702
3872
|
/**
|
|
3703
3873
|
* Type guard to check if a value is a fromRef marker.
|
|
3704
3874
|
*
|
|
3705
3875
|
* @param value - Value to check
|
|
3706
3876
|
* @returns True if value is a fromRef marker
|
|
3707
3877
|
*/
|
|
3708
|
-
declare function isFromRef(value: unknown): value is
|
|
3709
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3710
|
-
};
|
|
3878
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3711
3879
|
|
|
3712
3880
|
/**
|
|
3713
3881
|
* Symbol marker for mount-only method calls.
|
|
@@ -3734,7 +3902,15 @@ declare const ONCE: unique symbol;
|
|
|
3734
3902
|
* // No arguments
|
|
3735
3903
|
* <geometry center={once()} />
|
|
3736
3904
|
*/
|
|
3737
|
-
declare function once<
|
|
3905
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3906
|
+
/**
|
|
3907
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3908
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3909
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3910
|
+
*
|
|
3911
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3912
|
+
*/
|
|
3913
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3738
3914
|
/**
|
|
3739
3915
|
* Type guard to check if a value is a once marker.
|
|
3740
3916
|
*
|
|
@@ -3751,5 +3927,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
3751
3927
|
*/
|
|
3752
3928
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3753
3929
|
|
|
3754
|
-
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3755
|
-
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeProps, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|
|
3930
|
+
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, registerRootExtension, removeInteractivity, resolve, setRenderOverride, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3931
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, FromRefMarker, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootExtension, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|