@react-three/fiber 10.0.0-canary.d6fdf72 → 10.0.0-canary.e881a4a
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 +297 -1218
- package/dist/index.d.cts +71 -742
- package/dist/index.d.mts +71 -742
- package/dist/index.d.ts +71 -742
- package/dist/index.mjs +271 -1191
- package/dist/legacy.cjs +252 -1173
- package/dist/legacy.d.cts +71 -741
- package/dist/legacy.d.mts +71 -741
- package/dist/legacy.d.ts +71 -741
- package/dist/legacy.mjs +225 -1145
- package/dist/webgpu/index.cjs +818 -1962
- package/dist/webgpu/index.d.cts +104 -745
- package/dist/webgpu/index.d.mts +104 -745
- package/dist/webgpu/index.d.ts +104 -745
- package/dist/webgpu/index.mjs +793 -1936
- package/package.json +4 -3
- package/readme.md +2 -3
package/dist/webgpu/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
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';
|
|
2
|
+
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
3
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
4
4
|
import * as THREE$1 from 'three';
|
|
5
5
|
import { Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
@@ -7,6 +7,8 @@ import * as React$1 from 'react';
|
|
|
7
7
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
8
8
|
import { StoreApi } from 'zustand';
|
|
9
9
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
10
|
+
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
11
|
+
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
10
12
|
import { Options } from 'react-use-measure';
|
|
11
13
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
12
14
|
import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
|
|
@@ -47,12 +49,16 @@ type WebGLShadowMap = never;
|
|
|
47
49
|
|
|
48
50
|
declare const WebGLRenderTarget: any;
|
|
49
51
|
|
|
52
|
+
declare const WebGLCubeRenderTarget: any;
|
|
53
|
+
|
|
50
54
|
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
51
55
|
__proto__: null,
|
|
56
|
+
CubeRenderTargetCompat: CubeRenderTarget,
|
|
52
57
|
Inspector: Inspector,
|
|
53
58
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
54
59
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
55
60
|
RenderTargetCompat: RenderTarget,
|
|
61
|
+
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
56
62
|
WebGLRenderTarget: WebGLRenderTarget,
|
|
57
63
|
WebGLRenderer: WebGLRenderer,
|
|
58
64
|
WebGLRendererParameters: WebGLRendererParameters,
|
|
@@ -294,228 +300,33 @@ interface VisibilityEntry {
|
|
|
294
300
|
}
|
|
295
301
|
|
|
296
302
|
//* Scheduler Types (useFrame) ==============================
|
|
303
|
+
//
|
|
304
|
+
// The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
|
|
305
|
+
// This file re-exports them and layers r3f's RootState-aware frame state on top,
|
|
306
|
+
// so existing `#types` imports across the codebase keep resolving unchanged.
|
|
297
307
|
|
|
298
308
|
|
|
299
309
|
|
|
300
|
-
//
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Options for useFrame hook
|
|
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
|
-
}
|
|
310
|
+
// Frame State (r3f-specific) --------------------------------
|
|
352
311
|
|
|
353
312
|
/**
|
|
354
|
-
* State passed to useFrame callbacks (extends RootState with timing)
|
|
313
|
+
* State passed to useFrame callbacks (extends RootState with timing).
|
|
355
314
|
*/
|
|
356
315
|
interface FrameNextState extends RootState, FrameTimingState {}
|
|
357
316
|
|
|
358
317
|
/** Alias for FrameNextState */
|
|
359
318
|
type FrameState = FrameNextState
|
|
360
319
|
|
|
361
|
-
//
|
|
320
|
+
// Callback Types (r3f-specific) --------------------------------
|
|
362
321
|
|
|
363
322
|
/**
|
|
364
|
-
*
|
|
323
|
+
* Callback function for useFrame. Receives the full r3f RootState plus timing.
|
|
365
324
|
*/
|
|
366
|
-
|
|
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 --------------------------------
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Callback function for useFrame
|
|
377
|
-
*/
|
|
378
|
-
type FrameNextCallback = (state: FrameNextState, delta: number) => void
|
|
325
|
+
type FrameNextCallback = FrameCallback$1<RootState>
|
|
379
326
|
|
|
380
327
|
/** Alias for FrameNextCallback */
|
|
381
328
|
type FrameCallback = FrameNextCallback
|
|
382
329
|
|
|
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
330
|
//* Buffer Types (useBuffers) ========================================
|
|
520
331
|
|
|
521
332
|
/**
|
|
@@ -691,7 +502,7 @@ interface InternalState {
|
|
|
691
502
|
canvasTarget?: CanvasTarget
|
|
692
503
|
/**
|
|
693
504
|
* Whether multi-canvas rendering is active.
|
|
694
|
-
* True when any canvas uses `
|
|
505
|
+
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
695
506
|
* When true, setCanvasTarget is called before each render.
|
|
696
507
|
*/
|
|
697
508
|
isMultiCanvas?: boolean
|
|
@@ -789,8 +600,8 @@ interface RootState {
|
|
|
789
600
|
setSize: (width?: number, height?: number, top?: number, left?: number) => void
|
|
790
601
|
/** Shortcut to manual setting the pixel ratio */
|
|
791
602
|
setDpr: (dpr: Dpr) => void
|
|
792
|
-
/** Shortcut to setting frameloop flags */
|
|
793
|
-
setFrameloop: (frameloop
|
|
603
|
+
/** Shortcut to setting frameloop flags. No args resets to 'always'. */
|
|
604
|
+
setFrameloop: (frameloop?: Frameloop) => void
|
|
794
605
|
/** Set error state to propagate to error boundary */
|
|
795
606
|
setError: (error: Error | null) => void
|
|
796
607
|
/** Current error state (null when no error) */
|
|
@@ -808,7 +619,7 @@ interface RootState {
|
|
|
808
619
|
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
809
620
|
_textureRefs: Map<string, number>
|
|
810
621
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
811
|
-
renderPipeline:
|
|
622
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
812
623
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
813
624
|
passes: Record<string, any>
|
|
814
625
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
@@ -1101,8 +912,6 @@ interface Instance<O = any> {
|
|
|
1101
912
|
attach?: AttachType<O>
|
|
1102
913
|
previousAttach?: any
|
|
1103
914
|
isHidden: boolean
|
|
1104
|
-
/** Deferred ref props to apply in commitMount */
|
|
1105
|
-
deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
|
|
1106
915
|
/** Set of props that have been applied via once() */
|
|
1107
916
|
appliedOnce?: Set<string>
|
|
1108
917
|
}
|
|
@@ -1339,10 +1148,21 @@ type RenderTargetOptions = RenderTargetOptions$1
|
|
|
1339
1148
|
//* Global Types ==============================
|
|
1340
1149
|
|
|
1341
1150
|
declare global {
|
|
1342
|
-
/**
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1151
|
+
/**
|
|
1152
|
+
* Uniform node type.
|
|
1153
|
+
*
|
|
1154
|
+
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1155
|
+
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1156
|
+
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1157
|
+
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1158
|
+
* arity when three made `UniformNode` two-parameter.
|
|
1159
|
+
*
|
|
1160
|
+
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1161
|
+
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1162
|
+
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1163
|
+
* installed three instead of needing to be mirrored by hand.
|
|
1164
|
+
*/
|
|
1165
|
+
type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
|
|
1346
1166
|
|
|
1347
1167
|
/**
|
|
1348
1168
|
* ShaderCallable - the return type of Fn()
|
|
@@ -1487,13 +1307,14 @@ declare module 'three/tsl' {
|
|
|
1487
1307
|
): ShaderCallable<R>
|
|
1488
1308
|
}
|
|
1489
1309
|
|
|
1490
|
-
/**
|
|
1491
|
-
* RenderPipeline Types for useRenderPipeline hook (WebGPU only)
|
|
1492
|
-
*/
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
1310
|
declare global {
|
|
1311
|
+
/**
|
|
1312
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1313
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1314
|
+
* is r185, so the new name is the only one.
|
|
1315
|
+
*/
|
|
1316
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1317
|
+
|
|
1497
1318
|
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1498
1319
|
type PassRecord = Record<string, any>
|
|
1499
1320
|
|
|
@@ -1508,7 +1329,7 @@ declare global {
|
|
|
1508
1329
|
/** Current passes from state */
|
|
1509
1330
|
passes: PassRecord
|
|
1510
1331
|
/** RenderPipeline instance (null if not initialized) */
|
|
1511
|
-
renderPipeline:
|
|
1332
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
1512
1333
|
/** Clear all passes from state */
|
|
1513
1334
|
clearPasses: () => void
|
|
1514
1335
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
@@ -1520,146 +1341,6 @@ declare global {
|
|
|
1520
1341
|
}
|
|
1521
1342
|
}
|
|
1522
1343
|
|
|
1523
|
-
//* useFrameNext Types ==============================
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
//* Global Type Declarations ==============================
|
|
1528
|
-
|
|
1529
|
-
declare global {
|
|
1530
|
-
// Job --------------------------------
|
|
1531
|
-
|
|
1532
|
-
/**
|
|
1533
|
-
* Internal job representation in the scheduler
|
|
1534
|
-
*/
|
|
1535
|
-
interface Job {
|
|
1536
|
-
/** Unique identifier */
|
|
1537
|
-
id: string
|
|
1538
|
-
/** The callback to execute */
|
|
1539
|
-
callback: FrameNextCallback
|
|
1540
|
-
/** Phase this job belongs to */
|
|
1541
|
-
phase: string
|
|
1542
|
-
/** Run before these phases/job ids */
|
|
1543
|
-
before: Set<string>
|
|
1544
|
-
/** Run after these phases/job ids */
|
|
1545
|
-
after: Set<string>
|
|
1546
|
-
/** Priority within phase (higher first) */
|
|
1547
|
-
priority: number
|
|
1548
|
-
/** Insertion order for deterministic tie-breaking */
|
|
1549
|
-
index: number
|
|
1550
|
-
/** Max FPS for this job (undefined = no limit) */
|
|
1551
|
-
fps?: number
|
|
1552
|
-
/** Drop frames when behind (true) or catch up (false) */
|
|
1553
|
-
drop: boolean
|
|
1554
|
-
/** Last run timestamp (ms) */
|
|
1555
|
-
lastRun?: number
|
|
1556
|
-
/** Whether job is enabled */
|
|
1557
|
-
enabled: boolean
|
|
1558
|
-
/** Internal flag: system jobs (like default render) don't block user render takeover */
|
|
1559
|
-
system?: boolean
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
// Phase Graph --------------------------------
|
|
1563
|
-
|
|
1564
|
-
/**
|
|
1565
|
-
* A node in the phase graph
|
|
1566
|
-
*/
|
|
1567
|
-
interface PhaseNode {
|
|
1568
|
-
/** Phase name */
|
|
1569
|
-
name: string
|
|
1570
|
-
/** Whether this was auto-generated from a before/after constraint */
|
|
1571
|
-
isAutoGenerated: boolean
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
/**
|
|
1575
|
-
* Options for creating a job from hook options
|
|
1576
|
-
*/
|
|
1577
|
-
interface JobOptions {
|
|
1578
|
-
id?: string
|
|
1579
|
-
phase?: string
|
|
1580
|
-
before?: string | string[]
|
|
1581
|
-
after?: string | string[]
|
|
1582
|
-
priority?: number
|
|
1583
|
-
fps?: number
|
|
1584
|
-
drop?: boolean
|
|
1585
|
-
enabled?: boolean
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
// Frame Loop State --------------------------------
|
|
1589
|
-
|
|
1590
|
-
/**
|
|
1591
|
-
* Internal frame loop state
|
|
1592
|
-
*/
|
|
1593
|
-
interface FrameLoopState {
|
|
1594
|
-
/** Whether the loop is running */
|
|
1595
|
-
running: boolean
|
|
1596
|
-
/** Current RAF handle */
|
|
1597
|
-
rafHandle: number | null
|
|
1598
|
-
/** Last frame timestamp in ms (null = uninitialized) */
|
|
1599
|
-
lastTime: number | null
|
|
1600
|
-
/** Frame counter */
|
|
1601
|
-
frameCount: number
|
|
1602
|
-
/** Elapsed time since first frame in ms */
|
|
1603
|
-
elapsedTime: number
|
|
1604
|
-
/** createdAt timestamp in ms */
|
|
1605
|
-
createdAt: number
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
|
-
// Root Entry --------------------------------
|
|
1609
|
-
|
|
1610
|
-
/**
|
|
1611
|
-
* Internal representation of a registered root (Canvas).
|
|
1612
|
-
* Tracks jobs and manages rebuild state for this root.
|
|
1613
|
-
* @internal
|
|
1614
|
-
*/
|
|
1615
|
-
interface RootEntry {
|
|
1616
|
-
/** Unique identifier for this root */
|
|
1617
|
-
id: string
|
|
1618
|
-
/** Function to get the root's current state. Returns any to support independent mode. */
|
|
1619
|
-
getState: () => any
|
|
1620
|
-
/** Map of job IDs to Job objects */
|
|
1621
|
-
jobs: Map<string, Job>
|
|
1622
|
-
/** Cached sorted job list for execution order */
|
|
1623
|
-
sortedJobs: Job[]
|
|
1624
|
-
/** Whether sortedJobs needs rebuilding */
|
|
1625
|
-
needsRebuild: boolean
|
|
1626
|
-
}
|
|
1627
|
-
|
|
1628
|
-
/**
|
|
1629
|
-
* Internal representation of a global job (deprecated API).
|
|
1630
|
-
* Global jobs run once per frame, not per-root.
|
|
1631
|
-
* Used by legacy addEffect/addAfterEffect APIs.
|
|
1632
|
-
* @internal
|
|
1633
|
-
* @deprecated Use useFrame with phases instead
|
|
1634
|
-
*/
|
|
1635
|
-
interface GlobalJob {
|
|
1636
|
-
/** Unique identifier for this global job */
|
|
1637
|
-
id: string
|
|
1638
|
-
/** Callback invoked with RAF timestamp in ms */
|
|
1639
|
-
callback: (timestamp: number) => void
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
|
-
// HMR Support --------------------------------
|
|
1643
|
-
|
|
1644
|
-
/**
|
|
1645
|
-
* Hot Module Replacement data structure for preserving scheduler state
|
|
1646
|
-
* @internal
|
|
1647
|
-
*/
|
|
1648
|
-
interface HMRData {
|
|
1649
|
-
/** Shared data object for storing values across reloads */
|
|
1650
|
-
data: Record<string, any>
|
|
1651
|
-
/** Optional function to accept HMR updates */
|
|
1652
|
-
accept?: () => void
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
// Default Phases --------------------------------
|
|
1656
|
-
|
|
1657
|
-
/**
|
|
1658
|
-
* Default phase names for the scheduler
|
|
1659
|
-
*/
|
|
1660
|
-
type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
1344
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
1664
1345
|
|
|
1665
1346
|
interface MathRepresentation {
|
|
@@ -1829,7 +1510,7 @@ declare namespace three_d {
|
|
|
1829
1510
|
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
1830
1511
|
*
|
|
1831
1512
|
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
1832
|
-
* Secondary canvas: Has `
|
|
1513
|
+
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
1833
1514
|
*/
|
|
1834
1515
|
|
|
1835
1516
|
interface PrimaryCanvasEntry {
|
|
@@ -1897,12 +1578,23 @@ type EnvironmentLoaderProps = {
|
|
|
1897
1578
|
* const texture = useEnvironment({ preset: 'sunset' })
|
|
1898
1579
|
* ```
|
|
1899
1580
|
*/
|
|
1900
|
-
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture
|
|
1581
|
+
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
|
|
1901
1582
|
declare namespace useEnvironment {
|
|
1902
1583
|
var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
|
|
1903
1584
|
var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
|
|
1904
1585
|
}
|
|
1905
|
-
|
|
1586
|
+
/**
|
|
1587
|
+
* Options accepted by `useEnvironment.preload`.
|
|
1588
|
+
*
|
|
1589
|
+
* `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
|
|
1590
|
+
* applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
|
|
1591
|
+
* advertise an option this function silently ignores.
|
|
1592
|
+
*
|
|
1593
|
+
* This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
|
|
1594
|
+
* `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
|
|
1595
|
+
* type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
|
|
1596
|
+
*/
|
|
1597
|
+
type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
|
|
1906
1598
|
type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
|
|
1907
1599
|
|
|
1908
1600
|
/**
|
|
@@ -2152,383 +1844,21 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
|
|
|
2152
1844
|
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
2153
1845
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
2154
1846
|
*/
|
|
2155
|
-
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>;
|
|
1847
|
+
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>;
|
|
2156
1848
|
declare namespace useLoader {
|
|
2157
|
-
var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
|
|
2158
|
-
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
|
|
1849
|
+
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;
|
|
1850
|
+
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
|
|
2159
1851
|
var loader: typeof getLoader;
|
|
2160
1852
|
}
|
|
2161
1853
|
|
|
2162
|
-
/**
|
|
2163
|
-
* Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
|
|
2164
|
-
*
|
|
2165
|
-
* Features:
|
|
2166
|
-
* - Single RAF loop for entire application
|
|
2167
|
-
* - Root registration (multiple Canvas support)
|
|
2168
|
-
* - Global phases for addEffect/addAfterEffect (deprecated)
|
|
2169
|
-
* - Per-root job management with phases, priorities, FPS throttling
|
|
2170
|
-
* - onIdle callbacks for addTail (deprecated)
|
|
2171
|
-
* - Demand mode support via invalidate()
|
|
2172
|
-
*/
|
|
2173
|
-
declare class Scheduler {
|
|
2174
|
-
private static readonly INSTANCE_KEY;
|
|
2175
|
-
private static get instance();
|
|
2176
|
-
private static set instance(value);
|
|
2177
|
-
/**
|
|
2178
|
-
* Get the global scheduler instance (creates if doesn't exist).
|
|
2179
|
-
* Uses HMR data to preserve instance across hot reloads.
|
|
2180
|
-
* @returns {Scheduler} The singleton scheduler instance
|
|
2181
|
-
*/
|
|
2182
|
-
static get(): Scheduler;
|
|
2183
|
-
/**
|
|
2184
|
-
* Reset the singleton instance. Stops the loop and clears all state.
|
|
2185
|
-
* Primarily used for testing to ensure clean state between tests.
|
|
2186
|
-
* @returns {void}
|
|
2187
|
-
*/
|
|
2188
|
-
static reset(): void;
|
|
2189
|
-
private roots;
|
|
2190
|
-
private phaseGraph;
|
|
2191
|
-
private loopState;
|
|
2192
|
-
private stoppedTime;
|
|
2193
|
-
private nextRootIndex;
|
|
2194
|
-
private globalBeforeJobs;
|
|
2195
|
-
private globalAfterJobs;
|
|
2196
|
-
private nextGlobalIndex;
|
|
2197
|
-
private idleCallbacks;
|
|
2198
|
-
private nextJobIndex;
|
|
2199
|
-
private jobStateListeners;
|
|
2200
|
-
private pendingFrames;
|
|
2201
|
-
private _frameloop;
|
|
2202
|
-
private _independent;
|
|
2203
|
-
private errorHandler;
|
|
2204
|
-
private rootReadyCallbacks;
|
|
2205
|
-
get phases(): string[];
|
|
2206
|
-
get frameloop(): Frameloop;
|
|
2207
|
-
set frameloop(mode: Frameloop);
|
|
2208
|
-
get isRunning(): boolean;
|
|
2209
|
-
get isReady(): boolean;
|
|
2210
|
-
get independent(): boolean;
|
|
2211
|
-
set independent(value: boolean);
|
|
2212
|
-
constructor();
|
|
2213
|
-
/**
|
|
2214
|
-
* Register a root (Canvas) with the scheduler.
|
|
2215
|
-
* The first root to register starts the RAF loop (if frameloop='always').
|
|
2216
|
-
* @param {string} id - Unique identifier for this root
|
|
2217
|
-
* @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
|
|
2218
|
-
* @returns {() => void} Unsubscribe function to remove this root
|
|
2219
|
-
*/
|
|
2220
|
-
registerRoot(id: string, options?: RootOptions): () => void;
|
|
2221
|
-
/**
|
|
2222
|
-
* Unregister a root from the scheduler.
|
|
2223
|
-
* Cleans up all job state listeners for this root's jobs.
|
|
2224
|
-
* The last root to unregister stops the RAF loop.
|
|
2225
|
-
* @param {string} id - The root ID to unregister
|
|
2226
|
-
* @returns {void}
|
|
2227
|
-
*/
|
|
2228
|
-
unregisterRoot(id: string): void;
|
|
2229
|
-
/**
|
|
2230
|
-
* Subscribe to be notified when a root becomes available.
|
|
2231
|
-
* Fires immediately if a root already exists.
|
|
2232
|
-
* @param {() => void} callback - Function called when first root registers
|
|
2233
|
-
* @returns {() => void} Unsubscribe function
|
|
2234
|
-
*/
|
|
2235
|
-
onRootReady(callback: () => void): () => void;
|
|
2236
|
-
/**
|
|
2237
|
-
* Notify all registered root-ready callbacks.
|
|
2238
|
-
* Called when the first root registers.
|
|
2239
|
-
* @returns {void}
|
|
2240
|
-
* @private
|
|
2241
|
-
*/
|
|
2242
|
-
private notifyRootReady;
|
|
2243
|
-
/**
|
|
2244
|
-
* Ensure a default root exists for independent mode.
|
|
2245
|
-
* Creates a minimal root with no state provider.
|
|
2246
|
-
* @returns {void}
|
|
2247
|
-
* @private
|
|
2248
|
-
*/
|
|
2249
|
-
private ensureDefaultRoot;
|
|
2250
|
-
/**
|
|
2251
|
-
* Trigger error handling for job errors.
|
|
2252
|
-
* Uses the bound error handler if available, otherwise logs to console.
|
|
2253
|
-
* @param {Error} error - The error to handle
|
|
2254
|
-
* @returns {void}
|
|
2255
|
-
*/
|
|
2256
|
-
triggerError(error: Error): void;
|
|
2257
|
-
/**
|
|
2258
|
-
* Add a named phase to the scheduler's execution order.
|
|
2259
|
-
* Marks all roots for rebuild to incorporate the new phase.
|
|
2260
|
-
* @param {string} name - The phase name (e.g., 'physics', 'postprocess')
|
|
2261
|
-
* @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
|
|
2262
|
-
* @returns {void}
|
|
2263
|
-
* @example
|
|
2264
|
-
* scheduler.addPhase('physics', { before: 'update' });
|
|
2265
|
-
* scheduler.addPhase('postprocess', { after: 'render' });
|
|
2266
|
-
*/
|
|
2267
|
-
addPhase(name: string, options?: AddPhaseOptions): void;
|
|
2268
|
-
/**
|
|
2269
|
-
* Check if a phase exists in the scheduler.
|
|
2270
|
-
* @param {string} name - The phase name to check
|
|
2271
|
-
* @returns {boolean} True if the phase exists
|
|
2272
|
-
*/
|
|
2273
|
-
hasPhase(name: string): boolean;
|
|
2274
|
-
/**
|
|
2275
|
-
* Register a global job that runs once per frame (not per-root).
|
|
2276
|
-
* Used internally by deprecated addEffect/addAfterEffect APIs.
|
|
2277
|
-
* @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
|
|
2278
|
-
* @param {string} id - Unique identifier for this global job
|
|
2279
|
-
* @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
|
|
2280
|
-
* @returns {() => void} Unsubscribe function to remove this global job
|
|
2281
|
-
* @deprecated Use useFrame with phases instead
|
|
2282
|
-
*/
|
|
2283
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
|
|
2284
|
-
/**
|
|
2285
|
-
* Register an idle callback that fires when the loop stops.
|
|
2286
|
-
* Used internally by deprecated addTail API.
|
|
2287
|
-
* @param {(timestamp: number) => void} callback - Function called when loop becomes idle
|
|
2288
|
-
* @returns {() => void} Unsubscribe function to remove this idle callback
|
|
2289
|
-
* @deprecated Use demand mode with invalidate() instead
|
|
2290
|
-
*/
|
|
2291
|
-
onIdle(callback: (timestamp: number) => void): () => void;
|
|
2292
|
-
/**
|
|
2293
|
-
* Notify all registered idle callbacks.
|
|
2294
|
-
* Called when the loop stops in demand mode.
|
|
2295
|
-
* @param {number} timestamp - The RAF timestamp when idle occurred
|
|
2296
|
-
* @returns {void}
|
|
2297
|
-
* @private
|
|
2298
|
-
*/
|
|
2299
|
-
private notifyIdle;
|
|
2300
|
-
/**
|
|
2301
|
-
* Register a job (frame callback) with a specific root.
|
|
2302
|
-
* This is the core registration method used by useFrame internally.
|
|
2303
|
-
* @param {FrameNextCallback} callback - The function to call each frame
|
|
2304
|
-
* @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
|
|
2305
|
-
* @param {string} [options.rootId] - Target root ID (defaults to first registered root)
|
|
2306
|
-
* @param {string} [options.id] - Unique job ID (auto-generated if not provided)
|
|
2307
|
-
* @param {string} [options.phase] - Execution phase (defaults to 'update')
|
|
2308
|
-
* @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
|
|
2309
|
-
* @param {number} [options.fps] - FPS throttle limit
|
|
2310
|
-
* @param {boolean} [options.drop] - Drop frames when behind (default true)
|
|
2311
|
-
* @param {boolean} [options.enabled] - Whether job is active (default true)
|
|
2312
|
-
* @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
|
|
2313
|
-
* @returns {() => void} Unsubscribe function to remove this job
|
|
2314
|
-
*/
|
|
2315
|
-
register(callback: FrameNextCallback, options?: JobOptions & {
|
|
2316
|
-
rootId?: string;
|
|
2317
|
-
system?: boolean;
|
|
2318
|
-
}): () => void;
|
|
2319
|
-
/**
|
|
2320
|
-
* Unregister a job by its ID.
|
|
2321
|
-
* Searches all roots if rootId is not provided.
|
|
2322
|
-
* @param {string} id - The job ID to unregister
|
|
2323
|
-
* @param {string} [rootId] - Optional root ID to search (searches all if not provided)
|
|
2324
|
-
* @returns {void}
|
|
2325
|
-
*/
|
|
2326
|
-
unregister(id: string, rootId?: string): void;
|
|
2327
|
-
/**
|
|
2328
|
-
* Update a job's options dynamically.
|
|
2329
|
-
* Searches all roots to find the job by ID.
|
|
2330
|
-
* Phase/constraint changes trigger a rebuild of the sorted job list.
|
|
2331
|
-
* @param {string} id - The job ID to update
|
|
2332
|
-
* @param {Partial<JobOptions>} options - The options to update
|
|
2333
|
-
* @returns {void}
|
|
2334
|
-
*/
|
|
2335
|
-
updateJob(id: string, options: Partial<JobOptions>): void;
|
|
2336
|
-
/**
|
|
2337
|
-
* Check if a job is currently paused (disabled).
|
|
2338
|
-
* @param {string} id - The job ID to check
|
|
2339
|
-
* @returns {boolean} True if the job exists and is paused
|
|
2340
|
-
*/
|
|
2341
|
-
isJobPaused(id: string): boolean;
|
|
2342
|
-
/**
|
|
2343
|
-
* Subscribe to state changes for a specific job.
|
|
2344
|
-
* Listener is called when job is paused or resumed.
|
|
2345
|
-
* @param {string} id - The job ID to subscribe to
|
|
2346
|
-
* @param {() => void} listener - Callback invoked on state changes
|
|
2347
|
-
* @returns {() => void} Unsubscribe function
|
|
2348
|
-
*/
|
|
2349
|
-
subscribeJobState(id: string, listener: () => void): () => void;
|
|
2350
|
-
/**
|
|
2351
|
-
* Notify all listeners that a job's state has changed.
|
|
2352
|
-
* @param {string} id - The job ID that changed
|
|
2353
|
-
* @returns {void}
|
|
2354
|
-
* @private
|
|
2355
|
-
*/
|
|
2356
|
-
private notifyJobStateChange;
|
|
2357
|
-
/**
|
|
2358
|
-
* Pause a job by ID (sets enabled=false).
|
|
2359
|
-
* Notifies any subscribed state listeners.
|
|
2360
|
-
* @param {string} id - The job ID to pause
|
|
2361
|
-
* @returns {void}
|
|
2362
|
-
*/
|
|
2363
|
-
pauseJob(id: string): void;
|
|
2364
|
-
/**
|
|
2365
|
-
* Resume a paused job by ID (sets enabled=true).
|
|
2366
|
-
* Resets job timing to prevent frame accumulation.
|
|
2367
|
-
* Notifies any subscribed state listeners.
|
|
2368
|
-
* @param {string} id - The job ID to resume
|
|
2369
|
-
* @returns {void}
|
|
2370
|
-
*/
|
|
2371
|
-
resumeJob(id: string): void;
|
|
2372
|
-
/**
|
|
2373
|
-
* Start the requestAnimationFrame loop.
|
|
2374
|
-
* Resets timing state (elapsedTime, frameCount) on start.
|
|
2375
|
-
* No-op if already running.
|
|
2376
|
-
* @returns {void}
|
|
2377
|
-
*/
|
|
2378
|
-
start(): void;
|
|
2379
|
-
/**
|
|
2380
|
-
* Stop the requestAnimationFrame loop.
|
|
2381
|
-
* Cancels any pending RAF callback.
|
|
2382
|
-
* No-op if not running.
|
|
2383
|
-
* @returns {void}
|
|
2384
|
-
*/
|
|
2385
|
-
stop(): void;
|
|
2386
|
-
/**
|
|
2387
|
-
* Request frames to be rendered in demand mode.
|
|
2388
|
-
* Accumulates pending frames (capped at 60) and starts the loop if not running.
|
|
2389
|
-
* No-op if frameloop is not 'demand'.
|
|
2390
|
-
* @param {number} [frames=1] - Number of frames to request
|
|
2391
|
-
* @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
|
|
2392
|
-
* - `false` (default): Sets pending frames to the specified value (replaces existing count)
|
|
2393
|
-
* - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
|
|
2394
|
-
* @returns {void}
|
|
2395
|
-
* @example
|
|
2396
|
-
* // Request a single frame render
|
|
2397
|
-
* scheduler.invalidate();
|
|
2398
|
-
*
|
|
2399
|
-
* @example
|
|
2400
|
-
* // Request 5 frames (e.g., for animations)
|
|
2401
|
-
* scheduler.invalidate(5);
|
|
2402
|
-
*
|
|
2403
|
-
* @example
|
|
2404
|
-
* // Set pending frames to exactly 3 (don't stack with existing)
|
|
2405
|
-
* scheduler.invalidate(3, false);
|
|
2406
|
-
*
|
|
2407
|
-
* @example
|
|
2408
|
-
* // Add 2 more frames to existing pending count
|
|
2409
|
-
* scheduler.invalidate(2, true);
|
|
2410
|
-
*/
|
|
2411
|
-
invalidate(frames?: number, stackFrames?: boolean): void;
|
|
2412
|
-
/**
|
|
2413
|
-
* Reset timing state for deterministic testing.
|
|
2414
|
-
* Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
|
|
2415
|
-
* @returns {void}
|
|
2416
|
-
*/
|
|
2417
|
-
resetTiming(): void;
|
|
2418
|
-
/**
|
|
2419
|
-
* Manually execute a single frame for all roots.
|
|
2420
|
-
* Useful for frameloop='never' mode or testing scenarios.
|
|
2421
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2422
|
-
* @returns {void}
|
|
2423
|
-
* @example
|
|
2424
|
-
* // Manual control mode
|
|
2425
|
-
* scheduler.frameloop = 'never';
|
|
2426
|
-
* scheduler.step(); // Execute one frame
|
|
2427
|
-
*/
|
|
2428
|
-
step(timestamp?: number): void;
|
|
2429
|
-
/**
|
|
2430
|
-
* Manually execute a single job by its ID.
|
|
2431
|
-
* Useful for testing individual job callbacks in isolation.
|
|
2432
|
-
* @param {string} id - The job ID to step
|
|
2433
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2434
|
-
* @returns {void}
|
|
2435
|
-
*/
|
|
2436
|
-
stepJob(id: string, timestamp?: number): void;
|
|
2437
|
-
/**
|
|
2438
|
-
* Main RAF loop callback.
|
|
2439
|
-
* Executes frame, handles demand mode, and schedules next frame.
|
|
2440
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2441
|
-
* @returns {void}
|
|
2442
|
-
* @private
|
|
2443
|
-
*/
|
|
2444
|
-
private loop;
|
|
2445
|
-
/**
|
|
2446
|
-
* Execute a single frame across all roots.
|
|
2447
|
-
* Order: globalBefore → each root's jobs → globalAfter
|
|
2448
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2449
|
-
* @returns {void}
|
|
2450
|
-
* @private
|
|
2451
|
-
*/
|
|
2452
|
-
private executeFrame;
|
|
2453
|
-
/**
|
|
2454
|
-
* Run all global jobs from a job map.
|
|
2455
|
-
* Catches and logs errors without stopping execution.
|
|
2456
|
-
* @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
|
|
2457
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2458
|
-
* @returns {void}
|
|
2459
|
-
* @private
|
|
2460
|
-
*/
|
|
2461
|
-
private runGlobalJobs;
|
|
2462
|
-
/**
|
|
2463
|
-
* Execute all jobs for a single root in sorted order.
|
|
2464
|
-
* Rebuilds sorted job list if needed, then dispatches each job.
|
|
2465
|
-
* Errors are caught and propagated via triggerError.
|
|
2466
|
-
* @param {RootEntry} root - The root entry to tick
|
|
2467
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2468
|
-
* @param {number} delta - Time since last frame in seconds
|
|
2469
|
-
* @returns {void}
|
|
2470
|
-
* @private
|
|
2471
|
-
*/
|
|
2472
|
-
private tickRoot;
|
|
2473
|
-
/**
|
|
2474
|
-
* Get the total number of registered jobs across all roots.
|
|
2475
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2476
|
-
* @returns {number} Total job count
|
|
2477
|
-
*/
|
|
2478
|
-
getJobCount(): number;
|
|
2479
|
-
/**
|
|
2480
|
-
* Get all registered job IDs across all roots.
|
|
2481
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2482
|
-
* @returns {string[]} Array of all job IDs
|
|
2483
|
-
*/
|
|
2484
|
-
getJobIds(): string[];
|
|
2485
|
-
/**
|
|
2486
|
-
* Get the number of registered roots (Canvas instances).
|
|
2487
|
-
* @returns {number} Number of registered roots
|
|
2488
|
-
*/
|
|
2489
|
-
getRootCount(): number;
|
|
2490
|
-
/**
|
|
2491
|
-
* Check if any user (non-system) jobs are registered in a specific phase.
|
|
2492
|
-
* Used by the default render job to know if a user has taken over rendering.
|
|
2493
|
-
*
|
|
2494
|
-
* @param phase The phase to check
|
|
2495
|
-
* @param rootId Optional root ID to check (checks all roots if not provided)
|
|
2496
|
-
* @returns true if any user jobs exist in the phase
|
|
2497
|
-
*/
|
|
2498
|
-
hasUserJobsInPhase(phase: string, rootId?: string): boolean;
|
|
2499
|
-
/**
|
|
2500
|
-
* Generate a unique root ID for automatic root registration.
|
|
2501
|
-
* @returns {string} A unique root ID in the format 'root_N'
|
|
2502
|
-
*/
|
|
2503
|
-
generateRootId(): string;
|
|
2504
|
-
/**
|
|
2505
|
-
* Generate a unique job ID.
|
|
2506
|
-
* @returns {string} A unique job ID in the format 'job_N'
|
|
2507
|
-
* @private
|
|
2508
|
-
*/
|
|
2509
|
-
private generateJobId;
|
|
2510
|
-
/**
|
|
2511
|
-
* Normalize before/after constraints to a Set.
|
|
2512
|
-
* Handles undefined, single string, or array inputs.
|
|
2513
|
-
* @param {string | string[] | undefined} value - The constraint value(s)
|
|
2514
|
-
* @returns {Set<string>} Normalized Set of constraint strings
|
|
2515
|
-
* @private
|
|
2516
|
-
*/
|
|
2517
|
-
private normalizeConstraints;
|
|
2518
|
-
}
|
|
2519
|
-
/**
|
|
2520
|
-
* Get the global scheduler instance.
|
|
2521
|
-
* Creates one if it doesn't exist.
|
|
2522
|
-
*/
|
|
2523
|
-
declare const getScheduler: () => Scheduler;
|
|
2524
|
-
|
|
2525
1854
|
/**
|
|
2526
1855
|
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
2527
1856
|
*
|
|
2528
|
-
*
|
|
2529
|
-
* - Inside Canvas: Full RootState (
|
|
2530
|
-
* - Outside Canvas
|
|
2531
|
-
*
|
|
1857
|
+
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1858
|
+
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1859
|
+
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1860
|
+
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1861
|
+
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
2532
1862
|
*
|
|
2533
1863
|
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
2534
1864
|
*
|
|
@@ -2545,16 +1875,16 @@ declare const getScheduler: () => Scheduler;
|
|
|
2545
1875
|
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
2546
1876
|
*
|
|
2547
1877
|
* @example
|
|
2548
|
-
* // Outside Canvas - waits for Canvas
|
|
1878
|
+
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
2549
1879
|
* function UI() {
|
|
2550
1880
|
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
2551
1881
|
* return <button>...</button>;
|
|
2552
1882
|
* }
|
|
2553
1883
|
*
|
|
2554
1884
|
* @example
|
|
2555
|
-
* //
|
|
2556
|
-
* getScheduler
|
|
2557
|
-
*
|
|
1885
|
+
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
1886
|
+
* import { getScheduler } from '@pmndrs/scheduler'
|
|
1887
|
+
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
2558
1888
|
*
|
|
2559
1889
|
* @example
|
|
2560
1890
|
* // Scheduler-only access (no callback)
|
|
@@ -4491,9 +3821,12 @@ declare function useUniforms<T extends UniformInputRecord>(uniforms: T): Uniform
|
|
|
4491
3821
|
declare function useUniforms<T extends UniformInputRecord>(uniforms: T, scope: string): UniformsWithUtils<UniformRecord<UniformNode>>;
|
|
4492
3822
|
/**
|
|
4493
3823
|
* Global rebuildUniforms function for HMR integration.
|
|
4494
|
-
*
|
|
3824
|
+
* Invalidates cached uniforms and increments _hmrVersion to trigger re-creation.
|
|
4495
3825
|
* Call this when HMR is detected to refresh all uniform creators.
|
|
4496
3826
|
*
|
|
3827
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3828
|
+
* authoritative store.
|
|
3829
|
+
*
|
|
4497
3830
|
* @param store - The R3F store (from useStore or context)
|
|
4498
3831
|
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4499
3832
|
*/
|
|
@@ -4577,9 +3910,12 @@ declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCr
|
|
|
4577
3910
|
declare function useNodes<T extends Record<string, TSLNodeLike>>(creator: NodeCreator<T>, scope: string): NodesWithUtils<T>;
|
|
4578
3911
|
/**
|
|
4579
3912
|
* Global rebuildNodes function for HMR integration.
|
|
4580
|
-
*
|
|
3913
|
+
* Invalidates cached nodes and increments _hmrVersion to trigger re-creation.
|
|
4581
3914
|
* Call this when HMR is detected to refresh all node creators.
|
|
4582
3915
|
*
|
|
3916
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3917
|
+
* authoritative store.
|
|
3918
|
+
*
|
|
4583
3919
|
* @param store - The R3F store (from useStore or context)
|
|
4584
3920
|
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4585
3921
|
*/
|
|
@@ -4656,9 +3992,12 @@ declare function useBuffers<T extends Record<string, BufferLike>>(creator: Buffe
|
|
|
4656
3992
|
declare function useBuffers<T extends Record<string, BufferLike>>(creator: BufferCreator<T>, scope: string): BuffersWithUtils<T>;
|
|
4657
3993
|
/**
|
|
4658
3994
|
* Global rebuildBuffers function for HMR integration.
|
|
4659
|
-
*
|
|
3995
|
+
* Invalidates cached buffers and increments _hmrVersion to trigger re-creation.
|
|
4660
3996
|
* Call this when HMR is detected to refresh all buffer creators.
|
|
4661
3997
|
*
|
|
3998
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
3999
|
+
* authoritative store.
|
|
4000
|
+
*
|
|
4662
4001
|
* @param store - The R3F store (from useStore or context)
|
|
4663
4002
|
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4664
4003
|
*/
|
|
@@ -4690,14 +4029,34 @@ declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: S
|
|
|
4690
4029
|
declare function useGPUStorage<T extends Record<string, StorageLike>>(creator: StorageCreator<T>, scope: string): StorageWithUtils<T>;
|
|
4691
4030
|
/**
|
|
4692
4031
|
* Global rebuildStorage function for HMR integration.
|
|
4693
|
-
*
|
|
4032
|
+
* Invalidates cached storage and increments _hmrVersion to trigger re-creation.
|
|
4694
4033
|
* Call this when HMR is detected to refresh all storage creators.
|
|
4695
4034
|
*
|
|
4035
|
+
* Resolves to the primary store so shared TSL resources rebuild on the
|
|
4036
|
+
* authoritative store.
|
|
4037
|
+
*
|
|
4696
4038
|
* @param store - The R3F store (from useStore or context)
|
|
4697
4039
|
* @param scope - Optional scope to rebuild ('root' for root only, string for specific scope, undefined for all)
|
|
4698
4040
|
*/
|
|
4699
4041
|
declare function rebuildAllStorage(store: ReturnType<typeof useStore>, scope?: string): void;
|
|
4700
4042
|
|
|
4043
|
+
/**
|
|
4044
|
+
* Re-export from core - useTextures is now a core R3F hook (a reactive Texture registry).
|
|
4045
|
+
*
|
|
4046
|
+
* This file maintains backwards compatibility for existing webgpu imports.
|
|
4047
|
+
*/
|
|
4048
|
+
|
|
4049
|
+
/**
|
|
4050
|
+
* @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
|
|
4051
|
+
* Kept as an alias for backwards compatibility.
|
|
4052
|
+
*/
|
|
4053
|
+
type TextureEntry = Texture$1;
|
|
4054
|
+
/**
|
|
4055
|
+
* @deprecated The registry now stores plain `Texture` objects, not TSL nodes. Use `Texture` directly.
|
|
4056
|
+
* Kept as an alias for backwards compatibility.
|
|
4057
|
+
*/
|
|
4058
|
+
type TextureNode = Texture$1;
|
|
4059
|
+
|
|
4701
4060
|
interface TextureOperations {
|
|
4702
4061
|
add: (key: string, value: any) => void;
|
|
4703
4062
|
addMultiple: (items: Map<string, any> | Record<string, any>) => void;
|
|
@@ -4792,5 +4151,5 @@ interface WebGPURootState extends Omit<RootState, 'renderer' | 'gl' | 'internal'
|
|
|
4792
4151
|
internal: WebGPUInternalState
|
|
4793
4152
|
}
|
|
4794
4153
|
|
|
4795
|
-
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,
|
|
4796
|
-
export type { Act,
|
|
4154
|
+
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, act, 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, 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 };
|
|
4155
|
+
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, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };
|