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