@react-three/fiber 10.0.0-canary.dbbe704 → 10.0.0-canary.dc0ec15
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/extension.cjs +278 -0
- package/dist/extension.d.cts +1675 -0
- package/dist/extension.d.mts +1675 -0
- package/dist/extension.d.ts +1647 -0
- package/dist/extension.mjs +258 -0
- package/dist/index.cjs +2751 -3185
- package/dist/index.d.cts +609 -931
- package/dist/index.d.mts +609 -931
- package/dist/index.d.ts +604 -954
- package/dist/index.mjs +2680 -3115
- package/dist/legacy.cjs +2719 -3160
- package/dist/legacy.d.cts +621 -974
- package/dist/legacy.d.mts +621 -974
- package/dist/legacy.d.ts +617 -996
- package/dist/legacy.mjs +2669 -3111
- package/dist/webgpu/index.cjs +3624 -3816
- package/dist/webgpu/index.d.cts +786 -1037
- package/dist/webgpu/index.d.mts +786 -1037
- package/dist/webgpu/index.d.ts +782 -1061
- package/dist/webgpu/index.mjs +3635 -3832
- package/package.json +11 -5
- package/readme.md +3 -4
- package/react-reconciler/constants.d.ts +0 -7
- package/react-reconciler/constants.js +0 -1
- package/react-reconciler/index.d.ts +0 -1044
- package/react-reconciler/index.js +0 -208
package/dist/legacy.d.mts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as THREE$1 from 'three';
|
|
2
|
-
import { WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1,
|
|
2
|
+
import { WebGLCubeRenderTarget, WebGLRenderTarget, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Object3D, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Frustum, OrthographicCamera } from 'three';
|
|
3
3
|
import * as React$1 from 'react';
|
|
4
4
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
5
5
|
import * as three_webgpu from 'three/webgpu';
|
|
6
|
-
import { WebGPURenderer as WebGPURenderer$1,
|
|
6
|
+
import { WebGPURenderer as WebGPURenderer$1, Node, StorageTexture, Storage3DTexture, StorageArrayTexture, Data3DTexture, CanvasTarget } from 'three/webgpu';
|
|
7
7
|
import { StoreApi } from 'zustand';
|
|
8
8
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
9
|
+
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
10
|
+
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
9
11
|
import { Options } from 'react-use-measure';
|
|
10
12
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
11
|
-
import { ThreeElement as ThreeElement$1, Euler as Euler$2 } from '@react-three/fiber';
|
|
12
13
|
import { GroundedSkybox } from 'three/examples/jsm/objects/GroundedSkybox.js';
|
|
13
14
|
|
|
14
15
|
function _mergeNamespaces(n, m) {
|
|
@@ -37,23 +38,28 @@ function _mergeNamespaces(n, m) {
|
|
|
37
38
|
declare const R3F_BUILD_LEGACY = true;
|
|
38
39
|
declare const R3F_BUILD_WEBGPU = false;
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
declare
|
|
44
|
-
|
|
45
|
-
}
|
|
41
|
+
type Inspector = never;
|
|
42
|
+
/** Not available on the legacy (WebGL-only) entry. */
|
|
43
|
+
declare function loadInspector(): Promise<never>;
|
|
44
|
+
declare class WebGPURenderer {
|
|
45
|
+
constructor();
|
|
46
|
+
}
|
|
46
47
|
|
|
47
48
|
declare const RenderTarget: any;
|
|
48
49
|
|
|
50
|
+
declare const CubeRenderTarget: any;
|
|
51
|
+
|
|
49
52
|
var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
50
53
|
__proto__: null,
|
|
54
|
+
CubeRenderTarget: CubeRenderTarget,
|
|
55
|
+
CubeRenderTargetCompat: WebGLCubeRenderTarget,
|
|
51
56
|
Inspector: Inspector,
|
|
52
57
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
53
58
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
54
59
|
RenderTarget: RenderTarget,
|
|
55
60
|
RenderTargetCompat: WebGLRenderTarget,
|
|
56
|
-
WebGPURenderer: WebGPURenderer
|
|
61
|
+
WebGPURenderer: WebGPURenderer,
|
|
62
|
+
loadInspector: loadInspector
|
|
57
63
|
}, [THREE$1]);
|
|
58
64
|
|
|
59
65
|
//* Utility Types ==============================
|
|
@@ -148,6 +154,8 @@ interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
|
148
154
|
unprojectedPoint: THREE$1.Vector3
|
|
149
155
|
/** Normalized event coordinates */
|
|
150
156
|
pointer: THREE$1.Vector2
|
|
157
|
+
/** pointerId of the original event for multiple pointer events */
|
|
158
|
+
pointerId: number
|
|
151
159
|
/** Delta between first click and this event */
|
|
152
160
|
delta: number
|
|
153
161
|
/** The ray that pierced it */
|
|
@@ -224,6 +232,18 @@ interface EventHandlers {
|
|
|
224
232
|
type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
|
|
225
233
|
type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
|
|
226
234
|
|
|
235
|
+
/** Configuration for XR pointer registration (controllers/hands) */
|
|
236
|
+
interface XRPointerConfig {
|
|
237
|
+
/** Ray origin (updated each frame by XR system) */
|
|
238
|
+
ray: THREE$1.Ray
|
|
239
|
+
/** Optional: custom compute function for this pointer */
|
|
240
|
+
compute?: (state: RootState) => void
|
|
241
|
+
/** Pointer type identifier */
|
|
242
|
+
type: 'controller' | 'hand' | 'gaze'
|
|
243
|
+
/** Which hand (for controller/hand types) */
|
|
244
|
+
handedness?: 'left' | 'right'
|
|
245
|
+
}
|
|
246
|
+
|
|
227
247
|
interface EventManager<TTarget> {
|
|
228
248
|
/** Determines if the event layer is active */
|
|
229
249
|
enabled: boolean
|
|
@@ -243,8 +263,21 @@ interface EventManager<TTarget> {
|
|
|
243
263
|
disconnect?: () => void
|
|
244
264
|
/** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
|
|
245
265
|
* explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
|
|
266
|
+
* @param pointerId - Optional pointer ID to update specific pointer only
|
|
246
267
|
*/
|
|
247
|
-
update?: () => void
|
|
268
|
+
update?: (pointerId?: number) => void
|
|
269
|
+
/** Defer pointer move raycasting to frame start (default: true) */
|
|
270
|
+
frameTimedRaycasts?: boolean
|
|
271
|
+
/** Always fire raycaster immediately on scroll events (default: true) */
|
|
272
|
+
alwaysFireOnScroll?: boolean
|
|
273
|
+
/** Automatically re-raycast every frame to detect hover changes from moving objects/camera (default: false) */
|
|
274
|
+
updateOnFrame?: boolean
|
|
275
|
+
/** Flush deferred pointer raycasts. Called by scheduler at frame start (input phase). */
|
|
276
|
+
flush?: () => void
|
|
277
|
+
/** Register an XR pointer (controller/hand). Returns assigned pointerId */
|
|
278
|
+
registerPointer?: (config: XRPointerConfig) => number
|
|
279
|
+
/** Unregister an XR pointer */
|
|
280
|
+
unregisterPointer?: (pointerId: number) => void
|
|
248
281
|
}
|
|
249
282
|
|
|
250
283
|
interface PointerCaptureTarget {
|
|
@@ -264,227 +297,116 @@ interface VisibilityEntry {
|
|
|
264
297
|
}
|
|
265
298
|
|
|
266
299
|
//* Scheduler Types (useFrame) ==============================
|
|
300
|
+
//
|
|
301
|
+
// The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
|
|
302
|
+
// This file re-exports them and layers r3f's RootState-aware frame state on top,
|
|
303
|
+
// so existing `#types` imports across the codebase keep resolving unchanged.
|
|
267
304
|
|
|
268
305
|
|
|
269
306
|
|
|
270
|
-
//
|
|
307
|
+
// Frame State (r3f-specific) --------------------------------
|
|
271
308
|
|
|
272
309
|
/**
|
|
273
|
-
*
|
|
310
|
+
* State passed to useFrame callbacks (extends RootState with timing).
|
|
274
311
|
*/
|
|
275
|
-
interface
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
phase?: string
|
|
280
|
-
/** Run before this phase or job id */
|
|
281
|
-
before?: string | string[]
|
|
282
|
-
/** Run after this phase or job id */
|
|
283
|
-
after?: string | string[]
|
|
284
|
-
/** Priority within phase. Higher runs first. Default: 0 */
|
|
285
|
-
priority?: number
|
|
286
|
-
/** Max frames per second for this job */
|
|
287
|
-
fps?: number
|
|
288
|
-
/** If true, skip frames when behind. If false, try to catch up. Default: true */
|
|
289
|
-
drop?: boolean
|
|
290
|
-
/** Enable/disable without unregistering. Default: true */
|
|
291
|
-
enabled?: boolean
|
|
292
|
-
}
|
|
312
|
+
interface FrameNextState extends RootState, FrameTimingState {}
|
|
313
|
+
|
|
314
|
+
/** Alias for FrameNextState */
|
|
315
|
+
type FrameState = FrameNextState
|
|
293
316
|
|
|
294
|
-
|
|
295
|
-
type UseFrameOptions = UseFrameNextOptions
|
|
317
|
+
// Callback Types (r3f-specific) --------------------------------
|
|
296
318
|
|
|
297
319
|
/**
|
|
298
|
-
*
|
|
320
|
+
* Callback function for useFrame. Receives the full r3f RootState plus timing.
|
|
299
321
|
*/
|
|
300
|
-
|
|
301
|
-
/** Insert this phase before the specified phase */
|
|
302
|
-
before?: string
|
|
303
|
-
/** Insert this phase after the specified phase */
|
|
304
|
-
after?: string
|
|
305
|
-
}
|
|
322
|
+
type FrameNextCallback = FrameCallback$1<RootState>
|
|
306
323
|
|
|
307
|
-
|
|
324
|
+
/** Alias for FrameNextCallback */
|
|
325
|
+
type FrameCallback = FrameNextCallback
|
|
326
|
+
|
|
327
|
+
//* Buffer Types (useBuffers) ========================================
|
|
308
328
|
|
|
309
329
|
/**
|
|
310
|
-
*
|
|
330
|
+
* Buffer-like types for GPU compute and storage operations.
|
|
331
|
+
* Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```tsx
|
|
335
|
+
* const { positions, velocities } = useBuffers(() => ({
|
|
336
|
+
* positions: instancedArray(count, 'vec3'), // StorageBufferNode
|
|
337
|
+
* velocities: new Float32Array(count * 3), // TypedArray
|
|
338
|
+
* }), 'particles')
|
|
339
|
+
* ```
|
|
311
340
|
*/
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
341
|
+
type BufferLike =
|
|
342
|
+
| Float32Array
|
|
343
|
+
| Uint32Array
|
|
344
|
+
| Int32Array
|
|
345
|
+
| Float64Array
|
|
346
|
+
| Uint8Array
|
|
347
|
+
| Int8Array
|
|
348
|
+
| Uint16Array
|
|
349
|
+
| Int16Array
|
|
350
|
+
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
351
|
+
| THREE$1.InterleavedBufferAttribute
|
|
352
|
+
| Node // TSL buffer nodes (instancedArray, storage)
|
|
353
|
+
|
|
354
|
+
/** Flat record of buffer-like values (no nested scopes) */
|
|
355
|
+
type BufferRecord = Record<string, BufferLike>
|
|
322
356
|
|
|
323
357
|
/**
|
|
324
|
-
*
|
|
358
|
+
* Buffer store that can contain both root-level buffers and scoped buffer objects.
|
|
359
|
+
* Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
|
|
325
360
|
*/
|
|
326
|
-
|
|
361
|
+
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
327
362
|
|
|
328
|
-
|
|
329
|
-
type FrameState = FrameNextState
|
|
330
|
-
|
|
331
|
-
// Root Options --------------------------------
|
|
363
|
+
//* Node Types (useNodes) ========================================
|
|
332
364
|
|
|
333
365
|
/**
|
|
334
|
-
*
|
|
366
|
+
* Every node representation `useNodes` accepts and `state.nodes` holds: three's real `Node`,
|
|
367
|
+
* the callable proxy `Fn()` returns, and the legacy structural shape (`uuid`/`nodeType`) older
|
|
368
|
+
* code passes through. Creators are constrained to this same type, so the shape a creator returns
|
|
369
|
+
* and the shape the store holds are one type by construction.
|
|
335
370
|
*/
|
|
336
|
-
|
|
337
|
-
/** State provider for callbacks. Optional in independent mode. */
|
|
338
|
-
getState?: () => any
|
|
339
|
-
/** Error handler for job errors. Falls back to console.error if not provided. */
|
|
340
|
-
onError?: (error: Error) => void
|
|
341
|
-
}
|
|
371
|
+
type NodeLike = TSLNodeType | LegacyTSLNodeLike
|
|
342
372
|
|
|
343
|
-
|
|
373
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
374
|
+
type NodeRecord<T extends NodeLike = NodeLike> = Record<string, T>
|
|
344
375
|
|
|
345
376
|
/**
|
|
346
|
-
*
|
|
377
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
378
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
347
379
|
*/
|
|
348
|
-
type
|
|
380
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
349
381
|
|
|
350
|
-
|
|
351
|
-
type FrameCallback = FrameNextCallback
|
|
352
|
-
|
|
353
|
-
// Controls returned from useFrame --------------------------------
|
|
382
|
+
//* Storage Types (useGPUStorage) ========================================
|
|
354
383
|
|
|
355
384
|
/**
|
|
356
|
-
*
|
|
385
|
+
* GPU storage types for texture-based storage operations.
|
|
386
|
+
* Includes Three.js storage textures and TSL storage texture nodes.
|
|
387
|
+
*
|
|
388
|
+
* @example
|
|
389
|
+
* ```tsx
|
|
390
|
+
* const { heightMap } = useGPUStorage(() => ({
|
|
391
|
+
* heightMap: new StorageTexture(512, 512),
|
|
392
|
+
* }), 'terrain')
|
|
393
|
+
* ```
|
|
357
394
|
*/
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
step(timestamp?: number): void
|
|
365
|
-
/** Manually step ALL jobs in the scheduler */
|
|
366
|
-
stepAll(timestamp?: number): void
|
|
367
|
-
/** Pause this job (set enabled=false) */
|
|
368
|
-
pause(): void
|
|
369
|
-
/** Resume this job (set enabled=true) */
|
|
370
|
-
resume(): void
|
|
371
|
-
/** Reactive paused state - automatically triggers re-render when changed */
|
|
372
|
-
isPaused: boolean
|
|
373
|
-
}
|
|
395
|
+
type StorageLike =
|
|
396
|
+
| StorageTexture // 2D GPU storage texture
|
|
397
|
+
| Storage3DTexture // 3D GPU storage texture (volumes, fluid grids)
|
|
398
|
+
| StorageArrayTexture // 2D-array GPU storage texture
|
|
399
|
+
| Data3DTexture // 3D texture (can be used as storage)
|
|
400
|
+
| Node // TSL storage texture nodes (storageTexture)
|
|
374
401
|
|
|
375
|
-
/**
|
|
376
|
-
type
|
|
377
|
-
|
|
378
|
-
// Scheduler Interface --------------------------------
|
|
402
|
+
/** Flat record of storage-like values (no nested scopes) */
|
|
403
|
+
type StorageRecord = Record<string, StorageLike>
|
|
379
404
|
|
|
380
405
|
/**
|
|
381
|
-
*
|
|
406
|
+
* Storage store that can contain both root-level storage and scoped storage objects.
|
|
407
|
+
* Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
|
|
382
408
|
*/
|
|
383
|
-
|
|
384
|
-
//* Phase Management --------------------------------
|
|
385
|
-
|
|
386
|
-
/** Add a named phase to the scheduler */
|
|
387
|
-
addPhase(name: string, options?: AddPhaseOptions): void
|
|
388
|
-
/** Get the ordered list of phase names */
|
|
389
|
-
readonly phases: string[]
|
|
390
|
-
/** Check if a phase exists */
|
|
391
|
-
hasPhase(name: string): boolean
|
|
392
|
-
|
|
393
|
-
//* Root Management --------------------------------
|
|
394
|
-
|
|
395
|
-
/** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
|
|
396
|
-
registerRoot(id: string, options?: RootOptions): () => void
|
|
397
|
-
/** Unregister a root */
|
|
398
|
-
unregisterRoot(id: string): void
|
|
399
|
-
/** Generate a unique root ID */
|
|
400
|
-
generateRootId(): string
|
|
401
|
-
/** Get the number of registered roots */
|
|
402
|
-
getRootCount(): number
|
|
403
|
-
/** Check if any root is registered and ready */
|
|
404
|
-
readonly isReady: boolean
|
|
405
|
-
/** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
|
|
406
|
-
onRootReady(callback: () => void): () => void
|
|
407
|
-
|
|
408
|
-
//* Job Registration --------------------------------
|
|
409
|
-
|
|
410
|
-
/** Register a job with the scheduler (returns unsubscribe function) */
|
|
411
|
-
register(
|
|
412
|
-
callback: FrameNextCallback,
|
|
413
|
-
options?: {
|
|
414
|
-
id?: string
|
|
415
|
-
rootId?: string
|
|
416
|
-
phase?: string
|
|
417
|
-
before?: string | string[]
|
|
418
|
-
after?: string | string[]
|
|
419
|
-
priority?: number
|
|
420
|
-
fps?: number
|
|
421
|
-
drop?: boolean
|
|
422
|
-
enabled?: boolean
|
|
423
|
-
},
|
|
424
|
-
): () => void
|
|
425
|
-
/** Update a job's options */
|
|
426
|
-
updateJob(
|
|
427
|
-
id: string,
|
|
428
|
-
options: {
|
|
429
|
-
priority?: number
|
|
430
|
-
fps?: number
|
|
431
|
-
drop?: boolean
|
|
432
|
-
enabled?: boolean
|
|
433
|
-
phase?: string
|
|
434
|
-
before?: string | string[]
|
|
435
|
-
after?: string | string[]
|
|
436
|
-
},
|
|
437
|
-
): void
|
|
438
|
-
/** Unregister a job by ID */
|
|
439
|
-
unregister(id: string, rootId?: string): void
|
|
440
|
-
/** Get the number of registered jobs */
|
|
441
|
-
getJobCount(): number
|
|
442
|
-
/** Get all job IDs */
|
|
443
|
-
getJobIds(): string[]
|
|
444
|
-
|
|
445
|
-
//* Global Jobs (for legacy addEffect/addAfterEffect) --------------------------------
|
|
446
|
-
|
|
447
|
-
/** Register a global job (runs once per frame, not per-root). Returns unsubscribe function. */
|
|
448
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void
|
|
449
|
-
|
|
450
|
-
//* Idle Callbacks (for legacy addTail) --------------------------------
|
|
451
|
-
|
|
452
|
-
/** Register an idle callback (fires when loop stops). Returns unsubscribe function. */
|
|
453
|
-
onIdle(callback: (timestamp: number) => void): () => void
|
|
454
|
-
|
|
455
|
-
//* Frame Loop Control --------------------------------
|
|
456
|
-
|
|
457
|
-
/** Start the scheduler loop */
|
|
458
|
-
start(): void
|
|
459
|
-
/** Stop the scheduler loop */
|
|
460
|
-
stop(): void
|
|
461
|
-
/** Check if the scheduler is running */
|
|
462
|
-
readonly isRunning: boolean
|
|
463
|
-
/** Get/set the frameloop mode ('always', 'demand', 'never') */
|
|
464
|
-
frameloop: Frameloop
|
|
465
|
-
/** Independent mode - runs without Canvas, callbacks receive timing-only state */
|
|
466
|
-
independent: boolean
|
|
467
|
-
|
|
468
|
-
//* Manual Stepping --------------------------------
|
|
469
|
-
|
|
470
|
-
/** Manually step all jobs once (for frameloop='never' or testing) */
|
|
471
|
-
step(timestamp?: number): void
|
|
472
|
-
/** Manually step a single job by ID */
|
|
473
|
-
stepJob(id: string, timestamp?: number): void
|
|
474
|
-
/** Request frame(s) to be rendered (for frameloop='demand') */
|
|
475
|
-
invalidate(frames?: number): void
|
|
476
|
-
|
|
477
|
-
//* Per-Job Control --------------------------------
|
|
478
|
-
|
|
479
|
-
/** Check if a job is paused */
|
|
480
|
-
isJobPaused(id: string): boolean
|
|
481
|
-
/** Pause a job */
|
|
482
|
-
pauseJob(id: string): void
|
|
483
|
-
/** Resume a job */
|
|
484
|
-
resumeJob(id: string): void
|
|
485
|
-
/** Subscribe to job state changes (for reactive isPaused). Returns unsubscribe function. */
|
|
486
|
-
subscribeJobState(id: string, listener: () => void): () => void
|
|
487
|
-
}
|
|
409
|
+
type StorageStore = Record<string, StorageLike | StorageRecord>
|
|
488
410
|
|
|
489
411
|
//* Renderer Types ========================================
|
|
490
412
|
|
|
@@ -499,6 +421,18 @@ type Subscription = {
|
|
|
499
421
|
store: RootStore
|
|
500
422
|
}
|
|
501
423
|
|
|
424
|
+
/** Per-pointer state for multi-touch and XR support */
|
|
425
|
+
type PointerState = {
|
|
426
|
+
/** Objects currently hovered by this pointer */
|
|
427
|
+
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
428
|
+
/** Objects capturing this pointer */
|
|
429
|
+
captured: Map<THREE$1.Object3D, PointerCaptureTarget>
|
|
430
|
+
/** Initial click position [x, y] */
|
|
431
|
+
initialClick: [x: number, y: number]
|
|
432
|
+
/** Objects hit on initial click */
|
|
433
|
+
initialHits: THREE$1.Object3D[]
|
|
434
|
+
}
|
|
435
|
+
|
|
502
436
|
type Dpr = number | [min: number, max: number]
|
|
503
437
|
|
|
504
438
|
interface Size {
|
|
@@ -540,12 +474,21 @@ interface Performance {
|
|
|
540
474
|
|
|
541
475
|
interface InternalState {
|
|
542
476
|
interaction: THREE$1.Object3D[]
|
|
543
|
-
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
544
477
|
subscribers: Subscription[]
|
|
478
|
+
/** Per-pointer state (hover, capture, click tracking) - replaces hovered, capturedMap, initialClick, initialHits */
|
|
479
|
+
pointerMap: Map<number, PointerState>
|
|
480
|
+
/** Pointers needing raycast this frame (used with frameTimedRaycasts) */
|
|
481
|
+
pointerDirty: Map<number, DomEvent>
|
|
482
|
+
/** Last event received (for events.update() compatibility) */
|
|
483
|
+
lastEvent: React$1.RefObject<DomEvent | null>
|
|
484
|
+
/** @deprecated Use pointerMap.get(pointerId).hovered instead */
|
|
485
|
+
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
486
|
+
/** @deprecated Use pointerMap.get(pointerId).captured instead */
|
|
545
487
|
capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
|
|
488
|
+
/** @deprecated Use pointerMap.get(pointerId).initialClick instead */
|
|
546
489
|
initialClick: [x: number, y: number]
|
|
490
|
+
/** @deprecated Use pointerMap.get(pointerId).initialHits instead */
|
|
547
491
|
initialHits: THREE$1.Object3D[]
|
|
548
|
-
lastEvent: React$1.RefObject<DomEvent | null>
|
|
549
492
|
/** Visibility event registry (onFramed, onOccluded, onVisible) */
|
|
550
493
|
visibilityRegistry: Map<string, VisibilityEntry>
|
|
551
494
|
/** Whether occlusion queries are enabled (WebGPU only) */
|
|
@@ -564,6 +507,12 @@ interface InternalState {
|
|
|
564
507
|
actualRenderer: R3FRenderer
|
|
565
508
|
/** Global scheduler reference (for useFrame hook) */
|
|
566
509
|
scheduler: SchedulerApi | null
|
|
510
|
+
/**
|
|
511
|
+
* Replaces `renderer.render(scene, camera)` in the default render job when set. Set it with
|
|
512
|
+
* `setRenderOverride(store, fn)`; the job keeps its fps throttle, error handling and user
|
|
513
|
+
* render-phase takeover. Used by `useRenderPipeline`.
|
|
514
|
+
*/
|
|
515
|
+
renderOverride?: (() => void) | null
|
|
567
516
|
/** This root's unique ID in the global scheduler */
|
|
568
517
|
rootId?: string
|
|
569
518
|
/** Function to unregister this root from the global scheduler */
|
|
@@ -571,14 +520,31 @@ interface InternalState {
|
|
|
571
520
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
572
521
|
container?: THREE$1.Object3D
|
|
573
522
|
/**
|
|
574
|
-
* CanvasTarget
|
|
575
|
-
*
|
|
523
|
+
* The CanvasTarget this root sizes and renders through.
|
|
524
|
+
*
|
|
525
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
526
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
527
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
528
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
529
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
576
530
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
577
531
|
*/
|
|
578
532
|
canvasTarget?: CanvasTarget
|
|
533
|
+
/**
|
|
534
|
+
* Set when this root's canvas target has been resized and the backend's cached render pass
|
|
535
|
+
* descriptor (which holds a depth-stencil view built once per canvas) is therefore stale.
|
|
536
|
+
*
|
|
537
|
+
* Flushed by the canvas-target job in the `start` phase, which is the only place this root's
|
|
538
|
+
* target is guaranteed to be the renderer's active one — `backend.updateSize()` operates on
|
|
539
|
+
* whatever `getCanvasTarget()` returns, so calling it from the resize subscription would
|
|
540
|
+
* invalidate some other canvas's descriptor instead.
|
|
541
|
+
*
|
|
542
|
+
* @see https://github.com/pmndrs/react-three-fiber/issues/3847
|
|
543
|
+
*/
|
|
544
|
+
canvasTargetSizeDirty?: boolean
|
|
579
545
|
/**
|
|
580
546
|
* Whether multi-canvas rendering is active.
|
|
581
|
-
* True when any canvas uses `
|
|
547
|
+
* True when any canvas uses `renderer={{ primaryCanvas: 'id' }}` to share a renderer.
|
|
582
548
|
* When true, setCanvasTarget is called before each render.
|
|
583
549
|
*/
|
|
584
550
|
isMultiCanvas?: boolean
|
|
@@ -676,8 +642,8 @@ interface RootState {
|
|
|
676
642
|
setSize: (width?: number, height?: number, top?: number, left?: number) => void
|
|
677
643
|
/** Shortcut to manual setting the pixel ratio */
|
|
678
644
|
setDpr: (dpr: Dpr) => void
|
|
679
|
-
/** Shortcut to setting frameloop flags */
|
|
680
|
-
setFrameloop: (frameloop
|
|
645
|
+
/** Shortcut to setting frameloop flags. No args resets to 'always'. */
|
|
646
|
+
setFrameloop: (frameloop?: Frameloop) => void
|
|
681
647
|
/** Set error state to propagate to error boundary */
|
|
682
648
|
setError: (error: Error | null) => void
|
|
683
649
|
/** Current error state (null when no error) */
|
|
@@ -685,13 +651,19 @@ interface RootState {
|
|
|
685
651
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
686
652
|
uniforms: UniformStore
|
|
687
653
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
688
|
-
nodes:
|
|
689
|
-
/** Global TSL
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
|
|
693
|
-
/** Global
|
|
694
|
-
|
|
654
|
+
nodes: NodeStore
|
|
655
|
+
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
656
|
+
buffers: BufferStore
|
|
657
|
+
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
658
|
+
gpuStorage: StorageStore
|
|
659
|
+
/** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
|
|
660
|
+
textures: Map<string, THREE$1.Texture>
|
|
661
|
+
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
662
|
+
_textureRefs: Map<string, number>
|
|
663
|
+
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
664
|
+
renderPipeline: ThreeRenderPipeline | null
|
|
665
|
+
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
666
|
+
passes: PassRecord
|
|
695
667
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
696
668
|
_hmrVersion: number
|
|
697
669
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -740,6 +712,20 @@ interface Renderer {
|
|
|
740
712
|
render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
|
|
741
713
|
}
|
|
742
714
|
|
|
715
|
+
//* Color Management Config ==============================
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Color management configuration shared by both WebGL and WebGPU renderers.
|
|
719
|
+
*/
|
|
720
|
+
interface ColorManagementConfig {
|
|
721
|
+
/**
|
|
722
|
+
* Color space assigned to 8-bit input textures (color maps).
|
|
723
|
+
* Defaults to sRGB. Most textures are authored in sRGB.
|
|
724
|
+
* @default THREE.SRGBColorSpace
|
|
725
|
+
*/
|
|
726
|
+
textureColorSpace?: THREE$1.ColorSpace
|
|
727
|
+
}
|
|
728
|
+
|
|
743
729
|
//* WebGL Renderer Props ==============================
|
|
744
730
|
|
|
745
731
|
type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
|
|
@@ -750,7 +736,7 @@ type GLProps =
|
|
|
750
736
|
| Renderer
|
|
751
737
|
| ((defaultProps: DefaultGLProps) => Renderer)
|
|
752
738
|
| ((defaultProps: DefaultGLProps) => Promise<Renderer>)
|
|
753
|
-
| Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
|
|
739
|
+
| (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
|
|
754
740
|
|
|
755
741
|
//* WebGPU Renderer Props ==============================
|
|
756
742
|
|
|
@@ -765,20 +751,27 @@ type DefaultRendererProps = {
|
|
|
765
751
|
*/
|
|
766
752
|
interface CanvasSchedulerConfig {
|
|
767
753
|
/**
|
|
768
|
-
*
|
|
769
|
-
* Pass the `id` of another canvas.
|
|
754
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
770
755
|
*/
|
|
771
|
-
|
|
756
|
+
before?: string | string[]
|
|
772
757
|
/**
|
|
773
|
-
*
|
|
758
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
759
|
+
*/
|
|
760
|
+
after?: string | string[]
|
|
761
|
+
/**
|
|
762
|
+
* Numeric root order. Lower values run first.
|
|
763
|
+
*/
|
|
764
|
+
order?: number
|
|
765
|
+
/**
|
|
766
|
+
* Limit this Canvas's default render job (frames per second).
|
|
774
767
|
*/
|
|
775
768
|
fps?: number
|
|
776
769
|
}
|
|
777
770
|
|
|
778
771
|
/**
|
|
779
|
-
* Extended renderer configuration for multi-canvas support.
|
|
772
|
+
* Extended renderer configuration for multi-canvas support and color management.
|
|
780
773
|
*/
|
|
781
|
-
interface RendererConfigExtended {
|
|
774
|
+
interface RendererConfigExtended extends ColorManagementConfig {
|
|
782
775
|
/** Share renderer from another canvas (WebGPU only) */
|
|
783
776
|
primaryCanvas?: string
|
|
784
777
|
/** Canvas-level scheduler options */
|
|
@@ -843,8 +836,6 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
843
836
|
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
844
837
|
*/
|
|
845
838
|
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
|
|
846
|
-
/** Color space assigned to 8-bit input textures (color maps). Defaults to sRGB. Most textures are authored in sRGB. */
|
|
847
|
-
textureColorSpace?: THREE$1.ColorSpace
|
|
848
839
|
/** Creates an orthographic camera */
|
|
849
840
|
orthographic?: boolean
|
|
850
841
|
/**
|
|
@@ -859,14 +850,17 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
859
850
|
performance?: Partial<Omit<Performance, 'regress'>>
|
|
860
851
|
/** Target pixel ratio. Can clamp between a range: `[min, max]` */
|
|
861
852
|
dpr?: Dpr
|
|
862
|
-
/**
|
|
863
|
-
|
|
853
|
+
/**
|
|
854
|
+
* Props that go into the default raycaster. `params` is merged into the raycaster's defaults,
|
|
855
|
+
* so a single threshold can be set: `raycaster={{ params: { Points: { threshold: 0.2 } } }}`.
|
|
856
|
+
*/
|
|
857
|
+
raycaster?: Partial<Omit<THREE$1.Raycaster, 'params'>> & { params?: Partial<THREE$1.RaycasterParameters> }
|
|
864
858
|
/** A `THREE.Scene` instance or props that go into the default scene */
|
|
865
859
|
scene?: THREE$1.Scene | Partial<THREE$1.Scene>
|
|
866
860
|
/** A `THREE.Camera` instance or props that go into the default camera */
|
|
867
861
|
camera?: CameraProps
|
|
868
862
|
/** An R3F event manager to manage elements' pointer events */
|
|
869
|
-
events?: (store: RootStore) => EventManager<
|
|
863
|
+
events?: (store: RootStore) => EventManager<Element>
|
|
870
864
|
/** Callback after the canvas has rendered (but not yet committed) */
|
|
871
865
|
onCreated?: (state: RootState) => void
|
|
872
866
|
/** Response for pointer clicks that have missed any target */
|
|
@@ -955,7 +949,6 @@ type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
|
955
949
|
object?: T
|
|
956
950
|
dispose?: null
|
|
957
951
|
attach?: AttachType<T>
|
|
958
|
-
onUpdate?: (self: T) => void
|
|
959
952
|
}
|
|
960
953
|
|
|
961
954
|
interface Instance<O = any> {
|
|
@@ -970,8 +963,6 @@ interface Instance<O = any> {
|
|
|
970
963
|
attach?: AttachType<O>
|
|
971
964
|
previousAttach?: any
|
|
972
965
|
isHidden: boolean
|
|
973
|
-
/** Deferred ref props to apply in commitMount */
|
|
974
|
-
deferredRefs?: Array<{ prop: string; ref: React$1.RefObject<any> }>
|
|
975
966
|
/** Set of props that have been applied via once() */
|
|
976
967
|
appliedOnce?: Set<string>
|
|
977
968
|
}
|
|
@@ -1097,7 +1088,7 @@ interface CanvasProps
|
|
|
1097
1088
|
*/
|
|
1098
1089
|
resize?: Options
|
|
1099
1090
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1100
|
-
eventSource?:
|
|
1091
|
+
eventSource?: Element | React$1.RefObject<Element | null>
|
|
1101
1092
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1102
1093
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1103
1094
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1205,70 +1196,86 @@ interface LegacyRootState extends Omit<RootState, 'renderer' | 'internal'> {
|
|
|
1205
1196
|
|
|
1206
1197
|
type RenderTargetOptions = RenderTargetOptions$1
|
|
1207
1198
|
|
|
1208
|
-
//* Global Types ==============================
|
|
1199
|
+
//* Global TSL Types ==============================
|
|
1209
1200
|
|
|
1210
1201
|
declare global {
|
|
1211
|
-
/** Uniform node type - a Node with a value property (matches Three.js UniformNode) */
|
|
1212
|
-
interface UniformNode<T = unknown> extends Node {
|
|
1213
|
-
value: T
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
1202
|
/**
|
|
1217
|
-
*
|
|
1218
|
-
*
|
|
1219
|
-
* The function returns a ShaderNodeObject when called.
|
|
1220
|
-
*
|
|
1221
|
-
* @example
|
|
1222
|
-
* ```tsx
|
|
1223
|
-
* // Define a shader function
|
|
1224
|
-
* const blendColorFn = Fn(([color1, color2, factor]) => {
|
|
1225
|
-
* return mix(color1, color2, factor)
|
|
1226
|
-
* })
|
|
1227
|
-
*
|
|
1228
|
-
* // Type when retrieving from nodes store
|
|
1229
|
-
* const { blendColorFn } = nodes as { blendColorFn: ShaderCallable }
|
|
1230
|
-
*
|
|
1231
|
-
* // Or with specific return type
|
|
1232
|
-
* const { myFn } = nodes as { myFn: ShaderCallable<THREE.Node> }
|
|
1233
|
-
* ```
|
|
1203
|
+
* Broad callable-node fallback for dynamic store readers.
|
|
1204
|
+
* Creator hooks preserve the exact function signatures inferred from Three's `Fn`.
|
|
1234
1205
|
*/
|
|
1235
|
-
type
|
|
1206
|
+
type CallableTSLNode = ((...params: never[]) => unknown) & {
|
|
1207
|
+
readonly shaderNode: unknown
|
|
1208
|
+
readonly id: number
|
|
1209
|
+
}
|
|
1236
1210
|
|
|
1237
|
-
/**
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
*/
|
|
1246
|
-
type ShaderNodeRef<T extends Node = Node> = ShaderNodeObject<T>
|
|
1211
|
+
/** Legacy structural node accepted when at least one historical marker exists. */
|
|
1212
|
+
type LegacyTSLNodeLike = {
|
|
1213
|
+
label?: ((label: string) => unknown) | string
|
|
1214
|
+
setName?: (name: string) => unknown
|
|
1215
|
+
} & ({ uuid: string | undefined; nodeType?: string | null } | { uuid?: string; nodeType: string | null | undefined })
|
|
1216
|
+
|
|
1217
|
+
/** Node type accepted by broad dynamic node-store readers. */
|
|
1218
|
+
type TSLNodeType = three_webgpu.Node | CallableTSLNode
|
|
1247
1219
|
|
|
1248
1220
|
/**
|
|
1249
|
-
*
|
|
1250
|
-
*
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
* - Node: base Three.js node type
|
|
1254
|
-
* - ShaderCallable: function nodes created with Fn()
|
|
1255
|
-
* - ShaderNodeObject: wrapped nodes from TSL operations (sin, mul, mix, etc.)
|
|
1256
|
-
*
|
|
1257
|
-
* @example
|
|
1258
|
-
* ```tsx
|
|
1259
|
-
* // In useLocalNodes, nodes are typed as TSLNodeType
|
|
1260
|
-
* const { positionNode, blendColorFn } = useLocalNodes(({ nodes }) => ({
|
|
1261
|
-
* positionNode: nodes.myPosition, // Works - Node is in union
|
|
1262
|
-
* blendColorFn: nodes.myFn, // Works - ShaderCallable is in union
|
|
1263
|
-
* }))
|
|
1264
|
-
*
|
|
1265
|
-
* // Can narrow with type guard or assertion when needed
|
|
1266
|
-
* if (typeof blendColorFn === 'function') {
|
|
1267
|
-
* blendColorFn(someColor, 0.5)
|
|
1268
|
-
* }
|
|
1269
|
-
* ```
|
|
1221
|
+
* Derive Three's shader node type from an existing node or a supported raw input.
|
|
1222
|
+
* Existing InputNode generics take precedence over structural value normalization.
|
|
1223
|
+
* Both generics must be inferred because Three's UniformNode intersects an unknown-typed
|
|
1224
|
+
* InputNode base with its concrete InputNode specialization.
|
|
1270
1225
|
*/
|
|
1271
|
-
type
|
|
1226
|
+
type UniformNodeType<T> = T extends three_webgpu.UniformNode<infer TNodeType, infer _TValue>
|
|
1227
|
+
? TNodeType
|
|
1228
|
+
: T extends three_webgpu.InputNode<infer TNodeType, infer _TValue>
|
|
1229
|
+
? TNodeType
|
|
1230
|
+
: T extends number
|
|
1231
|
+
? 'float'
|
|
1232
|
+
: T extends boolean
|
|
1233
|
+
? 'bool'
|
|
1234
|
+
: T extends string | three_webgpu.Color | { r: number; g: number; b: number }
|
|
1235
|
+
? 'color'
|
|
1236
|
+
: T extends three_webgpu.Vector4 | { x: number; y: number; z: number; w: number }
|
|
1237
|
+
? 'vec4'
|
|
1238
|
+
: T extends three_webgpu.Vector3 | { x: number; y: number; z: number }
|
|
1239
|
+
? 'vec3'
|
|
1240
|
+
: T extends three_webgpu.Vector2 | { x: number; y: number }
|
|
1241
|
+
? 'vec2'
|
|
1242
|
+
: T extends three_webgpu.Matrix4
|
|
1243
|
+
? 'mat4'
|
|
1244
|
+
: T extends three_webgpu.Matrix3
|
|
1245
|
+
? 'mat3'
|
|
1246
|
+
: T extends three_webgpu.Matrix2
|
|
1247
|
+
? 'mat2'
|
|
1248
|
+
: unknown
|
|
1249
|
+
|
|
1250
|
+
/** Derive the normalized JavaScript value stored by a uniform node. */
|
|
1251
|
+
type UniformNodeValue<T> = T extends three_webgpu.UniformNode<infer _TNodeType, infer TValue>
|
|
1252
|
+
? TValue
|
|
1253
|
+
: T extends three_webgpu.InputNode<infer _TNodeType, infer TValue>
|
|
1254
|
+
? TValue
|
|
1255
|
+
: T extends string | { r: number; g: number; b: number }
|
|
1256
|
+
? three_webgpu.Color
|
|
1257
|
+
: T extends { x: number; y: number; z: number; w: number }
|
|
1258
|
+
? three_webgpu.Vector4
|
|
1259
|
+
: T extends { x: number; y: number; z: number }
|
|
1260
|
+
? three_webgpu.Vector3
|
|
1261
|
+
: T extends { x: number; y: number }
|
|
1262
|
+
? three_webgpu.Vector2
|
|
1263
|
+
: T extends number
|
|
1264
|
+
? number
|
|
1265
|
+
: T extends boolean
|
|
1266
|
+
? boolean
|
|
1267
|
+
: T
|
|
1268
|
+
|
|
1269
|
+
/** Three's exact UniformNode with shader and value generics derived from an input. */
|
|
1270
|
+
type UniformNodeFor<T> = three_webgpu.UniformNode<UniformNodeType<T>, UniformNodeValue<T>>
|
|
1271
|
+
|
|
1272
|
+
/** Preserve every input key while mapping values to exact Three uniform nodes. */
|
|
1273
|
+
type UniformNodesFor<T extends UniformInputRecord> = {
|
|
1274
|
+
[K in keyof T]: UniformNodeFor<T[K]>
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/** Backward-compatible single-parameter uniform alias. */
|
|
1278
|
+
type UniformNode<T = unknown> = UniformNodeFor<T>
|
|
1272
1279
|
|
|
1273
1280
|
/** Flat record of uniform nodes (no nested scopes) */
|
|
1274
1281
|
type UniformRecord<T extends UniformNode = UniformNode> = Record<string, T>
|
|
@@ -1293,7 +1300,7 @@ declare global {
|
|
|
1293
1300
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
1294
1301
|
* Supports:
|
|
1295
1302
|
* - Primitives: number, string (color), boolean
|
|
1296
|
-
* - Three.js types: Color, Vector2/3/4,
|
|
1303
|
+
* - Three.js types: Color, Vector2/3/4, Matrix2/3/4
|
|
1297
1304
|
* - Plain objects: { x, y, z, w } converted to vectors
|
|
1298
1305
|
* - TSL nodes: color(), vec3(), float() for type casting
|
|
1299
1306
|
* - UniformNode: existing uniforms (reused as-is)
|
|
@@ -1306,226 +1313,124 @@ declare global {
|
|
|
1306
1313
|
| three_webgpu.Vector2
|
|
1307
1314
|
| three_webgpu.Vector3
|
|
1308
1315
|
| three_webgpu.Vector4
|
|
1316
|
+
| three_webgpu.Matrix2
|
|
1309
1317
|
| three_webgpu.Matrix3
|
|
1310
1318
|
| three_webgpu.Matrix4
|
|
1311
|
-
|
|
|
1312
|
-
|
|
|
1313
|
-
| { x: number; y
|
|
1314
|
-
|
|
|
1319
|
+
| { x: number; y: number }
|
|
1320
|
+
| { x: number; y: number; z: number }
|
|
1321
|
+
| { x: number; y: number; z: number; w: number }
|
|
1322
|
+
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1323
|
+
| three_webgpu.Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1315
1324
|
| UniformNode
|
|
1316
1325
|
|
|
1317
1326
|
/** Input record for useUniforms - accepts raw values or UniformNodes */
|
|
1318
1327
|
type UniformInputRecord = Record<string, UniformValue>
|
|
1319
1328
|
}
|
|
1320
1329
|
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
declare module 'three/tsl' {
|
|
1330
|
+
declare global {
|
|
1324
1331
|
/**
|
|
1325
|
-
*
|
|
1326
|
-
*
|
|
1332
|
+
* three's own render pipeline type. Named here so the rest of R3F refers to three's shape
|
|
1333
|
+
* rather than `any`. three r183 renamed `PostProcessing` to `RenderPipeline`; our peer floor
|
|
1334
|
+
* is r185, so the new name is the only one.
|
|
1327
1335
|
*/
|
|
1328
|
-
|
|
1329
|
-
jsFunc: (inputs: ShaderNodeObject<Node>[]) => ShaderNodeObject<R>,
|
|
1330
|
-
): ShaderCallable<R>
|
|
1336
|
+
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1331
1337
|
|
|
1332
1338
|
/**
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1339
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1340
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1341
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1335
1342
|
*/
|
|
1336
|
-
|
|
1337
|
-
jsFunc: (inputs: T) => ShaderNodeObject<R>,
|
|
1338
|
-
): ShaderCallable<R>
|
|
1343
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1339
1344
|
|
|
1340
1345
|
/**
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1346
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1347
|
+
*
|
|
1348
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1349
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1350
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1351
|
+
* {@link RenderPipelineCallbackState}.
|
|
1352
|
+
*
|
|
1353
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1354
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1355
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1356
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1357
|
+
*
|
|
1358
|
+
* The index signature admits `undefined` because a key may simply not be registered, and
|
|
1359
|
+
* because the optional `scenePass` must be assignable to it: under `skipLibCheck: false` an
|
|
1360
|
+
* optional property whose type excludes `undefined` from the index signature is an error
|
|
1361
|
+
* (TS2411) for every consumer compiling these declarations.
|
|
1343
1362
|
*/
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1363
|
+
interface PassRecord {
|
|
1364
|
+
scenePass?: ScenePassNode
|
|
1365
|
+
[key: string]: three_webgpu.Node | undefined
|
|
1366
|
+
}
|
|
1348
1367
|
|
|
1349
1368
|
/**
|
|
1350
|
-
*
|
|
1369
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1370
|
+
*
|
|
1371
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1372
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1373
|
+
*
|
|
1374
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1375
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1351
1376
|
*/
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
/**
|
|
1359
|
-
* PostProcessing Types for usePostProcessing hook (WebGPU only)
|
|
1360
|
-
*/
|
|
1361
|
-
|
|
1362
|
-
|
|
1377
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1378
|
+
renderPipeline: ThreeRenderPipeline
|
|
1379
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1380
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1381
|
+
isLegacy: false
|
|
1382
|
+
}
|
|
1363
1383
|
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1384
|
+
/**
|
|
1385
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1386
|
+
*
|
|
1387
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1388
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1389
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1390
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1391
|
+
*/
|
|
1392
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1367
1393
|
|
|
1368
1394
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1369
|
-
type
|
|
1395
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1370
1396
|
|
|
1371
1397
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1372
|
-
type
|
|
1398
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1373
1399
|
|
|
1374
|
-
/**
|
|
1375
|
-
interface
|
|
1400
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1401
|
+
interface UseRenderPipelineActions {
|
|
1376
1402
|
/** Current passes from state */
|
|
1377
1403
|
passes: PassRecord
|
|
1378
|
-
/** PostProcessing instance (null if not initialized) */
|
|
1379
|
-
postProcessing: any | null // THREE.PostProcessing
|
|
1380
1404
|
/** Clear all passes from state */
|
|
1381
1405
|
clearPasses: () => void
|
|
1382
|
-
/** Reset
|
|
1406
|
+
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1383
1407
|
reset: () => void
|
|
1384
1408
|
/** Re-run setup/main callbacks with current closure values */
|
|
1385
1409
|
rebuild: () => void
|
|
1386
|
-
/** True when PostProcessing is configured and ready */
|
|
1387
|
-
isReady: boolean
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
//* useFrameNext Types ==============================
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
//* Global Type Declarations ==============================
|
|
1396
|
-
|
|
1397
|
-
declare global {
|
|
1398
|
-
// Job --------------------------------
|
|
1399
|
-
|
|
1400
|
-
/**
|
|
1401
|
-
* Internal job representation in the scheduler
|
|
1402
|
-
*/
|
|
1403
|
-
interface Job {
|
|
1404
|
-
/** Unique identifier */
|
|
1405
|
-
id: string
|
|
1406
|
-
/** The callback to execute */
|
|
1407
|
-
callback: FrameNextCallback
|
|
1408
|
-
/** Phase this job belongs to */
|
|
1409
|
-
phase: string
|
|
1410
|
-
/** Run before these phases/job ids */
|
|
1411
|
-
before: Set<string>
|
|
1412
|
-
/** Run after these phases/job ids */
|
|
1413
|
-
after: Set<string>
|
|
1414
|
-
/** Priority within phase (higher first) */
|
|
1415
|
-
priority: number
|
|
1416
|
-
/** Insertion order for deterministic tie-breaking */
|
|
1417
|
-
index: number
|
|
1418
|
-
/** Max FPS for this job (undefined = no limit) */
|
|
1419
|
-
fps?: number
|
|
1420
|
-
/** Drop frames when behind (true) or catch up (false) */
|
|
1421
|
-
drop: boolean
|
|
1422
|
-
/** Last run timestamp (ms) */
|
|
1423
|
-
lastRun?: number
|
|
1424
|
-
/** Whether job is enabled */
|
|
1425
|
-
enabled: boolean
|
|
1426
|
-
/** Internal flag: system jobs (like default render) don't block user render takeover */
|
|
1427
|
-
system?: boolean
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
// Phase Graph --------------------------------
|
|
1431
|
-
|
|
1432
|
-
/**
|
|
1433
|
-
* A node in the phase graph
|
|
1434
|
-
*/
|
|
1435
|
-
interface PhaseNode {
|
|
1436
|
-
/** Phase name */
|
|
1437
|
-
name: string
|
|
1438
|
-
/** Whether this was auto-generated from a before/after constraint */
|
|
1439
|
-
isAutoGenerated: boolean
|
|
1440
|
-
}
|
|
1441
|
-
|
|
1442
|
-
/**
|
|
1443
|
-
* Options for creating a job from hook options
|
|
1444
|
-
*/
|
|
1445
|
-
interface JobOptions {
|
|
1446
|
-
id?: string
|
|
1447
|
-
phase?: string
|
|
1448
|
-
before?: string | string[]
|
|
1449
|
-
after?: string | string[]
|
|
1450
|
-
priority?: number
|
|
1451
|
-
fps?: number
|
|
1452
|
-
drop?: boolean
|
|
1453
|
-
enabled?: boolean
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
// Frame Loop State --------------------------------
|
|
1457
|
-
|
|
1458
|
-
/**
|
|
1459
|
-
* Internal frame loop state
|
|
1460
|
-
*/
|
|
1461
|
-
interface FrameLoopState {
|
|
1462
|
-
/** Whether the loop is running */
|
|
1463
|
-
running: boolean
|
|
1464
|
-
/** Current RAF handle */
|
|
1465
|
-
rafHandle: number | null
|
|
1466
|
-
/** Last frame timestamp in ms (null = uninitialized) */
|
|
1467
|
-
lastTime: number | null
|
|
1468
|
-
/** Frame counter */
|
|
1469
|
-
frameCount: number
|
|
1470
|
-
/** Elapsed time since first frame in ms */
|
|
1471
|
-
elapsedTime: number
|
|
1472
|
-
/** createdAt timestamp in ms */
|
|
1473
|
-
createdAt: number
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
// Root Entry --------------------------------
|
|
1477
|
-
|
|
1478
|
-
/**
|
|
1479
|
-
* Internal representation of a registered root (Canvas).
|
|
1480
|
-
* Tracks jobs and manages rebuild state for this root.
|
|
1481
|
-
* @internal
|
|
1482
|
-
*/
|
|
1483
|
-
interface RootEntry {
|
|
1484
|
-
/** Unique identifier for this root */
|
|
1485
|
-
id: string
|
|
1486
|
-
/** Function to get the root's current state. Returns any to support independent mode. */
|
|
1487
|
-
getState: () => any
|
|
1488
|
-
/** Map of job IDs to Job objects */
|
|
1489
|
-
jobs: Map<string, Job>
|
|
1490
|
-
/** Cached sorted job list for execution order */
|
|
1491
|
-
sortedJobs: Job[]
|
|
1492
|
-
/** Whether sortedJobs needs rebuilding */
|
|
1493
|
-
needsRebuild: boolean
|
|
1494
1410
|
}
|
|
1495
1411
|
|
|
1496
1412
|
/**
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1500
|
-
*
|
|
1501
|
-
*
|
|
1502
|
-
*/
|
|
1503
|
-
interface GlobalJob {
|
|
1504
|
-
/** Unique identifier for this global job */
|
|
1505
|
-
id: string
|
|
1506
|
-
/** Callback invoked with RAF timestamp in ms */
|
|
1507
|
-
callback: (timestamp: number) => void
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
// HMR Support --------------------------------
|
|
1511
|
-
|
|
1512
|
-
/**
|
|
1513
|
-
* Hot Module Replacement data structure for preserving scheduler state
|
|
1514
|
-
* @internal
|
|
1515
|
-
*/
|
|
1516
|
-
interface HMRData {
|
|
1517
|
-
/** Shared data object for storing values across reloads */
|
|
1518
|
-
data: Record<string, any>
|
|
1519
|
-
/** Optional function to accept HMR updates */
|
|
1520
|
-
accept?: () => void
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
// Default Phases --------------------------------
|
|
1524
|
-
|
|
1525
|
-
/**
|
|
1526
|
-
* Default phase names for the scheduler
|
|
1413
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1414
|
+
*
|
|
1415
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1416
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1417
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1527
1418
|
*/
|
|
1528
|
-
type
|
|
1419
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1420
|
+
(
|
|
1421
|
+
| {
|
|
1422
|
+
/** True when RenderPipeline is configured and ready */
|
|
1423
|
+
isReady: true
|
|
1424
|
+
/** RenderPipeline instance */
|
|
1425
|
+
renderPipeline: ThreeRenderPipeline
|
|
1426
|
+
}
|
|
1427
|
+
| {
|
|
1428
|
+
/** False until the pipeline has been created */
|
|
1429
|
+
isReady: false
|
|
1430
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1431
|
+
renderPipeline: null
|
|
1432
|
+
}
|
|
1433
|
+
)
|
|
1529
1434
|
}
|
|
1530
1435
|
|
|
1531
1436
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1604,10 +1509,11 @@ type TSLNodeInput = { nodeType?: string | null; uuid?: string } | null
|
|
|
1604
1509
|
|
|
1605
1510
|
/**
|
|
1606
1511
|
* For node material properties (colorNode, positionNode, etc.), accept broader types
|
|
1607
|
-
* since @types/three has broken inheritance for TSL node subclasses.
|
|
1512
|
+
* since @types/three has broken inheritance for TSL node subclasses. NodeClass requires
|
|
1513
|
+
* `nodeType`, so this structural key test remains neutral to the selected Three entry.
|
|
1608
1514
|
*/
|
|
1609
1515
|
type NodeProps<P> = {
|
|
1610
|
-
[K in keyof P as P[K] extends
|
|
1516
|
+
[K in keyof P as NonNullable<P[K]> extends { nodeType: string | null } ? K : never]?: TSLNodeInput
|
|
1611
1517
|
}
|
|
1612
1518
|
|
|
1613
1519
|
interface ReactProps<P> {
|
|
@@ -1628,11 +1534,29 @@ type ThreeToJSXElements<T extends Record<string, any>> = {
|
|
|
1628
1534
|
[K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never
|
|
1629
1535
|
}
|
|
1630
1536
|
|
|
1537
|
+
/** Method names of Object3D, excluded from the `primitive` element's typed props. */
|
|
1538
|
+
type Object3DMethod = NonNullable<
|
|
1539
|
+
{
|
|
1540
|
+
[K in keyof Object3D]-?: Object3D[K] extends (...args: any[]) => any ? K : never
|
|
1541
|
+
}[keyof Object3D]
|
|
1542
|
+
>
|
|
1543
|
+
|
|
1631
1544
|
type ThreeExports = typeof THREE
|
|
1632
1545
|
type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>
|
|
1633
1546
|
|
|
1634
1547
|
interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
|
|
1635
|
-
|
|
1548
|
+
/**
|
|
1549
|
+
* `primitive` wraps a pre-existing object, so its props cannot be derived from one class.
|
|
1550
|
+
* Events are typed from `EventHandlers` (`onClick={(e) => ...}` infers `e`), the ref is
|
|
1551
|
+
* untyped, and any other prop is accepted and applied to the object by name. Object3D's own
|
|
1552
|
+
* methods are left out of the typed surface: they return `this`, so a subclass element's
|
|
1553
|
+
* props (`ThreeElements['group']`) could not be spread onto a primitive otherwise.
|
|
1554
|
+
*/
|
|
1555
|
+
primitive: Omit<ThreeElement<typeof Object3D>, 'args' | 'object' | 'ref' | Object3DMethod> & {
|
|
1556
|
+
object: object
|
|
1557
|
+
ref?: React.Ref<any>
|
|
1558
|
+
[prop: string]: unknown
|
|
1559
|
+
}
|
|
1636
1560
|
// Conflicts with DOM types can be accessed through a three* prefix
|
|
1637
1561
|
threeAudio: ThreeElementsImpl['audio']
|
|
1638
1562
|
threeSource: ThreeElementsImpl['source']
|
|
@@ -1673,6 +1597,7 @@ type three_d_Matrix3 = Matrix3;
|
|
|
1673
1597
|
type three_d_Matrix4 = Matrix4;
|
|
1674
1598
|
type three_d_MutableOrReadonlyParameters<T extends (...args: any) => any> = MutableOrReadonlyParameters<T>;
|
|
1675
1599
|
type three_d_NodeProps<P> = NodeProps<P>;
|
|
1600
|
+
type three_d_Object3DMethod = Object3DMethod;
|
|
1676
1601
|
type three_d_Quaternion = Quaternion;
|
|
1677
1602
|
type three_d_RaycastableRepresentation = RaycastableRepresentation;
|
|
1678
1603
|
type three_d_ReactProps<P> = ReactProps<P>;
|
|
@@ -1687,7 +1612,7 @@ type three_d_Vector3 = Vector3;
|
|
|
1687
1612
|
type three_d_Vector4 = Vector4;
|
|
1688
1613
|
type three_d_VectorRepresentation = VectorRepresentation;
|
|
1689
1614
|
declare namespace three_d {
|
|
1690
|
-
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1615
|
+
export type { three_d_Color as Color, three_d_ElementProps as ElementProps, three_d_Euler as Euler, three_d_EventProps as EventProps, three_d_GeometryProps as GeometryProps, three_d_GeometryTransformProps as GeometryTransformProps, three_d_Layers as Layers, three_d_MathProps as MathProps, three_d_MathRepresentation as MathRepresentation, three_d_MathType as MathType, three_d_MathTypes as MathTypes, three_d_Matrix3 as Matrix3, three_d_Matrix4 as Matrix4, three_d_MutableOrReadonlyParameters as MutableOrReadonlyParameters, three_d_NodeProps as NodeProps, three_d_Object3DMethod as Object3DMethod, three_d_Quaternion as Quaternion, three_d_RaycastableRepresentation as RaycastableRepresentation, three_d_ReactProps as ReactProps, three_d_TSLNodeInput as TSLNodeInput, three_d_ThreeElement as ThreeElement, three_d_ThreeElements as ThreeElements, three_d_ThreeElementsImpl as ThreeElementsImpl, three_d_ThreeExports as ThreeExports, three_d_ThreeToJSXElements as ThreeToJSXElements, three_d_Vector2 as Vector2, three_d_Vector3 as Vector3, three_d_Vector4 as Vector4, three_d_VectorRepresentation as VectorRepresentation };
|
|
1691
1616
|
}
|
|
1692
1617
|
|
|
1693
1618
|
/**
|
|
@@ -1697,7 +1622,7 @@ declare namespace three_d {
|
|
|
1697
1622
|
* a single WebGPURenderer using Three.js CanvasTarget API.
|
|
1698
1623
|
*
|
|
1699
1624
|
* Primary canvas: Has `id` prop, creates its own renderer, registers here
|
|
1700
|
-
* Secondary canvas: Has `
|
|
1625
|
+
* Secondary canvas: Has `renderer={{ primaryCanvas: 'id' }}`, shares primary's renderer via CanvasTarget
|
|
1701
1626
|
*/
|
|
1702
1627
|
|
|
1703
1628
|
interface PrimaryCanvasEntry {
|
|
@@ -1765,12 +1690,23 @@ type EnvironmentLoaderProps = {
|
|
|
1765
1690
|
* const texture = useEnvironment({ preset: 'sunset' })
|
|
1766
1691
|
* ```
|
|
1767
1692
|
*/
|
|
1768
|
-
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown> | CubeTexture
|
|
1693
|
+
declare function useEnvironment({ files, path, preset, colorSpace, extensions, }?: Partial<EnvironmentLoaderProps>): Texture$1<unknown, THREE$1.TextureEventMap> | CubeTexture<unknown>;
|
|
1769
1694
|
declare namespace useEnvironment {
|
|
1770
1695
|
var preload: (preloadOptions?: EnvironmentLoaderPreloadOptions) => void;
|
|
1771
1696
|
var clear: (clearOptions?: EnvironmentLoaderClearOptions) => void;
|
|
1772
1697
|
}
|
|
1773
|
-
|
|
1698
|
+
/**
|
|
1699
|
+
* Options accepted by `useEnvironment.preload`.
|
|
1700
|
+
*
|
|
1701
|
+
* `colorSpace` is deliberately omitted: preload only warms the loader cache, and colorSpace is
|
|
1702
|
+
* applied to the texture by `useEnvironment()` at use time, per consumer. Accepting it here would
|
|
1703
|
+
* advertise an option this function silently ignores.
|
|
1704
|
+
*
|
|
1705
|
+
* This previously read `Omit<…, 'encoding'>` — omitting a key that does not exist on
|
|
1706
|
+
* `EnvironmentLoaderProps`, a leftover from three's pre-`colorSpace` `encoding` API. That made the
|
|
1707
|
+
* type equivalent to the full props, so `colorSpace` was accepted and then dropped on the floor.
|
|
1708
|
+
*/
|
|
1709
|
+
type EnvironmentLoaderPreloadOptions = Omit<EnvironmentLoaderProps, 'colorSpace'>;
|
|
1774
1710
|
type EnvironmentLoaderClearOptions = Pick<EnvironmentLoaderProps, 'files' | 'preset'>;
|
|
1775
1711
|
|
|
1776
1712
|
/**
|
|
@@ -1814,9 +1750,9 @@ type EnvironmentProps = {
|
|
|
1814
1750
|
blur?: number;
|
|
1815
1751
|
backgroundBlurriness?: number;
|
|
1816
1752
|
backgroundIntensity?: number;
|
|
1817
|
-
backgroundRotation?: Euler
|
|
1753
|
+
backgroundRotation?: Euler;
|
|
1818
1754
|
environmentIntensity?: number;
|
|
1819
|
-
environmentRotation?: Euler
|
|
1755
|
+
environmentRotation?: Euler;
|
|
1820
1756
|
map?: Texture$1;
|
|
1821
1757
|
preset?: PresetsType;
|
|
1822
1758
|
scene?: Scene | React$1.RefObject<Scene>;
|
|
@@ -1900,7 +1836,7 @@ declare function EnvironmentCube({ background, scene, blur, backgroundBlurriness
|
|
|
1900
1836
|
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;
|
|
1901
1837
|
declare module '@react-three/fiber' {
|
|
1902
1838
|
interface ThreeElements {
|
|
1903
|
-
groundProjectedEnvImpl: ThreeElement
|
|
1839
|
+
groundProjectedEnvImpl: ThreeElement<typeof GroundedSkybox>;
|
|
1904
1840
|
}
|
|
1905
1841
|
}
|
|
1906
1842
|
/**
|
|
@@ -2000,12 +1936,68 @@ declare module '@react-three/fiber' {
|
|
|
2000
1936
|
*/
|
|
2001
1937
|
declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Element;
|
|
2002
1938
|
|
|
1939
|
+
/**
|
|
1940
|
+
* Moves every trace of interactivity from one object to its replacement, for reconstruction.
|
|
1941
|
+
*
|
|
1942
|
+
* When `args` or a `primitive`'s `object` changes, R3F builds a new three object and keeps the same
|
|
1943
|
+
* instance. Removing the old object from the interaction state and registering the new one from
|
|
1944
|
+
* scratch makes events *work* again (#3778), but it forgets what was in flight: a pointer resting on
|
|
1945
|
+
* the object fires a second `onPointerEnter` without ever having left, and an active pointer capture
|
|
1946
|
+
* is dropped mid-drag. Rewriting the references instead keeps the interaction continuous across a
|
|
1947
|
+
* swap the user never asked to see (#3744).
|
|
1948
|
+
*
|
|
1949
|
+
* Captures are re-keyed rather than released, so the DOM-level capture on `captureData.target` is
|
|
1950
|
+
* left alone — releasing and re-acquiring it is precisely the glitch being avoided.
|
|
1951
|
+
*
|
|
1952
|
+
* Visibility handlers are deliberately not transferred: that registry is keyed by `object.uuid`, so
|
|
1953
|
+
* the replacement re-registers itself through `applyProps`. The old entry is dropped here so it
|
|
1954
|
+
* cannot outlive the object it described.
|
|
1955
|
+
*/
|
|
1956
|
+
declare function swapInteractivity(store: RootStore, object: Object3D, newObject: Object3D): void;
|
|
2003
1957
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
2004
1958
|
declare function createEvents(store: RootStore): {
|
|
2005
1959
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
1960
|
+
flushDeferredPointers: () => void;
|
|
1961
|
+
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
2006
1962
|
};
|
|
2007
1963
|
/** Default R3F event manager for web */
|
|
2008
|
-
declare function createPointerEvents(store: RootStore): EventManager<
|
|
1964
|
+
declare function createPointerEvents(store: RootStore): EventManager<Element>;
|
|
1965
|
+
|
|
1966
|
+
interface RootExtension {
|
|
1967
|
+
/** Unique name. Registering the same name again replaces the entry (HMR-safe); roots it already
|
|
1968
|
+
* set up are not set up a second time, but get the new entry's dispose and hmr. */
|
|
1969
|
+
name: string;
|
|
1970
|
+
/**
|
|
1971
|
+
* Called once per root, after its renderer exists and before `onCreated` and the first frame.
|
|
1972
|
+
* `isLegacy` and `primaryStore` are known by then, so an extension can skip WebGL roots or defer
|
|
1973
|
+
* to the primary canvas. Return fields to merge into the root's state, or nothing.
|
|
1974
|
+
*/
|
|
1975
|
+
setup?(store: RootStore): Partial<RootState> | void;
|
|
1976
|
+
/** Called when a root this extension set up unmounts. */
|
|
1977
|
+
dispose?(store: RootStore): void;
|
|
1978
|
+
/** Called when `<Canvas>` detects hot module replacement (skipped with `hmr={false}`). */
|
|
1979
|
+
hmr?(store: RootStore): void;
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Register an extension. It is set up on every live root immediately, and on every root created
|
|
1983
|
+
* afterwards. Returns a function that unregisters it: new roots are no longer set up, while roots
|
|
1984
|
+
* it already set up keep its state and still get its dispose when they unmount.
|
|
1985
|
+
*/
|
|
1986
|
+
declare function registerRootExtension(extension: RootExtension): () => void;
|
|
1987
|
+
/**
|
|
1988
|
+
* Point a root's default render job at a different render function, or back at
|
|
1989
|
+
* `renderer.render(scene, camera)` with `null`.
|
|
1990
|
+
*
|
|
1991
|
+
* The default job keeps everything else: the Canvas `fps` throttle, error propagation to the error
|
|
1992
|
+
* boundary, and backing off when a user `useFrame(..., { phase: 'render' })` job takes over.
|
|
1993
|
+
*/
|
|
1994
|
+
declare function setRenderOverride(store: RootStore, render: (() => void) | null): void;
|
|
1995
|
+
|
|
1996
|
+
/**
|
|
1997
|
+
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
1998
|
+
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
1999
|
+
*/
|
|
2000
|
+
declare function useStore(): RootStore;
|
|
2009
2001
|
|
|
2010
2002
|
/**
|
|
2011
2003
|
* Gets or creates a memoized loader instance from a loader constructor or returns the loader if it's already an instance.
|
|
@@ -2018,419 +2010,13 @@ declare function getLoader<L extends LoaderLike | ConstructorRepresentation<Load
|
|
|
2018
2010
|
* Note: this hook's caller must be wrapped with `React.Suspense`
|
|
2019
2011
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
|
|
2020
2012
|
*/
|
|
2021
|
-
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>;
|
|
2013
|
+
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>;
|
|
2022
2014
|
declare namespace useLoader {
|
|
2023
|
-
var preload: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void) => void;
|
|
2024
|
-
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I) => void;
|
|
2015
|
+
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;
|
|
2016
|
+
var clear: <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(loader: L, input: I, cacheKey?: InputLike) => void;
|
|
2025
2017
|
var loader: typeof getLoader;
|
|
2026
2018
|
}
|
|
2027
2019
|
|
|
2028
|
-
/**
|
|
2029
|
-
* Global Singleton Scheduler - manages the frame loop and job execution for ALL R3F roots.
|
|
2030
|
-
*
|
|
2031
|
-
* Features:
|
|
2032
|
-
* - Single RAF loop for entire application
|
|
2033
|
-
* - Root registration (multiple Canvas support)
|
|
2034
|
-
* - Global phases for addEffect/addAfterEffect (deprecated)
|
|
2035
|
-
* - Per-root job management with phases, priorities, FPS throttling
|
|
2036
|
-
* - onIdle callbacks for addTail (deprecated)
|
|
2037
|
-
* - Demand mode support via invalidate()
|
|
2038
|
-
*/
|
|
2039
|
-
declare class Scheduler {
|
|
2040
|
-
private static readonly INSTANCE_KEY;
|
|
2041
|
-
private static get instance();
|
|
2042
|
-
private static set instance(value);
|
|
2043
|
-
/**
|
|
2044
|
-
* Get the global scheduler instance (creates if doesn't exist).
|
|
2045
|
-
* Uses HMR data to preserve instance across hot reloads.
|
|
2046
|
-
* @returns {Scheduler} The singleton scheduler instance
|
|
2047
|
-
*/
|
|
2048
|
-
static get(): Scheduler;
|
|
2049
|
-
/**
|
|
2050
|
-
* Reset the singleton instance. Stops the loop and clears all state.
|
|
2051
|
-
* Primarily used for testing to ensure clean state between tests.
|
|
2052
|
-
* @returns {void}
|
|
2053
|
-
*/
|
|
2054
|
-
static reset(): void;
|
|
2055
|
-
private roots;
|
|
2056
|
-
private phaseGraph;
|
|
2057
|
-
private loopState;
|
|
2058
|
-
private stoppedTime;
|
|
2059
|
-
private nextRootIndex;
|
|
2060
|
-
private globalBeforeJobs;
|
|
2061
|
-
private globalAfterJobs;
|
|
2062
|
-
private nextGlobalIndex;
|
|
2063
|
-
private idleCallbacks;
|
|
2064
|
-
private nextJobIndex;
|
|
2065
|
-
private jobStateListeners;
|
|
2066
|
-
private pendingFrames;
|
|
2067
|
-
private _frameloop;
|
|
2068
|
-
private _independent;
|
|
2069
|
-
private errorHandler;
|
|
2070
|
-
private rootReadyCallbacks;
|
|
2071
|
-
get phases(): string[];
|
|
2072
|
-
get frameloop(): Frameloop;
|
|
2073
|
-
set frameloop(mode: Frameloop);
|
|
2074
|
-
get isRunning(): boolean;
|
|
2075
|
-
get isReady(): boolean;
|
|
2076
|
-
get independent(): boolean;
|
|
2077
|
-
set independent(value: boolean);
|
|
2078
|
-
constructor();
|
|
2079
|
-
/**
|
|
2080
|
-
* Register a root (Canvas) with the scheduler.
|
|
2081
|
-
* The first root to register starts the RAF loop (if frameloop='always').
|
|
2082
|
-
* @param {string} id - Unique identifier for this root
|
|
2083
|
-
* @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
|
|
2084
|
-
* @returns {() => void} Unsubscribe function to remove this root
|
|
2085
|
-
*/
|
|
2086
|
-
registerRoot(id: string, options?: RootOptions): () => void;
|
|
2087
|
-
/**
|
|
2088
|
-
* Unregister a root from the scheduler.
|
|
2089
|
-
* Cleans up all job state listeners for this root's jobs.
|
|
2090
|
-
* The last root to unregister stops the RAF loop.
|
|
2091
|
-
* @param {string} id - The root ID to unregister
|
|
2092
|
-
* @returns {void}
|
|
2093
|
-
*/
|
|
2094
|
-
unregisterRoot(id: string): void;
|
|
2095
|
-
/**
|
|
2096
|
-
* Subscribe to be notified when a root becomes available.
|
|
2097
|
-
* Fires immediately if a root already exists.
|
|
2098
|
-
* @param {() => void} callback - Function called when first root registers
|
|
2099
|
-
* @returns {() => void} Unsubscribe function
|
|
2100
|
-
*/
|
|
2101
|
-
onRootReady(callback: () => void): () => void;
|
|
2102
|
-
/**
|
|
2103
|
-
* Notify all registered root-ready callbacks.
|
|
2104
|
-
* Called when the first root registers.
|
|
2105
|
-
* @returns {void}
|
|
2106
|
-
* @private
|
|
2107
|
-
*/
|
|
2108
|
-
private notifyRootReady;
|
|
2109
|
-
/**
|
|
2110
|
-
* Ensure a default root exists for independent mode.
|
|
2111
|
-
* Creates a minimal root with no state provider.
|
|
2112
|
-
* @returns {void}
|
|
2113
|
-
* @private
|
|
2114
|
-
*/
|
|
2115
|
-
private ensureDefaultRoot;
|
|
2116
|
-
/**
|
|
2117
|
-
* Trigger error handling for job errors.
|
|
2118
|
-
* Uses the bound error handler if available, otherwise logs to console.
|
|
2119
|
-
* @param {Error} error - The error to handle
|
|
2120
|
-
* @returns {void}
|
|
2121
|
-
*/
|
|
2122
|
-
triggerError(error: Error): void;
|
|
2123
|
-
/**
|
|
2124
|
-
* Add a named phase to the scheduler's execution order.
|
|
2125
|
-
* Marks all roots for rebuild to incorporate the new phase.
|
|
2126
|
-
* @param {string} name - The phase name (e.g., 'physics', 'postprocess')
|
|
2127
|
-
* @param {AddPhaseOptions} [options] - Positioning options (before/after other phases)
|
|
2128
|
-
* @returns {void}
|
|
2129
|
-
* @example
|
|
2130
|
-
* scheduler.addPhase('physics', { before: 'update' });
|
|
2131
|
-
* scheduler.addPhase('postprocess', { after: 'render' });
|
|
2132
|
-
*/
|
|
2133
|
-
addPhase(name: string, options?: AddPhaseOptions): void;
|
|
2134
|
-
/**
|
|
2135
|
-
* Check if a phase exists in the scheduler.
|
|
2136
|
-
* @param {string} name - The phase name to check
|
|
2137
|
-
* @returns {boolean} True if the phase exists
|
|
2138
|
-
*/
|
|
2139
|
-
hasPhase(name: string): boolean;
|
|
2140
|
-
/**
|
|
2141
|
-
* Register a global job that runs once per frame (not per-root).
|
|
2142
|
-
* Used internally by deprecated addEffect/addAfterEffect APIs.
|
|
2143
|
-
* @param {'before' | 'after'} phase - When to run: 'before' all roots or 'after' all roots
|
|
2144
|
-
* @param {string} id - Unique identifier for this global job
|
|
2145
|
-
* @param {(timestamp: number) => void} callback - Function called each frame with RAF timestamp
|
|
2146
|
-
* @returns {() => void} Unsubscribe function to remove this global job
|
|
2147
|
-
* @deprecated Use useFrame with phases instead
|
|
2148
|
-
*/
|
|
2149
|
-
registerGlobal(phase: 'before' | 'after', id: string, callback: (timestamp: number) => void): () => void;
|
|
2150
|
-
/**
|
|
2151
|
-
* Register an idle callback that fires when the loop stops.
|
|
2152
|
-
* Used internally by deprecated addTail API.
|
|
2153
|
-
* @param {(timestamp: number) => void} callback - Function called when loop becomes idle
|
|
2154
|
-
* @returns {() => void} Unsubscribe function to remove this idle callback
|
|
2155
|
-
* @deprecated Use demand mode with invalidate() instead
|
|
2156
|
-
*/
|
|
2157
|
-
onIdle(callback: (timestamp: number) => void): () => void;
|
|
2158
|
-
/**
|
|
2159
|
-
* Notify all registered idle callbacks.
|
|
2160
|
-
* Called when the loop stops in demand mode.
|
|
2161
|
-
* @param {number} timestamp - The RAF timestamp when idle occurred
|
|
2162
|
-
* @returns {void}
|
|
2163
|
-
* @private
|
|
2164
|
-
*/
|
|
2165
|
-
private notifyIdle;
|
|
2166
|
-
/**
|
|
2167
|
-
* Register a job (frame callback) with a specific root.
|
|
2168
|
-
* This is the core registration method used by useFrame internally.
|
|
2169
|
-
* @param {FrameNextCallback} callback - The function to call each frame
|
|
2170
|
-
* @param {JobOptions & { rootId?: string; system?: boolean }} [options] - Job configuration
|
|
2171
|
-
* @param {string} [options.rootId] - Target root ID (defaults to first registered root)
|
|
2172
|
-
* @param {string} [options.id] - Unique job ID (auto-generated if not provided)
|
|
2173
|
-
* @param {string} [options.phase] - Execution phase (defaults to 'update')
|
|
2174
|
-
* @param {number} [options.priority] - Priority within phase (higher = earlier, default 0)
|
|
2175
|
-
* @param {number} [options.fps] - FPS throttle limit
|
|
2176
|
-
* @param {boolean} [options.drop] - Drop frames when behind (default true)
|
|
2177
|
-
* @param {boolean} [options.enabled] - Whether job is active (default true)
|
|
2178
|
-
* @param {boolean} [options.system] - Internal flag for system jobs (not user-facing)
|
|
2179
|
-
* @returns {() => void} Unsubscribe function to remove this job
|
|
2180
|
-
*/
|
|
2181
|
-
register(callback: FrameNextCallback, options?: JobOptions & {
|
|
2182
|
-
rootId?: string;
|
|
2183
|
-
system?: boolean;
|
|
2184
|
-
}): () => void;
|
|
2185
|
-
/**
|
|
2186
|
-
* Unregister a job by its ID.
|
|
2187
|
-
* Searches all roots if rootId is not provided.
|
|
2188
|
-
* @param {string} id - The job ID to unregister
|
|
2189
|
-
* @param {string} [rootId] - Optional root ID to search (searches all if not provided)
|
|
2190
|
-
* @returns {void}
|
|
2191
|
-
*/
|
|
2192
|
-
unregister(id: string, rootId?: string): void;
|
|
2193
|
-
/**
|
|
2194
|
-
* Update a job's options dynamically.
|
|
2195
|
-
* Searches all roots to find the job by ID.
|
|
2196
|
-
* Phase/constraint changes trigger a rebuild of the sorted job list.
|
|
2197
|
-
* @param {string} id - The job ID to update
|
|
2198
|
-
* @param {Partial<JobOptions>} options - The options to update
|
|
2199
|
-
* @returns {void}
|
|
2200
|
-
*/
|
|
2201
|
-
updateJob(id: string, options: Partial<JobOptions>): void;
|
|
2202
|
-
/**
|
|
2203
|
-
* Check if a job is currently paused (disabled).
|
|
2204
|
-
* @param {string} id - The job ID to check
|
|
2205
|
-
* @returns {boolean} True if the job exists and is paused
|
|
2206
|
-
*/
|
|
2207
|
-
isJobPaused(id: string): boolean;
|
|
2208
|
-
/**
|
|
2209
|
-
* Subscribe to state changes for a specific job.
|
|
2210
|
-
* Listener is called when job is paused or resumed.
|
|
2211
|
-
* @param {string} id - The job ID to subscribe to
|
|
2212
|
-
* @param {() => void} listener - Callback invoked on state changes
|
|
2213
|
-
* @returns {() => void} Unsubscribe function
|
|
2214
|
-
*/
|
|
2215
|
-
subscribeJobState(id: string, listener: () => void): () => void;
|
|
2216
|
-
/**
|
|
2217
|
-
* Notify all listeners that a job's state has changed.
|
|
2218
|
-
* @param {string} id - The job ID that changed
|
|
2219
|
-
* @returns {void}
|
|
2220
|
-
* @private
|
|
2221
|
-
*/
|
|
2222
|
-
private notifyJobStateChange;
|
|
2223
|
-
/**
|
|
2224
|
-
* Pause a job by ID (sets enabled=false).
|
|
2225
|
-
* Notifies any subscribed state listeners.
|
|
2226
|
-
* @param {string} id - The job ID to pause
|
|
2227
|
-
* @returns {void}
|
|
2228
|
-
*/
|
|
2229
|
-
pauseJob(id: string): void;
|
|
2230
|
-
/**
|
|
2231
|
-
* Resume a paused job by ID (sets enabled=true).
|
|
2232
|
-
* Resets job timing to prevent frame accumulation.
|
|
2233
|
-
* Notifies any subscribed state listeners.
|
|
2234
|
-
* @param {string} id - The job ID to resume
|
|
2235
|
-
* @returns {void}
|
|
2236
|
-
*/
|
|
2237
|
-
resumeJob(id: string): void;
|
|
2238
|
-
/**
|
|
2239
|
-
* Start the requestAnimationFrame loop.
|
|
2240
|
-
* Resets timing state (elapsedTime, frameCount) on start.
|
|
2241
|
-
* No-op if already running.
|
|
2242
|
-
* @returns {void}
|
|
2243
|
-
*/
|
|
2244
|
-
start(): void;
|
|
2245
|
-
/**
|
|
2246
|
-
* Stop the requestAnimationFrame loop.
|
|
2247
|
-
* Cancels any pending RAF callback.
|
|
2248
|
-
* No-op if not running.
|
|
2249
|
-
* @returns {void}
|
|
2250
|
-
*/
|
|
2251
|
-
stop(): void;
|
|
2252
|
-
/**
|
|
2253
|
-
* Request frames to be rendered in demand mode.
|
|
2254
|
-
* Accumulates pending frames (capped at 60) and starts the loop if not running.
|
|
2255
|
-
* No-op if frameloop is not 'demand'.
|
|
2256
|
-
* @param {number} [frames=1] - Number of frames to request
|
|
2257
|
-
* @param {boolean} [stackFrames=false] - Whether to add frames to existing pending count
|
|
2258
|
-
* - `false` (default): Sets pending frames to the specified value (replaces existing count)
|
|
2259
|
-
* - `true`: Adds frames to existing pending count (useful for accumulating invalidations)
|
|
2260
|
-
* @returns {void}
|
|
2261
|
-
* @example
|
|
2262
|
-
* // Request a single frame render
|
|
2263
|
-
* scheduler.invalidate();
|
|
2264
|
-
*
|
|
2265
|
-
* @example
|
|
2266
|
-
* // Request 5 frames (e.g., for animations)
|
|
2267
|
-
* scheduler.invalidate(5);
|
|
2268
|
-
*
|
|
2269
|
-
* @example
|
|
2270
|
-
* // Set pending frames to exactly 3 (don't stack with existing)
|
|
2271
|
-
* scheduler.invalidate(3, false);
|
|
2272
|
-
*
|
|
2273
|
-
* @example
|
|
2274
|
-
* // Add 2 more frames to existing pending count
|
|
2275
|
-
* scheduler.invalidate(2, true);
|
|
2276
|
-
*/
|
|
2277
|
-
invalidate(frames?: number, stackFrames?: boolean): void;
|
|
2278
|
-
/**
|
|
2279
|
-
* Reset timing state for deterministic testing.
|
|
2280
|
-
* Preserves jobs and roots but resets lastTime, frameCount, elapsedTime, etc.
|
|
2281
|
-
* @returns {void}
|
|
2282
|
-
*/
|
|
2283
|
-
resetTiming(): void;
|
|
2284
|
-
/**
|
|
2285
|
-
* Manually execute a single frame for all roots.
|
|
2286
|
-
* Useful for frameloop='never' mode or testing scenarios.
|
|
2287
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2288
|
-
* @returns {void}
|
|
2289
|
-
* @example
|
|
2290
|
-
* // Manual control mode
|
|
2291
|
-
* scheduler.frameloop = 'never';
|
|
2292
|
-
* scheduler.step(); // Execute one frame
|
|
2293
|
-
*/
|
|
2294
|
-
step(timestamp?: number): void;
|
|
2295
|
-
/**
|
|
2296
|
-
* Manually execute a single job by its ID.
|
|
2297
|
-
* Useful for testing individual job callbacks in isolation.
|
|
2298
|
-
* @param {string} id - The job ID to step
|
|
2299
|
-
* @param {number} [timestamp] - Optional timestamp (defaults to performance.now())
|
|
2300
|
-
* @returns {void}
|
|
2301
|
-
*/
|
|
2302
|
-
stepJob(id: string, timestamp?: number): void;
|
|
2303
|
-
/**
|
|
2304
|
-
* Main RAF loop callback.
|
|
2305
|
-
* Executes frame, handles demand mode, and schedules next frame.
|
|
2306
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2307
|
-
* @returns {void}
|
|
2308
|
-
* @private
|
|
2309
|
-
*/
|
|
2310
|
-
private loop;
|
|
2311
|
-
/**
|
|
2312
|
-
* Execute a single frame across all roots.
|
|
2313
|
-
* Order: globalBefore → each root's jobs → globalAfter
|
|
2314
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2315
|
-
* @returns {void}
|
|
2316
|
-
* @private
|
|
2317
|
-
*/
|
|
2318
|
-
private executeFrame;
|
|
2319
|
-
/**
|
|
2320
|
-
* Run all global jobs from a job map.
|
|
2321
|
-
* Catches and logs errors without stopping execution.
|
|
2322
|
-
* @param {Map<string, GlobalJob>} jobs - The global jobs map to execute
|
|
2323
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2324
|
-
* @returns {void}
|
|
2325
|
-
* @private
|
|
2326
|
-
*/
|
|
2327
|
-
private runGlobalJobs;
|
|
2328
|
-
/**
|
|
2329
|
-
* Execute all jobs for a single root in sorted order.
|
|
2330
|
-
* Rebuilds sorted job list if needed, then dispatches each job.
|
|
2331
|
-
* Errors are caught and propagated via triggerError.
|
|
2332
|
-
* @param {RootEntry} root - The root entry to tick
|
|
2333
|
-
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
2334
|
-
* @param {number} delta - Time since last frame in seconds
|
|
2335
|
-
* @returns {void}
|
|
2336
|
-
* @private
|
|
2337
|
-
*/
|
|
2338
|
-
private tickRoot;
|
|
2339
|
-
/**
|
|
2340
|
-
* Get the total number of registered jobs across all roots.
|
|
2341
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2342
|
-
* @returns {number} Total job count
|
|
2343
|
-
*/
|
|
2344
|
-
getJobCount(): number;
|
|
2345
|
-
/**
|
|
2346
|
-
* Get all registered job IDs across all roots.
|
|
2347
|
-
* Includes both per-root jobs and global before/after jobs.
|
|
2348
|
-
* @returns {string[]} Array of all job IDs
|
|
2349
|
-
*/
|
|
2350
|
-
getJobIds(): string[];
|
|
2351
|
-
/**
|
|
2352
|
-
* Get the number of registered roots (Canvas instances).
|
|
2353
|
-
* @returns {number} Number of registered roots
|
|
2354
|
-
*/
|
|
2355
|
-
getRootCount(): number;
|
|
2356
|
-
/**
|
|
2357
|
-
* Check if any user (non-system) jobs are registered in a specific phase.
|
|
2358
|
-
* Used by the default render job to know if a user has taken over rendering.
|
|
2359
|
-
*
|
|
2360
|
-
* @param phase The phase to check
|
|
2361
|
-
* @param rootId Optional root ID to check (checks all roots if not provided)
|
|
2362
|
-
* @returns true if any user jobs exist in the phase
|
|
2363
|
-
*/
|
|
2364
|
-
hasUserJobsInPhase(phase: string, rootId?: string): boolean;
|
|
2365
|
-
/**
|
|
2366
|
-
* Generate a unique root ID for automatic root registration.
|
|
2367
|
-
* @returns {string} A unique root ID in the format 'root_N'
|
|
2368
|
-
*/
|
|
2369
|
-
generateRootId(): string;
|
|
2370
|
-
/**
|
|
2371
|
-
* Generate a unique job ID.
|
|
2372
|
-
* @returns {string} A unique job ID in the format 'job_N'
|
|
2373
|
-
* @private
|
|
2374
|
-
*/
|
|
2375
|
-
private generateJobId;
|
|
2376
|
-
/**
|
|
2377
|
-
* Normalize before/after constraints to a Set.
|
|
2378
|
-
* Handles undefined, single string, or array inputs.
|
|
2379
|
-
* @param {string | string[] | undefined} value - The constraint value(s)
|
|
2380
|
-
* @returns {Set<string>} Normalized Set of constraint strings
|
|
2381
|
-
* @private
|
|
2382
|
-
*/
|
|
2383
|
-
private normalizeConstraints;
|
|
2384
|
-
}
|
|
2385
|
-
/**
|
|
2386
|
-
* Get the global scheduler instance.
|
|
2387
|
-
* Creates one if it doesn't exist.
|
|
2388
|
-
*/
|
|
2389
|
-
declare const getScheduler: () => Scheduler;
|
|
2390
|
-
|
|
2391
|
-
/**
|
|
2392
|
-
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
2393
|
-
*
|
|
2394
|
-
* Works both inside and outside Canvas context:
|
|
2395
|
-
* - Inside Canvas: Full RootState (gl, scene, camera, etc.)
|
|
2396
|
-
* - Outside Canvas (waiting mode): Waits for Canvas to mount, then gets full state
|
|
2397
|
-
* - Outside Canvas (independent mode): Fires immediately with timing-only state
|
|
2398
|
-
*
|
|
2399
|
-
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
2400
|
-
*
|
|
2401
|
-
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
2402
|
-
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
2403
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
2404
|
-
*
|
|
2405
|
-
* @example
|
|
2406
|
-
* // Simple priority (backwards compat)
|
|
2407
|
-
* useFrame((state, delta) => { ... }, 5)
|
|
2408
|
-
*
|
|
2409
|
-
* @example
|
|
2410
|
-
* // With phase-based ordering
|
|
2411
|
-
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
2412
|
-
*
|
|
2413
|
-
* @example
|
|
2414
|
-
* // Outside Canvas - waits for Canvas to mount
|
|
2415
|
-
* function UI() {
|
|
2416
|
-
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
2417
|
-
* return <button>...</button>;
|
|
2418
|
-
* }
|
|
2419
|
-
*
|
|
2420
|
-
* @example
|
|
2421
|
-
* // Independent mode - no Canvas needed
|
|
2422
|
-
* getScheduler().independent = true;
|
|
2423
|
-
* useFrame((state, delta) => { updateGame(delta) });
|
|
2424
|
-
*
|
|
2425
|
-
* @example
|
|
2426
|
-
* // Scheduler-only access (no callback)
|
|
2427
|
-
* const { scheduler } = useFrame()
|
|
2428
|
-
* scheduler.pauseJob('some-job-id')
|
|
2429
|
-
*
|
|
2430
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
|
|
2431
|
-
*/
|
|
2432
|
-
declare function useFrame(callback?: FrameNextCallback, priorityOrOptions?: number | UseFrameNextOptions): FrameNextControls;
|
|
2433
|
-
|
|
2434
2020
|
declare const IsObject: (url: unknown) => url is Record<string, string>;
|
|
2435
2021
|
type TextureArray<T> = T extends string[] ? Texture$1[] : never;
|
|
2436
2022
|
type TextureRecord<T> = T extends Record<string, string> ? {
|
|
@@ -2443,11 +2029,16 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
|
|
|
2443
2029
|
/** Callback when texture(s) finish loading */
|
|
2444
2030
|
onLoad?: (texture: MappedTextureType<Url>) => void;
|
|
2445
2031
|
/**
|
|
2446
|
-
*
|
|
2447
|
-
* When true:
|
|
2032
|
+
* Register the texture(s) in R3F's global texture registry for access via useTextures().
|
|
2033
|
+
* When true (the default):
|
|
2448
2034
|
* - Textures persist until explicitly disposed
|
|
2449
|
-
* -
|
|
2450
|
-
*
|
|
2035
|
+
* - On mount, returns existing registered textures if available (preserving modifications like colorSpace)
|
|
2036
|
+
*
|
|
2037
|
+
* Reads are taken once at mount — a mounted `useTexture` does not re-render when the registry
|
|
2038
|
+
* changes. To react to registry swaps, use `useTextures(s => s.get(key))` instead.
|
|
2039
|
+
*
|
|
2040
|
+
* Pass `false` to opt out of registry enrollment entirely.
|
|
2041
|
+
* @default true
|
|
2451
2042
|
*/
|
|
2452
2043
|
cache?: boolean;
|
|
2453
2044
|
};
|
|
@@ -2471,15 +2062,18 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
|
|
|
2471
2062
|
* normal: '/normal.png'
|
|
2472
2063
|
* })
|
|
2473
2064
|
*
|
|
2474
|
-
* //
|
|
2475
|
-
* //
|
|
2476
|
-
* const diffuse = useTexture('/diffuse.png'
|
|
2065
|
+
* // Textures are registered in the global registry by default — the same texture
|
|
2066
|
+
* // object is shared across components and modifications (colorSpace, wrapS, etc.) are preserved
|
|
2067
|
+
* const diffuse = useTexture('/diffuse.png')
|
|
2477
2068
|
* diffuse.colorSpace = THREE.SRGBColorSpace
|
|
2478
2069
|
*
|
|
2479
2070
|
* // Another component gets the SAME texture with colorSpace already set
|
|
2480
|
-
* const sameDiffuse = useTexture('/diffuse.png'
|
|
2071
|
+
* const sameDiffuse = useTexture('/diffuse.png')
|
|
2072
|
+
*
|
|
2073
|
+
* // Opt out of registry enrollment for a one-off texture
|
|
2074
|
+
* const scratch = useTexture('/scratch.png', { cache: false })
|
|
2481
2075
|
*
|
|
2482
|
-
* // Access
|
|
2076
|
+
* // Access the registry directly
|
|
2483
2077
|
* const { get } = useTextures()
|
|
2484
2078
|
* const cached = get('/diffuse.png')
|
|
2485
2079
|
* ```
|
|
@@ -2496,63 +2090,80 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
|
|
|
2496
2090
|
cache?: boolean;
|
|
2497
2091
|
}) => react_jsx_runtime.JSX.Element;
|
|
2498
2092
|
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2093
|
+
/** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
|
|
2094
|
+
type TextureInput = string | string[] | Record<string, string>;
|
|
2095
|
+
/** Result of a `get()` read, mirroring the input shape. */
|
|
2096
|
+
type TextureResult<Input extends TextureInput> = Input extends string ? Texture$1 | undefined : Input extends string[] ? (Texture$1 | undefined)[] : {
|
|
2097
|
+
[K in keyof Input]: Texture$1 | undefined;
|
|
2502
2098
|
};
|
|
2099
|
+
/** Options for `dispose()`. */
|
|
2100
|
+
interface DisposeOptions {
|
|
2101
|
+
/** Dispose even if the texture still has active references (default false). */
|
|
2102
|
+
force?: boolean;
|
|
2103
|
+
}
|
|
2503
2104
|
interface UseTexturesReturn {
|
|
2504
|
-
/** Map
|
|
2505
|
-
|
|
2506
|
-
/**
|
|
2507
|
-
get
|
|
2508
|
-
/** Check
|
|
2509
|
-
has
|
|
2510
|
-
/**
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2105
|
+
/** The live registry Map (key → Texture). Treat as read-only. */
|
|
2106
|
+
readonly all: Map<string, Texture$1>;
|
|
2107
|
+
/** Read one texture, an array of textures, or a name→texture record (mirrors the input shape). */
|
|
2108
|
+
get<Input extends TextureInput>(input: Input): TextureResult<Input>;
|
|
2109
|
+
/** Check whether a key exists in the registry. */
|
|
2110
|
+
has(key: string): boolean;
|
|
2111
|
+
/**
|
|
2112
|
+
* Register a texture (or a record of textures) that has no URL — e.g. a render
|
|
2113
|
+
* target or procedural texture. URL-loaded textures are registered automatically
|
|
2114
|
+
* by `useTexture` (registry enrollment is on by default).
|
|
2115
|
+
*/
|
|
2116
|
+
add(key: string, texture: Texture$1): void;
|
|
2117
|
+
add(record: Record<string, Texture$1>): void;
|
|
2118
|
+
/**
|
|
2119
|
+
* Dispose a texture's GPU resources and remove it from the registry.
|
|
2120
|
+
* Refcount-aware: if the key is still in use by a mounted `useTexture` consumer it is
|
|
2121
|
+
* skipped (with a warning) unless `{ force: true }` is passed.
|
|
2122
|
+
* @returns true if disposed, false if skipped.
|
|
2123
|
+
*/
|
|
2124
|
+
dispose(key: string, options?: DisposeOptions): boolean;
|
|
2125
|
+
/** Dispose every texture in the registry and clear it. Use on scene teardown. */
|
|
2126
|
+
disposeAll(): void;
|
|
2524
2127
|
}
|
|
2525
2128
|
/**
|
|
2526
|
-
*
|
|
2129
|
+
* Reactive Texture registry — load once with `useTexture`, reach the textures from anywhere.
|
|
2527
2130
|
*
|
|
2528
|
-
*
|
|
2529
|
-
*
|
|
2131
|
+
* This is a registry of plain `Texture` objects (not TSL nodes), so the same texture can feed
|
|
2132
|
+
* a material map, a heightmap sampler, or anything else. It does **not** load — pair it with
|
|
2133
|
+
* `useTexture` for loading (registry enrollment is on by default); `useTextures` is for access and lifecycle.
|
|
2134
|
+
*
|
|
2135
|
+
* The returned handle is **reactive**: the calling component re-renders when the registry
|
|
2136
|
+
* changes. Pass a selector to scope the subscription to a single read.
|
|
2530
2137
|
*
|
|
2531
2138
|
* @example
|
|
2532
2139
|
* ```tsx
|
|
2533
|
-
*
|
|
2534
|
-
*
|
|
2535
|
-
* // Check if texture is already cached
|
|
2536
|
-
* if (!has('/textures/diffuse.png')) {
|
|
2537
|
-
* // Load with useTexture and cache: true, or manually add
|
|
2538
|
-
* const tex = useTexture('/textures/diffuse.png', { cache: true })
|
|
2539
|
-
* }
|
|
2140
|
+
* // Load + register once (anywhere in the tree) — registered by default
|
|
2141
|
+
* useTexture({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
|
|
2540
2142
|
*
|
|
2541
|
-
* //
|
|
2542
|
-
* const
|
|
2543
|
-
*
|
|
2143
|
+
* // Reach them from another component — record form lands straight into a material
|
|
2144
|
+
* const { map, normalMap } = useTextures().get({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
|
|
2145
|
+
* return <meshStandardMaterial map={map} normalMap={normalMap} />
|
|
2544
2146
|
*
|
|
2545
|
-
* //
|
|
2546
|
-
*
|
|
2147
|
+
* // A set of heightmaps at once
|
|
2148
|
+
* const [a, b, c] = useTextures().get(['/h0.png', '/h1.png', '/h2.png'])
|
|
2547
2149
|
*
|
|
2548
|
-
* //
|
|
2549
|
-
*
|
|
2150
|
+
* // Register a non-URL texture (render target / procedural)
|
|
2151
|
+
* useTextures().add('rt-main', renderTarget.texture)
|
|
2550
2152
|
*
|
|
2551
|
-
* //
|
|
2552
|
-
*
|
|
2153
|
+
* // Deliberate GPU cleanup (refcount-aware; force to override)
|
|
2154
|
+
* useTextures().dispose('/diffuse.jpg')
|
|
2155
|
+
* useTextures().disposeAll() // scene teardown
|
|
2553
2156
|
* ```
|
|
2157
|
+
*
|
|
2158
|
+
* @remarks
|
|
2159
|
+
* **Future expansion:** an imperative async loader (e.g. `await useTextures().load('/x.jpg')`) is
|
|
2160
|
+
* intentionally not included yet. It would let non-React code (loading screens, dynamic streaming)
|
|
2161
|
+
* populate the registry without Suspense, at the cost of putting loading back into this hook. It
|
|
2162
|
+
* will be added only if a concrete consumer needs imperative loading; for now, loading lives in
|
|
2163
|
+
* `useTexture`.
|
|
2554
2164
|
*/
|
|
2555
2165
|
declare function useTextures(): UseTexturesReturn;
|
|
2166
|
+
declare function useTextures<T>(selector: (registry: UseTexturesReturn) => T): T;
|
|
2556
2167
|
|
|
2557
2168
|
/**
|
|
2558
2169
|
* Creates a render target compatible with the current renderer.
|
|
@@ -2582,20 +2193,10 @@ declare function useTextures(): UseTexturesReturn;
|
|
|
2582
2193
|
* const fbo = useRenderTarget(512, 256, { samples: 4 })
|
|
2583
2194
|
* ```
|
|
2584
2195
|
*/
|
|
2585
|
-
declare function useRenderTarget(options?: RenderTargetOptions):
|
|
2586
|
-
declare function useRenderTarget(size: number, options?: RenderTargetOptions):
|
|
2587
|
-
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions):
|
|
2196
|
+
declare function useRenderTarget(options?: RenderTargetOptions): WebGLRenderTarget;
|
|
2197
|
+
declare function useRenderTarget(size: number, options?: RenderTargetOptions): WebGLRenderTarget;
|
|
2198
|
+
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): WebGLRenderTarget;
|
|
2588
2199
|
|
|
2589
|
-
/**
|
|
2590
|
-
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
2591
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
2592
|
-
*/
|
|
2593
|
-
declare function useStore(): RootStore;
|
|
2594
|
-
/**
|
|
2595
|
-
* Accesses R3F's internal state, containing renderer, canvas, scene, etc.
|
|
2596
|
-
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
|
|
2597
|
-
*/
|
|
2598
|
-
declare function useThree<T = RootState>(selector?: (state: RootState) => T, equalityFn?: <T>(state: T, newState: T) => boolean): T;
|
|
2599
2200
|
/**
|
|
2600
2201
|
* Exposes an object's {@link Instance}.
|
|
2601
2202
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
|
|
@@ -2671,7 +2272,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2671
2272
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2672
2273
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2673
2274
|
*
|
|
2674
|
-
*
|
|
2275
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2276
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2277
|
+
*
|
|
2278
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2675
2279
|
* @param frames - Number of frames to request (default: 1)
|
|
2676
2280
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2677
2281
|
*
|
|
@@ -2682,14 +2286,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2682
2286
|
* Advances the frameloop and runs render effects.
|
|
2683
2287
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2684
2288
|
*
|
|
2289
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2290
|
+
* registered root is stepped for backwards compatibility.
|
|
2291
|
+
*
|
|
2685
2292
|
* @param timestamp - The timestamp to use for this frame
|
|
2686
2293
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2687
|
-
* @param state -
|
|
2688
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2294
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2689
2295
|
*
|
|
2690
2296
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2691
2297
|
*/
|
|
2692
|
-
declare function advance(timestamp: number): void;
|
|
2298
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2693
2299
|
|
|
2694
2300
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2695
2301
|
declare function ReactReconciler<
|
|
@@ -3734,6 +3340,7 @@ declare namespace ReactReconciler {
|
|
|
3734
3340
|
|
|
3735
3341
|
declare function extend<T extends ConstructorRepresentation>(objects: T): React$1.ExoticComponent<ThreeElement<T>>;
|
|
3736
3342
|
declare function extend<T extends Catalogue>(objects: T): void;
|
|
3343
|
+
declare function extend(objects: Record<string, unknown>): void;
|
|
3737
3344
|
declare const reconciler: ReactReconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, never, any>;
|
|
3738
3345
|
|
|
3739
3346
|
declare const isRenderer: (def: any) => boolean;
|
|
@@ -3758,13 +3365,9 @@ declare function Portal({ children, container, state }: PortalProps): JSX.Elemen
|
|
|
3758
3365
|
declare function flushSync<R>(fn: () => R): R;
|
|
3759
3366
|
|
|
3760
3367
|
declare const context: React$1.Context<RootStore>;
|
|
3368
|
+
|
|
3761
3369
|
declare const createStore: (invalidate: (state?: RootState, frames?: number, stackFrames?: boolean) => void, advance: (timestamp: number, runGlobalEffects?: boolean, state?: RootState, frame?: XRFrame) => void) => RootStore;
|
|
3762
3370
|
|
|
3763
|
-
/**
|
|
3764
|
-
* Safely flush async effects when testing, simulating a legacy root.
|
|
3765
|
-
* @deprecated Import from React instead. import { act } from 'react'
|
|
3766
|
-
*/
|
|
3767
|
-
declare const act: typeof React$1.act;
|
|
3768
3371
|
/**
|
|
3769
3372
|
* An SSR-friendly useLayoutEffect.
|
|
3770
3373
|
*
|
|
@@ -4016,7 +3619,7 @@ declare function getInstanceProps<T = any>(pendingProps: Record<string, unknown>
|
|
|
4016
3619
|
declare function prepare<T = any>(target: T, root: RootStore, type: string, props: Instance<T>['props']): Instance<T>;
|
|
4017
3620
|
/**
|
|
4018
3621
|
* Triggers an update for an instance.
|
|
4019
|
-
*
|
|
3622
|
+
* Invalidates the frame if the root is in demand mode.
|
|
4020
3623
|
*
|
|
4021
3624
|
* @param instance - Instance to invalidate
|
|
4022
3625
|
*/
|
|
@@ -4182,29 +3785,44 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
4182
3785
|
* Used to identify values that should be resolved from refs after mount.
|
|
4183
3786
|
*/
|
|
4184
3787
|
declare const FROM_REF: unique symbol;
|
|
3788
|
+
/** The marker `fromRef()` returns; resolved by the reconciler in `commitMount`. */
|
|
3789
|
+
interface FromRefMarker<T = unknown, R = T> {
|
|
3790
|
+
[FROM_REF]: React$1.RefObject<T | null>;
|
|
3791
|
+
/** Optional transform applied to the resolved ref before assignment. */
|
|
3792
|
+
transform?: (value: T) => R;
|
|
3793
|
+
}
|
|
4185
3794
|
/**
|
|
4186
3795
|
* Defers prop application until the referenced object is available.
|
|
4187
3796
|
* Useful for props like `target` that need sibling refs to be populated.
|
|
4188
3797
|
*
|
|
3798
|
+
* Only top-level props on a three element are resolved: a marker nested inside another value
|
|
3799
|
+
* (an array, an options object) is never seen. When the prop needs the sibling *wrapped* rather
|
|
3800
|
+
* than assigned as-is, pass a `transform`; it runs once the ref is populated and its result is
|
|
3801
|
+
* what gets assigned.
|
|
3802
|
+
*
|
|
4189
3803
|
* @param ref - React ref object to resolve at mount time
|
|
4190
|
-
* @
|
|
3804
|
+
* @param transform - Optional mapping from the resolved object to the value the prop expects
|
|
3805
|
+
* @returns A marker value that the reconciler resolves after mount
|
|
4191
3806
|
*
|
|
4192
3807
|
* @example
|
|
4193
3808
|
* const targetRef = useRef<THREE.Object3D>(null)
|
|
4194
3809
|
*
|
|
4195
3810
|
* <group ref={targetRef} position={[-3, -2, -15]} />
|
|
4196
3811
|
* <spotLight target={fromRef(targetRef)} intensity={100} />
|
|
3812
|
+
*
|
|
3813
|
+
* @example
|
|
3814
|
+
* // Wrap the sibling: a node material's lightsNode needs a LightsNode, not the light itself
|
|
3815
|
+
* <meshPhongNodeMaterial lightsNode={fromRef(lightRef, (light) => lights([light]))} />
|
|
4197
3816
|
*/
|
|
4198
3817
|
declare function fromRef<T>(ref: React$1.RefObject<T | null>): T;
|
|
3818
|
+
declare function fromRef<T, R>(ref: React$1.RefObject<T | null>, transform: (value: T) => R): R;
|
|
4199
3819
|
/**
|
|
4200
3820
|
* Type guard to check if a value is a fromRef marker.
|
|
4201
3821
|
*
|
|
4202
3822
|
* @param value - Value to check
|
|
4203
3823
|
* @returns True if value is a fromRef marker
|
|
4204
3824
|
*/
|
|
4205
|
-
declare function isFromRef(value: unknown): value is
|
|
4206
|
-
[FROM_REF]: React$1.RefObject<any>;
|
|
4207
|
-
};
|
|
3825
|
+
declare function isFromRef(value: unknown): value is FromRefMarker<any, unknown>;
|
|
4208
3826
|
|
|
4209
3827
|
/**
|
|
4210
3828
|
* Symbol marker for mount-only method calls.
|
|
@@ -4231,7 +3849,15 @@ declare const ONCE: unique symbol;
|
|
|
4231
3849
|
* // No arguments
|
|
4232
3850
|
* <geometry center={once()} />
|
|
4233
3851
|
*/
|
|
4234
|
-
declare function once<
|
|
3852
|
+
declare function once<A extends unknown[]>(...args: A): OnceValue<A>;
|
|
3853
|
+
/**
|
|
3854
|
+
* What `once(...args)` is typed as, so the marker is assignable to the prop it targets:
|
|
3855
|
+
* the single argument itself (`rotateX={once(angle)}`), the argument tuple for multi-argument
|
|
3856
|
+
* methods (`translate={once(x, y, z)}`), or `true` for a bare call (`center={once()}`).
|
|
3857
|
+
*
|
|
3858
|
+
* The runtime value is always the marker object; only the declared type follows the prop.
|
|
3859
|
+
*/
|
|
3860
|
+
type OnceValue<A extends unknown[]> = A extends [] ? true : A extends [infer Single] ? Single : A;
|
|
4235
3861
|
/**
|
|
4236
3862
|
* Type guard to check if a value is a once marker.
|
|
4237
3863
|
*
|
|
@@ -4243,10 +3869,31 @@ declare function isOnce(value: unknown): value is {
|
|
|
4243
3869
|
};
|
|
4244
3870
|
|
|
4245
3871
|
/**
|
|
4246
|
-
*
|
|
4247
|
-
*
|
|
3872
|
+
* @fileoverview Legacy entry point - WebGL only
|
|
3873
|
+
*
|
|
3874
|
+
* This entry point is for apps that want to use the legacy WebGLRenderer.
|
|
3875
|
+
* No WebGPU features are available from this import path.
|
|
3876
|
+
* Auto-extends THREE with WebGL-only constructors (no node materials).
|
|
3877
|
+
*
|
|
3878
|
+
* Usage:
|
|
3879
|
+
* import { Canvas, useFrame } from '@react-three/fiber/legacy'
|
|
4248
3880
|
*/
|
|
4249
|
-
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
4250
3881
|
|
|
4251
|
-
|
|
4252
|
-
|
|
3882
|
+
/** `useThree` narrowed to legacy state — `state.renderer` is a `WebGLRenderer`. */
|
|
3883
|
+
type UseThreeLegacy = <T = LegacyRootState>(selector?: (state: LegacyRootState) => T, equalityFn?: <U>(state: U, newState: U) => boolean) => T;
|
|
3884
|
+
/** `useFrame` narrowed to legacy state — the callback's `state.renderer` is a `WebGLRenderer`. */
|
|
3885
|
+
type UseFrameLegacy = (callback?: FrameCallback$1<LegacyRootState>, priorityOrOptions?: number | UseFrameNextOptions) => FrameNextControls;
|
|
3886
|
+
declare const useThree: UseThreeLegacy;
|
|
3887
|
+
declare const useFrame: UseFrameLegacy;
|
|
3888
|
+
|
|
3889
|
+
/** Canvas props on the legacy entry: `onCreated` receives `LegacyRootState`. */
|
|
3890
|
+
type LegacyCanvasProps = Omit<CanvasProps, 'onCreated'> & {
|
|
3891
|
+
/** Callback after the canvas has rendered (but not yet committed); `state.renderer` is a `WebGLRenderer` */
|
|
3892
|
+
onCreated?: (state: LegacyRootState) => void;
|
|
3893
|
+
};
|
|
3894
|
+
|
|
3895
|
+
/** `Canvas` narrowed to legacy state — the same component, `onCreated` typed against `LegacyRootState`. */
|
|
3896
|
+
declare const Canvas: (props: LegacyCanvasProps) => JSX.Element;
|
|
3897
|
+
|
|
3898
|
+
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, registerRootExtension, removeInteractivity, resolve, setRenderOverride, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3899
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, LegacyCanvasProps as 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, FromRefMarker, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, LegacyInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyCanvasProps, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, Object3DMethod, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, OnceValue, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootExtension, LegacyRootState as RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameLegacy, UseTextureOptions, UseTexturesReturn, UseThreeLegacy, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|