@react-three/fiber 10.0.0-canary.1be335a → 10.0.0-canary.27df622
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2565 -2468
- package/dist/index.d.cts +310 -153
- package/dist/index.d.mts +310 -153
- package/dist/index.d.ts +308 -179
- package/dist/index.mjs +1701 -1604
- package/dist/legacy.cjs +2482 -2389
- package/dist/legacy.d.cts +313 -160
- package/dist/legacy.d.mts +313 -160
- package/dist/legacy.d.ts +311 -184
- package/dist/legacy.mjs +2483 -2390
- package/dist/webgpu/index.cjs +2851 -2729
- package/dist/webgpu/index.d.cts +390 -264
- package/dist/webgpu/index.d.mts +390 -264
- package/dist/webgpu/index.d.ts +388 -290
- package/dist/webgpu/index.mjs +2590 -2468
- package/package.json +4 -4
- package/readme.md +1 -1
- package/react-reconciler/constants.d.ts +0 -7
- package/react-reconciler/constants.js +0 -1
- package/react-reconciler/index.d.ts +0 -1044
- package/react-reconciler/index.js +0 -208
package/dist/legacy.d.cts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import * as THREE$1 from 'three';
|
|
2
|
-
import { WebGLCubeRenderTarget, WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1,
|
|
2
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$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, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera } from 'three';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
5
5
|
import * as three_webgpu from 'three/webgpu';
|
|
6
|
-
import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Data3DTexture, CanvasTarget
|
|
6
|
+
import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget } from 'three/webgpu';
|
|
7
7
|
import { StoreApi } from 'zustand';
|
|
8
8
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
9
9
|
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
10
10
|
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
11
11
|
import { Options } from 'react-use-measure';
|
|
12
12
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
13
|
-
import { ThreeElement as ThreeElement$1, Euler as Euler$2 } from '@react-three/fiber';
|
|
14
13
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
15
14
|
|
|
16
15
|
function _mergeNamespaces(n, m) {
|
|
@@ -39,12 +38,12 @@ function _mergeNamespaces(n, m) {
|
|
|
39
38
|
declare const R3F_BUILD_LEGACY = true;
|
|
40
39
|
declare const R3F_BUILD_WEBGPU = false;
|
|
41
40
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
declare
|
|
46
|
-
|
|
47
|
-
}
|
|
41
|
+
type Inspector = never;
|
|
42
|
+
/** Not available on the legacy (WebGL-only) entry. */
|
|
43
|
+
declare function loadInspector(): Promise<never>;
|
|
44
|
+
declare class WebGPURenderer {
|
|
45
|
+
constructor();
|
|
46
|
+
}
|
|
48
47
|
|
|
49
48
|
declare const RenderTarget: any;
|
|
50
49
|
|
|
@@ -59,7 +58,8 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
59
58
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
60
59
|
RenderTarget: RenderTarget,
|
|
61
60
|
RenderTargetCompat: WebGLRenderTarget,
|
|
62
|
-
WebGPURenderer: WebGPURenderer
|
|
61
|
+
WebGPURenderer: WebGPURenderer,
|
|
62
|
+
loadInspector: loadInspector
|
|
63
63
|
}, [THREE$1]);
|
|
64
64
|
|
|
65
65
|
//* Utility Types ==============================
|
|
@@ -348,6 +348,7 @@ type BufferLike =
|
|
|
348
348
|
| Uint16Array
|
|
349
349
|
| Int16Array
|
|
350
350
|
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
351
|
+
| THREE$1.InterleavedBufferAttribute
|
|
351
352
|
| Node // TSL buffer nodes (instancedArray, storage)
|
|
352
353
|
|
|
353
354
|
/** Flat record of buffer-like values (no nested scopes) */
|
|
@@ -359,6 +360,25 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
359
360
|
*/
|
|
360
361
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
361
362
|
|
|
363
|
+
//* Node Types (useNodes) ========================================
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
367
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
368
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
369
|
+
* and the shape the store holds are one type by construction.
|
|
370
|
+
*/
|
|
371
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
372
|
+
|
|
373
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
374
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
378
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
379
|
+
*/
|
|
380
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
381
|
+
|
|
362
382
|
//* Storage Types (useGPUStorage) ========================================
|
|
363
383
|
|
|
364
384
|
/**
|
|
@@ -373,7 +393,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
|
373
393
|
* ```
|
|
374
394
|
*/
|
|
375
395
|
type StorageLike =
|
|
376
|
-
| StorageTexture // GPU storage texture
|
|
396
|
+
| StorageTexture // 2D GPU storage texture
|
|
397
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
398
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
377
399
|
| Data3DTexture // 3D texture (can be used as storage)
|
|
378
400
|
| Node // TSL storage texture nodes (storageTexture)
|
|
379
401
|
|
|
@@ -492,11 +514,28 @@ interface InternalState {
|
|
|
492
514
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
493
515
|
container?: THREE$1.Object3D
|
|
494
516
|
/**
|
|
495
|
-
* CanvasTarget
|
|
496
|
-
*
|
|
517
|
+
* The CanvasTarget this root sizes and renders through.
|
|
518
|
+
*
|
|
519
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
520
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
521
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
522
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
523
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
497
524
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
498
525
|
*/
|
|
499
526
|
canvasTarget?: CanvasTarget
|
|
527
|
+
/**
|
|
528
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
529
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
530
|
+
*
|
|
531
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
532
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
533
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
534
|
+
* invalidate some other canvas's descriptor instead.
|
|
535
|
+
*
|
|
536
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
537
|
+
*/
|
|
538
|
+
canvasTargetSizeDirty?: boolean
|
|
500
539
|
/**
|
|
501
540
|
* Whether multi-canvas rendering is active.
|
|
502
541
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -606,7 +645,7 @@ interface RootState {
|
|
|
606
645
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
607
646
|
uniforms: UniformStore
|
|
608
647
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
609
|
-
nodes:
|
|
648
|
+
nodes: NodeStore
|
|
610
649
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
611
650
|
buffers: BufferStore
|
|
612
651
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -618,7 +657,7 @@ interface RootState {
|
|
|
618
657
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
619
658
|
renderPipeline: ThreeRenderPipeline | null
|
|
620
659
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
621
|
-
passes:
|
|
660
|
+
passes: PassRecord
|
|
622
661
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
623
662
|
_hmrVersion: number
|
|
624
663
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -706,12 +745,19 @@ type DefaultRendererProps = {
|
|
|
706
745
|
*/
|
|
707
746
|
interface CanvasSchedulerConfig {
|
|
708
747
|
/**
|
|
709
|
-
*
|
|
710
|
-
* Pass the `id` of another canvas.
|
|
748
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
711
749
|
*/
|
|
712
|
-
|
|
750
|
+
before?: string | string[]
|
|
713
751
|
/**
|
|
714
|
-
*
|
|
752
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
753
|
+
*/
|
|
754
|
+
after?: string | string[]
|
|
755
|
+
/**
|
|
756
|
+
* Numeric root order. Lower values run first.
|
|
757
|
+
*/
|
|
758
|
+
order?: number
|
|
759
|
+
/**
|
|
760
|
+
* Limit this Canvas's default render job (frames per second).
|
|
715
761
|
*/
|
|
716
762
|
fps?: number
|
|
717
763
|
}
|
|
@@ -798,14 +844,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
798
844
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
799
845
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
800
846
|
dpr?: Dpr
|
|
801
|
-
/**
|
|
802
|
-
|
|
847
|
+
/**
|
|
848
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
849
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
850
|
+
*/
|
|
851
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
803
852
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
804
853
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
805
854
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
806
855
|
camera?: CameraProps
|
|
807
856
|
/** An R3F event manager to manage elements' pointer events */
|
|
808
|
-
events?: (store: RootStore) => EventManager<
|
|
857
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
809
858
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
810
859
|
onCreated?: (state: RootState) => void
|
|
811
860
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -1034,7 +1083,7 @@ interface CanvasProps
|
|
|
1034
1083
|
*/
|
|
1035
1084
|
resize?: Options
|
|
1036
1085
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1037
|
-
eventSource?:
|
|
1086
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1038
1087
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1039
1088
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1040
1089
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1142,81 +1191,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1142
1191
|
|
|
1143
1192
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1144
1193
|
|
|
1145
|
-
//* Global Types ==============================
|
|
1194
|
+
//* Global TSL Types ==============================
|
|
1146
1195
|
|
|
1147
1196
|
declare global {
|
|
1148
1197
|
/**
|
|
1149
|
-
*
|
|
1150
|
-
*
|
|
1151
|
-
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1152
|
-
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1153
|
-
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1154
|
-
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1155
|
-
* arity when three made `UniformNode` two-parameter.
|
|
1156
|
-
*
|
|
1157
|
-
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1158
|
-
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1159
|
-
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1160
|
-
* installed three instead of needing to be mirrored by hand.
|
|
1198
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1199
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1161
1200
|
*/
|
|
1162
|
-
type
|
|
1201
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1202
|
+
readonly shaderNode: unknown
|
|
1203
|
+
readonly id: number
|
|
1204
|
+
}
|
|
1163
1205
|
|
|
1164
|
-
/**
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
* @example
|
|
1170
|
-
* ```tsx
|
|
1171
|
-
* // Define a shader function
|
|
1172
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1173
|
-
* return mix(color1, color2, factor)
|
|
1174
|
-
* })
|
|
1175
|
-
*
|
|
1176
|
-
* // Type when retrieving from nodes store
|
|
1177
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1178
|
-
*
|
|
1179
|
-
* // Or with specific return type
|
|
1180
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1181
|
-
* ```
|
|
1182
|
-
*/
|
|
1183
|
-
type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
|
|
1206
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1207
|
+
type LegacyTSLNodeLike = {
|
|
1208
|
+
label?: ((label: string) => unknown) | string
|
|
1209
|
+
setName?: (name: string) => unknown
|
|
1210
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1184
1211
|
|
|
1185
|
-
/**
|
|
1186
|
-
|
|
1187
|
-
* This is the common return type for TSL operations (add, mul, sin, etc.)
|
|
1188
|
-
*
|
|
1189
|
-
* @example
|
|
1190
|
-
* ```tsx
|
|
1191
|
-
* const { wobble } = nodes as { wobble: ShaderNodeRef }
|
|
1192
|
-
* ```
|
|
1193
|
-
*/
|
|
1194
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1212
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1213
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1195
1214
|
|
|
1196
1215
|
/**
|
|
1197
|
-
*
|
|
1198
|
-
*
|
|
1199
|
-
*
|
|
1200
|
-
*
|
|
1201
|
-
* - Node: base Three.js node type
|
|
1202
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1203
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1204
|
-
*
|
|
1205
|
-
* @example
|
|
1206
|
-
* ```tsx
|
|
1207
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1208
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1209
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1210
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1211
|
-
* }))
|
|
1212
|
-
*
|
|
1213
|
-
* // Can narrow with type guard or assertion when needed
|
|
1214
|
-
* if (typeof blendColorFn === 'function') {
|
|
1215
|
-
* blendColorFn(someColor, 0.5)
|
|
1216
|
-
* }
|
|
1217
|
-
* ```
|
|
1216
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1217
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1218
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1219
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1218
1220
|
*/
|
|
1219
|
-
type
|
|
1221
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1222
|
+
? TNodeType
|
|
1223
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1224
|
+
? TNodeType
|
|
1225
|
+
: T extends number
|
|
1226
|
+
? 'float'
|
|
1227
|
+
: T extends boolean
|
|
1228
|
+
? 'bool'
|
|
1229
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1230
|
+
? 'color'
|
|
1231
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1232
|
+
? 'vec4'
|
|
1233
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1234
|
+
? 'vec3'
|
|
1235
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1236
|
+
? 'vec2'
|
|
1237
|
+
: T extends three_webgpu.Matrix4
|
|
1238
|
+
? 'mat4'
|
|
1239
|
+
: T extends three_webgpu.Matrix3
|
|
1240
|
+
? 'mat3'
|
|
1241
|
+
: T extends three_webgpu.Matrix2
|
|
1242
|
+
? 'mat2'
|
|
1243
|
+
: unknown
|
|
1244
|
+
|
|
1245
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1246
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1247
|
+
? TValue
|
|
1248
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1249
|
+
? TValue
|
|
1250
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1251
|
+
? three_webgpu.Color
|
|
1252
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1253
|
+
? three_webgpu.Vector4
|
|
1254
|
+
: T extends { x: number; y: number; z: number }
|
|
1255
|
+
? three_webgpu.Vector3
|
|
1256
|
+
: T extends { x: number; y: number }
|
|
1257
|
+
? three_webgpu.Vector2
|
|
1258
|
+
: T extends number
|
|
1259
|
+
? number
|
|
1260
|
+
: T extends boolean
|
|
1261
|
+
? boolean
|
|
1262
|
+
: T
|
|
1263
|
+
|
|
1264
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1265
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1266
|
+
|
|
1267
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1268
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1269
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1273
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1220
1274
|
|
|
1221
1275
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1222
1276
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1241,7 +1295,7 @@ declare global {
|
|
|
1241
1295
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1242
1296
|
* Supports:
|
|
1243
1297
|
* - Primitives: number, string (color), boolean
|
|
1244
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1298
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1245
1299
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1246
1300
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1247
1301
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1254,88 +1308,124 @@ declare global {
|
|
|
1254
1308
|
| three_webgpu.Vector2
|
|
1255
1309
|
| three_webgpu.Vector3
|
|
1256
1310
|
| three_webgpu.Vector4
|
|
1311
|
+
| three_webgpu.Matrix2
|
|
1257
1312
|
| three_webgpu.Matrix3
|
|
1258
1313
|
| three_webgpu.Matrix4
|
|
1259
|
-
|
|
|
1260
|
-
|
|
|
1261
|
-
| { x: number; y
|
|
1314
|
+
| { x: number; y: number }
|
|
1315
|
+
| { x: number; y: number; z: number }
|
|
1316
|
+
| { x: number; y: number; z: number; w: number }
|
|
1262
1317
|
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1263
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1318
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1264
1319
|
| UniformNode
|
|
1265
1320
|
|
|
1266
1321
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1267
1322
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1268
1323
|
}
|
|
1269
1324
|
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
declare module 'three/tsl' {
|
|
1325
|
+
declare global {
|
|
1273
1326
|
/**
|
|
1274
|
-
*
|
|
1275
|
-
*
|
|
1327
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1328
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1329
|
+
* is r185, so the new name is the only one.
|
|
1276
1330
|
*/
|
|
1277
|
-
|
|
1278
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1279
|
-
): ShaderCallable<R>
|
|
1331
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1280
1332
|
|
|
1281
1333
|
/**
|
|
1282
|
-
*
|
|
1283
|
-
*
|
|
1334
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1335
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1336
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1284
1337
|
*/
|
|
1285
|
-
|
|
1286
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1287
|
-
): ShaderCallable<R>
|
|
1338
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1288
1339
|
|
|
1289
1340
|
/**
|
|
1290
|
-
*
|
|
1291
|
-
*
|
|
1341
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1342
|
+
*
|
|
1343
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1344
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1345
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1346
|
+
* {@link RenderPipelineCallbackState}.
|
|
1347
|
+
*
|
|
1348
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1349
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1350
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1351
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1352
|
+
*
|
|
1353
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1354
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1355
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1356
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1292
1357
|
*/
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1358
|
+
interface PassRecord {
|
|
1359
|
+
scenePass?: ScenePassNode
|
|
1360
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1361
|
+
}
|
|
1297
1362
|
|
|
1298
1363
|
/**
|
|
1299
|
-
*
|
|
1364
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1365
|
+
*
|
|
1366
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1367
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1368
|
+
*
|
|
1369
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1370
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1300
1371
|
*/
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1372
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1373
|
+
renderPipeline: ThreeRenderPipeline
|
|
1374
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1375
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1376
|
+
isLegacy: false
|
|
1377
|
+
}
|
|
1306
1378
|
|
|
1307
|
-
declare global {
|
|
1308
1379
|
/**
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
* is
|
|
1380
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1381
|
+
*
|
|
1382
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1383
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1384
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1385
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1312
1386
|
*/
|
|
1313
|
-
type
|
|
1314
|
-
|
|
1315
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1316
|
-
type PassRecord = Record<string, any>
|
|
1387
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1317
1388
|
|
|
1318
1389
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1319
|
-
type RenderPipelineSetupCallback = (state:
|
|
1390
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1320
1391
|
|
|
1321
1392
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1322
|
-
type RenderPipelineMainCallback = (state:
|
|
1393
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1323
1394
|
|
|
1324
|
-
/**
|
|
1325
|
-
interface
|
|
1395
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1396
|
+
interface UseRenderPipelineActions {
|
|
1326
1397
|
/** Current passes from state */
|
|
1327
1398
|
passes: PassRecord
|
|
1328
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1329
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1330
1399
|
/** Clear all passes from state */
|
|
1331
1400
|
clearPasses: () => void
|
|
1332
1401
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1333
1402
|
reset: () => void
|
|
1334
1403
|
/** Re-run setup/main callbacks with current closure values */
|
|
1335
1404
|
rebuild: () => void
|
|
1336
|
-
/** True when RenderPipeline is configured and ready */
|
|
1337
|
-
isReady: boolean
|
|
1338
1405
|
}
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1409
|
+
*
|
|
1410
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1411
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1412
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1413
|
+
*/
|
|
1414
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1415
|
+
(
|
|
1416
|
+
| {
|
|
1417
|
+
/** True when RenderPipeline is configured and ready */
|
|
1418
|
+
isReady: true
|
|
1419
|
+
/** RenderPipeline instance */
|
|
1420
|
+
renderPipeline: ThreeRenderPipeline
|
|
1421
|
+
}
|
|
1422
|
+
| {
|
|
1423
|
+
/** False until the pipeline has been created */
|
|
1424
|
+
isReady: false
|
|
1425
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1426
|
+
renderPipeline: null
|
|
1427
|
+
}
|
|
1428
|
+
)
|
|
1339
1429
|
}
|
|
1340
1430
|
|
|
1341
1431
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1414,10 +1504,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1414
1504
|
|
|
1415
1505
|
/**
|
|
1416
1506
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1417
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1507
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1508
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1418
1509
|
*/
|
|
1419
1510
|
type NodeProps<P> = {
|
|
1420
|
-
[K in keyof P as P[K] extends
|
|
1511
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1421
1512
|
}
|
|
1422
1513
|
|
|
1423
1514
|
interface ReactProps<P> {
|
|
@@ -1438,11 +1529,30 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1438
1529
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1439
1530
|
}
|
|
1440
1531
|
|
|
1532
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1533
|
+
type Object3DMethod = NonNullable<
|
|
1534
|
+
{
|
|
1535
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1536
|
+
}[keyof Object3D]
|
|
1537
|
+
>
|
|
1538
|
+
|
|
1441
1539
|
type ThreeExports = typeof THREE
|
|
1442
1540
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1443
1541
|
|
|
1444
1542
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1445
|
-
|
|
1543
|
+
/**
|
|
1544
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1545
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1546
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1547
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1548
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1549
|
+
*/
|
|
1550
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | 'onUpdate' | Object3DMethod> & {
|
|
1551
|
+
object: object
|
|
1552
|
+
ref?: React.Ref<any>
|
|
1553
|
+
onUpdate?: (self: any) => void
|
|
1554
|
+
[prop: string]: unknown
|
|
1555
|
+
}
|
|
1446
1556
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1447
1557
|
threeAudio: ThreeElementsImpl['audio']
|
|
1448
1558
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1483,6 +1593,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1483
1593
|
type three_d_Matrix4 = Matrix4;
|
|
1484
1594
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1485
1595
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1596
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1486
1597
|
type three_d_Quaternion = Quaternion;
|
|
1487
1598
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1488
1599
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1497,7 +1608,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1497
1608
|
type three_d_Vector4 = Vector4;
|
|
1498
1609
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1499
1610
|
declare namespace three_d {
|
|
1500
|
-
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 };
|
|
1611
|
+
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 };
|
|
1501
1612
|
}
|
|
1502
1613
|
|
|
1503
1614
|
/**
|
|
@@ -1635,9 +1746,9 @@ type EnvironmentProps = {
|
|
|
1635
1746
|
blur?: number;
|
|
1636
1747
|
backgroundBlurriness?: number;
|
|
1637
1748
|
backgroundIntensity?: number;
|
|
1638
|
-
backgroundRotation?: Euler
|
|
1749
|
+
backgroundRotation?: Euler;
|
|
1639
1750
|
environmentIntensity?: number;
|
|
1640
|
-
environmentRotation?: Euler
|
|
1751
|
+
environmentRotation?: Euler;
|
|
1641
1752
|
map?: Texture$1;
|
|
1642
1753
|
preset?: PresetsType;
|
|
1643
1754
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -1721,7 +1832,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
1721
1832
|
declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
1722
1833
|
declare module '@react-three/fiber' {
|
|
1723
1834
|
interface ThreeElements {
|
|
1724
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1835
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
1725
1836
|
}
|
|
1726
1837
|
}
|
|
1727
1838
|
/**
|
|
@@ -1821,6 +1932,24 @@ declare module '@react-three/fiber' {
|
|
|
1821
1932
|
*/
|
|
1822
1933
|
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
1823
1934
|
|
|
1935
|
+
/**
|
|
1936
|
+
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
1937
|
+
*
|
|
1938
|
+
* When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
|
|
1939
|
+
* instance. Removing the old object from the interaction state and registering the new one from
|
|
1940
|
+
* scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
|
|
1941
|
+
* the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
|
|
1942
|
+
* is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
|
|
1943
|
+
* swap the user never asked to see (#3744).
|
|
1944
|
+
*
|
|
1945
|
+
* Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
|
|
1946
|
+
* left alone — releasing and re-acquiring it is precisely the glitch being avoided.
|
|
1947
|
+
*
|
|
1948
|
+
* Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
|
|
1949
|
+
* the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
|
|
1950
|
+
* cannot outlive the object it described.
|
|
1951
|
+
*/
|
|
1952
|
+
declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
|
|
1824
1953
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
1825
1954
|
declare function createEvents(store: RootStore): {
|
|
1826
1955
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
@@ -1828,7 +1957,7 @@ declare function createEvents(store: RootStore): {
|
|
|
1828
1957
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1829
1958
|
};
|
|
1830
1959
|
/** Default R3F event manager for web */
|
|
1831
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1960
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1832
1961
|
|
|
1833
1962
|
/**
|
|
1834
1963
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -1861,7 +1990,7 @@ declare namespace useLoader {
|
|
|
1861
1990
|
*
|
|
1862
1991
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1863
1992
|
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1864
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1993
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
1865
1994
|
*
|
|
1866
1995
|
* @example
|
|
1867
1996
|
* // Simple priority (backwards compat)
|
|
@@ -2157,7 +2286,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2157
2286
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2158
2287
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2159
2288
|
*
|
|
2160
|
-
*
|
|
2289
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2290
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2291
|
+
*
|
|
2292
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2161
2293
|
* @param frames - Number of frames to request (default: 1)
|
|
2162
2294
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2163
2295
|
*
|
|
@@ -2168,14 +2300,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2168
2300
|
* Advances the frameloop and runs render effects.
|
|
2169
2301
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2170
2302
|
*
|
|
2303
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2304
|
+
* registered root is stepped for backwards compatibility.
|
|
2305
|
+
*
|
|
2171
2306
|
* @param timestamp - The timestamp to use for this frame
|
|
2172
2307
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2173
|
-
* @param state -
|
|
2174
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2308
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2175
2309
|
*
|
|
2176
2310
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2177
2311
|
*/
|
|
2178
|
-
declare function advance(timestamp: number): void;
|
|
2312
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2179
2313
|
|
|
2180
2314
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2181
2315
|
declare function ReactReconciler<
|
|
@@ -3220,6 +3354,7 @@ declare namespace ReactReconciler {
|
|
|
3220
3354
|
|
|
3221
3355
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3222
3356
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3357
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3223
3358
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3224
3359
|
|
|
3225
3360
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3246,11 +3381,6 @@ declare function flushSync<R>(fn: () => R): R;
|
|
|
3246
3381
|
declare const context: React$1.Context<RootStore>;
|
|
3247
3382
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3248
3383
|
|
|
3249
|
-
/**
|
|
3250
|
-
* Safely flush async effects when testing, simulating a legacy root.
|
|
3251
|
-
* @deprecated Import from React instead. import { act } from 'react'
|
|
3252
|
-
*/
|
|
3253
|
-
declare const act: typeof React$1.act;
|
|
3254
3384
|
/**
|
|
3255
3385
|
* An SSR-friendly useLayoutEffect.
|
|
3256
3386
|
*
|
|
@@ -3668,29 +3798,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3668
3798
|
* Used to identify values that should be resolved from refs after mount.
|
|
3669
3799
|
*/
|
|
3670
3800
|
declare const FROM_REF: unique symbol;
|
|
3801
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3802
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3803
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3804
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3805
|
+
transform?: (value: T) => R;
|
|
3806
|
+
}
|
|
3671
3807
|
/**
|
|
3672
3808
|
* Defers prop application until the referenced object is available.
|
|
3673
3809
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3674
3810
|
*
|
|
3811
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3812
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3813
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3814
|
+
* what gets assigned.
|
|
3815
|
+
*
|
|
3675
3816
|
* @param ref - React ref object to resolve at mount time
|
|
3676
|
-
* @
|
|
3817
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3818
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3677
3819
|
*
|
|
3678
3820
|
* @example
|
|
3679
3821
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3680
3822
|
*
|
|
3681
3823
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3682
3824
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3825
|
+
*
|
|
3826
|
+
* @example
|
|
3827
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3828
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3683
3829
|
*/
|
|
3684
3830
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3831
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3685
3832
|
/**
|
|
3686
3833
|
* Type guard to check if a value is a fromRef marker.
|
|
3687
3834
|
*
|
|
3688
3835
|
* @param value - Value to check
|
|
3689
3836
|
* @returns True if value is a fromRef marker
|
|
3690
3837
|
*/
|
|
3691
|
-
declare function isFromRef(value: unknown): value is
|
|
3692
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3693
|
-
};
|
|
3838
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3694
3839
|
|
|
3695
3840
|
/**
|
|
3696
3841
|
* Symbol marker for mount-only method calls.
|
|
@@ -3717,7 +3862,15 @@ declare const ONCE: unique symbol;
|
|
|
3717
3862
|
* // No arguments
|
|
3718
3863
|
* <geometry center={once()} />
|
|
3719
3864
|
*/
|
|
3720
|
-
declare function once<
|
|
3865
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3866
|
+
/**
|
|
3867
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3868
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3869
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3870
|
+
*
|
|
3871
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3872
|
+
*/
|
|
3873
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3721
3874
|
/**
|
|
3722
3875
|
* Type guard to check if a value is a once marker.
|
|
3723
3876
|
*
|
|
@@ -3734,5 +3887,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
3734
3887
|
*/
|
|
3735
3888
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3736
3889
|
|
|
3737
|
-
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,
|
|
3738
|
-
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, LegacyInternalState as 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, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, LegacyRootState as 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 };
|
|
3890
|
+
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 };
|
|
3891
|
+
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, LegacyInternalState as 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, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, LegacyRootState as 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 };
|