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