@react-three/fiber 10.0.0-canary.da7a768 → 10.0.0-canary.dc0ec15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension.cjs +278 -0
- package/dist/extension.d.cts +1675 -0
- package/dist/extension.d.mts +1675 -0
- package/dist/extension.d.ts +1647 -0
- package/dist/extension.mjs +258 -0
- package/dist/index.cjs +994 -898
- package/dist/index.d.cts +331 -155
- package/dist/index.d.mts +331 -155
- package/dist/index.d.ts +331 -183
- package/dist/index.mjs +995 -901
- package/dist/legacy.cjs +1345 -1245
- package/dist/legacy.d.cts +353 -205
- package/dist/legacy.d.mts +353 -205
- package/dist/legacy.d.ts +353 -231
- package/dist/legacy.mjs +1346 -1248
- package/dist/webgpu/index.cjs +908 -713
- package/dist/webgpu/index.d.cts +389 -212
- package/dist/webgpu/index.d.mts +389 -212
- package/dist/webgpu/index.d.ts +389 -240
- package/dist/webgpu/index.mjs +910 -717
- package/package.json +7 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
|
|
2
2
|
import * as three_webgpu from 'three/webgpu';
|
|
3
|
-
import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget,
|
|
3
|
+
import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Object3D, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera } from 'three/webgpu';
|
|
4
4
|
import * as THREE$1 from 'three';
|
|
5
5
|
import { WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
6
6
|
import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
|
|
@@ -15,20 +15,6 @@ import { Options } from 'react-use-measure';
|
|
|
15
15
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
16
16
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
17
17
|
|
|
18
|
-
function _mergeNamespaces(n, m) {
|
|
19
|
-
m.forEach(function (e) {
|
|
20
|
-
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
21
|
-
if (k !== 'default' && !(k in n)) {
|
|
22
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () { return e[k]; }
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
return Object.freeze(n);
|
|
31
|
-
}
|
|
32
18
|
|
|
33
19
|
/**
|
|
34
20
|
* @fileoverview Internal Three.js re-exports - DEFAULT ENTRY
|
|
@@ -51,20 +37,6 @@ declare const R3F_BUILD_WEBGPU = true;
|
|
|
51
37
|
/** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
|
|
52
38
|
declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
|
|
53
39
|
|
|
54
|
-
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
55
|
-
__proto__: null,
|
|
56
|
-
CubeRenderTarget: CubeRenderTarget,
|
|
57
|
-
CubeRenderTargetCompat: CubeRenderTarget,
|
|
58
|
-
Inspector: Inspector,
|
|
59
|
-
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
60
|
-
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
61
|
-
RenderTargetCompat: RenderTarget,
|
|
62
|
-
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
63
|
-
WebGLRenderTarget: WebGLRenderTarget,
|
|
64
|
-
WebGLRenderer: WebGLRenderer,
|
|
65
|
-
WebGLRendererParameters: WebGLRendererParameters,
|
|
66
|
-
loadInspector: loadInspector
|
|
67
|
-
}, [three_webgpu]);
|
|
68
40
|
|
|
69
41
|
//* Utility Types ==============================
|
|
70
42
|
|
|
@@ -352,6 +324,7 @@ type BufferLike =
|
|
|
352
324
|
| Uint16Array
|
|
353
325
|
| Int16Array
|
|
354
326
|
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
327
|
+
| THREE$1.InterleavedBufferAttribute
|
|
355
328
|
| Node // TSL buffer nodes (instancedArray, storage)
|
|
356
329
|
|
|
357
330
|
/** Flat record of buffer-like values (no nested scopes) */
|
|
@@ -363,6 +336,25 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
363
336
|
*/
|
|
364
337
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
365
338
|
|
|
339
|
+
//* Node Types (useNodes) ========================================
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
343
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
344
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
345
|
+
* and the shape the store holds are one type by construction.
|
|
346
|
+
*/
|
|
347
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
348
|
+
|
|
349
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
350
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
354
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
355
|
+
*/
|
|
356
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
357
|
+
|
|
366
358
|
//* Storage Types (useGPUStorage) ========================================
|
|
367
359
|
|
|
368
360
|
/**
|
|
@@ -377,7 +369,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
|
377
369
|
* ```
|
|
378
370
|
*/
|
|
379
371
|
type StorageLike =
|
|
380
|
-
| StorageTexture // GPU storage texture
|
|
372
|
+
| StorageTexture // 2D GPU storage texture
|
|
373
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
374
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
381
375
|
| Data3DTexture // 3D texture (can be used as storage)
|
|
382
376
|
| Node // TSL storage texture nodes (storageTexture)
|
|
383
377
|
|
|
@@ -489,6 +483,12 @@ interface InternalState {
|
|
|
489
483
|
actualRenderer: R3FRenderer
|
|
490
484
|
/** Global scheduler reference (for useFrame hook) */
|
|
491
485
|
scheduler: SchedulerApi | null
|
|
486
|
+
/**
|
|
487
|
+
* Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
|
|
488
|
+
* `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
|
|
489
|
+
* render-phase takeover. Used by `useRenderPipeline`.
|
|
490
|
+
*/
|
|
491
|
+
renderOverride?: (() => void) | null
|
|
492
492
|
/** This root's unique ID in the global scheduler */
|
|
493
493
|
rootId?: string
|
|
494
494
|
/** Function to unregister this root from the global scheduler */
|
|
@@ -496,11 +496,28 @@ interface InternalState {
|
|
|
496
496
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
497
497
|
container?: THREE$1.Object3D
|
|
498
498
|
/**
|
|
499
|
-
* CanvasTarget
|
|
500
|
-
*
|
|
499
|
+
* The CanvasTarget this root sizes and renders through.
|
|
500
|
+
*
|
|
501
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
502
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
503
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
504
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
505
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
501
506
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
502
507
|
*/
|
|
503
508
|
canvasTarget?: CanvasTarget
|
|
509
|
+
/**
|
|
510
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
511
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
512
|
+
*
|
|
513
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
514
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
515
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
516
|
+
* invalidate some other canvas's descriptor instead.
|
|
517
|
+
*
|
|
518
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
519
|
+
*/
|
|
520
|
+
canvasTargetSizeDirty?: boolean
|
|
504
521
|
/**
|
|
505
522
|
* Whether multi-canvas rendering is active.
|
|
506
523
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -610,7 +627,7 @@ interface RootState {
|
|
|
610
627
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
611
628
|
uniforms: UniformStore
|
|
612
629
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
613
|
-
nodes:
|
|
630
|
+
nodes: NodeStore
|
|
614
631
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
615
632
|
buffers: BufferStore
|
|
616
633
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -622,7 +639,7 @@ interface RootState {
|
|
|
622
639
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
623
640
|
renderPipeline: ThreeRenderPipeline | null
|
|
624
641
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
625
|
-
passes:
|
|
642
|
+
passes: PassRecord
|
|
626
643
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
627
644
|
_hmrVersion: number
|
|
628
645
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -710,12 +727,19 @@ type DefaultRendererProps = {
|
|
|
710
727
|
*/
|
|
711
728
|
interface CanvasSchedulerConfig {
|
|
712
729
|
/**
|
|
713
|
-
*
|
|
714
|
-
|
|
730
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
731
|
+
*/
|
|
732
|
+
before?: string | string[]
|
|
733
|
+
/**
|
|
734
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
715
735
|
*/
|
|
716
|
-
after?: string
|
|
736
|
+
after?: string | string[]
|
|
717
737
|
/**
|
|
718
|
-
*
|
|
738
|
+
* Numeric root order. Lower values run first.
|
|
739
|
+
*/
|
|
740
|
+
order?: number
|
|
741
|
+
/**
|
|
742
|
+
* Limit this Canvas's default render job (frames per second).
|
|
719
743
|
*/
|
|
720
744
|
fps?: number
|
|
721
745
|
}
|
|
@@ -802,14 +826,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
802
826
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
803
827
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
804
828
|
dpr?: Dpr
|
|
805
|
-
/**
|
|
806
|
-
|
|
829
|
+
/**
|
|
830
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
831
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
832
|
+
*/
|
|
833
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
807
834
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
808
835
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
809
836
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
810
837
|
camera?: CameraProps
|
|
811
838
|
/** An R3F event manager to manage elements' pointer events */
|
|
812
|
-
events?: (store: RootStore) => EventManager<
|
|
839
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
813
840
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
814
841
|
onCreated?: (state: RootState) => void
|
|
815
842
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -898,7 +925,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
898
925
|
object?: T
|
|
899
926
|
dispose?: null
|
|
900
927
|
attach?: AttachType<T>
|
|
901
|
-
onUpdate?: (self: T) => void
|
|
902
928
|
}
|
|
903
929
|
|
|
904
930
|
interface Instance<O = any> {
|
|
@@ -1038,7 +1064,7 @@ interface CanvasProps
|
|
|
1038
1064
|
*/
|
|
1039
1065
|
resize?: Options
|
|
1040
1066
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1041
|
-
eventSource?:
|
|
1067
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1042
1068
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1043
1069
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1044
1070
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1146,81 +1172,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1146
1172
|
|
|
1147
1173
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1148
1174
|
|
|
1149
|
-
//* Global Types ==============================
|
|
1175
|
+
//* Global TSL Types ==============================
|
|
1150
1176
|
|
|
1151
1177
|
declare global {
|
|
1152
1178
|
/**
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1155
|
-
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1156
|
-
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1157
|
-
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1158
|
-
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1159
|
-
* arity when three made `UniformNode` two-parameter.
|
|
1160
|
-
*
|
|
1161
|
-
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1162
|
-
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1163
|
-
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1164
|
-
* installed three instead of needing to be mirrored by hand.
|
|
1179
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1180
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1165
1181
|
*/
|
|
1166
|
-
type
|
|
1182
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1183
|
+
readonly shaderNode: unknown
|
|
1184
|
+
readonly id: number
|
|
1185
|
+
}
|
|
1167
1186
|
|
|
1168
|
-
/**
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
* @example
|
|
1174
|
-
* ```tsx
|
|
1175
|
-
* // Define a shader function
|
|
1176
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1177
|
-
* return mix(color1, color2, factor)
|
|
1178
|
-
* })
|
|
1179
|
-
*
|
|
1180
|
-
* // Type when retrieving from nodes store
|
|
1181
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1182
|
-
*
|
|
1183
|
-
* // Or with specific return type
|
|
1184
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1185
|
-
* ```
|
|
1186
|
-
*/
|
|
1187
|
-
type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
|
|
1187
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1188
|
+
type LegacyTSLNodeLike = {
|
|
1189
|
+
label?: ((label: string) => unknown) | string
|
|
1190
|
+
setName?: (name: string) => unknown
|
|
1191
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1188
1192
|
|
|
1189
|
-
/**
|
|
1190
|
-
|
|
1191
|
-
* This is the common return type for TSL operations (add, mul, sin, etc.)
|
|
1192
|
-
*
|
|
1193
|
-
* @example
|
|
1194
|
-
* ```tsx
|
|
1195
|
-
* const { wobble } = nodes as { wobble: ShaderNodeRef }
|
|
1196
|
-
* ```
|
|
1197
|
-
*/
|
|
1198
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1193
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1194
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1199
1195
|
|
|
1200
1196
|
/**
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
* - Node: base Three.js node type
|
|
1206
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1207
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1208
|
-
*
|
|
1209
|
-
* @example
|
|
1210
|
-
* ```tsx
|
|
1211
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1212
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1213
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1214
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1215
|
-
* }))
|
|
1216
|
-
*
|
|
1217
|
-
* // Can narrow with type guard or assertion when needed
|
|
1218
|
-
* if (typeof blendColorFn === 'function') {
|
|
1219
|
-
* blendColorFn(someColor, 0.5)
|
|
1220
|
-
* }
|
|
1221
|
-
* ```
|
|
1197
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1198
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1199
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1200
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1222
1201
|
*/
|
|
1223
|
-
type
|
|
1202
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1203
|
+
? TNodeType
|
|
1204
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1205
|
+
? TNodeType
|
|
1206
|
+
: T extends number
|
|
1207
|
+
? 'float'
|
|
1208
|
+
: T extends boolean
|
|
1209
|
+
? 'bool'
|
|
1210
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1211
|
+
? 'color'
|
|
1212
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1213
|
+
? 'vec4'
|
|
1214
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1215
|
+
? 'vec3'
|
|
1216
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1217
|
+
? 'vec2'
|
|
1218
|
+
: T extends three_webgpu.Matrix4
|
|
1219
|
+
? 'mat4'
|
|
1220
|
+
: T extends three_webgpu.Matrix3
|
|
1221
|
+
? 'mat3'
|
|
1222
|
+
: T extends three_webgpu.Matrix2
|
|
1223
|
+
? 'mat2'
|
|
1224
|
+
: unknown
|
|
1225
|
+
|
|
1226
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1227
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1228
|
+
? TValue
|
|
1229
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1230
|
+
? TValue
|
|
1231
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1232
|
+
? three_webgpu.Color
|
|
1233
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1234
|
+
? three_webgpu.Vector4
|
|
1235
|
+
: T extends { x: number; y: number; z: number }
|
|
1236
|
+
? three_webgpu.Vector3
|
|
1237
|
+
: T extends { x: number; y: number }
|
|
1238
|
+
? three_webgpu.Vector2
|
|
1239
|
+
: T extends number
|
|
1240
|
+
? number
|
|
1241
|
+
: T extends boolean
|
|
1242
|
+
? boolean
|
|
1243
|
+
: T
|
|
1244
|
+
|
|
1245
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1246
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1247
|
+
|
|
1248
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1249
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1250
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1254
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1224
1255
|
|
|
1225
1256
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1226
1257
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1245,7 +1276,7 @@ declare global {
|
|
|
1245
1276
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1246
1277
|
* Supports:
|
|
1247
1278
|
* - Primitives: number, string (color), boolean
|
|
1248
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1279
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1249
1280
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1250
1281
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1251
1282
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1258,88 +1289,124 @@ declare global {
|
|
|
1258
1289
|
| three_webgpu.Vector2
|
|
1259
1290
|
| three_webgpu.Vector3
|
|
1260
1291
|
| three_webgpu.Vector4
|
|
1292
|
+
| three_webgpu.Matrix2
|
|
1261
1293
|
| three_webgpu.Matrix3
|
|
1262
1294
|
| three_webgpu.Matrix4
|
|
1263
|
-
|
|
|
1264
|
-
|
|
|
1265
|
-
| { x: number; y
|
|
1295
|
+
| { x: number; y: number }
|
|
1296
|
+
| { x: number; y: number; z: number }
|
|
1297
|
+
| { x: number; y: number; z: number; w: number }
|
|
1266
1298
|
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1267
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1299
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1268
1300
|
| UniformNode
|
|
1269
1301
|
|
|
1270
1302
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1271
1303
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1272
1304
|
}
|
|
1273
1305
|
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
declare module 'three/tsl' {
|
|
1306
|
+
declare global {
|
|
1277
1307
|
/**
|
|
1278
|
-
*
|
|
1279
|
-
*
|
|
1308
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1309
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1310
|
+
* is r185, so the new name is the only one.
|
|
1280
1311
|
*/
|
|
1281
|
-
|
|
1282
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1283
|
-
): ShaderCallable<R>
|
|
1312
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1284
1313
|
|
|
1285
1314
|
/**
|
|
1286
|
-
*
|
|
1287
|
-
*
|
|
1315
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1316
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1317
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1288
1318
|
*/
|
|
1289
|
-
|
|
1290
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1291
|
-
): ShaderCallable<R>
|
|
1319
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1292
1320
|
|
|
1293
1321
|
/**
|
|
1294
|
-
*
|
|
1295
|
-
*
|
|
1322
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1323
|
+
*
|
|
1324
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1325
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1326
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1327
|
+
* {@link RenderPipelineCallbackState}.
|
|
1328
|
+
*
|
|
1329
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1330
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1331
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1332
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1333
|
+
*
|
|
1334
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1335
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1336
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1337
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1296
1338
|
*/
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1339
|
+
interface PassRecord {
|
|
1340
|
+
scenePass?: ScenePassNode
|
|
1341
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1342
|
+
}
|
|
1301
1343
|
|
|
1302
1344
|
/**
|
|
1303
|
-
*
|
|
1345
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1346
|
+
*
|
|
1347
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1348
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1349
|
+
*
|
|
1350
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1351
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1304
1352
|
*/
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1353
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1354
|
+
renderPipeline: ThreeRenderPipeline
|
|
1355
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1356
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1357
|
+
isLegacy: false
|
|
1358
|
+
}
|
|
1310
1359
|
|
|
1311
|
-
declare global {
|
|
1312
1360
|
/**
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
* is
|
|
1361
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1362
|
+
*
|
|
1363
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1364
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1365
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1366
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1316
1367
|
*/
|
|
1317
|
-
type
|
|
1318
|
-
|
|
1319
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1320
|
-
type PassRecord = Record<string, any>
|
|
1368
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1321
1369
|
|
|
1322
1370
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1323
|
-
type RenderPipelineSetupCallback = (state:
|
|
1371
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1324
1372
|
|
|
1325
1373
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1326
|
-
type RenderPipelineMainCallback = (state:
|
|
1374
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1327
1375
|
|
|
1328
|
-
/**
|
|
1329
|
-
interface
|
|
1376
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1377
|
+
interface UseRenderPipelineActions {
|
|
1330
1378
|
/** Current passes from state */
|
|
1331
1379
|
passes: PassRecord
|
|
1332
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1333
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1334
1380
|
/** Clear all passes from state */
|
|
1335
1381
|
clearPasses: () => void
|
|
1336
1382
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1337
1383
|
reset: () => void
|
|
1338
1384
|
/** Re-run setup/main callbacks with current closure values */
|
|
1339
1385
|
rebuild: () => void
|
|
1340
|
-
/** True when RenderPipeline is configured and ready */
|
|
1341
|
-
isReady: boolean
|
|
1342
1386
|
}
|
|
1387
|
+
|
|
1388
|
+
/**
|
|
1389
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1390
|
+
*
|
|
1391
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1392
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1393
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1394
|
+
*/
|
|
1395
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1396
|
+
(
|
|
1397
|
+
| {
|
|
1398
|
+
/** True when RenderPipeline is configured and ready */
|
|
1399
|
+
isReady: true
|
|
1400
|
+
/** RenderPipeline instance */
|
|
1401
|
+
renderPipeline: ThreeRenderPipeline
|
|
1402
|
+
}
|
|
1403
|
+
| {
|
|
1404
|
+
/** False until the pipeline has been created */
|
|
1405
|
+
isReady: false
|
|
1406
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1407
|
+
renderPipeline: null
|
|
1408
|
+
}
|
|
1409
|
+
)
|
|
1343
1410
|
}
|
|
1344
1411
|
|
|
1345
1412
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1418,10 +1485,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1418
1485
|
|
|
1419
1486
|
/**
|
|
1420
1487
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1421
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1488
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1489
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1422
1490
|
*/
|
|
1423
1491
|
type NodeProps<P> = {
|
|
1424
|
-
[K in keyof P as P[K] extends
|
|
1492
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1425
1493
|
}
|
|
1426
1494
|
|
|
1427
1495
|
interface ReactProps<P> {
|
|
@@ -1442,11 +1510,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1442
1510
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1443
1511
|
}
|
|
1444
1512
|
|
|
1513
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1514
|
+
type Object3DMethod = NonNullable<
|
|
1515
|
+
{
|
|
1516
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1517
|
+
}[keyof Object3D]
|
|
1518
|
+
>
|
|
1519
|
+
|
|
1445
1520
|
type ThreeExports = typeof import('three') & typeof import('three/webgpu')
|
|
1446
1521
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1447
1522
|
|
|
1448
1523
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1449
|
-
|
|
1524
|
+
/**
|
|
1525
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1526
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1527
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1528
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1529
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1530
|
+
*/
|
|
1531
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1532
|
+
object: object
|
|
1533
|
+
ref?: React.Ref<any>
|
|
1534
|
+
[prop: string]: unknown
|
|
1535
|
+
}
|
|
1450
1536
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1451
1537
|
threeAudio: ThreeElementsImpl['audio']
|
|
1452
1538
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1487,6 +1573,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1487
1573
|
type three_d_Matrix4 = Matrix4;
|
|
1488
1574
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1489
1575
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1576
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1490
1577
|
type three_d_Quaternion = Quaternion;
|
|
1491
1578
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1492
1579
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1501,7 +1588,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1501
1588
|
type three_d_Vector4 = Vector4;
|
|
1502
1589
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1503
1590
|
declare namespace three_d {
|
|
1504
|
-
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1591
|
+
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Object3DMethod as Object3DMethod, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1505
1592
|
}
|
|
1506
1593
|
|
|
1507
1594
|
/**
|
|
@@ -1850,7 +1937,48 @@ declare function createEvents(store: RootStore): {
|
|
|
1850
1937
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1851
1938
|
};
|
|
1852
1939
|
/** Default R3F event manager for web */
|
|
1853
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1940
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1941
|
+
|
|
1942
|
+
interface RootExtension {
|
|
1943
|
+
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
1944
|
+
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
1945
|
+
name: string;
|
|
1946
|
+
/**
|
|
1947
|
+
* Called once per root, after its renderer exists and before `onCreated` and the first frame.
|
|
1948
|
+
* `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
|
|
1949
|
+
* to the primary canvas. Return fields to merge into the root's state, or nothing.
|
|
1950
|
+
*/
|
|
1951
|
+
setup?(store: RootStore): Partial<RootState> | void;
|
|
1952
|
+
/** Called when a root this extension set up unmounts. */
|
|
1953
|
+
dispose?(store: RootStore): void;
|
|
1954
|
+
/** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
|
|
1955
|
+
hmr?(store: RootStore): void;
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Register an extension. It is set up on every live root immediately, and on every root created
|
|
1959
|
+
* afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
|
|
1960
|
+
* it already set up keep its state and still get its dispose when they unmount.
|
|
1961
|
+
*/
|
|
1962
|
+
declare function registerRootExtension(extension: RootExtension): () => void;
|
|
1963
|
+
/**
|
|
1964
|
+
* Point a root's default render job at a different render function, or back at
|
|
1965
|
+
* `renderer.render(scene, camera)` with `null`.
|
|
1966
|
+
*
|
|
1967
|
+
* The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
|
|
1968
|
+
* boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
|
|
1969
|
+
*/
|
|
1970
|
+
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
1971
|
+
|
|
1972
|
+
/**
|
|
1973
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
1974
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
1975
|
+
*/
|
|
1976
|
+
declare function useStore(): RootStore;
|
|
1977
|
+
/**
|
|
1978
|
+
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
1979
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
1980
|
+
*/
|
|
1981
|
+
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
1854
1982
|
|
|
1855
1983
|
/**
|
|
1856
1984
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -1883,7 +2011,7 @@ declare namespace useLoader {
|
|
|
1883
2011
|
*
|
|
1884
2012
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1885
2013
|
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1886
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
2014
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
1887
2015
|
*
|
|
1888
2016
|
* @example
|
|
1889
2017
|
* // Simple priority (backwards compat)
|
|
@@ -2094,16 +2222,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
|
|
|
2094
2222
|
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
|
|
2095
2223
|
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
|
|
2096
2224
|
|
|
2097
|
-
/**
|
|
2098
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2099
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2100
|
-
*/
|
|
2101
|
-
declare function useStore(): RootStore;
|
|
2102
|
-
/**
|
|
2103
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2104
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2105
|
-
*/
|
|
2106
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2107
2225
|
/**
|
|
2108
2226
|
* Exposes an object's {@link Instance}.
|
|
2109
2227
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2179,7 +2297,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2179
2297
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2180
2298
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2181
2299
|
*
|
|
2182
|
-
*
|
|
2300
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2301
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2302
|
+
*
|
|
2303
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2183
2304
|
* @param frames - Number of frames to request (default: 1)
|
|
2184
2305
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2185
2306
|
*
|
|
@@ -2190,14 +2311,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2190
2311
|
* Advances the frameloop and runs render effects.
|
|
2191
2312
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2192
2313
|
*
|
|
2314
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2315
|
+
* registered root is stepped for backwards compatibility.
|
|
2316
|
+
*
|
|
2193
2317
|
* @param timestamp - The timestamp to use for this frame
|
|
2194
2318
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2195
|
-
* @param state -
|
|
2196
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2319
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2197
2320
|
*
|
|
2198
2321
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2199
2322
|
*/
|
|
2200
|
-
declare function advance(timestamp: number): void;
|
|
2323
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2201
2324
|
|
|
2202
2325
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2203
2326
|
declare function ReactReconciler<
|
|
@@ -3242,6 +3365,7 @@ declare namespace ReactReconciler {
|
|
|
3242
3365
|
|
|
3243
3366
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3244
3367
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3368
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3245
3369
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3246
3370
|
|
|
3247
3371
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3266,6 +3390,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
3266
3390
|
declare function flushSync<R>(fn: () => R): R;
|
|
3267
3391
|
|
|
3268
3392
|
declare const context: React$1.Context<RootStore>;
|
|
3393
|
+
|
|
3269
3394
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3270
3395
|
|
|
3271
3396
|
/**
|
|
@@ -3519,7 +3644,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
3519
3644
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
3520
3645
|
/**
|
|
3521
3646
|
* Triggers an update for an instance.
|
|
3522
|
-
*
|
|
3647
|
+
* Invalidates the frame if the root is in demand mode.
|
|
3523
3648
|
*
|
|
3524
3649
|
* @param instance - Instance to invalidate
|
|
3525
3650
|
*/
|
|
@@ -3685,29 +3810,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3685
3810
|
* Used to identify values that should be resolved from refs after mount.
|
|
3686
3811
|
*/
|
|
3687
3812
|
declare const FROM_REF: unique symbol;
|
|
3813
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3814
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3815
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3816
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3817
|
+
transform?: (value: T) => R;
|
|
3818
|
+
}
|
|
3688
3819
|
/**
|
|
3689
3820
|
* Defers prop application until the referenced object is available.
|
|
3690
3821
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3691
3822
|
*
|
|
3823
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3824
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3825
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3826
|
+
* what gets assigned.
|
|
3827
|
+
*
|
|
3692
3828
|
* @param ref - React ref object to resolve at mount time
|
|
3693
|
-
* @
|
|
3829
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3830
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3694
3831
|
*
|
|
3695
3832
|
* @example
|
|
3696
3833
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3697
3834
|
*
|
|
3698
3835
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3699
3836
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3837
|
+
*
|
|
3838
|
+
* @example
|
|
3839
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3840
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3700
3841
|
*/
|
|
3701
3842
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3843
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3702
3844
|
/**
|
|
3703
3845
|
* Type guard to check if a value is a fromRef marker.
|
|
3704
3846
|
*
|
|
3705
3847
|
* @param value - Value to check
|
|
3706
3848
|
* @returns True if value is a fromRef marker
|
|
3707
3849
|
*/
|
|
3708
|
-
declare function isFromRef(value: unknown): value is
|
|
3709
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3710
|
-
};
|
|
3850
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3711
3851
|
|
|
3712
3852
|
/**
|
|
3713
3853
|
* Symbol marker for mount-only method calls.
|
|
@@ -3734,7 +3874,15 @@ declare const ONCE: unique symbol;
|
|
|
3734
3874
|
* // No arguments
|
|
3735
3875
|
* <geometry center={once()} />
|
|
3736
3876
|
*/
|
|
3737
|
-
declare function once<
|
|
3877
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3878
|
+
/**
|
|
3879
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3880
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3881
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3882
|
+
*
|
|
3883
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3884
|
+
*/
|
|
3885
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3738
3886
|
/**
|
|
3739
3887
|
* Type guard to check if a value is a once marker.
|
|
3740
3888
|
*
|
|
@@ -3751,5 +3899,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
3751
3899
|
*/
|
|
3752
3900
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3753
3901
|
|
|
3754
|
-
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3755
|
-
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeProps, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|
|
3902
|
+
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, registerRootExtension, removeInteractivity, resolve, setRenderOverride, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3903
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, FromRefMarker, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootExtension, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|