@react-three/fiber 10.0.0-canary.dbbe704 → 10.0.0-canary.dc0ec15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension.cjs +278 -0
- package/dist/extension.d.cts +1675 -0
- package/dist/extension.d.mts +1675 -0
- package/dist/extension.d.ts +1647 -0
- package/dist/extension.mjs +258 -0
- package/dist/index.cjs +2751 -3185
- package/dist/index.d.cts +609 -931
- package/dist/index.d.mts +609 -931
- package/dist/index.d.ts +604 -954
- package/dist/index.mjs +2680 -3115
- package/dist/legacy.cjs +2719 -3160
- package/dist/legacy.d.cts +621 -974
- package/dist/legacy.d.mts +621 -974
- package/dist/legacy.d.ts +617 -996
- package/dist/legacy.mjs +2669 -3111
- package/dist/webgpu/index.cjs +3624 -3816
- package/dist/webgpu/index.d.cts +786 -1037
- package/dist/webgpu/index.d.mts +786 -1037
- package/dist/webgpu/index.d.ts +782 -1061
- package/dist/webgpu/index.mjs +3635 -3832
- package/package.json +11 -5
- package/readme.md +3 -4
- package/react-reconciler/constants.d.ts +0 -7
- package/react-reconciler/constants.js +0 -1
- package/react-reconciler/index.d.ts +0 -1044
- package/react-reconciler/index.js +0 -208
package/dist/webgpu/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
|
|
1
2
|
import * as three_webgpu from 'three/webgpu';
|
|
2
|
-
import { RenderTarget, WebGPURenderer,
|
|
3
|
+
import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Object3D, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera, Matrix2, WebGPURendererParameters } from 'three/webgpu';
|
|
3
4
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
4
5
|
import * as THREE$1 from 'three';
|
|
5
6
|
import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
@@ -7,9 +8,10 @@ import * as React$1 from 'react';
|
|
|
7
8
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
8
9
|
import { StoreApi } from 'zustand';
|
|
9
10
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
11
|
+
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
12
|
+
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
10
13
|
import { Options } from 'react-use-measure';
|
|
11
14
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
12
|
-
import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
|
|
13
15
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
14
16
|
|
|
15
17
|
function _mergeNamespaces(n, m) {
|
|
@@ -39,6 +41,8 @@ function _mergeNamespaces(n, m) {
|
|
|
39
41
|
declare const R3F_BUILD_LEGACY = false;
|
|
40
42
|
declare const R3F_BUILD_WEBGPU = true;
|
|
41
43
|
|
|
44
|
+
/** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
|
|
45
|
+
declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
|
|
42
46
|
declare const WebGLRenderer: {
|
|
43
47
|
new (): {};
|
|
44
48
|
};
|
|
@@ -47,16 +51,21 @@ type WebGLShadowMap = never;
|
|
|
47
51
|
|
|
48
52
|
declare const WebGLRenderTarget: any;
|
|
49
53
|
|
|
54
|
+
declare const WebGLCubeRenderTarget: any;
|
|
55
|
+
|
|
50
56
|
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
51
57
|
__proto__: null,
|
|
58
|
+
CubeRenderTargetCompat: CubeRenderTarget,
|
|
52
59
|
Inspector: Inspector,
|
|
53
60
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
54
61
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
55
62
|
RenderTargetCompat: RenderTarget,
|
|
63
|
+
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
56
64
|
WebGLRenderTarget: WebGLRenderTarget,
|
|
57
65
|
WebGLRenderer: WebGLRenderer,
|
|
58
66
|
WebGLRendererParameters: WebGLRendererParameters,
|
|
59
|
-
WebGLShadowMap: WebGLShadowMap
|
|
67
|
+
WebGLShadowMap: WebGLShadowMap,
|
|
68
|
+
loadInspector: loadInspector
|
|
60
69
|
}, [three_webgpu]);
|
|
61
70
|
|
|
62
71
|
//* Utility Types ==============================
|
|
@@ -151,6 +160,8 @@ interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
|
151
160
|
unprojectedPoint: THREE$1.Vector3
|
|
152
161
|
/** Normalized event coordinates */
|
|
153
162
|
pointer: THREE$1.Vector2
|
|
163
|
+
/** pointerId of the original event for multiple pointer events */
|
|
164
|
+
pointerId: number
|
|
154
165
|
/** Delta between first click and this event */
|
|
155
166
|
delta: number
|
|
156
167
|
/** The ray that pierced it */
|
|
@@ -227,6 +238,18 @@ interface EventHandlers {
|
|
|
227
238
|
type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
|
|
228
239
|
type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
|
|
229
240
|
|
|
241
|
+
/** Configuration for XR pointer registration (controllers/hands) */
|
|
242
|
+
interface XRPointerConfig {
|
|
243
|
+
/** Ray origin (updated each frame by XR system) */
|
|
244
|
+
ray: THREE$1.Ray
|
|
245
|
+
/** Optional: custom compute function for this pointer */
|
|
246
|
+
compute?: (state: RootState) => void
|
|
247
|
+
/** Pointer type identifier */
|
|
248
|
+
type: 'controller' | 'hand' | 'gaze'
|
|
249
|
+
/** Which hand (for controller/hand types) */
|
|
250
|
+
handedness?: 'left' | 'right'
|
|
251
|
+
}
|
|
252
|
+
|
|
230
253
|
interface EventManager<TTarget> {
|
|
231
254
|
/** Determines if the event layer is active */
|
|
232
255
|
enabled: boolean
|
|
@@ -246,8 +269,21 @@ interface EventManager<TTarget> {
|
|
|
246
269
|
disconnect?: () => void
|
|
247
270
|
/** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
|
|
248
271
|
* explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
|
|
272
|
+
* @param pointerId - Optional pointer ID to update specific pointer only
|
|
249
273
|
*/
|
|
250
|
-
update?: () => void
|
|
274
|
+
update?: (pointerId?: number) => void
|
|
275
|
+
/** Defer pointer move raycasting to frame start (default: true) */
|
|
276
|
+
frameTimedRaycasts?: boolean
|
|
277
|
+
/** Always fire raycaster immediately on scroll events (default: true) */
|
|
278
|
+
alwaysFireOnScroll?: boolean
|
|
279
|
+
/** Automatically re-raycast every frame to detect hover changes from moving objects/camera (default: false) */
|
|
280
|
+
updateOnFrame?: boolean
|
|
281
|
+
/** Flush deferred pointer raycasts. Called by scheduler at frame start (input phase). */
|
|
282
|
+
flush?: () => void
|
|
283
|
+
/** Register an XR pointer (controller/hand). Returns assigned pointerId */
|
|
284
|
+
registerPointer?: (config: XRPointerConfig) => number
|
|
285
|
+
/** Unregister an XR pointer */
|
|
286
|
+
unregisterPointer?: (pointerId: number) => void
|
|
251
287
|
}
|
|
252
288
|
|
|
253
289
|
interface PointerCaptureTarget {
|
|
@@ -267,227 +303,116 @@ interface VisibilityEntry {
|
|
|
267
303
|
}
|
|
268
304
|
|
|
269
305
|
//* Scheduler Types (useFrame) ==============================
|
|
306
|
+
//
|
|
307
|
+
// The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
|
|
308
|
+
// This file re-exports them and layers r3f's RootState-aware frame state on top,
|
|
309
|
+
// so existing `#types` imports across the codebase keep resolving unchanged.
|
|
270
310
|
|
|
271
311
|
|
|
272
312
|
|
|
273
|
-
//
|
|
313
|
+
// Frame State (r3f-specific) --------------------------------
|
|
274
314
|
|
|
275
315
|
/**
|
|
276
|
-
*
|
|
316
|
+
* State passed to useFrame callbacks (extends RootState with timing).
|
|
277
317
|
*/
|
|
278
|
-
interface
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
phase?: string
|
|
283
|
-
/** Run before this phase or job id */
|
|
284
|
-
before?: string | string[]
|
|
285
|
-
/** Run after this phase or job id */
|
|
286
|
-
after?: string | string[]
|
|
287
|
-
/** Priority within phase. Higher runs first. Default: 0 */
|
|
288
|
-
priority?: number
|
|
289
|
-
/** Max frames per second for this job */
|
|
290
|
-
fps?: number
|
|
291
|
-
/** If true, skip frames when behind. If false, try to catch up. Default: true */
|
|
292
|
-
drop?: boolean
|
|
293
|
-
/** Enable/disable without unregistering. Default: true */
|
|
294
|
-
enabled?: boolean
|
|
295
|
-
}
|
|
318
|
+
interface FrameNextState extends RootState, FrameTimingState {}
|
|
319
|
+
|
|
320
|
+
/** Alias for FrameNextState */
|
|
321
|
+
type FrameState = FrameNextState
|
|
296
322
|
|
|
297
|
-
|
|
298
|
-
type UseFrameOptions = UseFrameNextOptions
|
|
323
|
+
// Callback Types (r3f-specific) --------------------------------
|
|
299
324
|
|
|
300
325
|
/**
|
|
301
|
-
*
|
|
326
|
+
* Callback function for useFrame. Receives the full r3f RootState plus timing.
|
|
302
327
|
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
after?: string
|
|
308
|
-
}
|
|
328
|
+
type FrameNextCallback = FrameCallback$1<RootState>
|
|
329
|
+
|
|
330
|
+
/** Alias for FrameNextCallback */
|
|
331
|
+
type FrameCallback = FrameNextCallback
|
|
309
332
|
|
|
310
|
-
|
|
333
|
+
//* Buffer Types (useBuffers) ========================================
|
|
311
334
|
|
|
312
335
|
/**
|
|
313
|
-
*
|
|
336
|
+
* Buffer-like types for GPU compute and storage operations.
|
|
337
|
+
* Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```tsx
|
|
341
|
+
* const { positions, velocities } = useBuffers(() => ({
|
|
342
|
+
* positions: instancedArray(count, 'vec3'), // StorageBufferNode
|
|
343
|
+
* velocities: new Float32Array(count * 3), // TypedArray
|
|
344
|
+
* }), 'particles')
|
|
345
|
+
* ```
|
|
314
346
|
*/
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
347
|
+
type BufferLike =
|
|
348
|
+
| Float32Array
|
|
349
|
+
| Uint32Array
|
|
350
|
+
| Int32Array
|
|
351
|
+
| Float64Array
|
|
352
|
+
| Uint8Array
|
|
353
|
+
| Int8Array
|
|
354
|
+
| Uint16Array
|
|
355
|
+
| Int16Array
|
|
356
|
+
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
357
|
+
| THREE$1.InterleavedBufferAttribute
|
|
358
|
+
| Node // TSL buffer nodes (instancedArray, storage)
|
|
359
|
+
|
|
360
|
+
/** Flat record of buffer-like values (no nested scopes) */
|
|
361
|
+
type BufferRecord = Record<string, BufferLike>
|
|
325
362
|
|
|
326
363
|
/**
|
|
327
|
-
*
|
|
364
|
+
* Buffer store that can contain both root-level buffers and scoped buffer objects.
|
|
365
|
+
* Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
|
|
328
366
|
*/
|
|
329
|
-
|
|
367
|
+
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
330
368
|
|
|
331
|
-
|
|
332
|
-
type FrameState = FrameNextState
|
|
333
|
-
|
|
334
|
-
// Root Options --------------------------------
|
|
369
|
+
//* Node Types (useNodes) ========================================
|
|
335
370
|
|
|
336
371
|
/**
|
|
337
|
-
*
|
|
372
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
373
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
374
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
375
|
+
* and the shape the store holds are one type by construction.
|
|
338
376
|
*/
|
|
339
|
-
|
|
340
|
-
/** State provider for callbacks. Optional in independent mode. */
|
|
341
|
-
getState?: () => any
|
|
342
|
-
/** Error handler for job errors. Falls back to console.error if not provided. */
|
|
343
|
-
onError?: (error: Error) => void
|
|
344
|
-
}
|
|
377
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
345
378
|
|
|
346
|
-
|
|
379
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
380
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
347
381
|
|
|
348
382
|
/**
|
|
349
|
-
*
|
|
383
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
384
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
350
385
|
*/
|
|
351
|
-
type
|
|
352
|
-
|
|
353
|
-
/** Alias for FrameNextCallback */
|
|
354
|
-
type FrameCallback = FrameNextCallback
|
|
386
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
355
387
|
|
|
356
|
-
|
|
388
|
+
//* Storage Types (useGPUStorage) ========================================
|
|
357
389
|
|
|
358
390
|
/**
|
|
359
|
-
*
|
|
391
|
+
* GPU storage types for texture-based storage operations.
|
|
392
|
+
* Includes Three.js storage textures and TSL storage texture nodes.
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```tsx
|
|
396
|
+
* const { heightMap } = useGPUStorage(() => ({
|
|
397
|
+
* heightMap: new StorageTexture(512, 512),
|
|
398
|
+
* }), 'terrain')
|
|
399
|
+
* ```
|
|
360
400
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
step(timestamp?: number): void
|
|
368
|
-
/** Manually step ALL jobs in the scheduler */
|
|
369
|
-
stepAll(timestamp?: number): void
|
|
370
|
-
/** Pause this job (set enabled=false) */
|
|
371
|
-
pause(): void
|
|
372
|
-
/** Resume this job (set enabled=true) */
|
|
373
|
-
resume(): void
|
|
374
|
-
/** Reactive paused state - automatically triggers re-render when changed */
|
|
375
|
-
isPaused: boolean
|
|
376
|
-
}
|
|
401
|
+
type StorageLike =
|
|
402
|
+
| StorageTexture // 2D GPU storage texture
|
|
403
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
404
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
405
|
+
| Data3DTexture // 3D texture (can be used as storage)
|
|
406
|
+
| Node // TSL storage texture nodes (storageTexture)
|
|
377
407
|
|
|
378
|
-
/**
|
|
379
|
-
type
|
|
380
|
-
|
|
381
|
-
// Scheduler Interface --------------------------------
|
|
408
|
+
/** Flat record of storage-like values (no nested scopes) */
|
|
409
|
+
type StorageRecord = Record<string, StorageLike>
|
|
382
410
|
|
|
383
411
|
/**
|
|
384
|
-
*
|
|
412
|
+
* Storage store that can contain both root-level storage and scoped storage objects.
|
|
413
|
+
* Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
|
|
385
414
|
*/
|
|
386
|
-
|
|
387
|
-
//* Phase Management --------------------------------
|
|
388
|
-
|
|
389
|
-
/** Add a named phase to the scheduler */
|
|
390
|
-
addPhase(name: string, options?: AddPhaseOptions): void
|
|
391
|
-
/** Get the ordered list of phase names */
|
|
392
|
-
readonly phases: string[]
|
|
393
|
-
/** Check if a phase exists */
|
|
394
|
-
hasPhase(name: string): boolean
|
|
395
|
-
|
|
396
|
-
//* Root Management --------------------------------
|
|
397
|
-
|
|
398
|
-
/** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
|
|
399
|
-
registerRoot(id: string, options?: RootOptions): () => void
|
|
400
|
-
/** Unregister a root */
|
|
401
|
-
unregisterRoot(id: string): void
|
|
402
|
-
/** Generate a unique root ID */
|
|
403
|
-
generateRootId(): string
|
|
404
|
-
/** Get the number of registered roots */
|
|
405
|
-
getRootCount(): number
|
|
406
|
-
/** Check if any root is registered and ready */
|
|
407
|
-
readonly isReady: boolean
|
|
408
|
-
/** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
|
|
409
|
-
onRootReady(callback: () => void): () => void
|
|
410
|
-
|
|
411
|
-
//* Job Registration --------------------------------
|
|
412
|
-
|
|
413
|
-
/** Register a job with the scheduler (returns unsubscribe function) */
|
|
414
|
-
register(
|
|
415
|
-
callback: FrameNextCallback,
|
|
416
|
-
options?: {
|
|
417
|
-
id?: string
|
|
418
|
-
rootId?: string
|
|
419
|
-
phase?: string
|
|
420
|
-
before?: string | string[]
|
|
421
|
-
after?: string | string[]
|
|
422
|
-
priority?: number
|
|
423
|
-
fps?: number
|
|
424
|
-
drop?: boolean
|
|
425
|
-
enabled?: boolean
|
|
426
|
-
},
|
|
427
|
-
): () => void
|
|
428
|
-
/** Update a job's options */
|
|
429
|
-
updateJob(
|
|
430
|
-
id: string,
|
|
431
|
-
options: {
|
|
432
|
-
priority?: number
|
|
433
|
-
fps?: number
|
|
434
|
-
drop?: boolean
|
|
435
|
-
enabled?: boolean
|
|
436
|
-
phase?: string
|
|
437
|
-
before?: string | string[]
|
|
438
|
-
after?: string | string[]
|
|
439
|
-
},
|
|
440
|
-
): void
|
|
441
|
-
/** Unregister a job by ID */
|
|
442
|
-
unregister(id: string, rootId?: string): void
|
|
443
|
-
/** Get the number of registered jobs */
|
|
444
|
-
getJobCount(): number
|
|
445
|
-
/** Get all job IDs */
|
|
446
|
-
getJobIds(): string[]
|
|
447
|
-
|
|
448
|
-
//* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
|
|
449
|
-
|
|
450
|
-
/** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
|
|
451
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
|
|
452
|
-
|
|
453
|
-
//* Idle Callbacks (for legacy addTail) --------------------------------
|
|
454
|
-
|
|
455
|
-
/** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
|
|
456
|
-
onIdle(callback: (timestamp: number) => void): () => void
|
|
457
|
-
|
|
458
|
-
//* Frame Loop Control --------------------------------
|
|
459
|
-
|
|
460
|
-
/** Start the scheduler loop */
|
|
461
|
-
start(): void
|
|
462
|
-
/** Stop the scheduler loop */
|
|
463
|
-
stop(): void
|
|
464
|
-
/** Check if the scheduler is running */
|
|
465
|
-
readonly isRunning: boolean
|
|
466
|
-
/** Get/set the frameloop mode ('always', 'demand', 'never') */
|
|
467
|
-
frameloop: Frameloop
|
|
468
|
-
/** Independent mode - runs without Canvas, callbacks receive timing-only state */
|
|
469
|
-
independent: boolean
|
|
470
|
-
|
|
471
|
-
//* Manual Stepping --------------------------------
|
|
472
|
-
|
|
473
|
-
/** Manually step all jobs once (for frameloop='never' or testing) */
|
|
474
|
-
step(timestamp?: number): void
|
|
475
|
-
/** Manually step a single job by ID */
|
|
476
|
-
stepJob(id: string, timestamp?: number): void
|
|
477
|
-
/** Request frame(s) to be rendered (for frameloop='demand') */
|
|
478
|
-
invalidate(frames?: number): void
|
|
479
|
-
|
|
480
|
-
//* Per-Job Control --------------------------------
|
|
481
|
-
|
|
482
|
-
/** Check if a job is paused */
|
|
483
|
-
isJobPaused(id: string): boolean
|
|
484
|
-
/** Pause a job */
|
|
485
|
-
pauseJob(id: string): void
|
|
486
|
-
/** Resume a job */
|
|
487
|
-
resumeJob(id: string): void
|
|
488
|
-
/** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
|
|
489
|
-
subscribeJobState(id: string, listener: () => void): () => void
|
|
490
|
-
}
|
|
415
|
+
type StorageStore = Record<string, StorageLike | StorageRecord>
|
|
491
416
|
|
|
492
417
|
//* Renderer Types ========================================
|
|
493
418
|
|
|
@@ -502,6 +427,18 @@ type Subscription = {
|
|
|
502
427
|
store: RootStore
|
|
503
428
|
}
|
|
504
429
|
|
|
430
|
+
/** Per-pointer state for multi-touch and XR support */
|
|
431
|
+
type PointerState = {
|
|
432
|
+
/** Objects currently hovered by this pointer */
|
|
433
|
+
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
434
|
+
/** Objects capturing this pointer */
|
|
435
|
+
captured: Map<THREE$1.Object3D, PointerCaptureTarget>
|
|
436
|
+
/** Initial click position [x, y] */
|
|
437
|
+
initialClick: [x: number, y: number]
|
|
438
|
+
/** Objects hit on initial click */
|
|
439
|
+
initialHits: THREE$1.Object3D[]
|
|
440
|
+
}
|
|
441
|
+
|
|
505
442
|
type Dpr = number | [min: number, max: number]
|
|
506
443
|
|
|
507
444
|
interface Size {
|
|
@@ -543,12 +480,21 @@ interface Performance {
|
|
|
543
480
|
|
|
544
481
|
interface InternalState {
|
|
545
482
|
interaction: THREE$1.Object3D[]
|
|
546
|
-
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
547
483
|
subscribers: Subscription[]
|
|
484
|
+
/** Per-pointer state (hover, capture, click tracking) - replaces hovered, capturedMap, initialClick, initialHits */
|
|
485
|
+
pointerMap: Map<number, PointerState>
|
|
486
|
+
/** Pointers needing raycast this frame (used with frameTimedRaycasts) */
|
|
487
|
+
pointerDirty: Map<number, DomEvent>
|
|
488
|
+
/** Last event received (for events.update() compatibility) */
|
|
489
|
+
lastEvent: React$1.RefObject<DomEvent | null>
|
|
490
|
+
/** @deprecated Use pointerMap.get(pointerId).hovered instead */
|
|
491
|
+
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
492
|
+
/** @deprecated Use pointerMap.get(pointerId).captured instead */
|
|
548
493
|
capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
|
|
494
|
+
/** @deprecated Use pointerMap.get(pointerId).initialClick instead */
|
|
549
495
|
initialClick: [x: number, y: number]
|
|
496
|
+
/** @deprecated Use pointerMap.get(pointerId).initialHits instead */
|
|
550
497
|
initialHits: THREE$1.Object3D[]
|
|
551
|
-
lastEvent: React$1.RefObject<DomEvent | null>
|
|
552
498
|
/** Visibility event registry (onFramed, onOccluded, onVisible) */
|
|
553
499
|
visibilityRegistry: Map<string, VisibilityEntry>
|
|
554
500
|
/** Whether occlusion queries are enabled (WebGPU only) */
|
|
@@ -567,6 +513,12 @@ interface InternalState {
|
|
|
567
513
|
actualRenderer: R3FRenderer
|
|
568
514
|
/** Global scheduler reference (for useFrame hook) */
|
|
569
515
|
scheduler: SchedulerApi | null
|
|
516
|
+
/**
|
|
517
|
+
* Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
|
|
518
|
+
* `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
|
|
519
|
+
* render-phase takeover. Used by `useRenderPipeline`.
|
|
520
|
+
*/
|
|
521
|
+
renderOverride?: (() => void) | null
|
|
570
522
|
/** This root's unique ID in the global scheduler */
|
|
571
523
|
rootId?: string
|
|
572
524
|
/** Function to unregister this root from the global scheduler */
|
|
@@ -574,14 +526,31 @@ interface InternalState {
|
|
|
574
526
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
575
527
|
container?: THREE$1.Object3D
|
|
576
528
|
/**
|
|
577
|
-
* CanvasTarget
|
|
578
|
-
*
|
|
529
|
+
* The CanvasTarget this root sizes and renders through.
|
|
530
|
+
*
|
|
531
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
532
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
533
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
534
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
535
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
579
536
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
580
537
|
*/
|
|
581
538
|
canvasTarget?: CanvasTarget
|
|
539
|
+
/**
|
|
540
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
541
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
542
|
+
*
|
|
543
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
544
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
545
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
546
|
+
* invalidate some other canvas's descriptor instead.
|
|
547
|
+
*
|
|
548
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
549
|
+
*/
|
|
550
|
+
canvasTargetSizeDirty?: boolean
|
|
582
551
|
/**
|
|
583
552
|
* Whether multi-canvas rendering is active.
|
|
584
|
-
* True when any canvas uses `
|
|
553
|
+
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
585
554
|
* When true, setCanvasTarget is called before each render.
|
|
586
555
|
*/
|
|
587
556
|
isMultiCanvas?: boolean
|
|
@@ -679,8 +648,8 @@ interface RootState {
|
|
|
679
648
|
setSize: (width?: number, height?: number, top?: number, left?: number) => void
|
|
680
649
|
/** Shortcut to manual setting the pixel ratio */
|
|
681
650
|
setDpr: (dpr: Dpr) => void
|
|
682
|
-
/** Shortcut to setting frameloop flags */
|
|
683
|
-
setFrameloop: (frameloop
|
|
651
|
+
/** Shortcut to setting frameloop flags. No args resets to 'always'. */
|
|
652
|
+
setFrameloop: (frameloop?: Frameloop) => void
|
|
684
653
|
/** Set error state to propagate to error boundary */
|
|
685
654
|
setError: (error: Error | null) => void
|
|
686
655
|
/** Current error state (null when no error) */
|
|
@@ -688,13 +657,19 @@ interface RootState {
|
|
|
688
657
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
689
658
|
uniforms: UniformStore
|
|
690
659
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
691
|
-
nodes:
|
|
692
|
-
/** Global TSL
|
|
693
|
-
|
|
694
|
-
/**
|
|
695
|
-
|
|
696
|
-
/** Global
|
|
697
|
-
|
|
660
|
+
nodes: NodeStore
|
|
661
|
+
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
662
|
+
buffers: BufferStore
|
|
663
|
+
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
664
|
+
gpuStorage: StorageStore
|
|
665
|
+
/** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
|
|
666
|
+
textures: Map<string, THREE$1.Texture>
|
|
667
|
+
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
668
|
+
_textureRefs: Map<string, number>
|
|
669
|
+
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
670
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
671
|
+
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
672
|
+
passes: PassRecord
|
|
698
673
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
699
674
|
_hmrVersion: number
|
|
700
675
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -743,6 +718,20 @@ interface Renderer {
|
|
|
743
718
|
render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
|
|
744
719
|
}
|
|
745
720
|
|
|
721
|
+
//* Color Management Config ==============================
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Color management configuration shared by both WebGL and WebGPU renderers.
|
|
725
|
+
*/
|
|
726
|
+
interface ColorManagementConfig {
|
|
727
|
+
/**
|
|
728
|
+
* Color space assigned to 8-bit input textures (color maps).
|
|
729
|
+
* Defaults to sRGB. Most textures are authored in sRGB.
|
|
730
|
+
* @default THREE.SRGBColorSpace
|
|
731
|
+
*/
|
|
732
|
+
textureColorSpace?: THREE$1.ColorSpace
|
|
733
|
+
}
|
|
734
|
+
|
|
746
735
|
//* WebGL Renderer Props ==============================
|
|
747
736
|
|
|
748
737
|
type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
|
|
@@ -753,7 +742,7 @@ type GLProps =
|
|
|
753
742
|
| Renderer
|
|
754
743
|
| ((defaultProps: DefaultGLProps) => Renderer)
|
|
755
744
|
| ((defaultProps: DefaultGLProps) => Promise<Renderer>)
|
|
756
|
-
| Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
|
|
745
|
+
| (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
|
|
757
746
|
|
|
758
747
|
//* WebGPU Renderer Props ==============================
|
|
759
748
|
|
|
@@ -768,20 +757,27 @@ type DefaultRendererProps = {
|
|
|
768
757
|
*/
|
|
769
758
|
interface CanvasSchedulerConfig {
|
|
770
759
|
/**
|
|
771
|
-
*
|
|
772
|
-
|
|
760
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
761
|
+
*/
|
|
762
|
+
before?: string | string[]
|
|
763
|
+
/**
|
|
764
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
765
|
+
*/
|
|
766
|
+
after?: string | string[]
|
|
767
|
+
/**
|
|
768
|
+
* Numeric root order. Lower values run first.
|
|
773
769
|
*/
|
|
774
|
-
|
|
770
|
+
order?: number
|
|
775
771
|
/**
|
|
776
|
-
* Limit this
|
|
772
|
+
* Limit this Canvas's default render job (frames per second).
|
|
777
773
|
*/
|
|
778
774
|
fps?: number
|
|
779
775
|
}
|
|
780
776
|
|
|
781
777
|
/**
|
|
782
|
-
* Extended renderer configuration for multi-canvas support.
|
|
778
|
+
* Extended renderer configuration for multi-canvas support and color management.
|
|
783
779
|
*/
|
|
784
|
-
interface RendererConfigExtended {
|
|
780
|
+
interface RendererConfigExtended extends ColorManagementConfig {
|
|
785
781
|
/** Share renderer from another canvas (WebGPU only) */
|
|
786
782
|
primaryCanvas?: string
|
|
787
783
|
/** Canvas-level scheduler options */
|
|
@@ -846,8 +842,6 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
846
842
|
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
847
843
|
*/
|
|
848
844
|
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
845
|
/** Creates an orthographic camera */
|
|
852
846
|
orthographic?: boolean
|
|
853
847
|
/**
|
|
@@ -862,14 +856,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
862
856
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
863
857
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
864
858
|
dpr?: Dpr
|
|
865
|
-
/**
|
|
866
|
-
|
|
859
|
+
/**
|
|
860
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
861
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
862
|
+
*/
|
|
863
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
867
864
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
868
865
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
869
866
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
870
867
|
camera?: CameraProps
|
|
871
868
|
/** An R3F event manager to manage elements' pointer events */
|
|
872
|
-
events?: (store: RootStore) => EventManager<
|
|
869
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
873
870
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
874
871
|
onCreated?: (state: RootState) => void
|
|
875
872
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -958,7 +955,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
958
955
|
object?: T
|
|
959
956
|
dispose?: null
|
|
960
957
|
attach?: AttachType<T>
|
|
961
|
-
onUpdate?: (self: T) => void
|
|
962
958
|
}
|
|
963
959
|
|
|
964
960
|
interface Instance<O = any> {
|
|
@@ -973,8 +969,6 @@ interface Instance<O = any> {
|
|
|
973
969
|
attach?: AttachType<O>
|
|
974
970
|
previousAttach?: any
|
|
975
971
|
isHidden: boolean
|
|
976
|
-
/** Deferred ref props to apply in commitMount */
|
|
977
|
-
deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
|
|
978
972
|
/** Set of props that have been applied via once() */
|
|
979
973
|
appliedOnce?: Set<string>
|
|
980
974
|
}
|
|
@@ -1100,7 +1094,7 @@ interface CanvasProps
|
|
|
1100
1094
|
*/
|
|
1101
1095
|
resize?: Options
|
|
1102
1096
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1103
|
-
eventSource?:
|
|
1097
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1104
1098
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1105
1099
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1106
1100
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1208,70 +1202,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1208
1202
|
|
|
1209
1203
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1210
1204
|
|
|
1211
|
-
//* Global Types ==============================
|
|
1205
|
+
//* Global TSL Types ==============================
|
|
1212
1206
|
|
|
1213
1207
|
declare global {
|
|
1214
|
-
/** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
|
|
1215
|
-
interface UniformNode<T = unknown> extends Node {
|
|
1216
|
-
value: T
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
1208
|
/**
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1222
|
-
* The function returns a ShaderNodeObject when called.
|
|
1223
|
-
*
|
|
1224
|
-
* @example
|
|
1225
|
-
* ```tsx
|
|
1226
|
-
* // Define a shader function
|
|
1227
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1228
|
-
* return mix(color1, color2, factor)
|
|
1229
|
-
* })
|
|
1230
|
-
*
|
|
1231
|
-
* // Type when retrieving from nodes store
|
|
1232
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1233
|
-
*
|
|
1234
|
-
* // Or with specific return type
|
|
1235
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1236
|
-
* ```
|
|
1209
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1210
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1237
1211
|
*/
|
|
1238
|
-
type
|
|
1212
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1213
|
+
readonly shaderNode: unknown
|
|
1214
|
+
readonly id: number
|
|
1215
|
+
}
|
|
1239
1216
|
|
|
1240
|
-
/**
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
*/
|
|
1249
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1217
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1218
|
+
type LegacyTSLNodeLike = {
|
|
1219
|
+
label?: ((label: string) => unknown) | string
|
|
1220
|
+
setName?: (name: string) => unknown
|
|
1221
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1222
|
+
|
|
1223
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1224
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1250
1225
|
|
|
1251
1226
|
/**
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1255
|
-
*
|
|
1256
|
-
* - Node: base Three.js node type
|
|
1257
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1258
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1259
|
-
*
|
|
1260
|
-
* @example
|
|
1261
|
-
* ```tsx
|
|
1262
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1263
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1264
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1265
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1266
|
-
* }))
|
|
1267
|
-
*
|
|
1268
|
-
* // Can narrow with type guard or assertion when needed
|
|
1269
|
-
* if (typeof blendColorFn === 'function') {
|
|
1270
|
-
* blendColorFn(someColor, 0.5)
|
|
1271
|
-
* }
|
|
1272
|
-
* ```
|
|
1227
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1228
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1229
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1230
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1273
1231
|
*/
|
|
1274
|
-
type
|
|
1232
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1233
|
+
? TNodeType
|
|
1234
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1235
|
+
? TNodeType
|
|
1236
|
+
: T extends number
|
|
1237
|
+
? 'float'
|
|
1238
|
+
: T extends boolean
|
|
1239
|
+
? 'bool'
|
|
1240
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1241
|
+
? 'color'
|
|
1242
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1243
|
+
? 'vec4'
|
|
1244
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1245
|
+
? 'vec3'
|
|
1246
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1247
|
+
? 'vec2'
|
|
1248
|
+
: T extends three_webgpu.Matrix4
|
|
1249
|
+
? 'mat4'
|
|
1250
|
+
: T extends three_webgpu.Matrix3
|
|
1251
|
+
? 'mat3'
|
|
1252
|
+
: T extends three_webgpu.Matrix2
|
|
1253
|
+
? 'mat2'
|
|
1254
|
+
: unknown
|
|
1255
|
+
|
|
1256
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1257
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1258
|
+
? TValue
|
|
1259
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1260
|
+
? TValue
|
|
1261
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1262
|
+
? three_webgpu.Color
|
|
1263
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1264
|
+
? three_webgpu.Vector4
|
|
1265
|
+
: T extends { x: number; y: number; z: number }
|
|
1266
|
+
? three_webgpu.Vector3
|
|
1267
|
+
: T extends { x: number; y: number }
|
|
1268
|
+
? three_webgpu.Vector2
|
|
1269
|
+
: T extends number
|
|
1270
|
+
? number
|
|
1271
|
+
: T extends boolean
|
|
1272
|
+
? boolean
|
|
1273
|
+
: T
|
|
1274
|
+
|
|
1275
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1276
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1277
|
+
|
|
1278
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1279
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1280
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1284
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1275
1285
|
|
|
1276
1286
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1277
1287
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1296,7 +1306,7 @@ declare global {
|
|
|
1296
1306
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1297
1307
|
* Supports:
|
|
1298
1308
|
* - Primitives: number, string (color), boolean
|
|
1299
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1309
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1300
1310
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1301
1311
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1302
1312
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1309,226 +1319,124 @@ declare global {
|
|
|
1309
1319
|
| three_webgpu.Vector2
|
|
1310
1320
|
| three_webgpu.Vector3
|
|
1311
1321
|
| three_webgpu.Vector4
|
|
1322
|
+
| three_webgpu.Matrix2
|
|
1312
1323
|
| three_webgpu.Matrix3
|
|
1313
1324
|
| three_webgpu.Matrix4
|
|
1314
|
-
|
|
|
1315
|
-
|
|
|
1316
|
-
| { x: number; y
|
|
1317
|
-
|
|
|
1325
|
+
| { x: number; y: number }
|
|
1326
|
+
| { x: number; y: number; z: number }
|
|
1327
|
+
| { x: number; y: number; z: number; w: number }
|
|
1328
|
+
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1329
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1318
1330
|
| UniformNode
|
|
1319
1331
|
|
|
1320
1332
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1321
1333
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1322
1334
|
}
|
|
1323
1335
|
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
declare module 'three/tsl' {
|
|
1336
|
+
declare global {
|
|
1327
1337
|
/**
|
|
1328
|
-
*
|
|
1329
|
-
*
|
|
1338
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1339
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1340
|
+
* is r185, so the new name is the only one.
|
|
1330
1341
|
*/
|
|
1331
|
-
|
|
1332
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1333
|
-
): ShaderCallable<R>
|
|
1342
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1334
1343
|
|
|
1335
1344
|
/**
|
|
1336
|
-
*
|
|
1337
|
-
*
|
|
1345
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1346
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1347
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1338
1348
|
*/
|
|
1339
|
-
|
|
1340
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1341
|
-
): ShaderCallable<R>
|
|
1349
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1342
1350
|
|
|
1343
1351
|
/**
|
|
1344
|
-
*
|
|
1345
|
-
*
|
|
1352
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1353
|
+
*
|
|
1354
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1355
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1356
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1357
|
+
* {@link RenderPipelineCallbackState}.
|
|
1358
|
+
*
|
|
1359
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1360
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1361
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1362
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1363
|
+
*
|
|
1364
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1365
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1366
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1367
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1346
1368
|
*/
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1369
|
+
interface PassRecord {
|
|
1370
|
+
scenePass?: ScenePassNode
|
|
1371
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1372
|
+
}
|
|
1351
1373
|
|
|
1352
1374
|
/**
|
|
1353
|
-
*
|
|
1375
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1376
|
+
*
|
|
1377
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1378
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1379
|
+
*
|
|
1380
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1381
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1354
1382
|
*/
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
/**
|
|
1362
|
-
* PostProcessing Types for usePostProcessing hook (WebGPU only)
|
|
1363
|
-
*/
|
|
1364
|
-
|
|
1365
|
-
|
|
1383
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1384
|
+
renderPipeline: ThreeRenderPipeline
|
|
1385
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1386
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1387
|
+
isLegacy: false
|
|
1388
|
+
}
|
|
1366
1389
|
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1390
|
+
/**
|
|
1391
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1392
|
+
*
|
|
1393
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1394
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1395
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1396
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1397
|
+
*/
|
|
1398
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1370
1399
|
|
|
1371
1400
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1372
|
-
type
|
|
1401
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1373
1402
|
|
|
1374
1403
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1375
|
-
type
|
|
1404
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1376
1405
|
|
|
1377
|
-
/**
|
|
1378
|
-
interface
|
|
1406
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1407
|
+
interface UseRenderPipelineActions {
|
|
1379
1408
|
/** Current passes from state */
|
|
1380
1409
|
passes: PassRecord
|
|
1381
|
-
/** PostProcessing instance (null if not initialized) */
|
|
1382
|
-
postProcessing: any | null // THREE.PostProcessing
|
|
1383
1410
|
/** Clear all passes from state */
|
|
1384
1411
|
clearPasses: () => void
|
|
1385
|
-
/** Reset
|
|
1412
|
+
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1386
1413
|
reset: () => void
|
|
1387
1414
|
/** Re-run setup/main callbacks with current closure values */
|
|
1388
1415
|
rebuild: () => void
|
|
1389
|
-
/** True when PostProcessing is configured and ready */
|
|
1390
|
-
isReady: boolean
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
//* useFrameNext Types ==============================
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
//* Global Type Declarations ==============================
|
|
1399
|
-
|
|
1400
|
-
declare global {
|
|
1401
|
-
// Job --------------------------------
|
|
1402
|
-
|
|
1403
|
-
/**
|
|
1404
|
-
* Internal job representation in the scheduler
|
|
1405
|
-
*/
|
|
1406
|
-
interface Job {
|
|
1407
|
-
/** Unique identifier */
|
|
1408
|
-
id: string
|
|
1409
|
-
/** The callback to execute */
|
|
1410
|
-
callback: FrameNextCallback
|
|
1411
|
-
/** Phase this job belongs to */
|
|
1412
|
-
phase: string
|
|
1413
|
-
/** Run before these phases/job ids */
|
|
1414
|
-
before: Set<string>
|
|
1415
|
-
/** Run after these phases/job ids */
|
|
1416
|
-
after: Set<string>
|
|
1417
|
-
/** Priority within phase (higher first) */
|
|
1418
|
-
priority: number
|
|
1419
|
-
/** Insertion order for deterministic tie-breaking */
|
|
1420
|
-
index: number
|
|
1421
|
-
/** Max FPS for this job (undefined = no limit) */
|
|
1422
|
-
fps?: number
|
|
1423
|
-
/** Drop frames when behind (true) or catch up (false) */
|
|
1424
|
-
drop: boolean
|
|
1425
|
-
/** Last run timestamp (ms) */
|
|
1426
|
-
lastRun?: number
|
|
1427
|
-
/** Whether job is enabled */
|
|
1428
|
-
enabled: boolean
|
|
1429
|
-
/** Internal flag: system jobs (like default render) don't block user render takeover */
|
|
1430
|
-
system?: boolean
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
// Phase Graph --------------------------------
|
|
1434
|
-
|
|
1435
|
-
/**
|
|
1436
|
-
* A node in the phase graph
|
|
1437
|
-
*/
|
|
1438
|
-
interface PhaseNode {
|
|
1439
|
-
/** Phase name */
|
|
1440
|
-
name: string
|
|
1441
|
-
/** Whether this was auto-generated from a before/after constraint */
|
|
1442
|
-
isAutoGenerated: boolean
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
/**
|
|
1446
|
-
* Options for creating a job from hook options
|
|
1447
|
-
*/
|
|
1448
|
-
interface JobOptions {
|
|
1449
|
-
id?: string
|
|
1450
|
-
phase?: string
|
|
1451
|
-
before?: string | string[]
|
|
1452
|
-
after?: string | string[]
|
|
1453
|
-
priority?: number
|
|
1454
|
-
fps?: number
|
|
1455
|
-
drop?: boolean
|
|
1456
|
-
enabled?: boolean
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
// Frame Loop State --------------------------------
|
|
1460
|
-
|
|
1461
|
-
/**
|
|
1462
|
-
* Internal frame loop state
|
|
1463
|
-
*/
|
|
1464
|
-
interface FrameLoopState {
|
|
1465
|
-
/** Whether the loop is running */
|
|
1466
|
-
running: boolean
|
|
1467
|
-
/** Current RAF handle */
|
|
1468
|
-
rafHandle: number | null
|
|
1469
|
-
/** Last frame timestamp in ms (null = uninitialized) */
|
|
1470
|
-
lastTime: number | null
|
|
1471
|
-
/** Frame counter */
|
|
1472
|
-
frameCount: number
|
|
1473
|
-
/** Elapsed time since first frame in ms */
|
|
1474
|
-
elapsedTime: number
|
|
1475
|
-
/** createdAt timestamp in ms */
|
|
1476
|
-
createdAt: number
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
// Root Entry --------------------------------
|
|
1480
|
-
|
|
1481
|
-
/**
|
|
1482
|
-
* Internal representation of a registered root (Canvas).
|
|
1483
|
-
* Tracks jobs and manages rebuild state for this root.
|
|
1484
|
-
* @internal
|
|
1485
|
-
*/
|
|
1486
|
-
interface RootEntry {
|
|
1487
|
-
/** Unique identifier for this root */
|
|
1488
|
-
id: string
|
|
1489
|
-
/** Function to get the root's current state. Returns any to support independent mode. */
|
|
1490
|
-
getState: () => any
|
|
1491
|
-
/** Map of job IDs to Job objects */
|
|
1492
|
-
jobs: Map<string, Job>
|
|
1493
|
-
/** Cached sorted job list for execution order */
|
|
1494
|
-
sortedJobs: Job[]
|
|
1495
|
-
/** Whether sortedJobs needs rebuilding */
|
|
1496
|
-
needsRebuild: boolean
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
/**
|
|
1500
|
-
* Internal representation of a global job (deprecated API).
|
|
1501
|
-
* Global jobs run once per frame, not per-root.
|
|
1502
|
-
* Used by legacy addEffect/addAfterEffect APIs.
|
|
1503
|
-
* @internal
|
|
1504
|
-
* @deprecated Use useFrame with phases instead
|
|
1505
|
-
*/
|
|
1506
|
-
interface GlobalJob {
|
|
1507
|
-
/** Unique identifier for this global job */
|
|
1508
|
-
id: string
|
|
1509
|
-
/** Callback invoked with RAF timestamp in ms */
|
|
1510
|
-
callback: (timestamp: number) => void
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
// HMR Support --------------------------------
|
|
1514
|
-
|
|
1515
|
-
/**
|
|
1516
|
-
* Hot Module Replacement data structure for preserving scheduler state
|
|
1517
|
-
* @internal
|
|
1518
|
-
*/
|
|
1519
|
-
interface HMRData {
|
|
1520
|
-
/** Shared data object for storing values across reloads */
|
|
1521
|
-
data: Record<string, any>
|
|
1522
|
-
/** Optional function to accept HMR updates */
|
|
1523
|
-
accept?: () => void
|
|
1524
1416
|
}
|
|
1525
1417
|
|
|
1526
|
-
// Default Phases --------------------------------
|
|
1527
|
-
|
|
1528
1418
|
/**
|
|
1529
|
-
*
|
|
1419
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1420
|
+
*
|
|
1421
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1422
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1423
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1530
1424
|
*/
|
|
1531
|
-
type
|
|
1425
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1426
|
+
(
|
|
1427
|
+
| {
|
|
1428
|
+
/** True when RenderPipeline is configured and ready */
|
|
1429
|
+
isReady: true
|
|
1430
|
+
/** RenderPipeline instance */
|
|
1431
|
+
renderPipeline: ThreeRenderPipeline
|
|
1432
|
+
}
|
|
1433
|
+
| {
|
|
1434
|
+
/** False until the pipeline has been created */
|
|
1435
|
+
isReady: false
|
|
1436
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1437
|
+
renderPipeline: null
|
|
1438
|
+
}
|
|
1439
|
+
)
|
|
1532
1440
|
}
|
|
1533
1441
|
|
|
1534
1442
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1607,10 +1515,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1607
1515
|
|
|
1608
1516
|
/**
|
|
1609
1517
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1610
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1518
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1519
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1611
1520
|
*/
|
|
1612
1521
|
type NodeProps<P> = {
|
|
1613
|
-
[K in keyof P as P[K] extends
|
|
1522
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1614
1523
|
}
|
|
1615
1524
|
|
|
1616
1525
|
interface ReactProps<P> {
|
|
@@ -1631,11 +1540,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1631
1540
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1632
1541
|
}
|
|
1633
1542
|
|
|
1543
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1544
|
+
type Object3DMethod = NonNullable<
|
|
1545
|
+
{
|
|
1546
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1547
|
+
}[keyof Object3D]
|
|
1548
|
+
>
|
|
1549
|
+
|
|
1634
1550
|
type ThreeExports = typeof THREE
|
|
1635
1551
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1636
1552
|
|
|
1637
1553
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1638
|
-
|
|
1554
|
+
/**
|
|
1555
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1556
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1557
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1558
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1559
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1560
|
+
*/
|
|
1561
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1562
|
+
object: object
|
|
1563
|
+
ref?: React.Ref<any>
|
|
1564
|
+
[prop: string]: unknown
|
|
1565
|
+
}
|
|
1639
1566
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1640
1567
|
threeAudio: ThreeElementsImpl['audio']
|
|
1641
1568
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1676,6 +1603,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1676
1603
|
type three_d_Matrix4 = Matrix4;
|
|
1677
1604
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1678
1605
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1606
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1679
1607
|
type three_d_Quaternion = Quaternion;
|
|
1680
1608
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1681
1609
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1690,7 +1618,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1690
1618
|
type three_d_Vector4 = Vector4;
|
|
1691
1619
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1692
1620
|
declare namespace three_d {
|
|
1693
|
-
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1621
|
+
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Object3DMethod as Object3DMethod, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1694
1622
|
}
|
|
1695
1623
|
|
|
1696
1624
|
/**
|
|
@@ -1700,7 +1628,7 @@ declare namespace three_d {
|
|
|
1700
1628
|
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
1701
1629
|
*
|
|
1702
1630
|
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
1703
|
-
* Secondary canvas: Has `
|
|
1631
|
+
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
1704
1632
|
*/
|
|
1705
1633
|
|
|
1706
1634
|
interface PrimaryCanvasEntry {
|
|
@@ -1768,12 +1696,23 @@ type EnvironmentLoaderProps = {
|
|
|
1768
1696
|
* const texture = useEnvironment({ preset: 'sunset' })
|
|
1769
1697
|
* ```
|
|
1770
1698
|
*/
|
|
1771
|
-
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture
|
|
1699
|
+
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
|
|
1772
1700
|
declare namespace useEnvironment {
|
|
1773
1701
|
var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
|
|
1774
1702
|
var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
|
|
1775
1703
|
}
|
|
1776
|
-
|
|
1704
|
+
/**
|
|
1705
|
+
* Options accepted by `useEnvironment.preload`.
|
|
1706
|
+
*
|
|
1707
|
+
* `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
|
|
1708
|
+
* applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
|
|
1709
|
+
* advertise an option this function silently ignores.
|
|
1710
|
+
*
|
|
1711
|
+
* This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
|
|
1712
|
+
* `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
|
|
1713
|
+
* type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
|
|
1714
|
+
*/
|
|
1715
|
+
type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
|
|
1777
1716
|
type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
|
|
1778
1717
|
|
|
1779
1718
|
/**
|
|
@@ -1817,9 +1756,9 @@ type EnvironmentProps = {
|
|
|
1817
1756
|
blur?: number;
|
|
1818
1757
|
backgroundBlurriness?: number;
|
|
1819
1758
|
backgroundIntensity?: number;
|
|
1820
|
-
backgroundRotation?: Euler
|
|
1759
|
+
backgroundRotation?: Euler;
|
|
1821
1760
|
environmentIntensity?: number;
|
|
1822
|
-
environmentRotation?: Euler
|
|
1761
|
+
environmentRotation?: Euler;
|
|
1823
1762
|
map?: Texture$1;
|
|
1824
1763
|
preset?: PresetsType;
|
|
1825
1764
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -1903,7 +1842,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
1903
1842
|
declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
1904
1843
|
declare module '@react-three/fiber' {
|
|
1905
1844
|
interface ThreeElements {
|
|
1906
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1845
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
1907
1846
|
}
|
|
1908
1847
|
}
|
|
1909
1848
|
/**
|
|
@@ -2003,12 +1942,68 @@ declare module '@react-three/fiber' {
|
|
|
2003
1942
|
*/
|
|
2004
1943
|
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
2005
1944
|
|
|
1945
|
+
/**
|
|
1946
|
+
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
1947
|
+
*
|
|
1948
|
+
* When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
|
|
1949
|
+
* instance. Removing the old object from the interaction state and registering the new one from
|
|
1950
|
+
* scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
|
|
1951
|
+
* the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
|
|
1952
|
+
* is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
|
|
1953
|
+
* swap the user never asked to see (#3744).
|
|
1954
|
+
*
|
|
1955
|
+
* Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
|
|
1956
|
+
* left alone — releasing and re-acquiring it is precisely the glitch being avoided.
|
|
1957
|
+
*
|
|
1958
|
+
* Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
|
|
1959
|
+
* the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
|
|
1960
|
+
* cannot outlive the object it described.
|
|
1961
|
+
*/
|
|
1962
|
+
declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
|
|
2006
1963
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
2007
1964
|
declare function createEvents(store: RootStore): {
|
|
2008
1965
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
1966
|
+
flushDeferredPointers: () => void;
|
|
1967
|
+
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
2009
1968
|
};
|
|
2010
1969
|
/** Default R3F event manager for web */
|
|
2011
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1970
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1971
|
+
|
|
1972
|
+
interface RootExtension {
|
|
1973
|
+
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
1974
|
+
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
1975
|
+
name: string;
|
|
1976
|
+
/**
|
|
1977
|
+
* Called once per root, after its renderer exists and before `onCreated` and the first frame.
|
|
1978
|
+
* `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
|
|
1979
|
+
* to the primary canvas. Return fields to merge into the root's state, or nothing.
|
|
1980
|
+
*/
|
|
1981
|
+
setup?(store: RootStore): Partial<RootState> | void;
|
|
1982
|
+
/** Called when a root this extension set up unmounts. */
|
|
1983
|
+
dispose?(store: RootStore): void;
|
|
1984
|
+
/** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
|
|
1985
|
+
hmr?(store: RootStore): void;
|
|
1986
|
+
}
|
|
1987
|
+
/**
|
|
1988
|
+
* Register an extension. It is set up on every live root immediately, and on every root created
|
|
1989
|
+
* afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
|
|
1990
|
+
* it already set up keep its state and still get its dispose when they unmount.
|
|
1991
|
+
*/
|
|
1992
|
+
declare function registerRootExtension(extension: RootExtension): () => void;
|
|
1993
|
+
/**
|
|
1994
|
+
* Point a root's default render job at a different render function, or back at
|
|
1995
|
+
* `renderer.render(scene, camera)` with `null`.
|
|
1996
|
+
*
|
|
1997
|
+
* The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
|
|
1998
|
+
* boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
|
|
1999
|
+
*/
|
|
2000
|
+
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
2001
|
+
|
|
2002
|
+
/**
|
|
2003
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2004
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2005
|
+
*/
|
|
2006
|
+
declare function useStore(): RootStore;
|
|
2012
2007
|
|
|
2013
2008
|
/**
|
|
2014
2009
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -2021,419 +2016,13 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
|
|
|
2021
2016
|
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
2022
2017
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
2023
2018
|
*/
|
|
2024
|
-
declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
|
|
2019
|
+
declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
|
|
2025
2020
|
declare namespace useLoader {
|
|
2026
|
-
var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
|
|
2027
|
-
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
|
|
2021
|
+
var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike) => void;
|
|
2022
|
+
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
|
|
2028
2023
|
var loader: typeof getLoader;
|
|
2029
2024
|
}
|
|
2030
2025
|
|
|
2031
|
-
/**
|
|
2032
|
-
* Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
|
|
2033
|
-
*
|
|
2034
|
-
* Features:
|
|
2035
|
-
* - Single RAF loop for entire application
|
|
2036
|
-
* - Root registration (multiple Canvas support)
|
|
2037
|
-
* - Global phases for addEffect/addAfterEffect (deprecated)
|
|
2038
|
-
* - Per-root job management with phases, priorities, FPS throttling
|
|
2039
|
-
* - onIdle callbacks for addTail (deprecated)
|
|
2040
|
-
* - Demand mode support via invalidate()
|
|
2041
|
-
*/
|
|
2042
|
-
declare class Scheduler {
|
|
2043
|
-
private static readonly INSTANCE_KEY;
|
|
2044
|
-
private static get instance();
|
|
2045
|
-
private static set instance(value);
|
|
2046
|
-
/**
|
|
2047
|
-
* Get the global scheduler instance (creates if doesn't exist).
|
|
2048
|
-
* Uses HMR data to preserve instance across hot reloads.
|
|
2049
|
-
* @returns {Scheduler} The singleton scheduler instance
|
|
2050
|
-
*/
|
|
2051
|
-
static get(): Scheduler;
|
|
2052
|
-
/**
|
|
2053
|
-
* Reset the singleton instance. Stops the loop and clears all state.
|
|
2054
|
-
* Primarily used for testing to ensure clean state between tests.
|
|
2055
|
-
* @returns {void}
|
|
2056
|
-
*/
|
|
2057
|
-
static reset(): void;
|
|
2058
|
-
private roots;
|
|
2059
|
-
private phaseGraph;
|
|
2060
|
-
private loopState;
|
|
2061
|
-
private stoppedTime;
|
|
2062
|
-
private nextRootIndex;
|
|
2063
|
-
private globalBeforeJobs;
|
|
2064
|
-
private globalAfterJobs;
|
|
2065
|
-
private nextGlobalIndex;
|
|
2066
|
-
private idleCallbacks;
|
|
2067
|
-
private nextJobIndex;
|
|
2068
|
-
private jobStateListeners;
|
|
2069
|
-
private pendingFrames;
|
|
2070
|
-
private _frameloop;
|
|
2071
|
-
private _independent;
|
|
2072
|
-
private errorHandler;
|
|
2073
|
-
private rootReadyCallbacks;
|
|
2074
|
-
get phases(): string[];
|
|
2075
|
-
get frameloop(): Frameloop;
|
|
2076
|
-
set frameloop(mode: Frameloop);
|
|
2077
|
-
get isRunning(): boolean;
|
|
2078
|
-
get isReady(): boolean;
|
|
2079
|
-
get independent(): boolean;
|
|
2080
|
-
set independent(value: boolean);
|
|
2081
|
-
constructor();
|
|
2082
|
-
/**
|
|
2083
|
-
* Register a root (Canvas) with the scheduler.
|
|
2084
|
-
* The first root to register starts the RAF loop (if frameloop='always').
|
|
2085
|
-
* @param {string} id - Unique identifier for this root
|
|
2086
|
-
* @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
|
|
2087
|
-
* @returns {() => void} Unsubscribe function to remove this root
|
|
2088
|
-
*/
|
|
2089
|
-
registerRoot(id: string, options?: RootOptions): () => void;
|
|
2090
|
-
/**
|
|
2091
|
-
* Unregister a root from the scheduler.
|
|
2092
|
-
* Cleans up all job state listeners for this root's jobs.
|
|
2093
|
-
* The last root to unregister stops the RAF loop.
|
|
2094
|
-
* @param {string} id - The root ID to unregister
|
|
2095
|
-
* @returns {void}
|
|
2096
|
-
*/
|
|
2097
|
-
unregisterRoot(id: string): void;
|
|
2098
|
-
/**
|
|
2099
|
-
* Subscribe to be notified when a root becomes available.
|
|
2100
|
-
* Fires immediately if a root already exists.
|
|
2101
|
-
* @param {() => void} callback - Function called when first root registers
|
|
2102
|
-
* @returns {() => void} Unsubscribe function
|
|
2103
|
-
*/
|
|
2104
|
-
onRootReady(callback: () => void): () => void;
|
|
2105
|
-
/**
|
|
2106
|
-
* Notify all registered root-ready callbacks.
|
|
2107
|
-
* Called when the first root registers.
|
|
2108
|
-
* @returns {void}
|
|
2109
|
-
* @private
|
|
2110
|
-
*/
|
|
2111
|
-
private notifyRootReady;
|
|
2112
|
-
/**
|
|
2113
|
-
* Ensure a default root exists for independent mode.
|
|
2114
|
-
* Creates a minimal root with no state provider.
|
|
2115
|
-
* @returns {void}
|
|
2116
|
-
* @private
|
|
2117
|
-
*/
|
|
2118
|
-
private ensureDefaultRoot;
|
|
2119
|
-
/**
|
|
2120
|
-
* Trigger error handling for job errors.
|
|
2121
|
-
* Uses the bound error handler if available, otherwise logs to console.
|
|
2122
|
-
* @param {Error} error - The error to handle
|
|
2123
|
-
* @returns {void}
|
|
2124
|
-
*/
|
|
2125
|
-
triggerError(error: Error): void;
|
|
2126
|
-
/**
|
|
2127
|
-
* Add a named phase to the scheduler's execution order.
|
|
2128
|
-
* Marks all roots for rebuild to incorporate the new phase.
|
|
2129
|
-
* @param {string} name - The phase name (e.g., 'physics', 'postprocess')
|
|
2130
|
-
* @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
|
|
2131
|
-
* @returns {void}
|
|
2132
|
-
* @example
|
|
2133
|
-
* scheduler.addPhase('physics', { before: 'update' });
|
|
2134
|
-
* scheduler.addPhase('postprocess', { after: 'render' });
|
|
2135
|
-
*/
|
|
2136
|
-
addPhase(name: string, options?: AddPhaseOptions): void;
|
|
2137
|
-
/**
|
|
2138
|
-
* Check if a phase exists in the scheduler.
|
|
2139
|
-
* @param {string} name - The phase name to check
|
|
2140
|
-
* @returns {boolean} True if the phase exists
|
|
2141
|
-
*/
|
|
2142
|
-
hasPhase(name: string): boolean;
|
|
2143
|
-
/**
|
|
2144
|
-
* Register a global job that runs once per frame (not per-root).
|
|
2145
|
-
* Used internally by deprecated addEffect/addAfterEffect APIs.
|
|
2146
|
-
* @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
|
|
2147
|
-
* @param {string} id - Unique identifier for this global job
|
|
2148
|
-
* @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
|
|
2149
|
-
* @returns {() => void} Unsubscribe function to remove this global job
|
|
2150
|
-
* @deprecated Use useFrame with phases instead
|
|
2151
|
-
*/
|
|
2152
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
|
|
2153
|
-
/**
|
|
2154
|
-
* Register an idle callback that fires when the loop stops.
|
|
2155
|
-
* Used internally by deprecated addTail API.
|
|
2156
|
-
* @param {(timestamp: number) => void} callback - Function called when loop becomes idle
|
|
2157
|
-
* @returns {() => void} Unsubscribe function to remove this idle callback
|
|
2158
|
-
* @deprecated Use demand mode with invalidate() instead
|
|
2159
|
-
*/
|
|
2160
|
-
onIdle(callback: (timestamp: number) => void): () => void;
|
|
2161
|
-
/**
|
|
2162
|
-
* Notify all registered idle callbacks.
|
|
2163
|
-
* Called when the loop stops in demand mode.
|
|
2164
|
-
* @param {number} timestamp - The RAF timestamp when idle occurred
|
|
2165
|
-
* @returns {void}
|
|
2166
|
-
* @private
|
|
2167
|
-
*/
|
|
2168
|
-
private notifyIdle;
|
|
2169
|
-
/**
|
|
2170
|
-
* Register a job (frame callback) with a specific root.
|
|
2171
|
-
* This is the core registration method used by useFrame internally.
|
|
2172
|
-
* @param {FrameNextCallback} callback - The function to call each frame
|
|
2173
|
-
* @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
|
|
2174
|
-
* @param {string} [options.rootId] - Target root ID (defaults to first registered root)
|
|
2175
|
-
* @param {string} [options.id] - Unique job ID (auto-generated if not provided)
|
|
2176
|
-
* @param {string} [options.phase] - Execution phase (defaults to 'update')
|
|
2177
|
-
* @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
|
|
2178
|
-
* @param {number} [options.fps] - FPS throttle limit
|
|
2179
|
-
* @param {boolean} [options.drop] - Drop frames when behind (default true)
|
|
2180
|
-
* @param {boolean} [options.enabled] - Whether job is active (default true)
|
|
2181
|
-
* @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
|
|
2182
|
-
* @returns {() => void} Unsubscribe function to remove this job
|
|
2183
|
-
*/
|
|
2184
|
-
register(callback: FrameNextCallback, options?: JobOptions & {
|
|
2185
|
-
rootId?: string;
|
|
2186
|
-
system?: boolean;
|
|
2187
|
-
}): () => void;
|
|
2188
|
-
/**
|
|
2189
|
-
* Unregister a job by its ID.
|
|
2190
|
-
* Searches all roots if rootId is not provided.
|
|
2191
|
-
* @param {string} id - The job ID to unregister
|
|
2192
|
-
* @param {string} [rootId] - Optional root ID to search (searches all if not provided)
|
|
2193
|
-
* @returns {void}
|
|
2194
|
-
*/
|
|
2195
|
-
unregister(id: string, rootId?: string): void;
|
|
2196
|
-
/**
|
|
2197
|
-
* Update a job's options dynamically.
|
|
2198
|
-
* Searches all roots to find the job by ID.
|
|
2199
|
-
* Phase/constraint changes trigger a rebuild of the sorted job list.
|
|
2200
|
-
* @param {string} id - The job ID to update
|
|
2201
|
-
* @param {Partial<JobOptions>} options - The options to update
|
|
2202
|
-
* @returns {void}
|
|
2203
|
-
*/
|
|
2204
|
-
updateJob(id: string, options: Partial<JobOptions>): void;
|
|
2205
|
-
/**
|
|
2206
|
-
* Check if a job is currently paused (disabled).
|
|
2207
|
-
* @param {string} id - The job ID to check
|
|
2208
|
-
* @returns {boolean} True if the job exists and is paused
|
|
2209
|
-
*/
|
|
2210
|
-
isJobPaused(id: string): boolean;
|
|
2211
|
-
/**
|
|
2212
|
-
* Subscribe to state changes for a specific job.
|
|
2213
|
-
* Listener is called when job is paused or resumed.
|
|
2214
|
-
* @param {string} id - The job ID to subscribe to
|
|
2215
|
-
* @param {() => void} listener - Callback invoked on state changes
|
|
2216
|
-
* @returns {() => void} Unsubscribe function
|
|
2217
|
-
*/
|
|
2218
|
-
subscribeJobState(id: string, listener: () => void): () => void;
|
|
2219
|
-
/**
|
|
2220
|
-
* Notify all listeners that a job's state has changed.
|
|
2221
|
-
* @param {string} id - The job ID that changed
|
|
2222
|
-
* @returns {void}
|
|
2223
|
-
* @private
|
|
2224
|
-
*/
|
|
2225
|
-
private notifyJobStateChange;
|
|
2226
|
-
/**
|
|
2227
|
-
* Pause a job by ID (sets enabled=false).
|
|
2228
|
-
* Notifies any subscribed state listeners.
|
|
2229
|
-
* @param {string} id - The job ID to pause
|
|
2230
|
-
* @returns {void}
|
|
2231
|
-
*/
|
|
2232
|
-
pauseJob(id: string): void;
|
|
2233
|
-
/**
|
|
2234
|
-
* Resume a paused job by ID (sets enabled=true).
|
|
2235
|
-
* Resets job timing to prevent frame accumulation.
|
|
2236
|
-
* Notifies any subscribed state listeners.
|
|
2237
|
-
* @param {string} id - The job ID to resume
|
|
2238
|
-
* @returns {void}
|
|
2239
|
-
*/
|
|
2240
|
-
resumeJob(id: string): void;
|
|
2241
|
-
/**
|
|
2242
|
-
* Start the requestAnimationFrame loop.
|
|
2243
|
-
* Resets timing state (elapsedTime, frameCount) on start.
|
|
2244
|
-
* No-op if already running.
|
|
2245
|
-
* @returns {void}
|
|
2246
|
-
*/
|
|
2247
|
-
start(): void;
|
|
2248
|
-
/**
|
|
2249
|
-
* Stop the requestAnimationFrame loop.
|
|
2250
|
-
* Cancels any pending RAF callback.
|
|
2251
|
-
* No-op if not running.
|
|
2252
|
-
* @returns {void}
|
|
2253
|
-
*/
|
|
2254
|
-
stop(): void;
|
|
2255
|
-
/**
|
|
2256
|
-
* Request frames to be rendered in demand mode.
|
|
2257
|
-
* Accumulates pending frames (capped at 60) and starts the loop if not running.
|
|
2258
|
-
* No-op if frameloop is not 'demand'.
|
|
2259
|
-
* @param {number} [frames=1] - Number of frames to request
|
|
2260
|
-
* @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
|
|
2261
|
-
* - `false` (default): Sets pending frames to the specified value (replaces existing count)
|
|
2262
|
-
* - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
|
|
2263
|
-
* @returns {void}
|
|
2264
|
-
* @example
|
|
2265
|
-
* // Request a single frame render
|
|
2266
|
-
* scheduler.invalidate();
|
|
2267
|
-
*
|
|
2268
|
-
* @example
|
|
2269
|
-
* // Request 5 frames (e.g., for animations)
|
|
2270
|
-
* scheduler.invalidate(5);
|
|
2271
|
-
*
|
|
2272
|
-
* @example
|
|
2273
|
-
* // Set pending frames to exactly 3 (don't stack with existing)
|
|
2274
|
-
* scheduler.invalidate(3, false);
|
|
2275
|
-
*
|
|
2276
|
-
* @example
|
|
2277
|
-
* // Add 2 more frames to existing pending count
|
|
2278
|
-
* scheduler.invalidate(2, true);
|
|
2279
|
-
*/
|
|
2280
|
-
invalidate(frames?: number, stackFrames?: boolean): void;
|
|
2281
|
-
/**
|
|
2282
|
-
* Reset timing state for deterministic testing.
|
|
2283
|
-
* Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
|
|
2284
|
-
* @returns {void}
|
|
2285
|
-
*/
|
|
2286
|
-
resetTiming(): void;
|
|
2287
|
-
/**
|
|
2288
|
-
* Manually execute a single frame for all roots.
|
|
2289
|
-
* Useful for frameloop='never' mode or testing scenarios.
|
|
2290
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2291
|
-
* @returns {void}
|
|
2292
|
-
* @example
|
|
2293
|
-
* // Manual control mode
|
|
2294
|
-
* scheduler.frameloop = 'never';
|
|
2295
|
-
* scheduler.step(); // Execute one frame
|
|
2296
|
-
*/
|
|
2297
|
-
step(timestamp?: number): void;
|
|
2298
|
-
/**
|
|
2299
|
-
* Manually execute a single job by its ID.
|
|
2300
|
-
* Useful for testing individual job callbacks in isolation.
|
|
2301
|
-
* @param {string} id - The job ID to step
|
|
2302
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2303
|
-
* @returns {void}
|
|
2304
|
-
*/
|
|
2305
|
-
stepJob(id: string, timestamp?: number): void;
|
|
2306
|
-
/**
|
|
2307
|
-
* Main RAF loop callback.
|
|
2308
|
-
* Executes frame, handles demand mode, and schedules next frame.
|
|
2309
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2310
|
-
* @returns {void}
|
|
2311
|
-
* @private
|
|
2312
|
-
*/
|
|
2313
|
-
private loop;
|
|
2314
|
-
/**
|
|
2315
|
-
* Execute a single frame across all roots.
|
|
2316
|
-
* Order: globalBefore → each root's jobs → globalAfter
|
|
2317
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2318
|
-
* @returns {void}
|
|
2319
|
-
* @private
|
|
2320
|
-
*/
|
|
2321
|
-
private executeFrame;
|
|
2322
|
-
/**
|
|
2323
|
-
* Run all global jobs from a job map.
|
|
2324
|
-
* Catches and logs errors without stopping execution.
|
|
2325
|
-
* @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
|
|
2326
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2327
|
-
* @returns {void}
|
|
2328
|
-
* @private
|
|
2329
|
-
*/
|
|
2330
|
-
private runGlobalJobs;
|
|
2331
|
-
/**
|
|
2332
|
-
* Execute all jobs for a single root in sorted order.
|
|
2333
|
-
* Rebuilds sorted job list if needed, then dispatches each job.
|
|
2334
|
-
* Errors are caught and propagated via triggerError.
|
|
2335
|
-
* @param {RootEntry} root - The root entry to tick
|
|
2336
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2337
|
-
* @param {number} delta - Time since last frame in seconds
|
|
2338
|
-
* @returns {void}
|
|
2339
|
-
* @private
|
|
2340
|
-
*/
|
|
2341
|
-
private tickRoot;
|
|
2342
|
-
/**
|
|
2343
|
-
* Get the total number of registered jobs across all roots.
|
|
2344
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2345
|
-
* @returns {number} Total job count
|
|
2346
|
-
*/
|
|
2347
|
-
getJobCount(): number;
|
|
2348
|
-
/**
|
|
2349
|
-
* Get all registered job IDs across all roots.
|
|
2350
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2351
|
-
* @returns {string[]} Array of all job IDs
|
|
2352
|
-
*/
|
|
2353
|
-
getJobIds(): string[];
|
|
2354
|
-
/**
|
|
2355
|
-
* Get the number of registered roots (Canvas instances).
|
|
2356
|
-
* @returns {number} Number of registered roots
|
|
2357
|
-
*/
|
|
2358
|
-
getRootCount(): number;
|
|
2359
|
-
/**
|
|
2360
|
-
* Check if any user (non-system) jobs are registered in a specific phase.
|
|
2361
|
-
* Used by the default render job to know if a user has taken over rendering.
|
|
2362
|
-
*
|
|
2363
|
-
* @param phase The phase to check
|
|
2364
|
-
* @param rootId Optional root ID to check (checks all roots if not provided)
|
|
2365
|
-
* @returns true if any user jobs exist in the phase
|
|
2366
|
-
*/
|
|
2367
|
-
hasUserJobsInPhase(phase: string, rootId?: string): boolean;
|
|
2368
|
-
/**
|
|
2369
|
-
* Generate a unique root ID for automatic root registration.
|
|
2370
|
-
* @returns {string} A unique root ID in the format 'root_N'
|
|
2371
|
-
*/
|
|
2372
|
-
generateRootId(): string;
|
|
2373
|
-
/**
|
|
2374
|
-
* Generate a unique job ID.
|
|
2375
|
-
* @returns {string} A unique job ID in the format 'job_N'
|
|
2376
|
-
* @private
|
|
2377
|
-
*/
|
|
2378
|
-
private generateJobId;
|
|
2379
|
-
/**
|
|
2380
|
-
* Normalize before/after constraints to a Set.
|
|
2381
|
-
* Handles undefined, single string, or array inputs.
|
|
2382
|
-
* @param {string | string[] | undefined} value - The constraint value(s)
|
|
2383
|
-
* @returns {Set<string>} Normalized Set of constraint strings
|
|
2384
|
-
* @private
|
|
2385
|
-
*/
|
|
2386
|
-
private normalizeConstraints;
|
|
2387
|
-
}
|
|
2388
|
-
/**
|
|
2389
|
-
* Get the global scheduler instance.
|
|
2390
|
-
* Creates one if it doesn't exist.
|
|
2391
|
-
*/
|
|
2392
|
-
declare const getScheduler: () => Scheduler;
|
|
2393
|
-
|
|
2394
|
-
/**
|
|
2395
|
-
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
2396
|
-
*
|
|
2397
|
-
* Works both inside and outside Canvas context:
|
|
2398
|
-
* - Inside Canvas: Full RootState (gl, scene, camera, etc.)
|
|
2399
|
-
* - Outside Canvas (waiting mode): Waits for Canvas to mount, then gets full state
|
|
2400
|
-
* - Outside Canvas (independent mode): Fires immediately with timing-only state
|
|
2401
|
-
*
|
|
2402
|
-
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
2403
|
-
*
|
|
2404
|
-
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
2405
|
-
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
2406
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
2407
|
-
*
|
|
2408
|
-
* @example
|
|
2409
|
-
* // Simple priority (backwards compat)
|
|
2410
|
-
* useFrame((state, delta) => { ... }, 5)
|
|
2411
|
-
*
|
|
2412
|
-
* @example
|
|
2413
|
-
* // With phase-based ordering
|
|
2414
|
-
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
2415
|
-
*
|
|
2416
|
-
* @example
|
|
2417
|
-
* // Outside Canvas - waits for Canvas to mount
|
|
2418
|
-
* function UI() {
|
|
2419
|
-
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
2420
|
-
* return <button>...</button>;
|
|
2421
|
-
* }
|
|
2422
|
-
*
|
|
2423
|
-
* @example
|
|
2424
|
-
* // Independent mode - no Canvas needed
|
|
2425
|
-
* getScheduler().independent = true;
|
|
2426
|
-
* useFrame((state, delta) => { updateGame(delta) });
|
|
2427
|
-
*
|
|
2428
|
-
* @example
|
|
2429
|
-
* // Scheduler-only access (no callback)
|
|
2430
|
-
* const { scheduler } = useFrame()
|
|
2431
|
-
* scheduler.pauseJob('some-job-id')
|
|
2432
|
-
*
|
|
2433
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
2434
|
-
*/
|
|
2435
|
-
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
2436
|
-
|
|
2437
2026
|
declare const IsObject: (url: unknown) => url is Record<string, string>;
|
|
2438
2027
|
type TextureArray<T> = T extends string[] ? Texture$1[] : never;
|
|
2439
2028
|
type TextureRecord<T> = T extends Record<string, string> ? {
|
|
@@ -2446,11 +2035,16 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
|
|
|
2446
2035
|
/** Callback when texture(s) finish loading */
|
|
2447
2036
|
onLoad?: (texture: MappedTextureType<Url>) => void;
|
|
2448
2037
|
/**
|
|
2449
|
-
*
|
|
2450
|
-
* When true:
|
|
2038
|
+
* Register the texture(s) in R3F's global texture registry for access via useTextures().
|
|
2039
|
+
* When true (the default):
|
|
2451
2040
|
* - Textures persist until explicitly disposed
|
|
2452
|
-
* -
|
|
2453
|
-
*
|
|
2041
|
+
* - On mount, returns existing registered textures if available (preserving modifications like colorSpace)
|
|
2042
|
+
*
|
|
2043
|
+
* Reads are taken once at mount — a mounted `useTexture` does not re-render when the registry
|
|
2044
|
+
* changes. To react to registry swaps, use `useTextures(s => s.get(key))` instead.
|
|
2045
|
+
*
|
|
2046
|
+
* Pass `false` to opt out of registry enrollment entirely.
|
|
2047
|
+
* @default true
|
|
2454
2048
|
*/
|
|
2455
2049
|
cache?: boolean;
|
|
2456
2050
|
};
|
|
@@ -2474,15 +2068,18 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
|
|
|
2474
2068
|
* normal: '/normal.png'
|
|
2475
2069
|
* })
|
|
2476
2070
|
*
|
|
2477
|
-
* //
|
|
2478
|
-
* //
|
|
2479
|
-
* const diffuse = useTexture('/diffuse.png'
|
|
2071
|
+
* // Textures are registered in the global registry by default — the same texture
|
|
2072
|
+
* // object is shared across components and modifications (colorSpace, wrapS, etc.) are preserved
|
|
2073
|
+
* const diffuse = useTexture('/diffuse.png')
|
|
2480
2074
|
* diffuse.colorSpace = THREE.SRGBColorSpace
|
|
2481
2075
|
*
|
|
2482
2076
|
* // Another component gets the SAME texture with colorSpace already set
|
|
2483
|
-
* const sameDiffuse = useTexture('/diffuse.png'
|
|
2077
|
+
* const sameDiffuse = useTexture('/diffuse.png')
|
|
2078
|
+
*
|
|
2079
|
+
* // Opt out of registry enrollment for a one-off texture
|
|
2080
|
+
* const scratch = useTexture('/scratch.png', { cache: false })
|
|
2484
2081
|
*
|
|
2485
|
-
* // Access
|
|
2082
|
+
* // Access the registry directly
|
|
2486
2083
|
* const { get } = useTextures()
|
|
2487
2084
|
* const cached = get('/diffuse.png')
|
|
2488
2085
|
* ```
|
|
@@ -2499,63 +2096,80 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
|
|
|
2499
2096
|
cache?: boolean;
|
|
2500
2097
|
}) => react_jsx_runtime.JSX.Element;
|
|
2501
2098
|
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2099
|
+
/** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
|
|
2100
|
+
type TextureInput = string | string[] | Record<string, string>;
|
|
2101
|
+
/** Result of a `get()` read, mirroring the input shape. */
|
|
2102
|
+
type TextureResult<Input extends TextureInput> = Input extends string ? Texture$1 | undefined : Input extends string[] ? (Texture$1 | undefined)[] : {
|
|
2103
|
+
[K in keyof Input]: Texture$1 | undefined;
|
|
2505
2104
|
};
|
|
2105
|
+
/** Options for `dispose()`. */
|
|
2106
|
+
interface DisposeOptions {
|
|
2107
|
+
/** Dispose even if the texture still has active references (default false). */
|
|
2108
|
+
force?: boolean;
|
|
2109
|
+
}
|
|
2506
2110
|
interface UseTexturesReturn {
|
|
2507
|
-
/** Map
|
|
2508
|
-
|
|
2509
|
-
/**
|
|
2510
|
-
get
|
|
2511
|
-
/** Check
|
|
2512
|
-
has
|
|
2513
|
-
/**
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2111
|
+
/** The live registry Map (key → Texture). Treat as read-only. */
|
|
2112
|
+
readonly all: Map<string, Texture$1>;
|
|
2113
|
+
/** Read one texture, an array of textures, or a name→texture record (mirrors the input shape). */
|
|
2114
|
+
get<Input extends TextureInput>(input: Input): TextureResult<Input>;
|
|
2115
|
+
/** Check whether a key exists in the registry. */
|
|
2116
|
+
has(key: string): boolean;
|
|
2117
|
+
/**
|
|
2118
|
+
* Register a texture (or a record of textures) that has no URL — e.g. a render
|
|
2119
|
+
* target or procedural texture. URL-loaded textures are registered automatically
|
|
2120
|
+
* by `useTexture` (registry enrollment is on by default).
|
|
2121
|
+
*/
|
|
2122
|
+
add(key: string, texture: Texture$1): void;
|
|
2123
|
+
add(record: Record<string, Texture$1>): void;
|
|
2124
|
+
/**
|
|
2125
|
+
* Dispose a texture's GPU resources and remove it from the registry.
|
|
2126
|
+
* Refcount-aware: if the key is still in use by a mounted `useTexture` consumer it is
|
|
2127
|
+
* skipped (with a warning) unless `{ force: true }` is passed.
|
|
2128
|
+
* @returns true if disposed, false if skipped.
|
|
2129
|
+
*/
|
|
2130
|
+
dispose(key: string, options?: DisposeOptions): boolean;
|
|
2131
|
+
/** Dispose every texture in the registry and clear it. Use on scene teardown. */
|
|
2132
|
+
disposeAll(): void;
|
|
2527
2133
|
}
|
|
2528
2134
|
/**
|
|
2529
|
-
*
|
|
2135
|
+
* Reactive Texture registry — load once with `useTexture`, reach the textures from anywhere.
|
|
2136
|
+
*
|
|
2137
|
+
* This is a registry of plain `Texture` objects (not TSL nodes), so the same texture can feed
|
|
2138
|
+
* a material map, a heightmap sampler, or anything else. It does **not** load — pair it with
|
|
2139
|
+
* `useTexture` for loading (registry enrollment is on by default); `useTextures` is for access and lifecycle.
|
|
2530
2140
|
*
|
|
2531
|
-
*
|
|
2532
|
-
*
|
|
2141
|
+
* The returned handle is **reactive**: the calling component re-renders when the registry
|
|
2142
|
+
* changes. Pass a selector to scope the subscription to a single read.
|
|
2533
2143
|
*
|
|
2534
2144
|
* @example
|
|
2535
2145
|
* ```tsx
|
|
2536
|
-
*
|
|
2146
|
+
* // Load + register once (anywhere in the tree) — registered by default
|
|
2147
|
+
* useTexture({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
|
|
2537
2148
|
*
|
|
2538
|
-
* //
|
|
2539
|
-
*
|
|
2540
|
-
*
|
|
2541
|
-
* const tex = useTexture('/textures/diffuse.png', { cache: true })
|
|
2542
|
-
* }
|
|
2543
|
-
*
|
|
2544
|
-
* // Access cached texture from anywhere
|
|
2545
|
-
* const diffuse = get('/textures/diffuse.png')
|
|
2546
|
-
* if (diffuse) material.map = diffuse
|
|
2149
|
+
* // Reach them from another component — record form lands straight into a material
|
|
2150
|
+
* const { map, normalMap } = useTextures().get({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
|
|
2151
|
+
* return <meshStandardMaterial map={map} normalMap={normalMap} />
|
|
2547
2152
|
*
|
|
2548
|
-
* //
|
|
2549
|
-
*
|
|
2153
|
+
* // A set of heightmaps at once
|
|
2154
|
+
* const [a, b, c] = useTextures().get(['/h0.png', '/h1.png', '/h2.png'])
|
|
2550
2155
|
*
|
|
2551
|
-
* //
|
|
2552
|
-
*
|
|
2156
|
+
* // Register a non-URL texture (render target / procedural)
|
|
2157
|
+
* useTextures().add('rt-main', renderTarget.texture)
|
|
2553
2158
|
*
|
|
2554
|
-
* //
|
|
2555
|
-
*
|
|
2159
|
+
* // Deliberate GPU cleanup (refcount-aware; force to override)
|
|
2160
|
+
* useTextures().dispose('/diffuse.jpg')
|
|
2161
|
+
* useTextures().disposeAll() // scene teardown
|
|
2556
2162
|
* ```
|
|
2163
|
+
*
|
|
2164
|
+
* @remarks
|
|
2165
|
+
* **Future expansion:** an imperative async loader (e.g. `await useTextures().load('/x.jpg')`) is
|
|
2166
|
+
* intentionally not included yet. It would let non-React code (loading screens, dynamic streaming)
|
|
2167
|
+
* populate the registry without Suspense, at the cost of putting loading back into this hook. It
|
|
2168
|
+
* will be added only if a concrete consumer needs imperative loading; for now, loading lives in
|
|
2169
|
+
* `useTexture`.
|
|
2557
2170
|
*/
|
|
2558
2171
|
declare function useTextures(): UseTexturesReturn;
|
|
2172
|
+
declare function useTextures<T>(selector: (registry: UseTexturesReturn) => T): T;
|
|
2559
2173
|
|
|
2560
2174
|
/**
|
|
2561
2175
|
* Creates a render target compatible with the current renderer.
|
|
@@ -2585,20 +2199,10 @@ declare function useTextures(): UseTexturesReturn;
|
|
|
2585
2199
|
* const fbo = useRenderTarget(512, 256, { samples: 4 })
|
|
2586
2200
|
* ```
|
|
2587
2201
|
*/
|
|
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
|
|
2202
|
+
declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
|
|
2203
|
+
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
|
|
2204
|
+
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
|
|
2591
2205
|
|
|
2592
|
-
/**
|
|
2593
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2594
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2595
|
-
*/
|
|
2596
|
-
declare function useStore(): RootStore;
|
|
2597
|
-
/**
|
|
2598
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2599
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2600
|
-
*/
|
|
2601
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2602
2206
|
/**
|
|
2603
2207
|
* Exposes an object's {@link Instance}.
|
|
2604
2208
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2674,7 +2278,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2674
2278
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2675
2279
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2676
2280
|
*
|
|
2677
|
-
*
|
|
2281
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2282
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2283
|
+
*
|
|
2284
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2678
2285
|
* @param frames - Number of frames to request (default: 1)
|
|
2679
2286
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2680
2287
|
*
|
|
@@ -2685,14 +2292,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2685
2292
|
* Advances the frameloop and runs render effects.
|
|
2686
2293
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2687
2294
|
*
|
|
2295
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2296
|
+
* registered root is stepped for backwards compatibility.
|
|
2297
|
+
*
|
|
2688
2298
|
* @param timestamp - The timestamp to use for this frame
|
|
2689
2299
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2690
|
-
* @param state -
|
|
2691
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2300
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2692
2301
|
*
|
|
2693
2302
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2694
2303
|
*/
|
|
2695
|
-
declare function advance(timestamp: number): void;
|
|
2304
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2696
2305
|
|
|
2697
2306
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2698
2307
|
declare function ReactReconciler<
|
|
@@ -3737,6 +3346,7 @@ declare namespace ReactReconciler {
|
|
|
3737
3346
|
|
|
3738
3347
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3739
3348
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3349
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3740
3350
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3741
3351
|
|
|
3742
3352
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3761,13 +3371,9 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
3761
3371
|
declare function flushSync<R>(fn: () => R): R;
|
|
3762
3372
|
|
|
3763
3373
|
declare const context: React$1.Context<RootStore>;
|
|
3374
|
+
|
|
3764
3375
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3765
3376
|
|
|
3766
|
-
/**
|
|
3767
|
-
* Safely flush async effects when testing, simulating a legacy root.
|
|
3768
|
-
* @deprecated Import from React instead. import { act } from 'react'
|
|
3769
|
-
*/
|
|
3770
|
-
declare const act: typeof React$1.act;
|
|
3771
3377
|
/**
|
|
3772
3378
|
* An SSR-friendly useLayoutEffect.
|
|
3773
3379
|
*
|
|
@@ -4019,7 +3625,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
4019
3625
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
4020
3626
|
/**
|
|
4021
3627
|
* Triggers an update for an instance.
|
|
4022
|
-
*
|
|
3628
|
+
* Invalidates the frame if the root is in demand mode.
|
|
4023
3629
|
*
|
|
4024
3630
|
* @param instance - Instance to invalidate
|
|
4025
3631
|
*/
|
|
@@ -4185,29 +3791,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
4185
3791
|
* Used to identify values that should be resolved from refs after mount.
|
|
4186
3792
|
*/
|
|
4187
3793
|
declare const FROM_REF: unique symbol;
|
|
3794
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3795
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3796
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3797
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3798
|
+
transform?: (value: T) => R;
|
|
3799
|
+
}
|
|
4188
3800
|
/**
|
|
4189
3801
|
* Defers prop application until the referenced object is available.
|
|
4190
3802
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
4191
3803
|
*
|
|
3804
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3805
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3806
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3807
|
+
* what gets assigned.
|
|
3808
|
+
*
|
|
4192
3809
|
* @param ref - React ref object to resolve at mount time
|
|
4193
|
-
* @
|
|
3810
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3811
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
4194
3812
|
*
|
|
4195
3813
|
* @example
|
|
4196
3814
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
4197
3815
|
*
|
|
4198
3816
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
4199
3817
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3818
|
+
*
|
|
3819
|
+
* @example
|
|
3820
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3821
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
4200
3822
|
*/
|
|
4201
3823
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3824
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
4202
3825
|
/**
|
|
4203
3826
|
* Type guard to check if a value is a fromRef marker.
|
|
4204
3827
|
*
|
|
4205
3828
|
* @param value - Value to check
|
|
4206
3829
|
* @returns True if value is a fromRef marker
|
|
4207
3830
|
*/
|
|
4208
|
-
declare function isFromRef(value: unknown): value is
|
|
4209
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
4210
|
-
};
|
|
3831
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
4211
3832
|
|
|
4212
3833
|
/**
|
|
4213
3834
|
* Symbol marker for mount-only method calls.
|
|
@@ -4234,7 +3855,15 @@ declare const ONCE: unique symbol;
|
|
|
4234
3855
|
* // No arguments
|
|
4235
3856
|
* <geometry center={once()} />
|
|
4236
3857
|
*/
|
|
4237
|
-
declare function once<
|
|
3858
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3859
|
+
/**
|
|
3860
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3861
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3862
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3863
|
+
*
|
|
3864
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3865
|
+
*/
|
|
3866
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
4238
3867
|
/**
|
|
4239
3868
|
* Type guard to check if a value is a once marker.
|
|
4240
3869
|
*
|
|
@@ -4245,11 +3874,8 @@ declare function isOnce(value: unknown): value is {
|
|
|
4245
3874
|
[ONCE]: any[] | true;
|
|
4246
3875
|
};
|
|
4247
3876
|
|
|
4248
|
-
/**
|
|
4249
|
-
|
|
4250
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
4251
|
-
*/
|
|
4252
|
-
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3877
|
+
/** Distinguishes a resource leaf from a nested resource scope. */
|
|
3878
|
+
type ResourceLeafGuard<T> = (value: unknown) => value is T;
|
|
4253
3879
|
|
|
4254
3880
|
/**
|
|
4255
3881
|
* ScopedStore - Type-safe wrapper for nested stores (uniforms, nodes)
|
|
@@ -4271,42 +3897,43 @@ declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
|
4271
3897
|
* ```
|
|
4272
3898
|
*/
|
|
4273
3899
|
|
|
4274
|
-
/** Keys reserved for methods (excluded from index signature) */
|
|
4275
|
-
type MethodKeys = 'scope' | 'has' | 'keys';
|
|
4276
3900
|
/**
|
|
4277
3901
|
* Type-safe wrapper interface for accessing nested store data.
|
|
4278
3902
|
* Property access returns `T` (assumes leaf node).
|
|
4279
3903
|
* Use `.scope(key)` for nested object access.
|
|
4280
3904
|
*
|
|
4281
|
-
* Uses mapped type with key filtering to exclude method names from index signature,
|
|
4282
|
-
* allowing methods to have their correct return types.
|
|
4283
3905
|
*/
|
|
4284
|
-
type
|
|
4285
|
-
/** Direct property access returns the leaf type T (method keys excluded) */
|
|
4286
|
-
readonly [K in string as K extends MethodKeys ? never : K]: T;
|
|
4287
|
-
} & {
|
|
3906
|
+
type ScopedStoreMethods<TLeaf> = {
|
|
4288
3907
|
/** Access a nested scope by key. Returns empty wrapper if scope doesn't exist. */
|
|
4289
|
-
scope(key: string): ScopedStoreType<
|
|
3908
|
+
scope<TScope extends Record<string, TLeaf> = Record<string, TLeaf>>(key: string): ScopedStoreType<TLeaf, TScope>;
|
|
4290
3909
|
/** Check if a key exists in the store */
|
|
4291
3910
|
has(key: string): boolean;
|
|
4292
3911
|
/** Get all keys in the store */
|
|
4293
3912
|
keys(): string[];
|
|
4294
3913
|
};
|
|
3914
|
+
type ScopedStoreType<TLeaf, TEntries extends Record<string, TLeaf> = Record<string, TLeaf>> = Readonly<TEntries> & ScopedStoreMethods<TLeaf>;
|
|
3915
|
+
interface ScopedStoreData<TLeaf> {
|
|
3916
|
+
[key: string]: TLeaf | ScopedStoreData<TLeaf>;
|
|
3917
|
+
}
|
|
4295
3918
|
/**
|
|
4296
3919
|
* Create a type-safe ScopedStore wrapper around store data.
|
|
4297
3920
|
* @param data - The raw store data (uniforms or nodes from RootState)
|
|
4298
3921
|
* @returns A ScopedStoreType wrapper with type-safe access
|
|
4299
3922
|
*/
|
|
4300
|
-
declare function createScopedStore<
|
|
3923
|
+
declare function createScopedStore<TLeaf>(data: ScopedStoreData<TLeaf>, isLeaf: ResourceLeafGuard<TLeaf>): ScopedStoreType<TLeaf>;
|
|
4301
3924
|
/**
|
|
4302
3925
|
* State type passed to creator functions with ScopedStore wrappers.
|
|
4303
|
-
* Provides type-safe access to uniforms and
|
|
3926
|
+
* Provides type-safe access to uniforms, nodes, buffers, and gpuStorage without manual casting.
|
|
4304
3927
|
*/
|
|
4305
|
-
type CreatorState = Omit<RootState, 'uniforms' | 'nodes'> & {
|
|
3928
|
+
type CreatorState = Omit<RootState, 'uniforms' | 'nodes' | 'buffers' | 'gpuStorage'> & {
|
|
4306
3929
|
/** Type-safe uniform access - property access returns UniformNode */
|
|
4307
3930
|
uniforms: ScopedStoreType<UniformNode>;
|
|
4308
|
-
/** Type-safe node access
|
|
4309
|
-
nodes: ScopedStoreType<
|
|
3931
|
+
/** Type-safe node access for real, callable, and legacy structural nodes */
|
|
3932
|
+
nodes: ScopedStoreType<NodeLike>;
|
|
3933
|
+
/** Type-safe buffer access - property access returns BufferLike (TypedArrays, BufferAttributes, TSL nodes) */
|
|
3934
|
+
buffers: ScopedStoreType<BufferLike>;
|
|
3935
|
+
/** Type-safe GPU storage access - property access returns StorageLike (StorageTexture, TSL nodes) */
|
|
3936
|
+
gpuStorage: ScopedStoreType<StorageLike>;
|
|
4310
3937
|
};
|
|
4311
3938
|
|
|
4312
3939
|
/** Creator function that returns uniform inputs (can be raw values or UniformNodes) */
|
|
@@ -4318,22 +3945,26 @@ type ClearUniformsFn = (scope?: string) => void;
|
|
|
4318
3945
|
/** Function signature for rebuildUniforms util */
|
|
4319
3946
|
type RebuildUniformsFn = (scope?: string) => void;
|
|
4320
3947
|
/** Return type with utils included */
|
|
4321
|
-
type UniformsWithUtils<T extends UniformRecord = UniformRecord> = T & {
|
|
3948
|
+
type UniformsWithUtils<T extends UniformRecord | UniformStore = UniformRecord> = T & {
|
|
4322
3949
|
removeUniforms: RemoveUniformsFn;
|
|
4323
3950
|
clearUniforms: ClearUniformsFn;
|
|
4324
3951
|
rebuildUniforms: RebuildUniformsFn;
|
|
4325
3952
|
};
|
|
4326
|
-
declare function useUniforms(): UniformsWithUtils<
|
|
3953
|
+
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3954
|
+
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3955
|
+
declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3956
|
+
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
3957
|
+
declare function useUniforms(): UniformsWithUtils<UniformStore>;
|
|
4327
3958
|
declare function useUniforms(scope: string): UniformsWithUtils;
|
|
4328
|
-
declare function useUniforms<T extends UniformInputRecord>(
|
|
4329
|
-
declare function useUniforms<T extends UniformInputRecord>(creator: UniformCreator<T>, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
4330
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
4331
|
-
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
3959
|
+
declare function useUniforms<T extends UniformInputRecord>(scope?: string): UniformsWithUtils<UniformNodesFor<T>>;
|
|
4332
3960
|
/**
|
|
4333
3961
|
* Global rebuildUniforms function for HMR integration.
|
|
4334
|
-
*
|
|
3962
|
+
* Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
|
|
4335
3963
|
* Call this when HMR is detected to refresh all uniform creators.
|
|
4336
3964
|
*
|
|
3965
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3966
|
+
* authoritative store.
|
|
3967
|
+
*
|
|
4337
3968
|
* @param store - The R3F store (from useStore or context)
|
|
4338
3969
|
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4339
3970
|
*/
|
|
@@ -4356,47 +3987,28 @@ declare function clearRootUniforms(set: ReturnType<typeof useStore>['setState'])
|
|
|
4356
3987
|
|
|
4357
3988
|
/**
|
|
4358
3989
|
* Supported uniform value types:
|
|
4359
|
-
* - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix3, Matrix4
|
|
3990
|
+
* - Raw values: number, boolean, Vector2, Vector3, Vector4, Color, Matrix2, Matrix3, Matrix4
|
|
4360
3991
|
* - String colors: '#ff0000', 'red', 'rgb(255,0,0)' (auto-converted to Color)
|
|
4361
3992
|
* - TSL nodes: color(), vec3(), float(), etc. (for type casting)
|
|
4362
3993
|
* - UniformNode: existing uniforms (reused as-is)
|
|
4363
3994
|
*/
|
|
4364
|
-
type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
* - 0 → number
|
|
4368
|
-
* - true → boolean
|
|
4369
|
-
* - '#ff0000' → Color (string colors are converted to Color objects)
|
|
4370
|
-
* - Node → Node (TSL nodes passed through for uniform type casting)
|
|
4371
|
-
*/
|
|
4372
|
-
type Widen<T> = T extends number ? number : T extends boolean ? boolean : T extends string ? Color$2 : T;
|
|
4373
|
-
declare function useUniform<T extends UniformValue>(name: string): UniformNode<T>;
|
|
4374
|
-
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
|
|
3995
|
+
type UniformValue = number | boolean | string | Vector2$1 | Vector3$1 | Vector4$1 | Color$2 | Matrix2 | Matrix3$1 | Matrix4$1 | Node | UniformNode;
|
|
3996
|
+
declare function useUniform<T extends UniformValue = UniformValue>(name: string): UniformNodeFor<T>;
|
|
3997
|
+
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNodeFor<T>;
|
|
4375
3998
|
|
|
4376
3999
|
/**
|
|
4377
|
-
*
|
|
4378
|
-
*
|
|
4379
|
-
*
|
|
4380
|
-
*
|
|
4000
|
+
* Every node representation a creator may return. The definition lives with the store types as
|
|
4001
|
+
* `NodeLike`, so the shape creators return and the shape `state.nodes` holds are one type by
|
|
4002
|
+
* construction: three's real `Node`, the callable proxy `Fn()` returns, or the legacy structural
|
|
4003
|
+
* `{ uuid, nodeType }` shape.
|
|
4381
4004
|
*/
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
/** label method for chaining - sets the node's label and returns self */
|
|
4386
|
-
label?: ((label: string) => TSLNodeLike) | string;
|
|
4387
|
-
setName?: (name: string) => this;
|
|
4388
|
-
}
|
|
4389
|
-
/** TSL node type - alias for compatibility */
|
|
4005
|
+
type TSLNodeLike = NodeLike;
|
|
4006
|
+
|
|
4007
|
+
/** Backward-compatible alias covering every accepted node representation. */
|
|
4390
4008
|
type TSLNode = TSLNodeLike;
|
|
4391
|
-
/**
|
|
4392
|
-
* A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
|
|
4393
|
-
* Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
|
|
4394
|
-
*/
|
|
4395
|
-
type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
|
|
4396
4009
|
/**
|
|
4397
4010
|
* Creator function that returns a record of nodes.
|
|
4398
|
-
*
|
|
4399
|
-
* (e.g., { n: OperatorNode; color: ConstNode<Color> }) to pass type checking.
|
|
4011
|
+
* Exact creator return inference is preserved within the compatible node constraint.
|
|
4400
4012
|
*/
|
|
4401
4013
|
type NodeCreator<T extends Record<string, TSLNodeLike>> = (state: CreatorState) => T;
|
|
4402
4014
|
/** Function signature for removeNodes util */
|
|
@@ -4406,20 +4018,25 @@ type ClearNodesFn = (scope?: string) => void;
|
|
|
4406
4018
|
/** Function signature for rebuildNodes util */
|
|
4407
4019
|
type RebuildNodesFn = (scope?: string) => void;
|
|
4408
4020
|
/** Return type with utils included */
|
|
4409
|
-
type NodesWithUtils<T extends Record<string,
|
|
4021
|
+
type NodesWithUtils<T extends Record<string, unknown> = NodeRecord> = T & {
|
|
4410
4022
|
removeNodes: RemoveNodesFn;
|
|
4411
4023
|
clearNodes: ClearNodesFn;
|
|
4412
4024
|
rebuildNodes: RebuildNodesFn;
|
|
4413
4025
|
};
|
|
4414
|
-
declare function useNodes(): NodesWithUtils<
|
|
4415
|
-
declare function useNodes(scope: string): NodesWithUtils<
|
|
4416
|
-
declare function useNodes<T extends
|
|
4417
|
-
declare function useNodes<T extends
|
|
4026
|
+
declare function useNodes(): NodesWithUtils<NodeStore>;
|
|
4027
|
+
declare function useNodes(scope: string): NodesWithUtils<NodeRecord>;
|
|
4028
|
+
declare function useNodes<T extends NodeRecord>(scope?: string): NodesWithUtils<T>;
|
|
4029
|
+
declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>): NodesWithUtils<T>;
|
|
4030
|
+
declare function useNodes<T extends NodeRecord>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
|
|
4031
|
+
declare function useNodes(creatorOrScope?: NodeCreator<NodeRecord> | string, scope?: string): NodesWithUtils<Record<string, unknown>>;
|
|
4418
4032
|
/**
|
|
4419
4033
|
* Global rebuildNodes function for HMR integration.
|
|
4420
|
-
*
|
|
4034
|
+
* Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
|
|
4421
4035
|
* Call this when HMR is detected to refresh all node creators.
|
|
4422
4036
|
*
|
|
4037
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
4038
|
+
* authoritative store.
|
|
4039
|
+
*
|
|
4423
4040
|
* @param store - The R3F store (from useStore or context)
|
|
4424
4041
|
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4425
4042
|
*/
|
|
@@ -4470,6 +4087,107 @@ type LocalNodeCreator<T extends Record<string, unknown>> = (state: CreatorState)
|
|
|
4470
4087
|
*/
|
|
4471
4088
|
declare function useLocalNodes<T extends Record<string, unknown>>(creator: LocalNodeCreator<T>): T;
|
|
4472
4089
|
|
|
4090
|
+
/**
|
|
4091
|
+
* A record of buffer-like values - allows mixed types (TypedArrays, BufferAttributes, TSL nodes)
|
|
4092
|
+
*/
|
|
4093
|
+
type BufferRecordType<T extends BufferLike = BufferLike> = Record<string, T>;
|
|
4094
|
+
/**
|
|
4095
|
+
* Creator function that returns a record of buffers.
|
|
4096
|
+
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
4097
|
+
*/
|
|
4098
|
+
type BufferCreator<T extends Record<string, BufferLike>> = (state: CreatorState) => T;
|
|
4099
|
+
/** Function signature for removeBuffers util */
|
|
4100
|
+
type RemoveBuffersFn = (names: string | string[], scope?: string) => void;
|
|
4101
|
+
/** Function signature for clearBuffers util */
|
|
4102
|
+
type ClearBuffersFn = (scope?: string) => void;
|
|
4103
|
+
/** Function signature for rebuildBuffers util */
|
|
4104
|
+
type RebuildBuffersFn = (scope?: string) => void;
|
|
4105
|
+
/** Function signature for disposeBuffers util - releases GPU resources */
|
|
4106
|
+
type DisposeBuffersFn = (names: string | string[], scope?: string) => void;
|
|
4107
|
+
/** Return type with utils included */
|
|
4108
|
+
type BuffersWithUtils<T extends BufferRecordType | BufferStore = BufferRecordType> = T & {
|
|
4109
|
+
removeBuffers: RemoveBuffersFn;
|
|
4110
|
+
clearBuffers: ClearBuffersFn;
|
|
4111
|
+
rebuildBuffers: RebuildBuffersFn;
|
|
4112
|
+
disposeBuffers: DisposeBuffersFn;
|
|
4113
|
+
};
|
|
4114
|
+
declare function useBuffers(): BuffersWithUtils<BufferStore>;
|
|
4115
|
+
declare function useBuffers(scope: string): BuffersWithUtils<Record<string, BufferLike>>;
|
|
4116
|
+
declare function useBuffers<T extends Record<string, BufferLike>>(scope?: string): BuffersWithUtils<T>;
|
|
4117
|
+
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>): BuffersWithUtils<T>;
|
|
4118
|
+
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
|
|
4119
|
+
/**
|
|
4120
|
+
* Global rebuildBuffers function for HMR integration.
|
|
4121
|
+
* Invalidates cached buffers and increments _hmrVersion to trigger re-creation.
|
|
4122
|
+
* Call this when HMR is detected to refresh all buffer creators.
|
|
4123
|
+
*
|
|
4124
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
4125
|
+
* authoritative store.
|
|
4126
|
+
*
|
|
4127
|
+
* @param store - The R3F store (from useStore or context)
|
|
4128
|
+
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4129
|
+
*/
|
|
4130
|
+
declare function rebuildAllBuffers(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4131
|
+
|
|
4132
|
+
/**
|
|
4133
|
+
* A record of storage-like values - allows mixed types (StorageTexture, Storage3DTexture, TSL nodes)
|
|
4134
|
+
*/
|
|
4135
|
+
type StorageRecordType<T extends StorageLike = StorageLike> = Record<string, T>;
|
|
4136
|
+
/**
|
|
4137
|
+
* Creator function that returns a record of GPU storage objects.
|
|
4138
|
+
* Receives CreatorState with access to existing buffers, gpuStorage, uniforms, nodes, etc.
|
|
4139
|
+
*/
|
|
4140
|
+
type StorageCreator<T extends Record<string, StorageLike>> = (state: CreatorState) => T;
|
|
4141
|
+
/** Function signature for removeStorage util */
|
|
4142
|
+
type RemoveStorageFn = (names: string | string[], scope?: string) => void;
|
|
4143
|
+
/** Function signature for clearStorage util */
|
|
4144
|
+
type ClearStorageFn = (scope?: string) => void;
|
|
4145
|
+
/** Function signature for rebuildStorage util */
|
|
4146
|
+
type RebuildStorageFn = (scope?: string) => void;
|
|
4147
|
+
/** Function signature for disposeStorage util - releases GPU resources */
|
|
4148
|
+
type DisposeStorageFn = (names: string | string[], scope?: string) => void;
|
|
4149
|
+
/** Return type with utils included */
|
|
4150
|
+
type StorageWithUtils<T extends StorageRecordType | StorageStore = StorageRecordType> = T & {
|
|
4151
|
+
removeStorage: RemoveStorageFn;
|
|
4152
|
+
clearStorage: ClearStorageFn;
|
|
4153
|
+
rebuildStorage: RebuildStorageFn;
|
|
4154
|
+
disposeStorage: DisposeStorageFn;
|
|
4155
|
+
};
|
|
4156
|
+
declare function useGPUStorage(): StorageWithUtils<StorageStore>;
|
|
4157
|
+
declare function useGPUStorage(scope: string): StorageWithUtils<Record<string, StorageLike>>;
|
|
4158
|
+
declare function useGPUStorage<T extends Record<string, StorageLike>>(scope?: string): StorageWithUtils<T>;
|
|
4159
|
+
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>): StorageWithUtils<T>;
|
|
4160
|
+
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
|
|
4161
|
+
/**
|
|
4162
|
+
* Global rebuildStorage function for HMR integration.
|
|
4163
|
+
* Invalidates cached storage and increments _hmrVersion to trigger re-creation.
|
|
4164
|
+
* Call this when HMR is detected to refresh all storage creators.
|
|
4165
|
+
*
|
|
4166
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
4167
|
+
* authoritative store.
|
|
4168
|
+
*
|
|
4169
|
+
* @param store - The R3F store (from useStore or context)
|
|
4170
|
+
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4171
|
+
*/
|
|
4172
|
+
declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4173
|
+
|
|
4174
|
+
/**
|
|
4175
|
+
* Re-export from core - useTextures is now a core R3F hook (a reactive Texture registry).
|
|
4176
|
+
*
|
|
4177
|
+
* This file maintains backwards compatibility for existing webgpu imports.
|
|
4178
|
+
*/
|
|
4179
|
+
|
|
4180
|
+
/**
|
|
4181
|
+
* @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
|
|
4182
|
+
* Kept as an alias for backwards compatibility.
|
|
4183
|
+
*/
|
|
4184
|
+
type TextureEntry = Texture$1;
|
|
4185
|
+
/**
|
|
4186
|
+
* @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
|
|
4187
|
+
* Kept as an alias for backwards compatibility.
|
|
4188
|
+
*/
|
|
4189
|
+
type TextureNode = Texture$1;
|
|
4190
|
+
|
|
4473
4191
|
interface TextureOperations {
|
|
4474
4192
|
add: (key: string, value: any) => void;
|
|
4475
4193
|
addMultiple: (items: Map<string, any> | Record<string, any>) => void;
|
|
@@ -4479,32 +4197,36 @@ interface TextureOperations {
|
|
|
4479
4197
|
declare function createTextureOperations(set: StoreApi<RootState>['setState']): TextureOperations;
|
|
4480
4198
|
|
|
4481
4199
|
/**
|
|
4482
|
-
* Hook for managing WebGPU
|
|
4200
|
+
* Hook for managing WebGPU RenderPipeline with automatic scenePass setup.
|
|
4483
4201
|
*
|
|
4484
4202
|
* Features:
|
|
4485
|
-
* - Creates
|
|
4203
|
+
* - Creates RenderPipeline instance if not exists
|
|
4486
4204
|
* - Creates default scenePass (no MRT) automatically
|
|
4487
4205
|
* - Callbacks receive full RootState for flexibility
|
|
4488
4206
|
* - No auto-cleanup on unmount - use reset() for explicit cleanup
|
|
4489
4207
|
* - Scene/camera changes trigger scenePass recreation
|
|
4208
|
+
* - A replaced scenePass is disposed once the new graph is installed, so rebuild() does not
|
|
4209
|
+
* strand its render target (and MRT attachments) on the GPU
|
|
4210
|
+
* - Any run that changes the output node sets RenderPipeline.needsUpdate, so rebuild() actually
|
|
4211
|
+
* recompiles instead of silently keeping the first compiled graph
|
|
4490
4212
|
*
|
|
4491
4213
|
* @param mainCB - Main callback to configure outputNode and create effect passes
|
|
4492
4214
|
* @param setupCB - Optional setup callback to configure MRT on scenePass
|
|
4493
|
-
* @returns { passes,
|
|
4215
|
+
* @returns { passes, renderPipeline, clearPasses, reset, rebuild }
|
|
4494
4216
|
*
|
|
4495
4217
|
* @example
|
|
4496
4218
|
* ```tsx
|
|
4497
4219
|
* // Simple effect
|
|
4498
|
-
*
|
|
4499
|
-
*
|
|
4220
|
+
* useRenderPipeline(({ renderPipeline, passes }) => {
|
|
4221
|
+
* renderPipeline.outputNode = bloom(passes.scenePass.getTextureNode())
|
|
4500
4222
|
* })
|
|
4501
4223
|
*
|
|
4502
4224
|
* // With MRT setup
|
|
4503
|
-
*
|
|
4504
|
-
* ({
|
|
4225
|
+
* useRenderPipeline(
|
|
4226
|
+
* ({ renderPipeline, passes }) => {
|
|
4505
4227
|
* const beauty = passes.scenePass.getTextureNode().toInspector('Color')
|
|
4506
4228
|
* const vel = passes.scenePass.getTextureNode('velocity')
|
|
4507
|
-
*
|
|
4229
|
+
* renderPipeline.outputNode = motionBlur(beauty, vel)
|
|
4508
4230
|
* },
|
|
4509
4231
|
* ({ passes }) => {
|
|
4510
4232
|
* passes.scenePass.setMRT(mrt({ output, velocity }))
|
|
@@ -4512,10 +4234,10 @@ declare function createTextureOperations(set: StoreApi<RootState>['setState']):
|
|
|
4512
4234
|
* )
|
|
4513
4235
|
*
|
|
4514
4236
|
* // Read-only access
|
|
4515
|
-
* const {
|
|
4237
|
+
* const { renderPipeline, passes } = useRenderPipeline()
|
|
4516
4238
|
* ```
|
|
4517
4239
|
*/
|
|
4518
|
-
declare function
|
|
4240
|
+
declare function useRenderPipeline(mainCB?: RenderPipelineMainCallback, setupCB?: RenderPipelineSetupCallback): UseRenderPipelineReturn;
|
|
4519
4241
|
|
|
4520
4242
|
//* Renderer Props ========================================
|
|
4521
4243
|
|
|
@@ -4564,5 +4286,32 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
|
|
|
4564
4286
|
internal: WebGPUInternalState
|
|
4565
4287
|
}
|
|
4566
4288
|
|
|
4567
|
-
|
|
4568
|
-
|
|
4289
|
+
/**
|
|
4290
|
+
* @fileoverview WebGPU entry point - WebGPU only, no legacy WebGL
|
|
4291
|
+
*
|
|
4292
|
+
* This entry point is for apps that want to use ONLY WebGPURenderer.
|
|
4293
|
+
* Includes WebGPU-specific hooks (useUniforms, useNodes, useTextures).
|
|
4294
|
+
* Auto-extends THREE with WebGPU node materials (MeshBasicNodeMaterial, etc.)
|
|
4295
|
+
*
|
|
4296
|
+
* Usage:
|
|
4297
|
+
* import { Canvas, useFrame, useUniforms } from '@react-three/fiber/webgpu'
|
|
4298
|
+
*/
|
|
4299
|
+
|
|
4300
|
+
/** `useThree` narrowed to WebGPU state — `state.renderer` is a `WebGPURenderer`. */
|
|
4301
|
+
type UseThreeWebGPU = <T = WebGPURootState>(selector?: (state: WebGPURootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
|
|
4302
|
+
/** `useFrame` narrowed to WebGPU state — the callback's `state.renderer` is a `WebGPURenderer`. */
|
|
4303
|
+
type UseFrameWebGPU = (callback?: FrameCallback$1<WebGPURootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
|
|
4304
|
+
declare const useThree: UseThreeWebGPU;
|
|
4305
|
+
declare const useFrame: UseFrameWebGPU;
|
|
4306
|
+
|
|
4307
|
+
/** Canvas props on the WebGPU entry: `onCreated` receives `WebGPURootState`. */
|
|
4308
|
+
type WebGPUCanvasProps = Omit<CanvasProps, 'onCreated'> & {
|
|
4309
|
+
/** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGPURenderer` */
|
|
4310
|
+
onCreated?: (state: WebGPURootState) => void;
|
|
4311
|
+
};
|
|
4312
|
+
|
|
4313
|
+
/** `Canvas` narrowed to WebGPU state — the same component, `onCreated` typed against `WebGPURootState`. */
|
|
4314
|
+
declare const Canvas: (props: WebGPUCanvasProps) => JSX.Element;
|
|
4315
|
+
|
|
4316
|
+
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, 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, 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, registerRootExtension, removeInteractivity, removeNodes, removeUniforms, resolve, setRenderOverride, swapInteractivity, 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 };
|
|
4317
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, Camera, CameraProps, WebGPUCanvasProps as CanvasProps, CanvasSchedulerConfig, Catalogue, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DisposeBuffersFn, DisposeOptions, DisposeStorageFn, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, FromRefMarker, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeLike, NodeProps, NodeRecord, NodeStore, NodesWithUtils, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, 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, RootExtension, WebGPURootState as RootState, RootStore, ScopedStoreType, SetBlock, Size, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, Subscription, TSLNode, TSLNodeInput, TSLNodeLike, TextureEntry, TextureInput, TextureNode, TextureOperations, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameWebGPU, UseTextureOptions, UseTexturesReturn, UseThreeWebGPU, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUCanvasProps, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };
|