@react-three/fiber 10.0.0-canary.2b511a5 → 10.0.0-canary.2c50459
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +529 -1305
- package/dist/index.d.cts +246 -785
- package/dist/index.d.mts +246 -785
- package/dist/index.d.ts +246 -785
- package/dist/index.mjs +503 -1278
- package/dist/legacy.cjs +523 -1305
- package/dist/legacy.d.cts +246 -785
- package/dist/legacy.d.mts +246 -785
- package/dist/legacy.d.ts +246 -785
- package/dist/legacy.mjs +497 -1278
- package/dist/webgpu/index.cjs +937 -1331
- package/dist/webgpu/index.d.cts +331 -798
- package/dist/webgpu/index.d.mts +331 -798
- package/dist/webgpu/index.d.ts +331 -798
- package/dist/webgpu/index.mjs +906 -1303
- package/package.json +2 -1
- package/readme.md +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as three_webgpu from 'three/webgpu';
|
|
2
|
-
import { RenderTarget, WebGPURenderer,
|
|
2
|
+
import { RenderTarget, WebGPURenderer, Node, StorageTexture, Data3DTexture, CanvasTarget, ShaderNodeObject, Euler as Euler$2, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, BufferGeometry, Matrix4 as Matrix4$1, Quaternion as Quaternion$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Matrix3 as Matrix3$1, Loader as Loader$1, ColorSpace, Texture as Texture$1, CubeTexture, Scene, Object3D, Frustum, OrthographicCamera } from 'three/webgpu';
|
|
3
3
|
import * as THREE$1 from 'three';
|
|
4
4
|
import { WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, Euler as Euler$1, Loader, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
5
5
|
import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
|
|
@@ -8,6 +8,8 @@ import * as React$1 from 'react';
|
|
|
8
8
|
import { ReactNode, Component, RefObject, JSX } from 'react';
|
|
9
9
|
import { StoreApi } from 'zustand';
|
|
10
10
|
import { UseBoundStoreWithEqualityFn } from 'zustand/traditional';
|
|
11
|
+
import { FrameTimingState, FrameCallback as FrameCallback$1, SchedulerApi, UseFrameNextOptions, FrameNextControls } from '@pmndrs/scheduler';
|
|
12
|
+
export { AddPhaseOptions, FrameControls, FrameNextControls, FrameTimingState, RootOptions, Scheduler, SchedulerApi, UseFrameNextOptions, UseFrameOptions, getScheduler } from '@pmndrs/scheduler';
|
|
11
13
|
import { Options } from 'react-use-measure';
|
|
12
14
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
13
15
|
import { ThreeElement as ThreeElement$1, Euler as Euler$3 } from '@react-three/fiber';
|
|
@@ -149,6 +151,8 @@ interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
|
149
151
|
unprojectedPoint: THREE$1.Vector3
|
|
150
152
|
/** Normalized event coordinates */
|
|
151
153
|
pointer: THREE$1.Vector2
|
|
154
|
+
/** pointerId of the original event for multiple pointer events */
|
|
155
|
+
pointerId: number
|
|
152
156
|
/** Delta between first click and this event */
|
|
153
157
|
delta: number
|
|
154
158
|
/** The ray that pierced it */
|
|
@@ -225,6 +229,18 @@ interface EventHandlers {
|
|
|
225
229
|
type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
|
|
226
230
|
type ComputeFunction = (event: DomEvent, root: RootState, previous?: RootState) => void
|
|
227
231
|
|
|
232
|
+
/** Configuration for XR pointer registration (controllers/hands) */
|
|
233
|
+
interface XRPointerConfig {
|
|
234
|
+
/** Ray origin (updated each frame by XR system) */
|
|
235
|
+
ray: THREE$1.Ray
|
|
236
|
+
/** Optional: custom compute function for this pointer */
|
|
237
|
+
compute?: (state: RootState) => void
|
|
238
|
+
/** Pointer type identifier */
|
|
239
|
+
type: 'controller' | 'hand' | 'gaze'
|
|
240
|
+
/** Which hand (for controller/hand types) */
|
|
241
|
+
handedness?: 'left' | 'right'
|
|
242
|
+
}
|
|
243
|
+
|
|
228
244
|
interface EventManager<TTarget> {
|
|
229
245
|
/** Determines if the event layer is active */
|
|
230
246
|
enabled: boolean
|
|
@@ -244,8 +260,21 @@ interface EventManager<TTarget> {
|
|
|
244
260
|
disconnect?: () => void
|
|
245
261
|
/** Triggers a onPointerMove with the last known event. This can be useful to enable raycasting without
|
|
246
262
|
* explicit user interaction, for instance when the camera moves a hoverable object underneath the cursor.
|
|
263
|
+
* @param pointerId - Optional pointer ID to update specific pointer only
|
|
247
264
|
*/
|
|
248
|
-
update?: () => void
|
|
265
|
+
update?: (pointerId?: number) => void
|
|
266
|
+
/** Defer pointer move raycasting to frame start (default: true) */
|
|
267
|
+
frameTimedRaycasts?: boolean
|
|
268
|
+
/** Always fire raycaster immediately on scroll events (default: true) */
|
|
269
|
+
alwaysFireOnScroll?: boolean
|
|
270
|
+
/** Automatically re-raycast every frame to detect hover changes from moving objects/camera (default: false) */
|
|
271
|
+
updateOnFrame?: boolean
|
|
272
|
+
/** Flush deferred pointer raycasts. Called by scheduler at frame start (input phase). */
|
|
273
|
+
flush?: () => void
|
|
274
|
+
/** Register an XR pointer (controller/hand). Returns assigned pointerId */
|
|
275
|
+
registerPointer?: (config: XRPointerConfig) => number
|
|
276
|
+
/** Unregister an XR pointer */
|
|
277
|
+
unregisterPointer?: (pointerId: number) => void
|
|
249
278
|
}
|
|
250
279
|
|
|
251
280
|
interface PointerCaptureTarget {
|
|
@@ -265,227 +294,94 @@ interface VisibilityEntry {
|
|
|
265
294
|
}
|
|
266
295
|
|
|
267
296
|
//* Scheduler Types (useFrame) ==============================
|
|
297
|
+
//
|
|
298
|
+
// The generic, framework-agnostic scheduler types now live in @pmndrs/scheduler.
|
|
299
|
+
// This file re-exports them and layers r3f's RootState-aware frame state on top,
|
|
300
|
+
// so existing `#types` imports across the codebase keep resolving unchanged.
|
|
268
301
|
|
|
269
302
|
|
|
270
303
|
|
|
271
|
-
//
|
|
304
|
+
// Frame State (r3f-specific) --------------------------------
|
|
272
305
|
|
|
273
306
|
/**
|
|
274
|
-
*
|
|
307
|
+
* State passed to useFrame callbacks (extends RootState with timing).
|
|
275
308
|
*/
|
|
276
|
-
interface
|
|
277
|
-
/** Optional stable id for the job. Auto-generated if not provided */
|
|
278
|
-
id?: string
|
|
279
|
-
/** Named phase to run in. Default: 'update' */
|
|
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
|
-
}
|
|
294
|
-
|
|
295
|
-
/** Alias for UseFrameNextOptions */
|
|
296
|
-
type UseFrameOptions = UseFrameNextOptions
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Options for addPhase
|
|
300
|
-
*/
|
|
301
|
-
interface AddPhaseOptions {
|
|
302
|
-
/** Insert this phase before the specified phase */
|
|
303
|
-
before?: string
|
|
304
|
-
/** Insert this phase after the specified phase */
|
|
305
|
-
after?: string
|
|
306
|
-
}
|
|
309
|
+
interface FrameNextState extends RootState, FrameTimingState {}
|
|
307
310
|
|
|
308
|
-
|
|
311
|
+
/** Alias for FrameNextState */
|
|
312
|
+
type FrameState = FrameNextState
|
|
309
313
|
|
|
310
|
-
|
|
311
|
-
* Timing-only state for independent/outside mode (no RootState)
|
|
312
|
-
*/
|
|
313
|
-
interface FrameTimingState {
|
|
314
|
-
/** High-resolution timestamp from RAF (ms) */
|
|
315
|
-
time: number
|
|
316
|
-
/** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
317
|
-
delta: number
|
|
318
|
-
/** Elapsed time since first frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
319
|
-
elapsed: number
|
|
320
|
-
/** Incrementing frame counter */
|
|
321
|
-
frame: number
|
|
322
|
-
}
|
|
314
|
+
// Callback Types (r3f-specific) --------------------------------
|
|
323
315
|
|
|
324
316
|
/**
|
|
325
|
-
*
|
|
317
|
+
* Callback function for useFrame. Receives the full r3f RootState plus timing.
|
|
326
318
|
*/
|
|
327
|
-
|
|
319
|
+
type FrameNextCallback = FrameCallback$1<RootState>
|
|
328
320
|
|
|
329
|
-
/** Alias for
|
|
330
|
-
type
|
|
321
|
+
/** Alias for FrameNextCallback */
|
|
322
|
+
type FrameCallback = FrameNextCallback
|
|
331
323
|
|
|
332
|
-
|
|
324
|
+
//* Buffer Types (useBuffers) ========================================
|
|
333
325
|
|
|
334
326
|
/**
|
|
335
|
-
*
|
|
327
|
+
* Buffer-like types for GPU compute and storage operations.
|
|
328
|
+
* Includes raw CPU arrays, Three.js buffer attributes, and TSL buffer nodes.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```tsx
|
|
332
|
+
* const { positions, velocities } = useBuffers(() => ({
|
|
333
|
+
* positions: instancedArray(count, 'vec3'), // StorageBufferNode
|
|
334
|
+
* velocities: new Float32Array(count * 3), // TypedArray
|
|
335
|
+
* }), 'particles')
|
|
336
|
+
* ```
|
|
336
337
|
*/
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
338
|
+
type BufferLike =
|
|
339
|
+
| Float32Array
|
|
340
|
+
| Uint32Array
|
|
341
|
+
| Int32Array
|
|
342
|
+
| Float64Array
|
|
343
|
+
| Uint8Array
|
|
344
|
+
| Int8Array
|
|
345
|
+
| Uint16Array
|
|
346
|
+
| Int16Array
|
|
347
|
+
| THREE$1.BufferAttribute // Base class for all buffer attributes
|
|
348
|
+
| Node // TSL buffer nodes (instancedArray, storage)
|
|
343
349
|
|
|
344
|
-
|
|
350
|
+
/** Flat record of buffer-like values (no nested scopes) */
|
|
351
|
+
type BufferRecord = Record<string, BufferLike>
|
|
345
352
|
|
|
346
353
|
/**
|
|
347
|
-
*
|
|
354
|
+
* Buffer store that can contain both root-level buffers and scoped buffer objects.
|
|
355
|
+
* Structure: { positions: Float32Array, particles: { vel: StorageBufferNode } }
|
|
348
356
|
*/
|
|
349
|
-
type
|
|
357
|
+
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
350
358
|
|
|
351
|
-
|
|
352
|
-
type FrameCallback = FrameNextCallback
|
|
353
|
-
|
|
354
|
-
// Controls returned from useFrame --------------------------------
|
|
359
|
+
//* Storage Types (useGPUStorage) ========================================
|
|
355
360
|
|
|
356
361
|
/**
|
|
357
|
-
*
|
|
362
|
+
* GPU storage types for texture-based storage operations.
|
|
363
|
+
* Includes Three.js storage textures and TSL storage texture nodes.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```tsx
|
|
367
|
+
* const { heightMap } = useGPUStorage(() => ({
|
|
368
|
+
* heightMap: new StorageTexture(512, 512),
|
|
369
|
+
* }), 'terrain')
|
|
370
|
+
* ```
|
|
358
371
|
*/
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
scheduler: SchedulerApi
|
|
364
|
-
/** Manually step this job only (bypasses FPS limiting) */
|
|
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
|
|
372
|
+
type StorageLike =
|
|
373
|
+
| StorageTexture // GPU storage texture
|
|
374
|
+
| Data3DTexture // 3D texture (can be used as storage)
|
|
375
|
+
| Node // TSL storage texture nodes (storageTexture)
|
|
378
376
|
|
|
379
|
-
|
|
377
|
+
/** Flat record of storage-like values (no nested scopes) */
|
|
378
|
+
type StorageRecord = Record<string, StorageLike>
|
|
380
379
|
|
|
381
380
|
/**
|
|
382
|
-
*
|
|
381
|
+
* Storage store that can contain both root-level storage and scoped storage objects.
|
|
382
|
+
* Structure: { heightMap: StorageTexture, terrain: { normal: StorageTextureNode } }
|
|
383
383
|
*/
|
|
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
|
-
}
|
|
384
|
+
type StorageStore = Record<string, StorageLike | StorageRecord>
|
|
489
385
|
|
|
490
386
|
//* Renderer Types ========================================
|
|
491
387
|
|
|
@@ -500,6 +396,18 @@ type Subscription = {
|
|
|
500
396
|
store: RootStore
|
|
501
397
|
}
|
|
502
398
|
|
|
399
|
+
/** Per-pointer state for multi-touch and XR support */
|
|
400
|
+
type PointerState = {
|
|
401
|
+
/** Objects currently hovered by this pointer */
|
|
402
|
+
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
403
|
+
/** Objects capturing this pointer */
|
|
404
|
+
captured: Map<THREE$1.Object3D, PointerCaptureTarget>
|
|
405
|
+
/** Initial click position [x, y] */
|
|
406
|
+
initialClick: [x: number, y: number]
|
|
407
|
+
/** Objects hit on initial click */
|
|
408
|
+
initialHits: THREE$1.Object3D[]
|
|
409
|
+
}
|
|
410
|
+
|
|
503
411
|
type Dpr = number | [min: number, max: number]
|
|
504
412
|
|
|
505
413
|
interface Size {
|
|
@@ -541,12 +449,21 @@ interface Performance {
|
|
|
541
449
|
|
|
542
450
|
interface InternalState {
|
|
543
451
|
interaction: THREE$1.Object3D[]
|
|
544
|
-
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
545
452
|
subscribers: Subscription[]
|
|
453
|
+
/** Per-pointer state (hover, capture, click tracking) - replaces hovered, capturedMap, initialClick, initialHits */
|
|
454
|
+
pointerMap: Map<number, PointerState>
|
|
455
|
+
/** Pointers needing raycast this frame (used with frameTimedRaycasts) */
|
|
456
|
+
pointerDirty: Map<number, DomEvent>
|
|
457
|
+
/** Last event received (for events.update() compatibility) */
|
|
458
|
+
lastEvent: React$1.RefObject<DomEvent | null>
|
|
459
|
+
/** @deprecated Use pointerMap.get(pointerId).hovered instead */
|
|
460
|
+
hovered: Map<string, ThreeEvent<DomEvent>>
|
|
461
|
+
/** @deprecated Use pointerMap.get(pointerId).captured instead */
|
|
546
462
|
capturedMap: Map<number, Map<THREE$1.Object3D, PointerCaptureTarget>>
|
|
463
|
+
/** @deprecated Use pointerMap.get(pointerId).initialClick instead */
|
|
547
464
|
initialClick: [x: number, y: number]
|
|
465
|
+
/** @deprecated Use pointerMap.get(pointerId).initialHits instead */
|
|
548
466
|
initialHits: THREE$1.Object3D[]
|
|
549
|
-
lastEvent: React$1.RefObject<DomEvent | null>
|
|
550
467
|
/** Visibility event registry (onFramed, onOccluded, onVisible) */
|
|
551
468
|
visibilityRegistry: Map<string, VisibilityEntry>
|
|
552
469
|
/** Whether occlusion queries are enabled (WebGPU only) */
|
|
@@ -687,11 +604,17 @@ interface RootState {
|
|
|
687
604
|
uniforms: UniformStore
|
|
688
605
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
689
606
|
nodes: Record<string, any>
|
|
690
|
-
/** Global TSL
|
|
691
|
-
|
|
692
|
-
/**
|
|
693
|
-
|
|
694
|
-
/** Global
|
|
607
|
+
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
608
|
+
buffers: BufferStore
|
|
609
|
+
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
610
|
+
gpuStorage: StorageStore
|
|
611
|
+
/** Global Texture registry (key → Texture, usually keyed by URL) - use useTextures() hook for access + lifecycle */
|
|
612
|
+
textures: Map<string, THREE$1.Texture>
|
|
613
|
+
/** Internal: refcount per texture key, driven by mounted useTexture consumers (registry enrollment is on by default) */
|
|
614
|
+
_textureRefs: Map<string, number>
|
|
615
|
+
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
616
|
+
renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
|
|
617
|
+
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
695
618
|
passes: Record<string, any>
|
|
696
619
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
697
620
|
_hmrVersion: number
|
|
@@ -741,6 +664,20 @@ interface Renderer {
|
|
|
741
664
|
render: (scene: THREE$1.Scene, camera: THREE$1.Camera) => any
|
|
742
665
|
}
|
|
743
666
|
|
|
667
|
+
//* Color Management Config ==============================
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Color management configuration shared by both WebGL and WebGPU renderers.
|
|
671
|
+
*/
|
|
672
|
+
interface ColorManagementConfig {
|
|
673
|
+
/**
|
|
674
|
+
* Color space assigned to 8-bit input textures (color maps).
|
|
675
|
+
* Defaults to sRGB. Most textures are authored in sRGB.
|
|
676
|
+
* @default THREE.SRGBColorSpace
|
|
677
|
+
*/
|
|
678
|
+
textureColorSpace?: THREE$1.ColorSpace
|
|
679
|
+
}
|
|
680
|
+
|
|
744
681
|
//* WebGL Renderer Props ==============================
|
|
745
682
|
|
|
746
683
|
type DefaultGLProps = Omit<THREE$1.WebGLRendererParameters, 'canvas'> & {
|
|
@@ -751,7 +688,7 @@ type GLProps =
|
|
|
751
688
|
| Renderer
|
|
752
689
|
| ((defaultProps: DefaultGLProps) => Renderer)
|
|
753
690
|
| ((defaultProps: DefaultGLProps) => Promise<Renderer>)
|
|
754
|
-
| Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters>
|
|
691
|
+
| (Partial<Properties<THREE$1.WebGLRenderer> | THREE$1.WebGLRendererParameters> & ColorManagementConfig)
|
|
755
692
|
|
|
756
693
|
//* WebGPU Renderer Props ==============================
|
|
757
694
|
|
|
@@ -777,9 +714,9 @@ interface CanvasSchedulerConfig {
|
|
|
777
714
|
}
|
|
778
715
|
|
|
779
716
|
/**
|
|
780
|
-
* Extended renderer configuration for multi-canvas support.
|
|
717
|
+
* Extended renderer configuration for multi-canvas support and color management.
|
|
781
718
|
*/
|
|
782
|
-
interface RendererConfigExtended {
|
|
719
|
+
interface RendererConfigExtended extends ColorManagementConfig {
|
|
783
720
|
/** Share renderer from another canvas (WebGPU only) */
|
|
784
721
|
primaryCanvas?: string
|
|
785
722
|
/** Canvas-level scheduler options */
|
|
@@ -844,8 +781,6 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
844
781
|
* @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.shadowMap
|
|
845
782
|
*/
|
|
846
783
|
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
784
|
/** Creates an orthographic camera */
|
|
850
785
|
orthographic?: boolean
|
|
851
786
|
/**
|
|
@@ -1098,7 +1033,7 @@ interface CanvasProps
|
|
|
1098
1033
|
*/
|
|
1099
1034
|
resize?: Options
|
|
1100
1035
|
/** The target where events are being subscribed to, default: the div that wraps canvas */
|
|
1101
|
-
eventSource?: HTMLElement | React$1.RefObject<HTMLElement>
|
|
1036
|
+
eventSource?: HTMLElement | React$1.RefObject<HTMLElement | null>
|
|
1102
1037
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
1103
1038
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
1104
1039
|
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
@@ -1312,6 +1247,7 @@ declare global {
|
|
|
1312
1247
|
| three_webgpu.Euler
|
|
1313
1248
|
| three_webgpu.Quaternion
|
|
1314
1249
|
| { x: number; y?: number; z?: number; w?: number } // Plain objects converted to vectors
|
|
1250
|
+
| { r: number; g: number; b: number; a?: number } // Plain objects converted to Color
|
|
1315
1251
|
| Node // TSL nodes like color(), vec3(), float() for type casting
|
|
1316
1252
|
| UniformNode
|
|
1317
1253
|
|
|
@@ -1357,178 +1293,38 @@ declare module 'three/tsl' {
|
|
|
1357
1293
|
}
|
|
1358
1294
|
|
|
1359
1295
|
/**
|
|
1360
|
-
*
|
|
1296
|
+
* RenderPipeline Types for useRenderPipeline hook (WebGPU only)
|
|
1361
1297
|
*/
|
|
1362
1298
|
|
|
1363
1299
|
|
|
1364
1300
|
|
|
1365
1301
|
declare global {
|
|
1366
|
-
/** Pass record - stores TSL pass nodes for
|
|
1302
|
+
/** Pass record - stores TSL pass nodes for render pipeline */
|
|
1367
1303
|
type PassRecord = Record<string, any>
|
|
1368
1304
|
|
|
1369
1305
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1370
|
-
type
|
|
1306
|
+
type RenderPipelineSetupCallback = (state: RootState) => PassRecord | void
|
|
1371
1307
|
|
|
1372
1308
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1373
|
-
type
|
|
1309
|
+
type RenderPipelineMainCallback = (state: RootState) => PassRecord | void
|
|
1374
1310
|
|
|
1375
|
-
/** Return type for
|
|
1376
|
-
interface
|
|
1311
|
+
/** Return type for useRenderPipeline hook */
|
|
1312
|
+
interface UseRenderPipelineReturn {
|
|
1377
1313
|
/** Current passes from state */
|
|
1378
1314
|
passes: PassRecord
|
|
1379
|
-
/**
|
|
1380
|
-
|
|
1315
|
+
/** RenderPipeline instance (null if not initialized) */
|
|
1316
|
+
renderPipeline: any | null // THREE.PostProcessing (will be THREE.RenderPipeline in future Three.js release)
|
|
1381
1317
|
/** Clear all passes from state */
|
|
1382
1318
|
clearPasses: () => void
|
|
1383
|
-
/** Reset
|
|
1319
|
+
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1384
1320
|
reset: () => void
|
|
1385
1321
|
/** Re-run setup/main callbacks with current closure values */
|
|
1386
1322
|
rebuild: () => void
|
|
1387
|
-
/** True when
|
|
1323
|
+
/** True when RenderPipeline is configured and ready */
|
|
1388
1324
|
isReady: boolean
|
|
1389
1325
|
}
|
|
1390
1326
|
}
|
|
1391
1327
|
|
|
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
|
-
|
|
1459
|
-
/**
|
|
1460
|
-
* Internal frame loop state
|
|
1461
|
-
*/
|
|
1462
|
-
interface FrameLoopState {
|
|
1463
|
-
/** Whether the loop is running */
|
|
1464
|
-
running: boolean
|
|
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
|
|
1528
|
-
*/
|
|
1529
|
-
type DefaultPhase = 'start' | 'input' | 'physics' | 'update' | 'render' | 'finish'
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
1328
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
1533
1329
|
|
|
1534
1330
|
interface MathRepresentation {
|
|
@@ -2004,6 +1800,8 @@ declare function Environment(props: EnvironmentProps): react_jsx_runtime.JSX.Ele
|
|
|
2004
1800
|
declare function removeInteractivity(store: RootStore, object: Object3D): void;
|
|
2005
1801
|
declare function createEvents(store: RootStore): {
|
|
2006
1802
|
handlePointer: (name: string) => (event: DomEvent) => void;
|
|
1803
|
+
flushDeferredPointers: () => void;
|
|
1804
|
+
processDeferredPointer: (event: DomEvent, pointerId: number) => void;
|
|
2007
1805
|
};
|
|
2008
1806
|
/** Default R3F event manager for web */
|
|
2009
1807
|
declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
|
|
@@ -2026,376 +1824,14 @@ declare namespace useLoader {
|
|
|
2026
1824
|
var loader: typeof getLoader;
|
|
2027
1825
|
}
|
|
2028
1826
|
|
|
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
1827
|
/**
|
|
2393
1828
|
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
2394
1829
|
*
|
|
2395
|
-
*
|
|
2396
|
-
* - Inside Canvas: Full RootState (
|
|
2397
|
-
* - Outside Canvas
|
|
2398
|
-
*
|
|
1830
|
+
* Always delivers full RootState — works both inside and outside Canvas context:
|
|
1831
|
+
* - Inside Canvas: Full RootState (renderer, scene, camera, etc.)
|
|
1832
|
+
* - Outside Canvas: The job registers immediately but the callback is held until a
|
|
1833
|
+
* Canvas adopts it, then runs with full RootState. For hostless / standalone
|
|
1834
|
+
* frame loops with no Canvas, use `@pmndrs/scheduler` directly.
|
|
2399
1835
|
*
|
|
2400
1836
|
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
2401
1837
|
*
|
|
@@ -2412,16 +1848,16 @@ declare const getScheduler: () => Scheduler;
|
|
|
2412
1848
|
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
2413
1849
|
*
|
|
2414
1850
|
* @example
|
|
2415
|
-
* // Outside Canvas - waits for Canvas
|
|
1851
|
+
* // Outside Canvas - callback waits for a Canvas, then always has full state
|
|
2416
1852
|
* function UI() {
|
|
2417
1853
|
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
2418
1854
|
* return <button>...</button>;
|
|
2419
1855
|
* }
|
|
2420
1856
|
*
|
|
2421
1857
|
* @example
|
|
2422
|
-
* //
|
|
2423
|
-
* getScheduler
|
|
2424
|
-
*
|
|
1858
|
+
* // Hostless / standalone loop (no Canvas) - use @pmndrs/scheduler directly
|
|
1859
|
+
* import { getScheduler } from '@pmndrs/scheduler'
|
|
1860
|
+
* getScheduler().register((state, delta) => { updateGame(delta) })
|
|
2425
1861
|
*
|
|
2426
1862
|
* @example
|
|
2427
1863
|
* // Scheduler-only access (no callback)
|
|
@@ -2444,11 +1880,16 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
|
|
|
2444
1880
|
/** Callback when texture(s) finish loading */
|
|
2445
1881
|
onLoad?: (texture: MappedTextureType<Url>) => void;
|
|
2446
1882
|
/**
|
|
2447
|
-
*
|
|
2448
|
-
* When true:
|
|
1883
|
+
* Register the texture(s) in R3F's global texture registry for access via useTextures().
|
|
1884
|
+
* When true (the default):
|
|
2449
1885
|
* - Textures persist until explicitly disposed
|
|
2450
|
-
* -
|
|
2451
|
-
*
|
|
1886
|
+
* - On mount, returns existing registered textures if available (preserving modifications like colorSpace)
|
|
1887
|
+
*
|
|
1888
|
+
* Reads are taken once at mount — a mounted `useTexture` does not re-render when the registry
|
|
1889
|
+
* changes. To react to registry swaps, use `useTextures(s => s.get(key))` instead.
|
|
1890
|
+
*
|
|
1891
|
+
* Pass `false` to opt out of registry enrollment entirely.
|
|
1892
|
+
* @default true
|
|
2452
1893
|
*/
|
|
2453
1894
|
cache?: boolean;
|
|
2454
1895
|
};
|
|
@@ -2472,15 +1913,18 @@ type UseTextureOptions<Url extends string[] | string | Record<string, string>> =
|
|
|
2472
1913
|
* normal: '/normal.png'
|
|
2473
1914
|
* })
|
|
2474
1915
|
*
|
|
2475
|
-
* //
|
|
2476
|
-
* //
|
|
2477
|
-
* const diffuse = useTexture('/diffuse.png'
|
|
1916
|
+
* // Textures are registered in the global registry by default — the same texture
|
|
1917
|
+
* // object is shared across components and modifications (colorSpace, wrapS, etc.) are preserved
|
|
1918
|
+
* const diffuse = useTexture('/diffuse.png')
|
|
2478
1919
|
* diffuse.colorSpace = THREE.SRGBColorSpace
|
|
2479
1920
|
*
|
|
2480
1921
|
* // Another component gets the SAME texture with colorSpace already set
|
|
2481
|
-
* const sameDiffuse = useTexture('/diffuse.png'
|
|
1922
|
+
* const sameDiffuse = useTexture('/diffuse.png')
|
|
2482
1923
|
*
|
|
2483
|
-
* //
|
|
1924
|
+
* // Opt out of registry enrollment for a one-off texture
|
|
1925
|
+
* const scratch = useTexture('/scratch.png', { cache: false })
|
|
1926
|
+
*
|
|
1927
|
+
* // Access the registry directly
|
|
2484
1928
|
* const { get } = useTextures()
|
|
2485
1929
|
* const cached = get('/diffuse.png')
|
|
2486
1930
|
* ```
|
|
@@ -2497,63 +1941,80 @@ declare const Texture: ({ children, input, onLoad, cache, }: {
|
|
|
2497
1941
|
cache?: boolean;
|
|
2498
1942
|
}) => react_jsx_runtime.JSX.Element;
|
|
2499
1943
|
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
1944
|
+
/** Accepted shapes for a registry read: a single key, a list of keys, or a name→key map. */
|
|
1945
|
+
type TextureInput = string | string[] | Record<string, string>;
|
|
1946
|
+
/** Result of a `get()` read, mirroring the input shape. */
|
|
1947
|
+
type TextureResult<Input extends TextureInput> = Input extends string ? Texture$1 | undefined : Input extends string[] ? (Texture$1 | undefined)[] : {
|
|
1948
|
+
[K in keyof Input]: Texture$1 | undefined;
|
|
2503
1949
|
};
|
|
1950
|
+
/** Options for `dispose()`. */
|
|
1951
|
+
interface DisposeOptions {
|
|
1952
|
+
/** Dispose even if the texture still has active references (default false). */
|
|
1953
|
+
force?: boolean;
|
|
1954
|
+
}
|
|
2504
1955
|
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
|
-
|
|
1956
|
+
/** The live registry Map (key → Texture). Treat as read-only. */
|
|
1957
|
+
readonly all: Map<string, Texture$1>;
|
|
1958
|
+
/** Read one texture, an array of textures, or a name→texture record (mirrors the input shape). */
|
|
1959
|
+
get<Input extends TextureInput>(input: Input): TextureResult<Input>;
|
|
1960
|
+
/** Check whether a key exists in the registry. */
|
|
1961
|
+
has(key: string): boolean;
|
|
1962
|
+
/**
|
|
1963
|
+
* Register a texture (or a record of textures) that has no URL — e.g. a render
|
|
1964
|
+
* target or procedural texture. URL-loaded textures are registered automatically
|
|
1965
|
+
* by `useTexture` (registry enrollment is on by default).
|
|
1966
|
+
*/
|
|
1967
|
+
add(key: string, texture: Texture$1): void;
|
|
1968
|
+
add(record: Record<string, Texture$1>): void;
|
|
1969
|
+
/**
|
|
1970
|
+
* Dispose a texture's GPU resources and remove it from the registry.
|
|
1971
|
+
* Refcount-aware: if the key is still in use by a mounted `useTexture` consumer it is
|
|
1972
|
+
* skipped (with a warning) unless `{ force: true }` is passed.
|
|
1973
|
+
* @returns true if disposed, false if skipped.
|
|
1974
|
+
*/
|
|
1975
|
+
dispose(key: string, options?: DisposeOptions): boolean;
|
|
1976
|
+
/** Dispose every texture in the registry and clear it. Use on scene teardown. */
|
|
1977
|
+
disposeAll(): void;
|
|
2525
1978
|
}
|
|
2526
1979
|
/**
|
|
2527
|
-
*
|
|
1980
|
+
* Reactive Texture registry — load once with `useTexture`, reach the textures from anywhere.
|
|
1981
|
+
*
|
|
1982
|
+
* This is a registry of plain `Texture` objects (not TSL nodes), so the same texture can feed
|
|
1983
|
+
* a material map, a heightmap sampler, or anything else. It does **not** load — pair it with
|
|
1984
|
+
* `useTexture` for loading (registry enrollment is on by default); `useTextures` is for access and lifecycle.
|
|
2528
1985
|
*
|
|
2529
|
-
*
|
|
2530
|
-
*
|
|
1986
|
+
* The returned handle is **reactive**: the calling component re-renders when the registry
|
|
1987
|
+
* changes. Pass a selector to scope the subscription to a single read.
|
|
2531
1988
|
*
|
|
2532
1989
|
* @example
|
|
2533
1990
|
* ```tsx
|
|
2534
|
-
*
|
|
2535
|
-
*
|
|
2536
|
-
* // Check if texture is already cached
|
|
2537
|
-
* if (!has('/textures/diffuse.png')) {
|
|
2538
|
-
* // Load with useTexture and cache: true, or manually add
|
|
2539
|
-
* const tex = useTexture('/textures/diffuse.png', { cache: true })
|
|
2540
|
-
* }
|
|
1991
|
+
* // Load + register once (anywhere in the tree) — registered by default
|
|
1992
|
+
* useTexture({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
|
|
2541
1993
|
*
|
|
2542
|
-
* //
|
|
2543
|
-
* const
|
|
2544
|
-
*
|
|
1994
|
+
* // Reach them from another component — record form lands straight into a material
|
|
1995
|
+
* const { map, normalMap } = useTextures().get({ map: '/diffuse.jpg', normalMap: '/normal.jpg' })
|
|
1996
|
+
* return <meshStandardMaterial map={map} normalMap={normalMap} />
|
|
2545
1997
|
*
|
|
2546
|
-
* //
|
|
2547
|
-
*
|
|
1998
|
+
* // A set of heightmaps at once
|
|
1999
|
+
* const [a, b, c] = useTextures().get(['/h0.png', '/h1.png', '/h2.png'])
|
|
2548
2000
|
*
|
|
2549
|
-
* //
|
|
2550
|
-
*
|
|
2001
|
+
* // Register a non-URL texture (render target / procedural)
|
|
2002
|
+
* useTextures().add('rt-main', renderTarget.texture)
|
|
2551
2003
|
*
|
|
2552
|
-
* //
|
|
2553
|
-
*
|
|
2004
|
+
* // Deliberate GPU cleanup (refcount-aware; force to override)
|
|
2005
|
+
* useTextures().dispose('/diffuse.jpg')
|
|
2006
|
+
* useTextures().disposeAll() // scene teardown
|
|
2554
2007
|
* ```
|
|
2008
|
+
*
|
|
2009
|
+
* @remarks
|
|
2010
|
+
* **Future expansion:** an imperative async loader (e.g. `await useTextures().load('/x.jpg')`) is
|
|
2011
|
+
* intentionally not included yet. It would let non-React code (loading screens, dynamic streaming)
|
|
2012
|
+
* populate the registry without Suspense, at the cost of putting loading back into this hook. It
|
|
2013
|
+
* will be added only if a concrete consumer needs imperative loading; for now, loading lives in
|
|
2014
|
+
* `useTexture`.
|
|
2555
2015
|
*/
|
|
2556
2016
|
declare function useTextures(): UseTexturesReturn;
|
|
2017
|
+
declare function useTextures<T>(selector: (registry: UseTexturesReturn) => T): T;
|
|
2557
2018
|
|
|
2558
2019
|
/**
|
|
2559
2020
|
* Creates a render target compatible with the current renderer.
|
|
@@ -2583,9 +2044,9 @@ declare function useTextures(): UseTexturesReturn;
|
|
|
2583
2044
|
* const fbo = useRenderTarget(512, 256, { samples: 4 })
|
|
2584
2045
|
* ```
|
|
2585
2046
|
*/
|
|
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
|
|
2047
|
+
declare function useRenderTarget(options?: RenderTargetOptions): RenderTarget;
|
|
2048
|
+
declare function useRenderTarget(size: number, options?: RenderTargetOptions): RenderTarget;
|
|
2049
|
+
declare function useRenderTarget(width: number, height: number, options?: RenderTargetOptions): RenderTarget;
|
|
2589
2050
|
|
|
2590
2051
|
/**
|
|
2591
2052
|
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
@@ -4249,5 +3710,5 @@ declare function isOnce(value: unknown): value is {
|
|
|
4249
3710
|
*/
|
|
4250
3711
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
4251
3712
|
|
|
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,
|
|
3713
|
+
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, act, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3714
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeProps, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|