@react-three/fiber 10.0.0-canary.ac30da2 → 10.0.0-canary.af75fd4
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 +72 -30
- package/dist/index.d.cts +162 -25
- package/dist/index.d.mts +162 -25
- package/dist/index.d.ts +162 -25
- package/dist/index.mjs +72 -30
- package/dist/legacy.cjs +69 -26
- package/dist/legacy.d.cts +162 -25
- package/dist/legacy.d.mts +162 -25
- package/dist/legacy.d.ts +162 -25
- package/dist/legacy.mjs +69 -26
- package/dist/webgpu/index.cjs +92 -43
- package/dist/webgpu/index.d.cts +165 -40
- package/dist/webgpu/index.d.mts +165 -40
- package/dist/webgpu/index.d.ts +165 -40
- package/dist/webgpu/index.mjs +92 -43
- package/package.json +2 -2
package/dist/legacy.d.ts
CHANGED
|
@@ -359,6 +359,33 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
359
359
|
*/
|
|
360
360
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
361
361
|
|
|
362
|
+
//* Node Types (useNodes) ========================================
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Structural shape of a TSL node as stored on `state.nodes`.
|
|
366
|
+
*
|
|
367
|
+
* Deliberately minimal rather than three's nominal `Node`: in @types/three several node classes
|
|
368
|
+
* TSL hands back (OperatorNode, ConstNode, ...) do not extend `Node` cleanly, so a `Node` bound
|
|
369
|
+
* would reject values `useNodes` creators legitimately return. This is the same shape
|
|
370
|
+
* `useNodes` already constrains creators to (`TSLNodeLike`).
|
|
371
|
+
*/
|
|
372
|
+
interface NodeLike {
|
|
373
|
+
uuid?: string
|
|
374
|
+
nodeType?: string | null
|
|
375
|
+
/** label method for chaining - sets the node's label and returns self */
|
|
376
|
+
label?: ((label: string) => NodeLike) | string
|
|
377
|
+
setName?: (name: string) => this
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
381
|
+
type NodeRecord = Record<string, NodeLike>
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
385
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
386
|
+
*/
|
|
387
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
388
|
+
|
|
362
389
|
//* Storage Types (useGPUStorage) ========================================
|
|
363
390
|
|
|
364
391
|
/**
|
|
@@ -492,8 +519,13 @@ interface InternalState {
|
|
|
492
519
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
493
520
|
container?: THREE$1.Object3D
|
|
494
521
|
/**
|
|
495
|
-
* CanvasTarget
|
|
496
|
-
*
|
|
522
|
+
* The CanvasTarget this root sizes and renders through.
|
|
523
|
+
*
|
|
524
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
525
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
526
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
527
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
528
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
497
529
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
498
530
|
*/
|
|
499
531
|
canvasTarget?: CanvasTarget
|
|
@@ -618,7 +650,7 @@ interface RootState {
|
|
|
618
650
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
619
651
|
uniforms: UniformStore
|
|
620
652
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
621
|
-
nodes:
|
|
653
|
+
nodes: NodeStore
|
|
622
654
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
623
655
|
buffers: BufferStore
|
|
624
656
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -630,7 +662,7 @@ interface RootState {
|
|
|
630
662
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
631
663
|
renderPipeline: ThreeRenderPipeline | null
|
|
632
664
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
633
|
-
passes:
|
|
665
|
+
passes: PassRecord
|
|
634
666
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
635
667
|
_hmrVersion: number
|
|
636
668
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -718,12 +750,19 @@ type DefaultRendererProps = {
|
|
|
718
750
|
*/
|
|
719
751
|
interface CanvasSchedulerConfig {
|
|
720
752
|
/**
|
|
721
|
-
*
|
|
722
|
-
* Pass the `id` of another canvas.
|
|
753
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
723
754
|
*/
|
|
724
|
-
|
|
755
|
+
before?: string | string[]
|
|
725
756
|
/**
|
|
726
|
-
*
|
|
757
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
758
|
+
*/
|
|
759
|
+
after?: string | string[]
|
|
760
|
+
/**
|
|
761
|
+
* Numeric root order. Lower values run first.
|
|
762
|
+
*/
|
|
763
|
+
order?: number
|
|
764
|
+
/**
|
|
765
|
+
* Limit this Canvas's default render job (frames per second).
|
|
727
766
|
*/
|
|
728
767
|
fps?: number
|
|
729
768
|
}
|
|
@@ -1171,7 +1210,33 @@ declare global {
|
|
|
1171
1210
|
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1172
1211
|
* installed three instead of needing to be mirrored by hand.
|
|
1173
1212
|
*/
|
|
1174
|
-
type UniformNode<T = unknown> = three_webgpu.UniformNode<
|
|
1213
|
+
type UniformNode<T = unknown> = three_webgpu.UniformNode<UniformNodeTypeFor<T>, T>
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* three's node type name for a uniform value type, mirroring the `uniform()` overloads.
|
|
1217
|
+
* A `UniformNode<number>` is a `Node<'float'>`, so TSL math (`.mul`, `.add`, ...) accepts it.
|
|
1218
|
+
* Unknown or unlisted value types resolve to `unknown`, which TSL math rejects: narrow with
|
|
1219
|
+
* `as UniformNode<number>` (or the matching value type) at the call site.
|
|
1220
|
+
*/
|
|
1221
|
+
type UniformNodeTypeFor<T> = T extends number
|
|
1222
|
+
? 'float'
|
|
1223
|
+
: T extends boolean
|
|
1224
|
+
? 'bool'
|
|
1225
|
+
: T extends three_webgpu.Color
|
|
1226
|
+
? 'color'
|
|
1227
|
+
: T extends three_webgpu.Vector2
|
|
1228
|
+
? 'vec2'
|
|
1229
|
+
: T extends three_webgpu.Vector3
|
|
1230
|
+
? 'vec3'
|
|
1231
|
+
: T extends three_webgpu.Vector4
|
|
1232
|
+
? 'vec4'
|
|
1233
|
+
: T extends three_webgpu.Matrix2
|
|
1234
|
+
? 'mat2'
|
|
1235
|
+
: T extends three_webgpu.Matrix3
|
|
1236
|
+
? 'mat3'
|
|
1237
|
+
: T extends three_webgpu.Matrix4
|
|
1238
|
+
? 'mat4'
|
|
1239
|
+
: unknown
|
|
1175
1240
|
|
|
1176
1241
|
/**
|
|
1177
1242
|
* ShaderCallable - the return type of Fn()
|
|
@@ -1324,30 +1389,97 @@ declare global {
|
|
|
1324
1389
|
*/
|
|
1325
1390
|
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1326
1391
|
|
|
1327
|
-
/**
|
|
1328
|
-
|
|
1392
|
+
/**
|
|
1393
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1394
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1395
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1396
|
+
*/
|
|
1397
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1401
|
+
*
|
|
1402
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1403
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1404
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1405
|
+
* {@link RenderPipelineCallbackState}.
|
|
1406
|
+
*
|
|
1407
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1408
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1409
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1410
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1411
|
+
*/
|
|
1412
|
+
interface PassRecord {
|
|
1413
|
+
scenePass?: ScenePassNode
|
|
1414
|
+
[key: string]: three_webgpu.Node
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1419
|
+
*
|
|
1420
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1421
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1422
|
+
*
|
|
1423
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1424
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1425
|
+
*/
|
|
1426
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1427
|
+
renderPipeline: ThreeRenderPipeline
|
|
1428
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1429
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1430
|
+
isLegacy: false
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
/**
|
|
1434
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1435
|
+
*
|
|
1436
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1437
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1438
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1439
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1440
|
+
*/
|
|
1441
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1329
1442
|
|
|
1330
1443
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1331
|
-
type RenderPipelineSetupCallback = (state:
|
|
1444
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1332
1445
|
|
|
1333
1446
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1334
|
-
type RenderPipelineMainCallback = (state:
|
|
1447
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1335
1448
|
|
|
1336
|
-
/**
|
|
1337
|
-
interface
|
|
1449
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1450
|
+
interface UseRenderPipelineActions {
|
|
1338
1451
|
/** Current passes from state */
|
|
1339
1452
|
passes: PassRecord
|
|
1340
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1341
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1342
1453
|
/** Clear all passes from state */
|
|
1343
1454
|
clearPasses: () => void
|
|
1344
1455
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1345
1456
|
reset: () => void
|
|
1346
1457
|
/** Re-run setup/main callbacks with current closure values */
|
|
1347
1458
|
rebuild: () => void
|
|
1348
|
-
/** True when RenderPipeline is configured and ready */
|
|
1349
|
-
isReady: boolean
|
|
1350
1459
|
}
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1463
|
+
*
|
|
1464
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1465
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1466
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1467
|
+
*/
|
|
1468
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1469
|
+
(
|
|
1470
|
+
| {
|
|
1471
|
+
/** True when RenderPipeline is configured and ready */
|
|
1472
|
+
isReady: true
|
|
1473
|
+
/** RenderPipeline instance */
|
|
1474
|
+
renderPipeline: ThreeRenderPipeline
|
|
1475
|
+
}
|
|
1476
|
+
| {
|
|
1477
|
+
/** False until the pipeline has been created */
|
|
1478
|
+
isReady: false
|
|
1479
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1480
|
+
renderPipeline: null
|
|
1481
|
+
}
|
|
1482
|
+
)
|
|
1351
1483
|
}
|
|
1352
1484
|
|
|
1353
1485
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -1891,7 +2023,7 @@ declare namespace useLoader {
|
|
|
1891
2023
|
*
|
|
1892
2024
|
* @param callback - Function called each frame with (state, delta). Optional if you only need scheduler access.
|
|
1893
2025
|
* @param priorityOrOptions - Either a priority number (backwards compat) or options object
|
|
1894
|
-
* @returns Controls object with step(), stepAll(), pause(), resume(), isPaused, id, scheduler
|
|
2026
|
+
* @returns Controls object with step(), stepAll(), invalidate(), pause(), resume(), isPaused, id, rootId, scheduler
|
|
1895
2027
|
*
|
|
1896
2028
|
* @example
|
|
1897
2029
|
* // Simple priority (backwards compat)
|
|
@@ -2187,7 +2319,10 @@ declare function addTail(callback: GlobalRenderCallback): () => void;
|
|
|
2187
2319
|
* Invalidates the view, requesting a frame to be rendered.
|
|
2188
2320
|
* In demand mode, this triggers the scheduler to run frames.
|
|
2189
2321
|
*
|
|
2190
|
-
*
|
|
2322
|
+
* With a state argument, only that root's jobs run on the requested frames; other
|
|
2323
|
+
* roots on 'demand' stay idle. Without one, every registered root is invalidated.
|
|
2324
|
+
*
|
|
2325
|
+
* @param state - Optional root state; targets the invalidation at that root
|
|
2191
2326
|
* @param frames - Number of frames to request (default: 1)
|
|
2192
2327
|
* @param stackFrames - If false, sets pendingFrames to frames. If true, adds to existing pendingFrames (default: false)
|
|
2193
2328
|
*
|
|
@@ -2198,14 +2333,16 @@ declare function invalidate(state?: RootState, frames?: number, stackFrames?: bo
|
|
|
2198
2333
|
* Advances the frameloop and runs render effects.
|
|
2199
2334
|
* Useful for when manually rendering via `frameloop="never"`.
|
|
2200
2335
|
*
|
|
2336
|
+
* With a state argument, only that root is stepped. Without one, every
|
|
2337
|
+
* registered root is stepped for backwards compatibility.
|
|
2338
|
+
*
|
|
2201
2339
|
* @param timestamp - The timestamp to use for this frame
|
|
2202
2340
|
* @param runGlobalEffects - Ignored (kept for backwards compat, global effects always run)
|
|
2203
|
-
* @param state -
|
|
2204
|
-
* @param frame - Ignored (kept for backwards compat)
|
|
2341
|
+
* @param state - Optional root state; targets the manual step at that root
|
|
2205
2342
|
*
|
|
2206
2343
|
* @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
|
|
2207
2344
|
*/
|
|
2208
|
-
declare function advance(timestamp: number): void;
|
|
2345
|
+
declare function advance(timestamp: number, runGlobalEffects?: boolean, state?: RootState): void;
|
|
2209
2346
|
|
|
2210
2347
|
/* eslint-disable @definitelytyped/no-unnecessary-generics */
|
|
2211
2348
|
declare function ReactReconciler<
|
|
@@ -3760,4 +3897,4 @@ declare function isOnce(value: unknown): value is {
|
|
|
3760
3897
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3761
3898
|
|
|
3762
3899
|
export { Block, Canvas, Environment, EnvironmentCube, EnvironmentMap, EnvironmentPortal, ErrorBoundary, FROM_REF, IsObject, ONCE, Portal, R3F_BUILD_LEGACY, R3F_BUILD_WEBGPU, REACT_INTERNAL_PROPS, RESERVED_PROPS, three_d as ReactThreeFiber, Texture, _roots, addAfterEffect, addEffect, addTail, advance, applyProps, attach, buildGraph, calculateDpr, context, createEvents, createPointerEvents, createPortal, createRoot, createStore, detach, diffProps, dispose, createPointerEvents as events, extend, findInitialRoot, flushSync, fromRef, getInstanceProps, getPrimary, getPrimaryIds, getRootState, getUuidPrefix, hasConstructor, hasPrimary, invalidate, invalidateInstance, is, isColorRepresentation, isCopyable, isFromRef, isObject3D, isOnce, isOrthographicCamera, isRef, isRenderer, isTexture, isVectorLike, once, prepare, presetsObj, reconciler, registerPrimary, removeInteractivity, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useEnvironment, useFrame, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useMutableCallback, useRenderTarget, useStore, useTexture, useTextures, useThree, waitForPrimary };
|
|
3763
|
-
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, LegacyInternalState as 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, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, LegacyRootState as 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 };
|
|
3900
|
+
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, LegacyInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, LegacyRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, LegacyRootState as 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 };
|
package/dist/legacy.mjs
CHANGED
|
@@ -909,7 +909,7 @@ const createStore = (invalidate, advance) => {
|
|
|
909
909
|
size: newSize,
|
|
910
910
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, newSize) }
|
|
911
911
|
}));
|
|
912
|
-
|
|
912
|
+
get().invalidate();
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
return;
|
|
@@ -924,15 +924,16 @@ const createStore = (invalidate, advance) => {
|
|
|
924
924
|
viewport: { ...s.viewport, ...getCurrentViewport(state2.camera, defaultTarget, size) },
|
|
925
925
|
_sizeImperative: true
|
|
926
926
|
}));
|
|
927
|
-
|
|
927
|
+
get().invalidate();
|
|
928
928
|
},
|
|
929
929
|
setDpr: (dpr) => set((state2) => {
|
|
930
930
|
const resolved = calculateDpr(dpr);
|
|
931
931
|
return { viewport: { ...state2.viewport, dpr: resolved, initialDpr: state2.viewport.initialDpr || resolved } };
|
|
932
932
|
}),
|
|
933
933
|
setFrameloop: (frameloop = "always") => {
|
|
934
|
+
const rootId = get().internal.rootId;
|
|
935
|
+
if (rootId) getScheduler().setRootFrameloop(rootId, frameloop);
|
|
934
936
|
set(() => ({ frameloop }));
|
|
935
|
-
getScheduler().frameloop = frameloop;
|
|
936
937
|
},
|
|
937
938
|
setError: (error) => set(() => ({ error })),
|
|
938
939
|
error: null,
|
|
@@ -1051,7 +1052,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1051
1052
|
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1052
1053
|
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1053
1054
|
resizeTarget.setSize(size.width, size.height, false);
|
|
1054
|
-
|
|
1055
|
+
const activeTarget = actualRenderer.getCanvasTarget?.();
|
|
1056
|
+
if (!canvasTarget || activeTarget !== canvasTarget) internal.canvasTargetSizeDirty = true;
|
|
1055
1057
|
}
|
|
1056
1058
|
if (camera !== oldCamera) {
|
|
1057
1059
|
oldCamera = camera;
|
|
@@ -1237,6 +1239,13 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
1237
1239
|
* Use for controlling the entire frame loop, adding phases, etc.
|
|
1238
1240
|
*/
|
|
1239
1241
|
scheduler: scheduler2,
|
|
1242
|
+
/**
|
|
1243
|
+
* The root that currently owns this job. Resolve on access because ambient
|
|
1244
|
+
* jobs can be adopted by a Canvas after the controls object is created.
|
|
1245
|
+
*/
|
|
1246
|
+
get rootId() {
|
|
1247
|
+
return getScheduler().getJobRootId(id);
|
|
1248
|
+
},
|
|
1240
1249
|
/**
|
|
1241
1250
|
* Manually step this job only.
|
|
1242
1251
|
* Bypasses FPS limiting - always runs.
|
|
@@ -1253,6 +1262,14 @@ function useFrame(callback, priorityOrOptions) {
|
|
|
1253
1262
|
stepAll: (timestamp) => {
|
|
1254
1263
|
getScheduler().step(timestamp);
|
|
1255
1264
|
},
|
|
1265
|
+
/**
|
|
1266
|
+
* Request frames for this job's owning root without waking sibling roots.
|
|
1267
|
+
*/
|
|
1268
|
+
invalidate: (frames, stackFrames) => {
|
|
1269
|
+
const scheduler3 = getScheduler();
|
|
1270
|
+
const rootId = scheduler3.getJobRootId(id);
|
|
1271
|
+
if (rootId) scheduler3.invalidateRoot(rootId, frames, stackFrames);
|
|
1272
|
+
},
|
|
1256
1273
|
/**
|
|
1257
1274
|
* Pause this job (set enabled=false).
|
|
1258
1275
|
* Job remains registered but won't run.
|
|
@@ -1670,13 +1687,19 @@ function addTail(callback) {
|
|
|
1670
1687
|
return getScheduler().onIdle(callback);
|
|
1671
1688
|
}
|
|
1672
1689
|
function invalidate(state, frames = 1, stackFrames = false) {
|
|
1673
|
-
|
|
1690
|
+
const rootId = state?.internal?.rootId;
|
|
1691
|
+
const scheduler = getScheduler();
|
|
1692
|
+
if (rootId) scheduler.invalidateRoot(rootId, frames, stackFrames);
|
|
1693
|
+
else scheduler.invalidate(frames, stackFrames);
|
|
1674
1694
|
}
|
|
1675
|
-
function advance(timestamp) {
|
|
1676
|
-
|
|
1695
|
+
function advance(timestamp, runGlobalEffects, state) {
|
|
1696
|
+
const rootId = state?.internal?.rootId;
|
|
1697
|
+
const scheduler = getScheduler();
|
|
1698
|
+
if (rootId) scheduler.stepRoot(rootId, timestamp);
|
|
1699
|
+
else scheduler.step(timestamp);
|
|
1677
1700
|
}
|
|
1678
1701
|
|
|
1679
|
-
const version = "10.0.0-alpha.
|
|
1702
|
+
const version = "10.0.0-alpha.4";
|
|
1680
1703
|
const packageData = {
|
|
1681
1704
|
version: version};
|
|
1682
1705
|
|
|
@@ -14288,7 +14311,7 @@ function createRoot(canvas) {
|
|
|
14288
14311
|
const handleXRFrame = (timestamp, _frame) => {
|
|
14289
14312
|
const state2 = store.getState();
|
|
14290
14313
|
if (state2.frameloop === "never") return;
|
|
14291
|
-
advance(timestamp);
|
|
14314
|
+
advance(timestamp, true, state2);
|
|
14292
14315
|
};
|
|
14293
14316
|
const actualRenderer = state.internal.actualRenderer;
|
|
14294
14317
|
const handleSessionChange = () => {
|
|
@@ -14296,7 +14319,7 @@ function createRoot(canvas) {
|
|
|
14296
14319
|
const renderer2 = state2.internal.actualRenderer;
|
|
14297
14320
|
actualRenderer.xr.enabled = actualRenderer.xr.isPresenting;
|
|
14298
14321
|
renderer2.xr.setAnimationLoop(renderer2.xr.isPresenting ? handleXRFrame : null);
|
|
14299
|
-
if (!renderer2.xr.isPresenting) invalidate();
|
|
14322
|
+
if (!renderer2.xr.isPresenting) invalidate(state2);
|
|
14300
14323
|
};
|
|
14301
14324
|
const xr = {
|
|
14302
14325
|
connect() {
|
|
@@ -14378,14 +14401,19 @@ function createRoot(canvas) {
|
|
|
14378
14401
|
const newRootId = canvasId || scheduler.generateRootId();
|
|
14379
14402
|
const unregisterRoot = scheduler.registerRoot(newRootId, {
|
|
14380
14403
|
getState: () => store.getState(),
|
|
14381
|
-
onError: (err) => store.getState().setError(err)
|
|
14404
|
+
onError: (err) => store.getState().setError(err),
|
|
14405
|
+
frameloop: store.getState().frameloop,
|
|
14406
|
+
before: schedulerConfig?.before,
|
|
14407
|
+
after: schedulerConfig?.after,
|
|
14408
|
+
order: schedulerConfig?.order
|
|
14382
14409
|
});
|
|
14383
14410
|
const unregisterCanvasTarget = scheduler.register(
|
|
14384
14411
|
() => {
|
|
14385
14412
|
const state2 = store.getState();
|
|
14386
|
-
|
|
14413
|
+
const canvasTarget = state2.internal.canvasTarget;
|
|
14414
|
+
if (canvasTarget) {
|
|
14387
14415
|
const renderer2 = state2.internal.actualRenderer;
|
|
14388
|
-
renderer2.setCanvasTarget(
|
|
14416
|
+
if (renderer2.getCanvasTarget() !== canvasTarget) renderer2.setCanvasTarget(canvasTarget);
|
|
14389
14417
|
if (state2.internal.canvasTargetSizeDirty) {
|
|
14390
14418
|
state2.internal.canvasTargetSizeDirty = false;
|
|
14391
14419
|
renderer2.backend?.updateSize?.();
|
|
@@ -14458,8 +14486,7 @@ function createRoot(canvas) {
|
|
|
14458
14486
|
phase: "render",
|
|
14459
14487
|
system: true,
|
|
14460
14488
|
// Internal flag: this is a system job, not user-controlled
|
|
14461
|
-
//
|
|
14462
|
-
...schedulerConfig?.after && { after: schedulerConfig.after },
|
|
14489
|
+
// FPS throttles only the default render job; Canvas ordering belongs to the root.
|
|
14463
14490
|
...schedulerConfig?.fps && { fps: schedulerConfig.fps }
|
|
14464
14491
|
}
|
|
14465
14492
|
);
|
|
@@ -14478,8 +14505,21 @@ function createRoot(canvas) {
|
|
|
14478
14505
|
scheduler
|
|
14479
14506
|
}
|
|
14480
14507
|
}));
|
|
14508
|
+
} else {
|
|
14509
|
+
const constraintsChanged = !is.equ(schedulerConfig?.before, lastConfiguredProps.schedulerBefore, shallowLoose) || !is.equ(schedulerConfig?.after, lastConfiguredProps.schedulerAfter, shallowLoose);
|
|
14510
|
+
if (constraintsChanged) {
|
|
14511
|
+
scheduler.setRootConstraints(rootId, {
|
|
14512
|
+
before: schedulerConfig?.before,
|
|
14513
|
+
after: schedulerConfig?.after
|
|
14514
|
+
});
|
|
14515
|
+
}
|
|
14516
|
+
if (schedulerConfig?.order !== lastConfiguredProps.schedulerOrder) {
|
|
14517
|
+
scheduler.setRootOrder(rootId, schedulerConfig?.order ?? 0);
|
|
14518
|
+
}
|
|
14481
14519
|
}
|
|
14482
|
-
|
|
14520
|
+
lastConfiguredProps.schedulerBefore = schedulerConfig?.before;
|
|
14521
|
+
lastConfiguredProps.schedulerAfter = schedulerConfig?.after;
|
|
14522
|
+
lastConfiguredProps.schedulerOrder = schedulerConfig?.order;
|
|
14483
14523
|
onCreated = onCreatedCallback;
|
|
14484
14524
|
configured = true;
|
|
14485
14525
|
resolve();
|
|
@@ -14521,18 +14561,23 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14521
14561
|
const fiber = root?.fiber;
|
|
14522
14562
|
if (fiber) {
|
|
14523
14563
|
const state = root?.store.getState();
|
|
14524
|
-
if (state)
|
|
14564
|
+
if (state) {
|
|
14565
|
+
state.internal.active = false;
|
|
14566
|
+
const unregisterRoot = state.internal.unregisterRoot;
|
|
14567
|
+
if (unregisterRoot) {
|
|
14568
|
+
unregisterRoot();
|
|
14569
|
+
state.internal.unregisterRoot = void 0;
|
|
14570
|
+
}
|
|
14571
|
+
}
|
|
14525
14572
|
reconciler.updateContainer(null, fiber, null, () => {
|
|
14526
14573
|
if (state) {
|
|
14527
14574
|
setTimeout(() => {
|
|
14528
14575
|
try {
|
|
14529
14576
|
const renderer = state.internal.actualRenderer;
|
|
14530
|
-
const unregisterRoot = state.internal.unregisterRoot;
|
|
14531
|
-
if (unregisterRoot) unregisterRoot();
|
|
14532
14577
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14533
14578
|
if (unregisterPrimary) unregisterPrimary();
|
|
14534
14579
|
const canvasTarget = state.internal.canvasTarget;
|
|
14535
|
-
if (canvasTarget?.dispose) canvasTarget.dispose();
|
|
14580
|
+
if (state.internal.isSecondary && canvasTarget?.dispose) canvasTarget.dispose();
|
|
14536
14581
|
state.events.disconnect?.();
|
|
14537
14582
|
cleanupHelperGroup(root.store);
|
|
14538
14583
|
if (state.isLegacy && renderer) {
|
|
@@ -14976,9 +15021,9 @@ function CanvasImpl({
|
|
|
14976
15021
|
React.useMemo(() => extend(THREE), []);
|
|
14977
15022
|
const Bridge = useBridge();
|
|
14978
15023
|
const backgroundProps = React.useMemo(() => parseBackground(background), [background]);
|
|
14979
|
-
const
|
|
15024
|
+
const [hasInitialSize, setHasInitialSize] = React.useState(false);
|
|
14980
15025
|
const measureConfig = React.useMemo(() => {
|
|
14981
|
-
if (!
|
|
15026
|
+
if (!hasInitialSize) {
|
|
14982
15027
|
return {
|
|
14983
15028
|
...resize,
|
|
14984
15029
|
scroll: resize?.scroll ?? true,
|
|
@@ -14990,7 +15035,7 @@ function CanvasImpl({
|
|
|
14990
15035
|
debounce: { scroll: 50, resize: 0 },
|
|
14991
15036
|
...resize
|
|
14992
15037
|
};
|
|
14993
|
-
}, [
|
|
15038
|
+
}, [hasInitialSize, resize]);
|
|
14994
15039
|
const [containerRef, containerRect] = useMeasure(measureConfig);
|
|
14995
15040
|
const effectiveSize = React.useMemo(() => {
|
|
14996
15041
|
let w = width ?? containerRect.width;
|
|
@@ -15006,9 +15051,7 @@ function CanvasImpl({
|
|
|
15006
15051
|
left: containerRect.left
|
|
15007
15052
|
};
|
|
15008
15053
|
}, [width, height, containerRect, forceEven]);
|
|
15009
|
-
if (!
|
|
15010
|
-
hasInitialSizeRef.current = true;
|
|
15011
|
-
}
|
|
15054
|
+
if (!hasInitialSize && effectiveSize.width > 0 && effectiveSize.height > 0) setHasInitialSize(true);
|
|
15012
15055
|
const canvasRef = React.useRef(null);
|
|
15013
15056
|
const divRef = React.useRef(null);
|
|
15014
15057
|
React.useImperativeHandle(ref, () => canvasRef.current);
|