@react-three/fiber 10.0.0-canary.aecbafb → 10.0.0-canary.af75fd4
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 +2794 -3491
- package/dist/index.d.cts +358 -824
- package/dist/index.d.mts +358 -824
- package/dist/index.d.ts +358 -824
- package/dist/index.mjs +2698 -3394
- package/dist/legacy.cjs +2614 -3315
- package/dist/legacy.d.cts +357 -826
- package/dist/legacy.d.mts +357 -826
- package/dist/legacy.d.ts +357 -826
- package/dist/legacy.mjs +2726 -3426
- package/dist/webgpu/index.cjs +3139 -4033
- package/dist/webgpu/index.d.cts +406 -882
- package/dist/webgpu/index.d.mts +406 -882
- package/dist/webgpu/index.d.ts +406 -882
- package/dist/webgpu/index.mjs +3000 -3893
- package/package.json +6 -5
- package/readme.md +3 -4
- package/react-reconciler/constants.d.ts +0 -7
- package/react-reconciler/constants.js +0 -1
- package/react-reconciler/index.d.ts +0 -1044
- package/react-reconciler/index.js +0 -208
package/dist/legacy.d.mts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as THREE$1 from 'three';
|
|
2
|
-
import { WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Node as Node$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera } from 'three';
|
|
2
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Node as Node$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera } from 'three';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
5
5
|
import * as three_webgpu from 'three/webgpu';
|
|
6
6
|
import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject } from 'three/webgpu';
|
|
7
7
|
import { StoreApi } from 'zustand';
|
|
8
8
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
9
|
+
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
10
|
+
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
9
11
|
import { Options } from 'react-use-measure';
|
|
10
12
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
11
|
-
import { ThreeElement as ThreeElement$1, Euler as Euler$2 } from '@react-three/fiber';
|
|
12
13
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
13
14
|
|
|
14
15
|
function _mergeNamespaces(n, m) {
|
|
@@ -37,23 +38,28 @@ function _mergeNamespaces(n, m) {
|
|
|
37
38
|
declare const R3F_BUILD_LEGACY = true;
|
|
38
39
|
declare const R3F_BUILD_WEBGPU = false;
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
type Inspector = never;
|
|
42
|
+
/** Not available on the legacy (WebGL-only) entry. */
|
|
43
|
+
declare function loadInspector(): Promise<never>;
|
|
43
44
|
declare const WebGPURenderer: {
|
|
44
45
|
new (): {};
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
declare const RenderTarget: any;
|
|
48
49
|
|
|
50
|
+
declare const CubeRenderTarget: any;
|
|
51
|
+
|
|
49
52
|
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
50
53
|
__proto__: null,
|
|
54
|
+
CubeRenderTarget: CubeRenderTarget,
|
|
55
|
+
CubeRenderTargetCompat: WebGLCubeRenderTarget,
|
|
51
56
|
Inspector: Inspector,
|
|
52
57
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
53
58
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
54
59
|
RenderTarget: RenderTarget,
|
|
55
60
|
RenderTargetCompat: WebGLRenderTarget,
|
|
56
|
-
WebGPURenderer: WebGPURenderer
|
|
61
|
+
WebGPURenderer: WebGPURenderer,
|
|
62
|
+
loadInspector: loadInspector
|
|
57
63
|
}, [THREE$1]);
|
|
58
64
|
|
|
59
65
|
//* Utility Types ==============================
|
|
@@ -291,228 +297,33 @@ interface VisibilityEntry {
|
|
|
291
297
|
}
|
|
292
298
|
|
|
293
299
|
//* Scheduler Types (useFrame) ==============================
|
|
300
|
+
//
|
|
301
|
+
// The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
|
|
302
|
+
// This file re-exports them and layers r3f's RootState-aware frame state on top,
|
|
303
|
+
// so existing `#types` imports across the codebase keep resolving unchanged.
|
|
294
304
|
|
|
295
305
|
|
|
296
306
|
|
|
297
|
-
//
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* Options for useFrame hook
|
|
301
|
-
*/
|
|
302
|
-
interface UseFrameNextOptions {
|
|
303
|
-
/** Optional stable id for the job. Auto-generated if not provided */
|
|
304
|
-
id?: string
|
|
305
|
-
/** Named phase to run in. Default: 'update' */
|
|
306
|
-
phase?: string
|
|
307
|
-
/** Run before this phase or job id */
|
|
308
|
-
before?: string | string[]
|
|
309
|
-
/** Run after this phase or job id */
|
|
310
|
-
after?: string | string[]
|
|
311
|
-
/** Priority within phase. Higher runs first. Default: 0 */
|
|
312
|
-
priority?: number
|
|
313
|
-
/** Max frames per second for this job */
|
|
314
|
-
fps?: number
|
|
315
|
-
/** If true, skip frames when behind. If false, try to catch up. Default: true */
|
|
316
|
-
drop?: boolean
|
|
317
|
-
/** Enable/disable without unregistering. Default: true */
|
|
318
|
-
enabled?: boolean
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/** Alias for UseFrameNextOptions */
|
|
322
|
-
type UseFrameOptions = UseFrameNextOptions
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Options for addPhase
|
|
326
|
-
*/
|
|
327
|
-
interface AddPhaseOptions {
|
|
328
|
-
/** Insert this phase before the specified phase */
|
|
329
|
-
before?: string
|
|
330
|
-
/** Insert this phase after the specified phase */
|
|
331
|
-
after?: string
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// Frame State --------------------------------
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Timing-only state for independent/outside mode (no RootState)
|
|
338
|
-
*/
|
|
339
|
-
interface FrameTimingState {
|
|
340
|
-
/** High-resolution timestamp from RAF (ms) */
|
|
341
|
-
time: number
|
|
342
|
-
/** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
343
|
-
delta: number
|
|
344
|
-
/** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
345
|
-
elapsed: number
|
|
346
|
-
/** Incrementing frame counter */
|
|
347
|
-
frame: number
|
|
348
|
-
}
|
|
307
|
+
// Frame State (r3f-specific) --------------------------------
|
|
349
308
|
|
|
350
309
|
/**
|
|
351
|
-
* State passed to useFrame callbacks (extends RootState with timing)
|
|
310
|
+
* State passed to useFrame callbacks (extends RootState with timing).
|
|
352
311
|
*/
|
|
353
312
|
interface FrameNextState extends RootState, FrameTimingState {}
|
|
354
313
|
|
|
355
314
|
/** Alias for FrameNextState */
|
|
356
315
|
type FrameState = FrameNextState
|
|
357
316
|
|
|
358
|
-
//
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Options for registerRoot
|
|
362
|
-
*/
|
|
363
|
-
interface RootOptions {
|
|
364
|
-
/** State provider for callbacks. Optional in independent mode. */
|
|
365
|
-
getState?: () => any
|
|
366
|
-
/** Error handler for job errors. Falls back to console.error if not provided. */
|
|
367
|
-
onError?: (error: Error) => void
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// Callback Types --------------------------------
|
|
317
|
+
// Callback Types (r3f-specific) --------------------------------
|
|
371
318
|
|
|
372
319
|
/**
|
|
373
|
-
* Callback function for useFrame
|
|
320
|
+
* Callback function for useFrame. Receives the full r3f RootState plus timing.
|
|
374
321
|
*/
|
|
375
|
-
type FrameNextCallback =
|
|
322
|
+
type FrameNextCallback = FrameCallback$1<RootState>
|
|
376
323
|
|
|
377
324
|
/** Alias for FrameNextCallback */
|
|
378
325
|
type FrameCallback = FrameNextCallback
|
|
379
326
|
|
|
380
|
-
// Controls returned from useFrame --------------------------------
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Controls object returned from useFrame hook
|
|
384
|
-
*/
|
|
385
|
-
interface FrameNextControls {
|
|
386
|
-
/** The job's unique ID */
|
|
387
|
-
id: string
|
|
388
|
-
/** Access to the global scheduler for frame loop control */
|
|
389
|
-
scheduler: SchedulerApi
|
|
390
|
-
/** Manually step this job only (bypasses FPS limiting) */
|
|
391
|
-
step(timestamp?: number): void
|
|
392
|
-
/** Manually step ALL jobs in the scheduler */
|
|
393
|
-
stepAll(timestamp?: number): void
|
|
394
|
-
/** Pause this job (set enabled=false) */
|
|
395
|
-
pause(): void
|
|
396
|
-
/** Resume this job (set enabled=true) */
|
|
397
|
-
resume(): void
|
|
398
|
-
/** Reactive paused state - automatically triggers re-render when changed */
|
|
399
|
-
isPaused: boolean
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/** Alias for FrameNextControls */
|
|
403
|
-
type FrameControls = FrameNextControls
|
|
404
|
-
|
|
405
|
-
// Scheduler Interface --------------------------------
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Public interface for the global Scheduler
|
|
409
|
-
*/
|
|
410
|
-
interface SchedulerApi {
|
|
411
|
-
//* Phase Management --------------------------------
|
|
412
|
-
|
|
413
|
-
/** Add a named phase to the scheduler */
|
|
414
|
-
addPhase(name: string, options?: AddPhaseOptions): void
|
|
415
|
-
/** Get the ordered list of phase names */
|
|
416
|
-
readonly phases: string[]
|
|
417
|
-
/** Check if a phase exists */
|
|
418
|
-
hasPhase(name: string): boolean
|
|
419
|
-
|
|
420
|
-
//* Root Management --------------------------------
|
|
421
|
-
|
|
422
|
-
/** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
|
|
423
|
-
registerRoot(id: string, options?: RootOptions): () => void
|
|
424
|
-
/** Unregister a root */
|
|
425
|
-
unregisterRoot(id: string): void
|
|
426
|
-
/** Generate a unique root ID */
|
|
427
|
-
generateRootId(): string
|
|
428
|
-
/** Get the number of registered roots */
|
|
429
|
-
getRootCount(): number
|
|
430
|
-
/** Check if any root is registered and ready */
|
|
431
|
-
readonly isReady: boolean
|
|
432
|
-
/** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
|
|
433
|
-
onRootReady(callback: () => void): () => void
|
|
434
|
-
|
|
435
|
-
//* Job Registration --------------------------------
|
|
436
|
-
|
|
437
|
-
/** Register a job with the scheduler (returns unsubscribe function) */
|
|
438
|
-
register(
|
|
439
|
-
callback: FrameNextCallback,
|
|
440
|
-
options?: {
|
|
441
|
-
id?: string
|
|
442
|
-
rootId?: string
|
|
443
|
-
phase?: string
|
|
444
|
-
before?: string | string[]
|
|
445
|
-
after?: string | string[]
|
|
446
|
-
priority?: number
|
|
447
|
-
fps?: number
|
|
448
|
-
drop?: boolean
|
|
449
|
-
enabled?: boolean
|
|
450
|
-
},
|
|
451
|
-
): () => void
|
|
452
|
-
/** Update a job's options */
|
|
453
|
-
updateJob(
|
|
454
|
-
id: string,
|
|
455
|
-
options: {
|
|
456
|
-
priority?: number
|
|
457
|
-
fps?: number
|
|
458
|
-
drop?: boolean
|
|
459
|
-
enabled?: boolean
|
|
460
|
-
phase?: string
|
|
461
|
-
before?: string | string[]
|
|
462
|
-
after?: string | string[]
|
|
463
|
-
},
|
|
464
|
-
): void
|
|
465
|
-
/** Unregister a job by ID */
|
|
466
|
-
unregister(id: string, rootId?: string): void
|
|
467
|
-
/** Get the number of registered jobs */
|
|
468
|
-
getJobCount(): number
|
|
469
|
-
/** Get all job IDs */
|
|
470
|
-
getJobIds(): string[]
|
|
471
|
-
|
|
472
|
-
//* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
|
|
473
|
-
|
|
474
|
-
/** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
|
|
475
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
|
|
476
|
-
|
|
477
|
-
//* Idle Callbacks (for legacy addTail) --------------------------------
|
|
478
|
-
|
|
479
|
-
/** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
|
|
480
|
-
onIdle(callback: (timestamp: number) => void): () => void
|
|
481
|
-
|
|
482
|
-
//* Frame Loop Control --------------------------------
|
|
483
|
-
|
|
484
|
-
/** Start the scheduler loop */
|
|
485
|
-
start(): void
|
|
486
|
-
/** Stop the scheduler loop */
|
|
487
|
-
stop(): void
|
|
488
|
-
/** Check if the scheduler is running */
|
|
489
|
-
readonly isRunning: boolean
|
|
490
|
-
/** Get/set the frameloop mode ('always', 'demand', 'never') */
|
|
491
|
-
frameloop: Frameloop
|
|
492
|
-
/** Independent mode - runs without Canvas, callbacks receive timing-only state */
|
|
493
|
-
independent: boolean
|
|
494
|
-
|
|
495
|
-
//* Manual Stepping --------------------------------
|
|
496
|
-
|
|
497
|
-
/** Manually step all jobs once (for frameloop='never' or testing) */
|
|
498
|
-
step(timestamp?: number): void
|
|
499
|
-
/** Manually step a single job by ID */
|
|
500
|
-
stepJob(id: string, timestamp?: number): void
|
|
501
|
-
/** Request frame(s) to be rendered (for frameloop='demand') */
|
|
502
|
-
invalidate(frames?: number): void
|
|
503
|
-
|
|
504
|
-
//* Per-Job Control --------------------------------
|
|
505
|
-
|
|
506
|
-
/** Check if a job is paused */
|
|
507
|
-
isJobPaused(id: string): boolean
|
|
508
|
-
/** Pause a job */
|
|
509
|
-
pauseJob(id: string): void
|
|
510
|
-
/** Resume a job */
|
|
511
|
-
resumeJob(id: string): void
|
|
512
|
-
/** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
|
|
513
|
-
subscribeJobState(id: string, listener: () => void): () => void
|
|
514
|
-
}
|
|
515
|
-
|
|
516
327
|
//* Buffer Types (useBuffers) ========================================
|
|
517
328
|
|
|
518
329
|
/**
|
|
@@ -548,6 +359,33 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
548
359
|
*/
|
|
549
360
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
550
361
|
|
|
362
|
+
//* Node Types (useNodes) ========================================
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Structural shape of a TSL node as stored on `state.nodes`.
|
|
366
|
+
*
|
|
367
|
+
* Deliberately minimal rather than three's nominal `Node`: in @types/three several node classes
|
|
368
|
+
* TSL hands back (OperatorNode, ConstNode, ...) do not extend `Node` cleanly, so a `Node` bound
|
|
369
|
+
* would reject values `useNodes` creators legitimately return. This is the same shape
|
|
370
|
+
* `useNodes` already constrains creators to (`TSLNodeLike`).
|
|
371
|
+
*/
|
|
372
|
+
interface NodeLike {
|
|
373
|
+
uuid?: string
|
|
374
|
+
nodeType?: string | null
|
|
375
|
+
/** label method for chaining - sets the node's label and returns self */
|
|
376
|
+
label?: ((label: string) => NodeLike) | string
|
|
377
|
+
setName?: (name: string) => this
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
381
|
+
type NodeRecord = Record<string, NodeLike>
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
385
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
386
|
+
*/
|
|
387
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
388
|
+
|
|
551
389
|
//* Storage Types (useGPUStorage) ========================================
|
|
552
390
|
|
|
553
391
|
/**
|
|
@@ -681,14 +519,31 @@ interface InternalState {
|
|
|
681
519
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
682
520
|
container?: THREE$1.Object3D
|
|
683
521
|
/**
|
|
684
|
-
* CanvasTarget
|
|
685
|
-
*
|
|
522
|
+
* The CanvasTarget this root sizes and renders through.
|
|
523
|
+
*
|
|
524
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
525
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
526
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
527
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
528
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
686
529
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
687
530
|
*/
|
|
688
531
|
canvasTarget?: CanvasTarget
|
|
532
|
+
/**
|
|
533
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
534
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
535
|
+
*
|
|
536
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
537
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
538
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
539
|
+
* invalidate some other canvas's descriptor instead.
|
|
540
|
+
*
|
|
541
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
542
|
+
*/
|
|
543
|
+
canvasTargetSizeDirty?: boolean
|
|
689
544
|
/**
|
|
690
545
|
* Whether multi-canvas rendering is active.
|
|
691
|
-
* True when any canvas uses `
|
|
546
|
+
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
692
547
|
* When true, setCanvasTarget is called before each render.
|
|
693
548
|
*/
|
|
694
549
|
isMultiCanvas?: boolean
|
|
@@ -786,8 +641,8 @@ interface RootState {
|
|
|
786
641
|
setSize: (width?: number, height?: number, top?: number, left?: number) => void
|
|
787
642
|
/** Shortcut to manual setting the pixel ratio */
|
|
788
643
|
setDpr: (dpr: Dpr) => void
|
|
789
|
-
/** Shortcut to setting frameloop flags */
|
|
790
|
-
setFrameloop: (frameloop
|
|
644
|
+
/** Shortcut to setting frameloop flags. No args resets to 'always'. */
|
|
645
|
+
setFrameloop: (frameloop?: Frameloop) => void
|
|
791
646
|
/** Set error state to propagate to error boundary */
|
|
792
647
|
setError: (error: Error | null) => void
|
|
793
648
|
/** Current error state (null when no error) */
|
|
@@ -795,17 +650,19 @@ interface RootState {
|
|
|
795
650
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
796
651
|
uniforms: UniformStore
|
|
797
652
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
798
|
-
nodes:
|
|
653
|
+
nodes: NodeStore
|
|
799
654
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
800
655
|
buffers: BufferStore
|
|
801
656
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
802
657
|
gpuStorage: StorageStore
|
|
803
|
-
/** Global
|
|
804
|
-
textures: Map<string,
|
|
658
|
+
/** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
|
|
659
|
+
textures: Map<string, THREE$1.Texture>
|
|
660
|
+
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
661
|
+
_textureRefs: Map<string, number>
|
|
805
662
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
806
|
-
renderPipeline:
|
|
663
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
807
664
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
808
|
-
passes:
|
|
665
|
+
passes: PassRecord
|
|
809
666
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
810
667
|
_hmrVersion: number
|
|
811
668
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -854,6 +711,20 @@ interface Renderer {
|
|
|
854
711
|
render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
|
|
855
712
|
}
|
|
856
713
|
|
|
714
|
+
//* Color Management Config ==============================
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Color management configuration shared by both WebGL and WebGPU renderers.
|
|
718
|
+
*/
|
|
719
|
+
interface ColorManagementConfig {
|
|
720
|
+
/**
|
|
721
|
+
* Color space assigned to 8-bit input textures (color maps).
|
|
722
|
+
* Defaults to sRGB. Most textures are authored in sRGB.
|
|
723
|
+
* @default THREE.SRGBColorSpace
|
|
724
|
+
*/
|
|
725
|
+
textureColorSpace?: THREE$1.ColorSpace
|
|
726
|
+
}
|
|
727
|
+
|
|
857
728
|
//* WebGL Renderer Props ==============================
|
|
858
729
|
|
|
859
730
|
type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
|
|
@@ -864,7 +735,7 @@ type GLProps =
|
|
|
864
735
|
| Renderer
|
|
865
736
|
| ((defaultProps: DefaultGLProps) => Renderer)
|
|
866
737
|
| ((defaultProps: DefaultGLProps) => Promise<Renderer>)
|
|
867
|
-
| Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
|
|
738
|
+
| (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
|
|
868
739
|
|
|
869
740
|
//* WebGPU Renderer Props ==============================
|
|
870
741
|
|
|
@@ -879,20 +750,27 @@ type DefaultRendererProps = {
|
|
|
879
750
|
*/
|
|
880
751
|
interface CanvasSchedulerConfig {
|
|
881
752
|
/**
|
|
882
|
-
*
|
|
883
|
-
|
|
753
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
754
|
+
*/
|
|
755
|
+
before?: string | string[]
|
|
756
|
+
/**
|
|
757
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
758
|
+
*/
|
|
759
|
+
after?: string | string[]
|
|
760
|
+
/**
|
|
761
|
+
* Numeric root order. Lower values run first.
|
|
884
762
|
*/
|
|
885
|
-
|
|
763
|
+
order?: number
|
|
886
764
|
/**
|
|
887
|
-
* Limit this
|
|
765
|
+
* Limit this Canvas's default render job (frames per second).
|
|
888
766
|
*/
|
|
889
767
|
fps?: number
|
|
890
768
|
}
|
|
891
769
|
|
|
892
770
|
/**
|
|
893
|
-
* Extended renderer configuration for multi-canvas support.
|
|
771
|
+
* Extended renderer configuration for multi-canvas support and color management.
|
|
894
772
|
*/
|
|
895
|
-
interface RendererConfigExtended {
|
|
773
|
+
interface RendererConfigExtended extends ColorManagementConfig {
|
|
896
774
|
/** Share renderer from another canvas (WebGPU only) */
|
|
897
775
|
primaryCanvas?: string
|
|
898
776
|
/** Canvas-level scheduler options */
|
|
@@ -957,8 +835,6 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
957
835
|
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
958
836
|
*/
|
|
959
837
|
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
|
|
960
|
-
/** Color space assigned to 8-bit input textures (color maps). Defaults to sRGB. Most textures are authored in sRGB. */
|
|
961
|
-
textureColorSpace?: THREE$1.ColorSpace
|
|
962
838
|
/** Creates an orthographic camera */
|
|
963
839
|
orthographic?: boolean
|
|
964
840
|
/**
|
|
@@ -1084,8 +960,6 @@ interface Instance<O = any> {
|
|
|
1084
960
|
attach?: AttachType<O>
|
|
1085
961
|
previousAttach?: any
|
|
1086
962
|
isHidden: boolean
|
|
1087
|
-
/** Deferred ref props to apply in commitMount */
|
|
1088
|
-
deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
|
|
1089
963
|
/** Set of props that have been applied via once() */
|
|
1090
964
|
appliedOnce?: Set<string>
|
|
1091
965
|
}
|
|
@@ -1211,7 +1085,7 @@ interface CanvasProps
|
|
|
1211
1085
|
*/
|
|
1212
1086
|
resize?: Options
|
|
1213
1087
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1214
|
-
eventSource?: HTMLElement | React$1.RefObject<HTMLElement>
|
|
1088
|
+
eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
|
|
1215
1089
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1216
1090
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1217
1091
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1322,10 +1196,47 @@ type RenderTargetOptions = RenderTargetOptions$1
|
|
|
1322
1196
|
//* Global Types ==============================
|
|
1323
1197
|
|
|
1324
1198
|
declare global {
|
|
1325
|
-
/**
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1199
|
+
/**
|
|
1200
|
+
* Uniform node type.
|
|
1201
|
+
*
|
|
1202
|
+
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1203
|
+
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1204
|
+
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1205
|
+
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1206
|
+
* arity when three made `UniformNode` two-parameter.
|
|
1207
|
+
*
|
|
1208
|
+
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1209
|
+
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1210
|
+
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1211
|
+
* installed three instead of needing to be mirrored by hand.
|
|
1212
|
+
*/
|
|
1213
|
+
type UniformNode<T = unknown> = three_webgpu.UniformNode<UniformNodeTypeFor<T>, T>
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* three's node type name for a uniform value type, mirroring the `uniform()` overloads.
|
|
1217
|
+
* A `UniformNode<number>` is a `Node<'float'>`, so TSL math (`.mul`, `.add`, ...) accepts it.
|
|
1218
|
+
* Unknown or unlisted value types resolve to `unknown`, which TSL math rejects: narrow with
|
|
1219
|
+
* `as UniformNode<number>` (or the matching value type) at the call site.
|
|
1220
|
+
*/
|
|
1221
|
+
type UniformNodeTypeFor<T> = T extends number
|
|
1222
|
+
? 'float'
|
|
1223
|
+
: T extends boolean
|
|
1224
|
+
? 'bool'
|
|
1225
|
+
: T extends three_webgpu.Color
|
|
1226
|
+
? 'color'
|
|
1227
|
+
: T extends three_webgpu.Vector2
|
|
1228
|
+
? 'vec2'
|
|
1229
|
+
: T extends three_webgpu.Vector3
|
|
1230
|
+
? 'vec3'
|
|
1231
|
+
: T extends three_webgpu.Vector4
|
|
1232
|
+
? 'vec4'
|
|
1233
|
+
: T extends three_webgpu.Matrix2
|
|
1234
|
+
? 'mat2'
|
|
1235
|
+
: T extends three_webgpu.Matrix3
|
|
1236
|
+
? 'mat3'
|
|
1237
|
+
: T extends three_webgpu.Matrix4
|
|
1238
|
+
? 'mat4'
|
|
1239
|
+
: unknown
|
|
1329
1240
|
|
|
1330
1241
|
/**
|
|
1331
1242
|
* ShaderCallable - the return type of Fn()
|
|
@@ -1470,177 +1381,105 @@ declare module 'three/tsl' {
|
|
|
1470
1381
|
): ShaderCallable<R>
|
|
1471
1382
|
}
|
|
1472
1383
|
|
|
1473
|
-
/**
|
|
1474
|
-
* RenderPipeline Types for useRenderPipeline hook (WebGPU only)
|
|
1475
|
-
*/
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
1384
|
declare global {
|
|
1480
|
-
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1481
|
-
type PassRecord = Record<string, any>
|
|
1482
|
-
|
|
1483
|
-
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1484
|
-
type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
|
|
1485
|
-
|
|
1486
|
-
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1487
|
-
type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
|
|
1488
|
-
|
|
1489
|
-
/** Return type for useRenderPipeline hook */
|
|
1490
|
-
interface UseRenderPipelineReturn {
|
|
1491
|
-
/** Current passes from state */
|
|
1492
|
-
passes: PassRecord
|
|
1493
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1494
|
-
renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
|
|
1495
|
-
/** Clear all passes from state */
|
|
1496
|
-
clearPasses: () => void
|
|
1497
|
-
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1498
|
-
reset: () => void
|
|
1499
|
-
/** Re-run setup/main callbacks with current closure values */
|
|
1500
|
-
rebuild: () => void
|
|
1501
|
-
/** True when RenderPipeline is configured and ready */
|
|
1502
|
-
isReady: boolean
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
//* useFrameNext Types ==============================
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
//* Global Type Declarations ==============================
|
|
1511
|
-
|
|
1512
|
-
declare global {
|
|
1513
|
-
// Job --------------------------------
|
|
1514
|
-
|
|
1515
1385
|
/**
|
|
1516
|
-
*
|
|
1386
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1387
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1388
|
+
* is r185, so the new name is the only one.
|
|
1517
1389
|
*/
|
|
1518
|
-
|
|
1519
|
-
/** Unique identifier */
|
|
1520
|
-
id: string
|
|
1521
|
-
/** The callback to execute */
|
|
1522
|
-
callback: FrameNextCallback
|
|
1523
|
-
/** Phase this job belongs to */
|
|
1524
|
-
phase: string
|
|
1525
|
-
/** Run before these phases/job ids */
|
|
1526
|
-
before: Set<string>
|
|
1527
|
-
/** Run after these phases/job ids */
|
|
1528
|
-
after: Set<string>
|
|
1529
|
-
/** Priority within phase (higher first) */
|
|
1530
|
-
priority: number
|
|
1531
|
-
/** Insertion order for deterministic tie-breaking */
|
|
1532
|
-
index: number
|
|
1533
|
-
/** Max FPS for this job (undefined = no limit) */
|
|
1534
|
-
fps?: number
|
|
1535
|
-
/** Drop frames when behind (true) or catch up (false) */
|
|
1536
|
-
drop: boolean
|
|
1537
|
-
/** Last run timestamp (ms) */
|
|
1538
|
-
lastRun?: number
|
|
1539
|
-
/** Whether job is enabled */
|
|
1540
|
-
enabled: boolean
|
|
1541
|
-
/** Internal flag: system jobs (like default render) don't block user render takeover */
|
|
1542
|
-
system?: boolean
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
// Phase Graph --------------------------------
|
|
1390
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1546
1391
|
|
|
1547
1392
|
/**
|
|
1548
|
-
*
|
|
1393
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1394
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1395
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1549
1396
|
*/
|
|
1550
|
-
|
|
1551
|
-
/** Phase name */
|
|
1552
|
-
name: string
|
|
1553
|
-
/** Whether this was auto-generated from a before/after constraint */
|
|
1554
|
-
isAutoGenerated: boolean
|
|
1555
|
-
}
|
|
1397
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1556
1398
|
|
|
1557
1399
|
/**
|
|
1558
|
-
*
|
|
1400
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1401
|
+
*
|
|
1402
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1403
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1404
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1405
|
+
* {@link RenderPipelineCallbackState}.
|
|
1406
|
+
*
|
|
1407
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1408
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1409
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1410
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1559
1411
|
*/
|
|
1560
|
-
interface
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
before?: string | string[]
|
|
1564
|
-
after?: string | string[]
|
|
1565
|
-
priority?: number
|
|
1566
|
-
fps?: number
|
|
1567
|
-
drop?: boolean
|
|
1568
|
-
enabled?: boolean
|
|
1412
|
+
interface PassRecord {
|
|
1413
|
+
scenePass?: ScenePassNode
|
|
1414
|
+
[key: string]: three_webgpu.Node
|
|
1569
1415
|
}
|
|
1570
1416
|
|
|
1571
|
-
// Frame Loop State --------------------------------
|
|
1572
|
-
|
|
1573
1417
|
/**
|
|
1574
|
-
*
|
|
1418
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1419
|
+
*
|
|
1420
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1421
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1422
|
+
*
|
|
1423
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1424
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1575
1425
|
*/
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
/** Last frame timestamp in ms (null = uninitialized) */
|
|
1582
|
-
lastTime: number | null
|
|
1583
|
-
/** Frame counter */
|
|
1584
|
-
frameCount: number
|
|
1585
|
-
/** Elapsed time since first frame in ms */
|
|
1586
|
-
elapsedTime: number
|
|
1587
|
-
/** createdAt timestamp in ms */
|
|
1588
|
-
createdAt: number
|
|
1426
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1427
|
+
renderPipeline: ThreeRenderPipeline
|
|
1428
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1429
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1430
|
+
isLegacy: false
|
|
1589
1431
|
}
|
|
1590
1432
|
|
|
1591
|
-
// Root Entry --------------------------------
|
|
1592
|
-
|
|
1593
1433
|
/**
|
|
1594
|
-
*
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1434
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1435
|
+
*
|
|
1436
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1437
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1438
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1439
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1597
1440
|
*/
|
|
1598
|
-
|
|
1599
|
-
/** Unique identifier for this root */
|
|
1600
|
-
id: string
|
|
1601
|
-
/** Function to get the root's current state. Returns any to support independent mode. */
|
|
1602
|
-
getState: () => any
|
|
1603
|
-
/** Map of job IDs to Job objects */
|
|
1604
|
-
jobs: Map<string, Job>
|
|
1605
|
-
/** Cached sorted job list for execution order */
|
|
1606
|
-
sortedJobs: Job[]
|
|
1607
|
-
/** Whether sortedJobs needs rebuilding */
|
|
1608
|
-
needsRebuild: boolean
|
|
1609
|
-
}
|
|
1441
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1610
1442
|
|
|
1611
|
-
/**
|
|
1612
|
-
|
|
1613
|
-
* Global jobs run once per frame, not per-root.
|
|
1614
|
-
* Used by legacy addEffect/addAfterEffect APIs.
|
|
1615
|
-
* @internal
|
|
1616
|
-
* @deprecated Use useFrame with phases instead
|
|
1617
|
-
*/
|
|
1618
|
-
interface GlobalJob {
|
|
1619
|
-
/** Unique identifier for this global job */
|
|
1620
|
-
id: string
|
|
1621
|
-
/** Callback invoked with RAF timestamp in ms */
|
|
1622
|
-
callback: (timestamp: number) => void
|
|
1623
|
-
}
|
|
1443
|
+
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1444
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1624
1445
|
|
|
1625
|
-
|
|
1446
|
+
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1447
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1626
1448
|
|
|
1627
|
-
/**
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1449
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1450
|
+
interface UseRenderPipelineActions {
|
|
1451
|
+
/** Current passes from state */
|
|
1452
|
+
passes: PassRecord
|
|
1453
|
+
/** Clear all passes from state */
|
|
1454
|
+
clearPasses: () => void
|
|
1455
|
+
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1456
|
+
reset: () => void
|
|
1457
|
+
/** Re-run setup/main callbacks with current closure values */
|
|
1458
|
+
rebuild: () => void
|
|
1636
1459
|
}
|
|
1637
1460
|
|
|
1638
|
-
// Default Phases --------------------------------
|
|
1639
|
-
|
|
1640
1461
|
/**
|
|
1641
|
-
*
|
|
1462
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1463
|
+
*
|
|
1464
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1465
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1466
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1642
1467
|
*/
|
|
1643
|
-
type
|
|
1468
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1469
|
+
(
|
|
1470
|
+
| {
|
|
1471
|
+
/** True when RenderPipeline is configured and ready */
|
|
1472
|
+
isReady: true
|
|
1473
|
+
/** RenderPipeline instance */
|
|
1474
|
+
renderPipeline: ThreeRenderPipeline
|
|
1475
|
+
}
|
|
1476
|
+
| {
|
|
1477
|
+
/** False until the pipeline has been created */
|
|
1478
|
+
isReady: false
|
|
1479
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1480
|
+
renderPipeline: null
|
|
1481
|
+
}
|
|
1482
|
+
)
|
|
1644
1483
|
}
|
|
1645
1484
|
|
|
1646
1485
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1812,7 +1651,7 @@ declare namespace three_d {
|
|
|
1812
1651
|
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
1813
1652
|
*
|
|
1814
1653
|
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
1815
|
-
* Secondary canvas: Has `
|
|
1654
|
+
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
1816
1655
|
*/
|
|
1817
1656
|
|
|
1818
1657
|
interface PrimaryCanvasEntry {
|
|
@@ -1880,12 +1719,23 @@ type EnvironmentLoaderProps = {
|
|
|
1880
1719
|
* const texture = useEnvironment({ preset: 'sunset' })
|
|
1881
1720
|
* ```
|
|
1882
1721
|
*/
|
|
1883
|
-
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture
|
|
1722
|
+
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
|
|
1884
1723
|
declare namespace useEnvironment {
|
|
1885
1724
|
var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
|
|
1886
1725
|
var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
|
|
1887
1726
|
}
|
|
1888
|
-
|
|
1727
|
+
/**
|
|
1728
|
+
* Options accepted by `useEnvironment.preload`.
|
|
1729
|
+
*
|
|
1730
|
+
* `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
|
|
1731
|
+
* applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
|
|
1732
|
+
* advertise an option this function silently ignores.
|
|
1733
|
+
*
|
|
1734
|
+
* This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
|
|
1735
|
+
* `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
|
|
1736
|
+
* type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
|
|
1737
|
+
*/
|
|
1738
|
+
type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
|
|
1889
1739
|
type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
|
|
1890
1740
|
|
|
1891
1741
|
/**
|
|
@@ -1929,9 +1779,9 @@ type EnvironmentProps = {
|
|
|
1929
1779
|
blur?: number;
|
|
1930
1780
|
backgroundBlurriness?: number;
|
|
1931
1781
|
backgroundIntensity?: number;
|
|
1932
|
-
backgroundRotation?: Euler
|
|
1782
|
+
backgroundRotation?: Euler;
|
|
1933
1783
|
environmentIntensity?: number;
|
|
1934
|
-
environmentRotation?: Euler
|
|
1784
|
+
environmentRotation?: Euler;
|
|
1935
1785
|
map?: Texture$1;
|
|
1936
1786
|
preset?: PresetsType;
|
|
1937
1787
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -2015,7 +1865,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
2015
1865
|
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;
|
|
2016
1866
|
declare module '@react-three/fiber' {
|
|
2017
1867
|
interface ThreeElements {
|
|
2018
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1868
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
2019
1869
|
}
|
|
2020
1870
|
}
|
|
2021
1871
|
/**
|
|
@@ -2115,6 +1965,24 @@ declare module '@react-three/fiber' {
|
|
|
2115
1965
|
*/
|
|
2116
1966
|
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
2117
1967
|
|
|
1968
|
+
/**
|
|
1969
|
+
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
1970
|
+
*
|
|
1971
|
+
* When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
|
|
1972
|
+
* instance. Removing the old object from the interaction state and registering the new one from
|
|
1973
|
+
* scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
|
|
1974
|
+
* the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
|
|
1975
|
+
* is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
|
|
1976
|
+
* swap the user never asked to see (#3744).
|
|
1977
|
+
*
|
|
1978
|
+
* Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
|
|
1979
|
+
* left alone — releasing and re-acquiring it is precisely the glitch being avoided.
|
|
1980
|
+
*
|
|
1981
|
+
* Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
|
|
1982
|
+
* the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
|
|
1983
|
+
* cannot outlive the object it described.
|
|
1984
|
+
*/
|
|
1985
|
+
declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
|
|
2118
1986
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
2119
1987
|
declare function createEvents(store: RootStore): {
|
|
2120
1988
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
@@ -2135,389 +2003,27 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
|
|
|
2135
2003
|
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
2136
2004
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
2137
2005
|
*/
|
|
2138
|
-
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>;
|
|
2006
|
+
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>;
|
|
2139
2007
|
declare namespace useLoader {
|
|
2140
|
-
var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
|
|
2141
|
-
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
|
|
2008
|
+
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;
|
|
2009
|
+
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
|
|
2142
2010
|
var loader: typeof getLoader;
|
|
2143
2011
|
}
|
|
2144
2012
|
|
|
2145
|
-
/**
|
|
2146
|
-
* Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
|
|
2147
|
-
*
|
|
2148
|
-
* Features:
|
|
2149
|
-
* - Single RAF loop for entire application
|
|
2150
|
-
* - Root registration (multiple Canvas support)
|
|
2151
|
-
* - Global phases for addEffect/addAfterEffect (deprecated)
|
|
2152
|
-
* - Per-root job management with phases, priorities, FPS throttling
|
|
2153
|
-
* - onIdle callbacks for addTail (deprecated)
|
|
2154
|
-
* - Demand mode support via invalidate()
|
|
2155
|
-
*/
|
|
2156
|
-
declare class Scheduler {
|
|
2157
|
-
private static readonly INSTANCE_KEY;
|
|
2158
|
-
private static get instance();
|
|
2159
|
-
private static set instance(value);
|
|
2160
|
-
/**
|
|
2161
|
-
* Get the global scheduler instance (creates if doesn't exist).
|
|
2162
|
-
* Uses HMR data to preserve instance across hot reloads.
|
|
2163
|
-
* @returns {Scheduler} The singleton scheduler instance
|
|
2164
|
-
*/
|
|
2165
|
-
static get(): Scheduler;
|
|
2166
|
-
/**
|
|
2167
|
-
* Reset the singleton instance. Stops the loop and clears all state.
|
|
2168
|
-
* Primarily used for testing to ensure clean state between tests.
|
|
2169
|
-
* @returns {void}
|
|
2170
|
-
*/
|
|
2171
|
-
static reset(): void;
|
|
2172
|
-
private roots;
|
|
2173
|
-
private phaseGraph;
|
|
2174
|
-
private loopState;
|
|
2175
|
-
private stoppedTime;
|
|
2176
|
-
private nextRootIndex;
|
|
2177
|
-
private globalBeforeJobs;
|
|
2178
|
-
private globalAfterJobs;
|
|
2179
|
-
private nextGlobalIndex;
|
|
2180
|
-
private idleCallbacks;
|
|
2181
|
-
private nextJobIndex;
|
|
2182
|
-
private jobStateListeners;
|
|
2183
|
-
private pendingFrames;
|
|
2184
|
-
private _frameloop;
|
|
2185
|
-
private _independent;
|
|
2186
|
-
private errorHandler;
|
|
2187
|
-
private rootReadyCallbacks;
|
|
2188
|
-
get phases(): string[];
|
|
2189
|
-
get frameloop(): Frameloop;
|
|
2190
|
-
set frameloop(mode: Frameloop);
|
|
2191
|
-
get isRunning(): boolean;
|
|
2192
|
-
get isReady(): boolean;
|
|
2193
|
-
get independent(): boolean;
|
|
2194
|
-
set independent(value: boolean);
|
|
2195
|
-
constructor();
|
|
2196
|
-
/**
|
|
2197
|
-
* Register a root (Canvas) with the scheduler.
|
|
2198
|
-
* The first root to register starts the RAF loop (if frameloop='always').
|
|
2199
|
-
* @param {string} id - Unique identifier for this root
|
|
2200
|
-
* @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
|
|
2201
|
-
* @returns {() => void} Unsubscribe function to remove this root
|
|
2202
|
-
*/
|
|
2203
|
-
registerRoot(id: string, options?: RootOptions): () => void;
|
|
2204
|
-
/**
|
|
2205
|
-
* Unregister a root from the scheduler.
|
|
2206
|
-
* Cleans up all job state listeners for this root's jobs.
|
|
2207
|
-
* The last root to unregister stops the RAF loop.
|
|
2208
|
-
* @param {string} id - The root ID to unregister
|
|
2209
|
-
* @returns {void}
|
|
2210
|
-
*/
|
|
2211
|
-
unregisterRoot(id: string): void;
|
|
2212
|
-
/**
|
|
2213
|
-
* Subscribe to be notified when a root becomes available.
|
|
2214
|
-
* Fires immediately if a root already exists.
|
|
2215
|
-
* @param {() => void} callback - Function called when first root registers
|
|
2216
|
-
* @returns {() => void} Unsubscribe function
|
|
2217
|
-
*/
|
|
2218
|
-
onRootReady(callback: () => void): () => void;
|
|
2219
|
-
/**
|
|
2220
|
-
* Notify all registered root-ready callbacks.
|
|
2221
|
-
* Called when the first root registers.
|
|
2222
|
-
* @returns {void}
|
|
2223
|
-
* @private
|
|
2224
|
-
*/
|
|
2225
|
-
private notifyRootReady;
|
|
2226
|
-
/**
|
|
2227
|
-
* Ensure a default root exists for independent mode.
|
|
2228
|
-
* Creates a minimal root with no state provider.
|
|
2229
|
-
* @returns {void}
|
|
2230
|
-
* @private
|
|
2231
|
-
*/
|
|
2232
|
-
private ensureDefaultRoot;
|
|
2233
|
-
/**
|
|
2234
|
-
* Trigger error handling for job errors.
|
|
2235
|
-
* Uses the bound error handler if available, otherwise logs to console.
|
|
2236
|
-
* @param {Error} error - The error to handle
|
|
2237
|
-
* @returns {void}
|
|
2238
|
-
*/
|
|
2239
|
-
triggerError(error: Error): void;
|
|
2240
|
-
/**
|
|
2241
|
-
* Add a named phase to the scheduler's execution order.
|
|
2242
|
-
* Marks all roots for rebuild to incorporate the new phase.
|
|
2243
|
-
* @param {string} name - The phase name (e.g., 'physics', 'postprocess')
|
|
2244
|
-
* @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
|
|
2245
|
-
* @returns {void}
|
|
2246
|
-
* @example
|
|
2247
|
-
* scheduler.addPhase('physics', { before: 'update' });
|
|
2248
|
-
* scheduler.addPhase('postprocess', { after: 'render' });
|
|
2249
|
-
*/
|
|
2250
|
-
addPhase(name: string, options?: AddPhaseOptions): void;
|
|
2251
|
-
/**
|
|
2252
|
-
* Check if a phase exists in the scheduler.
|
|
2253
|
-
* @param {string} name - The phase name to check
|
|
2254
|
-
* @returns {boolean} True if the phase exists
|
|
2255
|
-
*/
|
|
2256
|
-
hasPhase(name: string): boolean;
|
|
2257
|
-
/**
|
|
2258
|
-
* Register a global job that runs once per frame (not per-root).
|
|
2259
|
-
* Used internally by deprecated addEffect/addAfterEffect APIs.
|
|
2260
|
-
* @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
|
|
2261
|
-
* @param {string} id - Unique identifier for this global job
|
|
2262
|
-
* @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
|
|
2263
|
-
* @returns {() => void} Unsubscribe function to remove this global job
|
|
2264
|
-
* @deprecated Use useFrame with phases instead
|
|
2265
|
-
*/
|
|
2266
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
|
|
2267
|
-
/**
|
|
2268
|
-
* Register an idle callback that fires when the loop stops.
|
|
2269
|
-
* Used internally by deprecated addTail API.
|
|
2270
|
-
* @param {(timestamp: number) => void} callback - Function called when loop becomes idle
|
|
2271
|
-
* @returns {() => void} Unsubscribe function to remove this idle callback
|
|
2272
|
-
* @deprecated Use demand mode with invalidate() instead
|
|
2273
|
-
*/
|
|
2274
|
-
onIdle(callback: (timestamp: number) => void): () => void;
|
|
2275
|
-
/**
|
|
2276
|
-
* Notify all registered idle callbacks.
|
|
2277
|
-
* Called when the loop stops in demand mode.
|
|
2278
|
-
* @param {number} timestamp - The RAF timestamp when idle occurred
|
|
2279
|
-
* @returns {void}
|
|
2280
|
-
* @private
|
|
2281
|
-
*/
|
|
2282
|
-
private notifyIdle;
|
|
2283
|
-
/**
|
|
2284
|
-
* Register a job (frame callback) with a specific root.
|
|
2285
|
-
* This is the core registration method used by useFrame internally.
|
|
2286
|
-
* @param {FrameNextCallback} callback - The function to call each frame
|
|
2287
|
-
* @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
|
|
2288
|
-
* @param {string} [options.rootId] - Target root ID (defaults to first registered root)
|
|
2289
|
-
* @param {string} [options.id] - Unique job ID (auto-generated if not provided)
|
|
2290
|
-
* @param {string} [options.phase] - Execution phase (defaults to 'update')
|
|
2291
|
-
* @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
|
|
2292
|
-
* @param {number} [options.fps] - FPS throttle limit
|
|
2293
|
-
* @param {boolean} [options.drop] - Drop frames when behind (default true)
|
|
2294
|
-
* @param {boolean} [options.enabled] - Whether job is active (default true)
|
|
2295
|
-
* @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
|
|
2296
|
-
* @returns {() => void} Unsubscribe function to remove this job
|
|
2297
|
-
*/
|
|
2298
|
-
register(callback: FrameNextCallback, options?: JobOptions & {
|
|
2299
|
-
rootId?: string;
|
|
2300
|
-
system?: boolean;
|
|
2301
|
-
}): () => void;
|
|
2302
|
-
/**
|
|
2303
|
-
* Unregister a job by its ID.
|
|
2304
|
-
* Searches all roots if rootId is not provided.
|
|
2305
|
-
* @param {string} id - The job ID to unregister
|
|
2306
|
-
* @param {string} [rootId] - Optional root ID to search (searches all if not provided)
|
|
2307
|
-
* @returns {void}
|
|
2308
|
-
*/
|
|
2309
|
-
unregister(id: string, rootId?: string): void;
|
|
2310
|
-
/**
|
|
2311
|
-
* Update a job's options dynamically.
|
|
2312
|
-
* Searches all roots to find the job by ID.
|
|
2313
|
-
* Phase/constraint changes trigger a rebuild of the sorted job list.
|
|
2314
|
-
* @param {string} id - The job ID to update
|
|
2315
|
-
* @param {Partial<JobOptions>} options - The options to update
|
|
2316
|
-
* @returns {void}
|
|
2317
|
-
*/
|
|
2318
|
-
updateJob(id: string, options: Partial<JobOptions>): void;
|
|
2319
|
-
/**
|
|
2320
|
-
* Check if a job is currently paused (disabled).
|
|
2321
|
-
* @param {string} id - The job ID to check
|
|
2322
|
-
* @returns {boolean} True if the job exists and is paused
|
|
2323
|
-
*/
|
|
2324
|
-
isJobPaused(id: string): boolean;
|
|
2325
|
-
/**
|
|
2326
|
-
* Subscribe to state changes for a specific job.
|
|
2327
|
-
* Listener is called when job is paused or resumed.
|
|
2328
|
-
* @param {string} id - The job ID to subscribe to
|
|
2329
|
-
* @param {() => void} listener - Callback invoked on state changes
|
|
2330
|
-
* @returns {() => void} Unsubscribe function
|
|
2331
|
-
*/
|
|
2332
|
-
subscribeJobState(id: string, listener: () => void): () => void;
|
|
2333
|
-
/**
|
|
2334
|
-
* Notify all listeners that a job's state has changed.
|
|
2335
|
-
* @param {string} id - The job ID that changed
|
|
2336
|
-
* @returns {void}
|
|
2337
|
-
* @private
|
|
2338
|
-
*/
|
|
2339
|
-
private notifyJobStateChange;
|
|
2340
|
-
/**
|
|
2341
|
-
* Pause a job by ID (sets enabled=false).
|
|
2342
|
-
* Notifies any subscribed state listeners.
|
|
2343
|
-
* @param {string} id - The job ID to pause
|
|
2344
|
-
* @returns {void}
|
|
2345
|
-
*/
|
|
2346
|
-
pauseJob(id: string): void;
|
|
2347
|
-
/**
|
|
2348
|
-
* Resume a paused job by ID (sets enabled=true).
|
|
2349
|
-
* Resets job timing to prevent frame accumulation.
|
|
2350
|
-
* Notifies any subscribed state listeners.
|
|
2351
|
-
* @param {string} id - The job ID to resume
|
|
2352
|
-
* @returns {void}
|
|
2353
|
-
*/
|
|
2354
|
-
resumeJob(id: string): void;
|
|
2355
|
-
/**
|
|
2356
|
-
* Start the requestAnimationFrame loop.
|
|
2357
|
-
* Resets timing state (elapsedTime, frameCount) on start.
|
|
2358
|
-
* No-op if already running.
|
|
2359
|
-
* @returns {void}
|
|
2360
|
-
*/
|
|
2361
|
-
start(): void;
|
|
2362
|
-
/**
|
|
2363
|
-
* Stop the requestAnimationFrame loop.
|
|
2364
|
-
* Cancels any pending RAF callback.
|
|
2365
|
-
* No-op if not running.
|
|
2366
|
-
* @returns {void}
|
|
2367
|
-
*/
|
|
2368
|
-
stop(): void;
|
|
2369
|
-
/**
|
|
2370
|
-
* Request frames to be rendered in demand mode.
|
|
2371
|
-
* Accumulates pending frames (capped at 60) and starts the loop if not running.
|
|
2372
|
-
* No-op if frameloop is not 'demand'.
|
|
2373
|
-
* @param {number} [frames=1] - Number of frames to request
|
|
2374
|
-
* @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
|
|
2375
|
-
* - `false` (default): Sets pending frames to the specified value (replaces existing count)
|
|
2376
|
-
* - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
|
|
2377
|
-
* @returns {void}
|
|
2378
|
-
* @example
|
|
2379
|
-
* // Request a single frame render
|
|
2380
|
-
* scheduler.invalidate();
|
|
2381
|
-
*
|
|
2382
|
-
* @example
|
|
2383
|
-
* // Request 5 frames (e.g., for animations)
|
|
2384
|
-
* scheduler.invalidate(5);
|
|
2385
|
-
*
|
|
2386
|
-
* @example
|
|
2387
|
-
* // Set pending frames to exactly 3 (don't stack with existing)
|
|
2388
|
-
* scheduler.invalidate(3, false);
|
|
2389
|
-
*
|
|
2390
|
-
* @example
|
|
2391
|
-
* // Add 2 more frames to existing pending count
|
|
2392
|
-
* scheduler.invalidate(2, true);
|
|
2393
|
-
*/
|
|
2394
|
-
invalidate(frames?: number, stackFrames?: boolean): void;
|
|
2395
|
-
/**
|
|
2396
|
-
* Reset timing state for deterministic testing.
|
|
2397
|
-
* Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
|
|
2398
|
-
* @returns {void}
|
|
2399
|
-
*/
|
|
2400
|
-
resetTiming(): void;
|
|
2401
|
-
/**
|
|
2402
|
-
* Manually execute a single frame for all roots.
|
|
2403
|
-
* Useful for frameloop='never' mode or testing scenarios.
|
|
2404
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2405
|
-
* @returns {void}
|
|
2406
|
-
* @example
|
|
2407
|
-
* // Manual control mode
|
|
2408
|
-
* scheduler.frameloop = 'never';
|
|
2409
|
-
* scheduler.step(); // Execute one frame
|
|
2410
|
-
*/
|
|
2411
|
-
step(timestamp?: number): void;
|
|
2412
|
-
/**
|
|
2413
|
-
* Manually execute a single job by its ID.
|
|
2414
|
-
* Useful for testing individual job callbacks in isolation.
|
|
2415
|
-
* @param {string} id - The job ID to step
|
|
2416
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2417
|
-
* @returns {void}
|
|
2418
|
-
*/
|
|
2419
|
-
stepJob(id: string, timestamp?: number): void;
|
|
2420
|
-
/**
|
|
2421
|
-
* Main RAF loop callback.
|
|
2422
|
-
* Executes frame, handles demand mode, and schedules next frame.
|
|
2423
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2424
|
-
* @returns {void}
|
|
2425
|
-
* @private
|
|
2426
|
-
*/
|
|
2427
|
-
private loop;
|
|
2428
|
-
/**
|
|
2429
|
-
* Execute a single frame across all roots.
|
|
2430
|
-
* Order: globalBefore → each root's jobs → globalAfter
|
|
2431
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2432
|
-
* @returns {void}
|
|
2433
|
-
* @private
|
|
2434
|
-
*/
|
|
2435
|
-
private executeFrame;
|
|
2436
|
-
/**
|
|
2437
|
-
* Run all global jobs from a job map.
|
|
2438
|
-
* Catches and logs errors without stopping execution.
|
|
2439
|
-
* @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
|
|
2440
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2441
|
-
* @returns {void}
|
|
2442
|
-
* @private
|
|
2443
|
-
*/
|
|
2444
|
-
private runGlobalJobs;
|
|
2445
|
-
/**
|
|
2446
|
-
* Execute all jobs for a single root in sorted order.
|
|
2447
|
-
* Rebuilds sorted job list if needed, then dispatches each job.
|
|
2448
|
-
* Errors are caught and propagated via triggerError.
|
|
2449
|
-
* @param {RootEntry} root - The root entry to tick
|
|
2450
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2451
|
-
* @param {number} delta - Time since last frame in seconds
|
|
2452
|
-
* @returns {void}
|
|
2453
|
-
* @private
|
|
2454
|
-
*/
|
|
2455
|
-
private tickRoot;
|
|
2456
|
-
/**
|
|
2457
|
-
* Get the total number of registered jobs across all roots.
|
|
2458
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2459
|
-
* @returns {number} Total job count
|
|
2460
|
-
*/
|
|
2461
|
-
getJobCount(): number;
|
|
2462
|
-
/**
|
|
2463
|
-
* Get all registered job IDs across all roots.
|
|
2464
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2465
|
-
* @returns {string[]} Array of all job IDs
|
|
2466
|
-
*/
|
|
2467
|
-
getJobIds(): string[];
|
|
2468
|
-
/**
|
|
2469
|
-
* Get the number of registered roots (Canvas instances).
|
|
2470
|
-
* @returns {number} Number of registered roots
|
|
2471
|
-
*/
|
|
2472
|
-
getRootCount(): number;
|
|
2473
|
-
/**
|
|
2474
|
-
* Check if any user (non-system) jobs are registered in a specific phase.
|
|
2475
|
-
* Used by the default render job to know if a user has taken over rendering.
|
|
2476
|
-
*
|
|
2477
|
-
* @param phase The phase to check
|
|
2478
|
-
* @param rootId Optional root ID to check (checks all roots if not provided)
|
|
2479
|
-
* @returns true if any user jobs exist in the phase
|
|
2480
|
-
*/
|
|
2481
|
-
hasUserJobsInPhase(phase: string, rootId?: string): boolean;
|
|
2482
|
-
/**
|
|
2483
|
-
* Generate a unique root ID for automatic root registration.
|
|
2484
|
-
* @returns {string} A unique root ID in the format 'root_N'
|
|
2485
|
-
*/
|
|
2486
|
-
generateRootId(): string;
|
|
2487
|
-
/**
|
|
2488
|
-
* Generate a unique job ID.
|
|
2489
|
-
* @returns {string} A unique job ID in the format 'job_N'
|
|
2490
|
-
* @private
|
|
2491
|
-
*/
|
|
2492
|
-
private generateJobId;
|
|
2493
|
-
/**
|
|
2494
|
-
* Normalize before/after constraints to a Set.
|
|
2495
|
-
* Handles undefined, single string, or array inputs.
|
|
2496
|
-
* @param {string | string[] | undefined} value - The constraint value(s)
|
|
2497
|
-
* @returns {Set<string>} Normalized Set of constraint strings
|
|
2498
|
-
* @private
|
|
2499
|
-
*/
|
|
2500
|
-
private normalizeConstraints;
|
|
2501
|
-
}
|
|
2502
|
-
/**
|
|
2503
|
-
* Get the global scheduler instance.
|
|
2504
|
-
* Creates one if it doesn't exist.
|
|
2505
|
-
*/
|
|
2506
|
-
declare const getScheduler: () => Scheduler;
|
|
2507
|
-
|
|
2508
2013
|
/**
|
|
2509
2014
|
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
2510
2015
|
*
|
|
2511
|
-
*
|
|
2512
|
-
* - Inside Canvas: Full RootState (
|
|
2513
|
-
* - Outside Canvas
|
|
2514
|
-
*
|
|
2016
|
+
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
2017
|
+
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
2018
|
+
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
2019
|
+
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
2020
|
+
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
2515
2021
|
*
|
|
2516
2022
|
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
2517
2023
|
*
|
|
2518
2024
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
2519
2025
|
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
2520
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
2026
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
2521
2027
|
*
|
|
2522
2028
|
* @example
|
|
2523
2029
|
* // Simple priority (backwards compat)
|
|
@@ -2528,16 +2034,16 @@ declare const getScheduler: () => Scheduler;
|
|
|
2528
2034
|
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
2529
2035
|
*
|
|
2530
2036
|
* @example
|
|
2531
|
-
* // Outside Canvas - waits for Canvas
|
|
2037
|
+
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
2532
2038
|
* function UI() {
|
|
2533
2039
|
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
2534
2040
|
* return <button>...</button>;
|
|
2535
2041
|
* }
|
|
2536
2042
|
*
|
|
2537
2043
|
* @example
|
|
2538
|
-
* //
|
|
2539
|
-
* getScheduler
|
|
2540
|
-
*
|
|
2044
|
+
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
2045
|
+
* import { getScheduler } from '@pmndrs/scheduler'
|
|
2046
|
+
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
2541
2047
|
*
|
|
2542
2048
|
* @example
|
|
2543
2049
|
* // Scheduler-only access (no callback)
|
|
@@ -2560,11 +2066,16 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
|
|
|
2560
2066
|
/** Callback when texture(s) finish loading */
|
|
2561
2067
|
onLoad?: (texture: MappedTextureType<Url>) => void;
|
|
2562
2068
|
/**
|
|
2563
|
-
*
|
|
2564
|
-
* When true:
|
|
2069
|
+
* Register the texture(s) in R3F's global texture registry for access via useTextures().
|
|
2070
|
+
* When true (the default):
|
|
2565
2071
|
* - Textures persist until explicitly disposed
|
|
2566
|
-
* -
|
|
2567
|
-
*
|
|
2072
|
+
* - On mount, returns existing registered textures if available (preserving modifications like colorSpace)
|
|
2073
|
+
*
|
|
2074
|
+
* Reads are taken once at mount — a mounted `useTexture` does not re-render when the registry
|
|
2075
|
+
* changes. To react to registry swaps, use `useTextures(s => s.get(key))` instead.
|
|
2076
|
+
*
|
|
2077
|
+
* Pass `false` to opt out of registry enrollment entirely.
|
|
2078
|
+
* @default true
|
|
2568
2079
|
*/
|
|
2569
2080
|
cache?: boolean;
|
|
2570
2081
|
};
|
|
@@ -2588,15 +2099,18 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
|
|
|
2588
2099
|
* normal: '/normal.png'
|
|
2589
2100
|
* })
|
|
2590
2101
|
*
|
|
2591
|
-
* //
|
|
2592
|
-
* //
|
|
2593
|
-
* const diffuse = useTexture('/diffuse.png'
|
|
2102
|
+
* // Textures are registered in the global registry by default — the same texture
|
|
2103
|
+
* // object is shared across components and modifications (colorSpace, wrapS, etc.) are preserved
|
|
2104
|
+
* const diffuse = useTexture('/diffuse.png')
|
|
2594
2105
|
* diffuse.colorSpace = THREE.SRGBColorSpace
|
|
2595
2106
|
*
|
|
2596
2107
|
* // Another component gets the SAME texture with colorSpace already set
|
|
2597
|
-
* const sameDiffuse = useTexture('/diffuse.png'
|
|
2108
|
+
* const sameDiffuse = useTexture('/diffuse.png')
|
|
2598
2109
|
*
|
|
2599
|
-
* //
|
|
2110
|
+
* // Opt out of registry enrollment for a one-off texture
|
|
2111
|
+
* const scratch = useTexture('/scratch.png', { cache: false })
|
|
2112
|
+
*
|
|
2113
|
+
* // Access the registry directly
|
|
2600
2114
|
* const { get } = useTextures()
|
|
2601
2115
|
* const cached = get('/diffuse.png')
|
|
2602
2116
|
* ```
|
|
@@ -2613,63 +2127,80 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
|
|
|
2613
2127
|
cache?: boolean;
|
|
2614
2128
|
}) => react_jsx_runtime.JSX.Element;
|
|
2615
2129
|
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2130
|
+
/** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
|
|
2131
|
+
type TextureInput = string | string[] | Record<string, string>;
|
|
2132
|
+
/** Result of a `get()` read, mirroring the input shape. */
|
|
2133
|
+
type TextureResult<Input extends TextureInput> = Input extends string ? Texture$1 | undefined : Input extends string[] ? (Texture$1 | undefined)[] : {
|
|
2134
|
+
[K in keyof Input]: Texture$1 | undefined;
|
|
2619
2135
|
};
|
|
2136
|
+
/** Options for `dispose()`. */
|
|
2137
|
+
interface DisposeOptions {
|
|
2138
|
+
/** Dispose even if the texture still has active references (default false). */
|
|
2139
|
+
force?: boolean;
|
|
2140
|
+
}
|
|
2620
2141
|
interface UseTexturesReturn {
|
|
2621
|
-
/** Map
|
|
2622
|
-
|
|
2623
|
-
/**
|
|
2624
|
-
get
|
|
2625
|
-
/** Check
|
|
2626
|
-
has
|
|
2627
|
-
/**
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2142
|
+
/** The live registry Map (key → Texture). Treat as read-only. */
|
|
2143
|
+
readonly all: Map<string, Texture$1>;
|
|
2144
|
+
/** Read one texture, an array of textures, or a name→texture record (mirrors the input shape). */
|
|
2145
|
+
get<Input extends TextureInput>(input: Input): TextureResult<Input>;
|
|
2146
|
+
/** Check whether a key exists in the registry. */
|
|
2147
|
+
has(key: string): boolean;
|
|
2148
|
+
/**
|
|
2149
|
+
* Register a texture (or a record of textures) that has no URL — e.g. a render
|
|
2150
|
+
* target or procedural texture. URL-loaded textures are registered automatically
|
|
2151
|
+
* by `useTexture` (registry enrollment is on by default).
|
|
2152
|
+
*/
|
|
2153
|
+
add(key: string, texture: Texture$1): void;
|
|
2154
|
+
add(record: Record<string, Texture$1>): void;
|
|
2155
|
+
/**
|
|
2156
|
+
* Dispose a texture's GPU resources and remove it from the registry.
|
|
2157
|
+
* Refcount-aware: if the key is still in use by a mounted `useTexture` consumer it is
|
|
2158
|
+
* skipped (with a warning) unless `{ force: true }` is passed.
|
|
2159
|
+
* @returns true if disposed, false if skipped.
|
|
2160
|
+
*/
|
|
2161
|
+
dispose(key: string, options?: DisposeOptions): boolean;
|
|
2162
|
+
/** Dispose every texture in the registry and clear it. Use on scene teardown. */
|
|
2163
|
+
disposeAll(): void;
|
|
2641
2164
|
}
|
|
2642
2165
|
/**
|
|
2643
|
-
*
|
|
2166
|
+
* Reactive Texture registry — load once with `useTexture`, reach the textures from anywhere.
|
|
2644
2167
|
*
|
|
2645
|
-
*
|
|
2646
|
-
*
|
|
2168
|
+
* This is a registry of plain `Texture` objects (not TSL nodes), so the same texture can feed
|
|
2169
|
+
* a material map, a heightmap sampler, or anything else. It does **not** load — pair it with
|
|
2170
|
+
* `useTexture` for loading (registry enrollment is on by default); `useTextures` is for access and lifecycle.
|
|
2171
|
+
*
|
|
2172
|
+
* The returned handle is **reactive**: the calling component re-renders when the registry
|
|
2173
|
+
* changes. Pass a selector to scope the subscription to a single read.
|
|
2647
2174
|
*
|
|
2648
2175
|
* @example
|
|
2649
2176
|
* ```tsx
|
|
2650
|
-
*
|
|
2177
|
+
* // Load + register once (anywhere in the tree) — registered by default
|
|
2178
|
+
* useTexture({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
|
|
2651
2179
|
*
|
|
2652
|
-
* //
|
|
2653
|
-
*
|
|
2654
|
-
*
|
|
2655
|
-
* const tex = useTexture('/textures/diffuse.png', { cache: true })
|
|
2656
|
-
* }
|
|
2180
|
+
* // Reach them from another component — record form lands straight into a material
|
|
2181
|
+
* const { map, normalMap } = useTextures().get({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
|
|
2182
|
+
* return <meshStandardMaterial map={map} normalMap={normalMap} />
|
|
2657
2183
|
*
|
|
2658
|
-
* //
|
|
2659
|
-
* const
|
|
2660
|
-
* if (diffuse) material.map = diffuse
|
|
2184
|
+
* // A set of heightmaps at once
|
|
2185
|
+
* const [a, b, c] = useTextures().get(['/h0.png', '/h1.png', '/h2.png'])
|
|
2661
2186
|
*
|
|
2662
|
-
* //
|
|
2663
|
-
*
|
|
2187
|
+
* // Register a non-URL texture (render target / procedural)
|
|
2188
|
+
* useTextures().add('rt-main', renderTarget.texture)
|
|
2664
2189
|
*
|
|
2665
|
-
* //
|
|
2666
|
-
* dispose('/
|
|
2667
|
-
*
|
|
2668
|
-
* // Nuclear option - dispose everything
|
|
2669
|
-
* disposeAll()
|
|
2190
|
+
* // Deliberate GPU cleanup (refcount-aware; force to override)
|
|
2191
|
+
* useTextures().dispose('/diffuse.jpg')
|
|
2192
|
+
* useTextures().disposeAll() // scene teardown
|
|
2670
2193
|
* ```
|
|
2194
|
+
*
|
|
2195
|
+
* @remarks
|
|
2196
|
+
* **Future expansion:** an imperative async loader (e.g. `await useTextures().load('/x.jpg')`) is
|
|
2197
|
+
* intentionally not included yet. It would let non-React code (loading screens, dynamic streaming)
|
|
2198
|
+
* populate the registry without Suspense, at the cost of putting loading back into this hook. It
|
|
2199
|
+
* will be added only if a concrete consumer needs imperative loading; for now, loading lives in
|
|
2200
|
+
* `useTexture`.
|
|
2671
2201
|
*/
|
|
2672
2202
|
declare function useTextures(): UseTexturesReturn;
|
|
2203
|
+
declare function useTextures<T>(selector: (registry: UseTexturesReturn) => T): T;
|
|
2673
2204
|
|
|
2674
2205
|
/**
|
|
2675
2206
|
* Creates a render target compatible with the current renderer.
|
|
@@ -2788,7 +2319,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2788
2319
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2789
2320
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2790
2321
|
*
|
|
2791
|
-
*
|
|
2322
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2323
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2324
|
+
*
|
|
2325
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2792
2326
|
* @param frames - Number of frames to request (default: 1)
|
|
2793
2327
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2794
2328
|
*
|
|
@@ -2799,14 +2333,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2799
2333
|
* Advances the frameloop and runs render effects.
|
|
2800
2334
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2801
2335
|
*
|
|
2336
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2337
|
+
* registered root is stepped for backwards compatibility.
|
|
2338
|
+
*
|
|
2802
2339
|
* @param timestamp - The timestamp to use for this frame
|
|
2803
2340
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2804
|
-
* @param state -
|
|
2805
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2341
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2806
2342
|
*
|
|
2807
2343
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2808
2344
|
*/
|
|
2809
|
-
declare function advance(timestamp: number): void;
|
|
2345
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2810
2346
|
|
|
2811
2347
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2812
2348
|
declare function ReactReconciler<
|
|
@@ -3877,11 +3413,6 @@ declare function flushSync<R>(fn: () => R): R;
|
|
|
3877
3413
|
declare const context: React$1.Context<RootStore>;
|
|
3878
3414
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3879
3415
|
|
|
3880
|
-
/**
|
|
3881
|
-
* Safely flush async effects when testing, simulating a legacy root.
|
|
3882
|
-
* @deprecated Import from React instead. import { act } from 'react'
|
|
3883
|
-
*/
|
|
3884
|
-
declare const act: typeof React$1.act;
|
|
3885
3416
|
/**
|
|
3886
3417
|
* An SSR-friendly useLayoutEffect.
|
|
3887
3418
|
*
|
|
@@ -4365,5 +3896,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
4365
3896
|
*/
|
|
4366
3897
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
4367
3898
|
|
|
4368
|
-
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,
|
|
4369
|
-
export type { Act,
|
|
3899
|
+
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 };
|
|
3900
|
+
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, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, LegacyInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, LegacyRootState as RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|