@react-three/fiber 10.0.0-canary.b0fafc8 → 10.0.0-canary.c3fa45d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +363 -91
- package/dist/index.d.cts +156 -27
- package/dist/index.d.mts +156 -27
- package/dist/index.d.ts +156 -27
- package/dist/index.mjs +364 -92
- package/dist/legacy.cjs +357 -91
- package/dist/legacy.d.cts +156 -27
- package/dist/legacy.d.mts +156 -27
- package/dist/legacy.d.ts +156 -27
- package/dist/legacy.mjs +358 -92
- package/dist/webgpu/index.cjs +738 -102
- package/dist/webgpu/index.d.cts +241 -40
- package/dist/webgpu/index.d.mts +241 -40
- package/dist/webgpu/index.d.ts +241 -40
- package/dist/webgpu/index.mjs +735 -103
- package/package.json +1 -1
package/dist/webgpu/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as three_webgpu from 'three/webgpu';
|
|
2
|
-
import { RenderTarget, WebGPURenderer,
|
|
2
|
+
import { RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera, WebGPURendererParameters } from 'three/webgpu';
|
|
3
3
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
4
4
|
import * as THREE$1 from 'three';
|
|
5
5
|
import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
@@ -151,6 +151,8 @@ interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
|
151
151
|
unprojectedPoint: THREE$1.Vector3
|
|
152
152
|
/** Normalized event coordinates */
|
|
153
153
|
pointer: THREE$1.Vector2
|
|
154
|
+
/** pointerId of the original event for multiple pointer events */
|
|
155
|
+
pointerId: number
|
|
154
156
|
/** Delta between first click and this event */
|
|
155
157
|
delta: number
|
|
156
158
|
/** The ray that pierced it */
|
|
@@ -227,6 +229,18 @@ interface EventHandlers {
|
|
|
227
229
|
type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
|
|
228
230
|
type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
|
|
229
231
|
|
|
232
|
+
/** Configuration for XR pointer registration (controllers/hands) */
|
|
233
|
+
interface XRPointerConfig {
|
|
234
|
+
/** Ray origin (updated each frame by XR system) */
|
|
235
|
+
ray: THREE$1.Ray
|
|
236
|
+
/** Optional: custom compute function for this pointer */
|
|
237
|
+
compute?: (state: RootState) => void
|
|
238
|
+
/** Pointer type identifier */
|
|
239
|
+
type: 'controller' | 'hand' | 'gaze'
|
|
240
|
+
/** Which hand (for controller/hand types) */
|
|
241
|
+
handedness?: 'left' | 'right'
|
|
242
|
+
}
|
|
243
|
+
|
|
230
244
|
interface EventManager<TTarget> {
|
|
231
245
|
/** Determines if the event layer is active */
|
|
232
246
|
enabled: boolean
|
|
@@ -246,8 +260,21 @@ interface EventManager<TTarget> {
|
|
|
246
260
|
disconnect?: () => void
|
|
247
261
|
/** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
|
|
248
262
|
* explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
|
|
263
|
+
* @param pointerId - Optional pointer ID to update specific pointer only
|
|
249
264
|
*/
|
|
250
|
-
update?: () => void
|
|
265
|
+
update?: (pointerId?: number) => void
|
|
266
|
+
/** Defer pointer move raycasting to frame start (default: true) */
|
|
267
|
+
frameTimedRaycasts?: boolean
|
|
268
|
+
/** Always fire raycaster immediately on scroll events (default: true) */
|
|
269
|
+
alwaysFireOnScroll?: boolean
|
|
270
|
+
/** Automatically re-raycast every frame to detect hover changes from moving objects/camera (default: false) */
|
|
271
|
+
updateOnFrame?: boolean
|
|
272
|
+
/** Flush deferred pointer raycasts. Called by scheduler at frame start (input phase). */
|
|
273
|
+
flush?: () => void
|
|
274
|
+
/** Register an XR pointer (controller/hand). Returns assigned pointerId */
|
|
275
|
+
registerPointer?: (config: XRPointerConfig) => number
|
|
276
|
+
/** Unregister an XR pointer */
|
|
277
|
+
unregisterPointer?: (pointerId: number) => void
|
|
251
278
|
}
|
|
252
279
|
|
|
253
280
|
interface PointerCaptureTarget {
|
|
@@ -489,6 +516,68 @@ interface SchedulerApi {
|
|
|
489
516
|
subscribeJobState(id: string, listener: () => void): () => void
|
|
490
517
|
}
|
|
491
518
|
|
|
519
|
+
//* Buffer Types (useBuffers) ========================================
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Buffer-like types for GPU compute and storage operations.
|
|
523
|
+
* Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```tsx
|
|
527
|
+
* const { positions, velocities } = useBuffers(() => ({
|
|
528
|
+
* positions: instancedArray(count, 'vec3'), // StorageBufferNode
|
|
529
|
+
* velocities: new Float32Array(count * 3), // TypedArray
|
|
530
|
+
* }), 'particles')
|
|
531
|
+
* ```
|
|
532
|
+
*/
|
|
533
|
+
type BufferLike =
|
|
534
|
+
| Float32Array
|
|
535
|
+
| Uint32Array
|
|
536
|
+
| Int32Array
|
|
537
|
+
| Float64Array
|
|
538
|
+
| Uint8Array
|
|
539
|
+
| Int8Array
|
|
540
|
+
| Uint16Array
|
|
541
|
+
| Int16Array
|
|
542
|
+
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
543
|
+
| Node // TSL buffer nodes (instancedArray, storage)
|
|
544
|
+
|
|
545
|
+
/** Flat record of buffer-like values (no nested scopes) */
|
|
546
|
+
type BufferRecord = Record<string, BufferLike>
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Buffer store that can contain both root-level buffers and scoped buffer objects.
|
|
550
|
+
* Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
|
|
551
|
+
*/
|
|
552
|
+
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
553
|
+
|
|
554
|
+
//* Storage Types (useGPUStorage) ========================================
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* GPU storage types for texture-based storage operations.
|
|
558
|
+
* Includes Three.js storage textures and TSL storage texture nodes.
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* ```tsx
|
|
562
|
+
* const { heightMap } = useGPUStorage(() => ({
|
|
563
|
+
* heightMap: new StorageTexture(512, 512),
|
|
564
|
+
* }), 'terrain')
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
567
|
+
type StorageLike =
|
|
568
|
+
| StorageTexture // GPU storage texture
|
|
569
|
+
| Data3DTexture // 3D texture (can be used as storage)
|
|
570
|
+
| Node // TSL storage texture nodes (storageTexture)
|
|
571
|
+
|
|
572
|
+
/** Flat record of storage-like values (no nested scopes) */
|
|
573
|
+
type StorageRecord = Record<string, StorageLike>
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Storage store that can contain both root-level storage and scoped storage objects.
|
|
577
|
+
* Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
|
|
578
|
+
*/
|
|
579
|
+
type StorageStore = Record<string, StorageLike | StorageRecord>
|
|
580
|
+
|
|
492
581
|
//* Renderer Types ========================================
|
|
493
582
|
|
|
494
583
|
/** Default renderer type - union of WebGL and WebGPU renderers */
|
|
@@ -502,6 +591,18 @@ type Subscription = {
|
|
|
502
591
|
store: RootStore
|
|
503
592
|
}
|
|
504
593
|
|
|
594
|
+
/** Per-pointer state for multi-touch and XR support */
|
|
595
|
+
type PointerState = {
|
|
596
|
+
/** Objects currently hovered by this pointer */
|
|
597
|
+
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
598
|
+
/** Objects capturing this pointer */
|
|
599
|
+
captured: Map<THREE$1.Object3D, PointerCaptureTarget>
|
|
600
|
+
/** Initial click position [x, y] */
|
|
601
|
+
initialClick: [x: number, y: number]
|
|
602
|
+
/** Objects hit on initial click */
|
|
603
|
+
initialHits: THREE$1.Object3D[]
|
|
604
|
+
}
|
|
605
|
+
|
|
505
606
|
type Dpr = number | [min: number, max: number]
|
|
506
607
|
|
|
507
608
|
interface Size {
|
|
@@ -543,12 +644,21 @@ interface Performance {
|
|
|
543
644
|
|
|
544
645
|
interface InternalState {
|
|
545
646
|
interaction: THREE$1.Object3D[]
|
|
546
|
-
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
547
647
|
subscribers: Subscription[]
|
|
648
|
+
/** Per-pointer state (hover, capture, click tracking) - replaces hovered, capturedMap, initialClick, initialHits */
|
|
649
|
+
pointerMap: Map<number, PointerState>
|
|
650
|
+
/** Pointers needing raycast this frame (used with frameTimedRaycasts) */
|
|
651
|
+
pointerDirty: Map<number, DomEvent>
|
|
652
|
+
/** Last event received (for events.update() compatibility) */
|
|
653
|
+
lastEvent: React$1.RefObject<DomEvent | null>
|
|
654
|
+
/** @deprecated Use pointerMap.get(pointerId).hovered instead */
|
|
655
|
+
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
656
|
+
/** @deprecated Use pointerMap.get(pointerId).captured instead */
|
|
548
657
|
capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
|
|
658
|
+
/** @deprecated Use pointerMap.get(pointerId).initialClick instead */
|
|
549
659
|
initialClick: [x: number, y: number]
|
|
660
|
+
/** @deprecated Use pointerMap.get(pointerId).initialHits instead */
|
|
550
661
|
initialHits: THREE$1.Object3D[]
|
|
551
|
-
lastEvent: React$1.RefObject<DomEvent | null>
|
|
552
662
|
/** Visibility event registry (onFramed, onOccluded, onVisible) */
|
|
553
663
|
visibilityRegistry: Map<string, VisibilityEntry>
|
|
554
664
|
/** Whether occlusion queries are enabled (WebGPU only) */
|
|
@@ -689,11 +799,15 @@ interface RootState {
|
|
|
689
799
|
uniforms: UniformStore
|
|
690
800
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
691
801
|
nodes: Record<string, any>
|
|
802
|
+
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
803
|
+
buffers: BufferStore
|
|
804
|
+
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
805
|
+
gpuStorage: StorageStore
|
|
692
806
|
/** Global TSL texture nodes - use useTextures() hook for operations */
|
|
693
807
|
textures: Map<string, any>
|
|
694
|
-
/** WebGPU
|
|
695
|
-
|
|
696
|
-
/** Global TSL pass nodes for
|
|
808
|
+
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
809
|
+
renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
|
|
810
|
+
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
697
811
|
passes: Record<string, any>
|
|
698
812
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
699
813
|
_hmrVersion: number
|
|
@@ -743,6 +857,20 @@ interface Renderer {
|
|
|
743
857
|
render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
|
|
744
858
|
}
|
|
745
859
|
|
|
860
|
+
//* Color Management Config ==============================
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Color management configuration shared by both WebGL and WebGPU renderers.
|
|
864
|
+
*/
|
|
865
|
+
interface ColorManagementConfig {
|
|
866
|
+
/**
|
|
867
|
+
* Color space assigned to 8-bit input textures (color maps).
|
|
868
|
+
* Defaults to sRGB. Most textures are authored in sRGB.
|
|
869
|
+
* @default THREE.SRGBColorSpace
|
|
870
|
+
*/
|
|
871
|
+
textureColorSpace?: THREE$1.ColorSpace
|
|
872
|
+
}
|
|
873
|
+
|
|
746
874
|
//* WebGL Renderer Props ==============================
|
|
747
875
|
|
|
748
876
|
type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
|
|
@@ -753,7 +881,7 @@ type GLProps =
|
|
|
753
881
|
| Renderer
|
|
754
882
|
| ((defaultProps: DefaultGLProps) => Renderer)
|
|
755
883
|
| ((defaultProps: DefaultGLProps) => Promise<Renderer>)
|
|
756
|
-
| Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
|
|
884
|
+
| (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
|
|
757
885
|
|
|
758
886
|
//* WebGPU Renderer Props ==============================
|
|
759
887
|
|
|
@@ -779,9 +907,9 @@ interface CanvasSchedulerConfig {
|
|
|
779
907
|
}
|
|
780
908
|
|
|
781
909
|
/**
|
|
782
|
-
* Extended renderer configuration for multi-canvas support.
|
|
910
|
+
* Extended renderer configuration for multi-canvas support and color management.
|
|
783
911
|
*/
|
|
784
|
-
interface RendererConfigExtended {
|
|
912
|
+
interface RendererConfigExtended extends ColorManagementConfig {
|
|
785
913
|
/** Share renderer from another canvas (WebGPU only) */
|
|
786
914
|
primaryCanvas?: string
|
|
787
915
|
/** Canvas-level scheduler options */
|
|
@@ -846,8 +974,6 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
846
974
|
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
847
975
|
*/
|
|
848
976
|
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
|
|
849
|
-
/** Color space assigned to 8-bit input textures (color maps). Defaults to sRGB. Most textures are authored in sRGB. */
|
|
850
|
-
textureColorSpace?: THREE$1.ColorSpace
|
|
851
977
|
/** Creates an orthographic camera */
|
|
852
978
|
orthographic?: boolean
|
|
853
979
|
/**
|
|
@@ -1100,7 +1226,7 @@ interface CanvasProps
|
|
|
1100
1226
|
*/
|
|
1101
1227
|
resize?: Options
|
|
1102
1228
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1103
|
-
eventSource?: HTMLElement | React$1.RefObject<HTMLElement>
|
|
1229
|
+
eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
|
|
1104
1230
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1105
1231
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1106
1232
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1314,6 +1440,7 @@ declare global {
|
|
|
1314
1440
|
| three_webgpu.Euler
|
|
1315
1441
|
| three_webgpu.Quaternion
|
|
1316
1442
|
| { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
|
|
1443
|
+
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1317
1444
|
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1318
1445
|
| UniformNode
|
|
1319
1446
|
|
|
@@ -1359,34 +1486,34 @@ declare module 'three/tsl' {
|
|
|
1359
1486
|
}
|
|
1360
1487
|
|
|
1361
1488
|
/**
|
|
1362
|
-
*
|
|
1489
|
+
* RenderPipeline Types for useRenderPipeline hook (WebGPU only)
|
|
1363
1490
|
*/
|
|
1364
1491
|
|
|
1365
1492
|
|
|
1366
1493
|
|
|
1367
1494
|
declare global {
|
|
1368
|
-
/** Pass record - stores TSL pass nodes for
|
|
1495
|
+
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1369
1496
|
type PassRecord = Record<string, any>
|
|
1370
1497
|
|
|
1371
1498
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1372
|
-
type
|
|
1499
|
+
type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
|
|
1373
1500
|
|
|
1374
1501
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1375
|
-
type
|
|
1502
|
+
type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
|
|
1376
1503
|
|
|
1377
|
-
/** Return type for
|
|
1378
|
-
interface
|
|
1504
|
+
/** Return type for useRenderPipeline hook */
|
|
1505
|
+
interface UseRenderPipelineReturn {
|
|
1379
1506
|
/** Current passes from state */
|
|
1380
1507
|
passes: PassRecord
|
|
1381
|
-
/**
|
|
1382
|
-
|
|
1508
|
+
/** RenderPipeline instance (null if not initialized) */
|
|
1509
|
+
renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
|
|
1383
1510
|
/** Clear all passes from state */
|
|
1384
1511
|
clearPasses: () => void
|
|
1385
|
-
/** Reset
|
|
1512
|
+
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1386
1513
|
reset: () => void
|
|
1387
1514
|
/** Re-run setup/main callbacks with current closure values */
|
|
1388
1515
|
rebuild: () => void
|
|
1389
|
-
/** True when
|
|
1516
|
+
/** True when RenderPipeline is configured and ready */
|
|
1390
1517
|
isReady: boolean
|
|
1391
1518
|
}
|
|
1392
1519
|
}
|
|
@@ -2006,6 +2133,8 @@ declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Ele
|
|
|
2006
2133
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
2007
2134
|
declare function createEvents(store: RootStore): {
|
|
2008
2135
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
2136
|
+
flushDeferredPointers: () => void;
|
|
2137
|
+
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
2009
2138
|
};
|
|
2010
2139
|
/** Default R3F event manager for web */
|
|
2011
2140
|
declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
|
|
@@ -2585,9 +2714,9 @@ declare function useTextures(): UseTexturesReturn;
|
|
|
2585
2714
|
* const fbo = useRenderTarget(512, 256, { samples: 4 })
|
|
2586
2715
|
* ```
|
|
2587
2716
|
*/
|
|
2588
|
-
declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget
|
|
2589
|
-
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget
|
|
2590
|
-
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget
|
|
2717
|
+
declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
|
|
2718
|
+
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
|
|
2719
|
+
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
|
|
2591
2720
|
|
|
2592
2721
|
/**
|
|
2593
2722
|
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
@@ -4300,13 +4429,17 @@ type ScopedStoreType<T> = {
|
|
|
4300
4429
|
declare function createScopedStore<T>(data: Record<string, any>): ScopedStoreType<T>;
|
|
4301
4430
|
/**
|
|
4302
4431
|
* State type passed to creator functions with ScopedStore wrappers.
|
|
4303
|
-
* Provides type-safe access to uniforms and
|
|
4432
|
+
* Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
|
|
4304
4433
|
*/
|
|
4305
|
-
type CreatorState = Omit<RootState, 'uniforms' | 'nodes'> & {
|
|
4434
|
+
type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
|
|
4306
4435
|
/** Type-safe uniform access - property access returns UniformNode */
|
|
4307
4436
|
uniforms: ScopedStoreType<UniformNode>;
|
|
4308
4437
|
/** Type-safe node access - property access returns TSLNodeType (Node | ShaderCallable | ShaderNodeObject) */
|
|
4309
4438
|
nodes: ScopedStoreType<TSLNodeType>;
|
|
4439
|
+
/** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
|
|
4440
|
+
buffers: ScopedStoreType<BufferLike>;
|
|
4441
|
+
/** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
|
|
4442
|
+
gpuStorage: ScopedStoreType<StorageLike>;
|
|
4310
4443
|
};
|
|
4311
4444
|
|
|
4312
4445
|
/** Creator function that returns uniform inputs (can be raw values or UniformNodes) */
|
|
@@ -4470,6 +4603,74 @@ type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState)
|
|
|
4470
4603
|
*/
|
|
4471
4604
|
declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
|
|
4472
4605
|
|
|
4606
|
+
/**
|
|
4607
|
+
* Creator function that returns a record of buffers.
|
|
4608
|
+
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
4609
|
+
*/
|
|
4610
|
+
type BufferCreator<T extends Record<string, BufferLike>> = (state: CreatorState) => T;
|
|
4611
|
+
/** Function signature for removeBuffers util */
|
|
4612
|
+
type RemoveBuffersFn = (names: string | string[], scope?: string) => void;
|
|
4613
|
+
/** Function signature for clearBuffers util */
|
|
4614
|
+
type ClearBuffersFn = (scope?: string) => void;
|
|
4615
|
+
/** Function signature for rebuildBuffers util */
|
|
4616
|
+
type RebuildBuffersFn = (scope?: string) => void;
|
|
4617
|
+
/** Function signature for disposeBuffers util - releases GPU resources */
|
|
4618
|
+
type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
|
|
4619
|
+
/** Return type with utils included */
|
|
4620
|
+
type BuffersWithUtils<T extends Record<string, BufferLike> = Record<string, BufferLike>> = T & {
|
|
4621
|
+
removeBuffers: RemoveBuffersFn;
|
|
4622
|
+
clearBuffers: ClearBuffersFn;
|
|
4623
|
+
rebuildBuffers: RebuildBuffersFn;
|
|
4624
|
+
disposeBuffers: DisposeBuffersFn;
|
|
4625
|
+
};
|
|
4626
|
+
declare function useBuffers(): BuffersWithUtils<Record<string, BufferLike> & Record<string, Record<string, BufferLike>>>;
|
|
4627
|
+
declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
|
|
4628
|
+
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
|
|
4629
|
+
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
|
|
4630
|
+
/**
|
|
4631
|
+
* Global rebuildBuffers function for HMR integration.
|
|
4632
|
+
* Clears cached buffers and increments _hmrVersion to trigger re-creation.
|
|
4633
|
+
* Call this when HMR is detected to refresh all buffer creators.
|
|
4634
|
+
*
|
|
4635
|
+
* @param store - The R3F store (from useStore or context)
|
|
4636
|
+
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4637
|
+
*/
|
|
4638
|
+
declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4639
|
+
|
|
4640
|
+
/**
|
|
4641
|
+
* Creator function that returns a record of GPU storage objects.
|
|
4642
|
+
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
4643
|
+
*/
|
|
4644
|
+
type StorageCreator<T extends Record<string, StorageLike>> = (state: CreatorState) => T;
|
|
4645
|
+
/** Function signature for removeStorage util */
|
|
4646
|
+
type RemoveStorageFn = (names: string | string[], scope?: string) => void;
|
|
4647
|
+
/** Function signature for clearStorage util */
|
|
4648
|
+
type ClearStorageFn = (scope?: string) => void;
|
|
4649
|
+
/** Function signature for rebuildStorage util */
|
|
4650
|
+
type RebuildStorageFn = (scope?: string) => void;
|
|
4651
|
+
/** Function signature for disposeStorage util - releases GPU resources */
|
|
4652
|
+
type DisposeStorageFn = (names: string | string[], scope?: string) => void;
|
|
4653
|
+
/** Return type with utils included */
|
|
4654
|
+
type StorageWithUtils<T extends Record<string, StorageLike> = Record<string, StorageLike>> = T & {
|
|
4655
|
+
removeStorage: RemoveStorageFn;
|
|
4656
|
+
clearStorage: ClearStorageFn;
|
|
4657
|
+
rebuildStorage: RebuildStorageFn;
|
|
4658
|
+
disposeStorage: DisposeStorageFn;
|
|
4659
|
+
};
|
|
4660
|
+
declare function useGPUStorage(): StorageWithUtils<Record<string, StorageLike> & Record<string, Record<string, StorageLike>>>;
|
|
4661
|
+
declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
|
|
4662
|
+
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
|
|
4663
|
+
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
|
|
4664
|
+
/**
|
|
4665
|
+
* Global rebuildStorage function for HMR integration.
|
|
4666
|
+
* Clears cached storage and increments _hmrVersion to trigger re-creation.
|
|
4667
|
+
* Call this when HMR is detected to refresh all storage creators.
|
|
4668
|
+
*
|
|
4669
|
+
* @param store - The R3F store (from useStore or context)
|
|
4670
|
+
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4671
|
+
*/
|
|
4672
|
+
declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4673
|
+
|
|
4473
4674
|
interface TextureOperations {
|
|
4474
4675
|
add: (key: string, value: any) => void;
|
|
4475
4676
|
addMultiple: (items: Map<string, any> | Record<string, any>) => void;
|
|
@@ -4479,10 +4680,10 @@ interface TextureOperations {
|
|
|
4479
4680
|
declare function createTextureOperations(set: StoreApi<RootState>['setState']): TextureOperations;
|
|
4480
4681
|
|
|
4481
4682
|
/**
|
|
4482
|
-
* Hook for managing WebGPU
|
|
4683
|
+
* Hook for managing WebGPU RenderPipeline with automatic scenePass setup.
|
|
4483
4684
|
*
|
|
4484
4685
|
* Features:
|
|
4485
|
-
* - Creates
|
|
4686
|
+
* - Creates RenderPipeline instance if not exists
|
|
4486
4687
|
* - Creates default scenePass (no MRT) automatically
|
|
4487
4688
|
* - Callbacks receive full RootState for flexibility
|
|
4488
4689
|
* - No auto-cleanup on unmount - use reset() for explicit cleanup
|
|
@@ -4490,21 +4691,21 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
|
|
|
4490
4691
|
*
|
|
4491
4692
|
* @param mainCB - Main callback to configure outputNode and create effect passes
|
|
4492
4693
|
* @param setupCB - Optional setup callback to configure MRT on scenePass
|
|
4493
|
-
* @returns { passes,
|
|
4694
|
+
* @returns { passes, renderPipeline, clearPasses, reset, rebuild }
|
|
4494
4695
|
*
|
|
4495
4696
|
* @example
|
|
4496
4697
|
* ```tsx
|
|
4497
4698
|
* // Simple effect
|
|
4498
|
-
*
|
|
4499
|
-
*
|
|
4699
|
+
* useRenderPipeline(({ renderPipeline, passes }) => {
|
|
4700
|
+
* renderPipeline.outputNode = bloom(passes.scenePass.getTextureNode())
|
|
4500
4701
|
* })
|
|
4501
4702
|
*
|
|
4502
4703
|
* // With MRT setup
|
|
4503
|
-
*
|
|
4504
|
-
* ({
|
|
4704
|
+
* useRenderPipeline(
|
|
4705
|
+
* ({ renderPipeline, passes }) => {
|
|
4505
4706
|
* const beauty = passes.scenePass.getTextureNode().toInspector('Color')
|
|
4506
4707
|
* const vel = passes.scenePass.getTextureNode('velocity')
|
|
4507
|
-
*
|
|
4708
|
+
* renderPipeline.outputNode = motionBlur(beauty, vel)
|
|
4508
4709
|
* },
|
|
4509
4710
|
* ({ passes }) => {
|
|
4510
4711
|
* passes.scenePass.setMRT(mrt({ output, velocity }))
|
|
@@ -4512,10 +4713,10 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
|
|
|
4512
4713
|
* )
|
|
4513
4714
|
*
|
|
4514
4715
|
* // Read-only access
|
|
4515
|
-
* const {
|
|
4716
|
+
* const { renderPipeline, passes } = useRenderPipeline()
|
|
4516
4717
|
* ```
|
|
4517
4718
|
*/
|
|
4518
|
-
declare function
|
|
4719
|
+
declare function useRenderPipeline(mainCB?: RenderPipelineMainCallback, setupCB?: RenderPipelineSetupCallback): UseRenderPipelineReturn;
|
|
4519
4720
|
|
|
4520
4721
|
//* Renderer Props ========================================
|
|
4521
4722
|
|
|
@@ -4564,5 +4765,5 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
|
|
|
4564
4765
|
internal: WebGPUInternalState
|
|
4565
4766
|
}
|
|
4566
4767
|
|
|
4567
|
-
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, Scheduler, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getScheduler, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, rebuildAllNodes, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes,
|
|
4568
|
-
export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, ClearNodesFn, ClearUniformsFn, Color, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, FrameTimingState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeProps, NodeRecord, NodesWithUtils, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, RebuildNodesFn, RebuildUniformsFn, ReconcilerRoot, RemoveNodesFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootOptions, WebGPURootState as RootState, RootStore, SchedulerApi, ScopedStoreType, SetBlock, Size, Subscription, TSLNode, TSLNodeInput, TextureEntry, TextureOperations, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager };
|
|
4768
|
+
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, Scheduler, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getScheduler, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useBuffers, useEnvironment, useFrame, useGPUStorage, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, useRenderPipeline, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
|
|
4769
|
+
export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DisposeBuffersFn, DisposeStorageFn, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, FrameTimingState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeProps, NodeRecord, NodesWithUtils, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, RebuildBuffersFn, RebuildNodesFn, RebuildStorageFn, RebuildUniformsFn, ReconcilerRoot, RemoveBuffersFn, RemoveNodesFn, RemoveStorageFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootOptions, WebGPURootState as RootState, RootStore, SchedulerApi, ScopedStoreType, SetBlock, Size, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, Subscription, TSLNode, TSLNodeInput, TextureEntry, TextureOperations, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };
|