@react-three/fiber 10.0.0-canary.d6fdf72 → 10.0.0-canary.da7a768
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 +2997 -3779
- package/dist/index.d.cts +98 -752
- package/dist/index.d.mts +98 -752
- package/dist/index.d.ts +98 -752
- package/dist/index.mjs +2708 -3489
- package/dist/legacy.cjs +2820 -3607
- package/dist/legacy.d.cts +97 -754
- package/dist/legacy.d.mts +97 -754
- package/dist/legacy.d.ts +97 -754
- package/dist/legacy.mjs +2873 -3659
- package/dist/webgpu/index.cjs +3072 -4075
- package/dist/webgpu/index.d.cts +139 -795
- package/dist/webgpu/index.d.mts +139 -795
- package/dist/webgpu/index.d.ts +139 -795
- package/dist/webgpu/index.mjs +3440 -4442
- package/package.json +6 -5
- package/readme.md +3 -4
- package/react-reconciler/constants.d.ts +0 -7
- package/react-reconciler/constants.js +0 -1
- package/react-reconciler/index.d.ts +0 -1044
- package/react-reconciler/index.js +0 -208
package/dist/index.d.mts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import * as three_examples_jsm_inspector_Inspector_js from 'three/examples/jsm/inspector/Inspector.js';
|
|
1
2
|
import * as three_webgpu from 'three/webgpu';
|
|
2
|
-
import { RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera } from 'three/webgpu';
|
|
3
|
+
import { CubeRenderTarget, RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera } from 'three/webgpu';
|
|
3
4
|
import * as THREE$1 from 'three';
|
|
4
|
-
import { WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
5
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
5
6
|
import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
|
|
6
7
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
7
8
|
import * as React$1 from 'react';
|
|
8
9
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
9
10
|
import { StoreApi } from 'zustand';
|
|
10
11
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
12
|
+
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
13
|
+
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
11
14
|
import { Options } from 'react-use-measure';
|
|
12
15
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
13
|
-
import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
|
|
14
16
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
15
17
|
|
|
16
18
|
function _mergeNamespaces(n, m) {
|
|
@@ -46,15 +48,22 @@ function _mergeNamespaces(n, m) {
|
|
|
46
48
|
declare const R3F_BUILD_LEGACY = true;
|
|
47
49
|
declare const R3F_BUILD_WEBGPU = true;
|
|
48
50
|
|
|
51
|
+
/** Lazily load the three Inspector. Keeps it out of the eager module graph — see note above. */
|
|
52
|
+
declare function loadInspector(): Promise<typeof three_examples_jsm_inspector_Inspector_js.Inspector>;
|
|
53
|
+
|
|
49
54
|
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
50
55
|
__proto__: null,
|
|
56
|
+
CubeRenderTarget: CubeRenderTarget,
|
|
57
|
+
CubeRenderTargetCompat: CubeRenderTarget,
|
|
51
58
|
Inspector: Inspector,
|
|
52
59
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
53
60
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
54
61
|
RenderTargetCompat: RenderTarget,
|
|
62
|
+
WebGLCubeRenderTarget: WebGLCubeRenderTarget,
|
|
55
63
|
WebGLRenderTarget: WebGLRenderTarget,
|
|
56
64
|
WebGLRenderer: WebGLRenderer,
|
|
57
|
-
WebGLRendererParameters: WebGLRendererParameters
|
|
65
|
+
WebGLRendererParameters: WebGLRendererParameters,
|
|
66
|
+
loadInspector: loadInspector
|
|
58
67
|
}, [three_webgpu]);
|
|
59
68
|
|
|
60
69
|
//* Utility Types ==============================
|
|
@@ -292,228 +301,33 @@ interface VisibilityEntry {
|
|
|
292
301
|
}
|
|
293
302
|
|
|
294
303
|
//* Scheduler Types (useFrame) ==============================
|
|
304
|
+
//
|
|
305
|
+
// The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
|
|
306
|
+
// This file re-exports them and layers r3f's RootState-aware frame state on top,
|
|
307
|
+
// so existing `#types` imports across the codebase keep resolving unchanged.
|
|
295
308
|
|
|
296
309
|
|
|
297
310
|
|
|
298
|
-
//
|
|
311
|
+
// Frame State (r3f-specific) --------------------------------
|
|
299
312
|
|
|
300
313
|
/**
|
|
301
|
-
*
|
|
302
|
-
*/
|
|
303
|
-
interface UseFrameNextOptions {
|
|
304
|
-
/** Optional stable id for the job. Auto-generated if not provided */
|
|
305
|
-
id?: string
|
|
306
|
-
/** Named phase to run in. Default: 'update' */
|
|
307
|
-
phase?: string
|
|
308
|
-
/** Run before this phase or job id */
|
|
309
|
-
before?: string | string[]
|
|
310
|
-
/** Run after this phase or job id */
|
|
311
|
-
after?: string | string[]
|
|
312
|
-
/** Priority within phase. Higher runs first. Default: 0 */
|
|
313
|
-
priority?: number
|
|
314
|
-
/** Max frames per second for this job */
|
|
315
|
-
fps?: number
|
|
316
|
-
/** If true, skip frames when behind. If false, try to catch up. Default: true */
|
|
317
|
-
drop?: boolean
|
|
318
|
-
/** Enable/disable without unregistering. Default: true */
|
|
319
|
-
enabled?: boolean
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/** Alias for UseFrameNextOptions */
|
|
323
|
-
type UseFrameOptions = UseFrameNextOptions
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Options for addPhase
|
|
327
|
-
*/
|
|
328
|
-
interface AddPhaseOptions {
|
|
329
|
-
/** Insert this phase before the specified phase */
|
|
330
|
-
before?: string
|
|
331
|
-
/** Insert this phase after the specified phase */
|
|
332
|
-
after?: string
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Frame State --------------------------------
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Timing-only state for independent/outside mode (no RootState)
|
|
339
|
-
*/
|
|
340
|
-
interface FrameTimingState {
|
|
341
|
-
/** High-resolution timestamp from RAF (ms) */
|
|
342
|
-
time: number
|
|
343
|
-
/** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
344
|
-
delta: number
|
|
345
|
-
/** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
346
|
-
elapsed: number
|
|
347
|
-
/** Incrementing frame counter */
|
|
348
|
-
frame: number
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* State passed to useFrame callbacks (extends RootState with timing)
|
|
314
|
+
* State passed to useFrame callbacks (extends RootState with timing).
|
|
353
315
|
*/
|
|
354
316
|
interface FrameNextState extends RootState, FrameTimingState {}
|
|
355
317
|
|
|
356
318
|
/** Alias for FrameNextState */
|
|
357
319
|
type FrameState = FrameNextState
|
|
358
320
|
|
|
359
|
-
//
|
|
321
|
+
// Callback Types (r3f-specific) --------------------------------
|
|
360
322
|
|
|
361
323
|
/**
|
|
362
|
-
*
|
|
324
|
+
* Callback function for useFrame. Receives the full r3f RootState plus timing.
|
|
363
325
|
*/
|
|
364
|
-
|
|
365
|
-
/** State provider for callbacks. Optional in independent mode. */
|
|
366
|
-
getState?: () => any
|
|
367
|
-
/** Error handler for job errors. Falls back to console.error if not provided. */
|
|
368
|
-
onError?: (error: Error) => void
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// Callback Types --------------------------------
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Callback function for useFrame
|
|
375
|
-
*/
|
|
376
|
-
type FrameNextCallback = (state: FrameNextState, delta: number) => void
|
|
326
|
+
type FrameNextCallback = FrameCallback$1<RootState>
|
|
377
327
|
|
|
378
328
|
/** Alias for FrameNextCallback */
|
|
379
329
|
type FrameCallback = FrameNextCallback
|
|
380
330
|
|
|
381
|
-
// Controls returned from useFrame --------------------------------
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Controls object returned from useFrame hook
|
|
385
|
-
*/
|
|
386
|
-
interface FrameNextControls {
|
|
387
|
-
/** The job's unique ID */
|
|
388
|
-
id: string
|
|
389
|
-
/** Access to the global scheduler for frame loop control */
|
|
390
|
-
scheduler: SchedulerApi
|
|
391
|
-
/** Manually step this job only (bypasses FPS limiting) */
|
|
392
|
-
step(timestamp?: number): void
|
|
393
|
-
/** Manually step ALL jobs in the scheduler */
|
|
394
|
-
stepAll(timestamp?: number): void
|
|
395
|
-
/** Pause this job (set enabled=false) */
|
|
396
|
-
pause(): void
|
|
397
|
-
/** Resume this job (set enabled=true) */
|
|
398
|
-
resume(): void
|
|
399
|
-
/** Reactive paused state - automatically triggers re-render when changed */
|
|
400
|
-
isPaused: boolean
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/** Alias for FrameNextControls */
|
|
404
|
-
type FrameControls = FrameNextControls
|
|
405
|
-
|
|
406
|
-
// Scheduler Interface --------------------------------
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Public interface for the global Scheduler
|
|
410
|
-
*/
|
|
411
|
-
interface SchedulerApi {
|
|
412
|
-
//* Phase Management --------------------------------
|
|
413
|
-
|
|
414
|
-
/** Add a named phase to the scheduler */
|
|
415
|
-
addPhase(name: string, options?: AddPhaseOptions): void
|
|
416
|
-
/** Get the ordered list of phase names */
|
|
417
|
-
readonly phases: string[]
|
|
418
|
-
/** Check if a phase exists */
|
|
419
|
-
hasPhase(name: string): boolean
|
|
420
|
-
|
|
421
|
-
//* Root Management --------------------------------
|
|
422
|
-
|
|
423
|
-
/** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
|
|
424
|
-
registerRoot(id: string, options?: RootOptions): () => void
|
|
425
|
-
/** Unregister a root */
|
|
426
|
-
unregisterRoot(id: string): void
|
|
427
|
-
/** Generate a unique root ID */
|
|
428
|
-
generateRootId(): string
|
|
429
|
-
/** Get the number of registered roots */
|
|
430
|
-
getRootCount(): number
|
|
431
|
-
/** Check if any root is registered and ready */
|
|
432
|
-
readonly isReady: boolean
|
|
433
|
-
/** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
|
|
434
|
-
onRootReady(callback: () => void): () => void
|
|
435
|
-
|
|
436
|
-
//* Job Registration --------------------------------
|
|
437
|
-
|
|
438
|
-
/** Register a job with the scheduler (returns unsubscribe function) */
|
|
439
|
-
register(
|
|
440
|
-
callback: FrameNextCallback,
|
|
441
|
-
options?: {
|
|
442
|
-
id?: string
|
|
443
|
-
rootId?: string
|
|
444
|
-
phase?: string
|
|
445
|
-
before?: string | string[]
|
|
446
|
-
after?: string | string[]
|
|
447
|
-
priority?: number
|
|
448
|
-
fps?: number
|
|
449
|
-
drop?: boolean
|
|
450
|
-
enabled?: boolean
|
|
451
|
-
},
|
|
452
|
-
): () => void
|
|
453
|
-
/** Update a job's options */
|
|
454
|
-
updateJob(
|
|
455
|
-
id: string,
|
|
456
|
-
options: {
|
|
457
|
-
priority?: number
|
|
458
|
-
fps?: number
|
|
459
|
-
drop?: boolean
|
|
460
|
-
enabled?: boolean
|
|
461
|
-
phase?: string
|
|
462
|
-
before?: string | string[]
|
|
463
|
-
after?: string | string[]
|
|
464
|
-
},
|
|
465
|
-
): void
|
|
466
|
-
/** Unregister a job by ID */
|
|
467
|
-
unregister(id: string, rootId?: string): void
|
|
468
|
-
/** Get the number of registered jobs */
|
|
469
|
-
getJobCount(): number
|
|
470
|
-
/** Get all job IDs */
|
|
471
|
-
getJobIds(): string[]
|
|
472
|
-
|
|
473
|
-
//* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
|
|
474
|
-
|
|
475
|
-
/** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
|
|
476
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
|
|
477
|
-
|
|
478
|
-
//* Idle Callbacks (for legacy addTail) --------------------------------
|
|
479
|
-
|
|
480
|
-
/** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
|
|
481
|
-
onIdle(callback: (timestamp: number) => void): () => void
|
|
482
|
-
|
|
483
|
-
//* Frame Loop Control --------------------------------
|
|
484
|
-
|
|
485
|
-
/** Start the scheduler loop */
|
|
486
|
-
start(): void
|
|
487
|
-
/** Stop the scheduler loop */
|
|
488
|
-
stop(): void
|
|
489
|
-
/** Check if the scheduler is running */
|
|
490
|
-
readonly isRunning: boolean
|
|
491
|
-
/** Get/set the frameloop mode ('always', 'demand', 'never') */
|
|
492
|
-
frameloop: Frameloop
|
|
493
|
-
/** Independent mode - runs without Canvas, callbacks receive timing-only state */
|
|
494
|
-
independent: boolean
|
|
495
|
-
|
|
496
|
-
//* Manual Stepping --------------------------------
|
|
497
|
-
|
|
498
|
-
/** Manually step all jobs once (for frameloop='never' or testing) */
|
|
499
|
-
step(timestamp?: number): void
|
|
500
|
-
/** Manually step a single job by ID */
|
|
501
|
-
stepJob(id: string, timestamp?: number): void
|
|
502
|
-
/** Request frame(s) to be rendered (for frameloop='demand') */
|
|
503
|
-
invalidate(frames?: number): void
|
|
504
|
-
|
|
505
|
-
//* Per-Job Control --------------------------------
|
|
506
|
-
|
|
507
|
-
/** Check if a job is paused */
|
|
508
|
-
isJobPaused(id: string): boolean
|
|
509
|
-
/** Pause a job */
|
|
510
|
-
pauseJob(id: string): void
|
|
511
|
-
/** Resume a job */
|
|
512
|
-
resumeJob(id: string): void
|
|
513
|
-
/** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
|
|
514
|
-
subscribeJobState(id: string, listener: () => void): () => void
|
|
515
|
-
}
|
|
516
|
-
|
|
517
331
|
//* Buffer Types (useBuffers) ========================================
|
|
518
332
|
|
|
519
333
|
/**
|
|
@@ -689,7 +503,7 @@ interface InternalState {
|
|
|
689
503
|
canvasTarget?: CanvasTarget
|
|
690
504
|
/**
|
|
691
505
|
* Whether multi-canvas rendering is active.
|
|
692
|
-
* True when any canvas uses `
|
|
506
|
+
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
693
507
|
* When true, setCanvasTarget is called before each render.
|
|
694
508
|
*/
|
|
695
509
|
isMultiCanvas?: boolean
|
|
@@ -787,8 +601,8 @@ interface RootState {
|
|
|
787
601
|
setSize: (width?: number, height?: number, top?: number, left?: number) => void
|
|
788
602
|
/** Shortcut to manual setting the pixel ratio */
|
|
789
603
|
setDpr: (dpr: Dpr) => void
|
|
790
|
-
/** Shortcut to setting frameloop flags */
|
|
791
|
-
setFrameloop: (frameloop
|
|
604
|
+
/** Shortcut to setting frameloop flags. No args resets to 'always'. */
|
|
605
|
+
setFrameloop: (frameloop?: Frameloop) => void
|
|
792
606
|
/** Set error state to propagate to error boundary */
|
|
793
607
|
setError: (error: Error | null) => void
|
|
794
608
|
/** Current error state (null when no error) */
|
|
@@ -806,7 +620,7 @@ interface RootState {
|
|
|
806
620
|
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
807
621
|
_textureRefs: Map<string, number>
|
|
808
622
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
809
|
-
renderPipeline:
|
|
623
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
810
624
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
811
625
|
passes: Record<string, any>
|
|
812
626
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
@@ -1099,8 +913,6 @@ interface Instance<O = any> {
|
|
|
1099
913
|
attach?: AttachType<O>
|
|
1100
914
|
previousAttach?: any
|
|
1101
915
|
isHidden: boolean
|
|
1102
|
-
/** Deferred ref props to apply in commitMount */
|
|
1103
|
-
deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
|
|
1104
916
|
/** Set of props that have been applied via once() */
|
|
1105
917
|
appliedOnce?: Set<string>
|
|
1106
918
|
}
|
|
@@ -1337,10 +1149,21 @@ type RenderTargetOptions = RenderTargetOptions$1
|
|
|
1337
1149
|
//* Global Types ==============================
|
|
1338
1150
|
|
|
1339
1151
|
declare global {
|
|
1340
|
-
/**
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1152
|
+
/**
|
|
1153
|
+
* Uniform node type.
|
|
1154
|
+
*
|
|
1155
|
+
* This is three's own `UniformNode`, not a re-declaration of it. It previously was a
|
|
1156
|
+
* hand-rolled `interface UniformNode<T> extends Node { value: T }`, which shadowed the real
|
|
1157
|
+
* exported type globally — so R3F's ~58 references resolved to an approximation that was
|
|
1158
|
+
* missing members three actually ships (`setName` among them) and had drifted to the wrong
|
|
1159
|
+
* arity when three made `UniformNode` two-parameter.
|
|
1160
|
+
*
|
|
1161
|
+
* three's signature is `UniformNode<TNodeType, TValue>`. R3F only ever varies the value type,
|
|
1162
|
+
* so the node type is fixed to `unknown` and the single parameter is kept for call-site
|
|
1163
|
+
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1164
|
+
* installed three instead of needing to be mirrored by hand.
|
|
1165
|
+
*/
|
|
1166
|
+
type UniformNode<T = unknown> = three_webgpu.UniformNode<unknown, T>
|
|
1344
1167
|
|
|
1345
1168
|
/**
|
|
1346
1169
|
* ShaderCallable - the return type of Fn()
|
|
@@ -1485,13 +1308,14 @@ declare module 'three/tsl' {
|
|
|
1485
1308
|
): ShaderCallable<R>
|
|
1486
1309
|
}
|
|
1487
1310
|
|
|
1488
|
-
/**
|
|
1489
|
-
* RenderPipeline Types for useRenderPipeline hook (WebGPU only)
|
|
1490
|
-
*/
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
1311
|
declare global {
|
|
1312
|
+
/**
|
|
1313
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1314
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1315
|
+
* is r185, so the new name is the only one.
|
|
1316
|
+
*/
|
|
1317
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1318
|
+
|
|
1495
1319
|
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1496
1320
|
type PassRecord = Record<string, any>
|
|
1497
1321
|
|
|
@@ -1506,7 +1330,7 @@ declare global {
|
|
|
1506
1330
|
/** Current passes from state */
|
|
1507
1331
|
passes: PassRecord
|
|
1508
1332
|
/** RenderPipeline instance (null if not initialized) */
|
|
1509
|
-
renderPipeline:
|
|
1333
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
1510
1334
|
/** Clear all passes from state */
|
|
1511
1335
|
clearPasses: () => void
|
|
1512
1336
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
@@ -1518,146 +1342,6 @@ declare global {
|
|
|
1518
1342
|
}
|
|
1519
1343
|
}
|
|
1520
1344
|
|
|
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
1345
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
1662
1346
|
|
|
1663
1347
|
interface MathRepresentation {
|
|
@@ -1827,7 +1511,7 @@ declare namespace three_d {
|
|
|
1827
1511
|
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
1828
1512
|
*
|
|
1829
1513
|
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
1830
|
-
* Secondary canvas: Has `
|
|
1514
|
+
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
1831
1515
|
*/
|
|
1832
1516
|
|
|
1833
1517
|
interface PrimaryCanvasEntry {
|
|
@@ -1895,12 +1579,23 @@ type EnvironmentLoaderProps = {
|
|
|
1895
1579
|
* const texture = useEnvironment({ preset: 'sunset' })
|
|
1896
1580
|
* ```
|
|
1897
1581
|
*/
|
|
1898
|
-
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture
|
|
1582
|
+
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
|
|
1899
1583
|
declare namespace useEnvironment {
|
|
1900
1584
|
var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
|
|
1901
1585
|
var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
|
|
1902
1586
|
}
|
|
1903
|
-
|
|
1587
|
+
/**
|
|
1588
|
+
* Options accepted by `useEnvironment.preload`.
|
|
1589
|
+
*
|
|
1590
|
+
* `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
|
|
1591
|
+
* applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
|
|
1592
|
+
* advertise an option this function silently ignores.
|
|
1593
|
+
*
|
|
1594
|
+
* This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
|
|
1595
|
+
* `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
|
|
1596
|
+
* type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
|
|
1597
|
+
*/
|
|
1598
|
+
type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
|
|
1904
1599
|
type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
|
|
1905
1600
|
|
|
1906
1601
|
/**
|
|
@@ -1944,9 +1639,9 @@ type EnvironmentProps = {
|
|
|
1944
1639
|
blur?: number;
|
|
1945
1640
|
backgroundBlurriness?: number;
|
|
1946
1641
|
backgroundIntensity?: number;
|
|
1947
|
-
backgroundRotation?: Euler
|
|
1642
|
+
backgroundRotation?: Euler;
|
|
1948
1643
|
environmentIntensity?: number;
|
|
1949
|
-
environmentRotation?: Euler
|
|
1644
|
+
environmentRotation?: Euler;
|
|
1950
1645
|
map?: Texture$1;
|
|
1951
1646
|
preset?: PresetsType;
|
|
1952
1647
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -2030,7 +1725,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
2030
1725
|
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
1726
|
declare module '@react-three/fiber' {
|
|
2032
1727
|
interface ThreeElements {
|
|
2033
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1728
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
2034
1729
|
}
|
|
2035
1730
|
}
|
|
2036
1731
|
/**
|
|
@@ -2130,6 +1825,24 @@ declare module '@react-three/fiber' {
|
|
|
2130
1825
|
*/
|
|
2131
1826
|
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
2132
1827
|
|
|
1828
|
+
/**
|
|
1829
|
+
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
1830
|
+
*
|
|
1831
|
+
* When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
|
|
1832
|
+
* instance. Removing the old object from the interaction state and registering the new one from
|
|
1833
|
+
* scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
|
|
1834
|
+
* the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
|
|
1835
|
+
* is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
|
|
1836
|
+
* swap the user never asked to see (#3744).
|
|
1837
|
+
*
|
|
1838
|
+
* Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
|
|
1839
|
+
* left alone — releasing and re-acquiring it is precisely the glitch being avoided.
|
|
1840
|
+
*
|
|
1841
|
+
* Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
|
|
1842
|
+
* the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
|
|
1843
|
+
* cannot outlive the object it described.
|
|
1844
|
+
*/
|
|
1845
|
+
declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
|
|
2133
1846
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
2134
1847
|
declare function createEvents(store: RootStore): {
|
|
2135
1848
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
@@ -2150,383 +1863,21 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
|
|
|
2150
1863
|
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
2151
1864
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
2152
1865
|
*/
|
|
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>;
|
|
1866
|
+
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
1867
|
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;
|
|
1868
|
+
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;
|
|
1869
|
+
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
|
|
2157
1870
|
var loader: typeof getLoader;
|
|
2158
1871
|
}
|
|
2159
1872
|
|
|
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
1873
|
/**
|
|
2524
1874
|
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
2525
1875
|
*
|
|
2526
|
-
*
|
|
2527
|
-
* - Inside Canvas: Full RootState (
|
|
2528
|
-
* - Outside Canvas
|
|
2529
|
-
*
|
|
1876
|
+
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1877
|
+
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1878
|
+
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1879
|
+
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1880
|
+
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
2530
1881
|
*
|
|
2531
1882
|
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
2532
1883
|
*
|
|
@@ -2543,16 +1894,16 @@ declare const getScheduler: () => Scheduler;
|
|
|
2543
1894
|
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
2544
1895
|
*
|
|
2545
1896
|
* @example
|
|
2546
|
-
* // Outside Canvas - waits for Canvas
|
|
1897
|
+
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
2547
1898
|
* function UI() {
|
|
2548
1899
|
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
2549
1900
|
* return <button>...</button>;
|
|
2550
1901
|
* }
|
|
2551
1902
|
*
|
|
2552
1903
|
* @example
|
|
2553
|
-
* //
|
|
2554
|
-
* getScheduler
|
|
2555
|
-
*
|
|
1904
|
+
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
1905
|
+
* import { getScheduler } from '@pmndrs/scheduler'
|
|
1906
|
+
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
2556
1907
|
*
|
|
2557
1908
|
* @example
|
|
2558
1909
|
* // Scheduler-only access (no callback)
|
|
@@ -3917,11 +3268,6 @@ declare function flushSync<R>(fn: () => R): R;
|
|
|
3917
3268
|
declare const context: React$1.Context<RootStore>;
|
|
3918
3269
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3919
3270
|
|
|
3920
|
-
/**
|
|
3921
|
-
* Safely flush async effects when testing, simulating a legacy root.
|
|
3922
|
-
* @deprecated Import from React instead. import { act } from 'react'
|
|
3923
|
-
*/
|
|
3924
|
-
declare const act: typeof React$1.act;
|
|
3925
3271
|
/**
|
|
3926
3272
|
* An SSR-friendly useLayoutEffect.
|
|
3927
3273
|
*
|
|
@@ -4405,5 +3751,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
4405
3751
|
*/
|
|
4406
3752
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
4407
3753
|
|
|
4408
|
-
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber,
|
|
4409
|
-
export type { Act,
|
|
3754
|
+
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3755
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeProps, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|