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