@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.ts
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
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
|
-
function _mergeNamespaces(n, m) {
|
|
17
|
-
m.forEach(function (e) {
|
|
18
|
-
e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
|
|
19
|
-
if (k !== 'default' && !(k in n)) {
|
|
20
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return e[k]; }
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
return Object.freeze(n);
|
|
29
|
-
}
|
|
30
18
|
|
|
31
19
|
/**
|
|
32
20
|
* @fileoverview Internal Three.js re-exports - DEFAULT ENTRY
|
|
@@ -46,16 +34,9 @@ function _mergeNamespaces(n, m) {
|
|
|
46
34
|
declare const R3F_BUILD_LEGACY = true;
|
|
47
35
|
declare const R3F_BUILD_WEBGPU = true;
|
|
48
36
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
53
|
-
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
54
|
-
RenderTargetCompat: RenderTarget,
|
|
55
|
-
WebGLRenderTarget: WebGLRenderTarget,
|
|
56
|
-
WebGLRenderer: WebGLRenderer,
|
|
57
|
-
WebGLRendererParameters: WebGLRendererParameters
|
|
58
|
-
}, [three_webgpu]);
|
|
37
|
+
/** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
|
|
38
|
+
declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
|
|
39
|
+
|
|
59
40
|
|
|
60
41
|
//* Utility Types ==============================
|
|
61
42
|
|
|
@@ -292,228 +273,33 @@ interface VisibilityEntry {
|
|
|
292
273
|
}
|
|
293
274
|
|
|
294
275
|
//* Scheduler Types (useFrame) ==============================
|
|
276
|
+
//
|
|
277
|
+
// The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
|
|
278
|
+
// This file re-exports them and layers r3f's RootState-aware frame state on top,
|
|
279
|
+
// so existing `#types` imports across the codebase keep resolving unchanged.
|
|
295
280
|
|
|
296
281
|
|
|
297
282
|
|
|
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 --------------------------------
|
|
283
|
+
// Frame State (r3f-specific) --------------------------------
|
|
336
284
|
|
|
337
285
|
/**
|
|
338
|
-
*
|
|
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
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* State passed to useFrame callbacks (extends RootState with timing)
|
|
286
|
+
* State passed to useFrame callbacks (extends RootState with timing).
|
|
353
287
|
*/
|
|
354
288
|
interface FrameNextState extends RootState, FrameTimingState {}
|
|
355
289
|
|
|
356
290
|
/** Alias for FrameNextState */
|
|
357
291
|
type FrameState = FrameNextState
|
|
358
292
|
|
|
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 --------------------------------
|
|
293
|
+
// Callback Types (r3f-specific) --------------------------------
|
|
372
294
|
|
|
373
295
|
/**
|
|
374
|
-
* Callback function for useFrame
|
|
296
|
+
* Callback function for useFrame. Receives the full r3f RootState plus timing.
|
|
375
297
|
*/
|
|
376
|
-
type FrameNextCallback =
|
|
298
|
+
type FrameNextCallback = FrameCallback$1<RootState>
|
|
377
299
|
|
|
378
300
|
/** Alias for FrameNextCallback */
|
|
379
301
|
type FrameCallback = FrameNextCallback
|
|
380
302
|
|
|
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
303
|
//* Buffer Types (useBuffers) ========================================
|
|
518
304
|
|
|
519
305
|
/**
|
|
@@ -538,6 +324,7 @@ type BufferLike =
|
|
|
538
324
|
| Uint16Array
|
|
539
325
|
| Int16Array
|
|
540
326
|
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
327
|
+
| THREE$1.InterleavedBufferAttribute
|
|
541
328
|
| Node // TSL buffer nodes (instancedArray, storage)
|
|
542
329
|
|
|
543
330
|
/** Flat record of buffer-like values (no nested scopes) */
|
|
@@ -549,6 +336,25 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
549
336
|
*/
|
|
550
337
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
551
338
|
|
|
339
|
+
//* Node Types (useNodes) ========================================
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
343
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
344
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
345
|
+
* and the shape the store holds are one type by construction.
|
|
346
|
+
*/
|
|
347
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
348
|
+
|
|
349
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
350
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
354
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
355
|
+
*/
|
|
356
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
357
|
+
|
|
552
358
|
//* Storage Types (useGPUStorage) ========================================
|
|
553
359
|
|
|
554
360
|
/**
|
|
@@ -563,7 +369,9 @@ type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
|
563
369
|
* ```
|
|
564
370
|
*/
|
|
565
371
|
type StorageLike =
|
|
566
|
-
| StorageTexture // GPU storage texture
|
|
372
|
+
| StorageTexture // 2D GPU storage texture
|
|
373
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
374
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
567
375
|
| Data3DTexture // 3D texture (can be used as storage)
|
|
568
376
|
| Node // TSL storage texture nodes (storageTexture)
|
|
569
377
|
|
|
@@ -682,14 +490,31 @@ interface InternalState {
|
|
|
682
490
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
683
491
|
container?: THREE$1.Object3D
|
|
684
492
|
/**
|
|
685
|
-
* CanvasTarget
|
|
686
|
-
*
|
|
493
|
+
* The CanvasTarget this root sizes and renders through.
|
|
494
|
+
*
|
|
495
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
496
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
497
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
498
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
499
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
687
500
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
688
501
|
*/
|
|
689
502
|
canvasTarget?: CanvasTarget
|
|
503
|
+
/**
|
|
504
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
505
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
506
|
+
*
|
|
507
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
508
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
509
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
510
|
+
* invalidate some other canvas's descriptor instead.
|
|
511
|
+
*
|
|
512
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
513
|
+
*/
|
|
514
|
+
canvasTargetSizeDirty?: boolean
|
|
690
515
|
/**
|
|
691
516
|
* Whether multi-canvas rendering is active.
|
|
692
|
-
* True when any canvas uses `
|
|
517
|
+
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
693
518
|
* When true, setCanvasTarget is called before each render.
|
|
694
519
|
*/
|
|
695
520
|
isMultiCanvas?: boolean
|
|
@@ -787,8 +612,8 @@ interface RootState {
|
|
|
787
612
|
setSize: (width?: number, height?: number, top?: number, left?: number) => void
|
|
788
613
|
/** Shortcut to manual setting the pixel ratio */
|
|
789
614
|
setDpr: (dpr: Dpr) => void
|
|
790
|
-
/** Shortcut to setting frameloop flags */
|
|
791
|
-
setFrameloop: (frameloop
|
|
615
|
+
/** Shortcut to setting frameloop flags. No args resets to 'always'. */
|
|
616
|
+
setFrameloop: (frameloop?: Frameloop) => void
|
|
792
617
|
/** Set error state to propagate to error boundary */
|
|
793
618
|
setError: (error: Error | null) => void
|
|
794
619
|
/** Current error state (null when no error) */
|
|
@@ -796,7 +621,7 @@ interface RootState {
|
|
|
796
621
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
797
622
|
uniforms: UniformStore
|
|
798
623
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
799
|
-
nodes:
|
|
624
|
+
nodes: NodeStore
|
|
800
625
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
801
626
|
buffers: BufferStore
|
|
802
627
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -806,9 +631,9 @@ interface RootState {
|
|
|
806
631
|
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
807
632
|
_textureRefs: Map<string, number>
|
|
808
633
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
809
|
-
renderPipeline:
|
|
634
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
810
635
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
811
|
-
passes:
|
|
636
|
+
passes: PassRecord
|
|
812
637
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
813
638
|
_hmrVersion: number
|
|
814
639
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -896,12 +721,19 @@ type DefaultRendererProps = {
|
|
|
896
721
|
*/
|
|
897
722
|
interface CanvasSchedulerConfig {
|
|
898
723
|
/**
|
|
899
|
-
*
|
|
900
|
-
|
|
724
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
725
|
+
*/
|
|
726
|
+
before?: string | string[]
|
|
727
|
+
/**
|
|
728
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
729
|
+
*/
|
|
730
|
+
after?: string | string[]
|
|
731
|
+
/**
|
|
732
|
+
* Numeric root order. Lower values run first.
|
|
901
733
|
*/
|
|
902
|
-
|
|
734
|
+
order?: number
|
|
903
735
|
/**
|
|
904
|
-
* Limit this
|
|
736
|
+
* Limit this Canvas's default render job (frames per second).
|
|
905
737
|
*/
|
|
906
738
|
fps?: number
|
|
907
739
|
}
|
|
@@ -988,14 +820,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
988
820
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
989
821
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
990
822
|
dpr?: Dpr
|
|
991
|
-
/**
|
|
992
|
-
|
|
823
|
+
/**
|
|
824
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
825
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
826
|
+
*/
|
|
827
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
993
828
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
994
829
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
995
830
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
996
831
|
camera?: CameraProps
|
|
997
832
|
/** An R3F event manager to manage elements' pointer events */
|
|
998
|
-
events?: (store: RootStore) => EventManager<
|
|
833
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
999
834
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
1000
835
|
onCreated?: (state: RootState) => void
|
|
1001
836
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -1099,8 +934,6 @@ interface Instance<O = any> {
|
|
|
1099
934
|
attach?: AttachType<O>
|
|
1100
935
|
previousAttach?: any
|
|
1101
936
|
isHidden: boolean
|
|
1102
|
-
/** Deferred ref props to apply in commitMount */
|
|
1103
|
-
deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
|
|
1104
937
|
/** Set of props that have been applied via once() */
|
|
1105
938
|
appliedOnce?: Set<string>
|
|
1106
939
|
}
|
|
@@ -1226,7 +1059,7 @@ interface CanvasProps
|
|
|
1226
1059
|
*/
|
|
1227
1060
|
resize?: Options
|
|
1228
1061
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1229
|
-
eventSource?:
|
|
1062
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1230
1063
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1231
1064
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1232
1065
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1334,70 +1167,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1334
1167
|
|
|
1335
1168
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1336
1169
|
|
|
1337
|
-
//* Global Types ==============================
|
|
1170
|
+
//* Global TSL Types ==============================
|
|
1338
1171
|
|
|
1339
1172
|
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
1173
|
/**
|
|
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
|
-
* ```
|
|
1174
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1175
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1363
1176
|
*/
|
|
1364
|
-
type
|
|
1177
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1178
|
+
readonly shaderNode: unknown
|
|
1179
|
+
readonly id: number
|
|
1180
|
+
}
|
|
1365
1181
|
|
|
1366
|
-
/**
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
*/
|
|
1375
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1182
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1183
|
+
type LegacyTSLNodeLike = {
|
|
1184
|
+
label?: ((label: string) => unknown) | string
|
|
1185
|
+
setName?: (name: string) => unknown
|
|
1186
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1187
|
+
|
|
1188
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1189
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1376
1190
|
|
|
1377
1191
|
/**
|
|
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
|
-
* ```
|
|
1192
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1193
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1194
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1195
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1399
1196
|
*/
|
|
1400
|
-
type
|
|
1197
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1198
|
+
? TNodeType
|
|
1199
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1200
|
+
? TNodeType
|
|
1201
|
+
: T extends number
|
|
1202
|
+
? 'float'
|
|
1203
|
+
: T extends boolean
|
|
1204
|
+
? 'bool'
|
|
1205
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1206
|
+
? 'color'
|
|
1207
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1208
|
+
? 'vec4'
|
|
1209
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1210
|
+
? 'vec3'
|
|
1211
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1212
|
+
? 'vec2'
|
|
1213
|
+
: T extends three_webgpu.Matrix4
|
|
1214
|
+
? 'mat4'
|
|
1215
|
+
: T extends three_webgpu.Matrix3
|
|
1216
|
+
? 'mat3'
|
|
1217
|
+
: T extends three_webgpu.Matrix2
|
|
1218
|
+
? 'mat2'
|
|
1219
|
+
: unknown
|
|
1220
|
+
|
|
1221
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1222
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1223
|
+
? TValue
|
|
1224
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1225
|
+
? TValue
|
|
1226
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1227
|
+
? three_webgpu.Color
|
|
1228
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1229
|
+
? three_webgpu.Vector4
|
|
1230
|
+
: T extends { x: number; y: number; z: number }
|
|
1231
|
+
? three_webgpu.Vector3
|
|
1232
|
+
: T extends { x: number; y: number }
|
|
1233
|
+
? three_webgpu.Vector2
|
|
1234
|
+
: T extends number
|
|
1235
|
+
? number
|
|
1236
|
+
: T extends boolean
|
|
1237
|
+
? boolean
|
|
1238
|
+
: T
|
|
1239
|
+
|
|
1240
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1241
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1242
|
+
|
|
1243
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1244
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1245
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1249
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1401
1250
|
|
|
1402
1251
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1403
1252
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1422,7 +1271,7 @@ declare global {
|
|
|
1422
1271
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1423
1272
|
* Supports:
|
|
1424
1273
|
* - Primitives: number, string (color), boolean
|
|
1425
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1274
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1426
1275
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1427
1276
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1428
1277
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1435,227 +1284,124 @@ declare global {
|
|
|
1435
1284
|
| three_webgpu.Vector2
|
|
1436
1285
|
| three_webgpu.Vector3
|
|
1437
1286
|
| three_webgpu.Vector4
|
|
1287
|
+
| three_webgpu.Matrix2
|
|
1438
1288
|
| three_webgpu.Matrix3
|
|
1439
1289
|
| three_webgpu.Matrix4
|
|
1440
|
-
|
|
|
1441
|
-
|
|
|
1442
|
-
| { x: number; y
|
|
1290
|
+
| { x: number; y: number }
|
|
1291
|
+
| { x: number; y: number; z: number }
|
|
1292
|
+
| { x: number; y: number; z: number; w: number }
|
|
1443
1293
|
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1444
|
-
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1294
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1445
1295
|
| UniformNode
|
|
1446
1296
|
|
|
1447
1297
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1448
1298
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1449
1299
|
}
|
|
1450
1300
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
declare module 'three/tsl' {
|
|
1301
|
+
declare global {
|
|
1454
1302
|
/**
|
|
1455
|
-
*
|
|
1456
|
-
*
|
|
1303
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1304
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1305
|
+
* is r185, so the new name is the only one.
|
|
1457
1306
|
*/
|
|
1458
|
-
|
|
1459
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1460
|
-
): ShaderCallable<R>
|
|
1307
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1461
1308
|
|
|
1462
1309
|
/**
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1310
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1311
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1312
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1465
1313
|
*/
|
|
1466
|
-
|
|
1467
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1468
|
-
): ShaderCallable<R>
|
|
1314
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1469
1315
|
|
|
1470
1316
|
/**
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1317
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1318
|
+
*
|
|
1319
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1320
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1321
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1322
|
+
* {@link RenderPipelineCallbackState}.
|
|
1323
|
+
*
|
|
1324
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1325
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1326
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1327
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1328
|
+
*
|
|
1329
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1330
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1331
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1332
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1473
1333
|
*/
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1334
|
+
interface PassRecord {
|
|
1335
|
+
scenePass?: ScenePassNode
|
|
1336
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1337
|
+
}
|
|
1478
1338
|
|
|
1479
1339
|
/**
|
|
1480
|
-
*
|
|
1340
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1341
|
+
*
|
|
1342
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1343
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1344
|
+
*
|
|
1345
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1346
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1481
1347
|
*/
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
/**
|
|
1489
|
-
* RenderPipeline Types for useRenderPipeline hook (WebGPU only)
|
|
1490
|
-
*/
|
|
1491
|
-
|
|
1492
|
-
|
|
1348
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1349
|
+
renderPipeline: ThreeRenderPipeline
|
|
1350
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1351
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1352
|
+
isLegacy: false
|
|
1353
|
+
}
|
|
1493
1354
|
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1355
|
+
/**
|
|
1356
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1357
|
+
*
|
|
1358
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1359
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1360
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1361
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1362
|
+
*/
|
|
1363
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1497
1364
|
|
|
1498
1365
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1499
|
-
type RenderPipelineSetupCallback = (state:
|
|
1366
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1500
1367
|
|
|
1501
1368
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1502
|
-
type RenderPipelineMainCallback = (state:
|
|
1369
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1503
1370
|
|
|
1504
|
-
/**
|
|
1505
|
-
interface
|
|
1371
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1372
|
+
interface UseRenderPipelineActions {
|
|
1506
1373
|
/** Current passes from state */
|
|
1507
1374
|
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
1375
|
/** Clear all passes from state */
|
|
1511
1376
|
clearPasses: () => void
|
|
1512
1377
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1513
1378
|
reset: () => void
|
|
1514
1379
|
/** Re-run setup/main callbacks with current closure values */
|
|
1515
1380
|
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
1381
|
}
|
|
1585
1382
|
|
|
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
|
-
}
|
|
1605
|
-
|
|
1606
|
-
// Root Entry --------------------------------
|
|
1607
|
-
|
|
1608
1383
|
/**
|
|
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
|
|
1384
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1385
|
+
*
|
|
1386
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1387
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1388
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1657
1389
|
*/
|
|
1658
|
-
type
|
|
1390
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1391
|
+
(
|
|
1392
|
+
| {
|
|
1393
|
+
/** True when RenderPipeline is configured and ready */
|
|
1394
|
+
isReady: true
|
|
1395
|
+
/** RenderPipeline instance */
|
|
1396
|
+
renderPipeline: ThreeRenderPipeline
|
|
1397
|
+
}
|
|
1398
|
+
| {
|
|
1399
|
+
/** False until the pipeline has been created */
|
|
1400
|
+
isReady: false
|
|
1401
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1402
|
+
renderPipeline: null
|
|
1403
|
+
}
|
|
1404
|
+
)
|
|
1659
1405
|
}
|
|
1660
1406
|
|
|
1661
1407
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1734,10 +1480,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1734
1480
|
|
|
1735
1481
|
/**
|
|
1736
1482
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1737
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1483
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1484
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1738
1485
|
*/
|
|
1739
1486
|
type NodeProps<P> = {
|
|
1740
|
-
[K in keyof P as P[K] extends
|
|
1487
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1741
1488
|
}
|
|
1742
1489
|
|
|
1743
1490
|
interface ReactProps<P> {
|
|
@@ -1758,11 +1505,30 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1758
1505
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1759
1506
|
}
|
|
1760
1507
|
|
|
1508
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1509
|
+
type Object3DMethod = NonNullable<
|
|
1510
|
+
{
|
|
1511
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1512
|
+
}[keyof Object3D]
|
|
1513
|
+
>
|
|
1514
|
+
|
|
1761
1515
|
type ThreeExports = typeof import('three') & typeof import('three/webgpu')
|
|
1762
1516
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1763
1517
|
|
|
1764
1518
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1765
|
-
|
|
1519
|
+
/**
|
|
1520
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1521
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1522
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1523
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1524
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1525
|
+
*/
|
|
1526
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | 'onUpdate' | Object3DMethod> & {
|
|
1527
|
+
object: object
|
|
1528
|
+
ref?: React.Ref<any>
|
|
1529
|
+
onUpdate?: (self: any) => void
|
|
1530
|
+
[prop: string]: unknown
|
|
1531
|
+
}
|
|
1766
1532
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1767
1533
|
threeAudio: ThreeElementsImpl['audio']
|
|
1768
1534
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1803,6 +1569,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1803
1569
|
type three_d_Matrix4 = Matrix4;
|
|
1804
1570
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1805
1571
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1572
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1806
1573
|
type three_d_Quaternion = Quaternion;
|
|
1807
1574
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1808
1575
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1817,7 +1584,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1817
1584
|
type three_d_Vector4 = Vector4;
|
|
1818
1585
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1819
1586
|
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 };
|
|
1587
|
+
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
1588
|
}
|
|
1822
1589
|
|
|
1823
1590
|
/**
|
|
@@ -1827,7 +1594,7 @@ declare namespace three_d {
|
|
|
1827
1594
|
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
1828
1595
|
*
|
|
1829
1596
|
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
1830
|
-
* Secondary canvas: Has `
|
|
1597
|
+
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
1831
1598
|
*/
|
|
1832
1599
|
|
|
1833
1600
|
interface PrimaryCanvasEntry {
|
|
@@ -1895,12 +1662,23 @@ type EnvironmentLoaderProps = {
|
|
|
1895
1662
|
* const texture = useEnvironment({ preset: 'sunset' })
|
|
1896
1663
|
* ```
|
|
1897
1664
|
*/
|
|
1898
|
-
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture
|
|
1665
|
+
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
|
|
1899
1666
|
declare namespace useEnvironment {
|
|
1900
1667
|
var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
|
|
1901
1668
|
var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
|
|
1902
1669
|
}
|
|
1903
|
-
|
|
1670
|
+
/**
|
|
1671
|
+
* Options accepted by `useEnvironment.preload`.
|
|
1672
|
+
*
|
|
1673
|
+
* `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
|
|
1674
|
+
* applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
|
|
1675
|
+
* advertise an option this function silently ignores.
|
|
1676
|
+
*
|
|
1677
|
+
* This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
|
|
1678
|
+
* `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
|
|
1679
|
+
* type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
|
|
1680
|
+
*/
|
|
1681
|
+
type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
|
|
1904
1682
|
type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
|
|
1905
1683
|
|
|
1906
1684
|
/**
|
|
@@ -1944,9 +1722,9 @@ type EnvironmentProps = {
|
|
|
1944
1722
|
blur?: number;
|
|
1945
1723
|
backgroundBlurriness?: number;
|
|
1946
1724
|
backgroundIntensity?: number;
|
|
1947
|
-
backgroundRotation?: Euler
|
|
1725
|
+
backgroundRotation?: Euler;
|
|
1948
1726
|
environmentIntensity?: number;
|
|
1949
|
-
environmentRotation?: Euler
|
|
1727
|
+
environmentRotation?: Euler;
|
|
1950
1728
|
map?: Texture$1;
|
|
1951
1729
|
preset?: PresetsType;
|
|
1952
1730
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -2030,7 +1808,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
2030
1808
|
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
1809
|
declare module '@react-three/fiber' {
|
|
2032
1810
|
interface ThreeElements {
|
|
2033
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1811
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
2034
1812
|
}
|
|
2035
1813
|
}
|
|
2036
1814
|
/**
|
|
@@ -2130,6 +1908,24 @@ declare module '@react-three/fiber' {
|
|
|
2130
1908
|
*/
|
|
2131
1909
|
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
2132
1910
|
|
|
1911
|
+
/**
|
|
1912
|
+
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
1913
|
+
*
|
|
1914
|
+
* When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
|
|
1915
|
+
* instance. Removing the old object from the interaction state and registering the new one from
|
|
1916
|
+
* scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
|
|
1917
|
+
* the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
|
|
1918
|
+
* is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
|
|
1919
|
+
* swap the user never asked to see (#3744).
|
|
1920
|
+
*
|
|
1921
|
+
* Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
|
|
1922
|
+
* left alone — releasing and re-acquiring it is precisely the glitch being avoided.
|
|
1923
|
+
*
|
|
1924
|
+
* Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
|
|
1925
|
+
* the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
|
|
1926
|
+
* cannot outlive the object it described.
|
|
1927
|
+
*/
|
|
1928
|
+
declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
|
|
2133
1929
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
2134
1930
|
declare function createEvents(store: RootStore): {
|
|
2135
1931
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
@@ -2137,7 +1933,7 @@ declare function createEvents(store: RootStore): {
|
|
|
2137
1933
|
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
2138
1934
|
};
|
|
2139
1935
|
/** Default R3F event manager for web */
|
|
2140
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1936
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
2141
1937
|
|
|
2142
1938
|
/**
|
|
2143
1939
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -2150,389 +1946,27 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
|
|
|
2150
1946
|
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
2151
1947
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
2152
1948
|
*/
|
|
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>;
|
|
1949
|
+
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
1950
|
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;
|
|
1951
|
+
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;
|
|
1952
|
+
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
|
|
2157
1953
|
var loader: typeof getLoader;
|
|
2158
1954
|
}
|
|
2159
1955
|
|
|
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
1956
|
/**
|
|
2524
1957
|
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
2525
1958
|
*
|
|
2526
|
-
*
|
|
2527
|
-
* - Inside Canvas: Full RootState (
|
|
2528
|
-
* - Outside Canvas
|
|
2529
|
-
*
|
|
1959
|
+
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1960
|
+
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1961
|
+
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1962
|
+
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1963
|
+
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
2530
1964
|
*
|
|
2531
1965
|
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
2532
1966
|
*
|
|
2533
1967
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
2534
1968
|
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
2535
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
1969
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
2536
1970
|
*
|
|
2537
1971
|
* @example
|
|
2538
1972
|
* // Simple priority (backwards compat)
|
|
@@ -2543,16 +1977,16 @@ declare const getScheduler: () => Scheduler;
|
|
|
2543
1977
|
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
2544
1978
|
*
|
|
2545
1979
|
* @example
|
|
2546
|
-
* // Outside Canvas - waits for Canvas
|
|
1980
|
+
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
2547
1981
|
* function UI() {
|
|
2548
1982
|
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
2549
1983
|
* return <button>...</button>;
|
|
2550
1984
|
* }
|
|
2551
1985
|
*
|
|
2552
1986
|
* @example
|
|
2553
|
-
* //
|
|
2554
|
-
* getScheduler
|
|
2555
|
-
*
|
|
1987
|
+
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
1988
|
+
* import { getScheduler } from '@pmndrs/scheduler'
|
|
1989
|
+
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
2556
1990
|
*
|
|
2557
1991
|
* @example
|
|
2558
1992
|
* // Scheduler-only access (no callback)
|
|
@@ -2828,7 +2262,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2828
2262
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2829
2263
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2830
2264
|
*
|
|
2831
|
-
*
|
|
2265
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2266
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2267
|
+
*
|
|
2268
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2832
2269
|
* @param frames - Number of frames to request (default: 1)
|
|
2833
2270
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2834
2271
|
*
|
|
@@ -2839,14 +2276,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2839
2276
|
* Advances the frameloop and runs render effects.
|
|
2840
2277
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2841
2278
|
*
|
|
2279
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2280
|
+
* registered root is stepped for backwards compatibility.
|
|
2281
|
+
*
|
|
2842
2282
|
* @param timestamp - The timestamp to use for this frame
|
|
2843
2283
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2844
|
-
* @param state -
|
|
2845
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2284
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2846
2285
|
*
|
|
2847
2286
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2848
2287
|
*/
|
|
2849
|
-
declare function advance(timestamp: number): void;
|
|
2288
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2850
2289
|
|
|
2851
2290
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2852
2291
|
declare function ReactReconciler<
|
|
@@ -3891,6 +3330,7 @@ declare namespace ReactReconciler {
|
|
|
3891
3330
|
|
|
3892
3331
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3893
3332
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3333
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3894
3334
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3895
3335
|
|
|
3896
3336
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3917,11 +3357,6 @@ declare function flushSync<R>(fn: () => R): R;
|
|
|
3917
3357
|
declare const context: React$1.Context<RootStore>;
|
|
3918
3358
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3919
3359
|
|
|
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
3360
|
/**
|
|
3926
3361
|
* An SSR-friendly useLayoutEffect.
|
|
3927
3362
|
*
|
|
@@ -4339,29 +3774,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
4339
3774
|
* Used to identify values that should be resolved from refs after mount.
|
|
4340
3775
|
*/
|
|
4341
3776
|
declare const FROM_REF: unique symbol;
|
|
3777
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3778
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3779
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3780
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3781
|
+
transform?: (value: T) => R;
|
|
3782
|
+
}
|
|
4342
3783
|
/**
|
|
4343
3784
|
* Defers prop application until the referenced object is available.
|
|
4344
3785
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
4345
3786
|
*
|
|
3787
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3788
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3789
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3790
|
+
* what gets assigned.
|
|
3791
|
+
*
|
|
4346
3792
|
* @param ref - React ref object to resolve at mount time
|
|
4347
|
-
* @
|
|
3793
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3794
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
4348
3795
|
*
|
|
4349
3796
|
* @example
|
|
4350
3797
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
4351
3798
|
*
|
|
4352
3799
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
4353
3800
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3801
|
+
*
|
|
3802
|
+
* @example
|
|
3803
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3804
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
4354
3805
|
*/
|
|
4355
3806
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3807
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
4356
3808
|
/**
|
|
4357
3809
|
* Type guard to check if a value is a fromRef marker.
|
|
4358
3810
|
*
|
|
4359
3811
|
* @param value - Value to check
|
|
4360
3812
|
* @returns True if value is a fromRef marker
|
|
4361
3813
|
*/
|
|
4362
|
-
declare function isFromRef(value: unknown): value is
|
|
4363
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
4364
|
-
};
|
|
3814
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
4365
3815
|
|
|
4366
3816
|
/**
|
|
4367
3817
|
* Symbol marker for mount-only method calls.
|
|
@@ -4388,7 +3838,15 @@ declare const ONCE: unique symbol;
|
|
|
4388
3838
|
* // No arguments
|
|
4389
3839
|
* <geometry center={once()} />
|
|
4390
3840
|
*/
|
|
4391
|
-
declare function once<
|
|
3841
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3842
|
+
/**
|
|
3843
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3844
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3845
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3846
|
+
*
|
|
3847
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3848
|
+
*/
|
|
3849
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
4392
3850
|
/**
|
|
4393
3851
|
* Type guard to check if a value is a once marker.
|
|
4394
3852
|
*
|
|
@@ -4405,5 +3863,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
4405
3863
|
*/
|
|
4406
3864
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
4407
3865
|
|
|
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,
|
|
3866
|
+
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 };
|
|
3867
|
+
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 };
|