@react-three/fiber 10.0.0-canary.7dfc4e4 → 10.0.0-canary.979dc2d
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 +33 -18
- package/dist/index.d.cts +152 -20
- package/dist/index.d.mts +152 -20
- package/dist/index.d.ts +152 -20
- package/dist/index.mjs +33 -18
- package/dist/legacy.cjs +30 -14
- package/dist/legacy.d.cts +152 -20
- package/dist/legacy.d.mts +152 -20
- package/dist/legacy.d.ts +152 -20
- package/dist/legacy.mjs +30 -14
- package/dist/webgpu/index.cjs +53 -31
- package/dist/webgpu/index.d.cts +156 -36
- package/dist/webgpu/index.d.mts +156 -36
- package/dist/webgpu/index.d.ts +156 -36
- package/dist/webgpu/index.mjs +53 -31
- package/package.json +1 -1
package/dist/webgpu/index.d.ts
CHANGED
|
@@ -365,6 +365,33 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
365
365
|
*/
|
|
366
366
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
367
367
|
|
|
368
|
+
//* Node Types (useNodes) ========================================
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Structural shape of a TSL node as stored on `state.nodes`.
|
|
372
|
+
*
|
|
373
|
+
* Deliberately minimal rather than three's nominal `Node`: in @types/three several node classes
|
|
374
|
+
* TSL hands back (OperatorNode, ConstNode, ...) do not extend `Node` cleanly, so a `Node` bound
|
|
375
|
+
* would reject values `useNodes` creators legitimately return. This is the same shape
|
|
376
|
+
* `useNodes` already constrains creators to (`TSLNodeLike`).
|
|
377
|
+
*/
|
|
378
|
+
interface NodeLike {
|
|
379
|
+
uuid?: string
|
|
380
|
+
nodeType?: string | null
|
|
381
|
+
/** label method for chaining - sets the node's label and returns self */
|
|
382
|
+
label?: ((label: string) => NodeLike) | string
|
|
383
|
+
setName?: (name: string) => this
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
387
|
+
type NodeRecord = Record<string, NodeLike>
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
391
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
392
|
+
*/
|
|
393
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
394
|
+
|
|
368
395
|
//* Storage Types (useGPUStorage) ========================================
|
|
369
396
|
|
|
370
397
|
/**
|
|
@@ -498,8 +525,13 @@ interface InternalState {
|
|
|
498
525
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
499
526
|
container?: THREE$1.Object3D
|
|
500
527
|
/**
|
|
501
|
-
* CanvasTarget
|
|
502
|
-
*
|
|
528
|
+
* The CanvasTarget this root sizes and renders through.
|
|
529
|
+
*
|
|
530
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
531
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
532
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
533
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
534
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
503
535
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
504
536
|
*/
|
|
505
537
|
canvasTarget?: CanvasTarget
|
|
@@ -624,7 +656,7 @@ interface RootState {
|
|
|
624
656
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
625
657
|
uniforms: UniformStore
|
|
626
658
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
627
|
-
nodes:
|
|
659
|
+
nodes: NodeStore
|
|
628
660
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
629
661
|
buffers: BufferStore
|
|
630
662
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -636,7 +668,7 @@ interface RootState {
|
|
|
636
668
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
637
669
|
renderPipeline: ThreeRenderPipeline | null
|
|
638
670
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
639
|
-
passes:
|
|
671
|
+
passes: PassRecord
|
|
640
672
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
641
673
|
_hmrVersion: number
|
|
642
674
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -724,12 +756,19 @@ type DefaultRendererProps = {
|
|
|
724
756
|
*/
|
|
725
757
|
interface CanvasSchedulerConfig {
|
|
726
758
|
/**
|
|
727
|
-
*
|
|
728
|
-
* Pass the `id` of another canvas.
|
|
759
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
729
760
|
*/
|
|
730
|
-
|
|
761
|
+
before?: string | string[]
|
|
731
762
|
/**
|
|
732
|
-
*
|
|
763
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
764
|
+
*/
|
|
765
|
+
after?: string | string[]
|
|
766
|
+
/**
|
|
767
|
+
* Numeric root order. Lower values run first.
|
|
768
|
+
*/
|
|
769
|
+
order?: number
|
|
770
|
+
/**
|
|
771
|
+
* Limit this Canvas's default render job (frames per second).
|
|
733
772
|
*/
|
|
734
773
|
fps?: number
|
|
735
774
|
}
|
|
@@ -1177,7 +1216,33 @@ declare global {
|
|
|
1177
1216
|
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1178
1217
|
* installed three instead of needing to be mirrored by hand.
|
|
1179
1218
|
*/
|
|
1180
|
-
type UniformNode<T = unknown> = three_webgpu.UniformNode<
|
|
1219
|
+
type UniformNode<T = unknown> = three_webgpu.UniformNode<UniformNodeTypeFor<T>, T>
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* three's node type name for a uniform value type, mirroring the `uniform()` overloads.
|
|
1223
|
+
* A `UniformNode<number>` is a `Node<'float'>`, so TSL math (`.mul`, `.add`, ...) accepts it.
|
|
1224
|
+
* Unknown or unlisted value types resolve to `unknown`, which TSL math rejects: narrow with
|
|
1225
|
+
* `as UniformNode<number>` (or the matching value type) at the call site.
|
|
1226
|
+
*/
|
|
1227
|
+
type UniformNodeTypeFor<T> = T extends number
|
|
1228
|
+
? 'float'
|
|
1229
|
+
: T extends boolean
|
|
1230
|
+
? 'bool'
|
|
1231
|
+
: T extends three_webgpu.Color
|
|
1232
|
+
? 'color'
|
|
1233
|
+
: T extends three_webgpu.Vector2
|
|
1234
|
+
? 'vec2'
|
|
1235
|
+
: T extends three_webgpu.Vector3
|
|
1236
|
+
? 'vec3'
|
|
1237
|
+
: T extends three_webgpu.Vector4
|
|
1238
|
+
? 'vec4'
|
|
1239
|
+
: T extends three_webgpu.Matrix2
|
|
1240
|
+
? 'mat2'
|
|
1241
|
+
: T extends three_webgpu.Matrix3
|
|
1242
|
+
? 'mat3'
|
|
1243
|
+
: T extends three_webgpu.Matrix4
|
|
1244
|
+
? 'mat4'
|
|
1245
|
+
: unknown
|
|
1181
1246
|
|
|
1182
1247
|
/**
|
|
1183
1248
|
* ShaderCallable - the return type of Fn()
|
|
@@ -1330,30 +1395,97 @@ declare global {
|
|
|
1330
1395
|
*/
|
|
1331
1396
|
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1332
1397
|
|
|
1333
|
-
/**
|
|
1334
|
-
|
|
1398
|
+
/**
|
|
1399
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1400
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1401
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1402
|
+
*/
|
|
1403
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1404
|
+
|
|
1405
|
+
/**
|
|
1406
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1407
|
+
*
|
|
1408
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1409
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1410
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1411
|
+
* {@link RenderPipelineCallbackState}.
|
|
1412
|
+
*
|
|
1413
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1414
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1415
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1416
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1417
|
+
*/
|
|
1418
|
+
interface PassRecord {
|
|
1419
|
+
scenePass?: ScenePassNode
|
|
1420
|
+
[key: string]: three_webgpu.Node
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1425
|
+
*
|
|
1426
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1427
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1428
|
+
*
|
|
1429
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1430
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1431
|
+
*/
|
|
1432
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1433
|
+
renderPipeline: ThreeRenderPipeline
|
|
1434
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1435
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1436
|
+
isLegacy: false
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1441
|
+
*
|
|
1442
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1443
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1444
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1445
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1446
|
+
*/
|
|
1447
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1335
1448
|
|
|
1336
1449
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1337
|
-
type RenderPipelineSetupCallback = (state:
|
|
1450
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1338
1451
|
|
|
1339
1452
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1340
|
-
type RenderPipelineMainCallback = (state:
|
|
1453
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1341
1454
|
|
|
1342
|
-
/**
|
|
1343
|
-
interface
|
|
1455
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1456
|
+
interface UseRenderPipelineActions {
|
|
1344
1457
|
/** Current passes from state */
|
|
1345
1458
|
passes: PassRecord
|
|
1346
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1347
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1348
1459
|
/** Clear all passes from state */
|
|
1349
1460
|
clearPasses: () => void
|
|
1350
1461
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1351
1462
|
reset: () => void
|
|
1352
1463
|
/** Re-run setup/main callbacks with current closure values */
|
|
1353
1464
|
rebuild: () => void
|
|
1354
|
-
/** True when RenderPipeline is configured and ready */
|
|
1355
|
-
isReady: boolean
|
|
1356
1465
|
}
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1469
|
+
*
|
|
1470
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1471
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1472
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1473
|
+
*/
|
|
1474
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1475
|
+
(
|
|
1476
|
+
| {
|
|
1477
|
+
/** True when RenderPipeline is configured and ready */
|
|
1478
|
+
isReady: true
|
|
1479
|
+
/** RenderPipeline instance */
|
|
1480
|
+
renderPipeline: ThreeRenderPipeline
|
|
1481
|
+
}
|
|
1482
|
+
| {
|
|
1483
|
+
/** False until the pipeline has been created */
|
|
1484
|
+
isReady: false
|
|
1485
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1486
|
+
renderPipeline: null
|
|
1487
|
+
}
|
|
1488
|
+
)
|
|
1357
1489
|
}
|
|
1358
1490
|
|
|
1359
1491
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -3851,25 +3983,13 @@ declare function useUniform<T extends UniformValue>(name: string): UniformNode<T
|
|
|
3851
3983
|
declare function useUniform<T extends UniformValue>(name: string, value: T): UniformNode<Widen<T>>;
|
|
3852
3984
|
|
|
3853
3985
|
/**
|
|
3854
|
-
* Minimal interface for TSL nodes.
|
|
3855
|
-
*
|
|
3856
|
-
*
|
|
3857
|
-
* extend Node with all required properties.
|
|
3986
|
+
* Minimal interface for TSL nodes. The definition lives with the store types as `NodeLike`, so
|
|
3987
|
+
* the shape creators may return and the shape `state.nodes` holds are the same type by
|
|
3988
|
+
* construction. See `NodeLike` for why this is structural rather than three's `Node`.
|
|
3858
3989
|
*/
|
|
3859
|
-
|
|
3860
|
-
uuid?: string;
|
|
3861
|
-
nodeType?: string | null;
|
|
3862
|
-
/** label method for chaining - sets the node's label and returns self */
|
|
3863
|
-
label?: ((label: string) => TSLNodeLike) | string;
|
|
3864
|
-
setName?: (name: string) => this;
|
|
3865
|
-
}
|
|
3990
|
+
type TSLNodeLike = NodeLike;
|
|
3866
3991
|
/** TSL node type - alias for compatibility */
|
|
3867
3992
|
type TSLNode = TSLNodeLike;
|
|
3868
|
-
/**
|
|
3869
|
-
* A record of TSL nodes - allows mixed node types (OperatorNode, ConstNode, etc.)
|
|
3870
|
-
* Uses TSLNodeLike for broader compatibility with Three.js's TSL type definitions.
|
|
3871
|
-
*/
|
|
3872
|
-
type NodeRecord<T extends TSLNodeLike = TSLNodeLike> = Record<string, T>;
|
|
3873
3993
|
/**
|
|
3874
3994
|
* Creator function that returns a record of nodes.
|
|
3875
3995
|
* Uses TSLNodeLike constraint to allow mixed node types
|
|
@@ -4158,4 +4278,4 @@ declare const useThree: UseThreeWebGPU;
|
|
|
4158
4278
|
declare const useFrame: UseFrameWebGPU;
|
|
4159
4279
|
|
|
4160
4280
|
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, clearNodeScope, clearRootNodes, clearRootUniforms, clearScope, context, createEvents, createPointerEvents, createPortal, createRoot, createScopedStore, createStore, createTextureOperations, 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, rebuildAllBuffers, rebuildAllNodes, rebuildAllStorage, rebuildAllUniforms, reconciler, registerPrimary, removeInteractivity, removeNodes, removeUniforms, resolve, swapInteractivity, unmountComponentAtNode, unregisterPrimary, updateCamera, updateFrustum, useBridge, useBuffers, useEnvironment, useFrame, useGPUStorage, useGraph, useInstanceHandle, useIsomorphicLayoutEffect, useLoader, useLocalNodes, useMutableCallback, useNodes, useRenderPipeline, useRenderTarget, useStore, useTexture, useTextures, useThree, useUniform, useUniforms, waitForPrimary };
|
|
4161
|
-
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DisposeBuffersFn, DisposeOptions, DisposeStorageFn, 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, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeProps,
|
|
4281
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferCreator, BufferLike, BufferRecord, BufferStore, BuffersWithUtils, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, ClearBuffersFn, ClearNodesFn, ClearStorageFn, ClearUniformsFn, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, CreatorState, DefaultGLProps, DefaultRendererProps, Disposable, DisposeBuffersFn, DisposeOptions, DisposeStorageFn, 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, WebGPUInternalState as InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, LocalNodeCreator, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeCreator, NodeLike, NodeProps, NodeStore, NodesWithUtils, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, WebGPUR3FRenderer as R3FRenderer, RaycastableRepresentation, ReactProps, RebuildBuffersFn, RebuildNodesFn, RebuildStorageFn, RebuildUniformsFn, ReconcilerRoot, RemoveBuffersFn, RemoveNodesFn, RemoveStorageFn, RemoveUniformsFn, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, WebGPURootState as RootState, RootStore, ScopedStoreType, SetBlock, Size, StorageCreator, StorageLike, StorageRecord, StorageStore, StorageWithUtils, Subscription, TSLNode, TSLNodeInput, TextureEntry, TextureInput, TextureNode, TextureOperations, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UniformCreator, UniformValue, UniformsWithUtils, UseFrameWebGPU, UseTextureOptions, UseTexturesReturn, UseThreeWebGPU, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, WebGPUDefaultProps, WebGPUProps, WebGPUShadowConfig, XRManager, XRPointerConfig };
|
package/dist/webgpu/index.mjs
CHANGED
|
@@ -1058,7 +1058,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1058
1058
|
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1059
1059
|
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1060
1060
|
resizeTarget.setSize(size.width, size.height, false);
|
|
1061
|
-
|
|
1061
|
+
const activeTarget = actualRenderer.getCanvasTarget?.();
|
|
1062
|
+
if (!canvasTarget || activeTarget !== canvasTarget) internal.canvasTargetSizeDirty = true;
|
|
1062
1063
|
}
|
|
1063
1064
|
if (camera !== oldCamera) {
|
|
1064
1065
|
oldCamera = camera;
|
|
@@ -1704,7 +1705,7 @@ function advance(timestamp, runGlobalEffects, state) {
|
|
|
1704
1705
|
else scheduler.step(timestamp);
|
|
1705
1706
|
}
|
|
1706
1707
|
|
|
1707
|
-
const version = "10.0.0-alpha.
|
|
1708
|
+
const version = "10.0.0-alpha.4";
|
|
1708
1709
|
const packageData = {
|
|
1709
1710
|
version: version};
|
|
1710
1711
|
|
|
@@ -14220,9 +14221,8 @@ function createRoot(canvas) {
|
|
|
14220
14221
|
if (!renderer.hasInitialized?.()) {
|
|
14221
14222
|
const size2 = computeInitialSize(canvas, propsSize);
|
|
14222
14223
|
if (size2.width > 0 && size2.height > 0) {
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
canvas.height = size2.height * pixelRatio;
|
|
14224
|
+
renderer.setPixelRatio(calculateDpr(dpr));
|
|
14225
|
+
renderer.setSize(size2.width, size2.height, false);
|
|
14226
14226
|
}
|
|
14227
14227
|
await renderer.init();
|
|
14228
14228
|
}
|
|
@@ -14231,7 +14231,7 @@ function createRoot(canvas) {
|
|
|
14231
14231
|
state.internal.actualRenderer = renderer;
|
|
14232
14232
|
state.set({ webGPUSupported: isWebGPUBackend, renderer, primaryStore: store });
|
|
14233
14233
|
if (canvasId && !state.internal.isSecondary) {
|
|
14234
|
-
const canvasTarget =
|
|
14234
|
+
const canvasTarget = renderer.getCanvasTarget?.();
|
|
14235
14235
|
const unregisterPrimary = registerPrimary(canvasId, renderer, store);
|
|
14236
14236
|
state.set((prev) => ({
|
|
14237
14237
|
internal: {
|
|
@@ -14436,14 +14436,18 @@ function createRoot(canvas) {
|
|
|
14436
14436
|
const unregisterRoot = scheduler.registerRoot(newRootId, {
|
|
14437
14437
|
getState: () => store.getState(),
|
|
14438
14438
|
onError: (err) => store.getState().setError(err),
|
|
14439
|
-
frameloop: store.getState().frameloop
|
|
14439
|
+
frameloop: store.getState().frameloop,
|
|
14440
|
+
before: schedulerConfig?.before,
|
|
14441
|
+
after: schedulerConfig?.after,
|
|
14442
|
+
order: schedulerConfig?.order
|
|
14440
14443
|
});
|
|
14441
14444
|
const unregisterCanvasTarget = scheduler.register(
|
|
14442
14445
|
() => {
|
|
14443
14446
|
const state2 = store.getState();
|
|
14444
|
-
|
|
14447
|
+
const canvasTarget = state2.internal.canvasTarget;
|
|
14448
|
+
if (canvasTarget) {
|
|
14445
14449
|
const renderer2 = state2.internal.actualRenderer;
|
|
14446
|
-
renderer2.setCanvasTarget(
|
|
14450
|
+
if (renderer2.getCanvasTarget() !== canvasTarget) renderer2.setCanvasTarget(canvasTarget);
|
|
14447
14451
|
if (state2.internal.canvasTargetSizeDirty) {
|
|
14448
14452
|
state2.internal.canvasTargetSizeDirty = false;
|
|
14449
14453
|
renderer2.backend?.updateSize?.();
|
|
@@ -14516,8 +14520,7 @@ function createRoot(canvas) {
|
|
|
14516
14520
|
phase: "render",
|
|
14517
14521
|
system: true,
|
|
14518
14522
|
// Internal flag: this is a system job, not user-controlled
|
|
14519
|
-
//
|
|
14520
|
-
...schedulerConfig?.after && { after: schedulerConfig.after },
|
|
14523
|
+
// FPS throttles only the default render job; Canvas ordering belongs to the root.
|
|
14521
14524
|
...schedulerConfig?.fps && { fps: schedulerConfig.fps }
|
|
14522
14525
|
}
|
|
14523
14526
|
);
|
|
@@ -14536,7 +14539,21 @@ function createRoot(canvas) {
|
|
|
14536
14539
|
scheduler
|
|
14537
14540
|
}
|
|
14538
14541
|
}));
|
|
14542
|
+
} else {
|
|
14543
|
+
const constraintsChanged = !is.equ(schedulerConfig?.before, lastConfiguredProps.schedulerBefore, shallowLoose) || !is.equ(schedulerConfig?.after, lastConfiguredProps.schedulerAfter, shallowLoose);
|
|
14544
|
+
if (constraintsChanged) {
|
|
14545
|
+
scheduler.setRootConstraints(rootId, {
|
|
14546
|
+
before: schedulerConfig?.before,
|
|
14547
|
+
after: schedulerConfig?.after
|
|
14548
|
+
});
|
|
14549
|
+
}
|
|
14550
|
+
if (schedulerConfig?.order !== lastConfiguredProps.schedulerOrder) {
|
|
14551
|
+
scheduler.setRootOrder(rootId, schedulerConfig?.order ?? 0);
|
|
14552
|
+
}
|
|
14539
14553
|
}
|
|
14554
|
+
lastConfiguredProps.schedulerBefore = schedulerConfig?.before;
|
|
14555
|
+
lastConfiguredProps.schedulerAfter = schedulerConfig?.after;
|
|
14556
|
+
lastConfiguredProps.schedulerOrder = schedulerConfig?.order;
|
|
14540
14557
|
onCreated = onCreatedCallback;
|
|
14541
14558
|
configured = true;
|
|
14542
14559
|
resolve();
|
|
@@ -14594,7 +14611,7 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14594
14611
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14595
14612
|
if (unregisterPrimary) unregisterPrimary();
|
|
14596
14613
|
const canvasTarget = state.internal.canvasTarget;
|
|
14597
|
-
if (canvasTarget?.dispose) canvasTarget.dispose();
|
|
14614
|
+
if (state.internal.isSecondary && canvasTarget?.dispose) canvasTarget.dispose();
|
|
14598
14615
|
state.events.disconnect?.();
|
|
14599
14616
|
cleanupHelperGroup(root.store);
|
|
14600
14617
|
if (state.isLegacy && renderer) {
|
|
@@ -15135,9 +15152,9 @@ function CanvasImpl({
|
|
|
15135
15152
|
React.useMemo(() => extend(THREE), []);
|
|
15136
15153
|
const Bridge = useBridge();
|
|
15137
15154
|
const backgroundProps = React.useMemo(() => parseBackground(background), [background]);
|
|
15138
|
-
const
|
|
15155
|
+
const [hasInitialSize, setHasInitialSize] = React.useState(false);
|
|
15139
15156
|
const measureConfig = React.useMemo(() => {
|
|
15140
|
-
if (!
|
|
15157
|
+
if (!hasInitialSize) {
|
|
15141
15158
|
return {
|
|
15142
15159
|
...resize,
|
|
15143
15160
|
scroll: resize?.scroll ?? true,
|
|
@@ -15149,7 +15166,7 @@ function CanvasImpl({
|
|
|
15149
15166
|
debounce: { scroll: 50, resize: 0 },
|
|
15150
15167
|
...resize
|
|
15151
15168
|
};
|
|
15152
|
-
}, [
|
|
15169
|
+
}, [hasInitialSize, resize]);
|
|
15153
15170
|
const [containerRef, containerRect] = useMeasure(measureConfig);
|
|
15154
15171
|
const effectiveSize = React.useMemo(() => {
|
|
15155
15172
|
let w = width ?? containerRect.width;
|
|
@@ -15165,9 +15182,7 @@ function CanvasImpl({
|
|
|
15165
15182
|
left: containerRect.left
|
|
15166
15183
|
};
|
|
15167
15184
|
}, [width, height, containerRect, forceEven]);
|
|
15168
|
-
if (!
|
|
15169
|
-
hasInitialSizeRef.current = true;
|
|
15170
|
-
}
|
|
15185
|
+
if (!hasInitialSize && effectiveSize.width > 0 && effectiveSize.height > 0) setHasInitialSize(true);
|
|
15171
15186
|
const canvasRef = React.useRef(null);
|
|
15172
15187
|
const divRef = React.useRef(null);
|
|
15173
15188
|
React.useImperativeHandle(ref, () => canvasRef.current);
|
|
@@ -16026,7 +16041,7 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16026
16041
|
renderPipeline: null,
|
|
16027
16042
|
passes: {}
|
|
16028
16043
|
});
|
|
16029
|
-
scenePassCacheRef.current?.scenePass
|
|
16044
|
+
scenePassCacheRef.current?.scenePass.dispose();
|
|
16030
16045
|
callbacksRanRef.current = false;
|
|
16031
16046
|
scenePassCacheRef.current = null;
|
|
16032
16047
|
forceScenePassRebuildRef.current = false;
|
|
@@ -16041,6 +16056,9 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16041
16056
|
throw new Error("useRenderPipeline is only available with WebGPU renderer. Set renderer prop on Canvas.");
|
|
16042
16057
|
}
|
|
16043
16058
|
if (!renderer || !scene || !camera) return;
|
|
16059
|
+
if (!("isWebGPURenderer" in renderer)) {
|
|
16060
|
+
throw new Error("useRenderPipeline: renderer is not a WebGPURenderer but isLegacy is false.");
|
|
16061
|
+
}
|
|
16044
16062
|
const state = store.getState();
|
|
16045
16063
|
const set = store.setState;
|
|
16046
16064
|
try {
|
|
@@ -16072,7 +16090,12 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16072
16090
|
const shouldRunCallbacks = justCreatedPipeline || !callbacksRanRef.current || !cacheValid;
|
|
16073
16091
|
if (shouldRunCallbacks) {
|
|
16074
16092
|
if (setupCBRef.current) {
|
|
16075
|
-
const freshState = store.getState()
|
|
16093
|
+
const freshState = Object.assign({}, store.getState(), {
|
|
16094
|
+
renderPipeline: pipeline,
|
|
16095
|
+
passes: { ...currentPasses, scenePass },
|
|
16096
|
+
renderer,
|
|
16097
|
+
isLegacy: false
|
|
16098
|
+
});
|
|
16076
16099
|
const setupResult = setupCBRef.current(freshState);
|
|
16077
16100
|
if (setupResult && typeof setupResult === "object") {
|
|
16078
16101
|
currentPasses = { ...currentPasses, ...setupResult };
|
|
@@ -16080,7 +16103,12 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16080
16103
|
}
|
|
16081
16104
|
}
|
|
16082
16105
|
if (mainCBRef.current) {
|
|
16083
|
-
const freshState = store.getState()
|
|
16106
|
+
const freshState = Object.assign({}, store.getState(), {
|
|
16107
|
+
renderPipeline: pipeline,
|
|
16108
|
+
passes: { ...currentPasses, scenePass },
|
|
16109
|
+
renderer,
|
|
16110
|
+
isLegacy: false
|
|
16111
|
+
});
|
|
16084
16112
|
const mainResult = mainCBRef.current(freshState);
|
|
16085
16113
|
if (mainResult && typeof mainResult === "object") {
|
|
16086
16114
|
currentPasses = { ...currentPasses, ...mainResult };
|
|
@@ -16091,22 +16119,16 @@ function useRenderPipeline(mainCB, setupCB) {
|
|
|
16091
16119
|
callbacksRanRef.current = true;
|
|
16092
16120
|
}
|
|
16093
16121
|
if (outputNodeChanged) pipeline.needsUpdate = true;
|
|
16094
|
-
if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose
|
|
16122
|
+
if (outgoingScenePass && outgoingScenePass !== scenePass) outgoingScenePass.dispose();
|
|
16095
16123
|
} catch (error) {
|
|
16096
16124
|
console.warn("[useRenderPipeline] Setup failed; the render pipeline was not configured:", error);
|
|
16097
16125
|
}
|
|
16098
16126
|
}, [store, renderer, scene, camera, isLegacy, rebuildVersion]);
|
|
16099
16127
|
const passes = useThree$1((s) => s.passes);
|
|
16100
16128
|
const renderPipeline = useThree$1((s) => s.renderPipeline);
|
|
16101
|
-
|
|
16102
|
-
|
|
16103
|
-
|
|
16104
|
-
clearPasses,
|
|
16105
|
-
reset,
|
|
16106
|
-
rebuild,
|
|
16107
|
-
// isReady indicates if RenderPipeline is configured and ready for rendering
|
|
16108
|
-
isReady: renderPipeline !== null
|
|
16109
|
-
};
|
|
16129
|
+
const actions = { passes, clearPasses, reset, rebuild };
|
|
16130
|
+
if (renderPipeline) return { ...actions, isReady: true, renderPipeline };
|
|
16131
|
+
return { ...actions, isReady: false, renderPipeline: null };
|
|
16110
16132
|
}
|
|
16111
16133
|
|
|
16112
16134
|
extend(THREE);
|