@react-three/fiber 10.0.0-canary.76d2134 → 10.0.0-canary.777b94d
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 +629 -0
- package/dist/extension.d.mts +629 -0
- package/dist/extension.d.ts +629 -0
- package/dist/extension.mjs +258 -0
- package/dist/index.cjs +2803 -2706
- package/dist/index.d.cts +168 -322
- package/dist/index.d.mts +168 -322
- package/dist/index.d.ts +165 -347
- package/dist/index.mjs +2575 -2480
- package/dist/legacy.cjs +2558 -2462
- package/dist/legacy.d.cts +187 -374
- package/dist/legacy.d.mts +187 -374
- package/dist/legacy.d.ts +185 -398
- package/dist/legacy.mjs +2825 -2731
- package/dist/webgpu/index.cjs +2595 -3321
- package/dist/webgpu/index.d.cts +189 -713
- package/dist/webgpu/index.d.mts +189 -713
- package/dist/webgpu/index.d.ts +186 -738
- package/dist/webgpu/index.mjs +2592 -3302
- package/package.json +9 -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/webgpu/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
|
|
2
|
+
import * as webgpu from 'three/webgpu';
|
|
3
|
+
import { CubeRenderTarget, RenderTarget, WebGPURenderer, 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, WebGPURendererParameters } from 'three/webgpu';
|
|
3
4
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
4
5
|
import * as THREE$1 from 'three';
|
|
5
6
|
import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
@@ -11,23 +12,8 @@ import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFr
|
|
|
11
12
|
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
12
13
|
import { Options } from 'react-use-measure';
|
|
13
14
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
14
|
-
import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
|
|
15
15
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
16
16
|
|
|
17
|
-
function _mergeNamespaces(n, m) {
|
|
18
|
-
m.forEach(function (e) {
|
|
19
|
-
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
20
|
-
if (k !== 'default' && !(k in n)) {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return e[k]; }
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
return Object.freeze(n);
|
|
30
|
-
}
|
|
31
17
|
|
|
32
18
|
/**
|
|
33
19
|
* @fileoverview Internal Three.js re-exports - WEBGPU ONLY ENTRY
|
|
@@ -41,6 +27,8 @@ function _mergeNamespaces(n, m) {
|
|
|
41
27
|
declare const R3F_BUILD_LEGACY = false;
|
|
42
28
|
declare const R3F_BUILD_WEBGPU = true;
|
|
43
29
|
|
|
30
|
+
/** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
|
|
31
|
+
declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
|
|
44
32
|
declare const WebGLRenderer: {
|
|
45
33
|
new (): {};
|
|
46
34
|
};
|
|
@@ -51,19 +39,6 @@ declare const WebGLRenderTarget: any;
|
|
|
51
39
|
|
|
52
40
|
declare const WebGLCubeRenderTarget: any;
|
|
53
41
|
|
|
54
|
-
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
55
|
-
__proto__: null,
|
|
56
|
-
CubeRenderTargetCompat: CubeRenderTarget,
|
|
57
|
-
Inspector: Inspector,
|
|
58
|
-
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
59
|
-
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
60
|
-
RenderTargetCompat: RenderTarget,
|
|
61
|
-
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
62
|
-
WebGLRenderTarget: WebGLRenderTarget,
|
|
63
|
-
WebGLRenderer: WebGLRenderer,
|
|
64
|
-
WebGLRendererParameters: WebGLRendererParameters,
|
|
65
|
-
WebGLShadowMap: WebGLShadowMap
|
|
66
|
-
}, [three_webgpu]);
|
|
67
42
|
|
|
68
43
|
//* Utility Types ==============================
|
|
69
44
|
|
|
@@ -327,68 +302,6 @@ type FrameNextCallback = FrameCallback$1<RootState>
|
|
|
327
302
|
/** Alias for FrameNextCallback */
|
|
328
303
|
type FrameCallback = FrameNextCallback
|
|
329
304
|
|
|
330
|
-
//* Buffer Types (useBuffers) ========================================
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Buffer-like types for GPU compute and storage operations.
|
|
334
|
-
* Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* ```tsx
|
|
338
|
-
* const { positions, velocities } = useBuffers(() => ({
|
|
339
|
-
* positions: instancedArray(count, 'vec3'), // StorageBufferNode
|
|
340
|
-
* velocities: new Float32Array(count * 3), // TypedArray
|
|
341
|
-
* }), 'particles')
|
|
342
|
-
* ```
|
|
343
|
-
*/
|
|
344
|
-
type BufferLike =
|
|
345
|
-
| Float32Array
|
|
346
|
-
| Uint32Array
|
|
347
|
-
| Int32Array
|
|
348
|
-
| Float64Array
|
|
349
|
-
| Uint8Array
|
|
350
|
-
| Int8Array
|
|
351
|
-
| Uint16Array
|
|
352
|
-
| Int16Array
|
|
353
|
-
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
354
|
-
| Node // TSL buffer nodes (instancedArray, storage)
|
|
355
|
-
|
|
356
|
-
/** Flat record of buffer-like values (no nested scopes) */
|
|
357
|
-
type BufferRecord = Record<string, BufferLike>
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Buffer store that can contain both root-level buffers and scoped buffer objects.
|
|
361
|
-
* Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
|
|
362
|
-
*/
|
|
363
|
-
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
364
|
-
|
|
365
|
-
//* Storage Types (useGPUStorage) ========================================
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* GPU storage types for texture-based storage operations.
|
|
369
|
-
* Includes Three.js storage textures and TSL storage texture nodes.
|
|
370
|
-
*
|
|
371
|
-
* @example
|
|
372
|
-
* ```tsx
|
|
373
|
-
* const { heightMap } = useGPUStorage(() => ({
|
|
374
|
-
* heightMap: new StorageTexture(512, 512),
|
|
375
|
-
* }), 'terrain')
|
|
376
|
-
* ```
|
|
377
|
-
*/
|
|
378
|
-
type StorageLike =
|
|
379
|
-
| StorageTexture // GPU storage texture
|
|
380
|
-
| Data3DTexture // 3D texture (can be used as storage)
|
|
381
|
-
| Node // TSL storage texture nodes (storageTexture)
|
|
382
|
-
|
|
383
|
-
/** Flat record of storage-like values (no nested scopes) */
|
|
384
|
-
type StorageRecord = Record<string, StorageLike>
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Storage store that can contain both root-level storage and scoped storage objects.
|
|
388
|
-
* Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
|
|
389
|
-
*/
|
|
390
|
-
type StorageStore = Record<string, StorageLike | StorageRecord>
|
|
391
|
-
|
|
392
305
|
//* Renderer Types ========================================
|
|
393
306
|
|
|
394
307
|
/** Default renderer type - union of WebGL and WebGPU renderers */
|
|
@@ -488,6 +401,12 @@ interface InternalState {
|
|
|
488
401
|
actualRenderer: R3FRenderer
|
|
489
402
|
/** Global scheduler reference (for useFrame hook) */
|
|
490
403
|
scheduler: SchedulerApi | null
|
|
404
|
+
/**
|
|
405
|
+
* Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
|
|
406
|
+
* `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
|
|
407
|
+
* render-phase takeover. Used by `useRenderPipeline`.
|
|
408
|
+
*/
|
|
409
|
+
renderOverride?: (() => void) | null
|
|
491
410
|
/** This root's unique ID in the global scheduler */
|
|
492
411
|
rootId?: string
|
|
493
412
|
/** Function to unregister this root from the global scheduler */
|
|
@@ -495,11 +414,28 @@ interface InternalState {
|
|
|
495
414
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
496
415
|
container?: THREE$1.Object3D
|
|
497
416
|
/**
|
|
498
|
-
* CanvasTarget
|
|
499
|
-
*
|
|
417
|
+
* The CanvasTarget this root sizes and renders through.
|
|
418
|
+
*
|
|
419
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
420
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
421
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
422
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
423
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
500
424
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
501
425
|
*/
|
|
502
426
|
canvasTarget?: CanvasTarget
|
|
427
|
+
/**
|
|
428
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
429
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
430
|
+
*
|
|
431
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
432
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
433
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
434
|
+
* invalidate some other canvas's descriptor instead.
|
|
435
|
+
*
|
|
436
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
437
|
+
*/
|
|
438
|
+
canvasTargetSizeDirty?: boolean
|
|
503
439
|
/**
|
|
504
440
|
* Whether multi-canvas rendering is active.
|
|
505
441
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -538,12 +474,13 @@ interface RootState {
|
|
|
538
474
|
/** Get current state */
|
|
539
475
|
get: StoreApi<RootState>['getState']
|
|
540
476
|
/**
|
|
541
|
-
*
|
|
477
|
+
* The store of the canvas that owns this root's renderer.
|
|
542
478
|
* - For primary/independent canvases: points to its own store (self-reference)
|
|
543
479
|
* - For secondary canvases: points to the primary canvas's store
|
|
480
|
+
* - Portals copy it from their parent
|
|
544
481
|
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
482
|
+
* Anything shared per renderer rather than per canvas (e.g. @react-three/tsl's resources)
|
|
483
|
+
* resolves through it.
|
|
547
484
|
*/
|
|
548
485
|
primaryStore: RootStore
|
|
549
486
|
/** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
|
|
@@ -606,24 +543,10 @@ interface RootState {
|
|
|
606
543
|
setError: (error: Error | null) => void
|
|
607
544
|
/** Current error state (null when no error) */
|
|
608
545
|
error: Error | null
|
|
609
|
-
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
610
|
-
uniforms: UniformStore
|
|
611
|
-
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
612
|
-
nodes: Record<string, any>
|
|
613
|
-
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
614
|
-
buffers: BufferStore
|
|
615
|
-
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
616
|
-
gpuStorage: StorageStore
|
|
617
546
|
/** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
|
|
618
547
|
textures: Map<string, THREE$1.Texture>
|
|
619
548
|
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
620
549
|
_textureRefs: Map<string, number>
|
|
621
|
-
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
622
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
623
|
-
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
624
|
-
passes: Record<string, any>
|
|
625
|
-
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
626
|
-
_hmrVersion: number
|
|
627
550
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
628
551
|
_sizeImperative: boolean
|
|
629
552
|
/** Internal: stored size props from Canvas for reset functionality */
|
|
@@ -709,12 +632,19 @@ type DefaultRendererProps = {
|
|
|
709
632
|
*/
|
|
710
633
|
interface CanvasSchedulerConfig {
|
|
711
634
|
/**
|
|
712
|
-
*
|
|
713
|
-
* Pass the `id` of another canvas.
|
|
635
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
714
636
|
*/
|
|
715
|
-
|
|
637
|
+
before?: string | string[]
|
|
716
638
|
/**
|
|
717
|
-
*
|
|
639
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
640
|
+
*/
|
|
641
|
+
after?: string | string[]
|
|
642
|
+
/**
|
|
643
|
+
* Numeric root order. Lower values run first.
|
|
644
|
+
*/
|
|
645
|
+
order?: number
|
|
646
|
+
/**
|
|
647
|
+
* Limit this Canvas's default render job (frames per second).
|
|
718
648
|
*/
|
|
719
649
|
fps?: number
|
|
720
650
|
}
|
|
@@ -801,14 +731,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
801
731
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
802
732
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
803
733
|
dpr?: Dpr
|
|
804
|
-
/**
|
|
805
|
-
|
|
734
|
+
/**
|
|
735
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
736
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
737
|
+
*/
|
|
738
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
806
739
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
807
740
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
808
741
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
809
742
|
camera?: CameraProps
|
|
810
743
|
/** An R3F event manager to manage elements' pointer events */
|
|
811
|
-
events?: (store: RootStore) => EventManager<
|
|
744
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
812
745
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
813
746
|
onCreated?: (state: RootState) => void
|
|
814
747
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -897,7 +830,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
897
830
|
object?: T
|
|
898
831
|
dispose?: null
|
|
899
832
|
attach?: AttachType<T>
|
|
900
|
-
onUpdate?: (self: T) => void
|
|
901
833
|
}
|
|
902
834
|
|
|
903
835
|
interface Instance<O = any> {
|
|
@@ -1037,7 +969,7 @@ interface CanvasProps
|
|
|
1037
969
|
*/
|
|
1038
970
|
resize?: Options
|
|
1039
971
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1040
|
-
eventSource?:
|
|
972
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1041
973
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1042
974
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1043
975
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1145,202 +1077,6 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1145
1077
|
|
|
1146
1078
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1147
1079
|
|
|
1148
|
-
//* Global Types ==============================
|
|
1149
|
-
|
|
1150
|
-
declare global {
|
|
1151
|
-
/**
|
|
1152
|
-
* Uniform node type.
|
|
1153
|
-
*
|
|
1154
|
-
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1155
|
-
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1156
|
-
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1157
|
-
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1158
|
-
* arity when three made `UniformNode` two-parameter.
|
|
1159
|
-
*
|
|
1160
|
-
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1161
|
-
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1162
|
-
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1163
|
-
* installed three instead of needing to be mirrored by hand.
|
|
1164
|
-
*/
|
|
1165
|
-
type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
|
|
1166
|
-
|
|
1167
|
-
/**
|
|
1168
|
-
* ShaderCallable - the return type of Fn()
|
|
1169
|
-
* A callable shader function node that can be invoked with parameters.
|
|
1170
|
-
* The function returns a ShaderNodeObject when called.
|
|
1171
|
-
*
|
|
1172
|
-
* @example
|
|
1173
|
-
* ```tsx
|
|
1174
|
-
* // Define a shader function
|
|
1175
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1176
|
-
* return mix(color1, color2, factor)
|
|
1177
|
-
* })
|
|
1178
|
-
*
|
|
1179
|
-
* // Type when retrieving from nodes store
|
|
1180
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1181
|
-
*
|
|
1182
|
-
* // Or with specific return type
|
|
1183
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1184
|
-
* ```
|
|
1185
|
-
*/
|
|
1186
|
-
type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
|
|
1187
|
-
|
|
1188
|
-
/**
|
|
1189
|
-
* ShaderNodeRef - a ShaderNodeObject wrapper around a Node
|
|
1190
|
-
* This is the common return type for TSL operations (add, mul, sin, etc.)
|
|
1191
|
-
*
|
|
1192
|
-
* @example
|
|
1193
|
-
* ```tsx
|
|
1194
|
-
* const { wobble } = nodes as { wobble: ShaderNodeRef }
|
|
1195
|
-
* ```
|
|
1196
|
-
*/
|
|
1197
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1198
|
-
|
|
1199
|
-
/**
|
|
1200
|
-
* TSLNodeType - Union of all common TSL node types
|
|
1201
|
-
* Used by ScopedStore to properly type node access from the store.
|
|
1202
|
-
*
|
|
1203
|
-
* Includes:
|
|
1204
|
-
* - Node: base Three.js node type
|
|
1205
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1206
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1207
|
-
*
|
|
1208
|
-
* @example
|
|
1209
|
-
* ```tsx
|
|
1210
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1211
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1212
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1213
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1214
|
-
* }))
|
|
1215
|
-
*
|
|
1216
|
-
* // Can narrow with type guard or assertion when needed
|
|
1217
|
-
* if (typeof blendColorFn === 'function') {
|
|
1218
|
-
* blendColorFn(someColor, 0.5)
|
|
1219
|
-
* }
|
|
1220
|
-
* ```
|
|
1221
|
-
*/
|
|
1222
|
-
type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
|
|
1223
|
-
|
|
1224
|
-
/** Flat record of uniform nodes (no nested scopes) */
|
|
1225
|
-
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
1226
|
-
|
|
1227
|
-
/**
|
|
1228
|
-
* Uniform store that can contain both root-level uniforms and scoped uniform objects
|
|
1229
|
-
* Used by state.uniforms which has structure like:
|
|
1230
|
-
* { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
|
|
1231
|
-
*/
|
|
1232
|
-
type UniformStore = Record<string, UniformNode | UniformRecord>
|
|
1233
|
-
|
|
1234
|
-
/**
|
|
1235
|
-
* Helper to safely access a uniform node from the store.
|
|
1236
|
-
* Use this when accessing state.uniforms to get proper typing.
|
|
1237
|
-
* @example
|
|
1238
|
-
* const uTime = uniforms.uTime as UniformNode<number>
|
|
1239
|
-
* const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
|
|
1240
|
-
*/
|
|
1241
|
-
type GetUniform<T = unknown> = UniformNode<T>
|
|
1242
|
-
|
|
1243
|
-
/**
|
|
1244
|
-
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1245
|
-
* Supports:
|
|
1246
|
-
* - Primitives: number, string (color), boolean
|
|
1247
|
-
* - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
|
|
1248
|
-
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1249
|
-
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1250
|
-
* - UniformNode: existing uniforms (reused as-is)
|
|
1251
|
-
*/
|
|
1252
|
-
type UniformValue =
|
|
1253
|
-
| number
|
|
1254
|
-
| string
|
|
1255
|
-
| boolean
|
|
1256
|
-
| three_webgpu.Color
|
|
1257
|
-
| three_webgpu.Vector2
|
|
1258
|
-
| three_webgpu.Vector3
|
|
1259
|
-
| three_webgpu.Vector4
|
|
1260
|
-
| three_webgpu.Matrix3
|
|
1261
|
-
| three_webgpu.Matrix4
|
|
1262
|
-
| three_webgpu.Euler
|
|
1263
|
-
| three_webgpu.Quaternion
|
|
1264
|
-
| { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
|
|
1265
|
-
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1266
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1267
|
-
| UniformNode
|
|
1268
|
-
|
|
1269
|
-
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1270
|
-
type UniformInputRecord = Record<string, UniformValue>
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
//* Module Augmentation ==============================
|
|
1274
|
-
|
|
1275
|
-
declare module 'three/tsl' {
|
|
1276
|
-
/**
|
|
1277
|
-
* Fn with array parameter destructuring
|
|
1278
|
-
* @example Fn(([uv, skew]) => { ... })
|
|
1279
|
-
*/
|
|
1280
|
-
export function Fn<R extends Node = Node>(
|
|
1281
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1282
|
-
): ShaderCallable<R>
|
|
1283
|
-
|
|
1284
|
-
/**
|
|
1285
|
-
* Fn with object parameter destructuring
|
|
1286
|
-
* @example Fn(({ color, intensity }) => { ... })
|
|
1287
|
-
*/
|
|
1288
|
-
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1289
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1290
|
-
): ShaderCallable<R>
|
|
1291
|
-
|
|
1292
|
-
/**
|
|
1293
|
-
* Fn with array params + layout
|
|
1294
|
-
* @example Fn(([a, b]) => { ... }, { layout: [...] })
|
|
1295
|
-
*/
|
|
1296
|
-
export function Fn<R extends Node = Node>(
|
|
1297
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1298
|
-
layout: { layout?: unknown },
|
|
1299
|
-
): ShaderCallable<R>
|
|
1300
|
-
|
|
1301
|
-
/**
|
|
1302
|
-
* Fn with object params + layout
|
|
1303
|
-
*/
|
|
1304
|
-
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1305
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1306
|
-
layout: { layout?: unknown },
|
|
1307
|
-
): ShaderCallable<R>
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
declare global {
|
|
1311
|
-
/**
|
|
1312
|
-
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1313
|
-
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1314
|
-
* is r185, so the new name is the only one.
|
|
1315
|
-
*/
|
|
1316
|
-
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1317
|
-
|
|
1318
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1319
|
-
type PassRecord = Record<string, any>
|
|
1320
|
-
|
|
1321
|
-
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1322
|
-
type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
|
|
1323
|
-
|
|
1324
|
-
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1325
|
-
type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
|
|
1326
|
-
|
|
1327
|
-
/** Return type for useRenderPipeline hook */
|
|
1328
|
-
interface UseRenderPipelineReturn {
|
|
1329
|
-
/** Current passes from state */
|
|
1330
|
-
passes: PassRecord
|
|
1331
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1332
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1333
|
-
/** Clear all passes from state */
|
|
1334
|
-
clearPasses: () => void
|
|
1335
|
-
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1336
|
-
reset: () => void
|
|
1337
|
-
/** Re-run setup/main callbacks with current closure values */
|
|
1338
|
-
rebuild: () => void
|
|
1339
|
-
/** True when RenderPipeline is configured and ready */
|
|
1340
|
-
isReady: boolean
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
1080
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
1345
1081
|
|
|
1346
1082
|
interface MathRepresentation {
|
|
@@ -1417,10 +1153,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1417
1153
|
|
|
1418
1154
|
/**
|
|
1419
1155
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1420
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1156
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1157
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1421
1158
|
*/
|
|
1422
1159
|
type NodeProps<P> = {
|
|
1423
|
-
[K in keyof P as P[K] extends
|
|
1160
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1424
1161
|
}
|
|
1425
1162
|
|
|
1426
1163
|
interface ReactProps<P> {
|
|
@@ -1441,11 +1178,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1441
1178
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1442
1179
|
}
|
|
1443
1180
|
|
|
1181
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1182
|
+
type Object3DMethod = NonNullable<
|
|
1183
|
+
{
|
|
1184
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1185
|
+
}[keyof Object3D]
|
|
1186
|
+
>
|
|
1187
|
+
|
|
1444
1188
|
type ThreeExports = typeof import('three/webgpu')
|
|
1445
1189
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1446
1190
|
|
|
1447
1191
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1448
|
-
|
|
1192
|
+
/**
|
|
1193
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1194
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1195
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1196
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1197
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1198
|
+
*/
|
|
1199
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1200
|
+
object: object
|
|
1201
|
+
ref?: React.Ref<any>
|
|
1202
|
+
[prop: string]: unknown
|
|
1203
|
+
}
|
|
1449
1204
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1450
1205
|
threeAudio: ThreeElementsImpl['audio']
|
|
1451
1206
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1486,6 +1241,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1486
1241
|
type three_d_Matrix4 = Matrix4;
|
|
1487
1242
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1488
1243
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1244
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1489
1245
|
type three_d_Quaternion = Quaternion;
|
|
1490
1246
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1491
1247
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1500,7 +1256,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1500
1256
|
type three_d_Vector4 = Vector4;
|
|
1501
1257
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1502
1258
|
declare namespace three_d {
|
|
1503
|
-
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 };
|
|
1259
|
+
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 };
|
|
1504
1260
|
}
|
|
1505
1261
|
|
|
1506
1262
|
/**
|
|
@@ -1638,9 +1394,9 @@ type EnvironmentProps = {
|
|
|
1638
1394
|
blur?: number;
|
|
1639
1395
|
backgroundBlurriness?: number;
|
|
1640
1396
|
backgroundIntensity?: number;
|
|
1641
|
-
backgroundRotation?: Euler
|
|
1397
|
+
backgroundRotation?: Euler;
|
|
1642
1398
|
environmentIntensity?: number;
|
|
1643
|
-
environmentRotation?: Euler
|
|
1399
|
+
environmentRotation?: Euler;
|
|
1644
1400
|
map?: Texture$1;
|
|
1645
1401
|
preset?: PresetsType;
|
|
1646
1402
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -1724,7 +1480,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
1724
1480
|
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;
|
|
1725
1481
|
declare module '@react-three/fiber' {
|
|
1726
1482
|
interface ThreeElements {
|
|
1727
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1483
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
1728
1484
|
}
|
|
1729
1485
|
}
|
|
1730
1486
|
/**
|
|
@@ -1849,7 +1605,43 @@ declare function createEvents(store: RootStore): {
|
|
|
1849
1605
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1850
1606
|
};
|
|
1851
1607
|
/** Default R3F event manager for web */
|
|
1852
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1608
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1609
|
+
|
|
1610
|
+
interface RootExtension {
|
|
1611
|
+
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
1612
|
+
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
1613
|
+
name: string;
|
|
1614
|
+
/**
|
|
1615
|
+
* Called once per root, after its renderer exists and before `onCreated` and the first frame.
|
|
1616
|
+
* `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
|
|
1617
|
+
* to the primary canvas. Return fields to merge into the root's state, or nothing.
|
|
1618
|
+
*/
|
|
1619
|
+
setup?(store: RootStore): Partial<RootState> | void;
|
|
1620
|
+
/** Called when a root this extension set up unmounts. */
|
|
1621
|
+
dispose?(store: RootStore): void;
|
|
1622
|
+
/** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
|
|
1623
|
+
hmr?(store: RootStore): void;
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Register an extension. It is set up on every live root immediately, and on every root created
|
|
1627
|
+
* afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
|
|
1628
|
+
* it already set up keep its state and still get its dispose when they unmount.
|
|
1629
|
+
*/
|
|
1630
|
+
declare function registerRootExtension(extension: RootExtension): () => void;
|
|
1631
|
+
/**
|
|
1632
|
+
* Point a root's default render job at a different render function, or back at
|
|
1633
|
+
* `renderer.render(scene, camera)` with `null`.
|
|
1634
|
+
*
|
|
1635
|
+
* The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
|
|
1636
|
+
* boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
|
|
1637
|
+
*/
|
|
1638
|
+
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
1639
|
+
|
|
1640
|
+
/**
|
|
1641
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
1642
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
1643
|
+
*/
|
|
1644
|
+
declare function useStore(): RootStore;
|
|
1853
1645
|
|
|
1854
1646
|
/**
|
|
1855
1647
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -1869,50 +1661,6 @@ declare namespace useLoader {
|
|
|
1869
1661
|
var loader: typeof getLoader;
|
|
1870
1662
|
}
|
|
1871
1663
|
|
|
1872
|
-
/**
|
|
1873
|
-
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
1874
|
-
*
|
|
1875
|
-
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1876
|
-
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1877
|
-
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1878
|
-
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1879
|
-
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
1880
|
-
*
|
|
1881
|
-
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
1882
|
-
*
|
|
1883
|
-
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1884
|
-
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1885
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1886
|
-
*
|
|
1887
|
-
* @example
|
|
1888
|
-
* // Simple priority (backwards compat)
|
|
1889
|
-
* useFrame((state, delta) => { ... }, 5)
|
|
1890
|
-
*
|
|
1891
|
-
* @example
|
|
1892
|
-
* // With phase-based ordering
|
|
1893
|
-
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
1894
|
-
*
|
|
1895
|
-
* @example
|
|
1896
|
-
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
1897
|
-
* function UI() {
|
|
1898
|
-
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
1899
|
-
* return <button>...</button>;
|
|
1900
|
-
* }
|
|
1901
|
-
*
|
|
1902
|
-
* @example
|
|
1903
|
-
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
1904
|
-
* import { getScheduler } from '@pmndrs/scheduler'
|
|
1905
|
-
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
1906
|
-
*
|
|
1907
|
-
* @example
|
|
1908
|
-
* // Scheduler-only access (no callback)
|
|
1909
|
-
* const { scheduler } = useFrame()
|
|
1910
|
-
* scheduler.pauseJob('some-job-id')
|
|
1911
|
-
*
|
|
1912
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1913
|
-
*/
|
|
1914
|
-
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
1915
|
-
|
|
1916
1664
|
declare const IsObject: (url: unknown) => url is Record<string, string>;
|
|
1917
1665
|
type TextureArray<T> = T extends string[] ? Texture$1[] : never;
|
|
1918
1666
|
type TextureRecord<T> = T extends Record<string, string> ? {
|
|
@@ -2093,16 +1841,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
|
|
|
2093
1841
|
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
|
|
2094
1842
|
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
|
|
2095
1843
|
|
|
2096
|
-
/**
|
|
2097
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2098
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2099
|
-
*/
|
|
2100
|
-
declare function useStore(): RootStore;
|
|
2101
|
-
/**
|
|
2102
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2103
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2104
|
-
*/
|
|
2105
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2106
1844
|
/**
|
|
2107
1845
|
* Exposes an object's {@link Instance}.
|
|
2108
1846
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2178,7 +1916,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2178
1916
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2179
1917
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2180
1918
|
*
|
|
2181
|
-
*
|
|
1919
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
1920
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
1921
|
+
*
|
|
1922
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2182
1923
|
* @param frames - Number of frames to request (default: 1)
|
|
2183
1924
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2184
1925
|
*
|
|
@@ -2189,14 +1930,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2189
1930
|
* Advances the frameloop and runs render effects.
|
|
2190
1931
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2191
1932
|
*
|
|
1933
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
1934
|
+
* registered root is stepped for backwards compatibility.
|
|
1935
|
+
*
|
|
2192
1936
|
* @param timestamp - The timestamp to use for this frame
|
|
2193
1937
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2194
|
-
* @param state -
|
|
2195
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
1938
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2196
1939
|
*
|
|
2197
1940
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2198
1941
|
*/
|
|
2199
|
-
declare function advance(timestamp: number): void;
|
|
1942
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2200
1943
|
|
|
2201
1944
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2202
1945
|
declare function ReactReconciler<
|
|
@@ -3241,6 +2984,7 @@ declare namespace ReactReconciler {
|
|
|
3241
2984
|
|
|
3242
2985
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3243
2986
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
2987
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3244
2988
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3245
2989
|
|
|
3246
2990
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3265,6 +3009,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
3265
3009
|
declare function flushSync<R>(fn: () => R): R;
|
|
3266
3010
|
|
|
3267
3011
|
declare const context: React$1.Context<RootStore>;
|
|
3012
|
+
|
|
3268
3013
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3269
3014
|
|
|
3270
3015
|
/**
|
|
@@ -3518,7 +3263,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
3518
3263
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
3519
3264
|
/**
|
|
3520
3265
|
* Triggers an update for an instance.
|
|
3521
|
-
*
|
|
3266
|
+
* Invalidates the frame if the root is in demand mode.
|
|
3522
3267
|
*
|
|
3523
3268
|
* @param instance - Instance to invalidate
|
|
3524
3269
|
*/
|
|
@@ -3684,29 +3429,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3684
3429
|
* Used to identify values that should be resolved from refs after mount.
|
|
3685
3430
|
*/
|
|
3686
3431
|
declare const FROM_REF: unique symbol;
|
|
3432
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3433
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3434
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3435
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3436
|
+
transform?: (value: T) => R;
|
|
3437
|
+
}
|
|
3687
3438
|
/**
|
|
3688
3439
|
* Defers prop application until the referenced object is available.
|
|
3689
3440
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3690
3441
|
*
|
|
3442
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3443
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3444
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3445
|
+
* what gets assigned.
|
|
3446
|
+
*
|
|
3691
3447
|
* @param ref - React ref object to resolve at mount time
|
|
3692
|
-
* @
|
|
3448
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3449
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3693
3450
|
*
|
|
3694
3451
|
* @example
|
|
3695
3452
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3696
3453
|
*
|
|
3697
3454
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3698
3455
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3456
|
+
*
|
|
3457
|
+
* @example
|
|
3458
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3459
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3699
3460
|
*/
|
|
3700
3461
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3462
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3701
3463
|
/**
|
|
3702
3464
|
* Type guard to check if a value is a fromRef marker.
|
|
3703
3465
|
*
|
|
3704
3466
|
* @param value - Value to check
|
|
3705
3467
|
* @returns True if value is a fromRef marker
|
|
3706
3468
|
*/
|
|
3707
|
-
declare function isFromRef(value: unknown): value is
|
|
3708
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3709
|
-
};
|
|
3469
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3710
3470
|
|
|
3711
3471
|
/**
|
|
3712
3472
|
* Symbol marker for mount-only method calls.
|
|
@@ -3733,7 +3493,15 @@ declare const ONCE: unique symbol;
|
|
|
3733
3493
|
* // No arguments
|
|
3734
3494
|
* <geometry center={once()} />
|
|
3735
3495
|
*/
|
|
3736
|
-
declare function once<
|
|
3496
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3497
|
+
/**
|
|
3498
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3499
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3500
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3501
|
+
*
|
|
3502
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3503
|
+
*/
|
|
3504
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3737
3505
|
/**
|
|
3738
3506
|
* Type guard to check if a value is a once marker.
|
|
3739
3507
|
*
|
|
@@ -3744,315 +3512,6 @@ declare function isOnce(value: unknown): value is {
|
|
|
3744
3512
|
[ONCE]: any[] | true;
|
|
3745
3513
|
};
|
|
3746
3514
|
|
|
3747
|
-
/**
|
|
3748
|
-
* A DOM canvas which accepts threejs elements as children.
|
|
3749
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
3750
|
-
*/
|
|
3751
|
-
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3752
|
-
|
|
3753
|
-
/**
|
|
3754
|
-
* ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
|
|
3755
|
-
*
|
|
3756
|
-
* Provides TypeScript-friendly access to uniform/node stores where the runtime
|
|
3757
|
-
* structure is `Record<string, T | Record<string, T>>` (leaf nodes or nested scopes).
|
|
3758
|
-
*
|
|
3759
|
-
* The wrapper uses a Proxy to:
|
|
3760
|
-
* 1. Return `T` for property access (type assumption: assumes leaf node)
|
|
3761
|
-
* 2. Provide `.scope(key)` method for explicit nested access
|
|
3762
|
-
* 3. Support iteration methods: has(), keys(), Object.keys(), for...in
|
|
3763
|
-
*
|
|
3764
|
-
* @example
|
|
3765
|
-
* ```tsx
|
|
3766
|
-
* useLocalNodes(({ uniforms }) => ({
|
|
3767
|
-
* wobble: sin(uniforms.uTime.mul(2)), // No cast needed!
|
|
3768
|
-
* playerHealth: uniforms.scope('player').uHealth // Explicit scope access
|
|
3769
|
-
* }))
|
|
3770
|
-
* ```
|
|
3771
|
-
*/
|
|
3772
|
-
|
|
3773
|
-
/** Keys reserved for methods (excluded from index signature) */
|
|
3774
|
-
type MethodKeys = 'scope' | 'has' | 'keys';
|
|
3775
|
-
/**
|
|
3776
|
-
* Type-safe wrapper interface for accessing nested store data.
|
|
3777
|
-
* Property access returns `T` (assumes leaf node).
|
|
3778
|
-
* Use `.scope(key)` for nested object access.
|
|
3779
|
-
*
|
|
3780
|
-
* Uses mapped type with key filtering to exclude method names from index signature,
|
|
3781
|
-
* allowing methods to have their correct return types.
|
|
3782
|
-
*/
|
|
3783
|
-
type ScopedStoreType<T> = {
|
|
3784
|
-
/** Direct property access returns the leaf type T (method keys excluded) */
|
|
3785
|
-
readonly [K in string as K extends MethodKeys ? never : K]: T;
|
|
3786
|
-
} & {
|
|
3787
|
-
/** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
|
|
3788
|
-
scope(key: string): ScopedStoreType<T>;
|
|
3789
|
-
/** Check if a key exists in the store */
|
|
3790
|
-
has(key: string): boolean;
|
|
3791
|
-
/** Get all keys in the store */
|
|
3792
|
-
keys(): string[];
|
|
3793
|
-
};
|
|
3794
|
-
/**
|
|
3795
|
-
* Create a type-safe ScopedStore wrapper around store data.
|
|
3796
|
-
* @param data - The raw store data (uniforms or nodes from RootState)
|
|
3797
|
-
* @returns A ScopedStoreType wrapper with type-safe access
|
|
3798
|
-
*/
|
|
3799
|
-
declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreType<T>;
|
|
3800
|
-
/**
|
|
3801
|
-
* State type passed to creator functions with ScopedStore wrappers.
|
|
3802
|
-
* Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
|
|
3803
|
-
*/
|
|
3804
|
-
type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
|
|
3805
|
-
/** Type-safe uniform access - property access returns UniformNode */
|
|
3806
|
-
uniforms: ScopedStoreType<UniformNode>;
|
|
3807
|
-
/** Type-safe node access - property access returns TSLNodeType (Node | ShaderCallable | ShaderNodeObject) */
|
|
3808
|
-
nodes: ScopedStoreType<TSLNodeType>;
|
|
3809
|
-
/** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
|
|
3810
|
-
buffers: ScopedStoreType<BufferLike>;
|
|
3811
|
-
/** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
|
|
3812
|
-
gpuStorage: ScopedStoreType<StorageLike>;
|
|
3813
|
-
};
|
|
3814
|
-
|
|
3815
|
-
/** Creator function that returns uniform inputs (can be raw values or UniformNodes) */
|
|
3816
|
-
type UniformCreator<T extends UniformInputRecord = UniformInputRecord> = (state: CreatorState) => T;
|
|
3817
|
-
/** Function signature for removeUniforms util */
|
|
3818
|
-
type RemoveUniformsFn = (names: string | string[], scope?: string) => void;
|
|
3819
|
-
/** Function signature for clearUniforms util */
|
|
3820
|
-
type ClearUniformsFn = (scope?: string) => void;
|
|
3821
|
-
/** Function signature for rebuildUniforms util */
|
|
3822
|
-
type RebuildUniformsFn = (scope?: string) => void;
|
|
3823
|
-
/** Return type with utils included */
|
|
3824
|
-
type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
|
|
3825
|
-
removeUniforms: RemoveUniformsFn;
|
|
3826
|
-
clearUniforms: ClearUniformsFn;
|
|
3827
|
-
rebuildUniforms: RebuildUniformsFn;
|
|
3828
|
-
};
|
|
3829
|
-
declare function useUniforms(): UniformsWithUtils<UniformRecord & Record<string, UniformRecord>>;
|
|
3830
|
-
declare function useUniforms(scope: string): UniformsWithUtils;
|
|
3831
|
-
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3832
|
-
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3833
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3834
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3835
|
-
/**
|
|
3836
|
-
* Global rebuildUniforms function for HMR integration.
|
|
3837
|
-
* Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
|
|
3838
|
-
* Call this when HMR is detected to refresh all uniform creators.
|
|
3839
|
-
*
|
|
3840
|
-
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3841
|
-
* authoritative store.
|
|
3842
|
-
*
|
|
3843
|
-
* @param store - The R3F store (from useStore or context)
|
|
3844
|
-
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
3845
|
-
*/
|
|
3846
|
-
declare function rebuildAllUniforms(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
3847
|
-
/**
|
|
3848
|
-
* Remove uniforms by name from root level or a scope
|
|
3849
|
-
* @deprecated Use `const { removeUniforms } = useUniforms()` instead
|
|
3850
|
-
*/
|
|
3851
|
-
declare function removeUniforms(set: ReturnType<typeof useStore>['setState'], names: string[], scope?: string): void;
|
|
3852
|
-
/**
|
|
3853
|
-
* Clear all uniforms from a scope (removes the entire scope object)
|
|
3854
|
-
* @deprecated Use `const { clearUniforms } = useUniforms()` instead
|
|
3855
|
-
*/
|
|
3856
|
-
declare function clearScope(set: ReturnType<typeof useStore>['setState'], scope: string): void;
|
|
3857
|
-
/**
|
|
3858
|
-
* Clear all root-level uniforms (preserves scopes)
|
|
3859
|
-
* @deprecated Use `const { clearUniforms } = useUniforms()` with `clearUniforms('root')` instead
|
|
3860
|
-
*/
|
|
3861
|
-
declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState']): void;
|
|
3862
|
-
|
|
3863
|
-
/**
|
|
3864
|
-
* Supported uniform value types:
|
|
3865
|
-
* - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
|
|
3866
|
-
* - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
|
|
3867
|
-
* - TSL nodes: color(), vec3(), float(), etc. (for type casting)
|
|
3868
|
-
* - UniformNode: existing uniforms (reused as-is)
|
|
3869
|
-
*/
|
|
3870
|
-
type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
|
|
3871
|
-
/**
|
|
3872
|
-
* Widen literal types to their base types:
|
|
3873
|
-
* - 0 → number
|
|
3874
|
-
* - true → boolean
|
|
3875
|
-
* - '#ff0000' → Color (string colors are converted to Color objects)
|
|
3876
|
-
* - Node → Node (TSL nodes passed through for uniform type casting)
|
|
3877
|
-
*/
|
|
3878
|
-
type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
|
|
3879
|
-
declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
|
|
3880
|
-
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
|
|
3881
|
-
|
|
3882
|
-
/**
|
|
3883
|
-
* Minimal interface for TSL nodes.
|
|
3884
|
-
* Used instead of Three.js's Node type because the @types/three definitions
|
|
3885
|
-
* have inconsistencies where OperatorNode, ConstNode, etc. don't properly
|
|
3886
|
-
* extend Node with all required properties.
|
|
3887
|
-
*/
|
|
3888
|
-
interface TSLNodeLike {
|
|
3889
|
-
uuid?: string;
|
|
3890
|
-
nodeType?: string | null;
|
|
3891
|
-
/** label method for chaining - sets the node's label and returns self */
|
|
3892
|
-
label?: ((label: string) => TSLNodeLike) | string;
|
|
3893
|
-
setName?: (name: string) => this;
|
|
3894
|
-
}
|
|
3895
|
-
/** TSL node type - alias for compatibility */
|
|
3896
|
-
type TSLNode = TSLNodeLike;
|
|
3897
|
-
/**
|
|
3898
|
-
* A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
|
|
3899
|
-
* Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
|
|
3900
|
-
*/
|
|
3901
|
-
type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
|
|
3902
|
-
/**
|
|
3903
|
-
* Creator function that returns a record of nodes.
|
|
3904
|
-
* Uses TSLNodeLike constraint to allow mixed node types
|
|
3905
|
-
* (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
|
|
3906
|
-
*/
|
|
3907
|
-
type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
|
|
3908
|
-
/** Function signature for removeNodes util */
|
|
3909
|
-
type RemoveNodesFn = (names: string | string[], scope?: string) => void;
|
|
3910
|
-
/** Function signature for clearNodes util */
|
|
3911
|
-
type ClearNodesFn = (scope?: string) => void;
|
|
3912
|
-
/** Function signature for rebuildNodes util */
|
|
3913
|
-
type RebuildNodesFn = (scope?: string) => void;
|
|
3914
|
-
/** Return type with utils included */
|
|
3915
|
-
type NodesWithUtils<T extends Record<string, TSLNodeLike> = Record<string, TSLNodeLike>> = T & {
|
|
3916
|
-
removeNodes: RemoveNodesFn;
|
|
3917
|
-
clearNodes: ClearNodesFn;
|
|
3918
|
-
rebuildNodes: RebuildNodesFn;
|
|
3919
|
-
};
|
|
3920
|
-
declare function useNodes(): NodesWithUtils<Record<string, TSLNodeLike> & Record<string, Record<string, TSLNodeLike>>>;
|
|
3921
|
-
declare function useNodes(scope: string): NodesWithUtils<Record<string, TSLNodeLike>>;
|
|
3922
|
-
declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>): NodesWithUtils<T>;
|
|
3923
|
-
declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
|
|
3924
|
-
/**
|
|
3925
|
-
* Global rebuildNodes function for HMR integration.
|
|
3926
|
-
* Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
|
|
3927
|
-
* Call this when HMR is detected to refresh all node creators.
|
|
3928
|
-
*
|
|
3929
|
-
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3930
|
-
* authoritative store.
|
|
3931
|
-
*
|
|
3932
|
-
* @param store - The R3F store (from useStore or context)
|
|
3933
|
-
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
3934
|
-
*/
|
|
3935
|
-
declare function rebuildAllNodes(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
3936
|
-
/**
|
|
3937
|
-
* Remove nodes by name from root level or a scope
|
|
3938
|
-
* @deprecated Use `const { removeNodes } = useNodes()` instead
|
|
3939
|
-
*/
|
|
3940
|
-
declare function removeNodes(set: ReturnType<typeof useStore>['setState'], names: string[], scope?: string): void;
|
|
3941
|
-
/**
|
|
3942
|
-
* Clear all nodes from a scope (removes the entire scope object)
|
|
3943
|
-
* @deprecated Use `const { clearNodes } = useNodes()` instead
|
|
3944
|
-
*/
|
|
3945
|
-
declare function clearNodeScope(set: ReturnType<typeof useStore>['setState'], scope: string): void;
|
|
3946
|
-
/**
|
|
3947
|
-
* Clear all root-level nodes (preserves scopes)
|
|
3948
|
-
* @deprecated Use `const { clearNodes } = useNodes()` with `clearNodes('root')` instead
|
|
3949
|
-
*/
|
|
3950
|
-
declare function clearRootNodes(set: ReturnType<typeof useStore>['setState']): void;
|
|
3951
|
-
|
|
3952
|
-
/** Creator receives CreatorState with ScopedStore wrappers for type-safe access. Returns any record. */
|
|
3953
|
-
type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState) => T;
|
|
3954
|
-
/**
|
|
3955
|
-
* Creates local values that rebuild when uniforms, nodes, or textures change.
|
|
3956
|
-
*
|
|
3957
|
-
* Unlike `useNodes`, this does NOT register to the global store.
|
|
3958
|
-
* Use for component-specific nodes/values that depend on shared resources.
|
|
3959
|
-
*
|
|
3960
|
-
* @example
|
|
3961
|
-
* ```tsx
|
|
3962
|
-
* // Destructure what you need from state
|
|
3963
|
-
* const { wobble, uTime } = useLocalNodes(({ uniforms, nodes }) => ({
|
|
3964
|
-
* wobble: sin(uniforms.uTime.mul(2)),
|
|
3965
|
-
* uTime: uniforms.uTime, // can return uniforms too
|
|
3966
|
-
* }))
|
|
3967
|
-
*
|
|
3968
|
-
* // Or access anything else from RootState
|
|
3969
|
-
* const { scaled } = useLocalNodes(({ camera, nodes }) => ({
|
|
3970
|
-
* scaled: nodes.basePos.mul(camera.zoom),
|
|
3971
|
-
* }))
|
|
3972
|
-
*
|
|
3973
|
-
* // Type-safe uniform access
|
|
3974
|
-
* const { colorNode } = useLocalNodes(({ uniforms }) => {
|
|
3975
|
-
* const uValue = uniforms.myUniform as UniformNode<number>
|
|
3976
|
-
* return { colorNode: mix(colorA, colorB, uValue) }
|
|
3977
|
-
* })
|
|
3978
|
-
* ```
|
|
3979
|
-
*/
|
|
3980
|
-
declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
|
|
3981
|
-
|
|
3982
|
-
/**
|
|
3983
|
-
* Creator function that returns a record of buffers.
|
|
3984
|
-
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
3985
|
-
*/
|
|
3986
|
-
type BufferCreator<T extends Record<string, BufferLike>> = (state: CreatorState) => T;
|
|
3987
|
-
/** Function signature for removeBuffers util */
|
|
3988
|
-
type RemoveBuffersFn = (names: string | string[], scope?: string) => void;
|
|
3989
|
-
/** Function signature for clearBuffers util */
|
|
3990
|
-
type ClearBuffersFn = (scope?: string) => void;
|
|
3991
|
-
/** Function signature for rebuildBuffers util */
|
|
3992
|
-
type RebuildBuffersFn = (scope?: string) => void;
|
|
3993
|
-
/** Function signature for disposeBuffers util - releases GPU resources */
|
|
3994
|
-
type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
|
|
3995
|
-
/** Return type with utils included */
|
|
3996
|
-
type BuffersWithUtils<T extends Record<string, BufferLike> = Record<string, BufferLike>> = T & {
|
|
3997
|
-
removeBuffers: RemoveBuffersFn;
|
|
3998
|
-
clearBuffers: ClearBuffersFn;
|
|
3999
|
-
rebuildBuffers: RebuildBuffersFn;
|
|
4000
|
-
disposeBuffers: DisposeBuffersFn;
|
|
4001
|
-
};
|
|
4002
|
-
declare function useBuffers(): BuffersWithUtils<Record<string, BufferLike> & Record<string, Record<string, BufferLike>>>;
|
|
4003
|
-
declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
|
|
4004
|
-
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
|
|
4005
|
-
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
|
|
4006
|
-
/**
|
|
4007
|
-
* Global rebuildBuffers function for HMR integration.
|
|
4008
|
-
* Invalidates cached buffers and increments _hmrVersion to trigger re-creation.
|
|
4009
|
-
* Call this when HMR is detected to refresh all buffer creators.
|
|
4010
|
-
*
|
|
4011
|
-
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
4012
|
-
* authoritative store.
|
|
4013
|
-
*
|
|
4014
|
-
* @param store - The R3F store (from useStore or context)
|
|
4015
|
-
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4016
|
-
*/
|
|
4017
|
-
declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4018
|
-
|
|
4019
|
-
/**
|
|
4020
|
-
* Creator function that returns a record of GPU storage objects.
|
|
4021
|
-
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
4022
|
-
*/
|
|
4023
|
-
type StorageCreator<T extends Record<string, StorageLike>> = (state: CreatorState) => T;
|
|
4024
|
-
/** Function signature for removeStorage util */
|
|
4025
|
-
type RemoveStorageFn = (names: string | string[], scope?: string) => void;
|
|
4026
|
-
/** Function signature for clearStorage util */
|
|
4027
|
-
type ClearStorageFn = (scope?: string) => void;
|
|
4028
|
-
/** Function signature for rebuildStorage util */
|
|
4029
|
-
type RebuildStorageFn = (scope?: string) => void;
|
|
4030
|
-
/** Function signature for disposeStorage util - releases GPU resources */
|
|
4031
|
-
type DisposeStorageFn = (names: string | string[], scope?: string) => void;
|
|
4032
|
-
/** Return type with utils included */
|
|
4033
|
-
type StorageWithUtils<T extends Record<string, StorageLike> = Record<string, StorageLike>> = T & {
|
|
4034
|
-
removeStorage: RemoveStorageFn;
|
|
4035
|
-
clearStorage: ClearStorageFn;
|
|
4036
|
-
rebuildStorage: RebuildStorageFn;
|
|
4037
|
-
disposeStorage: DisposeStorageFn;
|
|
4038
|
-
};
|
|
4039
|
-
declare function useGPUStorage(): StorageWithUtils<Record<string, StorageLike> & Record<string, Record<string, StorageLike>>>;
|
|
4040
|
-
declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
|
|
4041
|
-
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
|
|
4042
|
-
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
|
|
4043
|
-
/**
|
|
4044
|
-
* Global rebuildStorage function for HMR integration.
|
|
4045
|
-
* Invalidates cached storage and increments _hmrVersion to trigger re-creation.
|
|
4046
|
-
* Call this when HMR is detected to refresh all storage creators.
|
|
4047
|
-
*
|
|
4048
|
-
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
4049
|
-
* authoritative store.
|
|
4050
|
-
*
|
|
4051
|
-
* @param store - The R3F store (from useStore or context)
|
|
4052
|
-
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4053
|
-
*/
|
|
4054
|
-
declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4055
|
-
|
|
4056
3515
|
/**
|
|
4057
3516
|
* Re-export from core - useTextures is now a core R3F hook (a reactive Texture registry).
|
|
4058
3517
|
*
|
|
@@ -4078,45 +3537,6 @@ interface TextureOperations {
|
|
|
4078
3537
|
}
|
|
4079
3538
|
declare function createTextureOperations(set: StoreApi<RootState>['setState']): TextureOperations;
|
|
4080
3539
|
|
|
4081
|
-
/**
|
|
4082
|
-
* Hook for managing WebGPU RenderPipeline with automatic scenePass setup.
|
|
4083
|
-
*
|
|
4084
|
-
* Features:
|
|
4085
|
-
* - Creates RenderPipeline instance if not exists
|
|
4086
|
-
* - Creates default scenePass (no MRT) automatically
|
|
4087
|
-
* - Callbacks receive full RootState for flexibility
|
|
4088
|
-
* - No auto-cleanup on unmount - use reset() for explicit cleanup
|
|
4089
|
-
* - Scene/camera changes trigger scenePass recreation
|
|
4090
|
-
*
|
|
4091
|
-
* @param mainCB - Main callback to configure outputNode and create effect passes
|
|
4092
|
-
* @param setupCB - Optional setup callback to configure MRT on scenePass
|
|
4093
|
-
* @returns { passes, renderPipeline, clearPasses, reset, rebuild }
|
|
4094
|
-
*
|
|
4095
|
-
* @example
|
|
4096
|
-
* ```tsx
|
|
4097
|
-
* // Simple effect
|
|
4098
|
-
* useRenderPipeline(({ renderPipeline, passes }) => {
|
|
4099
|
-
* renderPipeline.outputNode = bloom(passes.scenePass.getTextureNode())
|
|
4100
|
-
* })
|
|
4101
|
-
*
|
|
4102
|
-
* // With MRT setup
|
|
4103
|
-
* useRenderPipeline(
|
|
4104
|
-
* ({ renderPipeline, passes }) => {
|
|
4105
|
-
* const beauty = passes.scenePass.getTextureNode().toInspector('Color')
|
|
4106
|
-
* const vel = passes.scenePass.getTextureNode('velocity')
|
|
4107
|
-
* renderPipeline.outputNode = motionBlur(beauty, vel)
|
|
4108
|
-
* },
|
|
4109
|
-
* ({ passes }) => {
|
|
4110
|
-
* passes.scenePass.setMRT(mrt({ output, velocity }))
|
|
4111
|
-
* }
|
|
4112
|
-
* )
|
|
4113
|
-
*
|
|
4114
|
-
* // Read-only access
|
|
4115
|
-
* const { renderPipeline, passes } = useRenderPipeline()
|
|
4116
|
-
* ```
|
|
4117
|
-
*/
|
|
4118
|
-
declare function useRenderPipeline(mainCB?: RenderPipelineMainCallback, setupCB?: RenderPipelineSetupCallback): UseRenderPipelineReturn;
|
|
4119
|
-
|
|
4120
3540
|
//* Renderer Props ========================================
|
|
4121
3541
|
|
|
4122
3542
|
type WebGPUDefaultProps = Omit<WebGPURendererParameters, 'canvas'> & BaseRendererProps
|
|
@@ -4164,5 +3584,33 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
|
|
|
4164
3584
|
internal: WebGPUInternalState
|
|
4165
3585
|
}
|
|
4166
3586
|
|
|
4167
|
-
|
|
4168
|
-
|
|
3587
|
+
/**
|
|
3588
|
+
* @fileoverview WebGPU entry point - WebGPU only, no legacy WebGL
|
|
3589
|
+
*
|
|
3590
|
+
* This entry point is for apps that want to use ONLY WebGPURenderer.
|
|
3591
|
+
* Auto-extends THREE with WebGPU node materials (MeshBasicNodeMaterial, etc.)
|
|
3592
|
+
* The TSL resource hooks (useUniforms, useNodes, useRenderPipeline, ...) are in @react-three/tsl.
|
|
3593
|
+
*
|
|
3594
|
+
* Usage:
|
|
3595
|
+
* import { Canvas, useFrame } from '@react-three/fiber/webgpu'
|
|
3596
|
+
* import { useUniforms } from '@react-three/tsl'
|
|
3597
|
+
*/
|
|
3598
|
+
|
|
3599
|
+
/** `useThree` narrowed to WebGPU state — `state.renderer` is a `WebGPURenderer`. */
|
|
3600
|
+
type UseThreeWebGPU = <T = WebGPURootState>(selector?: (state: WebGPURootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
|
|
3601
|
+
/** `useFrame` narrowed to WebGPU state — the callback's `state.renderer` is a `WebGPURenderer`. */
|
|
3602
|
+
type UseFrameWebGPU = (callback?: FrameCallback$1<WebGPURootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
|
|
3603
|
+
declare const useThree: UseThreeWebGPU;
|
|
3604
|
+
declare const useFrame: UseFrameWebGPU;
|
|
3605
|
+
|
|
3606
|
+
/** Canvas props on the WebGPU entry: `onCreated` receives `WebGPURootState`. */
|
|
3607
|
+
type WebGPUCanvasProps = Omit<CanvasProps, 'onCreated'> & {
|
|
3608
|
+
/** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGPURenderer` */
|
|
3609
|
+
onCreated?: (state: WebGPURootState) => void;
|
|
3610
|
+
};
|
|
3611
|
+
|
|
3612
|
+
/** `Canvas` narrowed to WebGPU state — the same component, `onCreated` typed against `WebGPURootState`. */
|
|
3613
|
+
declare const Canvas: (props: WebGPUCanvasProps) => JSX.Element;
|
|
3614
|
+
|
|
3615
|
+
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, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, 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 };
|
|
3616
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, RootState as BaseRootState, Bridge, Camera, CameraProps, WebGPUCanvasProps 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, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeProps, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootExtension, WebGPURootState as RootState, RootStore, SetBlock, Size, Subscription, TSLNodeInput, TextureEntry, TextureInput, TextureNode, TextureOperations, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameWebGPU, UseTextureOptions, UseTexturesReturn, UseThreeWebGPU, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUCanvasProps, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };
|