@react-three/fiber 10.0.0-canary.c49d4cb → 10.0.0-canary.c4ecb6a
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 +2088 -1872
- package/dist/index.d.cts +310 -155
- package/dist/index.d.mts +310 -155
- package/dist/index.d.ts +308 -181
- package/dist/index.mjs +2090 -1874
- package/dist/legacy.cjs +2500 -2285
- package/dist/legacy.d.cts +336 -213
- package/dist/legacy.d.mts +336 -213
- package/dist/legacy.d.ts +334 -237
- package/dist/legacy.mjs +1929 -1714
- package/dist/webgpu/index.cjs +2598 -2598
- package/dist/webgpu/index.d.cts +406 -270
- package/dist/webgpu/index.d.mts +406 -270
- package/dist/webgpu/index.d.ts +404 -296
- package/dist/webgpu/index.mjs +2435 -2435
- 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.ts
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
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
|
-
function _mergeNamespaces(n, m) {
|
|
17
|
-
m.forEach(function (e) {
|
|
18
|
-
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
19
|
-
if (k !== 'default' && !(k in n)) {
|
|
20
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return e[k]; }
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
return Object.freeze(n);
|
|
29
|
-
}
|
|
30
15
|
|
|
31
16
|
/**
|
|
32
17
|
* @fileoverview Internal Three.js re-exports - LEGACY ENTRY
|
|
@@ -39,28 +24,17 @@ function _mergeNamespaces(n, m) {
|
|
|
39
24
|
declare const R3F_BUILD_LEGACY = true;
|
|
40
25
|
declare const R3F_BUILD_WEBGPU = false;
|
|
41
26
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
declare
|
|
46
|
-
|
|
47
|
-
}
|
|
27
|
+
type Inspector = never;
|
|
28
|
+
/** Not available on the legacy (WebGL-only) entry. */
|
|
29
|
+
declare function loadInspector(): Promise<never>;
|
|
30
|
+
declare class WebGPURenderer {
|
|
31
|
+
constructor();
|
|
32
|
+
}
|
|
48
33
|
|
|
49
34
|
declare const RenderTarget: any;
|
|
50
35
|
|
|
51
36
|
declare const CubeRenderTarget: any;
|
|
52
37
|
|
|
53
|
-
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
54
|
-
__proto__: null,
|
|
55
|
-
CubeRenderTarget: CubeRenderTarget,
|
|
56
|
-
CubeRenderTargetCompat: WebGLCubeRenderTarget,
|
|
57
|
-
Inspector: Inspector,
|
|
58
|
-
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
59
|
-
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
60
|
-
RenderTarget: RenderTarget,
|
|
61
|
-
RenderTargetCompat: WebGLRenderTarget,
|
|
62
|
-
WebGPURenderer: WebGPURenderer
|
|
63
|
-
}, [THREE$1]);
|
|
64
38
|
|
|
65
39
|
//* Utility Types ==============================
|
|
66
40
|
|
|
@@ -348,6 +322,7 @@ type BufferLike =
|
|
|
348
322
|
| Uint16Array
|
|
349
323
|
| Int16Array
|
|
350
324
|
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
325
|
+
| THREE$1.InterleavedBufferAttribute
|
|
351
326
|
| Node // TSL buffer nodes (instancedArray, storage)
|
|
352
327
|
|
|
353
328
|
/** Flat record of buffer-like values (no nested scopes) */
|
|
@@ -359,6 +334,25 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
359
334
|
*/
|
|
360
335
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
361
336
|
|
|
337
|
+
//* Node Types (useNodes) ========================================
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
341
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
342
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
343
|
+
* and the shape the store holds are one type by construction.
|
|
344
|
+
*/
|
|
345
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
346
|
+
|
|
347
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
348
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
352
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
353
|
+
*/
|
|
354
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
355
|
+
|
|
362
356
|
//* Storage Types (useGPUStorage) ========================================
|
|
363
357
|
|
|
364
358
|
/**
|
|
@@ -373,7 +367,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
|
373
367
|
* ```
|
|
374
368
|
*/
|
|
375
369
|
type StorageLike =
|
|
376
|
-
| StorageTexture // GPU storage texture
|
|
370
|
+
| StorageTexture // 2D GPU storage texture
|
|
371
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
372
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
377
373
|
| Data3DTexture // 3D texture (can be used as storage)
|
|
378
374
|
| Node // TSL storage texture nodes (storageTexture)
|
|
379
375
|
|
|
@@ -492,11 +488,28 @@ interface InternalState {
|
|
|
492
488
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
493
489
|
container?: THREE$1.Object3D
|
|
494
490
|
/**
|
|
495
|
-
* CanvasTarget
|
|
496
|
-
*
|
|
491
|
+
* The CanvasTarget this root sizes and renders through.
|
|
492
|
+
*
|
|
493
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
494
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
495
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
496
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
497
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
497
498
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
498
499
|
*/
|
|
499
500
|
canvasTarget?: CanvasTarget
|
|
501
|
+
/**
|
|
502
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
503
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
504
|
+
*
|
|
505
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
506
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
507
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
508
|
+
* invalidate some other canvas's descriptor instead.
|
|
509
|
+
*
|
|
510
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
511
|
+
*/
|
|
512
|
+
canvasTargetSizeDirty?: boolean
|
|
500
513
|
/**
|
|
501
514
|
* Whether multi-canvas rendering is active.
|
|
502
515
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -606,7 +619,7 @@ interface RootState {
|
|
|
606
619
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
607
620
|
uniforms: UniformStore
|
|
608
621
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
609
|
-
nodes:
|
|
622
|
+
nodes: NodeStore
|
|
610
623
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
611
624
|
buffers: BufferStore
|
|
612
625
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -618,7 +631,7 @@ interface RootState {
|
|
|
618
631
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
619
632
|
renderPipeline: ThreeRenderPipeline | null
|
|
620
633
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
621
|
-
passes:
|
|
634
|
+
passes: PassRecord
|
|
622
635
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
623
636
|
_hmrVersion: number
|
|
624
637
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -706,12 +719,19 @@ type DefaultRendererProps = {
|
|
|
706
719
|
*/
|
|
707
720
|
interface CanvasSchedulerConfig {
|
|
708
721
|
/**
|
|
709
|
-
*
|
|
710
|
-
|
|
722
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
723
|
+
*/
|
|
724
|
+
before?: string | string[]
|
|
725
|
+
/**
|
|
726
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
727
|
+
*/
|
|
728
|
+
after?: string | string[]
|
|
729
|
+
/**
|
|
730
|
+
* Numeric root order. Lower values run first.
|
|
711
731
|
*/
|
|
712
|
-
|
|
732
|
+
order?: number
|
|
713
733
|
/**
|
|
714
|
-
* Limit this
|
|
734
|
+
* Limit this Canvas's default render job (frames per second).
|
|
715
735
|
*/
|
|
716
736
|
fps?: number
|
|
717
737
|
}
|
|
@@ -798,14 +818,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
798
818
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
799
819
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
800
820
|
dpr?: Dpr
|
|
801
|
-
/**
|
|
802
|
-
|
|
821
|
+
/**
|
|
822
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
823
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
824
|
+
*/
|
|
825
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
803
826
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
804
827
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
805
828
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
806
829
|
camera?: CameraProps
|
|
807
830
|
/** An R3F event manager to manage elements' pointer events */
|
|
808
|
-
events?: (store: RootStore) => EventManager<
|
|
831
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
809
832
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
810
833
|
onCreated?: (state: RootState) => void
|
|
811
834
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -894,7 +917,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
894
917
|
object?: T
|
|
895
918
|
dispose?: null
|
|
896
919
|
attach?: AttachType<T>
|
|
897
|
-
onUpdate?: (self: T) => void
|
|
898
920
|
}
|
|
899
921
|
|
|
900
922
|
interface Instance<O = any> {
|
|
@@ -1034,7 +1056,7 @@ interface CanvasProps
|
|
|
1034
1056
|
*/
|
|
1035
1057
|
resize?: Options
|
|
1036
1058
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1037
|
-
eventSource?:
|
|
1059
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1038
1060
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1039
1061
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1040
1062
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1142,81 +1164,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1142
1164
|
|
|
1143
1165
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1144
1166
|
|
|
1145
|
-
//* Global Types ==============================
|
|
1167
|
+
//* Global TSL Types ==============================
|
|
1146
1168
|
|
|
1147
1169
|
declare global {
|
|
1148
1170
|
/**
|
|
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.
|
|
1171
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1172
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1161
1173
|
*/
|
|
1162
|
-
type
|
|
1174
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1175
|
+
readonly shaderNode: unknown
|
|
1176
|
+
readonly id: number
|
|
1177
|
+
}
|
|
1163
1178
|
|
|
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
|
|
1179
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1180
|
+
type LegacyTSLNodeLike = {
|
|
1181
|
+
label?: ((label: string) => unknown) | string
|
|
1182
|
+
setName?: (name: string) => unknown
|
|
1183
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1184
1184
|
|
|
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>
|
|
1185
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1186
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1195
1187
|
|
|
1196
1188
|
/**
|
|
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
|
-
* ```
|
|
1189
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1190
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1191
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1192
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1218
1193
|
*/
|
|
1219
|
-
type
|
|
1194
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1195
|
+
? TNodeType
|
|
1196
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1197
|
+
? TNodeType
|
|
1198
|
+
: T extends number
|
|
1199
|
+
? 'float'
|
|
1200
|
+
: T extends boolean
|
|
1201
|
+
? 'bool'
|
|
1202
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1203
|
+
? 'color'
|
|
1204
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1205
|
+
? 'vec4'
|
|
1206
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1207
|
+
? 'vec3'
|
|
1208
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1209
|
+
? 'vec2'
|
|
1210
|
+
: T extends three_webgpu.Matrix4
|
|
1211
|
+
? 'mat4'
|
|
1212
|
+
: T extends three_webgpu.Matrix3
|
|
1213
|
+
? 'mat3'
|
|
1214
|
+
: T extends three_webgpu.Matrix2
|
|
1215
|
+
? 'mat2'
|
|
1216
|
+
: unknown
|
|
1217
|
+
|
|
1218
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1219
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1220
|
+
? TValue
|
|
1221
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1222
|
+
? TValue
|
|
1223
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1224
|
+
? three_webgpu.Color
|
|
1225
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1226
|
+
? three_webgpu.Vector4
|
|
1227
|
+
: T extends { x: number; y: number; z: number }
|
|
1228
|
+
? three_webgpu.Vector3
|
|
1229
|
+
: T extends { x: number; y: number }
|
|
1230
|
+
? three_webgpu.Vector2
|
|
1231
|
+
: T extends number
|
|
1232
|
+
? number
|
|
1233
|
+
: T extends boolean
|
|
1234
|
+
? boolean
|
|
1235
|
+
: T
|
|
1236
|
+
|
|
1237
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1238
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1239
|
+
|
|
1240
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1241
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1242
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1246
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1220
1247
|
|
|
1221
1248
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1222
1249
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1241,7 +1268,7 @@ declare global {
|
|
|
1241
1268
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1242
1269
|
* Supports:
|
|
1243
1270
|
* - Primitives: number, string (color), boolean
|
|
1244
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1271
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1245
1272
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1246
1273
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1247
1274
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1254,88 +1281,124 @@ declare global {
|
|
|
1254
1281
|
| three_webgpu.Vector2
|
|
1255
1282
|
| three_webgpu.Vector3
|
|
1256
1283
|
| three_webgpu.Vector4
|
|
1284
|
+
| three_webgpu.Matrix2
|
|
1257
1285
|
| three_webgpu.Matrix3
|
|
1258
1286
|
| three_webgpu.Matrix4
|
|
1259
|
-
|
|
|
1260
|
-
|
|
|
1261
|
-
| { x: number; y
|
|
1287
|
+
| { x: number; y: number }
|
|
1288
|
+
| { x: number; y: number; z: number }
|
|
1289
|
+
| { x: number; y: number; z: number; w: number }
|
|
1262
1290
|
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1263
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1291
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1264
1292
|
| UniformNode
|
|
1265
1293
|
|
|
1266
1294
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1267
1295
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1268
1296
|
}
|
|
1269
1297
|
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
declare module 'three/tsl' {
|
|
1298
|
+
declare global {
|
|
1273
1299
|
/**
|
|
1274
|
-
*
|
|
1275
|
-
*
|
|
1300
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1301
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1302
|
+
* is r185, so the new name is the only one.
|
|
1276
1303
|
*/
|
|
1277
|
-
|
|
1278
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1279
|
-
): ShaderCallable<R>
|
|
1304
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1280
1305
|
|
|
1281
1306
|
/**
|
|
1282
|
-
*
|
|
1283
|
-
*
|
|
1307
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1308
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1309
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1284
1310
|
*/
|
|
1285
|
-
|
|
1286
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1287
|
-
): ShaderCallable<R>
|
|
1311
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1288
1312
|
|
|
1289
1313
|
/**
|
|
1290
|
-
*
|
|
1291
|
-
*
|
|
1314
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1315
|
+
*
|
|
1316
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1317
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1318
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1319
|
+
* {@link RenderPipelineCallbackState}.
|
|
1320
|
+
*
|
|
1321
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1322
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1323
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1324
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1325
|
+
*
|
|
1326
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1327
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1328
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1329
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1292
1330
|
*/
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1331
|
+
interface PassRecord {
|
|
1332
|
+
scenePass?: ScenePassNode
|
|
1333
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1334
|
+
}
|
|
1297
1335
|
|
|
1298
1336
|
/**
|
|
1299
|
-
*
|
|
1337
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1338
|
+
*
|
|
1339
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1340
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1341
|
+
*
|
|
1342
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1343
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1300
1344
|
*/
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1345
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1346
|
+
renderPipeline: ThreeRenderPipeline
|
|
1347
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1348
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1349
|
+
isLegacy: false
|
|
1350
|
+
}
|
|
1306
1351
|
|
|
1307
|
-
declare global {
|
|
1308
1352
|
/**
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
* is
|
|
1353
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1354
|
+
*
|
|
1355
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1356
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1357
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1358
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1312
1359
|
*/
|
|
1313
|
-
type
|
|
1314
|
-
|
|
1315
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1316
|
-
type PassRecord = Record<string, any>
|
|
1360
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1317
1361
|
|
|
1318
1362
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1319
|
-
type RenderPipelineSetupCallback = (state:
|
|
1363
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1320
1364
|
|
|
1321
1365
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1322
|
-
type RenderPipelineMainCallback = (state:
|
|
1366
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1323
1367
|
|
|
1324
|
-
/**
|
|
1325
|
-
interface
|
|
1368
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1369
|
+
interface UseRenderPipelineActions {
|
|
1326
1370
|
/** Current passes from state */
|
|
1327
1371
|
passes: PassRecord
|
|
1328
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1329
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1330
1372
|
/** Clear all passes from state */
|
|
1331
1373
|
clearPasses: () => void
|
|
1332
1374
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1333
1375
|
reset: () => void
|
|
1334
1376
|
/** Re-run setup/main callbacks with current closure values */
|
|
1335
1377
|
rebuild: () => void
|
|
1336
|
-
/** True when RenderPipeline is configured and ready */
|
|
1337
|
-
isReady: boolean
|
|
1338
1378
|
}
|
|
1379
|
+
|
|
1380
|
+
/**
|
|
1381
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1382
|
+
*
|
|
1383
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1384
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1385
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1386
|
+
*/
|
|
1387
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1388
|
+
(
|
|
1389
|
+
| {
|
|
1390
|
+
/** True when RenderPipeline is configured and ready */
|
|
1391
|
+
isReady: true
|
|
1392
|
+
/** RenderPipeline instance */
|
|
1393
|
+
renderPipeline: ThreeRenderPipeline
|
|
1394
|
+
}
|
|
1395
|
+
| {
|
|
1396
|
+
/** False until the pipeline has been created */
|
|
1397
|
+
isReady: false
|
|
1398
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1399
|
+
renderPipeline: null
|
|
1400
|
+
}
|
|
1401
|
+
)
|
|
1339
1402
|
}
|
|
1340
1403
|
|
|
1341
1404
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1414,10 +1477,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1414
1477
|
|
|
1415
1478
|
/**
|
|
1416
1479
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1417
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1480
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1481
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1418
1482
|
*/
|
|
1419
1483
|
type NodeProps<P> = {
|
|
1420
|
-
[K in keyof P as P[K] extends
|
|
1484
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1421
1485
|
}
|
|
1422
1486
|
|
|
1423
1487
|
interface ReactProps<P> {
|
|
@@ -1438,11 +1502,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1438
1502
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1439
1503
|
}
|
|
1440
1504
|
|
|
1505
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1506
|
+
type Object3DMethod = NonNullable<
|
|
1507
|
+
{
|
|
1508
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1509
|
+
}[keyof Object3D]
|
|
1510
|
+
>
|
|
1511
|
+
|
|
1441
1512
|
type ThreeExports = typeof import('three')
|
|
1442
1513
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1443
1514
|
|
|
1444
1515
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1445
|
-
|
|
1516
|
+
/**
|
|
1517
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1518
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1519
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1520
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1521
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1522
|
+
*/
|
|
1523
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1524
|
+
object: object
|
|
1525
|
+
ref?: React.Ref<any>
|
|
1526
|
+
[prop: string]: unknown
|
|
1527
|
+
}
|
|
1446
1528
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1447
1529
|
threeAudio: ThreeElementsImpl['audio']
|
|
1448
1530
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1483,6 +1565,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1483
1565
|
type three_d_Matrix4 = Matrix4;
|
|
1484
1566
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1485
1567
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1568
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1486
1569
|
type three_d_Quaternion = Quaternion;
|
|
1487
1570
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1488
1571
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1497,7 +1580,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1497
1580
|
type three_d_Vector4 = Vector4;
|
|
1498
1581
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1499
1582
|
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 };
|
|
1583
|
+
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
1584
|
}
|
|
1502
1585
|
|
|
1503
1586
|
/**
|
|
@@ -1635,9 +1718,9 @@ type EnvironmentProps = {
|
|
|
1635
1718
|
blur?: number;
|
|
1636
1719
|
backgroundBlurriness?: number;
|
|
1637
1720
|
backgroundIntensity?: number;
|
|
1638
|
-
backgroundRotation?: Euler
|
|
1721
|
+
backgroundRotation?: Euler;
|
|
1639
1722
|
environmentIntensity?: number;
|
|
1640
|
-
environmentRotation?: Euler
|
|
1723
|
+
environmentRotation?: Euler;
|
|
1641
1724
|
map?: Texture$1;
|
|
1642
1725
|
preset?: PresetsType;
|
|
1643
1726
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -1721,7 +1804,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
1721
1804
|
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
1805
|
declare module '@react-three/fiber' {
|
|
1723
1806
|
interface ThreeElements {
|
|
1724
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1807
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
1725
1808
|
}
|
|
1726
1809
|
}
|
|
1727
1810
|
/**
|
|
@@ -1821,6 +1904,24 @@ declare module '@react-three/fiber' {
|
|
|
1821
1904
|
*/
|
|
1822
1905
|
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
1823
1906
|
|
|
1907
|
+
/**
|
|
1908
|
+
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
1909
|
+
*
|
|
1910
|
+
* When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
|
|
1911
|
+
* instance. Removing the old object from the interaction state and registering the new one from
|
|
1912
|
+
* scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
|
|
1913
|
+
* the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
|
|
1914
|
+
* is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
|
|
1915
|
+
* swap the user never asked to see (#3744).
|
|
1916
|
+
*
|
|
1917
|
+
* Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
|
|
1918
|
+
* left alone — releasing and re-acquiring it is precisely the glitch being avoided.
|
|
1919
|
+
*
|
|
1920
|
+
* Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
|
|
1921
|
+
* the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
|
|
1922
|
+
* cannot outlive the object it described.
|
|
1923
|
+
*/
|
|
1924
|
+
declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
|
|
1824
1925
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
1825
1926
|
declare function createEvents(store: RootStore): {
|
|
1826
1927
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
@@ -1828,7 +1929,7 @@ declare function createEvents(store: RootStore): {
|
|
|
1828
1929
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1829
1930
|
};
|
|
1830
1931
|
/** Default R3F event manager for web */
|
|
1831
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1932
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1832
1933
|
|
|
1833
1934
|
/**
|
|
1834
1935
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -1848,50 +1949,6 @@ declare namespace useLoader {
|
|
|
1848
1949
|
var loader: typeof getLoader;
|
|
1849
1950
|
}
|
|
1850
1951
|
|
|
1851
|
-
/**
|
|
1852
|
-
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
1853
|
-
*
|
|
1854
|
-
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1855
|
-
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1856
|
-
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1857
|
-
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1858
|
-
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
1859
|
-
*
|
|
1860
|
-
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
1861
|
-
*
|
|
1862
|
-
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1863
|
-
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1864
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1865
|
-
*
|
|
1866
|
-
* @example
|
|
1867
|
-
* // Simple priority (backwards compat)
|
|
1868
|
-
* useFrame((state, delta) => { ... }, 5)
|
|
1869
|
-
*
|
|
1870
|
-
* @example
|
|
1871
|
-
* // With phase-based ordering
|
|
1872
|
-
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
1873
|
-
*
|
|
1874
|
-
* @example
|
|
1875
|
-
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
1876
|
-
* function UI() {
|
|
1877
|
-
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
1878
|
-
* return <button>...</button>;
|
|
1879
|
-
* }
|
|
1880
|
-
*
|
|
1881
|
-
* @example
|
|
1882
|
-
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
1883
|
-
* import { getScheduler } from '@pmndrs/scheduler'
|
|
1884
|
-
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
1885
|
-
*
|
|
1886
|
-
* @example
|
|
1887
|
-
* // Scheduler-only access (no callback)
|
|
1888
|
-
* const { scheduler } = useFrame()
|
|
1889
|
-
* scheduler.pauseJob('some-job-id')
|
|
1890
|
-
*
|
|
1891
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1892
|
-
*/
|
|
1893
|
-
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
1894
|
-
|
|
1895
1952
|
declare const IsObject: (url: unknown) => url is Record<string, string>;
|
|
1896
1953
|
type TextureArray<T> = T extends string[] ? Texture$1[] : never;
|
|
1897
1954
|
type TextureRecord<T> = T extends Record<string, string> ? {
|
|
@@ -2077,11 +2134,6 @@ declare function useRenderTarget(width: number, height: number, options?: Render
|
|
|
2077
2134
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2078
2135
|
*/
|
|
2079
2136
|
declare function useStore(): RootStore;
|
|
2080
|
-
/**
|
|
2081
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2082
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2083
|
-
*/
|
|
2084
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2085
2137
|
/**
|
|
2086
2138
|
* Exposes an object's {@link Instance}.
|
|
2087
2139
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2157,7 +2209,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2157
2209
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2158
2210
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2159
2211
|
*
|
|
2160
|
-
*
|
|
2212
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2213
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2214
|
+
*
|
|
2215
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2161
2216
|
* @param frames - Number of frames to request (default: 1)
|
|
2162
2217
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2163
2218
|
*
|
|
@@ -2168,14 +2223,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2168
2223
|
* Advances the frameloop and runs render effects.
|
|
2169
2224
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2170
2225
|
*
|
|
2226
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2227
|
+
* registered root is stepped for backwards compatibility.
|
|
2228
|
+
*
|
|
2171
2229
|
* @param timestamp - The timestamp to use for this frame
|
|
2172
2230
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2173
|
-
* @param state -
|
|
2174
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2231
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2175
2232
|
*
|
|
2176
2233
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2177
2234
|
*/
|
|
2178
|
-
declare function advance(timestamp: number): void;
|
|
2235
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2179
2236
|
|
|
2180
2237
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2181
2238
|
declare function ReactReconciler<
|
|
@@ -3220,6 +3277,7 @@ declare namespace ReactReconciler {
|
|
|
3220
3277
|
|
|
3221
3278
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3222
3279
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3280
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3223
3281
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3224
3282
|
|
|
3225
3283
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3246,11 +3304,6 @@ declare function flushSync<R>(fn: () => R): R;
|
|
|
3246
3304
|
declare const context: React$1.Context<RootStore>;
|
|
3247
3305
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3248
3306
|
|
|
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
3307
|
/**
|
|
3255
3308
|
* An SSR-friendly useLayoutEffect.
|
|
3256
3309
|
*
|
|
@@ -3502,7 +3555,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
3502
3555
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
3503
3556
|
/**
|
|
3504
3557
|
* Triggers an update for an instance.
|
|
3505
|
-
*
|
|
3558
|
+
* Invalidates the frame if the root is in demand mode.
|
|
3506
3559
|
*
|
|
3507
3560
|
* @param instance - Instance to invalidate
|
|
3508
3561
|
*/
|
|
@@ -3668,29 +3721,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3668
3721
|
* Used to identify values that should be resolved from refs after mount.
|
|
3669
3722
|
*/
|
|
3670
3723
|
declare const FROM_REF: unique symbol;
|
|
3724
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3725
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3726
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3727
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3728
|
+
transform?: (value: T) => R;
|
|
3729
|
+
}
|
|
3671
3730
|
/**
|
|
3672
3731
|
* Defers prop application until the referenced object is available.
|
|
3673
3732
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3674
3733
|
*
|
|
3734
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3735
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3736
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3737
|
+
* what gets assigned.
|
|
3738
|
+
*
|
|
3675
3739
|
* @param ref - React ref object to resolve at mount time
|
|
3676
|
-
* @
|
|
3740
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3741
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3677
3742
|
*
|
|
3678
3743
|
* @example
|
|
3679
3744
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3680
3745
|
*
|
|
3681
3746
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3682
3747
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3748
|
+
*
|
|
3749
|
+
* @example
|
|
3750
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3751
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3683
3752
|
*/
|
|
3684
3753
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3754
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3685
3755
|
/**
|
|
3686
3756
|
* Type guard to check if a value is a fromRef marker.
|
|
3687
3757
|
*
|
|
3688
3758
|
* @param value - Value to check
|
|
3689
3759
|
* @returns True if value is a fromRef marker
|
|
3690
3760
|
*/
|
|
3691
|
-
declare function isFromRef(value: unknown): value is
|
|
3692
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3693
|
-
};
|
|
3761
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3694
3762
|
|
|
3695
3763
|
/**
|
|
3696
3764
|
* Symbol marker for mount-only method calls.
|
|
@@ -3717,7 +3785,15 @@ declare const ONCE: unique symbol;
|
|
|
3717
3785
|
* // No arguments
|
|
3718
3786
|
* <geometry center={once()} />
|
|
3719
3787
|
*/
|
|
3720
|
-
declare function once<
|
|
3788
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3789
|
+
/**
|
|
3790
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3791
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3792
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3793
|
+
*
|
|
3794
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3795
|
+
*/
|
|
3796
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3721
3797
|
/**
|
|
3722
3798
|
* Type guard to check if a value is a once marker.
|
|
3723
3799
|
*
|
|
@@ -3729,10 +3805,31 @@ declare function isOnce(value: unknown): value is {
|
|
|
3729
3805
|
};
|
|
3730
3806
|
|
|
3731
3807
|
/**
|
|
3732
|
-
*
|
|
3733
|
-
*
|
|
3808
|
+
* @fileoverview Legacy entry point - WebGL only
|
|
3809
|
+
*
|
|
3810
|
+
* This entry point is for apps that want to use the legacy WebGLRenderer.
|
|
3811
|
+
* No WebGPU features are available from this import path.
|
|
3812
|
+
* Auto-extends THREE with WebGL-only constructors (no node materials).
|
|
3813
|
+
*
|
|
3814
|
+
* Usage:
|
|
3815
|
+
* import { Canvas, useFrame } from '@react-three/fiber/legacy'
|
|
3734
3816
|
*/
|
|
3735
|
-
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3736
3817
|
|
|
3737
|
-
|
|
3738
|
-
|
|
3818
|
+
/** `useThree` narrowed to legacy state — `state.renderer` is a `WebGLRenderer`. */
|
|
3819
|
+
type UseThreeLegacy = <T = LegacyRootState>(selector?: (state: LegacyRootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
|
|
3820
|
+
/** `useFrame` narrowed to legacy state — the callback's `state.renderer` is a `WebGLRenderer`. */
|
|
3821
|
+
type UseFrameLegacy = (callback?: FrameCallback$1<LegacyRootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
|
|
3822
|
+
declare const useThree: UseThreeLegacy;
|
|
3823
|
+
declare const useFrame: UseFrameLegacy;
|
|
3824
|
+
|
|
3825
|
+
/** Canvas props on the legacy entry: `onCreated` receives `LegacyRootState`. */
|
|
3826
|
+
type LegacyCanvasProps = Omit<CanvasProps, 'onCreated'> & {
|
|
3827
|
+
/** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGLRenderer` */
|
|
3828
|
+
onCreated?: (state: LegacyRootState) => void;
|
|
3829
|
+
};
|
|
3830
|
+
|
|
3831
|
+
/** `Canvas` narrowed to legacy state — the same component, `onCreated` typed against `LegacyRootState`. */
|
|
3832
|
+
declare const Canvas: (props: LegacyCanvasProps) => JSX.Element;
|
|
3833
|
+
|
|
3834
|
+
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 };
|
|
3835
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, LegacyCanvasProps as 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, LegacyCanvasProps, 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, UseFrameLegacy, UseTextureOptions, UseTexturesReturn, UseThreeLegacy, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|