@react-three/fiber 10.0.0-canary.1b98c17 → 10.0.0-canary.20de6b2
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 +2694 -3489
- package/dist/index.d.cts +190 -805
- package/dist/index.d.mts +190 -805
- package/dist/index.d.ts +190 -805
- package/dist/index.mjs +2719 -3513
- package/dist/legacy.cjs +2521 -3321
- package/dist/legacy.d.cts +189 -807
- package/dist/legacy.d.mts +189 -807
- package/dist/legacy.d.ts +189 -807
- package/dist/legacy.mjs +3058 -3857
- package/dist/webgpu/index.cjs +2975 -3987
- package/dist/webgpu/index.d.cts +231 -848
- package/dist/webgpu/index.d.mts +231 -848
- package/dist/webgpu/index.d.ts +231 -848
- package/dist/webgpu/index.mjs +3108 -4119
- 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/webgpu/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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, WebGPURendererParameters } 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, WebGPURendererParameters } from 'three/webgpu';
|
|
3
4
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
4
5
|
import * as THREE$1 from 'three';
|
|
5
6
|
import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
@@ -7,9 +8,10 @@ import * as React$1 from 'react';
|
|
|
7
8
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
8
9
|
import { StoreApi } from 'zustand';
|
|
9
10
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
11
|
+
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
12
|
+
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
10
13
|
import { Options } from 'react-use-measure';
|
|
11
14
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
12
|
-
import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
|
|
13
15
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
14
16
|
|
|
15
17
|
function _mergeNamespaces(n, m) {
|
|
@@ -39,6 +41,8 @@ function _mergeNamespaces(n, m) {
|
|
|
39
41
|
declare const R3F_BUILD_LEGACY = false;
|
|
40
42
|
declare const R3F_BUILD_WEBGPU = true;
|
|
41
43
|
|
|
44
|
+
/** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
|
|
45
|
+
declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
|
|
42
46
|
declare const WebGLRenderer: {
|
|
43
47
|
new (): {};
|
|
44
48
|
};
|
|
@@ -47,16 +51,21 @@ type WebGLShadowMap = never;
|
|
|
47
51
|
|
|
48
52
|
declare const WebGLRenderTarget: any;
|
|
49
53
|
|
|
54
|
+
declare const WebGLCubeRenderTarget: any;
|
|
55
|
+
|
|
50
56
|
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
51
57
|
__proto__: null,
|
|
58
|
+
CubeRenderTargetCompat: CubeRenderTarget,
|
|
52
59
|
Inspector: Inspector,
|
|
53
60
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
54
61
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
55
62
|
RenderTargetCompat: RenderTarget,
|
|
63
|
+
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
56
64
|
WebGLRenderTarget: WebGLRenderTarget,
|
|
57
65
|
WebGLRenderer: WebGLRenderer,
|
|
58
66
|
WebGLRendererParameters: WebGLRendererParameters,
|
|
59
|
-
WebGLShadowMap: WebGLShadowMap
|
|
67
|
+
WebGLShadowMap: WebGLShadowMap,
|
|
68
|
+
loadInspector: loadInspector
|
|
60
69
|
}, [three_webgpu]);
|
|
61
70
|
|
|
62
71
|
//* Utility Types ==============================
|
|
@@ -294,228 +303,33 @@ interface VisibilityEntry {
|
|
|
294
303
|
}
|
|
295
304
|
|
|
296
305
|
//* Scheduler Types (useFrame) ==============================
|
|
306
|
+
//
|
|
307
|
+
// The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
|
|
308
|
+
// This file re-exports them and layers r3f's RootState-aware frame state on top,
|
|
309
|
+
// so existing `#types` imports across the codebase keep resolving unchanged.
|
|
297
310
|
|
|
298
311
|
|
|
299
312
|
|
|
300
|
-
//
|
|
313
|
+
// Frame State (r3f-specific) --------------------------------
|
|
301
314
|
|
|
302
315
|
/**
|
|
303
|
-
*
|
|
304
|
-
*/
|
|
305
|
-
interface UseFrameNextOptions {
|
|
306
|
-
/** Optional stable id for the job. Auto-generated if not provided */
|
|
307
|
-
id?: string
|
|
308
|
-
/** Named phase to run in. Default: 'update' */
|
|
309
|
-
phase?: string
|
|
310
|
-
/** Run before this phase or job id */
|
|
311
|
-
before?: string | string[]
|
|
312
|
-
/** Run after this phase or job id */
|
|
313
|
-
after?: string | string[]
|
|
314
|
-
/** Priority within phase. Higher runs first. Default: 0 */
|
|
315
|
-
priority?: number
|
|
316
|
-
/** Max frames per second for this job */
|
|
317
|
-
fps?: number
|
|
318
|
-
/** If true, skip frames when behind. If false, try to catch up. Default: true */
|
|
319
|
-
drop?: boolean
|
|
320
|
-
/** Enable/disable without unregistering. Default: true */
|
|
321
|
-
enabled?: boolean
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/** Alias for UseFrameNextOptions */
|
|
325
|
-
type UseFrameOptions = UseFrameNextOptions
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Options for addPhase
|
|
329
|
-
*/
|
|
330
|
-
interface AddPhaseOptions {
|
|
331
|
-
/** Insert this phase before the specified phase */
|
|
332
|
-
before?: string
|
|
333
|
-
/** Insert this phase after the specified phase */
|
|
334
|
-
after?: string
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// Frame State --------------------------------
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Timing-only state for independent/outside mode (no RootState)
|
|
341
|
-
*/
|
|
342
|
-
interface FrameTimingState {
|
|
343
|
-
/** High-resolution timestamp from RAF (ms) */
|
|
344
|
-
time: number
|
|
345
|
-
/** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
346
|
-
delta: number
|
|
347
|
-
/** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
348
|
-
elapsed: number
|
|
349
|
-
/** Incrementing frame counter */
|
|
350
|
-
frame: number
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* State passed to useFrame callbacks (extends RootState with timing)
|
|
316
|
+
* State passed to useFrame callbacks (extends RootState with timing).
|
|
355
317
|
*/
|
|
356
318
|
interface FrameNextState extends RootState, FrameTimingState {}
|
|
357
319
|
|
|
358
320
|
/** Alias for FrameNextState */
|
|
359
321
|
type FrameState = FrameNextState
|
|
360
322
|
|
|
361
|
-
//
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Options for registerRoot
|
|
365
|
-
*/
|
|
366
|
-
interface RootOptions {
|
|
367
|
-
/** State provider for callbacks. Optional in independent mode. */
|
|
368
|
-
getState?: () => any
|
|
369
|
-
/** Error handler for job errors. Falls back to console.error if not provided. */
|
|
370
|
-
onError?: (error: Error) => void
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// Callback Types --------------------------------
|
|
323
|
+
// Callback Types (r3f-specific) --------------------------------
|
|
374
324
|
|
|
375
325
|
/**
|
|
376
|
-
* Callback function for useFrame
|
|
326
|
+
* Callback function for useFrame. Receives the full r3f RootState plus timing.
|
|
377
327
|
*/
|
|
378
|
-
type FrameNextCallback =
|
|
328
|
+
type FrameNextCallback = FrameCallback$1<RootState>
|
|
379
329
|
|
|
380
330
|
/** Alias for FrameNextCallback */
|
|
381
331
|
type FrameCallback = FrameNextCallback
|
|
382
332
|
|
|
383
|
-
// Controls returned from useFrame --------------------------------
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* Controls object returned from useFrame hook
|
|
387
|
-
*/
|
|
388
|
-
interface FrameNextControls {
|
|
389
|
-
/** The job's unique ID */
|
|
390
|
-
id: string
|
|
391
|
-
/** Access to the global scheduler for frame loop control */
|
|
392
|
-
scheduler: SchedulerApi
|
|
393
|
-
/** Manually step this job only (bypasses FPS limiting) */
|
|
394
|
-
step(timestamp?: number): void
|
|
395
|
-
/** Manually step ALL jobs in the scheduler */
|
|
396
|
-
stepAll(timestamp?: number): void
|
|
397
|
-
/** Pause this job (set enabled=false) */
|
|
398
|
-
pause(): void
|
|
399
|
-
/** Resume this job (set enabled=true) */
|
|
400
|
-
resume(): void
|
|
401
|
-
/** Reactive paused state - automatically triggers re-render when changed */
|
|
402
|
-
isPaused: boolean
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/** Alias for FrameNextControls */
|
|
406
|
-
type FrameControls = FrameNextControls
|
|
407
|
-
|
|
408
|
-
// Scheduler Interface --------------------------------
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Public interface for the global Scheduler
|
|
412
|
-
*/
|
|
413
|
-
interface SchedulerApi {
|
|
414
|
-
//* Phase Management --------------------------------
|
|
415
|
-
|
|
416
|
-
/** Add a named phase to the scheduler */
|
|
417
|
-
addPhase(name: string, options?: AddPhaseOptions): void
|
|
418
|
-
/** Get the ordered list of phase names */
|
|
419
|
-
readonly phases: string[]
|
|
420
|
-
/** Check if a phase exists */
|
|
421
|
-
hasPhase(name: string): boolean
|
|
422
|
-
|
|
423
|
-
//* Root Management --------------------------------
|
|
424
|
-
|
|
425
|
-
/** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
|
|
426
|
-
registerRoot(id: string, options?: RootOptions): () => void
|
|
427
|
-
/** Unregister a root */
|
|
428
|
-
unregisterRoot(id: string): void
|
|
429
|
-
/** Generate a unique root ID */
|
|
430
|
-
generateRootId(): string
|
|
431
|
-
/** Get the number of registered roots */
|
|
432
|
-
getRootCount(): number
|
|
433
|
-
/** Check if any root is registered and ready */
|
|
434
|
-
readonly isReady: boolean
|
|
435
|
-
/** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
|
|
436
|
-
onRootReady(callback: () => void): () => void
|
|
437
|
-
|
|
438
|
-
//* Job Registration --------------------------------
|
|
439
|
-
|
|
440
|
-
/** Register a job with the scheduler (returns unsubscribe function) */
|
|
441
|
-
register(
|
|
442
|
-
callback: FrameNextCallback,
|
|
443
|
-
options?: {
|
|
444
|
-
id?: string
|
|
445
|
-
rootId?: string
|
|
446
|
-
phase?: string
|
|
447
|
-
before?: string | string[]
|
|
448
|
-
after?: string | string[]
|
|
449
|
-
priority?: number
|
|
450
|
-
fps?: number
|
|
451
|
-
drop?: boolean
|
|
452
|
-
enabled?: boolean
|
|
453
|
-
},
|
|
454
|
-
): () => void
|
|
455
|
-
/** Update a job's options */
|
|
456
|
-
updateJob(
|
|
457
|
-
id: string,
|
|
458
|
-
options: {
|
|
459
|
-
priority?: number
|
|
460
|
-
fps?: number
|
|
461
|
-
drop?: boolean
|
|
462
|
-
enabled?: boolean
|
|
463
|
-
phase?: string
|
|
464
|
-
before?: string | string[]
|
|
465
|
-
after?: string | string[]
|
|
466
|
-
},
|
|
467
|
-
): void
|
|
468
|
-
/** Unregister a job by ID */
|
|
469
|
-
unregister(id: string, rootId?: string): void
|
|
470
|
-
/** Get the number of registered jobs */
|
|
471
|
-
getJobCount(): number
|
|
472
|
-
/** Get all job IDs */
|
|
473
|
-
getJobIds(): string[]
|
|
474
|
-
|
|
475
|
-
//* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
|
|
476
|
-
|
|
477
|
-
/** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
|
|
478
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
|
|
479
|
-
|
|
480
|
-
//* Idle Callbacks (for legacy addTail) --------------------------------
|
|
481
|
-
|
|
482
|
-
/** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
|
|
483
|
-
onIdle(callback: (timestamp: number) => void): () => void
|
|
484
|
-
|
|
485
|
-
//* Frame Loop Control --------------------------------
|
|
486
|
-
|
|
487
|
-
/** Start the scheduler loop */
|
|
488
|
-
start(): void
|
|
489
|
-
/** Stop the scheduler loop */
|
|
490
|
-
stop(): void
|
|
491
|
-
/** Check if the scheduler is running */
|
|
492
|
-
readonly isRunning: boolean
|
|
493
|
-
/** Get/set the frameloop mode ('always', 'demand', 'never') */
|
|
494
|
-
frameloop: Frameloop
|
|
495
|
-
/** Independent mode - runs without Canvas, callbacks receive timing-only state */
|
|
496
|
-
independent: boolean
|
|
497
|
-
|
|
498
|
-
//* Manual Stepping --------------------------------
|
|
499
|
-
|
|
500
|
-
/** Manually step all jobs once (for frameloop='never' or testing) */
|
|
501
|
-
step(timestamp?: number): void
|
|
502
|
-
/** Manually step a single job by ID */
|
|
503
|
-
stepJob(id: string, timestamp?: number): void
|
|
504
|
-
/** Request frame(s) to be rendered (for frameloop='demand') */
|
|
505
|
-
invalidate(frames?: number): void
|
|
506
|
-
|
|
507
|
-
//* Per-Job Control --------------------------------
|
|
508
|
-
|
|
509
|
-
/** Check if a job is paused */
|
|
510
|
-
isJobPaused(id: string): boolean
|
|
511
|
-
/** Pause a job */
|
|
512
|
-
pauseJob(id: string): void
|
|
513
|
-
/** Resume a job */
|
|
514
|
-
resumeJob(id: string): void
|
|
515
|
-
/** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
|
|
516
|
-
subscribeJobState(id: string, listener: () => void): () => void
|
|
517
|
-
}
|
|
518
|
-
|
|
519
333
|
//* Buffer Types (useBuffers) ========================================
|
|
520
334
|
|
|
521
335
|
/**
|
|
@@ -689,9 +503,21 @@ interface InternalState {
|
|
|
689
503
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
690
504
|
*/
|
|
691
505
|
canvasTarget?: CanvasTarget
|
|
506
|
+
/**
|
|
507
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
508
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
509
|
+
*
|
|
510
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
511
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
512
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
513
|
+
* invalidate some other canvas's descriptor instead.
|
|
514
|
+
*
|
|
515
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
516
|
+
*/
|
|
517
|
+
canvasTargetSizeDirty?: boolean
|
|
692
518
|
/**
|
|
693
519
|
* Whether multi-canvas rendering is active.
|
|
694
|
-
* True when any canvas uses `
|
|
520
|
+
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
695
521
|
* When true, setCanvasTarget is called before each render.
|
|
696
522
|
*/
|
|
697
523
|
isMultiCanvas?: boolean
|
|
@@ -789,8 +615,8 @@ interface RootState {
|
|
|
789
615
|
setSize: (width?: number, height?: number, top?: number, left?: number) => void
|
|
790
616
|
/** Shortcut to manual setting the pixel ratio */
|
|
791
617
|
setDpr: (dpr: Dpr) => void
|
|
792
|
-
/** Shortcut to setting frameloop flags */
|
|
793
|
-
setFrameloop: (frameloop
|
|
618
|
+
/** Shortcut to setting frameloop flags. No args resets to 'always'. */
|
|
619
|
+
setFrameloop: (frameloop?: Frameloop) => void
|
|
794
620
|
/** Set error state to propagate to error boundary */
|
|
795
621
|
setError: (error: Error | null) => void
|
|
796
622
|
/** Current error state (null when no error) */
|
|
@@ -803,10 +629,12 @@ interface RootState {
|
|
|
803
629
|
buffers: BufferStore
|
|
804
630
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
805
631
|
gpuStorage: StorageStore
|
|
806
|
-
/** Global
|
|
807
|
-
textures: Map<string,
|
|
632
|
+
/** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
|
|
633
|
+
textures: Map<string, THREE$1.Texture>
|
|
634
|
+
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
635
|
+
_textureRefs: Map<string, number>
|
|
808
636
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
809
|
-
renderPipeline:
|
|
637
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
810
638
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
811
639
|
passes: Record<string, any>
|
|
812
640
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
@@ -1099,8 +927,6 @@ interface Instance<O = any> {
|
|
|
1099
927
|
attach?: AttachType<O>
|
|
1100
928
|
previousAttach?: any
|
|
1101
929
|
isHidden: boolean
|
|
1102
|
-
/** Deferred ref props to apply in commitMount */
|
|
1103
|
-
deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
|
|
1104
930
|
/** Set of props that have been applied via once() */
|
|
1105
931
|
appliedOnce?: Set<string>
|
|
1106
932
|
}
|
|
@@ -1337,10 +1163,21 @@ type RenderTargetOptions = RenderTargetOptions$1
|
|
|
1337
1163
|
//* Global Types ==============================
|
|
1338
1164
|
|
|
1339
1165
|
declare global {
|
|
1340
|
-
/**
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1166
|
+
/**
|
|
1167
|
+
* Uniform node type.
|
|
1168
|
+
*
|
|
1169
|
+
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1170
|
+
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1171
|
+
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1172
|
+
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1173
|
+
* arity when three made `UniformNode` two-parameter.
|
|
1174
|
+
*
|
|
1175
|
+
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1176
|
+
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1177
|
+
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1178
|
+
* installed three instead of needing to be mirrored by hand.
|
|
1179
|
+
*/
|
|
1180
|
+
type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
|
|
1344
1181
|
|
|
1345
1182
|
/**
|
|
1346
1183
|
* ShaderCallable - the return type of Fn()
|
|
@@ -1485,13 +1322,14 @@ declare module 'three/tsl' {
|
|
|
1485
1322
|
): ShaderCallable<R>
|
|
1486
1323
|
}
|
|
1487
1324
|
|
|
1488
|
-
/**
|
|
1489
|
-
* RenderPipeline Types for useRenderPipeline hook (WebGPU only)
|
|
1490
|
-
*/
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
1325
|
declare global {
|
|
1326
|
+
/**
|
|
1327
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1328
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1329
|
+
* is r185, so the new name is the only one.
|
|
1330
|
+
*/
|
|
1331
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1332
|
+
|
|
1495
1333
|
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1496
1334
|
type PassRecord = Record<string, any>
|
|
1497
1335
|
|
|
@@ -1506,7 +1344,7 @@ declare global {
|
|
|
1506
1344
|
/** Current passes from state */
|
|
1507
1345
|
passes: PassRecord
|
|
1508
1346
|
/** RenderPipeline instance (null if not initialized) */
|
|
1509
|
-
renderPipeline:
|
|
1347
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
1510
1348
|
/** Clear all passes from state */
|
|
1511
1349
|
clearPasses: () => void
|
|
1512
1350
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
@@ -1518,146 +1356,6 @@ declare global {
|
|
|
1518
1356
|
}
|
|
1519
1357
|
}
|
|
1520
1358
|
|
|
1521
|
-
//* useFrameNext Types ==============================
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
//* Global Type Declarations ==============================
|
|
1526
|
-
|
|
1527
|
-
declare global {
|
|
1528
|
-
// Job --------------------------------
|
|
1529
|
-
|
|
1530
|
-
/**
|
|
1531
|
-
* Internal job representation in the scheduler
|
|
1532
|
-
*/
|
|
1533
|
-
interface Job {
|
|
1534
|
-
/** Unique identifier */
|
|
1535
|
-
id: string
|
|
1536
|
-
/** The callback to execute */
|
|
1537
|
-
callback: FrameNextCallback
|
|
1538
|
-
/** Phase this job belongs to */
|
|
1539
|
-
phase: string
|
|
1540
|
-
/** Run before these phases/job ids */
|
|
1541
|
-
before: Set<string>
|
|
1542
|
-
/** Run after these phases/job ids */
|
|
1543
|
-
after: Set<string>
|
|
1544
|
-
/** Priority within phase (higher first) */
|
|
1545
|
-
priority: number
|
|
1546
|
-
/** Insertion order for deterministic tie-breaking */
|
|
1547
|
-
index: number
|
|
1548
|
-
/** Max FPS for this job (undefined = no limit) */
|
|
1549
|
-
fps?: number
|
|
1550
|
-
/** Drop frames when behind (true) or catch up (false) */
|
|
1551
|
-
drop: boolean
|
|
1552
|
-
/** Last run timestamp (ms) */
|
|
1553
|
-
lastRun?: number
|
|
1554
|
-
/** Whether job is enabled */
|
|
1555
|
-
enabled: boolean
|
|
1556
|
-
/** Internal flag: system jobs (like default render) don't block user render takeover */
|
|
1557
|
-
system?: boolean
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
// Phase Graph --------------------------------
|
|
1561
|
-
|
|
1562
|
-
/**
|
|
1563
|
-
* A node in the phase graph
|
|
1564
|
-
*/
|
|
1565
|
-
interface PhaseNode {
|
|
1566
|
-
/** Phase name */
|
|
1567
|
-
name: string
|
|
1568
|
-
/** Whether this was auto-generated from a before/after constraint */
|
|
1569
|
-
isAutoGenerated: boolean
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
/**
|
|
1573
|
-
* Options for creating a job from hook options
|
|
1574
|
-
*/
|
|
1575
|
-
interface JobOptions {
|
|
1576
|
-
id?: string
|
|
1577
|
-
phase?: string
|
|
1578
|
-
before?: string | string[]
|
|
1579
|
-
after?: string | string[]
|
|
1580
|
-
priority?: number
|
|
1581
|
-
fps?: number
|
|
1582
|
-
drop?: boolean
|
|
1583
|
-
enabled?: boolean
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
// Frame Loop State --------------------------------
|
|
1587
|
-
|
|
1588
|
-
/**
|
|
1589
|
-
* Internal frame loop state
|
|
1590
|
-
*/
|
|
1591
|
-
interface FrameLoopState {
|
|
1592
|
-
/** Whether the loop is running */
|
|
1593
|
-
running: boolean
|
|
1594
|
-
/** Current RAF handle */
|
|
1595
|
-
rafHandle: number | null
|
|
1596
|
-
/** Last frame timestamp in ms (null = uninitialized) */
|
|
1597
|
-
lastTime: number | null
|
|
1598
|
-
/** Frame counter */
|
|
1599
|
-
frameCount: number
|
|
1600
|
-
/** Elapsed time since first frame in ms */
|
|
1601
|
-
elapsedTime: number
|
|
1602
|
-
/** createdAt timestamp in ms */
|
|
1603
|
-
createdAt: number
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
// Root Entry --------------------------------
|
|
1607
|
-
|
|
1608
|
-
/**
|
|
1609
|
-
* Internal representation of a registered root (Canvas).
|
|
1610
|
-
* Tracks jobs and manages rebuild state for this root.
|
|
1611
|
-
* @internal
|
|
1612
|
-
*/
|
|
1613
|
-
interface RootEntry {
|
|
1614
|
-
/** Unique identifier for this root */
|
|
1615
|
-
id: string
|
|
1616
|
-
/** Function to get the root's current state. Returns any to support independent mode. */
|
|
1617
|
-
getState: () => any
|
|
1618
|
-
/** Map of job IDs to Job objects */
|
|
1619
|
-
jobs: Map<string, Job>
|
|
1620
|
-
/** Cached sorted job list for execution order */
|
|
1621
|
-
sortedJobs: Job[]
|
|
1622
|
-
/** Whether sortedJobs needs rebuilding */
|
|
1623
|
-
needsRebuild: boolean
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
/**
|
|
1627
|
-
* Internal representation of a global job (deprecated API).
|
|
1628
|
-
* Global jobs run once per frame, not per-root.
|
|
1629
|
-
* Used by legacy addEffect/addAfterEffect APIs.
|
|
1630
|
-
* @internal
|
|
1631
|
-
* @deprecated Use useFrame with phases instead
|
|
1632
|
-
*/
|
|
1633
|
-
interface GlobalJob {
|
|
1634
|
-
/** Unique identifier for this global job */
|
|
1635
|
-
id: string
|
|
1636
|
-
/** Callback invoked with RAF timestamp in ms */
|
|
1637
|
-
callback: (timestamp: number) => void
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
// HMR Support --------------------------------
|
|
1641
|
-
|
|
1642
|
-
/**
|
|
1643
|
-
* Hot Module Replacement data structure for preserving scheduler state
|
|
1644
|
-
* @internal
|
|
1645
|
-
*/
|
|
1646
|
-
interface HMRData {
|
|
1647
|
-
/** Shared data object for storing values across reloads */
|
|
1648
|
-
data: Record<string, any>
|
|
1649
|
-
/** Optional function to accept HMR updates */
|
|
1650
|
-
accept?: () => void
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
// Default Phases --------------------------------
|
|
1654
|
-
|
|
1655
|
-
/**
|
|
1656
|
-
* Default phase names for the scheduler
|
|
1657
|
-
*/
|
|
1658
|
-
type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
|
|
1659
|
-
}
|
|
1660
|
-
|
|
1661
1359
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
1662
1360
|
|
|
1663
1361
|
interface MathRepresentation {
|
|
@@ -1827,7 +1525,7 @@ declare namespace three_d {
|
|
|
1827
1525
|
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
1828
1526
|
*
|
|
1829
1527
|
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
1830
|
-
* Secondary canvas: Has `
|
|
1528
|
+
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
1831
1529
|
*/
|
|
1832
1530
|
|
|
1833
1531
|
interface PrimaryCanvasEntry {
|
|
@@ -1895,12 +1593,23 @@ type EnvironmentLoaderProps = {
|
|
|
1895
1593
|
* const texture = useEnvironment({ preset: 'sunset' })
|
|
1896
1594
|
* ```
|
|
1897
1595
|
*/
|
|
1898
|
-
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture
|
|
1596
|
+
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
|
|
1899
1597
|
declare namespace useEnvironment {
|
|
1900
1598
|
var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
|
|
1901
1599
|
var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
|
|
1902
1600
|
}
|
|
1903
|
-
|
|
1601
|
+
/**
|
|
1602
|
+
* Options accepted by `useEnvironment.preload`.
|
|
1603
|
+
*
|
|
1604
|
+
* `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
|
|
1605
|
+
* applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
|
|
1606
|
+
* advertise an option this function silently ignores.
|
|
1607
|
+
*
|
|
1608
|
+
* This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
|
|
1609
|
+
* `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
|
|
1610
|
+
* type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
|
|
1611
|
+
*/
|
|
1612
|
+
type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
|
|
1904
1613
|
type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
|
|
1905
1614
|
|
|
1906
1615
|
/**
|
|
@@ -1944,9 +1653,9 @@ type EnvironmentProps = {
|
|
|
1944
1653
|
blur?: number;
|
|
1945
1654
|
backgroundBlurriness?: number;
|
|
1946
1655
|
backgroundIntensity?: number;
|
|
1947
|
-
backgroundRotation?: Euler
|
|
1656
|
+
backgroundRotation?: Euler;
|
|
1948
1657
|
environmentIntensity?: number;
|
|
1949
|
-
environmentRotation?: Euler
|
|
1658
|
+
environmentRotation?: Euler;
|
|
1950
1659
|
map?: Texture$1;
|
|
1951
1660
|
preset?: PresetsType;
|
|
1952
1661
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -2030,7 +1739,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
2030
1739
|
declare function EnvironmentPortal({ children, near, far, resolution, frames, map, background, blur, backgroundBlurriness, backgroundIntensity, backgroundRotation, environmentIntensity, environmentRotation, scene, files, path, preset, extensions, }: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
2031
1740
|
declare module '@react-three/fiber' {
|
|
2032
1741
|
interface ThreeElements {
|
|
2033
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1742
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
2034
1743
|
}
|
|
2035
1744
|
}
|
|
2036
1745
|
/**
|
|
@@ -2130,6 +1839,24 @@ declare module '@react-three/fiber' {
|
|
|
2130
1839
|
*/
|
|
2131
1840
|
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
2132
1841
|
|
|
1842
|
+
/**
|
|
1843
|
+
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
1844
|
+
*
|
|
1845
|
+
* When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
|
|
1846
|
+
* instance. Removing the old object from the interaction state and registering the new one from
|
|
1847
|
+
* scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
|
|
1848
|
+
* the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
|
|
1849
|
+
* is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
|
|
1850
|
+
* swap the user never asked to see (#3744).
|
|
1851
|
+
*
|
|
1852
|
+
* Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
|
|
1853
|
+
* left alone — releasing and re-acquiring it is precisely the glitch being avoided.
|
|
1854
|
+
*
|
|
1855
|
+
* Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
|
|
1856
|
+
* the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
|
|
1857
|
+
* cannot outlive the object it described.
|
|
1858
|
+
*/
|
|
1859
|
+
declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
|
|
2133
1860
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
2134
1861
|
declare function createEvents(store: RootStore): {
|
|
2135
1862
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
@@ -2150,419 +1877,13 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
|
|
|
2150
1877
|
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
2151
1878
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
2152
1879
|
*/
|
|
2153
|
-
declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
|
|
1880
|
+
declare function useLoader<I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void, cacheKey?: InputLike): I extends any[] ? LoaderResult<L>[] : LoaderResult<L>;
|
|
2154
1881
|
declare namespace useLoader {
|
|
2155
|
-
var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
|
|
2156
|
-
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
|
|
1882
|
+
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;
|
|
1883
|
+
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
|
|
2157
1884
|
var loader: typeof getLoader;
|
|
2158
1885
|
}
|
|
2159
1886
|
|
|
2160
|
-
/**
|
|
2161
|
-
* Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
|
|
2162
|
-
*
|
|
2163
|
-
* Features:
|
|
2164
|
-
* - Single RAF loop for entire application
|
|
2165
|
-
* - Root registration (multiple Canvas support)
|
|
2166
|
-
* - Global phases for addEffect/addAfterEffect (deprecated)
|
|
2167
|
-
* - Per-root job management with phases, priorities, FPS throttling
|
|
2168
|
-
* - onIdle callbacks for addTail (deprecated)
|
|
2169
|
-
* - Demand mode support via invalidate()
|
|
2170
|
-
*/
|
|
2171
|
-
declare class Scheduler {
|
|
2172
|
-
private static readonly INSTANCE_KEY;
|
|
2173
|
-
private static get instance();
|
|
2174
|
-
private static set instance(value);
|
|
2175
|
-
/**
|
|
2176
|
-
* Get the global scheduler instance (creates if doesn't exist).
|
|
2177
|
-
* Uses HMR data to preserve instance across hot reloads.
|
|
2178
|
-
* @returns {Scheduler} The singleton scheduler instance
|
|
2179
|
-
*/
|
|
2180
|
-
static get(): Scheduler;
|
|
2181
|
-
/**
|
|
2182
|
-
* Reset the singleton instance. Stops the loop and clears all state.
|
|
2183
|
-
* Primarily used for testing to ensure clean state between tests.
|
|
2184
|
-
* @returns {void}
|
|
2185
|
-
*/
|
|
2186
|
-
static reset(): void;
|
|
2187
|
-
private roots;
|
|
2188
|
-
private phaseGraph;
|
|
2189
|
-
private loopState;
|
|
2190
|
-
private stoppedTime;
|
|
2191
|
-
private nextRootIndex;
|
|
2192
|
-
private globalBeforeJobs;
|
|
2193
|
-
private globalAfterJobs;
|
|
2194
|
-
private nextGlobalIndex;
|
|
2195
|
-
private idleCallbacks;
|
|
2196
|
-
private nextJobIndex;
|
|
2197
|
-
private jobStateListeners;
|
|
2198
|
-
private pendingFrames;
|
|
2199
|
-
private _frameloop;
|
|
2200
|
-
private _independent;
|
|
2201
|
-
private errorHandler;
|
|
2202
|
-
private rootReadyCallbacks;
|
|
2203
|
-
get phases(): string[];
|
|
2204
|
-
get frameloop(): Frameloop;
|
|
2205
|
-
set frameloop(mode: Frameloop);
|
|
2206
|
-
get isRunning(): boolean;
|
|
2207
|
-
get isReady(): boolean;
|
|
2208
|
-
get independent(): boolean;
|
|
2209
|
-
set independent(value: boolean);
|
|
2210
|
-
constructor();
|
|
2211
|
-
/**
|
|
2212
|
-
* Register a root (Canvas) with the scheduler.
|
|
2213
|
-
* The first root to register starts the RAF loop (if frameloop='always').
|
|
2214
|
-
* @param {string} id - Unique identifier for this root
|
|
2215
|
-
* @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
|
|
2216
|
-
* @returns {() => void} Unsubscribe function to remove this root
|
|
2217
|
-
*/
|
|
2218
|
-
registerRoot(id: string, options?: RootOptions): () => void;
|
|
2219
|
-
/**
|
|
2220
|
-
* Unregister a root from the scheduler.
|
|
2221
|
-
* Cleans up all job state listeners for this root's jobs.
|
|
2222
|
-
* The last root to unregister stops the RAF loop.
|
|
2223
|
-
* @param {string} id - The root ID to unregister
|
|
2224
|
-
* @returns {void}
|
|
2225
|
-
*/
|
|
2226
|
-
unregisterRoot(id: string): void;
|
|
2227
|
-
/**
|
|
2228
|
-
* Subscribe to be notified when a root becomes available.
|
|
2229
|
-
* Fires immediately if a root already exists.
|
|
2230
|
-
* @param {() => void} callback - Function called when first root registers
|
|
2231
|
-
* @returns {() => void} Unsubscribe function
|
|
2232
|
-
*/
|
|
2233
|
-
onRootReady(callback: () => void): () => void;
|
|
2234
|
-
/**
|
|
2235
|
-
* Notify all registered root-ready callbacks.
|
|
2236
|
-
* Called when the first root registers.
|
|
2237
|
-
* @returns {void}
|
|
2238
|
-
* @private
|
|
2239
|
-
*/
|
|
2240
|
-
private notifyRootReady;
|
|
2241
|
-
/**
|
|
2242
|
-
* Ensure a default root exists for independent mode.
|
|
2243
|
-
* Creates a minimal root with no state provider.
|
|
2244
|
-
* @returns {void}
|
|
2245
|
-
* @private
|
|
2246
|
-
*/
|
|
2247
|
-
private ensureDefaultRoot;
|
|
2248
|
-
/**
|
|
2249
|
-
* Trigger error handling for job errors.
|
|
2250
|
-
* Uses the bound error handler if available, otherwise logs to console.
|
|
2251
|
-
* @param {Error} error - The error to handle
|
|
2252
|
-
* @returns {void}
|
|
2253
|
-
*/
|
|
2254
|
-
triggerError(error: Error): void;
|
|
2255
|
-
/**
|
|
2256
|
-
* Add a named phase to the scheduler's execution order.
|
|
2257
|
-
* Marks all roots for rebuild to incorporate the new phase.
|
|
2258
|
-
* @param {string} name - The phase name (e.g., 'physics', 'postprocess')
|
|
2259
|
-
* @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
|
|
2260
|
-
* @returns {void}
|
|
2261
|
-
* @example
|
|
2262
|
-
* scheduler.addPhase('physics', { before: 'update' });
|
|
2263
|
-
* scheduler.addPhase('postprocess', { after: 'render' });
|
|
2264
|
-
*/
|
|
2265
|
-
addPhase(name: string, options?: AddPhaseOptions): void;
|
|
2266
|
-
/**
|
|
2267
|
-
* Check if a phase exists in the scheduler.
|
|
2268
|
-
* @param {string} name - The phase name to check
|
|
2269
|
-
* @returns {boolean} True if the phase exists
|
|
2270
|
-
*/
|
|
2271
|
-
hasPhase(name: string): boolean;
|
|
2272
|
-
/**
|
|
2273
|
-
* Register a global job that runs once per frame (not per-root).
|
|
2274
|
-
* Used internally by deprecated addEffect/addAfterEffect APIs.
|
|
2275
|
-
* @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
|
|
2276
|
-
* @param {string} id - Unique identifier for this global job
|
|
2277
|
-
* @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
|
|
2278
|
-
* @returns {() => void} Unsubscribe function to remove this global job
|
|
2279
|
-
* @deprecated Use useFrame with phases instead
|
|
2280
|
-
*/
|
|
2281
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
|
|
2282
|
-
/**
|
|
2283
|
-
* Register an idle callback that fires when the loop stops.
|
|
2284
|
-
* Used internally by deprecated addTail API.
|
|
2285
|
-
* @param {(timestamp: number) => void} callback - Function called when loop becomes idle
|
|
2286
|
-
* @returns {() => void} Unsubscribe function to remove this idle callback
|
|
2287
|
-
* @deprecated Use demand mode with invalidate() instead
|
|
2288
|
-
*/
|
|
2289
|
-
onIdle(callback: (timestamp: number) => void): () => void;
|
|
2290
|
-
/**
|
|
2291
|
-
* Notify all registered idle callbacks.
|
|
2292
|
-
* Called when the loop stops in demand mode.
|
|
2293
|
-
* @param {number} timestamp - The RAF timestamp when idle occurred
|
|
2294
|
-
* @returns {void}
|
|
2295
|
-
* @private
|
|
2296
|
-
*/
|
|
2297
|
-
private notifyIdle;
|
|
2298
|
-
/**
|
|
2299
|
-
* Register a job (frame callback) with a specific root.
|
|
2300
|
-
* This is the core registration method used by useFrame internally.
|
|
2301
|
-
* @param {FrameNextCallback} callback - The function to call each frame
|
|
2302
|
-
* @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
|
|
2303
|
-
* @param {string} [options.rootId] - Target root ID (defaults to first registered root)
|
|
2304
|
-
* @param {string} [options.id] - Unique job ID (auto-generated if not provided)
|
|
2305
|
-
* @param {string} [options.phase] - Execution phase (defaults to 'update')
|
|
2306
|
-
* @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
|
|
2307
|
-
* @param {number} [options.fps] - FPS throttle limit
|
|
2308
|
-
* @param {boolean} [options.drop] - Drop frames when behind (default true)
|
|
2309
|
-
* @param {boolean} [options.enabled] - Whether job is active (default true)
|
|
2310
|
-
* @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
|
|
2311
|
-
* @returns {() => void} Unsubscribe function to remove this job
|
|
2312
|
-
*/
|
|
2313
|
-
register(callback: FrameNextCallback, options?: JobOptions & {
|
|
2314
|
-
rootId?: string;
|
|
2315
|
-
system?: boolean;
|
|
2316
|
-
}): () => void;
|
|
2317
|
-
/**
|
|
2318
|
-
* Unregister a job by its ID.
|
|
2319
|
-
* Searches all roots if rootId is not provided.
|
|
2320
|
-
* @param {string} id - The job ID to unregister
|
|
2321
|
-
* @param {string} [rootId] - Optional root ID to search (searches all if not provided)
|
|
2322
|
-
* @returns {void}
|
|
2323
|
-
*/
|
|
2324
|
-
unregister(id: string, rootId?: string): void;
|
|
2325
|
-
/**
|
|
2326
|
-
* Update a job's options dynamically.
|
|
2327
|
-
* Searches all roots to find the job by ID.
|
|
2328
|
-
* Phase/constraint changes trigger a rebuild of the sorted job list.
|
|
2329
|
-
* @param {string} id - The job ID to update
|
|
2330
|
-
* @param {Partial<JobOptions>} options - The options to update
|
|
2331
|
-
* @returns {void}
|
|
2332
|
-
*/
|
|
2333
|
-
updateJob(id: string, options: Partial<JobOptions>): void;
|
|
2334
|
-
/**
|
|
2335
|
-
* Check if a job is currently paused (disabled).
|
|
2336
|
-
* @param {string} id - The job ID to check
|
|
2337
|
-
* @returns {boolean} True if the job exists and is paused
|
|
2338
|
-
*/
|
|
2339
|
-
isJobPaused(id: string): boolean;
|
|
2340
|
-
/**
|
|
2341
|
-
* Subscribe to state changes for a specific job.
|
|
2342
|
-
* Listener is called when job is paused or resumed.
|
|
2343
|
-
* @param {string} id - The job ID to subscribe to
|
|
2344
|
-
* @param {() => void} listener - Callback invoked on state changes
|
|
2345
|
-
* @returns {() => void} Unsubscribe function
|
|
2346
|
-
*/
|
|
2347
|
-
subscribeJobState(id: string, listener: () => void): () => void;
|
|
2348
|
-
/**
|
|
2349
|
-
* Notify all listeners that a job's state has changed.
|
|
2350
|
-
* @param {string} id - The job ID that changed
|
|
2351
|
-
* @returns {void}
|
|
2352
|
-
* @private
|
|
2353
|
-
*/
|
|
2354
|
-
private notifyJobStateChange;
|
|
2355
|
-
/**
|
|
2356
|
-
* Pause a job by ID (sets enabled=false).
|
|
2357
|
-
* Notifies any subscribed state listeners.
|
|
2358
|
-
* @param {string} id - The job ID to pause
|
|
2359
|
-
* @returns {void}
|
|
2360
|
-
*/
|
|
2361
|
-
pauseJob(id: string): void;
|
|
2362
|
-
/**
|
|
2363
|
-
* Resume a paused job by ID (sets enabled=true).
|
|
2364
|
-
* Resets job timing to prevent frame accumulation.
|
|
2365
|
-
* Notifies any subscribed state listeners.
|
|
2366
|
-
* @param {string} id - The job ID to resume
|
|
2367
|
-
* @returns {void}
|
|
2368
|
-
*/
|
|
2369
|
-
resumeJob(id: string): void;
|
|
2370
|
-
/**
|
|
2371
|
-
* Start the requestAnimationFrame loop.
|
|
2372
|
-
* Resets timing state (elapsedTime, frameCount) on start.
|
|
2373
|
-
* No-op if already running.
|
|
2374
|
-
* @returns {void}
|
|
2375
|
-
*/
|
|
2376
|
-
start(): void;
|
|
2377
|
-
/**
|
|
2378
|
-
* Stop the requestAnimationFrame loop.
|
|
2379
|
-
* Cancels any pending RAF callback.
|
|
2380
|
-
* No-op if not running.
|
|
2381
|
-
* @returns {void}
|
|
2382
|
-
*/
|
|
2383
|
-
stop(): void;
|
|
2384
|
-
/**
|
|
2385
|
-
* Request frames to be rendered in demand mode.
|
|
2386
|
-
* Accumulates pending frames (capped at 60) and starts the loop if not running.
|
|
2387
|
-
* No-op if frameloop is not 'demand'.
|
|
2388
|
-
* @param {number} [frames=1] - Number of frames to request
|
|
2389
|
-
* @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
|
|
2390
|
-
* - `false` (default): Sets pending frames to the specified value (replaces existing count)
|
|
2391
|
-
* - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
|
|
2392
|
-
* @returns {void}
|
|
2393
|
-
* @example
|
|
2394
|
-
* // Request a single frame render
|
|
2395
|
-
* scheduler.invalidate();
|
|
2396
|
-
*
|
|
2397
|
-
* @example
|
|
2398
|
-
* // Request 5 frames (e.g., for animations)
|
|
2399
|
-
* scheduler.invalidate(5);
|
|
2400
|
-
*
|
|
2401
|
-
* @example
|
|
2402
|
-
* // Set pending frames to exactly 3 (don't stack with existing)
|
|
2403
|
-
* scheduler.invalidate(3, false);
|
|
2404
|
-
*
|
|
2405
|
-
* @example
|
|
2406
|
-
* // Add 2 more frames to existing pending count
|
|
2407
|
-
* scheduler.invalidate(2, true);
|
|
2408
|
-
*/
|
|
2409
|
-
invalidate(frames?: number, stackFrames?: boolean): void;
|
|
2410
|
-
/**
|
|
2411
|
-
* Reset timing state for deterministic testing.
|
|
2412
|
-
* Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
|
|
2413
|
-
* @returns {void}
|
|
2414
|
-
*/
|
|
2415
|
-
resetTiming(): void;
|
|
2416
|
-
/**
|
|
2417
|
-
* Manually execute a single frame for all roots.
|
|
2418
|
-
* Useful for frameloop='never' mode or testing scenarios.
|
|
2419
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2420
|
-
* @returns {void}
|
|
2421
|
-
* @example
|
|
2422
|
-
* // Manual control mode
|
|
2423
|
-
* scheduler.frameloop = 'never';
|
|
2424
|
-
* scheduler.step(); // Execute one frame
|
|
2425
|
-
*/
|
|
2426
|
-
step(timestamp?: number): void;
|
|
2427
|
-
/**
|
|
2428
|
-
* Manually execute a single job by its ID.
|
|
2429
|
-
* Useful for testing individual job callbacks in isolation.
|
|
2430
|
-
* @param {string} id - The job ID to step
|
|
2431
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2432
|
-
* @returns {void}
|
|
2433
|
-
*/
|
|
2434
|
-
stepJob(id: string, timestamp?: number): void;
|
|
2435
|
-
/**
|
|
2436
|
-
* Main RAF loop callback.
|
|
2437
|
-
* Executes frame, handles demand mode, and schedules next frame.
|
|
2438
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2439
|
-
* @returns {void}
|
|
2440
|
-
* @private
|
|
2441
|
-
*/
|
|
2442
|
-
private loop;
|
|
2443
|
-
/**
|
|
2444
|
-
* Execute a single frame across all roots.
|
|
2445
|
-
* Order: globalBefore → each root's jobs → globalAfter
|
|
2446
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2447
|
-
* @returns {void}
|
|
2448
|
-
* @private
|
|
2449
|
-
*/
|
|
2450
|
-
private executeFrame;
|
|
2451
|
-
/**
|
|
2452
|
-
* Run all global jobs from a job map.
|
|
2453
|
-
* Catches and logs errors without stopping execution.
|
|
2454
|
-
* @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
|
|
2455
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2456
|
-
* @returns {void}
|
|
2457
|
-
* @private
|
|
2458
|
-
*/
|
|
2459
|
-
private runGlobalJobs;
|
|
2460
|
-
/**
|
|
2461
|
-
* Execute all jobs for a single root in sorted order.
|
|
2462
|
-
* Rebuilds sorted job list if needed, then dispatches each job.
|
|
2463
|
-
* Errors are caught and propagated via triggerError.
|
|
2464
|
-
* @param {RootEntry} root - The root entry to tick
|
|
2465
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2466
|
-
* @param {number} delta - Time since last frame in seconds
|
|
2467
|
-
* @returns {void}
|
|
2468
|
-
* @private
|
|
2469
|
-
*/
|
|
2470
|
-
private tickRoot;
|
|
2471
|
-
/**
|
|
2472
|
-
* Get the total number of registered jobs across all roots.
|
|
2473
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2474
|
-
* @returns {number} Total job count
|
|
2475
|
-
*/
|
|
2476
|
-
getJobCount(): number;
|
|
2477
|
-
/**
|
|
2478
|
-
* Get all registered job IDs across all roots.
|
|
2479
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2480
|
-
* @returns {string[]} Array of all job IDs
|
|
2481
|
-
*/
|
|
2482
|
-
getJobIds(): string[];
|
|
2483
|
-
/**
|
|
2484
|
-
* Get the number of registered roots (Canvas instances).
|
|
2485
|
-
* @returns {number} Number of registered roots
|
|
2486
|
-
*/
|
|
2487
|
-
getRootCount(): number;
|
|
2488
|
-
/**
|
|
2489
|
-
* Check if any user (non-system) jobs are registered in a specific phase.
|
|
2490
|
-
* Used by the default render job to know if a user has taken over rendering.
|
|
2491
|
-
*
|
|
2492
|
-
* @param phase The phase to check
|
|
2493
|
-
* @param rootId Optional root ID to check (checks all roots if not provided)
|
|
2494
|
-
* @returns true if any user jobs exist in the phase
|
|
2495
|
-
*/
|
|
2496
|
-
hasUserJobsInPhase(phase: string, rootId?: string): boolean;
|
|
2497
|
-
/**
|
|
2498
|
-
* Generate a unique root ID for automatic root registration.
|
|
2499
|
-
* @returns {string} A unique root ID in the format 'root_N'
|
|
2500
|
-
*/
|
|
2501
|
-
generateRootId(): string;
|
|
2502
|
-
/**
|
|
2503
|
-
* Generate a unique job ID.
|
|
2504
|
-
* @returns {string} A unique job ID in the format 'job_N'
|
|
2505
|
-
* @private
|
|
2506
|
-
*/
|
|
2507
|
-
private generateJobId;
|
|
2508
|
-
/**
|
|
2509
|
-
* Normalize before/after constraints to a Set.
|
|
2510
|
-
* Handles undefined, single string, or array inputs.
|
|
2511
|
-
* @param {string | string[] | undefined} value - The constraint value(s)
|
|
2512
|
-
* @returns {Set<string>} Normalized Set of constraint strings
|
|
2513
|
-
* @private
|
|
2514
|
-
*/
|
|
2515
|
-
private normalizeConstraints;
|
|
2516
|
-
}
|
|
2517
|
-
/**
|
|
2518
|
-
* Get the global scheduler instance.
|
|
2519
|
-
* Creates one if it doesn't exist.
|
|
2520
|
-
*/
|
|
2521
|
-
declare const getScheduler: () => Scheduler;
|
|
2522
|
-
|
|
2523
|
-
/**
|
|
2524
|
-
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
2525
|
-
*
|
|
2526
|
-
* Works both inside and outside Canvas context:
|
|
2527
|
-
* - Inside Canvas: Full RootState (gl, scene, camera, etc.)
|
|
2528
|
-
* - Outside Canvas (waiting mode): Waits for Canvas to mount, then gets full state
|
|
2529
|
-
* - Outside Canvas (independent mode): Fires immediately with timing-only state
|
|
2530
|
-
*
|
|
2531
|
-
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
2532
|
-
*
|
|
2533
|
-
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
2534
|
-
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
2535
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
2536
|
-
*
|
|
2537
|
-
* @example
|
|
2538
|
-
* // Simple priority (backwards compat)
|
|
2539
|
-
* useFrame((state, delta) => { ... }, 5)
|
|
2540
|
-
*
|
|
2541
|
-
* @example
|
|
2542
|
-
* // With phase-based ordering
|
|
2543
|
-
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
2544
|
-
*
|
|
2545
|
-
* @example
|
|
2546
|
-
* // Outside Canvas - waits for Canvas to mount
|
|
2547
|
-
* function UI() {
|
|
2548
|
-
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
2549
|
-
* return <button>...</button>;
|
|
2550
|
-
* }
|
|
2551
|
-
*
|
|
2552
|
-
* @example
|
|
2553
|
-
* // Independent mode - no Canvas needed
|
|
2554
|
-
* getScheduler().independent = true;
|
|
2555
|
-
* useFrame((state, delta) => { updateGame(delta) });
|
|
2556
|
-
*
|
|
2557
|
-
* @example
|
|
2558
|
-
* // Scheduler-only access (no callback)
|
|
2559
|
-
* const { scheduler } = useFrame()
|
|
2560
|
-
* scheduler.pauseJob('some-job-id')
|
|
2561
|
-
*
|
|
2562
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
2563
|
-
*/
|
|
2564
|
-
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
2565
|
-
|
|
2566
1887
|
declare const IsObject: (url: unknown) => url is Record<string, string>;
|
|
2567
1888
|
type TextureArray<T> = T extends string[] ? Texture$1[] : never;
|
|
2568
1889
|
type TextureRecord<T> = T extends Record<string, string> ? {
|
|
@@ -2575,11 +1896,16 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
|
|
|
2575
1896
|
/** Callback when texture(s) finish loading */
|
|
2576
1897
|
onLoad?: (texture: MappedTextureType<Url>) => void;
|
|
2577
1898
|
/**
|
|
2578
|
-
*
|
|
2579
|
-
* When true:
|
|
1899
|
+
* Register the texture(s) in R3F's global texture registry for access via useTextures().
|
|
1900
|
+
* When true (the default):
|
|
2580
1901
|
* - Textures persist until explicitly disposed
|
|
2581
|
-
* -
|
|
2582
|
-
*
|
|
1902
|
+
* - On mount, returns existing registered textures if available (preserving modifications like colorSpace)
|
|
1903
|
+
*
|
|
1904
|
+
* Reads are taken once at mount — a mounted `useTexture` does not re-render when the registry
|
|
1905
|
+
* changes. To react to registry swaps, use `useTextures(s => s.get(key))` instead.
|
|
1906
|
+
*
|
|
1907
|
+
* Pass `false` to opt out of registry enrollment entirely.
|
|
1908
|
+
* @default true
|
|
2583
1909
|
*/
|
|
2584
1910
|
cache?: boolean;
|
|
2585
1911
|
};
|
|
@@ -2603,15 +1929,18 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
|
|
|
2603
1929
|
* normal: '/normal.png'
|
|
2604
1930
|
* })
|
|
2605
1931
|
*
|
|
2606
|
-
* //
|
|
2607
|
-
* //
|
|
2608
|
-
* const diffuse = useTexture('/diffuse.png'
|
|
1932
|
+
* // Textures are registered in the global registry by default — the same texture
|
|
1933
|
+
* // object is shared across components and modifications (colorSpace, wrapS, etc.) are preserved
|
|
1934
|
+
* const diffuse = useTexture('/diffuse.png')
|
|
2609
1935
|
* diffuse.colorSpace = THREE.SRGBColorSpace
|
|
2610
1936
|
*
|
|
2611
1937
|
* // Another component gets the SAME texture with colorSpace already set
|
|
2612
|
-
* const sameDiffuse = useTexture('/diffuse.png'
|
|
1938
|
+
* const sameDiffuse = useTexture('/diffuse.png')
|
|
1939
|
+
*
|
|
1940
|
+
* // Opt out of registry enrollment for a one-off texture
|
|
1941
|
+
* const scratch = useTexture('/scratch.png', { cache: false })
|
|
2613
1942
|
*
|
|
2614
|
-
* // Access
|
|
1943
|
+
* // Access the registry directly
|
|
2615
1944
|
* const { get } = useTextures()
|
|
2616
1945
|
* const cached = get('/diffuse.png')
|
|
2617
1946
|
* ```
|
|
@@ -2628,63 +1957,80 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
|
|
|
2628
1957
|
cache?: boolean;
|
|
2629
1958
|
}) => react_jsx_runtime.JSX.Element;
|
|
2630
1959
|
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
1960
|
+
/** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
|
|
1961
|
+
type TextureInput = string | string[] | Record<string, string>;
|
|
1962
|
+
/** Result of a `get()` read, mirroring the input shape. */
|
|
1963
|
+
type TextureResult<Input extends TextureInput> = Input extends string ? Texture$1 | undefined : Input extends string[] ? (Texture$1 | undefined)[] : {
|
|
1964
|
+
[K in keyof Input]: Texture$1 | undefined;
|
|
2634
1965
|
};
|
|
1966
|
+
/** Options for `dispose()`. */
|
|
1967
|
+
interface DisposeOptions {
|
|
1968
|
+
/** Dispose even if the texture still has active references (default false). */
|
|
1969
|
+
force?: boolean;
|
|
1970
|
+
}
|
|
2635
1971
|
interface UseTexturesReturn {
|
|
2636
|
-
/** Map
|
|
2637
|
-
|
|
2638
|
-
/**
|
|
2639
|
-
get
|
|
2640
|
-
/** Check
|
|
2641
|
-
has
|
|
2642
|
-
/**
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
1972
|
+
/** The live registry Map (key → Texture). Treat as read-only. */
|
|
1973
|
+
readonly all: Map<string, Texture$1>;
|
|
1974
|
+
/** Read one texture, an array of textures, or a name→texture record (mirrors the input shape). */
|
|
1975
|
+
get<Input extends TextureInput>(input: Input): TextureResult<Input>;
|
|
1976
|
+
/** Check whether a key exists in the registry. */
|
|
1977
|
+
has(key: string): boolean;
|
|
1978
|
+
/**
|
|
1979
|
+
* Register a texture (or a record of textures) that has no URL — e.g. a render
|
|
1980
|
+
* target or procedural texture. URL-loaded textures are registered automatically
|
|
1981
|
+
* by `useTexture` (registry enrollment is on by default).
|
|
1982
|
+
*/
|
|
1983
|
+
add(key: string, texture: Texture$1): void;
|
|
1984
|
+
add(record: Record<string, Texture$1>): void;
|
|
1985
|
+
/**
|
|
1986
|
+
* Dispose a texture's GPU resources and remove it from the registry.
|
|
1987
|
+
* Refcount-aware: if the key is still in use by a mounted `useTexture` consumer it is
|
|
1988
|
+
* skipped (with a warning) unless `{ force: true }` is passed.
|
|
1989
|
+
* @returns true if disposed, false if skipped.
|
|
1990
|
+
*/
|
|
1991
|
+
dispose(key: string, options?: DisposeOptions): boolean;
|
|
1992
|
+
/** Dispose every texture in the registry and clear it. Use on scene teardown. */
|
|
1993
|
+
disposeAll(): void;
|
|
2656
1994
|
}
|
|
2657
1995
|
/**
|
|
2658
|
-
*
|
|
1996
|
+
* Reactive Texture registry — load once with `useTexture`, reach the textures from anywhere.
|
|
2659
1997
|
*
|
|
2660
|
-
*
|
|
2661
|
-
*
|
|
1998
|
+
* This is a registry of plain `Texture` objects (not TSL nodes), so the same texture can feed
|
|
1999
|
+
* a material map, a heightmap sampler, or anything else. It does **not** load — pair it with
|
|
2000
|
+
* `useTexture` for loading (registry enrollment is on by default); `useTextures` is for access and lifecycle.
|
|
2001
|
+
*
|
|
2002
|
+
* The returned handle is **reactive**: the calling component re-renders when the registry
|
|
2003
|
+
* changes. Pass a selector to scope the subscription to a single read.
|
|
2662
2004
|
*
|
|
2663
2005
|
* @example
|
|
2664
2006
|
* ```tsx
|
|
2665
|
-
*
|
|
2666
|
-
*
|
|
2667
|
-
* // Check if texture is already cached
|
|
2668
|
-
* if (!has('/textures/diffuse.png')) {
|
|
2669
|
-
* // Load with useTexture and cache: true, or manually add
|
|
2670
|
-
* const tex = useTexture('/textures/diffuse.png', { cache: true })
|
|
2671
|
-
* }
|
|
2007
|
+
* // Load + register once (anywhere in the tree) — registered by default
|
|
2008
|
+
* useTexture({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
|
|
2672
2009
|
*
|
|
2673
|
-
* //
|
|
2674
|
-
* const
|
|
2675
|
-
*
|
|
2010
|
+
* // Reach them from another component — record form lands straight into a material
|
|
2011
|
+
* const { map, normalMap } = useTextures().get({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
|
|
2012
|
+
* return <meshStandardMaterial map={map} normalMap={normalMap} />
|
|
2676
2013
|
*
|
|
2677
|
-
* //
|
|
2678
|
-
*
|
|
2014
|
+
* // A set of heightmaps at once
|
|
2015
|
+
* const [a, b, c] = useTextures().get(['/h0.png', '/h1.png', '/h2.png'])
|
|
2679
2016
|
*
|
|
2680
|
-
* //
|
|
2681
|
-
*
|
|
2017
|
+
* // Register a non-URL texture (render target / procedural)
|
|
2018
|
+
* useTextures().add('rt-main', renderTarget.texture)
|
|
2682
2019
|
*
|
|
2683
|
-
* //
|
|
2684
|
-
*
|
|
2020
|
+
* // Deliberate GPU cleanup (refcount-aware; force to override)
|
|
2021
|
+
* useTextures().dispose('/diffuse.jpg')
|
|
2022
|
+
* useTextures().disposeAll() // scene teardown
|
|
2685
2023
|
* ```
|
|
2024
|
+
*
|
|
2025
|
+
* @remarks
|
|
2026
|
+
* **Future expansion:** an imperative async loader (e.g. `await useTextures().load('/x.jpg')`) is
|
|
2027
|
+
* intentionally not included yet. It would let non-React code (loading screens, dynamic streaming)
|
|
2028
|
+
* populate the registry without Suspense, at the cost of putting loading back into this hook. It
|
|
2029
|
+
* will be added only if a concrete consumer needs imperative loading; for now, loading lives in
|
|
2030
|
+
* `useTexture`.
|
|
2686
2031
|
*/
|
|
2687
2032
|
declare function useTextures(): UseTexturesReturn;
|
|
2033
|
+
declare function useTextures<T>(selector: (registry: UseTexturesReturn) => T): T;
|
|
2688
2034
|
|
|
2689
2035
|
/**
|
|
2690
2036
|
* Creates a render target compatible with the current renderer.
|
|
@@ -2723,11 +2069,6 @@ declare function useRenderTarget(width: number, height: number, options?: Render
|
|
|
2723
2069
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2724
2070
|
*/
|
|
2725
2071
|
declare function useStore(): RootStore;
|
|
2726
|
-
/**
|
|
2727
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2728
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2729
|
-
*/
|
|
2730
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2731
2072
|
/**
|
|
2732
2073
|
* Exposes an object's {@link Instance}.
|
|
2733
2074
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -3892,11 +3233,6 @@ declare function flushSync<R>(fn: () => R): R;
|
|
|
3892
3233
|
declare const context: React$1.Context<RootStore>;
|
|
3893
3234
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3894
3235
|
|
|
3895
|
-
/**
|
|
3896
|
-
* Safely flush async effects when testing, simulating a legacy root.
|
|
3897
|
-
* @deprecated Import from React instead. import { act } from 'react'
|
|
3898
|
-
*/
|
|
3899
|
-
declare const act: typeof React$1.act;
|
|
3900
3236
|
/**
|
|
3901
3237
|
* An SSR-friendly useLayoutEffect.
|
|
3902
3238
|
*
|
|
@@ -4464,9 +3800,12 @@ declare function useUniforms<T extends UniformInputRecord>(uniforms: T): Uniform
|
|
|
4464
3800
|
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
4465
3801
|
/**
|
|
4466
3802
|
* Global rebuildUniforms function for HMR integration.
|
|
4467
|
-
*
|
|
3803
|
+
* Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
|
|
4468
3804
|
* Call this when HMR is detected to refresh all uniform creators.
|
|
4469
3805
|
*
|
|
3806
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3807
|
+
* authoritative store.
|
|
3808
|
+
*
|
|
4470
3809
|
* @param store - The R3F store (from useStore or context)
|
|
4471
3810
|
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4472
3811
|
*/
|
|
@@ -4550,9 +3889,12 @@ declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCr
|
|
|
4550
3889
|
declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
|
|
4551
3890
|
/**
|
|
4552
3891
|
* Global rebuildNodes function for HMR integration.
|
|
4553
|
-
*
|
|
3892
|
+
* Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
|
|
4554
3893
|
* Call this when HMR is detected to refresh all node creators.
|
|
4555
3894
|
*
|
|
3895
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3896
|
+
* authoritative store.
|
|
3897
|
+
*
|
|
4556
3898
|
* @param store - The R3F store (from useStore or context)
|
|
4557
3899
|
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4558
3900
|
*/
|
|
@@ -4629,9 +3971,12 @@ declare function useBuffers<T extends Record<string, BufferLike>>(creator: Buffe
|
|
|
4629
3971
|
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
|
|
4630
3972
|
/**
|
|
4631
3973
|
* Global rebuildBuffers function for HMR integration.
|
|
4632
|
-
*
|
|
3974
|
+
* Invalidates cached buffers and increments _hmrVersion to trigger re-creation.
|
|
4633
3975
|
* Call this when HMR is detected to refresh all buffer creators.
|
|
4634
3976
|
*
|
|
3977
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3978
|
+
* authoritative store.
|
|
3979
|
+
*
|
|
4635
3980
|
* @param store - The R3F store (from useStore or context)
|
|
4636
3981
|
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4637
3982
|
*/
|
|
@@ -4663,14 +4008,34 @@ declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: S
|
|
|
4663
4008
|
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
|
|
4664
4009
|
/**
|
|
4665
4010
|
* Global rebuildStorage function for HMR integration.
|
|
4666
|
-
*
|
|
4011
|
+
* Invalidates cached storage and increments _hmrVersion to trigger re-creation.
|
|
4667
4012
|
* Call this when HMR is detected to refresh all storage creators.
|
|
4668
4013
|
*
|
|
4014
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
4015
|
+
* authoritative store.
|
|
4016
|
+
*
|
|
4669
4017
|
* @param store - The R3F store (from useStore or context)
|
|
4670
4018
|
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4671
4019
|
*/
|
|
4672
4020
|
declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4673
4021
|
|
|
4022
|
+
/**
|
|
4023
|
+
* Re-export from core - useTextures is now a core R3F hook (a reactive Texture registry).
|
|
4024
|
+
*
|
|
4025
|
+
* This file maintains backwards compatibility for existing webgpu imports.
|
|
4026
|
+
*/
|
|
4027
|
+
|
|
4028
|
+
/**
|
|
4029
|
+
* @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
|
|
4030
|
+
* Kept as an alias for backwards compatibility.
|
|
4031
|
+
*/
|
|
4032
|
+
type TextureEntry = Texture$1;
|
|
4033
|
+
/**
|
|
4034
|
+
* @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
|
|
4035
|
+
* Kept as an alias for backwards compatibility.
|
|
4036
|
+
*/
|
|
4037
|
+
type TextureNode = Texture$1;
|
|
4038
|
+
|
|
4674
4039
|
interface TextureOperations {
|
|
4675
4040
|
add: (key: string, value: any) => void;
|
|
4676
4041
|
addMultiple: (items: Map<string, any> | Record<string, any>) => void;
|
|
@@ -4765,5 +4130,23 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
|
|
|
4765
4130
|
internal: WebGPUInternalState
|
|
4766
4131
|
}
|
|
4767
4132
|
|
|
4768
|
-
|
|
4769
|
-
|
|
4133
|
+
/**
|
|
4134
|
+
* @fileoverview WebGPU entry point - WebGPU only, no legacy WebGL
|
|
4135
|
+
*
|
|
4136
|
+
* This entry point is for apps that want to use ONLY WebGPURenderer.
|
|
4137
|
+
* Includes WebGPU-specific hooks (useUniforms, useNodes, useTextures).
|
|
4138
|
+
* Auto-extends THREE with WebGPU node materials (MeshBasicNodeMaterial, etc.)
|
|
4139
|
+
*
|
|
4140
|
+
* Usage:
|
|
4141
|
+
* import { Canvas, useFrame, useUniforms } from '@react-three/fiber/webgpu'
|
|
4142
|
+
*/
|
|
4143
|
+
|
|
4144
|
+
/** `useThree` narrowed to WebGPU state — `state.renderer` is a `WebGPURenderer`. */
|
|
4145
|
+
type UseThreeWebGPU = <T = WebGPURootState>(selector?: (state: WebGPURootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
|
|
4146
|
+
/** `useFrame` narrowed to WebGPU state — the callback's `state.renderer` is a `WebGPURenderer`. */
|
|
4147
|
+
type UseFrameWebGPU = (callback?: FrameCallback$1<WebGPURootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
|
|
4148
|
+
declare const useThree: UseThreeWebGPU;
|
|
4149
|
+
declare const useFrame: UseFrameWebGPU;
|
|
4150
|
+
|
|
4151
|
+
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, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, 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, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useBuffers, useEnvironment, useFrame, useGPUStorage, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, useRenderPipeline, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
|
|
4152
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DisposeBuffersFn, DisposeOptions, DisposeStorageFn, 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, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeProps, NodeRecord, NodesWithUtils, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, RebuildBuffersFn, RebuildNodesFn, RebuildStorageFn, RebuildUniformsFn, ReconcilerRoot, RemoveBuffersFn, RemoveNodesFn, RemoveStorageFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, WebGPURootState as RootState, RootStore, ScopedStoreType, SetBlock, Size, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, Subscription, TSLNode, TSLNodeInput, TextureEntry, TextureInput, TextureNode, TextureOperations, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameWebGPU, UseTextureOptions, UseTexturesReturn, UseThreeWebGPU, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };
|