@react-three/fiber 10.0.0-canary.dc0ec15 → 10.0.0-canary.de17310
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.d.cts +49 -1095
- package/dist/extension.d.mts +49 -1095
- package/dist/extension.d.ts +49 -1067
- package/dist/index.cjs +2 -8
- package/dist/index.d.cts +8 -342
- package/dist/index.d.mts +8 -342
- package/dist/index.d.ts +7 -341
- package/dist/index.mjs +2 -8
- package/dist/legacy.cjs +2 -8
- package/dist/legacy.d.cts +6 -341
- package/dist/legacy.d.mts +6 -341
- package/dist/legacy.d.ts +6 -341
- package/dist/legacy.mjs +2 -8
- package/dist/webgpu/index.cjs +9 -939
- package/dist/webgpu/index.d.cts +12 -685
- package/dist/webgpu/index.d.mts +12 -685
- package/dist/webgpu/index.d.ts +11 -684
- package/dist/webgpu/index.mjs +11 -923
- package/package.json +1 -1
package/dist/extension.d.cts
CHANGED
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
import * as React
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Euler as Euler$2, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
5
|
-
import * as three_webgpu from 'three/webgpu';
|
|
6
|
-
import { WebGPURenderer, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget, CubeRenderTarget, RenderTarget, Euler as Euler$1, Color as Color$1, ColorRepresentation, 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 } from 'three/webgpu';
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
import { WebGPURenderer, CanvasTarget } from 'three/webgpu';
|
|
7
4
|
import { StoreApi } from 'zustand';
|
|
8
5
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
9
6
|
import { FrameCallback as FrameCallback$1, FrameTimingState, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
10
7
|
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, SchedulerApi, UseFrameNextOptions, UseFrameOptions } from '@pmndrs/scheduler';
|
|
11
|
-
import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
|
|
12
|
-
import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
|
|
13
|
-
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
14
|
-
import { Options } from 'react-use-measure';
|
|
15
|
-
|
|
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
8
|
|
|
31
9
|
//* Utility Types ==============================
|
|
32
10
|
|
|
@@ -43,7 +21,7 @@ type IsAllOptional<T extends any[]> = T extends [infer First, ...infer Rest]
|
|
|
43
21
|
|
|
44
22
|
//* Camera Types ==============================
|
|
45
23
|
|
|
46
|
-
type ThreeCamera = (THREE
|
|
24
|
+
type ThreeCamera = (THREE.OrthographicCamera | THREE.PerspectiveCamera) & { manual?: boolean }
|
|
47
25
|
|
|
48
26
|
//* Act Type ==============================
|
|
49
27
|
|
|
@@ -51,10 +29,10 @@ type Act = <T = any>(cb: () => Promise<T>) => Promise<T>
|
|
|
51
29
|
|
|
52
30
|
//* Bridge & Block Types ==============================
|
|
53
31
|
|
|
54
|
-
type Bridge = React
|
|
32
|
+
type Bridge = React.FC<{ children?: React.ReactNode }>
|
|
55
33
|
|
|
56
34
|
type SetBlock = false | Promise<null> | null
|
|
57
|
-
type UnblockProps = { set: React
|
|
35
|
+
type UnblockProps = { set: React.Dispatch<React.SetStateAction<SetBlock>>; children: React.ReactNode }
|
|
58
36
|
|
|
59
37
|
//* Object Map Type ==============================
|
|
60
38
|
|
|
@@ -79,9 +57,9 @@ interface ObjectMap<
|
|
|
79
57
|
meshes: string
|
|
80
58
|
},
|
|
81
59
|
> {
|
|
82
|
-
nodes: Record<T['nodes'] extends string ? T['nodes'] : string, THREE
|
|
83
|
-
materials: Record<T['materials'] extends string ? T['materials'] : string, THREE
|
|
84
|
-
meshes: Record<T['meshes'] extends string ? T['meshes'] : string, THREE
|
|
60
|
+
nodes: Record<T['nodes'] extends string ? T['nodes'] : string, THREE.Object3D>
|
|
61
|
+
materials: Record<T['materials'] extends string ? T['materials'] : string, THREE.Material>
|
|
62
|
+
meshes: Record<T['meshes'] extends string ? T['meshes'] : string, THREE.Mesh>
|
|
85
63
|
}
|
|
86
64
|
|
|
87
65
|
//* Equality Config ==============================
|
|
@@ -104,28 +82,28 @@ interface Disposable {
|
|
|
104
82
|
|
|
105
83
|
//* Event-related Types =====================================
|
|
106
84
|
|
|
107
|
-
interface Intersection extends THREE
|
|
85
|
+
interface Intersection extends THREE.Intersection {
|
|
108
86
|
/** The event source (the object which registered the handler) */
|
|
109
|
-
eventObject: THREE
|
|
87
|
+
eventObject: THREE.Object3D
|
|
110
88
|
}
|
|
111
89
|
|
|
112
|
-
type Camera = THREE
|
|
90
|
+
type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera
|
|
113
91
|
|
|
114
92
|
interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
115
93
|
/** The event source (the object which registered the handler) */
|
|
116
|
-
eventObject: THREE
|
|
94
|
+
eventObject: THREE.Object3D
|
|
117
95
|
/** An array of intersections */
|
|
118
96
|
intersections: Intersection[]
|
|
119
97
|
/** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
|
|
120
|
-
unprojectedPoint: THREE
|
|
98
|
+
unprojectedPoint: THREE.Vector3
|
|
121
99
|
/** Normalized event coordinates */
|
|
122
|
-
pointer: THREE
|
|
100
|
+
pointer: THREE.Vector2
|
|
123
101
|
/** pointerId of the original event for multiple pointer events */
|
|
124
102
|
pointerId: number
|
|
125
103
|
/** Delta between first click and this event */
|
|
126
104
|
delta: number
|
|
127
105
|
/** The ray that pierced it */
|
|
128
|
-
ray: THREE
|
|
106
|
+
ray: THREE.Ray
|
|
129
107
|
/** The camera that was used by the raycaster */
|
|
130
108
|
camera: Camera
|
|
131
109
|
/** stopPropagation will stop underlying handlers from firing */
|
|
@@ -195,13 +173,13 @@ interface EventHandlers {
|
|
|
195
173
|
onVisible?: (visible: boolean) => void
|
|
196
174
|
}
|
|
197
175
|
|
|
198
|
-
type FilterFunction = (items: THREE
|
|
176
|
+
type FilterFunction = (items: THREE.Intersection[], state: RootState) => THREE.Intersection[]
|
|
199
177
|
type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
|
|
200
178
|
|
|
201
179
|
/** Configuration for XR pointer registration (controllers/hands) */
|
|
202
180
|
interface XRPointerConfig {
|
|
203
181
|
/** Ray origin (updated each frame by XR system) */
|
|
204
|
-
ray: THREE
|
|
182
|
+
ray: THREE.Ray
|
|
205
183
|
/** Optional: custom compute function for this pointer */
|
|
206
184
|
compute?: (state: RootState) => void
|
|
207
185
|
/** Pointer type identifier */
|
|
@@ -255,7 +233,7 @@ interface PointerCaptureTarget {
|
|
|
255
233
|
|
|
256
234
|
/** Entry in the visibility registry for tracking object visibility state */
|
|
257
235
|
interface VisibilityEntry {
|
|
258
|
-
object: THREE
|
|
236
|
+
object: THREE.Object3D
|
|
259
237
|
handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
|
|
260
238
|
lastFramedState: boolean | null
|
|
261
239
|
lastOccludedState: boolean | null
|
|
@@ -290,99 +268,15 @@ type FrameNextCallback = FrameCallback$1<RootState>
|
|
|
290
268
|
/** Alias for FrameNextCallback */
|
|
291
269
|
type FrameCallback = FrameNextCallback
|
|
292
270
|
|
|
293
|
-
//* Buffer Types (useBuffers) ========================================
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Buffer-like types for GPU compute and storage operations.
|
|
297
|
-
* Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
|
|
298
|
-
*
|
|
299
|
-
* @example
|
|
300
|
-
* ```tsx
|
|
301
|
-
* const { positions, velocities } = useBuffers(() => ({
|
|
302
|
-
* positions: instancedArray(count, 'vec3'), // StorageBufferNode
|
|
303
|
-
* velocities: new Float32Array(count * 3), // TypedArray
|
|
304
|
-
* }), 'particles')
|
|
305
|
-
* ```
|
|
306
|
-
*/
|
|
307
|
-
type BufferLike =
|
|
308
|
-
| Float32Array
|
|
309
|
-
| Uint32Array
|
|
310
|
-
| Int32Array
|
|
311
|
-
| Float64Array
|
|
312
|
-
| Uint8Array
|
|
313
|
-
| Int8Array
|
|
314
|
-
| Uint16Array
|
|
315
|
-
| Int16Array
|
|
316
|
-
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
317
|
-
| THREE$1.InterleavedBufferAttribute
|
|
318
|
-
| Node // TSL buffer nodes (instancedArray, storage)
|
|
319
|
-
|
|
320
|
-
/** Flat record of buffer-like values (no nested scopes) */
|
|
321
|
-
type BufferRecord = Record<string, BufferLike>
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Buffer store that can contain both root-level buffers and scoped buffer objects.
|
|
325
|
-
* Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
|
|
326
|
-
*/
|
|
327
|
-
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
328
|
-
|
|
329
|
-
//* Node Types (useNodes) ========================================
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
333
|
-
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
334
|
-
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
335
|
-
* and the shape the store holds are one type by construction.
|
|
336
|
-
*/
|
|
337
|
-
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
338
|
-
|
|
339
|
-
/** Flat record of TSL nodes (no nested scopes) */
|
|
340
|
-
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Node store that can contain both root-level nodes and scoped node objects.
|
|
344
|
-
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
345
|
-
*/
|
|
346
|
-
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
347
|
-
|
|
348
|
-
//* Storage Types (useGPUStorage) ========================================
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* GPU storage types for texture-based storage operations.
|
|
352
|
-
* Includes Three.js storage textures and TSL storage texture nodes.
|
|
353
|
-
*
|
|
354
|
-
* @example
|
|
355
|
-
* ```tsx
|
|
356
|
-
* const { heightMap } = useGPUStorage(() => ({
|
|
357
|
-
* heightMap: new StorageTexture(512, 512),
|
|
358
|
-
* }), 'terrain')
|
|
359
|
-
* ```
|
|
360
|
-
*/
|
|
361
|
-
type StorageLike =
|
|
362
|
-
| StorageTexture // 2D GPU storage texture
|
|
363
|
-
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
364
|
-
| StorageArrayTexture // 2D-array GPU storage texture
|
|
365
|
-
| Data3DTexture // 3D texture (can be used as storage)
|
|
366
|
-
| Node // TSL storage texture nodes (storageTexture)
|
|
367
|
-
|
|
368
|
-
/** Flat record of storage-like values (no nested scopes) */
|
|
369
|
-
type StorageRecord = Record<string, StorageLike>
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Storage store that can contain both root-level storage and scoped storage objects.
|
|
373
|
-
* Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
|
|
374
|
-
*/
|
|
375
|
-
type StorageStore = Record<string, StorageLike | StorageRecord>
|
|
376
|
-
|
|
377
271
|
//* Renderer Types ========================================
|
|
378
272
|
|
|
379
273
|
/** Default renderer type - union of WebGL and WebGPU renderers */
|
|
380
|
-
type R3FRenderer = THREE
|
|
274
|
+
type R3FRenderer = THREE.WebGLRenderer | WebGPURenderer
|
|
381
275
|
|
|
382
276
|
//* Core Store Types ========================================
|
|
383
277
|
|
|
384
278
|
type Subscription = {
|
|
385
|
-
ref: React
|
|
279
|
+
ref: React.RefObject<RenderCallback>
|
|
386
280
|
priority: number
|
|
387
281
|
store: RootStore
|
|
388
282
|
}
|
|
@@ -392,11 +286,11 @@ type PointerState = {
|
|
|
392
286
|
/** Objects currently hovered by this pointer */
|
|
393
287
|
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
394
288
|
/** Objects capturing this pointer */
|
|
395
|
-
captured: Map<THREE
|
|
289
|
+
captured: Map<THREE.Object3D, PointerCaptureTarget>
|
|
396
290
|
/** Initial click position [x, y] */
|
|
397
291
|
initialClick: [x: number, y: number]
|
|
398
292
|
/** Objects hit on initial click */
|
|
399
|
-
initialHits: THREE
|
|
293
|
+
initialHits: THREE.Object3D[]
|
|
400
294
|
}
|
|
401
295
|
|
|
402
296
|
type Dpr = number | [min: number, max: number]
|
|
@@ -439,36 +333,36 @@ interface Performance {
|
|
|
439
333
|
}
|
|
440
334
|
|
|
441
335
|
interface InternalState {
|
|
442
|
-
interaction: THREE
|
|
336
|
+
interaction: THREE.Object3D[]
|
|
443
337
|
subscribers: Subscription[]
|
|
444
338
|
/** Per-pointer state (hover, capture, click tracking) - replaces hovered, capturedMap, initialClick, initialHits */
|
|
445
339
|
pointerMap: Map<number, PointerState>
|
|
446
340
|
/** Pointers needing raycast this frame (used with frameTimedRaycasts) */
|
|
447
341
|
pointerDirty: Map<number, DomEvent>
|
|
448
342
|
/** Last event received (for events.update() compatibility) */
|
|
449
|
-
lastEvent: React
|
|
343
|
+
lastEvent: React.RefObject<DomEvent | null>
|
|
450
344
|
/** @deprecated Use pointerMap.get(pointerId).hovered instead */
|
|
451
345
|
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
452
346
|
/** @deprecated Use pointerMap.get(pointerId).captured instead */
|
|
453
|
-
capturedMap: Map<number, Map<THREE
|
|
347
|
+
capturedMap: Map<number, Map<THREE.Object3D, PointerCaptureTarget>>
|
|
454
348
|
/** @deprecated Use pointerMap.get(pointerId).initialClick instead */
|
|
455
349
|
initialClick: [x: number, y: number]
|
|
456
350
|
/** @deprecated Use pointerMap.get(pointerId).initialHits instead */
|
|
457
|
-
initialHits: THREE
|
|
351
|
+
initialHits: THREE.Object3D[]
|
|
458
352
|
/** Visibility event registry (onFramed, onOccluded, onVisible) */
|
|
459
353
|
visibilityRegistry: Map<string, VisibilityEntry>
|
|
460
354
|
/** Whether occlusion queries are enabled (WebGPU only) */
|
|
461
355
|
occlusionEnabled: boolean
|
|
462
356
|
/** Reference to the invisible occlusion observer mesh */
|
|
463
|
-
occlusionObserver: THREE
|
|
357
|
+
occlusionObserver: THREE.Mesh | null
|
|
464
358
|
/** Cached occlusion results from render pass - keyed by Object3D */
|
|
465
|
-
occlusionCache: Map<THREE
|
|
359
|
+
occlusionCache: Map<THREE.Object3D, boolean | null>
|
|
466
360
|
/** Internal helper group for R3F system objects (occlusion observer, etc.) */
|
|
467
|
-
helperGroup: THREE
|
|
361
|
+
helperGroup: THREE.Group | null
|
|
468
362
|
active: boolean
|
|
469
363
|
priority: number
|
|
470
364
|
frames: number
|
|
471
|
-
subscribe: (callback: React
|
|
365
|
+
subscribe: (callback: React.RefObject<RenderCallback>, priority: number, store: RootStore) => () => void
|
|
472
366
|
/** Internal renderer storage - use state.renderer or state.gl to access */
|
|
473
367
|
actualRenderer: R3FRenderer
|
|
474
368
|
/** Global scheduler reference (for useFrame hook) */
|
|
@@ -484,7 +378,7 @@ interface InternalState {
|
|
|
484
378
|
/** Function to unregister this root from the global scheduler */
|
|
485
379
|
unregisterRoot?: () => void
|
|
486
380
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
487
|
-
container?: THREE
|
|
381
|
+
container?: THREE.Object3D
|
|
488
382
|
/**
|
|
489
383
|
* The CanvasTarget this root sizes and renders through.
|
|
490
384
|
*
|
|
@@ -546,16 +440,17 @@ interface RootState {
|
|
|
546
440
|
/** Get current state */
|
|
547
441
|
get: StoreApi<RootState>['getState']
|
|
548
442
|
/**
|
|
549
|
-
*
|
|
443
|
+
* The store of the canvas that owns this root's renderer.
|
|
550
444
|
* - For primary/independent canvases: points to its own store (self-reference)
|
|
551
445
|
* - For secondary canvases: points to the primary canvas's store
|
|
446
|
+
* - Portals copy it from their parent
|
|
552
447
|
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
448
|
+
* Anything shared per renderer rather than per canvas (e.g. @react-three/tsl's resources)
|
|
449
|
+
* resolves through it.
|
|
555
450
|
*/
|
|
556
451
|
primaryStore: RootStore
|
|
557
452
|
/** @deprecated Use `renderer` instead. The instance of the renderer (typed as WebGLRenderer for backwards compat) */
|
|
558
|
-
gl: THREE
|
|
453
|
+
gl: THREE.WebGLRenderer
|
|
559
454
|
/** The renderer instance - type depends on entry point (WebGPU, Legacy, or union for default) */
|
|
560
455
|
renderer: R3FRenderer
|
|
561
456
|
/** Inspector of the webGPU Renderer. Init in the canvas */
|
|
@@ -564,27 +459,27 @@ interface RootState {
|
|
|
564
459
|
/** Default camera */
|
|
565
460
|
camera: ThreeCamera
|
|
566
461
|
/** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
|
|
567
|
-
frustum: THREE
|
|
462
|
+
frustum: THREE.Frustum
|
|
568
463
|
/** Whether to automatically update the frustum each frame (default: true) */
|
|
569
464
|
autoUpdateFrustum: boolean
|
|
570
465
|
/** Default scene (may be overridden in portals to point to the portal container) */
|
|
571
|
-
scene: THREE
|
|
466
|
+
scene: THREE.Scene
|
|
572
467
|
/** The actual root THREE.Scene - always points to the true scene, even inside portals */
|
|
573
|
-
rootScene: THREE
|
|
468
|
+
rootScene: THREE.Scene
|
|
574
469
|
/** Default raycaster */
|
|
575
|
-
raycaster: THREE
|
|
470
|
+
raycaster: THREE.Raycaster
|
|
576
471
|
/** Event layer interface, contains the event handler and the node they're connected to */
|
|
577
472
|
events: EventManager<any>
|
|
578
473
|
/** XR interface */
|
|
579
474
|
xr: XRManager
|
|
580
475
|
/** Currently used controls */
|
|
581
|
-
controls: THREE
|
|
476
|
+
controls: THREE.EventDispatcher | null
|
|
582
477
|
/** Normalized event coordinates */
|
|
583
|
-
pointer: THREE
|
|
478
|
+
pointer: THREE.Vector2
|
|
584
479
|
/** @deprecated Normalized event coordinates, use "pointer" instead! */
|
|
585
|
-
mouse: THREE
|
|
480
|
+
mouse: THREE.Vector2
|
|
586
481
|
/** Color space assigned to 8-bit input textures (color maps). Most textures are authored in sRGB. */
|
|
587
|
-
textureColorSpace: THREE
|
|
482
|
+
textureColorSpace: THREE.ColorSpace
|
|
588
483
|
/** Render loop flags */
|
|
589
484
|
frameloop: Frameloop
|
|
590
485
|
performance: Performance
|
|
@@ -594,7 +489,7 @@ interface RootState {
|
|
|
594
489
|
viewport: Viewport & {
|
|
595
490
|
getCurrentViewport: (
|
|
596
491
|
camera?: ThreeCamera,
|
|
597
|
-
target?: THREE
|
|
492
|
+
target?: THREE.Vector3 | Parameters<THREE.Vector3['set']>,
|
|
598
493
|
size?: Size,
|
|
599
494
|
) => Omit<Viewport, 'dpr' | 'initialDpr'>
|
|
600
495
|
}
|
|
@@ -614,24 +509,10 @@ interface RootState {
|
|
|
614
509
|
setError: (error: Error | null) => void
|
|
615
510
|
/** Current error state (null when no error) */
|
|
616
511
|
error: Error | null
|
|
617
|
-
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
618
|
-
uniforms: UniformStore
|
|
619
|
-
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
620
|
-
nodes: NodeStore
|
|
621
|
-
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
622
|
-
buffers: BufferStore
|
|
623
|
-
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
624
|
-
gpuStorage: StorageStore
|
|
625
512
|
/** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
|
|
626
|
-
textures: Map<string, THREE
|
|
513
|
+
textures: Map<string, THREE.Texture>
|
|
627
514
|
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
628
515
|
_textureRefs: Map<string, number>
|
|
629
|
-
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
630
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
631
|
-
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
632
|
-
passes: PassRecord
|
|
633
|
-
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
634
|
-
_hmrVersion: number
|
|
635
516
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
636
517
|
_sizeImperative: boolean
|
|
637
518
|
/** Internal: stored size props from Canvas for reset functionality */
|
|
@@ -657,934 +538,7 @@ interface RootState {
|
|
|
657
538
|
|
|
658
539
|
type RootStore = UseBoundStoreWithEqualityFn<StoreApi<RootState>>
|
|
659
540
|
|
|
660
|
-
|
|
661
|
-
* @fileoverview Internal Three.js re-exports - DEFAULT ENTRY
|
|
662
|
-
*
|
|
663
|
-
* This is the single source of truth for Three.js imports within R3F.
|
|
664
|
-
* All internal code should import from '#three' (or '../three' relative).
|
|
665
|
-
*
|
|
666
|
-
* DEFAULT behavior (root import):
|
|
667
|
-
* - Exports from three/webgpu (the new standard)
|
|
668
|
-
* - Also exports WebGLRenderer for backwards compatibility (with deprecation)
|
|
669
|
-
* - Both renderer types available, runtime decides which to use
|
|
670
|
-
*
|
|
671
|
-
* For explicit legacy or webgpu-only builds, use:
|
|
672
|
-
* - #three/legacy - WebGL only, no WebGPU
|
|
673
|
-
* - #three/webgpu - WebGPU only, no WebGL legacy
|
|
674
|
-
*/
|
|
675
|
-
declare const R3F_BUILD_LEGACY = true;
|
|
676
|
-
declare const R3F_BUILD_WEBGPU = true;
|
|
677
|
-
|
|
678
|
-
/** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
|
|
679
|
-
declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
|
|
680
|
-
|
|
681
|
-
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
682
|
-
__proto__: null,
|
|
683
|
-
CubeRenderTarget: CubeRenderTarget,
|
|
684
|
-
CubeRenderTargetCompat: CubeRenderTarget,
|
|
685
|
-
Inspector: Inspector,
|
|
686
|
-
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
687
|
-
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
688
|
-
RenderTargetCompat: RenderTarget,
|
|
689
|
-
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
690
|
-
WebGLRenderTarget: WebGLRenderTarget,
|
|
691
|
-
WebGLRenderer: WebGLRenderer,
|
|
692
|
-
WebGLRendererParameters: WebGLRendererParameters,
|
|
693
|
-
loadInspector: loadInspector
|
|
694
|
-
}, [three_webgpu]);
|
|
695
|
-
|
|
696
|
-
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
697
|
-
|
|
698
|
-
interface MathRepresentation {
|
|
699
|
-
set(...args: number[]): any
|
|
700
|
-
}
|
|
701
|
-
interface VectorRepresentation extends MathRepresentation {
|
|
702
|
-
setScalar(value: number): any
|
|
703
|
-
}
|
|
704
|
-
type MathTypes = MathRepresentation | Euler$1 | Color$1
|
|
705
|
-
|
|
706
|
-
type MathType<T extends MathTypes> = T extends Color$1
|
|
707
|
-
? Args<typeof Color$1> | ColorRepresentation
|
|
708
|
-
: T extends VectorRepresentation | Layers$1 | Euler$1
|
|
709
|
-
? T | MutableOrReadonlyParameters<T['set']> | number
|
|
710
|
-
: T | MutableOrReadonlyParameters<T['set']>
|
|
711
|
-
|
|
712
|
-
type MathProps<P> = {
|
|
713
|
-
[K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
type Vector2 = MathType<Vector2$1>
|
|
717
|
-
type Vector3 = MathType<Vector3$1>
|
|
718
|
-
type Vector4 = MathType<Vector4$1>
|
|
719
|
-
type Color = MathType<Color$1>
|
|
720
|
-
type Layers = MathType<Layers$1>
|
|
721
|
-
type Quaternion = MathType<Quaternion$1>
|
|
722
|
-
type Euler = MathType<Euler$1>
|
|
723
|
-
type Matrix3 = MathType<Matrix3$1>
|
|
724
|
-
type Matrix4 = MathType<Matrix4$1>
|
|
725
|
-
|
|
726
|
-
interface RaycastableRepresentation {
|
|
727
|
-
raycast(raycaster: Raycaster, intersects: Intersection$1[]): void
|
|
728
|
-
}
|
|
729
|
-
type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {}
|
|
730
|
-
|
|
731
|
-
/**
|
|
732
|
-
* Props for geometry transform methods that can be called with `once()`.
|
|
733
|
-
* These methods modify the geometry in-place and only make sense to call once on mount.
|
|
734
|
-
*
|
|
735
|
-
* @example
|
|
736
|
-
* import { once } from '@react-three/fiber'
|
|
737
|
-
*
|
|
738
|
-
* <boxGeometry args={[1, 1, 1]} rotateX={once(Math.PI / 2)} />
|
|
739
|
-
* <planeGeometry args={[10, 10]} translate={once(0, 0, 5)} />
|
|
740
|
-
* <bufferGeometry applyMatrix4={once(matrix)} center={once()} />
|
|
741
|
-
*/
|
|
742
|
-
interface GeometryTransformProps {
|
|
743
|
-
/** Rotate the geometry about the X axis (radians). Use with once(). */
|
|
744
|
-
rotateX?: number
|
|
745
|
-
/** Rotate the geometry about the Y axis (radians). Use with once(). */
|
|
746
|
-
rotateY?: number
|
|
747
|
-
/** Rotate the geometry about the Z axis (radians). Use with once(). */
|
|
748
|
-
rotateZ?: number
|
|
749
|
-
/** Translate the geometry (x, y, z). Use with once(). */
|
|
750
|
-
translate?: [x: number, y: number, z: number]
|
|
751
|
-
/** Scale the geometry (x, y, z). Use with once(). */
|
|
752
|
-
scale?: [x: number, y: number, z: number]
|
|
753
|
-
/** Center the geometry based on bounding box. Use with once(). */
|
|
754
|
-
center?: true
|
|
755
|
-
/** Apply a Matrix4 transformation. Use with once(). */
|
|
756
|
-
applyMatrix4?: Matrix4$1
|
|
757
|
-
/** Apply a Quaternion rotation. Use with once(). */
|
|
758
|
-
applyQuaternion?: Quaternion$1
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
type GeometryProps<P> = P extends BufferGeometry ? GeometryTransformProps : {}
|
|
762
|
-
|
|
763
|
-
/**
|
|
764
|
-
* Workaround for @types/three TSL node type issues.
|
|
765
|
-
* The Node base class has properties that subclasses (OperatorNode, ConstNode, etc.) don't inherit.
|
|
766
|
-
* This transforms `Node | null` properties to accept any object with node-like shape.
|
|
767
|
-
*/
|
|
768
|
-
type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
769
|
-
|
|
770
|
-
/**
|
|
771
|
-
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
772
|
-
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
773
|
-
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
774
|
-
*/
|
|
775
|
-
type NodeProps<P> = {
|
|
776
|
-
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
interface ReactProps<P> {
|
|
780
|
-
children?: React.ReactNode
|
|
781
|
-
ref?: React.Ref<P>
|
|
782
|
-
key?: React.Key
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<
|
|
786
|
-
Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P> & GeometryProps<P> & NodeProps<P>>
|
|
787
|
-
>
|
|
788
|
-
|
|
789
|
-
type ThreeElement<T extends ConstructorRepresentation> = Mutable<
|
|
790
|
-
Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>
|
|
791
|
-
>
|
|
792
|
-
|
|
793
|
-
type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
794
|
-
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
798
|
-
type Object3DMethod = NonNullable<
|
|
799
|
-
{
|
|
800
|
-
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
801
|
-
}[keyof Object3D]
|
|
802
|
-
>
|
|
803
|
-
|
|
804
|
-
type ThreeExports = typeof THREE
|
|
805
|
-
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
806
|
-
|
|
807
|
-
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
808
|
-
/**
|
|
809
|
-
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
810
|
-
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
811
|
-
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
812
|
-
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
813
|
-
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
814
|
-
*/
|
|
815
|
-
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
816
|
-
object: object
|
|
817
|
-
ref?: React.Ref<any>
|
|
818
|
-
[prop: string]: unknown
|
|
819
|
-
}
|
|
820
|
-
// Conflicts with DOM types can be accessed through a three* prefix
|
|
821
|
-
threeAudio: ThreeElementsImpl['audio']
|
|
822
|
-
threeSource: ThreeElementsImpl['source']
|
|
823
|
-
threeLine: ThreeElementsImpl['line']
|
|
824
|
-
threePath: ThreeElementsImpl['path']
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
declare module 'react' {
|
|
828
|
-
namespace JSX {
|
|
829
|
-
interface IntrinsicElements extends ThreeElements {}
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
declare module 'react/jsx-runtime' {
|
|
834
|
-
namespace JSX {
|
|
835
|
-
interface IntrinsicElements extends ThreeElements {}
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
declare module 'react/jsx-dev-runtime' {
|
|
840
|
-
namespace JSX {
|
|
841
|
-
interface IntrinsicElements extends ThreeElements {}
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
//* Base Renderer Types =====================================
|
|
846
|
-
|
|
847
|
-
// Shim for OffscreenCanvas since it was removed from DOM types
|
|
848
|
-
interface OffscreenCanvas extends EventTarget {}
|
|
849
|
-
|
|
850
|
-
interface BaseRendererProps {
|
|
851
|
-
canvas: HTMLCanvasElement | OffscreenCanvas
|
|
852
|
-
powerPreference?: 'high-performance' | 'low-power' | 'default'
|
|
853
|
-
antialias?: boolean
|
|
854
|
-
alpha?: boolean
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
type RendererFactory<TRenderer, TParams> =
|
|
858
|
-
| TRenderer
|
|
859
|
-
| ((defaultProps: TParams) => TRenderer)
|
|
860
|
-
| ((defaultProps: TParams) => Promise<TRenderer>)
|
|
861
|
-
|
|
862
|
-
interface Renderer {
|
|
863
|
-
render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
//* Color Management Config ==============================
|
|
867
|
-
|
|
868
|
-
/**
|
|
869
|
-
* Color management configuration shared by both WebGL and WebGPU renderers.
|
|
870
|
-
*/
|
|
871
|
-
interface ColorManagementConfig {
|
|
872
|
-
/**
|
|
873
|
-
* Color space assigned to 8-bit input textures (color maps).
|
|
874
|
-
* Defaults to sRGB. Most textures are authored in sRGB.
|
|
875
|
-
* @default THREE.SRGBColorSpace
|
|
876
|
-
*/
|
|
877
|
-
textureColorSpace?: THREE$1.ColorSpace
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
//* WebGL Renderer Props ==============================
|
|
881
|
-
|
|
882
|
-
type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
|
|
883
|
-
canvas: HTMLCanvasElement | OffscreenCanvas
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
type GLProps =
|
|
887
|
-
| Renderer
|
|
888
|
-
| ((defaultProps: DefaultGLProps) => Renderer)
|
|
889
|
-
| ((defaultProps: DefaultGLProps) => Promise<Renderer>)
|
|
890
|
-
| (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
|
|
891
|
-
|
|
892
|
-
//* WebGPU Renderer Props ==============================
|
|
893
|
-
|
|
894
|
-
type DefaultRendererProps = {
|
|
895
|
-
canvas: HTMLCanvasElement | OffscreenCanvas
|
|
896
|
-
[key: string]: any
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
/**
|
|
900
|
-
* Canvas-level scheduler configuration.
|
|
901
|
-
* Controls render timing relative to other canvases.
|
|
902
|
-
*/
|
|
903
|
-
interface CanvasSchedulerConfig {
|
|
904
|
-
/**
|
|
905
|
-
* Run this Canvas root before the referenced Canvas root id(s).
|
|
906
|
-
*/
|
|
907
|
-
before?: string | string[]
|
|
908
|
-
/**
|
|
909
|
-
* Run this Canvas root after the referenced Canvas root id(s).
|
|
910
|
-
*/
|
|
911
|
-
after?: string | string[]
|
|
912
|
-
/**
|
|
913
|
-
* Numeric root order. Lower values run first.
|
|
914
|
-
*/
|
|
915
|
-
order?: number
|
|
916
|
-
/**
|
|
917
|
-
* Limit this Canvas's default render job (frames per second).
|
|
918
|
-
*/
|
|
919
|
-
fps?: number
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
/**
|
|
923
|
-
* Extended renderer configuration for multi-canvas support and color management.
|
|
924
|
-
*/
|
|
925
|
-
interface RendererConfigExtended extends ColorManagementConfig {
|
|
926
|
-
/** Share renderer from another canvas (WebGPU only) */
|
|
927
|
-
primaryCanvas?: string
|
|
928
|
-
/** Canvas-level scheduler options */
|
|
929
|
-
scheduler?: CanvasSchedulerConfig
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
type RendererProps =
|
|
933
|
-
| any // WebGPURenderer
|
|
934
|
-
| ((defaultProps: DefaultRendererProps) => any)
|
|
935
|
-
| ((defaultProps: DefaultRendererProps) => Promise<any>)
|
|
936
|
-
| (Partial<Properties<any> | Record<string, any>> & RendererConfigExtended)
|
|
937
|
-
|
|
938
|
-
//* Camera Props ==============================
|
|
939
|
-
|
|
940
|
-
type CameraProps = (
|
|
941
|
-
| THREE$1.Camera
|
|
942
|
-
| Partial<
|
|
943
|
-
ThreeElement<typeof THREE$1.Camera> &
|
|
944
|
-
ThreeElement<typeof THREE$1.PerspectiveCamera> &
|
|
945
|
-
ThreeElement<typeof THREE$1.OrthographicCamera>
|
|
946
|
-
>
|
|
947
|
-
) & {
|
|
948
|
-
/** Flags the camera as manual, putting projection into your own hands */
|
|
949
|
-
manual?: boolean
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
//* Render Props ==============================
|
|
953
|
-
|
|
954
|
-
interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
|
|
955
|
-
/**
|
|
956
|
-
* Unique identifier for multi-canvas renderer sharing.
|
|
957
|
-
* Makes this canvas targetable by other canvases using the `primaryCanvas` prop.
|
|
958
|
-
* Also sets the HTML `id` attribute on the canvas element.
|
|
959
|
-
* @example <Canvas id="main-viewer">...</Canvas>
|
|
960
|
-
*/
|
|
961
|
-
id?: string
|
|
962
|
-
/**
|
|
963
|
-
* Share the renderer from another canvas instead of creating a new one.
|
|
964
|
-
* Pass the `id` of the primary canvas to share its WebGPURenderer.
|
|
965
|
-
* Only available with WebGPU (not legacy WebGL).
|
|
966
|
-
*
|
|
967
|
-
* Note: This is extracted from `renderer={{ primaryCanvas: "id" }}` by Canvas.
|
|
968
|
-
* @internal
|
|
969
|
-
*/
|
|
970
|
-
primaryCanvas?: string
|
|
971
|
-
/**
|
|
972
|
-
* Canvas-level scheduler options. Controls render timing relative to other canvases.
|
|
973
|
-
*
|
|
974
|
-
* Note: This is extracted from `renderer={{ scheduler: {...} }}` by Canvas.
|
|
975
|
-
* @internal
|
|
976
|
-
*/
|
|
977
|
-
scheduler?: CanvasSchedulerConfig
|
|
978
|
-
/** A threejs renderer instance or props that go into the default renderer */
|
|
979
|
-
gl?: GLProps
|
|
980
|
-
/** A WebGPU renderer instance or props that go into the default renderer */
|
|
981
|
-
renderer?: RendererProps
|
|
982
|
-
/** Dimensions to fit the renderer to. Will measure canvas dimensions if omitted */
|
|
983
|
-
size?: Size
|
|
984
|
-
/**
|
|
985
|
-
* Enables shadows (by default PCFsoft). Can accept `gl.shadowMap` options for fine-tuning,
|
|
986
|
-
* but also strings: 'basic' | 'percentage' | 'soft' | 'variance'.
|
|
987
|
-
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
988
|
-
*/
|
|
989
|
-
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
|
|
990
|
-
/** Creates an orthographic camera */
|
|
991
|
-
orthographic?: boolean
|
|
992
|
-
/**
|
|
993
|
-
* R3F's render mode. Set to `demand` to only render on state change or `never` to take control.
|
|
994
|
-
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#on-demand-rendering
|
|
995
|
-
*/
|
|
996
|
-
frameloop?: Frameloop
|
|
997
|
-
/**
|
|
998
|
-
* R3F performance options for adaptive performance.
|
|
999
|
-
* @see https://docs.pmnd.rs/react-three-fiber/advanced/scaling-performance#movement-regression
|
|
1000
|
-
*/
|
|
1001
|
-
performance?: Partial<Omit<Performance, 'regress'>>
|
|
1002
|
-
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
1003
|
-
dpr?: Dpr
|
|
1004
|
-
/**
|
|
1005
|
-
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
1006
|
-
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
1007
|
-
*/
|
|
1008
|
-
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
1009
|
-
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
1010
|
-
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
1011
|
-
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
1012
|
-
camera?: CameraProps
|
|
1013
|
-
/** An R3F event manager to manage elements' pointer events */
|
|
1014
|
-
events?: (store: RootStore) => EventManager<Element>
|
|
1015
|
-
/** Callback after the canvas has rendered (but not yet committed) */
|
|
1016
|
-
onCreated?: (state: RootState) => void
|
|
1017
|
-
/** Response for pointer clicks that have missed any target */
|
|
1018
|
-
onPointerMissed?: (event: MouseEvent) => void
|
|
1019
|
-
/** Response for dragover events that have missed any target */
|
|
1020
|
-
onDragOverMissed?: (event: DragEvent) => void
|
|
1021
|
-
/** Response for drop events that have missed any target */
|
|
1022
|
-
onDropMissed?: (event: DragEvent) => void
|
|
1023
|
-
/** Whether to automatically update the frustum each frame (default: true) */
|
|
1024
|
-
autoUpdateFrustum?: boolean
|
|
1025
|
-
/**
|
|
1026
|
-
* Enable WebGPU occlusion queries for onOccluded/onVisible events.
|
|
1027
|
-
* Auto-enabled when any object uses onOccluded or onVisible handlers.
|
|
1028
|
-
* Only works with WebGPU renderer - WebGL will log a warning.
|
|
1029
|
-
*/
|
|
1030
|
-
occlusion?: boolean
|
|
1031
|
-
/** Internal: stored size props from Canvas for reset functionality */
|
|
1032
|
-
_sizeProps?: { width?: number; height?: number } | null
|
|
1033
|
-
/** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
|
|
1034
|
-
forceEven?: boolean
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
//* Reconciler Root ==============================
|
|
1038
|
-
|
|
1039
|
-
interface ReconcilerRoot<TCanvas extends HTMLCanvasElement | OffscreenCanvas> {
|
|
1040
|
-
configure: (config?: RenderProps<TCanvas>) => Promise<ReconcilerRoot<TCanvas>>
|
|
1041
|
-
render: (element: ReactNode) => RootStore
|
|
1042
|
-
unmount: () => void
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
//* Inject State ==============================
|
|
1046
|
-
|
|
1047
|
-
type InjectState = Partial<
|
|
1048
|
-
Omit<RootState, 'events'> & {
|
|
1049
|
-
events?: {
|
|
1050
|
-
enabled?: boolean
|
|
1051
|
-
priority?: number
|
|
1052
|
-
compute?: ComputeFunction
|
|
1053
|
-
connected?: any
|
|
1054
|
-
}
|
|
1055
|
-
/**
|
|
1056
|
-
* When true (default), injects a THREE.Scene between container and children if container isn't already a Scene.
|
|
1057
|
-
* This ensures state.scene is always a real THREE.Scene with proper properties (background, environment, fog).
|
|
1058
|
-
* Set to false to use the container directly as scene (anti-pattern, but supported for edge cases).
|
|
1059
|
-
*/
|
|
1060
|
-
injectScene?: boolean
|
|
1061
|
-
}
|
|
1062
|
-
>
|
|
1063
|
-
|
|
1064
|
-
//* Reconciler Types ==============================
|
|
1065
|
-
|
|
1066
|
-
// FiberRoot is an opaque internal React type - we define it locally
|
|
1067
|
-
// to avoid bundling @types/react-reconciler which causes absolute path issues
|
|
1068
|
-
type FiberRoot = any
|
|
1069
|
-
|
|
1070
|
-
interface Root {
|
|
1071
|
-
fiber: FiberRoot
|
|
1072
|
-
store: RootStore
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
type AttachFnType<O = any> = (parent: any, self: O) => () => void
|
|
1076
|
-
type AttachType<O = any> = string | AttachFnType<O>
|
|
1077
|
-
|
|
1078
|
-
type ConstructorRepresentation<T = any> = new (...args: any[]) => T
|
|
1079
|
-
|
|
1080
|
-
interface Catalogue {
|
|
1081
|
-
[name: string]: ConstructorRepresentation
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
// TODO: handle constructor overloads
|
|
1085
|
-
// https://github.com/pmndrs/react-three-fiber/pull/2931
|
|
1086
|
-
// https://github.com/microsoft/TypeScript/issues/37079
|
|
1087
|
-
type Args<T> = T extends ConstructorRepresentation
|
|
1088
|
-
? T extends typeof Color$2
|
|
1089
|
-
? [r: number, g: number, b: number] | [color: ColorRepresentation$1]
|
|
1090
|
-
: ConstructorParameters<T>
|
|
1091
|
-
: any[]
|
|
1092
|
-
|
|
1093
|
-
type ArgsProp<P> = P extends ConstructorRepresentation
|
|
1094
|
-
? IsAllOptional<ConstructorParameters<P>> extends true
|
|
1095
|
-
? { args?: Args<P> }
|
|
1096
|
-
: { args: Args<P> }
|
|
1097
|
-
: { args: unknown[] }
|
|
1098
|
-
|
|
1099
|
-
type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
1100
|
-
object?: T
|
|
1101
|
-
dispose?: null
|
|
1102
|
-
attach?: AttachType<T>
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
interface Instance<O = any> {
|
|
1106
|
-
root: RootStore
|
|
1107
|
-
type: string
|
|
1108
|
-
parent: Instance | null
|
|
1109
|
-
children: Instance[]
|
|
1110
|
-
props: InstanceProps<O> & Record<string, unknown>
|
|
1111
|
-
object: O & { __r3f?: Instance<O> }
|
|
1112
|
-
eventCount: number
|
|
1113
|
-
handlers: Partial<EventHandlers>
|
|
1114
|
-
attach?: AttachType<O>
|
|
1115
|
-
previousAttach?: any
|
|
1116
|
-
isHidden: boolean
|
|
1117
|
-
/** Set of props that have been applied via once() */
|
|
1118
|
-
appliedOnce?: Set<string>
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
interface HostConfig {
|
|
1122
|
-
type: string
|
|
1123
|
-
props: Instance['props']
|
|
1124
|
-
container: RootStore
|
|
1125
|
-
instance: Instance
|
|
1126
|
-
textInstance: void
|
|
1127
|
-
suspenseInstance: Instance
|
|
1128
|
-
hydratableInstance: never
|
|
1129
|
-
formInstance: never
|
|
1130
|
-
publicInstance: Instance['object']
|
|
1131
|
-
hostContext: {}
|
|
1132
|
-
childSet: never
|
|
1133
|
-
timeoutHandle: number | undefined
|
|
1134
|
-
noTimeout: -1
|
|
1135
|
-
TransitionStatus: null
|
|
1136
|
-
}
|
|
1137
|
-
declare global {
|
|
1138
|
-
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
//* Loop Types ==============================
|
|
1142
|
-
|
|
1143
|
-
type GlobalRenderCallback = (timestamp: number) => void
|
|
1144
|
-
|
|
1145
|
-
type GlobalEffectType = 'before' | 'after' | 'tail'
|
|
1146
|
-
|
|
1147
|
-
declare const presetsObj: {
|
|
1148
|
-
apartment: string;
|
|
1149
|
-
city: string;
|
|
1150
|
-
dawn: string;
|
|
1151
|
-
forest: string;
|
|
1152
|
-
lobby: string;
|
|
1153
|
-
night: string;
|
|
1154
|
-
park: string;
|
|
1155
|
-
studio: string;
|
|
1156
|
-
sunset: string;
|
|
1157
|
-
warehouse: string;
|
|
1158
|
-
};
|
|
1159
|
-
type PresetsType = keyof typeof presetsObj;
|
|
1160
|
-
|
|
1161
|
-
//* Background Types ==============================
|
|
1162
|
-
|
|
1163
|
-
/**
|
|
1164
|
-
* Expanded object form for background configuration.
|
|
1165
|
-
* Allows separate textures for background (visual backdrop) and environment (PBR lighting).
|
|
1166
|
-
*/
|
|
1167
|
-
interface BackgroundConfig {
|
|
1168
|
-
/** HDRI preset name: 'apartment', 'city', 'dawn', 'forest', 'lobby', 'night', 'park', 'studio', 'sunset', 'warehouse' */
|
|
1169
|
-
preset?: PresetsType
|
|
1170
|
-
/** Files for cube texture (6 faces) or single HDR/EXR */
|
|
1171
|
-
files?: string | string[]
|
|
1172
|
-
/** Separate files for scene.background (visual backdrop) */
|
|
1173
|
-
backgroundMap?: string | string[]
|
|
1174
|
-
backgroundRotation?: Euler$2 | [number, number, number]
|
|
1175
|
-
backgroundBlurriness?: number
|
|
1176
|
-
backgroundIntensity?: number
|
|
1177
|
-
/** Separate files for scene.environment (PBR lighting/reflections) */
|
|
1178
|
-
envMap?: string | string[]
|
|
1179
|
-
environmentRotation?: Euler$2 | [number, number, number]
|
|
1180
|
-
environmentIntensity?: number
|
|
1181
|
-
path?: string
|
|
1182
|
-
extensions?: (loader: Loader) => void
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
/**
|
|
1186
|
-
* Background prop type for Canvas.
|
|
1187
|
-
*
|
|
1188
|
-
* String detection priority:
|
|
1189
|
-
* 1. Preset - exact match against known presets (apartment, city, dawn, forest, lobby, night, park, studio, sunset, warehouse)
|
|
1190
|
-
* 2. URL - starts with /, ./, ../, http://, https://, OR has image extension
|
|
1191
|
-
* 3. Color - default fallback (CSS color names, hex values, rgb(), etc.)
|
|
1192
|
-
*
|
|
1193
|
-
* @example Color
|
|
1194
|
-
* ```tsx
|
|
1195
|
-
* <Canvas background="red" />
|
|
1196
|
-
* <Canvas background="#ff0000" />
|
|
1197
|
-
* <Canvas background={0xff0000} />
|
|
1198
|
-
* ```
|
|
1199
|
-
*
|
|
1200
|
-
* @example Preset
|
|
1201
|
-
* ```tsx
|
|
1202
|
-
* <Canvas background="city" />
|
|
1203
|
-
* ```
|
|
1204
|
-
*
|
|
1205
|
-
* @example URL
|
|
1206
|
-
* ```tsx
|
|
1207
|
-
* <Canvas background="/path/to/env.hdr" />
|
|
1208
|
-
* <Canvas background="./sky.jpg" />
|
|
1209
|
-
* ```
|
|
1210
|
-
*
|
|
1211
|
-
* @example Object form
|
|
1212
|
-
* ```tsx
|
|
1213
|
-
* <Canvas background={{
|
|
1214
|
-
* files: ['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png'],
|
|
1215
|
-
* backgroundMap: 'path/to/sky.jpg',
|
|
1216
|
-
* envMap: 'path/to/lighting.hdr',
|
|
1217
|
-
* backgroundBlurriness: 0.5,
|
|
1218
|
-
* }} />
|
|
1219
|
-
* ```
|
|
1220
|
-
*/
|
|
1221
|
-
type BackgroundProp =
|
|
1222
|
-
| ColorRepresentation$1 // "red", "#ff0000", 0xff0000
|
|
1223
|
-
| string // URL or preset
|
|
1224
|
-
| BackgroundConfig // Expanded object form
|
|
1225
|
-
|
|
1226
|
-
//* Canvas Types ==============================
|
|
1227
|
-
|
|
1228
|
-
interface CanvasProps
|
|
1229
|
-
extends
|
|
1230
|
-
Omit<RenderProps<HTMLCanvasElement>, 'size' | 'primaryCanvas' | 'scheduler'>,
|
|
1231
|
-
React$1.HTMLAttributes<HTMLDivElement> {
|
|
1232
|
-
children?: React$1.ReactNode
|
|
1233
|
-
ref?: React$1.Ref<HTMLCanvasElement>
|
|
1234
|
-
/** Canvas fallback content, similar to img's alt prop */
|
|
1235
|
-
fallback?: React$1.ReactNode
|
|
1236
|
-
/**
|
|
1237
|
-
* Options to pass to useMeasure.
|
|
1238
|
-
* @see https://github.com/pmndrs/react-use-measure#api
|
|
1239
|
-
*/
|
|
1240
|
-
resize?: Options
|
|
1241
|
-
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1242
|
-
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1243
|
-
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1244
|
-
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1245
|
-
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
1246
|
-
hmr?: boolean
|
|
1247
|
-
/** Canvas resolution width in pixels. If omitted, uses container width. */
|
|
1248
|
-
width?: number
|
|
1249
|
-
/** Canvas resolution height in pixels. If omitted, uses container height. */
|
|
1250
|
-
height?: number
|
|
1251
|
-
/** Force canvas dimensions to even numbers (fixes Safari rendering issues with odd/fractional sizes) */
|
|
1252
|
-
forceEven?: boolean
|
|
1253
|
-
/**
|
|
1254
|
-
* Scene background configuration.
|
|
1255
|
-
* Accepts colors, URLs, presets, or an expanded object for separate background/environment.
|
|
1256
|
-
* @see BackgroundProp for full documentation and examples
|
|
1257
|
-
*/
|
|
1258
|
-
background?: BackgroundProp
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
//* Loader Types ==============================
|
|
1262
|
-
|
|
1263
|
-
type InputLike = string | string[] | string[][] | Readonly<string | string[] | string[][]>
|
|
1264
|
-
|
|
1265
|
-
// Define a loader-like interface that matches THREE.Loader's load signature
|
|
1266
|
-
// This works for both generic and non-generic THREE.Loader instances
|
|
1267
|
-
interface LoaderLike {
|
|
1268
|
-
load(
|
|
1269
|
-
url: InputLike,
|
|
1270
|
-
onLoad?: (result: any) => void,
|
|
1271
|
-
onProgress?: (event: ProgressEvent<EventTarget>) => void,
|
|
1272
|
-
onError?: (error: unknown) => void,
|
|
1273
|
-
): any
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
type GLTFLike = { scene: THREE$1.Object3D }
|
|
1277
|
-
|
|
1278
|
-
type LoaderInstance<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
|
|
1279
|
-
T extends ConstructorRepresentation<LoaderLike> ? InstanceType<T> : T
|
|
1280
|
-
|
|
1281
|
-
// Infer result type from the load method's callback parameter
|
|
1282
|
-
type InferLoadResult<T> = T extends {
|
|
1283
|
-
load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
|
|
1284
|
-
}
|
|
1285
|
-
? R
|
|
1286
|
-
: T extends ConstructorRepresentation<any>
|
|
1287
|
-
? InstanceType<T> extends {
|
|
1288
|
-
load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
|
|
1289
|
-
}
|
|
1290
|
-
? R
|
|
1291
|
-
: any
|
|
1292
|
-
: any
|
|
1293
|
-
|
|
1294
|
-
type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
|
|
1295
|
-
InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
|
|
1296
|
-
|
|
1297
|
-
type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
|
|
1298
|
-
loader: LoaderInstance<T>,
|
|
1299
|
-
) => void
|
|
1300
|
-
|
|
1301
|
-
//* Renderer Props ========================================
|
|
1302
|
-
|
|
1303
|
-
type WebGLDefaultProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & BaseRendererProps
|
|
1304
|
-
|
|
1305
|
-
type WebGLProps =
|
|
1306
|
-
| RendererFactory<THREE$1.WebGLRenderer, WebGLDefaultProps>
|
|
1307
|
-
| Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
|
|
1308
|
-
|
|
1309
|
-
interface WebGLShadowConfig {
|
|
1310
|
-
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
//* Legacy-specific Types ========================================
|
|
1314
|
-
|
|
1315
|
-
/** Legacy (WebGL) renderer type - re-exported as R3FRenderer from @react-three/fiber/legacy */
|
|
1316
|
-
type LegacyRenderer = THREE$1.WebGLRenderer
|
|
1317
|
-
|
|
1318
|
-
/** Legacy internal state with narrowed renderer type */
|
|
1319
|
-
interface LegacyInternalState extends Omit<InternalState, 'actualRenderer'> {
|
|
1320
|
-
actualRenderer: THREE$1.WebGLRenderer
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
/**
|
|
1324
|
-
* Legacy-specific RootState with narrowed renderer type.
|
|
1325
|
-
* Automatically used when importing from `@react-three/fiber/legacy`.
|
|
1326
|
-
*
|
|
1327
|
-
* @example
|
|
1328
|
-
* ```tsx
|
|
1329
|
-
* import { useThree } from '@react-three/fiber/legacy'
|
|
1330
|
-
*
|
|
1331
|
-
* function MyComponent() {
|
|
1332
|
-
* const { renderer } = useThree()
|
|
1333
|
-
* // renderer is typed as THREE.WebGLRenderer
|
|
1334
|
-
* renderer.shadowMap.enabled = true
|
|
1335
|
-
* }
|
|
1336
|
-
* ```
|
|
1337
|
-
*/
|
|
1338
|
-
interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
1339
|
-
/** The WebGL renderer instance */
|
|
1340
|
-
renderer: THREE$1.WebGLRenderer
|
|
1341
|
-
/** Internals with WebGL renderer */
|
|
1342
|
-
internal: LegacyInternalState
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
//* RenderTarget Types ==============================
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
type RenderTargetOptions = RenderTargetOptions$1
|
|
1349
|
-
|
|
1350
|
-
//* Global TSL Types ==============================
|
|
1351
|
-
|
|
1352
|
-
declare global {
|
|
1353
|
-
/**
|
|
1354
|
-
* Broad callable-node fallback for dynamic store readers.
|
|
1355
|
-
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1356
|
-
*/
|
|
1357
|
-
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1358
|
-
readonly shaderNode: unknown
|
|
1359
|
-
readonly id: number
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1363
|
-
type LegacyTSLNodeLike = {
|
|
1364
|
-
label?: ((label: string) => unknown) | string
|
|
1365
|
-
setName?: (name: string) => unknown
|
|
1366
|
-
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1367
|
-
|
|
1368
|
-
/** Node type accepted by broad dynamic node-store readers. */
|
|
1369
|
-
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1370
|
-
|
|
1371
|
-
/**
|
|
1372
|
-
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1373
|
-
* Existing InputNode generics take precedence over structural value normalization.
|
|
1374
|
-
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1375
|
-
* InputNode base with its concrete InputNode specialization.
|
|
1376
|
-
*/
|
|
1377
|
-
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1378
|
-
? TNodeType
|
|
1379
|
-
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1380
|
-
? TNodeType
|
|
1381
|
-
: T extends number
|
|
1382
|
-
? 'float'
|
|
1383
|
-
: T extends boolean
|
|
1384
|
-
? 'bool'
|
|
1385
|
-
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1386
|
-
? 'color'
|
|
1387
|
-
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1388
|
-
? 'vec4'
|
|
1389
|
-
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1390
|
-
? 'vec3'
|
|
1391
|
-
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1392
|
-
? 'vec2'
|
|
1393
|
-
: T extends three_webgpu.Matrix4
|
|
1394
|
-
? 'mat4'
|
|
1395
|
-
: T extends three_webgpu.Matrix3
|
|
1396
|
-
? 'mat3'
|
|
1397
|
-
: T extends three_webgpu.Matrix2
|
|
1398
|
-
? 'mat2'
|
|
1399
|
-
: unknown
|
|
1400
|
-
|
|
1401
|
-
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1402
|
-
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1403
|
-
? TValue
|
|
1404
|
-
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1405
|
-
? TValue
|
|
1406
|
-
: T extends string | { r: number; g: number; b: number }
|
|
1407
|
-
? three_webgpu.Color
|
|
1408
|
-
: T extends { x: number; y: number; z: number; w: number }
|
|
1409
|
-
? three_webgpu.Vector4
|
|
1410
|
-
: T extends { x: number; y: number; z: number }
|
|
1411
|
-
? three_webgpu.Vector3
|
|
1412
|
-
: T extends { x: number; y: number }
|
|
1413
|
-
? three_webgpu.Vector2
|
|
1414
|
-
: T extends number
|
|
1415
|
-
? number
|
|
1416
|
-
: T extends boolean
|
|
1417
|
-
? boolean
|
|
1418
|
-
: T
|
|
1419
|
-
|
|
1420
|
-
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1421
|
-
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1422
|
-
|
|
1423
|
-
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1424
|
-
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1425
|
-
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
/** Backward-compatible single-parameter uniform alias. */
|
|
1429
|
-
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1430
|
-
|
|
1431
|
-
/** Flat record of uniform nodes (no nested scopes) */
|
|
1432
|
-
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
1433
|
-
|
|
1434
|
-
/**
|
|
1435
|
-
* Uniform store that can contain both root-level uniforms and scoped uniform objects
|
|
1436
|
-
* Used by state.uniforms which has structure like:
|
|
1437
|
-
* { uTime: UniformNode, player: { uHealth: UniformNode }, enemy: { uHealth: UniformNode } }
|
|
1438
|
-
*/
|
|
1439
|
-
type UniformStore = Record<string, UniformNode | UniformRecord>
|
|
1440
|
-
|
|
1441
|
-
/**
|
|
1442
|
-
* Helper to safely access a uniform node from the store.
|
|
1443
|
-
* Use this when accessing state.uniforms to get proper typing.
|
|
1444
|
-
* @example
|
|
1445
|
-
* const uTime = uniforms.uTime as UniformNode<number>
|
|
1446
|
-
* const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
|
|
1447
|
-
*/
|
|
1448
|
-
type GetUniform<T = unknown> = UniformNode<T>
|
|
1449
|
-
|
|
1450
|
-
/**
|
|
1451
|
-
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1452
|
-
* Supports:
|
|
1453
|
-
* - Primitives: number, string (color), boolean
|
|
1454
|
-
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1455
|
-
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1456
|
-
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1457
|
-
* - UniformNode: existing uniforms (reused as-is)
|
|
1458
|
-
*/
|
|
1459
|
-
type UniformValue =
|
|
1460
|
-
| number
|
|
1461
|
-
| string
|
|
1462
|
-
| boolean
|
|
1463
|
-
| three_webgpu.Color
|
|
1464
|
-
| three_webgpu.Vector2
|
|
1465
|
-
| three_webgpu.Vector3
|
|
1466
|
-
| three_webgpu.Vector4
|
|
1467
|
-
| three_webgpu.Matrix2
|
|
1468
|
-
| three_webgpu.Matrix3
|
|
1469
|
-
| three_webgpu.Matrix4
|
|
1470
|
-
| { x: number; y: number }
|
|
1471
|
-
| { x: number; y: number; z: number }
|
|
1472
|
-
| { x: number; y: number; z: number; w: number }
|
|
1473
|
-
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1474
|
-
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1475
|
-
| UniformNode
|
|
1476
|
-
|
|
1477
|
-
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1478
|
-
type UniformInputRecord = Record<string, UniformValue>
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
declare global {
|
|
1482
|
-
/**
|
|
1483
|
-
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1484
|
-
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1485
|
-
* is r185, so the new name is the only one.
|
|
1486
|
-
*/
|
|
1487
|
-
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1488
|
-
|
|
1489
|
-
/**
|
|
1490
|
-
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1491
|
-
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1492
|
-
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1493
|
-
*/
|
|
1494
|
-
type ScenePassNode = three_webgpu.PassNode
|
|
1495
|
-
|
|
1496
|
-
/**
|
|
1497
|
-
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1498
|
-
*
|
|
1499
|
-
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1500
|
-
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1501
|
-
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1502
|
-
* {@link RenderPipelineCallbackState}.
|
|
1503
|
-
*
|
|
1504
|
-
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1505
|
-
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1506
|
-
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1507
|
-
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1508
|
-
*
|
|
1509
|
-
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1510
|
-
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1511
|
-
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1512
|
-
* (TS2411) for every consumer compiling these declarations.
|
|
1513
|
-
*/
|
|
1514
|
-
interface PassRecord {
|
|
1515
|
-
scenePass?: ScenePassNode
|
|
1516
|
-
[key: string]: three_webgpu.Node | undefined
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
/**
|
|
1520
|
-
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1521
|
-
*
|
|
1522
|
-
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1523
|
-
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1524
|
-
*
|
|
1525
|
-
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1526
|
-
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1527
|
-
*/
|
|
1528
|
-
type RenderPipelineCallbackState = RootState & {
|
|
1529
|
-
renderPipeline: ThreeRenderPipeline
|
|
1530
|
-
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1531
|
-
renderer: three_webgpu.WebGPURenderer
|
|
1532
|
-
isLegacy: false
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
/**
|
|
1536
|
-
* What a callback may return to register entries into `state.passes`.
|
|
1537
|
-
*
|
|
1538
|
-
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1539
|
-
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1540
|
-
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1541
|
-
* disposing a pass nothing references. So returning it is a type error.
|
|
1542
|
-
*/
|
|
1543
|
-
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1544
|
-
|
|
1545
|
-
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1546
|
-
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1547
|
-
|
|
1548
|
-
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1549
|
-
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1550
|
-
|
|
1551
|
-
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1552
|
-
interface UseRenderPipelineActions {
|
|
1553
|
-
/** Current passes from state */
|
|
1554
|
-
passes: PassRecord
|
|
1555
|
-
/** Clear all passes from state */
|
|
1556
|
-
clearPasses: () => void
|
|
1557
|
-
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1558
|
-
reset: () => void
|
|
1559
|
-
/** Re-run setup/main callbacks with current closure values */
|
|
1560
|
-
rebuild: () => void
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
/**
|
|
1564
|
-
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1565
|
-
*
|
|
1566
|
-
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1567
|
-
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1568
|
-
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1569
|
-
*/
|
|
1570
|
-
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1571
|
-
(
|
|
1572
|
-
| {
|
|
1573
|
-
/** True when RenderPipeline is configured and ready */
|
|
1574
|
-
isReady: true
|
|
1575
|
-
/** RenderPipeline instance */
|
|
1576
|
-
renderPipeline: ThreeRenderPipeline
|
|
1577
|
-
}
|
|
1578
|
-
| {
|
|
1579
|
-
/** False until the pipeline has been created */
|
|
1580
|
-
isReady: false
|
|
1581
|
-
/** Not initialized yet, or torn down by reset() */
|
|
1582
|
-
renderPipeline: null
|
|
1583
|
-
}
|
|
1584
|
-
)
|
|
1585
|
-
}
|
|
1586
|
-
|
|
1587
|
-
declare const context: React$1.Context<RootStore>;
|
|
541
|
+
declare const context: React.Context<RootStore>;
|
|
1588
542
|
|
|
1589
543
|
/**
|
|
1590
544
|
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
@@ -1672,4 +626,4 @@ declare function registerRootExtension(extension: RootExtension): () => void;
|
|
|
1672
626
|
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
1673
627
|
|
|
1674
628
|
export { context, registerRootExtension, setRenderOverride, useFrame, useStore, useThree };
|
|
1675
|
-
export type { Act,
|
|
629
|
+
export type { Act, Bridge, Camera, ComputeFunction, Disposable, DomEvent, Dpr, EquConfig, EventHandlers, EventManager, Events, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Mutable, NonFunctionKeys, ObjectMap, Overwrite, Performance, PointerCaptureTarget, PointerState, Properties, R3FRenderer, RenderCallback, RootExtension, RootState, RootStore, SetBlock, Size, Subscription, ThreeCamera, ThreeEvent, UnblockProps, Viewport, VisibilityEntry, XRManager, XRPointerConfig };
|