@react-three/fiber 10.0.0-alpha.0 → 10.0.0-alpha.2
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 +613 -146
- package/dist/index.d.cts +230 -43
- package/dist/index.d.mts +230 -43
- package/dist/index.d.ts +230 -43
- package/dist/index.mjs +613 -149
- package/dist/legacy.cjs +607 -144
- package/dist/legacy.d.cts +231 -42
- package/dist/legacy.d.mts +231 -42
- package/dist/legacy.d.ts +231 -42
- package/dist/legacy.mjs +606 -146
- package/dist/webgpu/index.cjs +925 -251
- package/dist/webgpu/index.d.cts +361 -60
- package/dist/webgpu/index.d.mts +361 -60
- package/dist/webgpu/index.d.ts +361 -60
- package/dist/webgpu/index.mjs +921 -253
- package/package.json +5 -5
- package/react-reconciler/constants.js +1 -9
- package/react-reconciler/index.js +4 -20
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as three_webgpu from 'three/webgpu';
|
|
2
|
-
import { Node, ShaderNodeObject, Euler as Euler$1, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Quaternion as Quaternion$1, Matrix3 as Matrix3$1, Matrix4 as Matrix4$1, Object3D, Texture as Texture$1, OrthographicCamera } from 'three/webgpu';
|
|
2
|
+
import { RenderTarget, Node, ShaderNodeObject, Euler as Euler$1, Color as Color$2, ColorRepresentation as ColorRepresentation$1, Layers as Layers$1, Raycaster, Intersection as Intersection$1, Vector2 as Vector2$1, Vector3 as Vector3$1, Vector4 as Vector4$1, Quaternion as Quaternion$1, Matrix3 as Matrix3$1, Matrix4 as Matrix4$1, Object3D, Texture as Texture$1, Frustum, OrthographicCamera } from 'three/webgpu';
|
|
3
3
|
import * as THREE$1 from 'three';
|
|
4
|
-
import { WebGLRenderer, Color as Color$1, ColorRepresentation } from 'three';
|
|
4
|
+
import { WebGLRenderTarget, WebGLRenderer, Color as Color$1, ColorRepresentation, RenderTargetOptions as RenderTargetOptions$1 } from 'three';
|
|
5
5
|
import { WebGLRendererParameters } from 'three/src/renderers/WebGLRenderer.js';
|
|
6
6
|
import { Inspector } from 'three/addons/inspector/Inspector.js';
|
|
7
7
|
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 * as react_reconciler from 'C:\\dev\\react-three-fiber\\node_modules\\.pnpm\\@types+react-reconciler@0.32.3_@types+react@19.2.7\\node_modules\\@types\\react-reconciler\\index.d.ts';
|
|
12
11
|
import { Options } from 'react-use-measure';
|
|
13
12
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
14
13
|
|
|
@@ -50,6 +49,8 @@ var THREE = /*#__PURE__*/_mergeNamespaces({
|
|
|
50
49
|
Inspector: Inspector,
|
|
51
50
|
R3F_BUILD_LEGACY: R3F_BUILD_LEGACY,
|
|
52
51
|
R3F_BUILD_WEBGPU: R3F_BUILD_WEBGPU,
|
|
52
|
+
RenderTargetCompat: RenderTarget,
|
|
53
|
+
WebGLRenderTarget: WebGLRenderTarget,
|
|
53
54
|
WebGLRenderer: WebGLRenderer,
|
|
54
55
|
WebGLRendererParameters: WebGLRendererParameters
|
|
55
56
|
}, [three_webgpu]);
|
|
@@ -189,6 +190,14 @@ interface EventHandlers {
|
|
|
189
190
|
onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void
|
|
190
191
|
onWheel?: (event: ThreeEvent<WheelEvent>) => void
|
|
191
192
|
onLostPointerCapture?: (event: ThreeEvent<PointerEvent>) => void
|
|
193
|
+
|
|
194
|
+
//* Visibility Events --------------------------------
|
|
195
|
+
/** Fires when object enters/exits camera frustum. Receives true when in view, false when out. */
|
|
196
|
+
onFramed?: (inView: boolean) => void
|
|
197
|
+
/** Fires when object occlusion state changes (WebGPU only, requires occlusionTest=true on object) */
|
|
198
|
+
onOccluded?: (occluded: boolean) => void
|
|
199
|
+
/** Fires when combined visibility changes (frustum + occlusion + visible prop) */
|
|
200
|
+
onVisible?: (visible: boolean) => void
|
|
192
201
|
}
|
|
193
202
|
|
|
194
203
|
type FilterFunction = (items: THREE$1.Intersection[], state: RootState) => THREE$1.Intersection[]
|
|
@@ -220,6 +229,17 @@ interface EventManager<TTarget> {
|
|
|
220
229
|
interface PointerCaptureTarget {
|
|
221
230
|
intersection: Intersection
|
|
222
231
|
target: Element
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
//* Visibility System Types =====================================
|
|
235
|
+
|
|
236
|
+
/** Entry in the visibility registry for tracking object visibility state */
|
|
237
|
+
interface VisibilityEntry {
|
|
238
|
+
object: THREE$1.Object3D
|
|
239
|
+
handlers: Pick<EventHandlers, 'onFramed' | 'onOccluded' | 'onVisible'>
|
|
240
|
+
lastFramedState: boolean | null
|
|
241
|
+
lastOccludedState: boolean | null
|
|
242
|
+
lastVisibleState: boolean | null
|
|
223
243
|
}
|
|
224
244
|
|
|
225
245
|
//* Scheduler Types (useFrame) ==============================
|
|
@@ -266,9 +286,9 @@ interface AddPhaseOptions {
|
|
|
266
286
|
// Frame State --------------------------------
|
|
267
287
|
|
|
268
288
|
/**
|
|
269
|
-
*
|
|
289
|
+
* Timing-only state for independent/outside mode (no RootState)
|
|
270
290
|
*/
|
|
271
|
-
interface
|
|
291
|
+
interface FrameTimingState {
|
|
272
292
|
/** High-resolution timestamp from RAF (ms) */
|
|
273
293
|
time: number
|
|
274
294
|
/** Time since last frame in seconds (for legacy compatibility with THREE.Clock) */
|
|
@@ -279,9 +299,26 @@ interface FrameNextState extends RootState {
|
|
|
279
299
|
frame: number
|
|
280
300
|
}
|
|
281
301
|
|
|
302
|
+
/**
|
|
303
|
+
* State passed to useFrame callbacks (extends RootState with timing)
|
|
304
|
+
*/
|
|
305
|
+
interface FrameNextState extends RootState, FrameTimingState {}
|
|
306
|
+
|
|
282
307
|
/** Alias for FrameNextState */
|
|
283
308
|
type FrameState = FrameNextState
|
|
284
309
|
|
|
310
|
+
// Root Options --------------------------------
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Options for registerRoot
|
|
314
|
+
*/
|
|
315
|
+
interface RootOptions {
|
|
316
|
+
/** State provider for callbacks. Optional in independent mode. */
|
|
317
|
+
getState?: () => any
|
|
318
|
+
/** Error handler for job errors. Falls back to console.error if not provided. */
|
|
319
|
+
onError?: (error: Error) => void
|
|
320
|
+
}
|
|
321
|
+
|
|
285
322
|
// Callback Types --------------------------------
|
|
286
323
|
|
|
287
324
|
/**
|
|
@@ -335,13 +372,17 @@ interface SchedulerApi {
|
|
|
335
372
|
//* Root Management --------------------------------
|
|
336
373
|
|
|
337
374
|
/** Register a root (Canvas) with the scheduler. Returns unsubscribe function. */
|
|
338
|
-
registerRoot(id: string,
|
|
375
|
+
registerRoot(id: string, options?: RootOptions): () => void
|
|
339
376
|
/** Unregister a root */
|
|
340
377
|
unregisterRoot(id: string): void
|
|
341
378
|
/** Generate a unique root ID */
|
|
342
379
|
generateRootId(): string
|
|
343
380
|
/** Get the number of registered roots */
|
|
344
381
|
getRootCount(): number
|
|
382
|
+
/** Check if any root is registered and ready */
|
|
383
|
+
readonly isReady: boolean
|
|
384
|
+
/** Subscribe to root-ready event. Fires immediately if already ready. Returns unsubscribe. */
|
|
385
|
+
onRootReady(callback: () => void): () => void
|
|
345
386
|
|
|
346
387
|
//* Job Registration --------------------------------
|
|
347
388
|
|
|
@@ -400,6 +441,8 @@ interface SchedulerApi {
|
|
|
400
441
|
readonly isRunning: boolean
|
|
401
442
|
/** Get/set the frameloop mode ('always', 'demand', 'never') */
|
|
402
443
|
frameloop: Frameloop
|
|
444
|
+
/** Independent mode - runs without Canvas, callbacks receive timing-only state */
|
|
445
|
+
independent: boolean
|
|
403
446
|
|
|
404
447
|
//* Manual Stepping --------------------------------
|
|
405
448
|
|
|
@@ -477,6 +520,16 @@ interface InternalState {
|
|
|
477
520
|
initialClick: [x: number, y: number]
|
|
478
521
|
initialHits: THREE$1.Object3D[]
|
|
479
522
|
lastEvent: React$1.RefObject<DomEvent | null>
|
|
523
|
+
/** Visibility event registry (onFramed, onOccluded, onVisible) */
|
|
524
|
+
visibilityRegistry: Map<string, VisibilityEntry>
|
|
525
|
+
/** Whether occlusion queries are enabled (WebGPU only) */
|
|
526
|
+
occlusionEnabled: boolean
|
|
527
|
+
/** Reference to the invisible occlusion observer mesh */
|
|
528
|
+
occlusionObserver: THREE$1.Mesh | null
|
|
529
|
+
/** Cached occlusion results from render pass - keyed by Object3D */
|
|
530
|
+
occlusionCache: Map<THREE$1.Object3D, boolean | null>
|
|
531
|
+
/** Internal helper group for R3F system objects (occlusion observer, etc.) */
|
|
532
|
+
helperGroup: THREE$1.Group | null
|
|
480
533
|
active: boolean
|
|
481
534
|
priority: number
|
|
482
535
|
frames: number
|
|
@@ -514,6 +567,10 @@ interface RootState {
|
|
|
514
567
|
|
|
515
568
|
/** Default camera */
|
|
516
569
|
camera: ThreeCamera
|
|
570
|
+
/** Camera frustum for visibility checks - auto-updated each frame when autoUpdateFrustum is true */
|
|
571
|
+
frustum: THREE$1.Frustum
|
|
572
|
+
/** Whether to automatically update the frustum each frame (default: true) */
|
|
573
|
+
autoUpdateFrustum: boolean
|
|
517
574
|
/** Default scene (may be overridden in portals to point to the portal container) */
|
|
518
575
|
scene: THREE$1.Scene
|
|
519
576
|
/** The actual root THREE.Scene - always points to the true scene, even inside portals */
|
|
@@ -557,8 +614,8 @@ interface RootState {
|
|
|
557
614
|
advance: (timestamp: number, runGlobalEffects?: boolean) => void
|
|
558
615
|
/** Shortcut to setting the event layer */
|
|
559
616
|
setEvents: (events: Partial<EventManager<any>>) => void
|
|
560
|
-
/** Shortcut to manual sizing */
|
|
561
|
-
setSize: (width
|
|
617
|
+
/** Shortcut to manual sizing. No args resets to props/container. Single arg creates square. */
|
|
618
|
+
setSize: (width?: number, height?: number, top?: number, left?: number) => void
|
|
562
619
|
/** Shortcut to manual setting the pixel ratio */
|
|
563
620
|
setDpr: (dpr: Dpr) => void
|
|
564
621
|
/** Shortcut to setting frameloop flags */
|
|
@@ -577,6 +634,12 @@ interface RootState {
|
|
|
577
634
|
postProcessing: any | null // THREE.PostProcessing when available
|
|
578
635
|
/** Global TSL pass nodes for post-processing - use usePostProcessing() hook */
|
|
579
636
|
passes: Record<string, any>
|
|
637
|
+
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
638
|
+
_hmrVersion: number
|
|
639
|
+
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
640
|
+
_sizeImperative: boolean
|
|
641
|
+
/** Internal: stored size props from Canvas for reset functionality */
|
|
642
|
+
_sizeProps: { width?: number; height?: number } | null
|
|
580
643
|
/** When the canvas was clicked but nothing was hit */
|
|
581
644
|
onPointerMissed?: (event: MouseEvent) => void
|
|
582
645
|
/** When a dragover event has missed any target */
|
|
@@ -715,6 +778,16 @@ interface RenderProps<TCanvas extends HTMLCanvasElement | OffscreenCanvas$1> {
|
|
|
715
778
|
onDragOverMissed?: (event: DragEvent) => void
|
|
716
779
|
/** Response for drop events that have missed any target */
|
|
717
780
|
onDropMissed?: (event: DragEvent) => void
|
|
781
|
+
/** Whether to automatically update the frustum each frame (default: true) */
|
|
782
|
+
autoUpdateFrustum?: boolean
|
|
783
|
+
/**
|
|
784
|
+
* Enable WebGPU occlusion queries for onOccluded/onVisible events.
|
|
785
|
+
* Auto-enabled when any object uses onOccluded or onVisible handlers.
|
|
786
|
+
* Only works with WebGPU renderer - WebGL will log a warning.
|
|
787
|
+
*/
|
|
788
|
+
occlusion?: boolean
|
|
789
|
+
/** Internal: stored size props from Canvas for reset functionality */
|
|
790
|
+
_sizeProps?: { width?: number; height?: number } | null
|
|
718
791
|
}
|
|
719
792
|
|
|
720
793
|
//* Reconciler Root ==============================
|
|
@@ -746,8 +819,12 @@ type InjectState = Partial<
|
|
|
746
819
|
|
|
747
820
|
//* Reconciler Types ==============================
|
|
748
821
|
|
|
822
|
+
// FiberRoot is an opaque internal React type - we define it locally
|
|
823
|
+
// to avoid bundling @types/react-reconciler which causes absolute path issues
|
|
824
|
+
type FiberRoot = any
|
|
825
|
+
|
|
749
826
|
interface Root {
|
|
750
|
-
fiber:
|
|
827
|
+
fiber: FiberRoot
|
|
751
828
|
store: RootStore
|
|
752
829
|
}
|
|
753
830
|
|
|
@@ -825,8 +902,7 @@ type GlobalEffectType = 'before' | 'after' | 'tail'
|
|
|
825
902
|
//* Canvas Types ==============================
|
|
826
903
|
|
|
827
904
|
interface CanvasProps
|
|
828
|
-
extends Omit<RenderProps<HTMLCanvasElement>, 'size'>,
|
|
829
|
-
React$1.HTMLAttributes<HTMLDivElement> {
|
|
905
|
+
extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React$1.HTMLAttributes<HTMLDivElement> {
|
|
830
906
|
children?: React$1.ReactNode
|
|
831
907
|
ref?: React$1.Ref<HTMLCanvasElement>
|
|
832
908
|
/** Canvas fallback content, similar to img's alt prop */
|
|
@@ -840,6 +916,12 @@ interface CanvasProps
|
|
|
840
916
|
eventSource?: HTMLElement | React$1.RefObject<HTMLElement>
|
|
841
917
|
/** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
|
|
842
918
|
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen'
|
|
919
|
+
/** Enable/disable automatic HMR refresh for TSL nodes and uniforms, default: true in dev */
|
|
920
|
+
hmr?: boolean
|
|
921
|
+
/** Canvas resolution width in pixels. If omitted, uses container width. */
|
|
922
|
+
width?: number
|
|
923
|
+
/** Canvas resolution height in pixels. If omitted, uses container height. */
|
|
924
|
+
height?: number
|
|
843
925
|
}
|
|
844
926
|
|
|
845
927
|
//* Loader Types ==============================
|
|
@@ -868,20 +950,15 @@ type InferLoadResult<T> = T extends {
|
|
|
868
950
|
}
|
|
869
951
|
? R
|
|
870
952
|
: T extends ConstructorRepresentation<any>
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
953
|
+
? InstanceType<T> extends {
|
|
954
|
+
load(url: any, onLoad?: (result: infer R) => void, ...args: any[]): any
|
|
955
|
+
}
|
|
956
|
+
? R
|
|
957
|
+
: any
|
|
875
958
|
: any
|
|
876
|
-
: any
|
|
877
959
|
|
|
878
|
-
type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
|
|
879
|
-
LoaderInstance<T
|
|
880
|
-
> extends infer R
|
|
881
|
-
? R extends GLTFLike
|
|
882
|
-
? R & ObjectMap
|
|
883
|
-
: R
|
|
884
|
-
: never
|
|
960
|
+
type LoaderResult<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> =
|
|
961
|
+
InferLoadResult<LoaderInstance<T>> extends infer R ? (R extends GLTFLike ? R & ObjectMap : R) : never
|
|
885
962
|
|
|
886
963
|
type Extensions<T extends LoaderLike | ConstructorRepresentation<LoaderLike>> = (
|
|
887
964
|
loader: LoaderInstance<T>,
|
|
@@ -897,6 +974,11 @@ interface WebGLShadowConfig {
|
|
|
897
974
|
shadows?: boolean | 'basic' | 'percentage' | 'soft' | 'variance' | Partial<THREE$1.WebGLShadowMap>
|
|
898
975
|
}
|
|
899
976
|
|
|
977
|
+
//* RenderTarget Types ==============================
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
type RenderTargetOptions = RenderTargetOptions$1
|
|
981
|
+
|
|
900
982
|
//* Global Types ==============================
|
|
901
983
|
|
|
902
984
|
declare global {
|
|
@@ -915,6 +997,15 @@ declare global {
|
|
|
915
997
|
*/
|
|
916
998
|
type UniformStore = Record<string, UniformNode | UniformRecord>
|
|
917
999
|
|
|
1000
|
+
/**
|
|
1001
|
+
* Helper to safely access a uniform node from the store.
|
|
1002
|
+
* Use this when accessing state.uniforms to get proper typing.
|
|
1003
|
+
* @example
|
|
1004
|
+
* const uTime = uniforms.uTime as UniformNode<number>
|
|
1005
|
+
* const uColor = uniforms.uColor as UniformNode<import('three/webgpu').Color>
|
|
1006
|
+
*/
|
|
1007
|
+
type GetUniform<T = unknown> = UniformNode<T>
|
|
1008
|
+
|
|
918
1009
|
/**
|
|
919
1010
|
* Acceptable input values for useUniforms - raw values that get converted to UniformNodes
|
|
920
1011
|
* Supports: primitives, Three.js types, plain objects (converted to vectors), and UniformNodes
|
|
@@ -1013,6 +1104,10 @@ declare global {
|
|
|
1013
1104
|
}
|
|
1014
1105
|
}
|
|
1015
1106
|
|
|
1107
|
+
//* useFrameNext Types ==============================
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
|
|
1016
1111
|
//* Global Type Declarations ==============================
|
|
1017
1112
|
|
|
1018
1113
|
declare global {
|
|
@@ -1104,8 +1199,8 @@ declare global {
|
|
|
1104
1199
|
interface RootEntry {
|
|
1105
1200
|
/** Unique identifier for this root */
|
|
1106
1201
|
id: string
|
|
1107
|
-
/** Function to get the root's current state */
|
|
1108
|
-
getState: () =>
|
|
1202
|
+
/** Function to get the root's current state. Returns any to support independent mode. */
|
|
1203
|
+
getState: () => any
|
|
1109
1204
|
/** Map of job IDs to Job objects */
|
|
1110
1205
|
jobs: Map<string, Job>
|
|
1111
1206
|
/** Cached sorted job list for execution order */
|
|
@@ -1162,8 +1257,8 @@ type MathTypes = MathRepresentation | Euler$1 | Color$2
|
|
|
1162
1257
|
type MathType<T extends MathTypes> = T extends Color$2
|
|
1163
1258
|
? Args<typeof Color$2> | ColorRepresentation$1
|
|
1164
1259
|
: T extends VectorRepresentation | Layers$1 | Euler$1
|
|
1165
|
-
|
|
1166
|
-
|
|
1260
|
+
? T | MutableOrReadonlyParameters<T['set']> | number
|
|
1261
|
+
: T | MutableOrReadonlyParameters<T['set']>
|
|
1167
1262
|
|
|
1168
1263
|
type MathProps<P> = {
|
|
1169
1264
|
[K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never
|
|
@@ -1297,7 +1392,9 @@ declare namespace useLoader {
|
|
|
1297
1392
|
* - Demand mode support via invalidate()
|
|
1298
1393
|
*/
|
|
1299
1394
|
declare class Scheduler {
|
|
1300
|
-
private static
|
|
1395
|
+
private static readonly INSTANCE_KEY;
|
|
1396
|
+
private static get instance();
|
|
1397
|
+
private static set instance(value);
|
|
1301
1398
|
/**
|
|
1302
1399
|
* Get the global scheduler instance (creates if doesn't exist).
|
|
1303
1400
|
* Uses HMR data to preserve instance across hot reloads.
|
|
@@ -1323,19 +1420,25 @@ declare class Scheduler {
|
|
|
1323
1420
|
private jobStateListeners;
|
|
1324
1421
|
private pendingFrames;
|
|
1325
1422
|
private _frameloop;
|
|
1423
|
+
private _independent;
|
|
1424
|
+
private errorHandler;
|
|
1425
|
+
private rootReadyCallbacks;
|
|
1326
1426
|
get phases(): string[];
|
|
1327
1427
|
get frameloop(): Frameloop;
|
|
1328
1428
|
set frameloop(mode: Frameloop);
|
|
1329
1429
|
get isRunning(): boolean;
|
|
1430
|
+
get isReady(): boolean;
|
|
1431
|
+
get independent(): boolean;
|
|
1432
|
+
set independent(value: boolean);
|
|
1330
1433
|
constructor();
|
|
1331
1434
|
/**
|
|
1332
1435
|
* Register a root (Canvas) with the scheduler.
|
|
1333
1436
|
* The first root to register starts the RAF loop (if frameloop='always').
|
|
1334
1437
|
* @param {string} id - Unique identifier for this root
|
|
1335
|
-
* @param {
|
|
1438
|
+
* @param {RootOptions} [options] - Optional configuration with getState and onError callbacks
|
|
1336
1439
|
* @returns {() => void} Unsubscribe function to remove this root
|
|
1337
1440
|
*/
|
|
1338
|
-
registerRoot(id: string,
|
|
1441
|
+
registerRoot(id: string, options?: RootOptions): () => void;
|
|
1339
1442
|
/**
|
|
1340
1443
|
* Unregister a root from the scheduler.
|
|
1341
1444
|
* Cleans up all job state listeners for this root's jobs.
|
|
@@ -1344,6 +1447,34 @@ declare class Scheduler {
|
|
|
1344
1447
|
* @returns {void}
|
|
1345
1448
|
*/
|
|
1346
1449
|
unregisterRoot(id: string): void;
|
|
1450
|
+
/**
|
|
1451
|
+
* Subscribe to be notified when a root becomes available.
|
|
1452
|
+
* Fires immediately if a root already exists.
|
|
1453
|
+
* @param {() => void} callback - Function called when first root registers
|
|
1454
|
+
* @returns {() => void} Unsubscribe function
|
|
1455
|
+
*/
|
|
1456
|
+
onRootReady(callback: () => void): () => void;
|
|
1457
|
+
/**
|
|
1458
|
+
* Notify all registered root-ready callbacks.
|
|
1459
|
+
* Called when the first root registers.
|
|
1460
|
+
* @returns {void}
|
|
1461
|
+
* @private
|
|
1462
|
+
*/
|
|
1463
|
+
private notifyRootReady;
|
|
1464
|
+
/**
|
|
1465
|
+
* Ensure a default root exists for independent mode.
|
|
1466
|
+
* Creates a minimal root with no state provider.
|
|
1467
|
+
* @returns {void}
|
|
1468
|
+
* @private
|
|
1469
|
+
*/
|
|
1470
|
+
private ensureDefaultRoot;
|
|
1471
|
+
/**
|
|
1472
|
+
* Trigger error handling for job errors.
|
|
1473
|
+
* Uses the bound error handler if available, otherwise logs to console.
|
|
1474
|
+
* @param {Error} error - The error to handle
|
|
1475
|
+
* @returns {void}
|
|
1476
|
+
*/
|
|
1477
|
+
triggerError(error: Error): void;
|
|
1347
1478
|
/**
|
|
1348
1479
|
* Add a named phase to the scheduler's execution order.
|
|
1349
1480
|
* Marks all roots for rebuild to incorporate the new phase.
|
|
@@ -1552,7 +1683,7 @@ declare class Scheduler {
|
|
|
1552
1683
|
/**
|
|
1553
1684
|
* Execute all jobs for a single root in sorted order.
|
|
1554
1685
|
* Rebuilds sorted job list if needed, then dispatches each job.
|
|
1555
|
-
* Errors are caught and propagated
|
|
1686
|
+
* Errors are caught and propagated via triggerError.
|
|
1556
1687
|
* @param {RootEntry} root - The root entry to tick
|
|
1557
1688
|
* @param {number} timestamp - RAF timestamp in milliseconds
|
|
1558
1689
|
* @param {number} delta - Time since last frame in seconds
|
|
@@ -1615,6 +1746,11 @@ declare const getScheduler: () => Scheduler;
|
|
|
1615
1746
|
/**
|
|
1616
1747
|
* Frame hook with phase-based ordering, priority, and FPS throttling.
|
|
1617
1748
|
*
|
|
1749
|
+
* Works both inside and outside Canvas context:
|
|
1750
|
+
* - Inside Canvas: Full RootState (gl, scene, camera, etc.)
|
|
1751
|
+
* - Outside Canvas (waiting mode): Waits for Canvas to mount, then gets full state
|
|
1752
|
+
* - Outside Canvas (independent mode): Fires immediately with timing-only state
|
|
1753
|
+
*
|
|
1618
1754
|
* Returns a controls object for manual stepping, pausing, and resuming.
|
|
1619
1755
|
*
|
|
1620
1756
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
@@ -1630,18 +1766,16 @@ declare const getScheduler: () => Scheduler;
|
|
|
1630
1766
|
* useFrame((state, delta) => { ... }, { phase: 'physics' })
|
|
1631
1767
|
*
|
|
1632
1768
|
* @example
|
|
1633
|
-
* //
|
|
1634
|
-
*
|
|
1635
|
-
*
|
|
1636
|
-
*
|
|
1637
|
-
*
|
|
1638
|
-
* controls.resume() // Resume this job
|
|
1769
|
+
* // Outside Canvas - waits for Canvas to mount
|
|
1770
|
+
* function UI() {
|
|
1771
|
+
* useFrame((state, delta) => { syncUI(state.camera) });
|
|
1772
|
+
* return <button>...</button>;
|
|
1773
|
+
* }
|
|
1639
1774
|
*
|
|
1640
1775
|
* @example
|
|
1641
|
-
* //
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
* stepAll() // Advance all useFrame jobs
|
|
1776
|
+
* // Independent mode - no Canvas needed
|
|
1777
|
+
* getScheduler().independent = true;
|
|
1778
|
+
* useFrame((state, delta) => { updateGame(delta) });
|
|
1645
1779
|
*
|
|
1646
1780
|
* @example
|
|
1647
1781
|
* // Scheduler-only access (no callback)
|
|
@@ -1775,6 +1909,39 @@ interface UseTexturesReturn {
|
|
|
1775
1909
|
*/
|
|
1776
1910
|
declare function useTextures(): UseTexturesReturn;
|
|
1777
1911
|
|
|
1912
|
+
/**
|
|
1913
|
+
* Creates a render target compatible with the current renderer.
|
|
1914
|
+
*
|
|
1915
|
+
* - Legacy build: Returns WebGLRenderTarget
|
|
1916
|
+
* - WebGPU build: Returns RenderTarget
|
|
1917
|
+
* - Default build: Returns whichever matches the active renderer
|
|
1918
|
+
*
|
|
1919
|
+
* @param width - Target width (defaults to canvas width)
|
|
1920
|
+
* @param height - Target height (defaults to canvas height)
|
|
1921
|
+
* @param options - Three.js RenderTarget options
|
|
1922
|
+
*
|
|
1923
|
+
* @example
|
|
1924
|
+
* ```tsx
|
|
1925
|
+
* function PortalScene() {
|
|
1926
|
+
* const fbo = useRenderTarget(512, 512, { depthBuffer: true })
|
|
1927
|
+
*
|
|
1928
|
+
* useFrame(({ renderer, scene, camera }) => {
|
|
1929
|
+
* renderer.setRenderTarget(fbo)
|
|
1930
|
+
* renderer.render(scene, camera)
|
|
1931
|
+
* renderer.setRenderTarget(null)
|
|
1932
|
+
* })
|
|
1933
|
+
*
|
|
1934
|
+
* return (
|
|
1935
|
+
* <mesh>
|
|
1936
|
+
* <planeGeometry />
|
|
1937
|
+
* <meshBasicMaterial map={fbo.texture} />
|
|
1938
|
+
* </mesh>
|
|
1939
|
+
* )
|
|
1940
|
+
* }
|
|
1941
|
+
* ```
|
|
1942
|
+
*/
|
|
1943
|
+
declare function useRenderTarget(width?: number, height?: number, options?: RenderTargetOptions): RenderTarget<THREE$1.Texture<unknown>>;
|
|
1944
|
+
|
|
1778
1945
|
/**
|
|
1779
1946
|
* Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
|
|
1780
1947
|
* @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
|
|
@@ -3309,6 +3476,26 @@ declare function getUuidPrefix(uuid: string): string;
|
|
|
3309
3476
|
* @param size - Current viewport size
|
|
3310
3477
|
*/
|
|
3311
3478
|
declare function updateCamera(camera: ThreeCamera, size: Size): void;
|
|
3479
|
+
/**
|
|
3480
|
+
* Updates a frustum from a camera's projection and world matrices.
|
|
3481
|
+
* If no target frustum is provided, creates and returns a new one.
|
|
3482
|
+
*
|
|
3483
|
+
* @param camera - Camera to extract frustum from
|
|
3484
|
+
* @param frustum - Optional existing frustum to update (creates new if not provided)
|
|
3485
|
+
* @returns The updated or newly created frustum
|
|
3486
|
+
*
|
|
3487
|
+
* @example
|
|
3488
|
+
* // Create new frustum
|
|
3489
|
+
* const frustum = updateFrustum(camera)
|
|
3490
|
+
*
|
|
3491
|
+
* // Update existing frustum (no allocation)
|
|
3492
|
+
* updateFrustum(camera, existingFrustum)
|
|
3493
|
+
*
|
|
3494
|
+
* // Use for visibility checks
|
|
3495
|
+
* if (frustum.containsPoint(point)) { ... }
|
|
3496
|
+
* if (frustum.intersectsObject(mesh)) { ... }
|
|
3497
|
+
*/
|
|
3498
|
+
declare function updateFrustum(camera: ThreeCamera, frustum?: Frustum): Frustum;
|
|
3312
3499
|
|
|
3313
3500
|
declare const is: {
|
|
3314
3501
|
obj: (a: any) => boolean;
|
|
@@ -3346,5 +3533,5 @@ declare const hasConstructor: (object: unknown) => object is {
|
|
|
3346
3533
|
*/
|
|
3347
3534
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3348
3535
|
|
|
3349
|
-
export { Block, Canvas, ErrorBoundary, IsObject, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Scheduler, 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, getInstanceProps, getRootState, getScheduler, getUuidPrefix, hasConstructor, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isObject3D, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, prepare, reconciler, removeInteractivity, resolve, unmountComponentAtNode, updateCamera, useBridge, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useStore, useTexture, useTextures, useThree };
|
|
3350
|
-
export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BaseRendererProps, Bridge, Camera, CameraProps, CanvasProps, Catalogue, Color, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DomEvent, Dpr, ElementProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, Properties, Quaternion, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, Renderer, RendererFactory, RendererProps, Root, RootState, RootStore, SchedulerApi, SetBlock, Size, Subscription, TextureEntry, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager };
|
|
3536
|
+
export { Block, Canvas, ErrorBoundary, IsObject, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Scheduler, 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, getInstanceProps, getRootState, getScheduler, getUuidPrefix, hasConstructor, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isObject3D, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, prepare, reconciler, removeInteractivity, resolve, unmountComponentAtNode, updateCamera, updateFrustum, useBridge, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree };
|
|
3537
|
+
export type { Act, AddPhaseOptions, Args, ArgsProp, AttachFnType, AttachType, BaseRendererProps, Bridge, Camera, CameraProps, CanvasProps, Catalogue, Color, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DomEvent, Dpr, ElementProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameControls, FrameNextCallback, FrameNextControls, FrameNextState, FrameState, FrameTimingState, Frameloop, GLProps, GLTFLike, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, Properties, Quaternion, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererFactory, RendererProps, Root, RootOptions, RootState, RootStore, SchedulerApi, SetBlock, Size, Subscription, TextureEntry, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseFrameNextOptions, UseFrameOptions, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager };
|