@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/legacy.d.ts
CHANGED
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
import * as THREE$1 from 'three';
|
|
2
|
-
import { WebGLCubeRenderTarget, WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1,
|
|
2
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Object3D, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera } from 'three';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
5
|
-
import
|
|
6
|
-
import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject } from 'three/webgpu';
|
|
5
|
+
import { WebGPURenderer as WebGPURenderer$1, CanvasTarget } from 'three/webgpu';
|
|
7
6
|
import { StoreApi } from 'zustand';
|
|
8
7
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
9
8
|
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
10
9
|
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
11
10
|
import { Options } from 'react-use-measure';
|
|
12
11
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
13
|
-
import { ThreeElement as ThreeElement$1, Euler as Euler$2 } from '@react-three/fiber';
|
|
14
12
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
15
13
|
|
|
16
|
-
function _mergeNamespaces(n, m) {
|
|
17
|
-
m.forEach(function (e) {
|
|
18
|
-
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
19
|
-
if (k !== 'default' && !(k in n)) {
|
|
20
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return e[k]; }
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
return Object.freeze(n);
|
|
29
|
-
}
|
|
30
14
|
|
|
31
15
|
/**
|
|
32
16
|
* @fileoverview Internal Three.js re-exports - LEGACY ENTRY
|
|
@@ -39,28 +23,17 @@ function _mergeNamespaces(n, m) {
|
|
|
39
23
|
declare const R3F_BUILD_LEGACY = true;
|
|
40
24
|
declare const R3F_BUILD_WEBGPU = false;
|
|
41
25
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
declare
|
|
46
|
-
|
|
47
|
-
}
|
|
26
|
+
type Inspector = never;
|
|
27
|
+
/** Not available on the legacy (WebGL-only) entry. */
|
|
28
|
+
declare function loadInspector(): Promise<never>;
|
|
29
|
+
declare class WebGPURenderer {
|
|
30
|
+
constructor();
|
|
31
|
+
}
|
|
48
32
|
|
|
49
33
|
declare const RenderTarget: any;
|
|
50
34
|
|
|
51
35
|
declare const CubeRenderTarget: any;
|
|
52
36
|
|
|
53
|
-
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
54
|
-
__proto__: null,
|
|
55
|
-
CubeRenderTarget: CubeRenderTarget,
|
|
56
|
-
CubeRenderTargetCompat: WebGLCubeRenderTarget,
|
|
57
|
-
Inspector: Inspector,
|
|
58
|
-
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
59
|
-
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
60
|
-
RenderTarget: RenderTarget,
|
|
61
|
-
RenderTargetCompat: WebGLRenderTarget,
|
|
62
|
-
WebGPURenderer: WebGPURenderer
|
|
63
|
-
}, [THREE$1]);
|
|
64
37
|
|
|
65
38
|
//* Utility Types ==============================
|
|
66
39
|
|
|
@@ -324,68 +297,6 @@ type FrameNextCallback = FrameCallback$1<RootState>
|
|
|
324
297
|
/** Alias for FrameNextCallback */
|
|
325
298
|
type FrameCallback = FrameNextCallback
|
|
326
299
|
|
|
327
|
-
//* Buffer Types (useBuffers) ========================================
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Buffer-like types for GPU compute and storage operations.
|
|
331
|
-
* Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
|
|
332
|
-
*
|
|
333
|
-
* @example
|
|
334
|
-
* ```tsx
|
|
335
|
-
* const { positions, velocities } = useBuffers(() => ({
|
|
336
|
-
* positions: instancedArray(count, 'vec3'), // StorageBufferNode
|
|
337
|
-
* velocities: new Float32Array(count * 3), // TypedArray
|
|
338
|
-
* }), 'particles')
|
|
339
|
-
* ```
|
|
340
|
-
*/
|
|
341
|
-
type BufferLike =
|
|
342
|
-
| Float32Array
|
|
343
|
-
| Uint32Array
|
|
344
|
-
| Int32Array
|
|
345
|
-
| Float64Array
|
|
346
|
-
| Uint8Array
|
|
347
|
-
| Int8Array
|
|
348
|
-
| Uint16Array
|
|
349
|
-
| Int16Array
|
|
350
|
-
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
351
|
-
| Node // TSL buffer nodes (instancedArray, storage)
|
|
352
|
-
|
|
353
|
-
/** Flat record of buffer-like values (no nested scopes) */
|
|
354
|
-
type BufferRecord = Record<string, BufferLike>
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Buffer store that can contain both root-level buffers and scoped buffer objects.
|
|
358
|
-
* Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
|
|
359
|
-
*/
|
|
360
|
-
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
361
|
-
|
|
362
|
-
//* Storage Types (useGPUStorage) ========================================
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* GPU storage types for texture-based storage operations.
|
|
366
|
-
* Includes Three.js storage textures and TSL storage texture nodes.
|
|
367
|
-
*
|
|
368
|
-
* @example
|
|
369
|
-
* ```tsx
|
|
370
|
-
* const { heightMap } = useGPUStorage(() => ({
|
|
371
|
-
* heightMap: new StorageTexture(512, 512),
|
|
372
|
-
* }), 'terrain')
|
|
373
|
-
* ```
|
|
374
|
-
*/
|
|
375
|
-
type StorageLike =
|
|
376
|
-
| StorageTexture // GPU storage texture
|
|
377
|
-
| Data3DTexture // 3D texture (can be used as storage)
|
|
378
|
-
| Node // TSL storage texture nodes (storageTexture)
|
|
379
|
-
|
|
380
|
-
/** Flat record of storage-like values (no nested scopes) */
|
|
381
|
-
type StorageRecord = Record<string, StorageLike>
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Storage store that can contain both root-level storage and scoped storage objects.
|
|
385
|
-
* Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
|
|
386
|
-
*/
|
|
387
|
-
type StorageStore = Record<string, StorageLike | StorageRecord>
|
|
388
|
-
|
|
389
300
|
//* Renderer Types ========================================
|
|
390
301
|
|
|
391
302
|
/** Default renderer type - union of WebGL and WebGPU renderers */
|
|
@@ -485,6 +396,12 @@ interface InternalState {
|
|
|
485
396
|
actualRenderer: R3FRenderer
|
|
486
397
|
/** Global scheduler reference (for useFrame hook) */
|
|
487
398
|
scheduler: SchedulerApi | null
|
|
399
|
+
/**
|
|
400
|
+
* Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
|
|
401
|
+
* `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
|
|
402
|
+
* render-phase takeover. Used by `useRenderPipeline`.
|
|
403
|
+
*/
|
|
404
|
+
renderOverride?: (() => void) | null
|
|
488
405
|
/** This root's unique ID in the global scheduler */
|
|
489
406
|
rootId?: string
|
|
490
407
|
/** Function to unregister this root from the global scheduler */
|
|
@@ -492,11 +409,28 @@ interface InternalState {
|
|
|
492
409
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
493
410
|
container?: THREE$1.Object3D
|
|
494
411
|
/**
|
|
495
|
-
* CanvasTarget
|
|
496
|
-
*
|
|
412
|
+
* The CanvasTarget this root sizes and renders through.
|
|
413
|
+
*
|
|
414
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
415
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
416
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
417
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
418
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
497
419
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
498
420
|
*/
|
|
499
421
|
canvasTarget?: CanvasTarget
|
|
422
|
+
/**
|
|
423
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
424
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
425
|
+
*
|
|
426
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
427
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
428
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
429
|
+
* invalidate some other canvas's descriptor instead.
|
|
430
|
+
*
|
|
431
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
432
|
+
*/
|
|
433
|
+
canvasTargetSizeDirty?: boolean
|
|
500
434
|
/**
|
|
501
435
|
* Whether multi-canvas rendering is active.
|
|
502
436
|
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
@@ -535,12 +469,13 @@ interface RootState {
|
|
|
535
469
|
/** Get current state */
|
|
536
470
|
get: StoreApi<RootState>['getState']
|
|
537
471
|
/**
|
|
538
|
-
*
|
|
472
|
+
* The store of the canvas that owns this root's renderer.
|
|
539
473
|
* - For primary/independent canvases: points to its own store (self-reference)
|
|
540
474
|
* - For secondary canvases: points to the primary canvas's store
|
|
475
|
+
* - Portals copy it from their parent
|
|
541
476
|
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
477
|
+
* Anything shared per renderer rather than per canvas (e.g. @react-three/tsl's resources)
|
|
478
|
+
* resolves through it.
|
|
544
479
|
*/
|
|
545
480
|
primaryStore: RootStore
|
|
546
481
|
/** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
|
|
@@ -603,24 +538,10 @@ interface RootState {
|
|
|
603
538
|
setError: (error: Error | null) => void
|
|
604
539
|
/** Current error state (null when no error) */
|
|
605
540
|
error: Error | null
|
|
606
|
-
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
607
|
-
uniforms: UniformStore
|
|
608
|
-
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
609
|
-
nodes: Record<string, any>
|
|
610
|
-
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
611
|
-
buffers: BufferStore
|
|
612
|
-
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
613
|
-
gpuStorage: StorageStore
|
|
614
541
|
/** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
|
|
615
542
|
textures: Map<string, THREE$1.Texture>
|
|
616
543
|
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
617
544
|
_textureRefs: Map<string, number>
|
|
618
|
-
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
619
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
620
|
-
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
621
|
-
passes: Record<string, any>
|
|
622
|
-
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
623
|
-
_hmrVersion: number
|
|
624
545
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
625
546
|
_sizeImperative: boolean
|
|
626
547
|
/** Internal: stored size props from Canvas for reset functionality */
|
|
@@ -706,12 +627,19 @@ type DefaultRendererProps = {
|
|
|
706
627
|
*/
|
|
707
628
|
interface CanvasSchedulerConfig {
|
|
708
629
|
/**
|
|
709
|
-
*
|
|
710
|
-
|
|
630
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
631
|
+
*/
|
|
632
|
+
before?: string | string[]
|
|
633
|
+
/**
|
|
634
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
635
|
+
*/
|
|
636
|
+
after?: string | string[]
|
|
637
|
+
/**
|
|
638
|
+
* Numeric root order. Lower values run first.
|
|
711
639
|
*/
|
|
712
|
-
|
|
640
|
+
order?: number
|
|
713
641
|
/**
|
|
714
|
-
* Limit this
|
|
642
|
+
* Limit this Canvas's default render job (frames per second).
|
|
715
643
|
*/
|
|
716
644
|
fps?: number
|
|
717
645
|
}
|
|
@@ -798,14 +726,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
798
726
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
799
727
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
800
728
|
dpr?: Dpr
|
|
801
|
-
/**
|
|
802
|
-
|
|
729
|
+
/**
|
|
730
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
731
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
732
|
+
*/
|
|
733
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
803
734
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
804
735
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
805
736
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
806
737
|
camera?: CameraProps
|
|
807
738
|
/** An R3F event manager to manage elements' pointer events */
|
|
808
|
-
events?: (store: RootStore) => EventManager<
|
|
739
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
809
740
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
810
741
|
onCreated?: (state: RootState) => void
|
|
811
742
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -894,7 +825,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
894
825
|
object?: T
|
|
895
826
|
dispose?: null
|
|
896
827
|
attach?: AttachType<T>
|
|
897
|
-
onUpdate?: (self: T) => void
|
|
898
828
|
}
|
|
899
829
|
|
|
900
830
|
interface Instance<O = any> {
|
|
@@ -1034,7 +964,7 @@ interface CanvasProps
|
|
|
1034
964
|
*/
|
|
1035
965
|
resize?: Options
|
|
1036
966
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1037
|
-
eventSource?:
|
|
967
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1038
968
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1039
969
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1040
970
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1142,202 +1072,6 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1142
1072
|
|
|
1143
1073
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1144
1074
|
|
|
1145
|
-
//* Global Types ==============================
|
|
1146
|
-
|
|
1147
|
-
declare global {
|
|
1148
|
-
/**
|
|
1149
|
-
* Uniform node type.
|
|
1150
|
-
*
|
|
1151
|
-
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1152
|
-
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1153
|
-
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1154
|
-
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1155
|
-
* arity when three made `UniformNode` two-parameter.
|
|
1156
|
-
*
|
|
1157
|
-
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1158
|
-
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1159
|
-
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1160
|
-
* installed three instead of needing to be mirrored by hand.
|
|
1161
|
-
*/
|
|
1162
|
-
type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
|
|
1163
|
-
|
|
1164
|
-
/**
|
|
1165
|
-
* ShaderCallable - the return type of Fn()
|
|
1166
|
-
* A callable shader function node that can be invoked with parameters.
|
|
1167
|
-
* The function returns a ShaderNodeObject when called.
|
|
1168
|
-
*
|
|
1169
|
-
* @example
|
|
1170
|
-
* ```tsx
|
|
1171
|
-
* // Define a shader function
|
|
1172
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1173
|
-
* return mix(color1, color2, factor)
|
|
1174
|
-
* })
|
|
1175
|
-
*
|
|
1176
|
-
* // Type when retrieving from nodes store
|
|
1177
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1178
|
-
*
|
|
1179
|
-
* // Or with specific return type
|
|
1180
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1181
|
-
* ```
|
|
1182
|
-
*/
|
|
1183
|
-
type ShaderCallable<R extends Node = Node> = ((...params: unknown[]) => ShaderNodeObject<R>) & Node
|
|
1184
|
-
|
|
1185
|
-
/**
|
|
1186
|
-
* ShaderNodeRef - a ShaderNodeObject wrapper around a Node
|
|
1187
|
-
* This is the common return type for TSL operations (add, mul, sin, etc.)
|
|
1188
|
-
*
|
|
1189
|
-
* @example
|
|
1190
|
-
* ```tsx
|
|
1191
|
-
* const { wobble } = nodes as { wobble: ShaderNodeRef }
|
|
1192
|
-
* ```
|
|
1193
|
-
*/
|
|
1194
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1195
|
-
|
|
1196
|
-
/**
|
|
1197
|
-
* TSLNodeType - Union of all common TSL node types
|
|
1198
|
-
* Used by ScopedStore to properly type node access from the store.
|
|
1199
|
-
*
|
|
1200
|
-
* Includes:
|
|
1201
|
-
* - Node: base Three.js node type
|
|
1202
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1203
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1204
|
-
*
|
|
1205
|
-
* @example
|
|
1206
|
-
* ```tsx
|
|
1207
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1208
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1209
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1210
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1211
|
-
* }))
|
|
1212
|
-
*
|
|
1213
|
-
* // Can narrow with type guard or assertion when needed
|
|
1214
|
-
* if (typeof blendColorFn === 'function') {
|
|
1215
|
-
* blendColorFn(someColor, 0.5)
|
|
1216
|
-
* }
|
|
1217
|
-
* ```
|
|
1218
|
-
*/
|
|
1219
|
-
type TSLNodeType = Node | ShaderCallable<Node> | ShaderNodeObject<Node>
|
|
1220
|
-
|
|
1221
|
-
/** Flat record of uniform nodes (no nested scopes) */
|
|
1222
|
-
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
1223
|
-
|
|
1224
|
-
/**
|
|
1225
|
-
* Uniform store that can contain both root-level uniforms and scoped uniform objects
|
|
1226
|
-
* Used by state.uniforms which has structure like:
|
|
1227
|
-
* { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
|
|
1228
|
-
*/
|
|
1229
|
-
type UniformStore = Record<string, UniformNode | UniformRecord>
|
|
1230
|
-
|
|
1231
|
-
/**
|
|
1232
|
-
* Helper to safely access a uniform node from the store.
|
|
1233
|
-
* Use this when accessing state.uniforms to get proper typing.
|
|
1234
|
-
* @example
|
|
1235
|
-
* const uTime = uniforms.uTime as UniformNode<number>
|
|
1236
|
-
* const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
|
|
1237
|
-
*/
|
|
1238
|
-
type GetUniform<T = unknown> = UniformNode<T>
|
|
1239
|
-
|
|
1240
|
-
/**
|
|
1241
|
-
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1242
|
-
* Supports:
|
|
1243
|
-
* - Primitives: number, string (color), boolean
|
|
1244
|
-
* - Three.js types: Color, Vector2/3/4, Matrix3/4, Euler, Quaternion
|
|
1245
|
-
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1246
|
-
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1247
|
-
* - UniformNode: existing uniforms (reused as-is)
|
|
1248
|
-
*/
|
|
1249
|
-
type UniformValue =
|
|
1250
|
-
| number
|
|
1251
|
-
| string
|
|
1252
|
-
| boolean
|
|
1253
|
-
| three_webgpu.Color
|
|
1254
|
-
| three_webgpu.Vector2
|
|
1255
|
-
| three_webgpu.Vector3
|
|
1256
|
-
| three_webgpu.Vector4
|
|
1257
|
-
| three_webgpu.Matrix3
|
|
1258
|
-
| three_webgpu.Matrix4
|
|
1259
|
-
| three_webgpu.Euler
|
|
1260
|
-
| three_webgpu.Quaternion
|
|
1261
|
-
| { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
|
|
1262
|
-
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1263
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1264
|
-
| UniformNode
|
|
1265
|
-
|
|
1266
|
-
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1267
|
-
type UniformInputRecord = Record<string, UniformValue>
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
//* Module Augmentation ==============================
|
|
1271
|
-
|
|
1272
|
-
declare module 'three/tsl' {
|
|
1273
|
-
/**
|
|
1274
|
-
* Fn with array parameter destructuring
|
|
1275
|
-
* @example Fn(([uv, skew]) => { ... })
|
|
1276
|
-
*/
|
|
1277
|
-
export function Fn<R extends Node = Node>(
|
|
1278
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1279
|
-
): ShaderCallable<R>
|
|
1280
|
-
|
|
1281
|
-
/**
|
|
1282
|
-
* Fn with object parameter destructuring
|
|
1283
|
-
* @example Fn(({ color, intensity }) => { ... })
|
|
1284
|
-
*/
|
|
1285
|
-
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1286
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1287
|
-
): ShaderCallable<R>
|
|
1288
|
-
|
|
1289
|
-
/**
|
|
1290
|
-
* Fn with array params + layout
|
|
1291
|
-
* @example Fn(([a, b]) => { ... }, { layout: [...] })
|
|
1292
|
-
*/
|
|
1293
|
-
export function Fn<R extends Node = Node>(
|
|
1294
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1295
|
-
layout: { layout?: unknown },
|
|
1296
|
-
): ShaderCallable<R>
|
|
1297
|
-
|
|
1298
|
-
/**
|
|
1299
|
-
* Fn with object params + layout
|
|
1300
|
-
*/
|
|
1301
|
-
export function Fn<T extends Record<string, unknown>, R extends Node = Node>(
|
|
1302
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1303
|
-
layout: { layout?: unknown },
|
|
1304
|
-
): ShaderCallable<R>
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
declare global {
|
|
1308
|
-
/**
|
|
1309
|
-
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1310
|
-
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1311
|
-
* is r185, so the new name is the only one.
|
|
1312
|
-
*/
|
|
1313
|
-
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1314
|
-
|
|
1315
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1316
|
-
type PassRecord = Record<string, any>
|
|
1317
|
-
|
|
1318
|
-
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1319
|
-
type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
|
|
1320
|
-
|
|
1321
|
-
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1322
|
-
type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
|
|
1323
|
-
|
|
1324
|
-
/** Return type for useRenderPipeline hook */
|
|
1325
|
-
interface UseRenderPipelineReturn {
|
|
1326
|
-
/** Current passes from state */
|
|
1327
|
-
passes: PassRecord
|
|
1328
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1329
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1330
|
-
/** Clear all passes from state */
|
|
1331
|
-
clearPasses: () => void
|
|
1332
|
-
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1333
|
-
reset: () => void
|
|
1334
|
-
/** Re-run setup/main callbacks with current closure values */
|
|
1335
|
-
rebuild: () => void
|
|
1336
|
-
/** True when RenderPipeline is configured and ready */
|
|
1337
|
-
isReady: boolean
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
1075
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
1342
1076
|
|
|
1343
1077
|
interface MathRepresentation {
|
|
@@ -1414,10 +1148,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1414
1148
|
|
|
1415
1149
|
/**
|
|
1416
1150
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1417
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1151
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1152
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1418
1153
|
*/
|
|
1419
1154
|
type NodeProps<P> = {
|
|
1420
|
-
[K in keyof P as P[K] extends
|
|
1155
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1421
1156
|
}
|
|
1422
1157
|
|
|
1423
1158
|
interface ReactProps<P> {
|
|
@@ -1438,11 +1173,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1438
1173
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1439
1174
|
}
|
|
1440
1175
|
|
|
1176
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1177
|
+
type Object3DMethod = NonNullable<
|
|
1178
|
+
{
|
|
1179
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1180
|
+
}[keyof Object3D]
|
|
1181
|
+
>
|
|
1182
|
+
|
|
1441
1183
|
type ThreeExports = typeof import('three')
|
|
1442
1184
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1443
1185
|
|
|
1444
1186
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1445
|
-
|
|
1187
|
+
/**
|
|
1188
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1189
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1190
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1191
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1192
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1193
|
+
*/
|
|
1194
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1195
|
+
object: object
|
|
1196
|
+
ref?: React.Ref<any>
|
|
1197
|
+
[prop: string]: unknown
|
|
1198
|
+
}
|
|
1446
1199
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1447
1200
|
threeAudio: ThreeElementsImpl['audio']
|
|
1448
1201
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1483,6 +1236,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1483
1236
|
type three_d_Matrix4 = Matrix4;
|
|
1484
1237
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1485
1238
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1239
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1486
1240
|
type three_d_Quaternion = Quaternion;
|
|
1487
1241
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1488
1242
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1497,7 +1251,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1497
1251
|
type three_d_Vector4 = Vector4;
|
|
1498
1252
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1499
1253
|
declare namespace three_d {
|
|
1500
|
-
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1254
|
+
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Object3DMethod as Object3DMethod, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1501
1255
|
}
|
|
1502
1256
|
|
|
1503
1257
|
/**
|
|
@@ -1635,9 +1389,9 @@ type EnvironmentProps = {
|
|
|
1635
1389
|
blur?: number;
|
|
1636
1390
|
backgroundBlurriness?: number;
|
|
1637
1391
|
backgroundIntensity?: number;
|
|
1638
|
-
backgroundRotation?: Euler
|
|
1392
|
+
backgroundRotation?: Euler;
|
|
1639
1393
|
environmentIntensity?: number;
|
|
1640
|
-
environmentRotation?: Euler
|
|
1394
|
+
environmentRotation?: Euler;
|
|
1641
1395
|
map?: Texture$1;
|
|
1642
1396
|
preset?: PresetsType;
|
|
1643
1397
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -1721,7 +1475,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
1721
1475
|
declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
1722
1476
|
declare module '@react-three/fiber' {
|
|
1723
1477
|
interface ThreeElements {
|
|
1724
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1478
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
1725
1479
|
}
|
|
1726
1480
|
}
|
|
1727
1481
|
/**
|
|
@@ -1846,7 +1600,43 @@ declare function createEvents(store: RootStore): {
|
|
|
1846
1600
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
1847
1601
|
};
|
|
1848
1602
|
/** Default R3F event manager for web */
|
|
1849
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1603
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1604
|
+
|
|
1605
|
+
interface RootExtension {
|
|
1606
|
+
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
1607
|
+
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
1608
|
+
name: string;
|
|
1609
|
+
/**
|
|
1610
|
+
* Called once per root, after its renderer exists and before `onCreated` and the first frame.
|
|
1611
|
+
* `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
|
|
1612
|
+
* to the primary canvas. Return fields to merge into the root's state, or nothing.
|
|
1613
|
+
*/
|
|
1614
|
+
setup?(store: RootStore): Partial<RootState> | void;
|
|
1615
|
+
/** Called when a root this extension set up unmounts. */
|
|
1616
|
+
dispose?(store: RootStore): void;
|
|
1617
|
+
/** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
|
|
1618
|
+
hmr?(store: RootStore): void;
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Register an extension. It is set up on every live root immediately, and on every root created
|
|
1622
|
+
* afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
|
|
1623
|
+
* it already set up keep its state and still get its dispose when they unmount.
|
|
1624
|
+
*/
|
|
1625
|
+
declare function registerRootExtension(extension: RootExtension): () => void;
|
|
1626
|
+
/**
|
|
1627
|
+
* Point a root's default render job at a different render function, or back at
|
|
1628
|
+
* `renderer.render(scene, camera)` with `null`.
|
|
1629
|
+
*
|
|
1630
|
+
* The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
|
|
1631
|
+
* boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
|
|
1632
|
+
*/
|
|
1633
|
+
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
1634
|
+
|
|
1635
|
+
/**
|
|
1636
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
1637
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
1638
|
+
*/
|
|
1639
|
+
declare function useStore(): RootStore;
|
|
1850
1640
|
|
|
1851
1641
|
/**
|
|
1852
1642
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -1866,50 +1656,6 @@ declare namespace useLoader {
|
|
|
1866
1656
|
var loader: typeof getLoader;
|
|
1867
1657
|
}
|
|
1868
1658
|
|
|
1869
|
-
/**
|
|
1870
|
-
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
1871
|
-
*
|
|
1872
|
-
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1873
|
-
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1874
|
-
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1875
|
-
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1876
|
-
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
1877
|
-
*
|
|
1878
|
-
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
1879
|
-
*
|
|
1880
|
-
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1881
|
-
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1882
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1883
|
-
*
|
|
1884
|
-
* @example
|
|
1885
|
-
* // Simple priority (backwards compat)
|
|
1886
|
-
* useFrame((state, delta) => { ... }, 5)
|
|
1887
|
-
*
|
|
1888
|
-
* @example
|
|
1889
|
-
* // With phase-based ordering
|
|
1890
|
-
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
1891
|
-
*
|
|
1892
|
-
* @example
|
|
1893
|
-
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
1894
|
-
* function UI() {
|
|
1895
|
-
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
1896
|
-
* return <button>...</button>;
|
|
1897
|
-
* }
|
|
1898
|
-
*
|
|
1899
|
-
* @example
|
|
1900
|
-
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
1901
|
-
* import { getScheduler } from '@pmndrs/scheduler'
|
|
1902
|
-
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
1903
|
-
*
|
|
1904
|
-
* @example
|
|
1905
|
-
* // Scheduler-only access (no callback)
|
|
1906
|
-
* const { scheduler } = useFrame()
|
|
1907
|
-
* scheduler.pauseJob('some-job-id')
|
|
1908
|
-
*
|
|
1909
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
1910
|
-
*/
|
|
1911
|
-
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
1912
|
-
|
|
1913
1659
|
declare const IsObject: (url: unknown) => url is Record<string, string>;
|
|
1914
1660
|
type TextureArray<T> = T extends string[] ? Texture$1[] : never;
|
|
1915
1661
|
type TextureRecord<T> = T extends Record<string, string> ? {
|
|
@@ -2090,16 +1836,6 @@ declare function useRenderTarget(options?: RenderTargetOptions): WebGLRenderTarg
|
|
|
2090
1836
|
declare function useRenderTarget(size: number, options?: RenderTargetOptions): WebGLRenderTarget;
|
|
2091
1837
|
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): WebGLRenderTarget;
|
|
2092
1838
|
|
|
2093
|
-
/**
|
|
2094
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2095
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2096
|
-
*/
|
|
2097
|
-
declare function useStore(): RootStore;
|
|
2098
|
-
/**
|
|
2099
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2100
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2101
|
-
*/
|
|
2102
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2103
1839
|
/**
|
|
2104
1840
|
* Exposes an object's {@link Instance}.
|
|
2105
1841
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2175,7 +1911,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2175
1911
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2176
1912
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2177
1913
|
*
|
|
2178
|
-
*
|
|
1914
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
1915
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
1916
|
+
*
|
|
1917
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2179
1918
|
* @param frames - Number of frames to request (default: 1)
|
|
2180
1919
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2181
1920
|
*
|
|
@@ -2186,14 +1925,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2186
1925
|
* Advances the frameloop and runs render effects.
|
|
2187
1926
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2188
1927
|
*
|
|
1928
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
1929
|
+
* registered root is stepped for backwards compatibility.
|
|
1930
|
+
*
|
|
2189
1931
|
* @param timestamp - The timestamp to use for this frame
|
|
2190
1932
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2191
|
-
* @param state -
|
|
2192
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
1933
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2193
1934
|
*
|
|
2194
1935
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2195
1936
|
*/
|
|
2196
|
-
declare function advance(timestamp: number): void;
|
|
1937
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2197
1938
|
|
|
2198
1939
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2199
1940
|
declare function ReactReconciler<
|
|
@@ -3238,6 +2979,7 @@ declare namespace ReactReconciler {
|
|
|
3238
2979
|
|
|
3239
2980
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3240
2981
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
2982
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3241
2983
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3242
2984
|
|
|
3243
2985
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3262,6 +3004,7 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
3262
3004
|
declare function flushSync<R>(fn: () => R): R;
|
|
3263
3005
|
|
|
3264
3006
|
declare const context: React$1.Context<RootStore>;
|
|
3007
|
+
|
|
3265
3008
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3266
3009
|
|
|
3267
3010
|
/**
|
|
@@ -3515,7 +3258,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
3515
3258
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
3516
3259
|
/**
|
|
3517
3260
|
* Triggers an update for an instance.
|
|
3518
|
-
*
|
|
3261
|
+
* Invalidates the frame if the root is in demand mode.
|
|
3519
3262
|
*
|
|
3520
3263
|
* @param instance - Instance to invalidate
|
|
3521
3264
|
*/
|
|
@@ -3681,29 +3424,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3681
3424
|
* Used to identify values that should be resolved from refs after mount.
|
|
3682
3425
|
*/
|
|
3683
3426
|
declare const FROM_REF: unique symbol;
|
|
3427
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3428
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3429
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3430
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3431
|
+
transform?: (value: T) => R;
|
|
3432
|
+
}
|
|
3684
3433
|
/**
|
|
3685
3434
|
* Defers prop application until the referenced object is available.
|
|
3686
3435
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
3687
3436
|
*
|
|
3437
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3438
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3439
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3440
|
+
* what gets assigned.
|
|
3441
|
+
*
|
|
3688
3442
|
* @param ref - React ref object to resolve at mount time
|
|
3689
|
-
* @
|
|
3443
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3444
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
3690
3445
|
*
|
|
3691
3446
|
* @example
|
|
3692
3447
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
3693
3448
|
*
|
|
3694
3449
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
3695
3450
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3451
|
+
*
|
|
3452
|
+
* @example
|
|
3453
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3454
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
3696
3455
|
*/
|
|
3697
3456
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3457
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
3698
3458
|
/**
|
|
3699
3459
|
* Type guard to check if a value is a fromRef marker.
|
|
3700
3460
|
*
|
|
3701
3461
|
* @param value - Value to check
|
|
3702
3462
|
* @returns True if value is a fromRef marker
|
|
3703
3463
|
*/
|
|
3704
|
-
declare function isFromRef(value: unknown): value is
|
|
3705
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
3706
|
-
};
|
|
3464
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
3707
3465
|
|
|
3708
3466
|
/**
|
|
3709
3467
|
* Symbol marker for mount-only method calls.
|
|
@@ -3730,7 +3488,15 @@ declare const ONCE: unique symbol;
|
|
|
3730
3488
|
* // No arguments
|
|
3731
3489
|
* <geometry center={once()} />
|
|
3732
3490
|
*/
|
|
3733
|
-
declare function once<
|
|
3491
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3492
|
+
/**
|
|
3493
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3494
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3495
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3496
|
+
*
|
|
3497
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3498
|
+
*/
|
|
3499
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
3734
3500
|
/**
|
|
3735
3501
|
* Type guard to check if a value is a once marker.
|
|
3736
3502
|
*
|
|
@@ -3742,10 +3508,31 @@ declare function isOnce(value: unknown): value is {
|
|
|
3742
3508
|
};
|
|
3743
3509
|
|
|
3744
3510
|
/**
|
|
3745
|
-
*
|
|
3746
|
-
*
|
|
3511
|
+
* @fileoverview Legacy entry point - WebGL only
|
|
3512
|
+
*
|
|
3513
|
+
* This entry point is for apps that want to use the legacy WebGLRenderer.
|
|
3514
|
+
* No WebGPU features are available from this import path.
|
|
3515
|
+
* Auto-extends THREE with WebGL-only constructors (no node materials).
|
|
3516
|
+
*
|
|
3517
|
+
* Usage:
|
|
3518
|
+
* import { Canvas, useFrame } from '@react-three/fiber/legacy'
|
|
3747
3519
|
*/
|
|
3748
|
-
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3749
3520
|
|
|
3750
|
-
|
|
3751
|
-
|
|
3521
|
+
/** `useThree` narrowed to legacy state — `state.renderer` is a `WebGLRenderer`. */
|
|
3522
|
+
type UseThreeLegacy = <T = LegacyRootState>(selector?: (state: LegacyRootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
|
|
3523
|
+
/** `useFrame` narrowed to legacy state — the callback's `state.renderer` is a `WebGLRenderer`. */
|
|
3524
|
+
type UseFrameLegacy = (callback?: FrameCallback$1<LegacyRootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
|
|
3525
|
+
declare const useThree: UseThreeLegacy;
|
|
3526
|
+
declare const useFrame: UseFrameLegacy;
|
|
3527
|
+
|
|
3528
|
+
/** Canvas props on the legacy entry: `onCreated` receives `LegacyRootState`. */
|
|
3529
|
+
type LegacyCanvasProps = Omit<CanvasProps, 'onCreated'> & {
|
|
3530
|
+
/** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGLRenderer` */
|
|
3531
|
+
onCreated?: (state: LegacyRootState) => void;
|
|
3532
|
+
};
|
|
3533
|
+
|
|
3534
|
+
/** `Canvas` narrowed to legacy state — the same component, `onCreated` typed against `LegacyRootState`. */
|
|
3535
|
+
declare const Canvas: (props: LegacyCanvasProps) => JSX.Element;
|
|
3536
|
+
|
|
3537
|
+
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 };
|
|
3538
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, Camera, CameraProps, LegacyCanvasProps as CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, FromRefMarker, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, LegacyInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyCanvasProps, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeProps, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootExtension, LegacyRootState as RootState, RootStore, SetBlock, Size, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameLegacy, UseTextureOptions, UseTexturesReturn, UseThreeLegacy, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|