@react-three/fiber 10.0.0-canary.d6fdf72 → 10.0.0-canary.d91831d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3232 -3964
- package/dist/index.d.cts +355 -869
- package/dist/index.d.mts +355 -869
- package/dist/index.d.ts +350 -892
- package/dist/index.mjs +2990 -3721
- package/dist/legacy.cjs +2569 -3305
- package/dist/legacy.d.cts +358 -875
- package/dist/legacy.d.mts +358 -875
- package/dist/legacy.d.ts +354 -897
- package/dist/legacy.mjs +2936 -3671
- package/dist/webgpu/index.cjs +2984 -3914
- package/dist/webgpu/index.d.cts +459 -974
- package/dist/webgpu/index.d.mts +459 -974
- package/dist/webgpu/index.d.ts +455 -998
- package/dist/webgpu/index.mjs +3149 -4078
- package/package.json +6 -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/legacy.d.cts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as THREE$1 from 'three';
|
|
2
|
-
import { WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1,
|
|
2
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Object3D, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera } from 'three';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
5
5
|
import * as three_webgpu from 'three/webgpu';
|
|
6
|
-
import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Data3DTexture, CanvasTarget
|
|
6
|
+
import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget } from 'three/webgpu';
|
|
7
7
|
import { StoreApi } from 'zustand';
|
|
8
8
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
9
|
+
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
10
|
+
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
9
11
|
import { Options } from 'react-use-measure';
|
|
10
12
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
11
|
-
import { ThreeElement as ThreeElement$1, Euler as Euler$2 } from '@react-three/fiber';
|
|
12
13
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
13
14
|
|
|
14
15
|
function _mergeNamespaces(n, m) {
|
|
@@ -37,23 +38,28 @@ function _mergeNamespaces(n, m) {
|
|
|
37
38
|
declare const R3F_BUILD_LEGACY = true;
|
|
38
39
|
declare const R3F_BUILD_WEBGPU = false;
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
declare
|
|
44
|
-
|
|
45
|
-
}
|
|
41
|
+
type Inspector = never;
|
|
42
|
+
/** Not available on the legacy (WebGL-only) entry. */
|
|
43
|
+
declare function loadInspector(): Promise<never>;
|
|
44
|
+
declare class WebGPURenderer {
|
|
45
|
+
constructor();
|
|
46
|
+
}
|
|
46
47
|
|
|
47
48
|
declare const RenderTarget: any;
|
|
48
49
|
|
|
50
|
+
declare const CubeRenderTarget: any;
|
|
51
|
+
|
|
49
52
|
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
50
53
|
__proto__: null,
|
|
54
|
+
CubeRenderTarget: CubeRenderTarget,
|
|
55
|
+
CubeRenderTargetCompat: WebGLCubeRenderTarget,
|
|
51
56
|
Inspector: Inspector,
|
|
52
57
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
53
58
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
54
59
|
RenderTarget: RenderTarget,
|
|
55
60
|
RenderTargetCompat: WebGLRenderTarget,
|
|
56
|
-
WebGPURenderer: WebGPURenderer
|
|
61
|
+
WebGPURenderer: WebGPURenderer,
|
|
62
|
+
loadInspector: loadInspector
|
|
57
63
|
}, [THREE$1]);
|
|
58
64
|
|
|
59
65
|
//* Utility Types ==============================
|
|
@@ -291,228 +297,33 @@ interface VisibilityEntry {
|
|
|
291
297
|
}
|
|
292
298
|
|
|
293
299
|
//* Scheduler Types (useFrame) ==============================
|
|
300
|
+
//
|
|
301
|
+
// The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
|
|
302
|
+
// This file re-exports them and layers r3f's RootState-aware frame state on top,
|
|
303
|
+
// so existing `#types` imports across the codebase keep resolving unchanged.
|
|
294
304
|
|
|
295
305
|
|
|
296
306
|
|
|
297
|
-
//
|
|
307
|
+
// Frame State (r3f-specific) --------------------------------
|
|
298
308
|
|
|
299
309
|
/**
|
|
300
|
-
*
|
|
301
|
-
*/
|
|
302
|
-
interface UseFrameNextOptions {
|
|
303
|
-
/** Optional stable id for the job. Auto-generated if not provided */
|
|
304
|
-
id?: string
|
|
305
|
-
/** Named phase to run in. Default: 'update' */
|
|
306
|
-
phase?: string
|
|
307
|
-
/** Run before this phase or job id */
|
|
308
|
-
before?: string | string[]
|
|
309
|
-
/** Run after this phase or job id */
|
|
310
|
-
after?: string | string[]
|
|
311
|
-
/** Priority within phase. Higher runs first. Default: 0 */
|
|
312
|
-
priority?: number
|
|
313
|
-
/** Max frames per second for this job */
|
|
314
|
-
fps?: number
|
|
315
|
-
/** If true, skip frames when behind. If false, try to catch up. Default: true */
|
|
316
|
-
drop?: boolean
|
|
317
|
-
/** Enable/disable without unregistering. Default: true */
|
|
318
|
-
enabled?: boolean
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/** Alias for UseFrameNextOptions */
|
|
322
|
-
type UseFrameOptions = UseFrameNextOptions
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Options for addPhase
|
|
326
|
-
*/
|
|
327
|
-
interface AddPhaseOptions {
|
|
328
|
-
/** Insert this phase before the specified phase */
|
|
329
|
-
before?: string
|
|
330
|
-
/** Insert this phase after the specified phase */
|
|
331
|
-
after?: string
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// Frame State --------------------------------
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Timing-only state for independent/outside mode (no RootState)
|
|
338
|
-
*/
|
|
339
|
-
interface FrameTimingState {
|
|
340
|
-
/** High-resolution timestamp from RAF (ms) */
|
|
341
|
-
time: number
|
|
342
|
-
/** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
343
|
-
delta: number
|
|
344
|
-
/** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
345
|
-
elapsed: number
|
|
346
|
-
/** Incrementing frame counter */
|
|
347
|
-
frame: number
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* State passed to useFrame callbacks (extends RootState with timing)
|
|
310
|
+
* State passed to useFrame callbacks (extends RootState with timing).
|
|
352
311
|
*/
|
|
353
312
|
interface FrameNextState extends RootState, FrameTimingState {}
|
|
354
313
|
|
|
355
314
|
/** Alias for FrameNextState */
|
|
356
315
|
type FrameState = FrameNextState
|
|
357
316
|
|
|
358
|
-
//
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Options for registerRoot
|
|
362
|
-
*/
|
|
363
|
-
interface RootOptions {
|
|
364
|
-
/** State provider for callbacks. Optional in independent mode. */
|
|
365
|
-
getState?: () => any
|
|
366
|
-
/** Error handler for job errors. Falls back to console.error if not provided. */
|
|
367
|
-
onError?: (error: Error) => void
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// Callback Types --------------------------------
|
|
317
|
+
// Callback Types (r3f-specific) --------------------------------
|
|
371
318
|
|
|
372
319
|
/**
|
|
373
|
-
* Callback function for useFrame
|
|
320
|
+
* Callback function for useFrame. Receives the full r3f RootState plus timing.
|
|
374
321
|
*/
|
|
375
|
-
type FrameNextCallback =
|
|
322
|
+
type FrameNextCallback = FrameCallback$1<RootState>
|
|
376
323
|
|
|
377
324
|
/** Alias for FrameNextCallback */
|
|
378
325
|
type FrameCallback = FrameNextCallback
|
|
379
326
|
|
|
380
|
-
// Controls returned from useFrame --------------------------------
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Controls object returned from useFrame hook
|
|
384
|
-
*/
|
|
385
|
-
interface FrameNextControls {
|
|
386
|
-
/** The job's unique ID */
|
|
387
|
-
id: string
|
|
388
|
-
/** Access to the global scheduler for frame loop control */
|
|
389
|
-
scheduler: SchedulerApi
|
|
390
|
-
/** Manually step this job only (bypasses FPS limiting) */
|
|
391
|
-
step(timestamp?: number): void
|
|
392
|
-
/** Manually step ALL jobs in the scheduler */
|
|
393
|
-
stepAll(timestamp?: number): void
|
|
394
|
-
/** Pause this job (set enabled=false) */
|
|
395
|
-
pause(): void
|
|
396
|
-
/** Resume this job (set enabled=true) */
|
|
397
|
-
resume(): void
|
|
398
|
-
/** Reactive paused state - automatically triggers re-render when changed */
|
|
399
|
-
isPaused: boolean
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/** Alias for FrameNextControls */
|
|
403
|
-
type FrameControls = FrameNextControls
|
|
404
|
-
|
|
405
|
-
// Scheduler Interface --------------------------------
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Public interface for the global Scheduler
|
|
409
|
-
*/
|
|
410
|
-
interface SchedulerApi {
|
|
411
|
-
//* Phase Management --------------------------------
|
|
412
|
-
|
|
413
|
-
/** Add a named phase to the scheduler */
|
|
414
|
-
addPhase(name: string, options?: AddPhaseOptions): void
|
|
415
|
-
/** Get the ordered list of phase names */
|
|
416
|
-
readonly phases: string[]
|
|
417
|
-
/** Check if a phase exists */
|
|
418
|
-
hasPhase(name: string): boolean
|
|
419
|
-
|
|
420
|
-
//* Root Management --------------------------------
|
|
421
|
-
|
|
422
|
-
/** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
|
|
423
|
-
registerRoot(id: string, options?: RootOptions): () => void
|
|
424
|
-
/** Unregister a root */
|
|
425
|
-
unregisterRoot(id: string): void
|
|
426
|
-
/** Generate a unique root ID */
|
|
427
|
-
generateRootId(): string
|
|
428
|
-
/** Get the number of registered roots */
|
|
429
|
-
getRootCount(): number
|
|
430
|
-
/** Check if any root is registered and ready */
|
|
431
|
-
readonly isReady: boolean
|
|
432
|
-
/** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
|
|
433
|
-
onRootReady(callback: () => void): () => void
|
|
434
|
-
|
|
435
|
-
//* Job Registration --------------------------------
|
|
436
|
-
|
|
437
|
-
/** Register a job with the scheduler (returns unsubscribe function) */
|
|
438
|
-
register(
|
|
439
|
-
callback: FrameNextCallback,
|
|
440
|
-
options?: {
|
|
441
|
-
id?: string
|
|
442
|
-
rootId?: string
|
|
443
|
-
phase?: string
|
|
444
|
-
before?: string | string[]
|
|
445
|
-
after?: string | string[]
|
|
446
|
-
priority?: number
|
|
447
|
-
fps?: number
|
|
448
|
-
drop?: boolean
|
|
449
|
-
enabled?: boolean
|
|
450
|
-
},
|
|
451
|
-
): () => void
|
|
452
|
-
/** Update a job's options */
|
|
453
|
-
updateJob(
|
|
454
|
-
id: string,
|
|
455
|
-
options: {
|
|
456
|
-
priority?: number
|
|
457
|
-
fps?: number
|
|
458
|
-
drop?: boolean
|
|
459
|
-
enabled?: boolean
|
|
460
|
-
phase?: string
|
|
461
|
-
before?: string | string[]
|
|
462
|
-
after?: string | string[]
|
|
463
|
-
},
|
|
464
|
-
): void
|
|
465
|
-
/** Unregister a job by ID */
|
|
466
|
-
unregister(id: string, rootId?: string): void
|
|
467
|
-
/** Get the number of registered jobs */
|
|
468
|
-
getJobCount(): number
|
|
469
|
-
/** Get all job IDs */
|
|
470
|
-
getJobIds(): string[]
|
|
471
|
-
|
|
472
|
-
//* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
|
|
473
|
-
|
|
474
|
-
/** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
|
|
475
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
|
|
476
|
-
|
|
477
|
-
//* Idle Callbacks (for legacy addTail) --------------------------------
|
|
478
|
-
|
|
479
|
-
/** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
|
|
480
|
-
onIdle(callback: (timestamp: number) => void): () => void
|
|
481
|
-
|
|
482
|
-
//* Frame Loop Control --------------------------------
|
|
483
|
-
|
|
484
|
-
/** Start the scheduler loop */
|
|
485
|
-
start(): void
|
|
486
|
-
/** Stop the scheduler loop */
|
|
487
|
-
stop(): void
|
|
488
|
-
/** Check if the scheduler is running */
|
|
489
|
-
readonly isRunning: boolean
|
|
490
|
-
/** Get/set the frameloop mode ('always', 'demand', 'never') */
|
|
491
|
-
frameloop: Frameloop
|
|
492
|
-
/** Independent mode - runs without Canvas, callbacks receive timing-only state */
|
|
493
|
-
independent: boolean
|
|
494
|
-
|
|
495
|
-
//* Manual Stepping --------------------------------
|
|
496
|
-
|
|
497
|
-
/** Manually step all jobs once (for frameloop='never' or testing) */
|
|
498
|
-
step(timestamp?: number): void
|
|
499
|
-
/** Manually step a single job by ID */
|
|
500
|
-
stepJob(id: string, timestamp?: number): void
|
|
501
|
-
/** Request frame(s) to be rendered (for frameloop='demand') */
|
|
502
|
-
invalidate(frames?: number): void
|
|
503
|
-
|
|
504
|
-
//* Per-Job Control --------------------------------
|
|
505
|
-
|
|
506
|
-
/** Check if a job is paused */
|
|
507
|
-
isJobPaused(id: string): boolean
|
|
508
|
-
/** Pause a job */
|
|
509
|
-
pauseJob(id: string): void
|
|
510
|
-
/** Resume a job */
|
|
511
|
-
resumeJob(id: string): void
|
|
512
|
-
/** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
|
|
513
|
-
subscribeJobState(id: string, listener: () => void): () => void
|
|
514
|
-
}
|
|
515
|
-
|
|
516
327
|
//* Buffer Types (useBuffers) ========================================
|
|
517
328
|
|
|
518
329
|
/**
|
|
@@ -537,6 +348,7 @@ type BufferLike =
|
|
|
537
348
|
| Uint16Array
|
|
538
349
|
| Int16Array
|
|
539
350
|
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
351
|
+
| THREE$1.InterleavedBufferAttribute
|
|
540
352
|
| Node // TSL buffer nodes (instancedArray, storage)
|
|
541
353
|
|
|
542
354
|
/** Flat record of buffer-like values (no nested scopes) */
|
|
@@ -548,6 +360,25 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
548
360
|
*/
|
|
549
361
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
550
362
|
|
|
363
|
+
//* Node Types (useNodes) ========================================
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
367
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
368
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
369
|
+
* and the shape the store holds are one type by construction.
|
|
370
|
+
*/
|
|
371
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
372
|
+
|
|
373
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
374
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
378
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
379
|
+
*/
|
|
380
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
381
|
+
|
|
551
382
|
//* Storage Types (useGPUStorage) ========================================
|
|
552
383
|
|
|
553
384
|
/**
|
|
@@ -562,7 +393,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
|
562
393
|
* ```
|
|
563
394
|
*/
|
|
564
395
|
type StorageLike =
|
|
565
|
-
| StorageTexture // GPU storage texture
|
|
396
|
+
| StorageTexture // 2D GPU storage texture
|
|
397
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
398
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
566
399
|
| Data3DTexture // 3D texture (can be used as storage)
|
|
567
400
|
| Node // TSL storage texture nodes (storageTexture)
|
|
568
401
|
|
|
@@ -681,14 +514,31 @@ interface InternalState {
|
|
|
681
514
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
682
515
|
container?: THREE$1.Object3D
|
|
683
516
|
/**
|
|
684
|
-
* CanvasTarget
|
|
685
|
-
*
|
|
517
|
+
* The CanvasTarget this root sizes and renders through.
|
|
518
|
+
*
|
|
519
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
520
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
521
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
522
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
523
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
686
524
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
687
525
|
*/
|
|
688
526
|
canvasTarget?: CanvasTarget
|
|
527
|
+
/**
|
|
528
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
529
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
530
|
+
*
|
|
531
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
532
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
533
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
534
|
+
* invalidate some other canvas's descriptor instead.
|
|
535
|
+
*
|
|
536
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
537
|
+
*/
|
|
538
|
+
canvasTargetSizeDirty?: boolean
|
|
689
539
|
/**
|
|
690
540
|
* Whether multi-canvas rendering is active.
|
|
691
|
-
* True when any canvas uses `
|
|
541
|
+
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
692
542
|
* When true, setCanvasTarget is called before each render.
|
|
693
543
|
*/
|
|
694
544
|
isMultiCanvas?: boolean
|
|
@@ -786,8 +636,8 @@ interface RootState {
|
|
|
786
636
|
setSize: (width?: number, height?: number, top?: number, left?: number) => void
|
|
787
637
|
/** Shortcut to manual setting the pixel ratio */
|
|
788
638
|
setDpr: (dpr: Dpr) => void
|
|
789
|
-
/** Shortcut to setting frameloop flags */
|
|
790
|
-
setFrameloop: (frameloop
|
|
639
|
+
/** Shortcut to setting frameloop flags. No args resets to 'always'. */
|
|
640
|
+
setFrameloop: (frameloop?: Frameloop) => void
|
|
791
641
|
/** Set error state to propagate to error boundary */
|
|
792
642
|
setError: (error: Error | null) => void
|
|
793
643
|
/** Current error state (null when no error) */
|
|
@@ -795,7 +645,7 @@ interface RootState {
|
|
|
795
645
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
796
646
|
uniforms: UniformStore
|
|
797
647
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
798
|
-
nodes:
|
|
648
|
+
nodes: NodeStore
|
|
799
649
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
800
650
|
buffers: BufferStore
|
|
801
651
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -805,9 +655,9 @@ interface RootState {
|
|
|
805
655
|
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
806
656
|
_textureRefs: Map<string, number>
|
|
807
657
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
808
|
-
renderPipeline:
|
|
658
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
809
659
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
810
|
-
passes:
|
|
660
|
+
passes: PassRecord
|
|
811
661
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
812
662
|
_hmrVersion: number
|
|
813
663
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -895,12 +745,19 @@ type DefaultRendererProps = {
|
|
|
895
745
|
*/
|
|
896
746
|
interface CanvasSchedulerConfig {
|
|
897
747
|
/**
|
|
898
|
-
*
|
|
899
|
-
|
|
748
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
749
|
+
*/
|
|
750
|
+
before?: string | string[]
|
|
751
|
+
/**
|
|
752
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
900
753
|
*/
|
|
901
|
-
after?: string
|
|
754
|
+
after?: string | string[]
|
|
755
|
+
/**
|
|
756
|
+
* Numeric root order. Lower values run first.
|
|
757
|
+
*/
|
|
758
|
+
order?: number
|
|
902
759
|
/**
|
|
903
|
-
* Limit this
|
|
760
|
+
* Limit this Canvas's default render job (frames per second).
|
|
904
761
|
*/
|
|
905
762
|
fps?: number
|
|
906
763
|
}
|
|
@@ -987,14 +844,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
987
844
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
988
845
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
989
846
|
dpr?: Dpr
|
|
990
|
-
/**
|
|
991
|
-
|
|
847
|
+
/**
|
|
848
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
849
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
850
|
+
*/
|
|
851
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
992
852
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
993
853
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
994
854
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
995
855
|
camera?: CameraProps
|
|
996
856
|
/** An R3F event manager to manage elements' pointer events */
|
|
997
|
-
events?: (store: RootStore) => EventManager<
|
|
857
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
998
858
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
999
859
|
onCreated?: (state: RootState) => void
|
|
1000
860
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -1098,8 +958,6 @@ interface Instance<O = any> {
|
|
|
1098
958
|
attach?: AttachType<O>
|
|
1099
959
|
previousAttach?: any
|
|
1100
960
|
isHidden: boolean
|
|
1101
|
-
/** Deferred ref props to apply in commitMount */
|
|
1102
|
-
deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
|
|
1103
961
|
/** Set of props that have been applied via once() */
|
|
1104
962
|
appliedOnce?: Set<string>
|
|
1105
963
|
}
|
|
@@ -1225,7 +1083,7 @@ interface CanvasProps
|
|
|
1225
1083
|
*/
|
|
1226
1084
|
resize?: Options
|
|
1227
1085
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1228
|
-
eventSource?:
|
|
1086
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1229
1087
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1230
1088
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1231
1089
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1333,70 +1191,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1333
1191
|
|
|
1334
1192
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1335
1193
|
|
|
1336
|
-
//* Global Types ==============================
|
|
1194
|
+
//* Global TSL Types ==============================
|
|
1337
1195
|
|
|
1338
1196
|
declare global {
|
|
1339
|
-
/** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
|
|
1340
|
-
interface UniformNode<T = unknown> extends Node {
|
|
1341
|
-
value: T
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
1197
|
/**
|
|
1345
|
-
*
|
|
1346
|
-
*
|
|
1347
|
-
* The function returns a ShaderNodeObject when called.
|
|
1348
|
-
*
|
|
1349
|
-
* @example
|
|
1350
|
-
* ```tsx
|
|
1351
|
-
* // Define a shader function
|
|
1352
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1353
|
-
* return mix(color1, color2, factor)
|
|
1354
|
-
* })
|
|
1355
|
-
*
|
|
1356
|
-
* // Type when retrieving from nodes store
|
|
1357
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1358
|
-
*
|
|
1359
|
-
* // Or with specific return type
|
|
1360
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1361
|
-
* ```
|
|
1198
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1199
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1362
1200
|
*/
|
|
1363
|
-
type
|
|
1201
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1202
|
+
readonly shaderNode: unknown
|
|
1203
|
+
readonly id: number
|
|
1204
|
+
}
|
|
1364
1205
|
|
|
1365
|
-
/**
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
*/
|
|
1374
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1206
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1207
|
+
type LegacyTSLNodeLike = {
|
|
1208
|
+
label?: ((label: string) => unknown) | string
|
|
1209
|
+
setName?: (name: string) => unknown
|
|
1210
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1211
|
+
|
|
1212
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1213
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1375
1214
|
|
|
1376
1215
|
/**
|
|
1377
|
-
*
|
|
1378
|
-
*
|
|
1379
|
-
*
|
|
1380
|
-
*
|
|
1381
|
-
* - Node: base Three.js node type
|
|
1382
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1383
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1384
|
-
*
|
|
1385
|
-
* @example
|
|
1386
|
-
* ```tsx
|
|
1387
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1388
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1389
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1390
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1391
|
-
* }))
|
|
1392
|
-
*
|
|
1393
|
-
* // Can narrow with type guard or assertion when needed
|
|
1394
|
-
* if (typeof blendColorFn === 'function') {
|
|
1395
|
-
* blendColorFn(someColor, 0.5)
|
|
1396
|
-
* }
|
|
1397
|
-
* ```
|
|
1216
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1217
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1218
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1219
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1398
1220
|
*/
|
|
1399
|
-
type
|
|
1221
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1222
|
+
? TNodeType
|
|
1223
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1224
|
+
? TNodeType
|
|
1225
|
+
: T extends number
|
|
1226
|
+
? 'float'
|
|
1227
|
+
: T extends boolean
|
|
1228
|
+
? 'bool'
|
|
1229
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1230
|
+
? 'color'
|
|
1231
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1232
|
+
? 'vec4'
|
|
1233
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1234
|
+
? 'vec3'
|
|
1235
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1236
|
+
? 'vec2'
|
|
1237
|
+
: T extends three_webgpu.Matrix4
|
|
1238
|
+
? 'mat4'
|
|
1239
|
+
: T extends three_webgpu.Matrix3
|
|
1240
|
+
? 'mat3'
|
|
1241
|
+
: T extends three_webgpu.Matrix2
|
|
1242
|
+
? 'mat2'
|
|
1243
|
+
: unknown
|
|
1244
|
+
|
|
1245
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1246
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1247
|
+
? TValue
|
|
1248
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1249
|
+
? TValue
|
|
1250
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1251
|
+
? three_webgpu.Color
|
|
1252
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1253
|
+
? three_webgpu.Vector4
|
|
1254
|
+
: T extends { x: number; y: number; z: number }
|
|
1255
|
+
? three_webgpu.Vector3
|
|
1256
|
+
: T extends { x: number; y: number }
|
|
1257
|
+
? three_webgpu.Vector2
|
|
1258
|
+
: T extends number
|
|
1259
|
+
? number
|
|
1260
|
+
: T extends boolean
|
|
1261
|
+
? boolean
|
|
1262
|
+
: T
|
|
1263
|
+
|
|
1264
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1265
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1266
|
+
|
|
1267
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1268
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1269
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1273
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1400
1274
|
|
|
1401
1275
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1402
1276
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1421,7 +1295,7 @@ declare global {
|
|
|
1421
1295
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1422
1296
|
* Supports:
|
|
1423
1297
|
* - Primitives: number, string (color), boolean
|
|
1424
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1298
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1425
1299
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1426
1300
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1427
1301
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1434,227 +1308,124 @@ declare global {
|
|
|
1434
1308
|
| three_webgpu.Vector2
|
|
1435
1309
|
| three_webgpu.Vector3
|
|
1436
1310
|
| three_webgpu.Vector4
|
|
1311
|
+
| three_webgpu.Matrix2
|
|
1437
1312
|
| three_webgpu.Matrix3
|
|
1438
1313
|
| three_webgpu.Matrix4
|
|
1439
|
-
|
|
|
1440
|
-
|
|
|
1441
|
-
| { x: number; y
|
|
1314
|
+
| { x: number; y: number }
|
|
1315
|
+
| { x: number; y: number; z: number }
|
|
1316
|
+
| { x: number; y: number; z: number; w: number }
|
|
1442
1317
|
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1443
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1318
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1444
1319
|
| UniformNode
|
|
1445
1320
|
|
|
1446
1321
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1447
1322
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1448
1323
|
}
|
|
1449
1324
|
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
declare module 'three/tsl' {
|
|
1325
|
+
declare global {
|
|
1453
1326
|
/**
|
|
1454
|
-
*
|
|
1455
|
-
*
|
|
1327
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1328
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1329
|
+
* is r185, so the new name is the only one.
|
|
1456
1330
|
*/
|
|
1457
|
-
|
|
1458
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1459
|
-
): ShaderCallable<R>
|
|
1331
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1460
1332
|
|
|
1461
1333
|
/**
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1334
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1335
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1336
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1464
1337
|
*/
|
|
1465
|
-
|
|
1466
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1467
|
-
): ShaderCallable<R>
|
|
1338
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1468
1339
|
|
|
1469
1340
|
/**
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1341
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1342
|
+
*
|
|
1343
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1344
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1345
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1346
|
+
* {@link RenderPipelineCallbackState}.
|
|
1347
|
+
*
|
|
1348
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1349
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1350
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1351
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1352
|
+
*
|
|
1353
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1354
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1355
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1356
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1472
1357
|
*/
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1358
|
+
interface PassRecord {
|
|
1359
|
+
scenePass?: ScenePassNode
|
|
1360
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1361
|
+
}
|
|
1477
1362
|
|
|
1478
1363
|
/**
|
|
1479
|
-
*
|
|
1364
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1365
|
+
*
|
|
1366
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1367
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1368
|
+
*
|
|
1369
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1370
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1480
1371
|
*/
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
/**
|
|
1488
|
-
* RenderPipeline Types for useRenderPipeline hook (WebGPU only)
|
|
1489
|
-
*/
|
|
1490
|
-
|
|
1491
|
-
|
|
1372
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1373
|
+
renderPipeline: ThreeRenderPipeline
|
|
1374
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1375
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1376
|
+
isLegacy: false
|
|
1377
|
+
}
|
|
1492
1378
|
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1379
|
+
/**
|
|
1380
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1381
|
+
*
|
|
1382
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1383
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1384
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1385
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1386
|
+
*/
|
|
1387
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1496
1388
|
|
|
1497
1389
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1498
|
-
type RenderPipelineSetupCallback = (state:
|
|
1390
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1499
1391
|
|
|
1500
1392
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1501
|
-
type RenderPipelineMainCallback = (state:
|
|
1393
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1502
1394
|
|
|
1503
|
-
/**
|
|
1504
|
-
interface
|
|
1395
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1396
|
+
interface UseRenderPipelineActions {
|
|
1505
1397
|
/** Current passes from state */
|
|
1506
1398
|
passes: PassRecord
|
|
1507
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1508
|
-
renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
|
|
1509
1399
|
/** Clear all passes from state */
|
|
1510
1400
|
clearPasses: () => void
|
|
1511
1401
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1512
1402
|
reset: () => void
|
|
1513
1403
|
/** Re-run setup/main callbacks with current closure values */
|
|
1514
1404
|
rebuild: () => void
|
|
1515
|
-
/** True when RenderPipeline is configured and ready */
|
|
1516
|
-
isReady: boolean
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
//* useFrameNext Types ==============================
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
//* Global Type Declarations ==============================
|
|
1525
|
-
|
|
1526
|
-
declare global {
|
|
1527
|
-
// Job --------------------------------
|
|
1528
|
-
|
|
1529
|
-
/**
|
|
1530
|
-
* Internal job representation in the scheduler
|
|
1531
|
-
*/
|
|
1532
|
-
interface Job {
|
|
1533
|
-
/** Unique identifier */
|
|
1534
|
-
id: string
|
|
1535
|
-
/** The callback to execute */
|
|
1536
|
-
callback: FrameNextCallback
|
|
1537
|
-
/** Phase this job belongs to */
|
|
1538
|
-
phase: string
|
|
1539
|
-
/** Run before these phases/job ids */
|
|
1540
|
-
before: Set<string>
|
|
1541
|
-
/** Run after these phases/job ids */
|
|
1542
|
-
after: Set<string>
|
|
1543
|
-
/** Priority within phase (higher first) */
|
|
1544
|
-
priority: number
|
|
1545
|
-
/** Insertion order for deterministic tie-breaking */
|
|
1546
|
-
index: number
|
|
1547
|
-
/** Max FPS for this job (undefined = no limit) */
|
|
1548
|
-
fps?: number
|
|
1549
|
-
/** Drop frames when behind (true) or catch up (false) */
|
|
1550
|
-
drop: boolean
|
|
1551
|
-
/** Last run timestamp (ms) */
|
|
1552
|
-
lastRun?: number
|
|
1553
|
-
/** Whether job is enabled */
|
|
1554
|
-
enabled: boolean
|
|
1555
|
-
/** Internal flag: system jobs (like default render) don't block user render takeover */
|
|
1556
|
-
system?: boolean
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
// Phase Graph --------------------------------
|
|
1560
|
-
|
|
1561
|
-
/**
|
|
1562
|
-
* A node in the phase graph
|
|
1563
|
-
*/
|
|
1564
|
-
interface PhaseNode {
|
|
1565
|
-
/** Phase name */
|
|
1566
|
-
name: string
|
|
1567
|
-
/** Whether this was auto-generated from a before/after constraint */
|
|
1568
|
-
isAutoGenerated: boolean
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
/**
|
|
1572
|
-
* Options for creating a job from hook options
|
|
1573
|
-
*/
|
|
1574
|
-
interface JobOptions {
|
|
1575
|
-
id?: string
|
|
1576
|
-
phase?: string
|
|
1577
|
-
before?: string | string[]
|
|
1578
|
-
after?: string | string[]
|
|
1579
|
-
priority?: number
|
|
1580
|
-
fps?: number
|
|
1581
|
-
drop?: boolean
|
|
1582
|
-
enabled?: boolean
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
// Frame Loop State --------------------------------
|
|
1586
|
-
|
|
1587
|
-
/**
|
|
1588
|
-
* Internal frame loop state
|
|
1589
|
-
*/
|
|
1590
|
-
interface FrameLoopState {
|
|
1591
|
-
/** Whether the loop is running */
|
|
1592
|
-
running: boolean
|
|
1593
|
-
/** Current RAF handle */
|
|
1594
|
-
rafHandle: number | null
|
|
1595
|
-
/** Last frame timestamp in ms (null = uninitialized) */
|
|
1596
|
-
lastTime: number | null
|
|
1597
|
-
/** Frame counter */
|
|
1598
|
-
frameCount: number
|
|
1599
|
-
/** Elapsed time since first frame in ms */
|
|
1600
|
-
elapsedTime: number
|
|
1601
|
-
/** createdAt timestamp in ms */
|
|
1602
|
-
createdAt: number
|
|
1603
|
-
}
|
|
1604
|
-
|
|
1605
|
-
// Root Entry --------------------------------
|
|
1606
|
-
|
|
1607
|
-
/**
|
|
1608
|
-
* Internal representation of a registered root (Canvas).
|
|
1609
|
-
* Tracks jobs and manages rebuild state for this root.
|
|
1610
|
-
* @internal
|
|
1611
|
-
*/
|
|
1612
|
-
interface RootEntry {
|
|
1613
|
-
/** Unique identifier for this root */
|
|
1614
|
-
id: string
|
|
1615
|
-
/** Function to get the root's current state. Returns any to support independent mode. */
|
|
1616
|
-
getState: () => any
|
|
1617
|
-
/** Map of job IDs to Job objects */
|
|
1618
|
-
jobs: Map<string, Job>
|
|
1619
|
-
/** Cached sorted job list for execution order */
|
|
1620
|
-
sortedJobs: Job[]
|
|
1621
|
-
/** Whether sortedJobs needs rebuilding */
|
|
1622
|
-
needsRebuild: boolean
|
|
1623
1405
|
}
|
|
1624
1406
|
|
|
1625
1407
|
/**
|
|
1626
|
-
*
|
|
1627
|
-
*
|
|
1628
|
-
*
|
|
1629
|
-
*
|
|
1630
|
-
*
|
|
1631
|
-
*/
|
|
1632
|
-
interface GlobalJob {
|
|
1633
|
-
/** Unique identifier for this global job */
|
|
1634
|
-
id: string
|
|
1635
|
-
/** Callback invoked with RAF timestamp in ms */
|
|
1636
|
-
callback: (timestamp: number) => void
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
// HMR Support --------------------------------
|
|
1640
|
-
|
|
1641
|
-
/**
|
|
1642
|
-
* Hot Module Replacement data structure for preserving scheduler state
|
|
1643
|
-
* @internal
|
|
1644
|
-
*/
|
|
1645
|
-
interface HMRData {
|
|
1646
|
-
/** Shared data object for storing values across reloads */
|
|
1647
|
-
data: Record<string, any>
|
|
1648
|
-
/** Optional function to accept HMR updates */
|
|
1649
|
-
accept?: () => void
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
// Default Phases --------------------------------
|
|
1653
|
-
|
|
1654
|
-
/**
|
|
1655
|
-
* Default phase names for the scheduler
|
|
1408
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1409
|
+
*
|
|
1410
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1411
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1412
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1656
1413
|
*/
|
|
1657
|
-
type
|
|
1414
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1415
|
+
(
|
|
1416
|
+
| {
|
|
1417
|
+
/** True when RenderPipeline is configured and ready */
|
|
1418
|
+
isReady: true
|
|
1419
|
+
/** RenderPipeline instance */
|
|
1420
|
+
renderPipeline: ThreeRenderPipeline
|
|
1421
|
+
}
|
|
1422
|
+
| {
|
|
1423
|
+
/** False until the pipeline has been created */
|
|
1424
|
+
isReady: false
|
|
1425
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1426
|
+
renderPipeline: null
|
|
1427
|
+
}
|
|
1428
|
+
)
|
|
1658
1429
|
}
|
|
1659
1430
|
|
|
1660
1431
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1733,10 +1504,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1733
1504
|
|
|
1734
1505
|
/**
|
|
1735
1506
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1736
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1507
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1508
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1737
1509
|
*/
|
|
1738
1510
|
type NodeProps<P> = {
|
|
1739
|
-
[K in keyof P as P[K] extends
|
|
1511
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1740
1512
|
}
|
|
1741
1513
|
|
|
1742
1514
|
interface ReactProps<P> {
|
|
@@ -1757,11 +1529,30 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1757
1529
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1758
1530
|
}
|
|
1759
1531
|
|
|
1532
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1533
|
+
type Object3DMethod = NonNullable<
|
|
1534
|
+
{
|
|
1535
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1536
|
+
}[keyof Object3D]
|
|
1537
|
+
>
|
|
1538
|
+
|
|
1760
1539
|
type ThreeExports = typeof THREE
|
|
1761
1540
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1762
1541
|
|
|
1763
1542
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1764
|
-
|
|
1543
|
+
/**
|
|
1544
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1545
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1546
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1547
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1548
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1549
|
+
*/
|
|
1550
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | 'onUpdate' | Object3DMethod> & {
|
|
1551
|
+
object: object
|
|
1552
|
+
ref?: React.Ref<any>
|
|
1553
|
+
onUpdate?: (self: any) => void
|
|
1554
|
+
[prop: string]: unknown
|
|
1555
|
+
}
|
|
1765
1556
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1766
1557
|
threeAudio: ThreeElementsImpl['audio']
|
|
1767
1558
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1802,6 +1593,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1802
1593
|
type three_d_Matrix4 = Matrix4;
|
|
1803
1594
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1804
1595
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1596
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1805
1597
|
type three_d_Quaternion = Quaternion;
|
|
1806
1598
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1807
1599
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1816,7 +1608,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1816
1608
|
type three_d_Vector4 = Vector4;
|
|
1817
1609
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1818
1610
|
declare namespace three_d {
|
|
1819
|
-
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 };
|
|
1611
|
+
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 };
|
|
1820
1612
|
}
|
|
1821
1613
|
|
|
1822
1614
|
/**
|
|
@@ -1826,7 +1618,7 @@ declare namespace three_d {
|
|
|
1826
1618
|
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
1827
1619
|
*
|
|
1828
1620
|
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
1829
|
-
* Secondary canvas: Has `
|
|
1621
|
+
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
1830
1622
|
*/
|
|
1831
1623
|
|
|
1832
1624
|
interface PrimaryCanvasEntry {
|
|
@@ -1894,12 +1686,23 @@ type EnvironmentLoaderProps = {
|
|
|
1894
1686
|
* const texture = useEnvironment({ preset: 'sunset' })
|
|
1895
1687
|
* ```
|
|
1896
1688
|
*/
|
|
1897
|
-
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture
|
|
1689
|
+
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
|
|
1898
1690
|
declare namespace useEnvironment {
|
|
1899
1691
|
var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
|
|
1900
1692
|
var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
|
|
1901
1693
|
}
|
|
1902
|
-
|
|
1694
|
+
/**
|
|
1695
|
+
* Options accepted by `useEnvironment.preload`.
|
|
1696
|
+
*
|
|
1697
|
+
* `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
|
|
1698
|
+
* applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
|
|
1699
|
+
* advertise an option this function silently ignores.
|
|
1700
|
+
*
|
|
1701
|
+
* This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
|
|
1702
|
+
* `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
|
|
1703
|
+
* type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
|
|
1704
|
+
*/
|
|
1705
|
+
type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
|
|
1903
1706
|
type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
|
|
1904
1707
|
|
|
1905
1708
|
/**
|
|
@@ -1943,9 +1746,9 @@ type EnvironmentProps = {
|
|
|
1943
1746
|
blur?: number;
|
|
1944
1747
|
backgroundBlurriness?: number;
|
|
1945
1748
|
backgroundIntensity?: number;
|
|
1946
|
-
backgroundRotation?: Euler
|
|
1749
|
+
backgroundRotation?: Euler;
|
|
1947
1750
|
environmentIntensity?: number;
|
|
1948
|
-
environmentRotation?: Euler
|
|
1751
|
+
environmentRotation?: Euler;
|
|
1949
1752
|
map?: Texture$1;
|
|
1950
1753
|
preset?: PresetsType;
|
|
1951
1754
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -2029,7 +1832,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
2029
1832
|
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;
|
|
2030
1833
|
declare module '@react-three/fiber' {
|
|
2031
1834
|
interface ThreeElements {
|
|
2032
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1835
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
2033
1836
|
}
|
|
2034
1837
|
}
|
|
2035
1838
|
/**
|
|
@@ -2129,6 +1932,24 @@ declare module '@react-three/fiber' {
|
|
|
2129
1932
|
*/
|
|
2130
1933
|
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
2131
1934
|
|
|
1935
|
+
/**
|
|
1936
|
+
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
1937
|
+
*
|
|
1938
|
+
* When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
|
|
1939
|
+
* instance. Removing the old object from the interaction state and registering the new one from
|
|
1940
|
+
* scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
|
|
1941
|
+
* the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
|
|
1942
|
+
* is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
|
|
1943
|
+
* swap the user never asked to see (#3744).
|
|
1944
|
+
*
|
|
1945
|
+
* Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
|
|
1946
|
+
* left alone — releasing and re-acquiring it is precisely the glitch being avoided.
|
|
1947
|
+
*
|
|
1948
|
+
* Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
|
|
1949
|
+
* the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
|
|
1950
|
+
* cannot outlive the object it described.
|
|
1951
|
+
*/
|
|
1952
|
+
declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
|
|
2132
1953
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
2133
1954
|
declare function createEvents(store: RootStore): {
|
|
2134
1955
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
@@ -2136,7 +1957,7 @@ declare function createEvents(store: RootStore): {
|
|
|
2136
1957
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
2137
1958
|
};
|
|
2138
1959
|
/** Default R3F event manager for web */
|
|
2139
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1960
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
2140
1961
|
|
|
2141
1962
|
/**
|
|
2142
1963
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -2149,389 +1970,27 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
|
|
|
2149
1970
|
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
2150
1971
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
2151
1972
|
*/
|
|
2152
|
-
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>;
|
|
1973
|
+
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>;
|
|
2153
1974
|
declare namespace useLoader {
|
|
2154
|
-
var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
|
|
2155
|
-
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
|
|
1975
|
+
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;
|
|
1976
|
+
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
|
|
2156
1977
|
var loader: typeof getLoader;
|
|
2157
1978
|
}
|
|
2158
1979
|
|
|
2159
|
-
/**
|
|
2160
|
-
* Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
|
|
2161
|
-
*
|
|
2162
|
-
* Features:
|
|
2163
|
-
* - Single RAF loop for entire application
|
|
2164
|
-
* - Root registration (multiple Canvas support)
|
|
2165
|
-
* - Global phases for addEffect/addAfterEffect (deprecated)
|
|
2166
|
-
* - Per-root job management with phases, priorities, FPS throttling
|
|
2167
|
-
* - onIdle callbacks for addTail (deprecated)
|
|
2168
|
-
* - Demand mode support via invalidate()
|
|
2169
|
-
*/
|
|
2170
|
-
declare class Scheduler {
|
|
2171
|
-
private static readonly INSTANCE_KEY;
|
|
2172
|
-
private static get instance();
|
|
2173
|
-
private static set instance(value);
|
|
2174
|
-
/**
|
|
2175
|
-
* Get the global scheduler instance (creates if doesn't exist).
|
|
2176
|
-
* Uses HMR data to preserve instance across hot reloads.
|
|
2177
|
-
* @returns {Scheduler} The singleton scheduler instance
|
|
2178
|
-
*/
|
|
2179
|
-
static get(): Scheduler;
|
|
2180
|
-
/**
|
|
2181
|
-
* Reset the singleton instance. Stops the loop and clears all state.
|
|
2182
|
-
* Primarily used for testing to ensure clean state between tests.
|
|
2183
|
-
* @returns {void}
|
|
2184
|
-
*/
|
|
2185
|
-
static reset(): void;
|
|
2186
|
-
private roots;
|
|
2187
|
-
private phaseGraph;
|
|
2188
|
-
private loopState;
|
|
2189
|
-
private stoppedTime;
|
|
2190
|
-
private nextRootIndex;
|
|
2191
|
-
private globalBeforeJobs;
|
|
2192
|
-
private globalAfterJobs;
|
|
2193
|
-
private nextGlobalIndex;
|
|
2194
|
-
private idleCallbacks;
|
|
2195
|
-
private nextJobIndex;
|
|
2196
|
-
private jobStateListeners;
|
|
2197
|
-
private pendingFrames;
|
|
2198
|
-
private _frameloop;
|
|
2199
|
-
private _independent;
|
|
2200
|
-
private errorHandler;
|
|
2201
|
-
private rootReadyCallbacks;
|
|
2202
|
-
get phases(): string[];
|
|
2203
|
-
get frameloop(): Frameloop;
|
|
2204
|
-
set frameloop(mode: Frameloop);
|
|
2205
|
-
get isRunning(): boolean;
|
|
2206
|
-
get isReady(): boolean;
|
|
2207
|
-
get independent(): boolean;
|
|
2208
|
-
set independent(value: boolean);
|
|
2209
|
-
constructor();
|
|
2210
|
-
/**
|
|
2211
|
-
* Register a root (Canvas) with the scheduler.
|
|
2212
|
-
* The first root to register starts the RAF loop (if frameloop='always').
|
|
2213
|
-
* @param {string} id - Unique identifier for this root
|
|
2214
|
-
* @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
|
|
2215
|
-
* @returns {() => void} Unsubscribe function to remove this root
|
|
2216
|
-
*/
|
|
2217
|
-
registerRoot(id: string, options?: RootOptions): () => void;
|
|
2218
|
-
/**
|
|
2219
|
-
* Unregister a root from the scheduler.
|
|
2220
|
-
* Cleans up all job state listeners for this root's jobs.
|
|
2221
|
-
* The last root to unregister stops the RAF loop.
|
|
2222
|
-
* @param {string} id - The root ID to unregister
|
|
2223
|
-
* @returns {void}
|
|
2224
|
-
*/
|
|
2225
|
-
unregisterRoot(id: string): void;
|
|
2226
|
-
/**
|
|
2227
|
-
* Subscribe to be notified when a root becomes available.
|
|
2228
|
-
* Fires immediately if a root already exists.
|
|
2229
|
-
* @param {() => void} callback - Function called when first root registers
|
|
2230
|
-
* @returns {() => void} Unsubscribe function
|
|
2231
|
-
*/
|
|
2232
|
-
onRootReady(callback: () => void): () => void;
|
|
2233
|
-
/**
|
|
2234
|
-
* Notify all registered root-ready callbacks.
|
|
2235
|
-
* Called when the first root registers.
|
|
2236
|
-
* @returns {void}
|
|
2237
|
-
* @private
|
|
2238
|
-
*/
|
|
2239
|
-
private notifyRootReady;
|
|
2240
|
-
/**
|
|
2241
|
-
* Ensure a default root exists for independent mode.
|
|
2242
|
-
* Creates a minimal root with no state provider.
|
|
2243
|
-
* @returns {void}
|
|
2244
|
-
* @private
|
|
2245
|
-
*/
|
|
2246
|
-
private ensureDefaultRoot;
|
|
2247
|
-
/**
|
|
2248
|
-
* Trigger error handling for job errors.
|
|
2249
|
-
* Uses the bound error handler if available, otherwise logs to console.
|
|
2250
|
-
* @param {Error} error - The error to handle
|
|
2251
|
-
* @returns {void}
|
|
2252
|
-
*/
|
|
2253
|
-
triggerError(error: Error): void;
|
|
2254
|
-
/**
|
|
2255
|
-
* Add a named phase to the scheduler's execution order.
|
|
2256
|
-
* Marks all roots for rebuild to incorporate the new phase.
|
|
2257
|
-
* @param {string} name - The phase name (e.g., 'physics', 'postprocess')
|
|
2258
|
-
* @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
|
|
2259
|
-
* @returns {void}
|
|
2260
|
-
* @example
|
|
2261
|
-
* scheduler.addPhase('physics', { before: 'update' });
|
|
2262
|
-
* scheduler.addPhase('postprocess', { after: 'render' });
|
|
2263
|
-
*/
|
|
2264
|
-
addPhase(name: string, options?: AddPhaseOptions): void;
|
|
2265
|
-
/**
|
|
2266
|
-
* Check if a phase exists in the scheduler.
|
|
2267
|
-
* @param {string} name - The phase name to check
|
|
2268
|
-
* @returns {boolean} True if the phase exists
|
|
2269
|
-
*/
|
|
2270
|
-
hasPhase(name: string): boolean;
|
|
2271
|
-
/**
|
|
2272
|
-
* Register a global job that runs once per frame (not per-root).
|
|
2273
|
-
* Used internally by deprecated addEffect/addAfterEffect APIs.
|
|
2274
|
-
* @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
|
|
2275
|
-
* @param {string} id - Unique identifier for this global job
|
|
2276
|
-
* @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
|
|
2277
|
-
* @returns {() => void} Unsubscribe function to remove this global job
|
|
2278
|
-
* @deprecated Use useFrame with phases instead
|
|
2279
|
-
*/
|
|
2280
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
|
|
2281
|
-
/**
|
|
2282
|
-
* Register an idle callback that fires when the loop stops.
|
|
2283
|
-
* Used internally by deprecated addTail API.
|
|
2284
|
-
* @param {(timestamp: number) => void} callback - Function called when loop becomes idle
|
|
2285
|
-
* @returns {() => void} Unsubscribe function to remove this idle callback
|
|
2286
|
-
* @deprecated Use demand mode with invalidate() instead
|
|
2287
|
-
*/
|
|
2288
|
-
onIdle(callback: (timestamp: number) => void): () => void;
|
|
2289
|
-
/**
|
|
2290
|
-
* Notify all registered idle callbacks.
|
|
2291
|
-
* Called when the loop stops in demand mode.
|
|
2292
|
-
* @param {number} timestamp - The RAF timestamp when idle occurred
|
|
2293
|
-
* @returns {void}
|
|
2294
|
-
* @private
|
|
2295
|
-
*/
|
|
2296
|
-
private notifyIdle;
|
|
2297
|
-
/**
|
|
2298
|
-
* Register a job (frame callback) with a specific root.
|
|
2299
|
-
* This is the core registration method used by useFrame internally.
|
|
2300
|
-
* @param {FrameNextCallback} callback - The function to call each frame
|
|
2301
|
-
* @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
|
|
2302
|
-
* @param {string} [options.rootId] - Target root ID (defaults to first registered root)
|
|
2303
|
-
* @param {string} [options.id] - Unique job ID (auto-generated if not provided)
|
|
2304
|
-
* @param {string} [options.phase] - Execution phase (defaults to 'update')
|
|
2305
|
-
* @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
|
|
2306
|
-
* @param {number} [options.fps] - FPS throttle limit
|
|
2307
|
-
* @param {boolean} [options.drop] - Drop frames when behind (default true)
|
|
2308
|
-
* @param {boolean} [options.enabled] - Whether job is active (default true)
|
|
2309
|
-
* @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
|
|
2310
|
-
* @returns {() => void} Unsubscribe function to remove this job
|
|
2311
|
-
*/
|
|
2312
|
-
register(callback: FrameNextCallback, options?: JobOptions & {
|
|
2313
|
-
rootId?: string;
|
|
2314
|
-
system?: boolean;
|
|
2315
|
-
}): () => void;
|
|
2316
|
-
/**
|
|
2317
|
-
* Unregister a job by its ID.
|
|
2318
|
-
* Searches all roots if rootId is not provided.
|
|
2319
|
-
* @param {string} id - The job ID to unregister
|
|
2320
|
-
* @param {string} [rootId] - Optional root ID to search (searches all if not provided)
|
|
2321
|
-
* @returns {void}
|
|
2322
|
-
*/
|
|
2323
|
-
unregister(id: string, rootId?: string): void;
|
|
2324
|
-
/**
|
|
2325
|
-
* Update a job's options dynamically.
|
|
2326
|
-
* Searches all roots to find the job by ID.
|
|
2327
|
-
* Phase/constraint changes trigger a rebuild of the sorted job list.
|
|
2328
|
-
* @param {string} id - The job ID to update
|
|
2329
|
-
* @param {Partial<JobOptions>} options - The options to update
|
|
2330
|
-
* @returns {void}
|
|
2331
|
-
*/
|
|
2332
|
-
updateJob(id: string, options: Partial<JobOptions>): void;
|
|
2333
|
-
/**
|
|
2334
|
-
* Check if a job is currently paused (disabled).
|
|
2335
|
-
* @param {string} id - The job ID to check
|
|
2336
|
-
* @returns {boolean} True if the job exists and is paused
|
|
2337
|
-
*/
|
|
2338
|
-
isJobPaused(id: string): boolean;
|
|
2339
|
-
/**
|
|
2340
|
-
* Subscribe to state changes for a specific job.
|
|
2341
|
-
* Listener is called when job is paused or resumed.
|
|
2342
|
-
* @param {string} id - The job ID to subscribe to
|
|
2343
|
-
* @param {() => void} listener - Callback invoked on state changes
|
|
2344
|
-
* @returns {() => void} Unsubscribe function
|
|
2345
|
-
*/
|
|
2346
|
-
subscribeJobState(id: string, listener: () => void): () => void;
|
|
2347
|
-
/**
|
|
2348
|
-
* Notify all listeners that a job's state has changed.
|
|
2349
|
-
* @param {string} id - The job ID that changed
|
|
2350
|
-
* @returns {void}
|
|
2351
|
-
* @private
|
|
2352
|
-
*/
|
|
2353
|
-
private notifyJobStateChange;
|
|
2354
|
-
/**
|
|
2355
|
-
* Pause a job by ID (sets enabled=false).
|
|
2356
|
-
* Notifies any subscribed state listeners.
|
|
2357
|
-
* @param {string} id - The job ID to pause
|
|
2358
|
-
* @returns {void}
|
|
2359
|
-
*/
|
|
2360
|
-
pauseJob(id: string): void;
|
|
2361
|
-
/**
|
|
2362
|
-
* Resume a paused job by ID (sets enabled=true).
|
|
2363
|
-
* Resets job timing to prevent frame accumulation.
|
|
2364
|
-
* Notifies any subscribed state listeners.
|
|
2365
|
-
* @param {string} id - The job ID to resume
|
|
2366
|
-
* @returns {void}
|
|
2367
|
-
*/
|
|
2368
|
-
resumeJob(id: string): void;
|
|
2369
|
-
/**
|
|
2370
|
-
* Start the requestAnimationFrame loop.
|
|
2371
|
-
* Resets timing state (elapsedTime, frameCount) on start.
|
|
2372
|
-
* No-op if already running.
|
|
2373
|
-
* @returns {void}
|
|
2374
|
-
*/
|
|
2375
|
-
start(): void;
|
|
2376
|
-
/**
|
|
2377
|
-
* Stop the requestAnimationFrame loop.
|
|
2378
|
-
* Cancels any pending RAF callback.
|
|
2379
|
-
* No-op if not running.
|
|
2380
|
-
* @returns {void}
|
|
2381
|
-
*/
|
|
2382
|
-
stop(): void;
|
|
2383
|
-
/**
|
|
2384
|
-
* Request frames to be rendered in demand mode.
|
|
2385
|
-
* Accumulates pending frames (capped at 60) and starts the loop if not running.
|
|
2386
|
-
* No-op if frameloop is not 'demand'.
|
|
2387
|
-
* @param {number} [frames=1] - Number of frames to request
|
|
2388
|
-
* @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
|
|
2389
|
-
* - `false` (default): Sets pending frames to the specified value (replaces existing count)
|
|
2390
|
-
* - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
|
|
2391
|
-
* @returns {void}
|
|
2392
|
-
* @example
|
|
2393
|
-
* // Request a single frame render
|
|
2394
|
-
* scheduler.invalidate();
|
|
2395
|
-
*
|
|
2396
|
-
* @example
|
|
2397
|
-
* // Request 5 frames (e.g., for animations)
|
|
2398
|
-
* scheduler.invalidate(5);
|
|
2399
|
-
*
|
|
2400
|
-
* @example
|
|
2401
|
-
* // Set pending frames to exactly 3 (don't stack with existing)
|
|
2402
|
-
* scheduler.invalidate(3, false);
|
|
2403
|
-
*
|
|
2404
|
-
* @example
|
|
2405
|
-
* // Add 2 more frames to existing pending count
|
|
2406
|
-
* scheduler.invalidate(2, true);
|
|
2407
|
-
*/
|
|
2408
|
-
invalidate(frames?: number, stackFrames?: boolean): void;
|
|
2409
|
-
/**
|
|
2410
|
-
* Reset timing state for deterministic testing.
|
|
2411
|
-
* Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
|
|
2412
|
-
* @returns {void}
|
|
2413
|
-
*/
|
|
2414
|
-
resetTiming(): void;
|
|
2415
|
-
/**
|
|
2416
|
-
* Manually execute a single frame for all roots.
|
|
2417
|
-
* Useful for frameloop='never' mode or testing scenarios.
|
|
2418
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2419
|
-
* @returns {void}
|
|
2420
|
-
* @example
|
|
2421
|
-
* // Manual control mode
|
|
2422
|
-
* scheduler.frameloop = 'never';
|
|
2423
|
-
* scheduler.step(); // Execute one frame
|
|
2424
|
-
*/
|
|
2425
|
-
step(timestamp?: number): void;
|
|
2426
|
-
/**
|
|
2427
|
-
* Manually execute a single job by its ID.
|
|
2428
|
-
* Useful for testing individual job callbacks in isolation.
|
|
2429
|
-
* @param {string} id - The job ID to step
|
|
2430
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2431
|
-
* @returns {void}
|
|
2432
|
-
*/
|
|
2433
|
-
stepJob(id: string, timestamp?: number): void;
|
|
2434
|
-
/**
|
|
2435
|
-
* Main RAF loop callback.
|
|
2436
|
-
* Executes frame, handles demand mode, and schedules next frame.
|
|
2437
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2438
|
-
* @returns {void}
|
|
2439
|
-
* @private
|
|
2440
|
-
*/
|
|
2441
|
-
private loop;
|
|
2442
|
-
/**
|
|
2443
|
-
* Execute a single frame across all roots.
|
|
2444
|
-
* Order: globalBefore → each root's jobs → globalAfter
|
|
2445
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2446
|
-
* @returns {void}
|
|
2447
|
-
* @private
|
|
2448
|
-
*/
|
|
2449
|
-
private executeFrame;
|
|
2450
|
-
/**
|
|
2451
|
-
* Run all global jobs from a job map.
|
|
2452
|
-
* Catches and logs errors without stopping execution.
|
|
2453
|
-
* @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
|
|
2454
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2455
|
-
* @returns {void}
|
|
2456
|
-
* @private
|
|
2457
|
-
*/
|
|
2458
|
-
private runGlobalJobs;
|
|
2459
|
-
/**
|
|
2460
|
-
* Execute all jobs for a single root in sorted order.
|
|
2461
|
-
* Rebuilds sorted job list if needed, then dispatches each job.
|
|
2462
|
-
* Errors are caught and propagated via triggerError.
|
|
2463
|
-
* @param {RootEntry} root - The root entry to tick
|
|
2464
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2465
|
-
* @param {number} delta - Time since last frame in seconds
|
|
2466
|
-
* @returns {void}
|
|
2467
|
-
* @private
|
|
2468
|
-
*/
|
|
2469
|
-
private tickRoot;
|
|
2470
|
-
/**
|
|
2471
|
-
* Get the total number of registered jobs across all roots.
|
|
2472
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2473
|
-
* @returns {number} Total job count
|
|
2474
|
-
*/
|
|
2475
|
-
getJobCount(): number;
|
|
2476
|
-
/**
|
|
2477
|
-
* Get all registered job IDs across all roots.
|
|
2478
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2479
|
-
* @returns {string[]} Array of all job IDs
|
|
2480
|
-
*/
|
|
2481
|
-
getJobIds(): string[];
|
|
2482
|
-
/**
|
|
2483
|
-
* Get the number of registered roots (Canvas instances).
|
|
2484
|
-
* @returns {number} Number of registered roots
|
|
2485
|
-
*/
|
|
2486
|
-
getRootCount(): number;
|
|
2487
|
-
/**
|
|
2488
|
-
* Check if any user (non-system) jobs are registered in a specific phase.
|
|
2489
|
-
* Used by the default render job to know if a user has taken over rendering.
|
|
2490
|
-
*
|
|
2491
|
-
* @param phase The phase to check
|
|
2492
|
-
* @param rootId Optional root ID to check (checks all roots if not provided)
|
|
2493
|
-
* @returns true if any user jobs exist in the phase
|
|
2494
|
-
*/
|
|
2495
|
-
hasUserJobsInPhase(phase: string, rootId?: string): boolean;
|
|
2496
|
-
/**
|
|
2497
|
-
* Generate a unique root ID for automatic root registration.
|
|
2498
|
-
* @returns {string} A unique root ID in the format 'root_N'
|
|
2499
|
-
*/
|
|
2500
|
-
generateRootId(): string;
|
|
2501
|
-
/**
|
|
2502
|
-
* Generate a unique job ID.
|
|
2503
|
-
* @returns {string} A unique job ID in the format 'job_N'
|
|
2504
|
-
* @private
|
|
2505
|
-
*/
|
|
2506
|
-
private generateJobId;
|
|
2507
|
-
/**
|
|
2508
|
-
* Normalize before/after constraints to a Set.
|
|
2509
|
-
* Handles undefined, single string, or array inputs.
|
|
2510
|
-
* @param {string | string[] | undefined} value - The constraint value(s)
|
|
2511
|
-
* @returns {Set<string>} Normalized Set of constraint strings
|
|
2512
|
-
* @private
|
|
2513
|
-
*/
|
|
2514
|
-
private normalizeConstraints;
|
|
2515
|
-
}
|
|
2516
|
-
/**
|
|
2517
|
-
* Get the global scheduler instance.
|
|
2518
|
-
* Creates one if it doesn't exist.
|
|
2519
|
-
*/
|
|
2520
|
-
declare const getScheduler: () => Scheduler;
|
|
2521
|
-
|
|
2522
1980
|
/**
|
|
2523
1981
|
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
2524
1982
|
*
|
|
2525
|
-
*
|
|
2526
|
-
* - Inside Canvas: Full RootState (
|
|
2527
|
-
* - Outside Canvas
|
|
2528
|
-
*
|
|
1983
|
+
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1984
|
+
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1985
|
+
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1986
|
+
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1987
|
+
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
2529
1988
|
*
|
|
2530
1989
|
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
2531
1990
|
*
|
|
2532
1991
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
2533
1992
|
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
2534
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1993
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
2535
1994
|
*
|
|
2536
1995
|
* @example
|
|
2537
1996
|
* // Simple priority (backwards compat)
|
|
@@ -2542,16 +2001,16 @@ declare const getScheduler: () => Scheduler;
|
|
|
2542
2001
|
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
2543
2002
|
*
|
|
2544
2003
|
* @example
|
|
2545
|
-
* // Outside Canvas - waits for Canvas
|
|
2004
|
+
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
2546
2005
|
* function UI() {
|
|
2547
2006
|
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
2548
2007
|
* return <button>...</button>;
|
|
2549
2008
|
* }
|
|
2550
2009
|
*
|
|
2551
2010
|
* @example
|
|
2552
|
-
* //
|
|
2553
|
-
* getScheduler
|
|
2554
|
-
*
|
|
2011
|
+
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
2012
|
+
* import { getScheduler } from '@pmndrs/scheduler'
|
|
2013
|
+
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
2555
2014
|
*
|
|
2556
2015
|
* @example
|
|
2557
2016
|
* // Scheduler-only access (no callback)
|
|
@@ -2827,7 +2286,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2827
2286
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2828
2287
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2829
2288
|
*
|
|
2830
|
-
*
|
|
2289
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2290
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2291
|
+
*
|
|
2292
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2831
2293
|
* @param frames - Number of frames to request (default: 1)
|
|
2832
2294
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2833
2295
|
*
|
|
@@ -2838,14 +2300,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2838
2300
|
* Advances the frameloop and runs render effects.
|
|
2839
2301
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2840
2302
|
*
|
|
2303
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2304
|
+
* registered root is stepped for backwards compatibility.
|
|
2305
|
+
*
|
|
2841
2306
|
* @param timestamp - The timestamp to use for this frame
|
|
2842
2307
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2843
|
-
* @param state -
|
|
2844
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2308
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2845
2309
|
*
|
|
2846
2310
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2847
2311
|
*/
|
|
2848
|
-
declare function advance(timestamp: number): void;
|
|
2312
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2849
2313
|
|
|
2850
2314
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2851
2315
|
declare function ReactReconciler<
|
|
@@ -3890,6 +3354,7 @@ declare namespace ReactReconciler {
|
|
|
3890
3354
|
|
|
3891
3355
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3892
3356
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3357
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3893
3358
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3894
3359
|
|
|
3895
3360
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3916,11 +3381,6 @@ declare function flushSync<R>(fn: () => R): R;
|
|
|
3916
3381
|
declare const context: React$1.Context<RootStore>;
|
|
3917
3382
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3918
3383
|
|
|
3919
|
-
/**
|
|
3920
|
-
* Safely flush async effects when testing, simulating a legacy root.
|
|
3921
|
-
* @deprecated Import from React instead. import { act } from 'react'
|
|
3922
|
-
*/
|
|
3923
|
-
declare const act: typeof React$1.act;
|
|
3924
3384
|
/**
|
|
3925
3385
|
* An SSR-friendly useLayoutEffect.
|
|
3926
3386
|
*
|
|
@@ -4338,29 +3798,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
4338
3798
|
* Used to identify values that should be resolved from refs after mount.
|
|
4339
3799
|
*/
|
|
4340
3800
|
declare const FROM_REF: unique symbol;
|
|
3801
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3802
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3803
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3804
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3805
|
+
transform?: (value: T) => R;
|
|
3806
|
+
}
|
|
4341
3807
|
/**
|
|
4342
3808
|
* Defers prop application until the referenced object is available.
|
|
4343
3809
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
4344
3810
|
*
|
|
3811
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3812
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3813
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3814
|
+
* what gets assigned.
|
|
3815
|
+
*
|
|
4345
3816
|
* @param ref - React ref object to resolve at mount time
|
|
4346
|
-
* @
|
|
3817
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3818
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
4347
3819
|
*
|
|
4348
3820
|
* @example
|
|
4349
3821
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
4350
3822
|
*
|
|
4351
3823
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
4352
3824
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3825
|
+
*
|
|
3826
|
+
* @example
|
|
3827
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3828
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
4353
3829
|
*/
|
|
4354
3830
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3831
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
4355
3832
|
/**
|
|
4356
3833
|
* Type guard to check if a value is a fromRef marker.
|
|
4357
3834
|
*
|
|
4358
3835
|
* @param value - Value to check
|
|
4359
3836
|
* @returns True if value is a fromRef marker
|
|
4360
3837
|
*/
|
|
4361
|
-
declare function isFromRef(value: unknown): value is
|
|
4362
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
4363
|
-
};
|
|
3838
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
4364
3839
|
|
|
4365
3840
|
/**
|
|
4366
3841
|
* Symbol marker for mount-only method calls.
|
|
@@ -4387,7 +3862,15 @@ declare const ONCE: unique symbol;
|
|
|
4387
3862
|
* // No arguments
|
|
4388
3863
|
* <geometry center={once()} />
|
|
4389
3864
|
*/
|
|
4390
|
-
declare function once<
|
|
3865
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3866
|
+
/**
|
|
3867
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3868
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3869
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3870
|
+
*
|
|
3871
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3872
|
+
*/
|
|
3873
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
4391
3874
|
/**
|
|
4392
3875
|
* Type guard to check if a value is a once marker.
|
|
4393
3876
|
*
|
|
@@ -4404,5 +3887,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
4404
3887
|
*/
|
|
4405
3888
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
4406
3889
|
|
|
4407
|
-
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,
|
|
4408
|
-
export type { Act,
|
|
3890
|
+
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3891
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, FromRefMarker, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, LegacyInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, LegacyRootState as RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|