@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/index.d.ts
CHANGED
|
@@ -363,6 +363,33 @@ type BufferRecord = Record<string, BufferLike>
|
|
|
363
363
|
*/
|
|
364
364
|
type BufferStore = Record<string, BufferLike | BufferRecord>
|
|
365
365
|
|
|
366
|
+
//* Node Types (useNodes) ========================================
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Structural shape of a TSL node as stored on `state.nodes`.
|
|
370
|
+
*
|
|
371
|
+
* Deliberately minimal rather than three's nominal `Node`: in @types/three several node classes
|
|
372
|
+
* TSL hands back (OperatorNode, ConstNode, ...) do not extend `Node` cleanly, so a `Node` bound
|
|
373
|
+
* would reject values `useNodes` creators legitimately return. This is the same shape
|
|
374
|
+
* `useNodes` already constrains creators to (`TSLNodeLike`).
|
|
375
|
+
*/
|
|
376
|
+
interface NodeLike {
|
|
377
|
+
uuid?: string
|
|
378
|
+
nodeType?: string | null
|
|
379
|
+
/** label method for chaining - sets the node's label and returns self */
|
|
380
|
+
label?: ((label: string) => NodeLike) | string
|
|
381
|
+
setName?: (name: string) => this
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** Flat record of TSL nodes (no nested scopes) */
|
|
385
|
+
type NodeRecord = Record<string, NodeLike>
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Node store that can contain both root-level nodes and scoped node objects.
|
|
389
|
+
* Structure: { wobble: OperatorNode, fx: { blur: ShaderCallable } }
|
|
390
|
+
*/
|
|
391
|
+
type NodeStore = Record<string, NodeLike | NodeRecord>
|
|
392
|
+
|
|
366
393
|
//* Storage Types (useGPUStorage) ========================================
|
|
367
394
|
|
|
368
395
|
/**
|
|
@@ -496,8 +523,13 @@ interface InternalState {
|
|
|
496
523
|
/** Container for child attachment (scene for root, original container for portals) */
|
|
497
524
|
container?: THREE$1.Object3D
|
|
498
525
|
/**
|
|
499
|
-
* CanvasTarget
|
|
500
|
-
*
|
|
526
|
+
* The CanvasTarget this root sizes and renders through.
|
|
527
|
+
*
|
|
528
|
+
* A primary (`<Canvas id>`) owns the renderer's default target -- the one three itself built
|
|
529
|
+
* around the canvas element -- so sizing it is sizing the renderer. A secondary owns a target
|
|
530
|
+
* R3F created for its own element. Either way there is exactly one target per canvas element,
|
|
531
|
+
* and the canvas-target job makes it the renderer's active one before this root renders.
|
|
532
|
+
* Absent on WebGL and on an id-less WebGPU canvas, where the renderer is sized directly.
|
|
501
533
|
* @see https://threejs.org/docs/#api/en/renderers/common/CanvasTarget
|
|
502
534
|
*/
|
|
503
535
|
canvasTarget?: CanvasTarget
|
|
@@ -622,7 +654,7 @@ interface RootState {
|
|
|
622
654
|
/** Global TSL uniform nodes - root-level uniforms + scoped sub-objects. Use useUniforms() hook */
|
|
623
655
|
uniforms: UniformStore
|
|
624
656
|
/** Global TSL nodes - root-level nodes + scoped sub-objects. Use useNodes() hook */
|
|
625
|
-
nodes:
|
|
657
|
+
nodes: NodeStore
|
|
626
658
|
/** Global TSL buffer nodes - root-level buffers + scoped sub-objects. Use useBuffers() hook */
|
|
627
659
|
buffers: BufferStore
|
|
628
660
|
/** Global GPU storage (textures, etc.) - root-level storage + scoped sub-objects. Use useGPUStorage() hook */
|
|
@@ -634,7 +666,7 @@ interface RootState {
|
|
|
634
666
|
/** WebGPU RenderPipeline instance - use useRenderPipeline() hook */
|
|
635
667
|
renderPipeline: ThreeRenderPipeline | null
|
|
636
668
|
/** Global TSL pass nodes for render pipeline - use useRenderPipeline() hook */
|
|
637
|
-
passes:
|
|
669
|
+
passes: PassRecord
|
|
638
670
|
/** Internal version counter for HMR - incremented by rebuildNodes/rebuildUniforms to bust memoization */
|
|
639
671
|
_hmrVersion: number
|
|
640
672
|
/** Internal: whether setSize() has taken ownership of canvas dimensions */
|
|
@@ -722,12 +754,19 @@ type DefaultRendererProps = {
|
|
|
722
754
|
*/
|
|
723
755
|
interface CanvasSchedulerConfig {
|
|
724
756
|
/**
|
|
725
|
-
*
|
|
726
|
-
|
|
757
|
+
* Run this Canvas root before the referenced Canvas root id(s).
|
|
758
|
+
*/
|
|
759
|
+
before?: string | string[]
|
|
760
|
+
/**
|
|
761
|
+
* Run this Canvas root after the referenced Canvas root id(s).
|
|
762
|
+
*/
|
|
763
|
+
after?: string | string[]
|
|
764
|
+
/**
|
|
765
|
+
* Numeric root order. Lower values run first.
|
|
727
766
|
*/
|
|
728
|
-
|
|
767
|
+
order?: number
|
|
729
768
|
/**
|
|
730
|
-
* Limit this
|
|
769
|
+
* Limit this Canvas's default render job (frames per second).
|
|
731
770
|
*/
|
|
732
771
|
fps?: number
|
|
733
772
|
}
|
|
@@ -1175,7 +1214,33 @@ declare global {
|
|
|
1175
1214
|
* ergonomics. The result is three's structural type, so members stay in sync with the
|
|
1176
1215
|
* installed three instead of needing to be mirrored by hand.
|
|
1177
1216
|
*/
|
|
1178
|
-
type UniformNode<T = unknown> = three_webgpu.UniformNode<
|
|
1217
|
+
type UniformNode<T = unknown> = three_webgpu.UniformNode<UniformNodeTypeFor<T>, T>
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* three's node type name for a uniform value type, mirroring the `uniform()` overloads.
|
|
1221
|
+
* A `UniformNode<number>` is a `Node<'float'>`, so TSL math (`.mul`, `.add`, ...) accepts it.
|
|
1222
|
+
* Unknown or unlisted value types resolve to `unknown`, which TSL math rejects: narrow with
|
|
1223
|
+
* `as UniformNode<number>` (or the matching value type) at the call site.
|
|
1224
|
+
*/
|
|
1225
|
+
type UniformNodeTypeFor<T> = T extends number
|
|
1226
|
+
? 'float'
|
|
1227
|
+
: T extends boolean
|
|
1228
|
+
? 'bool'
|
|
1229
|
+
: T extends three_webgpu.Color
|
|
1230
|
+
? 'color'
|
|
1231
|
+
: T extends three_webgpu.Vector2
|
|
1232
|
+
? 'vec2'
|
|
1233
|
+
: T extends three_webgpu.Vector3
|
|
1234
|
+
? 'vec3'
|
|
1235
|
+
: T extends three_webgpu.Vector4
|
|
1236
|
+
? 'vec4'
|
|
1237
|
+
: T extends three_webgpu.Matrix2
|
|
1238
|
+
? 'mat2'
|
|
1239
|
+
: T extends three_webgpu.Matrix3
|
|
1240
|
+
? 'mat3'
|
|
1241
|
+
: T extends three_webgpu.Matrix4
|
|
1242
|
+
? 'mat4'
|
|
1243
|
+
: unknown
|
|
1179
1244
|
|
|
1180
1245
|
/**
|
|
1181
1246
|
* ShaderCallable - the return type of Fn()
|
|
@@ -1328,30 +1393,97 @@ declare global {
|
|
|
1328
1393
|
*/
|
|
1329
1394
|
type ThreeRenderPipeline = three_webgpu.RenderPipeline
|
|
1330
1395
|
|
|
1331
|
-
/**
|
|
1332
|
-
|
|
1396
|
+
/**
|
|
1397
|
+
* The pass `useRenderPipeline` creates for you: three's own `PassNode`, as returned by
|
|
1398
|
+
* `pass(scene, camera)` from `three/tsl`. Referenced from three so members like
|
|
1399
|
+
* `getTextureNode`, `setMRT` and `dispose` track the installed version.
|
|
1400
|
+
*/
|
|
1401
|
+
type ScenePassNode = three_webgpu.PassNode
|
|
1402
|
+
|
|
1403
|
+
/**
|
|
1404
|
+
* Pass record - stores TSL pass nodes for render pipeline.
|
|
1405
|
+
*
|
|
1406
|
+
* `scenePass` is the only key the library owns. It is optional here because this is also the
|
|
1407
|
+
* shape of `state.passes`, which is `{}` before the pipeline exists and again after `reset()`
|
|
1408
|
+
* or `clearPasses()`. Inside the callbacks it is always present; see
|
|
1409
|
+
* {@link RenderPipelineCallbackState}.
|
|
1410
|
+
*
|
|
1411
|
+
* Every other key is user-registered, via a callback's return value. Those are TSL nodes of
|
|
1412
|
+
* any kind, not only passes: texture reads of an MRT attachment, effect nodes, extra
|
|
1413
|
+
* `pass()` instances. `Node` is the common base, so that is the bound. Narrow at the call
|
|
1414
|
+
* site when you need a member, e.g. `passes.velocity as TextureNode`.
|
|
1415
|
+
*/
|
|
1416
|
+
interface PassRecord {
|
|
1417
|
+
scenePass?: ScenePassNode
|
|
1418
|
+
[key: string]: three_webgpu.Node
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* State passed to pipeline callbacks after the active pipeline has been created.
|
|
1423
|
+
*
|
|
1424
|
+
* `passes.scenePass` is required here: the hook installs the default scene pass before either
|
|
1425
|
+
* callback runs, so callbacks can use it without a guard or a cast.
|
|
1426
|
+
*
|
|
1427
|
+
* `renderer` is narrowed to `WebGPURenderer` and `isLegacy` to `false`: the hook throws under
|
|
1428
|
+
* the legacy renderer before either callback can run, so a callback never sees WebGL.
|
|
1429
|
+
*/
|
|
1430
|
+
type RenderPipelineCallbackState = RootState & {
|
|
1431
|
+
renderPipeline: ThreeRenderPipeline
|
|
1432
|
+
passes: PassRecord & { scenePass: ScenePassNode }
|
|
1433
|
+
renderer: three_webgpu.WebGPURenderer
|
|
1434
|
+
isLegacy: false
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* What a callback may return to register entries into `state.passes`.
|
|
1439
|
+
*
|
|
1440
|
+
* `scenePass` is reserved. The hook owns that entry and its lifecycle: it caches the pass it
|
|
1441
|
+
* created, and `rebuild()` / `reset()` dispose that cached pass. A callback overwriting the
|
|
1442
|
+
* store entry would leave the store pointing at a node the hook never disposes, and the hook
|
|
1443
|
+
* disposing a pass nothing references. So returning it is a type error.
|
|
1444
|
+
*/
|
|
1445
|
+
type RegisteredPasses = Record<string, three_webgpu.Node> & { scenePass?: never }
|
|
1333
1446
|
|
|
1334
1447
|
/** Setup callback - runs first to configure MRT, create additional passes */
|
|
1335
|
-
type RenderPipelineSetupCallback = (state:
|
|
1448
|
+
type RenderPipelineSetupCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1336
1449
|
|
|
1337
1450
|
/** Main callback - runs second to configure outputNode, create effect passes */
|
|
1338
|
-
type RenderPipelineMainCallback = (state:
|
|
1451
|
+
type RenderPipelineMainCallback = (state: RenderPipelineCallbackState) => RegisteredPasses | void
|
|
1339
1452
|
|
|
1340
|
-
/**
|
|
1341
|
-
interface
|
|
1453
|
+
/** The imperative half of useRenderPipeline's return value, present in every state */
|
|
1454
|
+
interface UseRenderPipelineActions {
|
|
1342
1455
|
/** Current passes from state */
|
|
1343
1456
|
passes: PassRecord
|
|
1344
|
-
/** RenderPipeline instance (null if not initialized) */
|
|
1345
|
-
renderPipeline: ThreeRenderPipeline | null
|
|
1346
1457
|
/** Clear all passes from state */
|
|
1347
1458
|
clearPasses: () => void
|
|
1348
1459
|
/** Reset RenderPipeline entirely (clears PP + passes) */
|
|
1349
1460
|
reset: () => void
|
|
1350
1461
|
/** Re-run setup/main callbacks with current closure values */
|
|
1351
1462
|
rebuild: () => void
|
|
1352
|
-
/** True when RenderPipeline is configured and ready */
|
|
1353
|
-
isReady: boolean
|
|
1354
1463
|
}
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* Return type for useRenderPipeline hook, discriminated on `isReady`.
|
|
1467
|
+
*
|
|
1468
|
+
* `if (isReady)` narrows `renderPipeline` to non-null, which is what the docs already tell
|
|
1469
|
+
* callers to check. `passes.scenePass` deliberately stays optional in the ready branch:
|
|
1470
|
+
* `clearPasses()` empties the record while leaving the pipeline in place.
|
|
1471
|
+
*/
|
|
1472
|
+
type UseRenderPipelineReturn = UseRenderPipelineActions &
|
|
1473
|
+
(
|
|
1474
|
+
| {
|
|
1475
|
+
/** True when RenderPipeline is configured and ready */
|
|
1476
|
+
isReady: true
|
|
1477
|
+
/** RenderPipeline instance */
|
|
1478
|
+
renderPipeline: ThreeRenderPipeline
|
|
1479
|
+
}
|
|
1480
|
+
| {
|
|
1481
|
+
/** False until the pipeline has been created */
|
|
1482
|
+
isReady: false
|
|
1483
|
+
/** Not initialized yet, or torn down by reset() */
|
|
1484
|
+
renderPipeline: null
|
|
1485
|
+
}
|
|
1486
|
+
)
|
|
1355
1487
|
}
|
|
1356
1488
|
|
|
1357
1489
|
type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>
|
|
@@ -3769,4 +3901,4 @@ declare function isOnce(value: unknown): value is {
|
|
|
3769
3901
|
declare function Canvas(props: CanvasProps): react_jsx_runtime.JSX.Element;
|
|
3770
3902
|
|
|
3771
3903
|
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 };
|
|
3772
|
-
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeProps, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|
|
3904
|
+
export type { Act, Args, ArgsProp, AttachFnType, AttachType, BackgroundConfig, BackgroundProp, BaseRendererProps, Bridge, BufferLike, BufferRecord, BufferStore, Camera, CameraProps, CanvasProps, CanvasSchedulerConfig, Catalogue, Color, ColorManagementConfig, ComputeFunction, ConstructorRepresentation, DefaultGLProps, DefaultRendererProps, Disposable, DisposeOptions, DomEvent, Dpr, ElementProps, EnvironmentLoaderProps, EnvironmentProps, EquConfig, Euler, EventHandlers, EventManager, EventProps, Events, Extensions, FiberRoot, FilterFunction, FrameCallback, FrameNextCallback, FrameNextState, FrameState, Frameloop, GLProps, GLTFLike, GeometryProps, GeometryTransformProps, GlobalEffectType, GlobalRenderCallback, HostConfig, InferLoadResult, InjectState, InputLike, Instance, InstanceProps, InternalState, Intersection, IntersectionEvent, IsAllOptional, IsOptional, Layers, LegacyInternalState, LegacyRenderer, LegacyRootState, LoaderInstance, LoaderLike, LoaderResult, MappedTextureType, MathProps, MathRepresentation, MathType, MathTypes, Matrix3, Matrix4, Mutable, MutableOrReadonlyParameters, NodeLike, NodeProps, NodeRecord, NodeStore, NonFunctionKeys, ObjectMap, OffscreenCanvas$1 as OffscreenCanvas, Overwrite, Performance, PointerCaptureTarget, PointerState, PresetsType, PrimaryCanvasEntry, Properties, Quaternion, R3FRenderer, RaycastableRepresentation, ReactProps, ReconcilerRoot, RenderCallback, RenderProps, RenderTargetOptions, Renderer, RendererConfigExtended, RendererFactory, RendererProps, Root, RootState, RootStore, SetBlock, Size, StorageLike, StorageRecord, StorageStore, Subscription, TSLNodeInput, TextureInput, TextureResult, ThreeCamera, ThreeElement, ThreeElements, ThreeElementsImpl, ThreeEvent, ThreeExports, ThreeToJSXElements, UnblockProps, UseTextureOptions, UseTexturesReturn, Vector2, Vector3, Vector4, VectorRepresentation, Viewport, VisibilityEntry, WebGLDefaultProps, WebGLProps, WebGLShadowConfig, XRManager, XRPointerConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1048,7 +1048,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1048
1048
|
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1049
1049
|
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1050
1050
|
resizeTarget.setSize(size.width, size.height, false);
|
|
1051
|
-
|
|
1051
|
+
const activeTarget = actualRenderer.getCanvasTarget?.();
|
|
1052
|
+
if (!canvasTarget || activeTarget !== canvasTarget) internal.canvasTargetSizeDirty = true;
|
|
1052
1053
|
}
|
|
1053
1054
|
if (camera !== oldCamera) {
|
|
1054
1055
|
oldCamera = camera;
|
|
@@ -1696,7 +1697,7 @@ function advance(timestamp, runGlobalEffects, state) {
|
|
|
1696
1697
|
else scheduler.step(timestamp);
|
|
1697
1698
|
}
|
|
1698
1699
|
|
|
1699
|
-
const version = "10.0.0-alpha.
|
|
1700
|
+
const version = "10.0.0-alpha.4";
|
|
1700
1701
|
const packageData = {
|
|
1701
1702
|
version: version};
|
|
1702
1703
|
|
|
@@ -14230,9 +14231,8 @@ function createRoot(canvas) {
|
|
|
14230
14231
|
if (!renderer.hasInitialized?.()) {
|
|
14231
14232
|
const size2 = computeInitialSize(canvas, propsSize);
|
|
14232
14233
|
if (size2.width > 0 && size2.height > 0) {
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
canvas.height = size2.height * pixelRatio;
|
|
14234
|
+
renderer.setPixelRatio(calculateDpr(dpr));
|
|
14235
|
+
renderer.setSize(size2.width, size2.height, false);
|
|
14236
14236
|
}
|
|
14237
14237
|
await renderer.init();
|
|
14238
14238
|
}
|
|
@@ -14241,7 +14241,7 @@ function createRoot(canvas) {
|
|
|
14241
14241
|
state.internal.actualRenderer = renderer;
|
|
14242
14242
|
state.set({ webGPUSupported: isWebGPUBackend, renderer, primaryStore: store });
|
|
14243
14243
|
if (canvasId && !state.internal.isSecondary) {
|
|
14244
|
-
const canvasTarget =
|
|
14244
|
+
const canvasTarget = renderer.getCanvasTarget?.();
|
|
14245
14245
|
const unregisterPrimary = registerPrimary(canvasId, renderer, store);
|
|
14246
14246
|
state.set((prev) => ({
|
|
14247
14247
|
internal: {
|
|
@@ -14446,14 +14446,18 @@ function createRoot(canvas) {
|
|
|
14446
14446
|
const unregisterRoot = scheduler.registerRoot(newRootId, {
|
|
14447
14447
|
getState: () => store.getState(),
|
|
14448
14448
|
onError: (err) => store.getState().setError(err),
|
|
14449
|
-
frameloop: store.getState().frameloop
|
|
14449
|
+
frameloop: store.getState().frameloop,
|
|
14450
|
+
before: schedulerConfig?.before,
|
|
14451
|
+
after: schedulerConfig?.after,
|
|
14452
|
+
order: schedulerConfig?.order
|
|
14450
14453
|
});
|
|
14451
14454
|
const unregisterCanvasTarget = scheduler.register(
|
|
14452
14455
|
() => {
|
|
14453
14456
|
const state2 = store.getState();
|
|
14454
|
-
|
|
14457
|
+
const canvasTarget = state2.internal.canvasTarget;
|
|
14458
|
+
if (canvasTarget) {
|
|
14455
14459
|
const renderer2 = state2.internal.actualRenderer;
|
|
14456
|
-
renderer2.setCanvasTarget(
|
|
14460
|
+
if (renderer2.getCanvasTarget() !== canvasTarget) renderer2.setCanvasTarget(canvasTarget);
|
|
14457
14461
|
if (state2.internal.canvasTargetSizeDirty) {
|
|
14458
14462
|
state2.internal.canvasTargetSizeDirty = false;
|
|
14459
14463
|
renderer2.backend?.updateSize?.();
|
|
@@ -14526,8 +14530,7 @@ function createRoot(canvas) {
|
|
|
14526
14530
|
phase: "render",
|
|
14527
14531
|
system: true,
|
|
14528
14532
|
// Internal flag: this is a system job, not user-controlled
|
|
14529
|
-
//
|
|
14530
|
-
...schedulerConfig?.after && { after: schedulerConfig.after },
|
|
14533
|
+
// FPS throttles only the default render job; Canvas ordering belongs to the root.
|
|
14531
14534
|
...schedulerConfig?.fps && { fps: schedulerConfig.fps }
|
|
14532
14535
|
}
|
|
14533
14536
|
);
|
|
@@ -14546,7 +14549,21 @@ function createRoot(canvas) {
|
|
|
14546
14549
|
scheduler
|
|
14547
14550
|
}
|
|
14548
14551
|
}));
|
|
14552
|
+
} else {
|
|
14553
|
+
const constraintsChanged = !is.equ(schedulerConfig?.before, lastConfiguredProps.schedulerBefore, shallowLoose) || !is.equ(schedulerConfig?.after, lastConfiguredProps.schedulerAfter, shallowLoose);
|
|
14554
|
+
if (constraintsChanged) {
|
|
14555
|
+
scheduler.setRootConstraints(rootId, {
|
|
14556
|
+
before: schedulerConfig?.before,
|
|
14557
|
+
after: schedulerConfig?.after
|
|
14558
|
+
});
|
|
14559
|
+
}
|
|
14560
|
+
if (schedulerConfig?.order !== lastConfiguredProps.schedulerOrder) {
|
|
14561
|
+
scheduler.setRootOrder(rootId, schedulerConfig?.order ?? 0);
|
|
14562
|
+
}
|
|
14549
14563
|
}
|
|
14564
|
+
lastConfiguredProps.schedulerBefore = schedulerConfig?.before;
|
|
14565
|
+
lastConfiguredProps.schedulerAfter = schedulerConfig?.after;
|
|
14566
|
+
lastConfiguredProps.schedulerOrder = schedulerConfig?.order;
|
|
14550
14567
|
onCreated = onCreatedCallback;
|
|
14551
14568
|
configured = true;
|
|
14552
14569
|
resolve();
|
|
@@ -14604,7 +14621,7 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14604
14621
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14605
14622
|
if (unregisterPrimary) unregisterPrimary();
|
|
14606
14623
|
const canvasTarget = state.internal.canvasTarget;
|
|
14607
|
-
if (canvasTarget?.dispose) canvasTarget.dispose();
|
|
14624
|
+
if (state.internal.isSecondary && canvasTarget?.dispose) canvasTarget.dispose();
|
|
14608
14625
|
state.events.disconnect?.();
|
|
14609
14626
|
cleanupHelperGroup(root.store);
|
|
14610
14627
|
if (state.isLegacy && renderer) {
|
|
@@ -15048,9 +15065,9 @@ function CanvasImpl({
|
|
|
15048
15065
|
React.useMemo(() => extend(THREE), []);
|
|
15049
15066
|
const Bridge = useBridge();
|
|
15050
15067
|
const backgroundProps = React.useMemo(() => parseBackground(background), [background]);
|
|
15051
|
-
const
|
|
15068
|
+
const [hasInitialSize, setHasInitialSize] = React.useState(false);
|
|
15052
15069
|
const measureConfig = React.useMemo(() => {
|
|
15053
|
-
if (!
|
|
15070
|
+
if (!hasInitialSize) {
|
|
15054
15071
|
return {
|
|
15055
15072
|
...resize,
|
|
15056
15073
|
scroll: resize?.scroll ?? true,
|
|
@@ -15062,7 +15079,7 @@ function CanvasImpl({
|
|
|
15062
15079
|
debounce: { scroll: 50, resize: 0 },
|
|
15063
15080
|
...resize
|
|
15064
15081
|
};
|
|
15065
|
-
}, [
|
|
15082
|
+
}, [hasInitialSize, resize]);
|
|
15066
15083
|
const [containerRef, containerRect] = useMeasure(measureConfig);
|
|
15067
15084
|
const effectiveSize = React.useMemo(() => {
|
|
15068
15085
|
let w = width ?? containerRect.width;
|
|
@@ -15078,9 +15095,7 @@ function CanvasImpl({
|
|
|
15078
15095
|
left: containerRect.left
|
|
15079
15096
|
};
|
|
15080
15097
|
}, [width, height, containerRect, forceEven]);
|
|
15081
|
-
if (!
|
|
15082
|
-
hasInitialSizeRef.current = true;
|
|
15083
|
-
}
|
|
15098
|
+
if (!hasInitialSize && effectiveSize.width > 0 && effectiveSize.height > 0) setHasInitialSize(true);
|
|
15084
15099
|
const canvasRef = React.useRef(null);
|
|
15085
15100
|
const divRef = React.useRef(null);
|
|
15086
15101
|
React.useImperativeHandle(ref, () => canvasRef.current);
|
package/dist/legacy.cjs
CHANGED
|
@@ -1072,7 +1072,8 @@ const createStore = (invalidate, advance) => {
|
|
|
1072
1072
|
const resizeTarget = canvasTarget ?? actualRenderer;
|
|
1073
1073
|
if (viewport.dpr > 0) resizeTarget.setPixelRatio(viewport.dpr);
|
|
1074
1074
|
resizeTarget.setSize(size.width, size.height, false);
|
|
1075
|
-
|
|
1075
|
+
const activeTarget = actualRenderer.getCanvasTarget?.();
|
|
1076
|
+
if (!canvasTarget || activeTarget !== canvasTarget) internal.canvasTargetSizeDirty = true;
|
|
1076
1077
|
}
|
|
1077
1078
|
if (camera !== oldCamera) {
|
|
1078
1079
|
oldCamera = camera;
|
|
@@ -1718,7 +1719,7 @@ function advance(timestamp, runGlobalEffects, state) {
|
|
|
1718
1719
|
else scheduler$1.step(timestamp);
|
|
1719
1720
|
}
|
|
1720
1721
|
|
|
1721
|
-
const version = "10.0.0-alpha.
|
|
1722
|
+
const version = "10.0.0-alpha.4";
|
|
1722
1723
|
const packageData = {
|
|
1723
1724
|
version: version};
|
|
1724
1725
|
|
|
@@ -14421,14 +14422,18 @@ function createRoot(canvas) {
|
|
|
14421
14422
|
const unregisterRoot = scheduler$1.registerRoot(newRootId, {
|
|
14422
14423
|
getState: () => store.getState(),
|
|
14423
14424
|
onError: (err) => store.getState().setError(err),
|
|
14424
|
-
frameloop: store.getState().frameloop
|
|
14425
|
+
frameloop: store.getState().frameloop,
|
|
14426
|
+
before: schedulerConfig?.before,
|
|
14427
|
+
after: schedulerConfig?.after,
|
|
14428
|
+
order: schedulerConfig?.order
|
|
14425
14429
|
});
|
|
14426
14430
|
const unregisterCanvasTarget = scheduler$1.register(
|
|
14427
14431
|
() => {
|
|
14428
14432
|
const state2 = store.getState();
|
|
14429
|
-
|
|
14433
|
+
const canvasTarget = state2.internal.canvasTarget;
|
|
14434
|
+
if (canvasTarget) {
|
|
14430
14435
|
const renderer2 = state2.internal.actualRenderer;
|
|
14431
|
-
renderer2.setCanvasTarget(
|
|
14436
|
+
if (renderer2.getCanvasTarget() !== canvasTarget) renderer2.setCanvasTarget(canvasTarget);
|
|
14432
14437
|
if (state2.internal.canvasTargetSizeDirty) {
|
|
14433
14438
|
state2.internal.canvasTargetSizeDirty = false;
|
|
14434
14439
|
renderer2.backend?.updateSize?.();
|
|
@@ -14501,8 +14506,7 @@ function createRoot(canvas) {
|
|
|
14501
14506
|
phase: "render",
|
|
14502
14507
|
system: true,
|
|
14503
14508
|
// Internal flag: this is a system job, not user-controlled
|
|
14504
|
-
//
|
|
14505
|
-
...schedulerConfig?.after && { after: schedulerConfig.after },
|
|
14509
|
+
// FPS throttles only the default render job; Canvas ordering belongs to the root.
|
|
14506
14510
|
...schedulerConfig?.fps && { fps: schedulerConfig.fps }
|
|
14507
14511
|
}
|
|
14508
14512
|
);
|
|
@@ -14521,7 +14525,21 @@ function createRoot(canvas) {
|
|
|
14521
14525
|
scheduler: scheduler$1
|
|
14522
14526
|
}
|
|
14523
14527
|
}));
|
|
14528
|
+
} else {
|
|
14529
|
+
const constraintsChanged = !is.equ(schedulerConfig?.before, lastConfiguredProps.schedulerBefore, shallowLoose) || !is.equ(schedulerConfig?.after, lastConfiguredProps.schedulerAfter, shallowLoose);
|
|
14530
|
+
if (constraintsChanged) {
|
|
14531
|
+
scheduler$1.setRootConstraints(rootId, {
|
|
14532
|
+
before: schedulerConfig?.before,
|
|
14533
|
+
after: schedulerConfig?.after
|
|
14534
|
+
});
|
|
14535
|
+
}
|
|
14536
|
+
if (schedulerConfig?.order !== lastConfiguredProps.schedulerOrder) {
|
|
14537
|
+
scheduler$1.setRootOrder(rootId, schedulerConfig?.order ?? 0);
|
|
14538
|
+
}
|
|
14524
14539
|
}
|
|
14540
|
+
lastConfiguredProps.schedulerBefore = schedulerConfig?.before;
|
|
14541
|
+
lastConfiguredProps.schedulerAfter = schedulerConfig?.after;
|
|
14542
|
+
lastConfiguredProps.schedulerOrder = schedulerConfig?.order;
|
|
14525
14543
|
onCreated = onCreatedCallback;
|
|
14526
14544
|
configured = true;
|
|
14527
14545
|
resolve();
|
|
@@ -14579,7 +14597,7 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
14579
14597
|
const unregisterPrimary = state.internal.unregisterPrimary;
|
|
14580
14598
|
if (unregisterPrimary) unregisterPrimary();
|
|
14581
14599
|
const canvasTarget = state.internal.canvasTarget;
|
|
14582
|
-
if (canvasTarget?.dispose) canvasTarget.dispose();
|
|
14600
|
+
if (state.internal.isSecondary && canvasTarget?.dispose) canvasTarget.dispose();
|
|
14583
14601
|
state.events.disconnect?.();
|
|
14584
14602
|
cleanupHelperGroup(root.store);
|
|
14585
14603
|
if (state.isLegacy && renderer) {
|
|
@@ -15023,9 +15041,9 @@ function CanvasImpl({
|
|
|
15023
15041
|
React__namespace.useMemo(() => extend(THREE), []);
|
|
15024
15042
|
const Bridge = useBridge();
|
|
15025
15043
|
const backgroundProps = React__namespace.useMemo(() => parseBackground(background), [background]);
|
|
15026
|
-
const
|
|
15044
|
+
const [hasInitialSize, setHasInitialSize] = React__namespace.useState(false);
|
|
15027
15045
|
const measureConfig = React__namespace.useMemo(() => {
|
|
15028
|
-
if (!
|
|
15046
|
+
if (!hasInitialSize) {
|
|
15029
15047
|
return {
|
|
15030
15048
|
...resize,
|
|
15031
15049
|
scroll: resize?.scroll ?? true,
|
|
@@ -15037,7 +15055,7 @@ function CanvasImpl({
|
|
|
15037
15055
|
debounce: { scroll: 50, resize: 0 },
|
|
15038
15056
|
...resize
|
|
15039
15057
|
};
|
|
15040
|
-
}, [
|
|
15058
|
+
}, [hasInitialSize, resize]);
|
|
15041
15059
|
const [containerRef, containerRect] = useMeasure__default(measureConfig);
|
|
15042
15060
|
const effectiveSize = React__namespace.useMemo(() => {
|
|
15043
15061
|
let w = width ?? containerRect.width;
|
|
@@ -15053,9 +15071,7 @@ function CanvasImpl({
|
|
|
15053
15071
|
left: containerRect.left
|
|
15054
15072
|
};
|
|
15055
15073
|
}, [width, height, containerRect, forceEven]);
|
|
15056
|
-
if (!
|
|
15057
|
-
hasInitialSizeRef.current = true;
|
|
15058
|
-
}
|
|
15074
|
+
if (!hasInitialSize && effectiveSize.width > 0 && effectiveSize.height > 0) setHasInitialSize(true);
|
|
15059
15075
|
const canvasRef = React__namespace.useRef(null);
|
|
15060
15076
|
const divRef = React__namespace.useRef(null);
|
|
15061
15077
|
React__namespace.useImperativeHandle(ref, () => canvasRef.current);
|