@react-three/fiber 9.5.0 → 9.6.0

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +1198 -1192
  2. package/dist/declarations/src/core/events.d.ts +92 -92
  3. package/dist/declarations/src/core/hooks.d.ts +53 -53
  4. package/dist/declarations/src/core/index.d.ts +13 -13
  5. package/dist/declarations/src/core/loop.d.ts +31 -31
  6. package/dist/declarations/src/core/reconciler.d.ts +50 -50
  7. package/dist/declarations/src/core/renderer.d.ts +89 -89
  8. package/dist/declarations/src/core/store.d.ts +130 -130
  9. package/dist/declarations/src/core/utils.d.ts +262 -262
  10. package/dist/declarations/src/index.d.ts +6 -6
  11. package/dist/declarations/src/native/Canvas.d.ts +13 -13
  12. package/dist/declarations/src/native/events.d.ts +4 -4
  13. package/dist/declarations/src/native.d.ts +6 -6
  14. package/dist/declarations/src/three-types.d.ts +68 -68
  15. package/dist/declarations/src/web/Canvas.d.ts +23 -23
  16. package/dist/declarations/src/web/events.d.ts +4 -4
  17. package/dist/{events-238e0986.cjs.prod.js → events-11ca7a92.cjs.prod.js} +100 -87
  18. package/dist/{events-358c3764.cjs.dev.js → events-508aad4b.cjs.dev.js} +100 -87
  19. package/dist/{events-5a94e5eb.esm.js → events-760a1017.esm.js} +100 -87
  20. package/dist/react-three-fiber.cjs.dev.js +4 -4
  21. package/dist/react-three-fiber.cjs.prod.js +4 -4
  22. package/dist/react-three-fiber.esm.js +5 -5
  23. package/native/dist/react-three-fiber-native.cjs.dev.js +4 -4
  24. package/native/dist/react-three-fiber-native.cjs.prod.js +4 -4
  25. package/native/dist/react-three-fiber-native.esm.js +5 -5
  26. package/native/package.json +5 -5
  27. package/package.json +1 -1
  28. package/readme.md +253 -253
@@ -1,68 +1,68 @@
1
- import type * as THREE from 'three';
2
- import type { Args, EventHandlers, InstanceProps, ConstructorRepresentation } from "./core/index.js";
3
- import type { Overwrite, Mutable } from "./core/utils.js";
4
- type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>;
5
- export interface MathRepresentation {
6
- set(...args: number[]): any;
7
- }
8
- export interface VectorRepresentation extends MathRepresentation {
9
- setScalar(value: number): any;
10
- }
11
- export type MathTypes = MathRepresentation | THREE.Euler | THREE.Color;
12
- export type MathType<T extends MathTypes> = T extends THREE.Color ? Args<typeof THREE.Color> | THREE.ColorRepresentation : T extends VectorRepresentation | THREE.Layers | THREE.Euler ? T | MutableOrReadonlyParameters<T['set']> | number : T | MutableOrReadonlyParameters<T['set']>;
13
- export type MathProps<P> = {
14
- [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never;
15
- };
16
- export type Vector2 = MathType<THREE.Vector2>;
17
- export type Vector3 = MathType<THREE.Vector3>;
18
- export type Vector4 = MathType<THREE.Vector4>;
19
- export type Color = MathType<THREE.Color>;
20
- export type Layers = MathType<THREE.Layers>;
21
- export type Quaternion = MathType<THREE.Quaternion>;
22
- export type Euler = MathType<THREE.Euler>;
23
- export type Matrix3 = MathType<THREE.Matrix3>;
24
- export type Matrix4 = MathType<THREE.Matrix4>;
25
- export interface RaycastableRepresentation {
26
- raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
27
- }
28
- export type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {};
29
- export interface ReactProps<P> {
30
- children?: React.ReactNode;
31
- ref?: React.Ref<P>;
32
- key?: React.Key;
33
- }
34
- export type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P>>>;
35
- export type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
36
- export type ThreeToJSXElements<T extends Record<string, any>> = {
37
- [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never;
38
- };
39
- type ThreeExports = typeof THREE;
40
- type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>;
41
- export interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
42
- primitive: Omit<ThreeElement<any>, 'args'> & {
43
- object: object;
44
- };
45
- threeAudio: ThreeElementsImpl['audio'];
46
- threeSource: ThreeElementsImpl['source'];
47
- threeLine: ThreeElementsImpl['line'];
48
- threePath: ThreeElementsImpl['path'];
49
- }
50
- declare module 'react' {
51
- namespace JSX {
52
- interface IntrinsicElements extends ThreeElements {
53
- }
54
- }
55
- }
56
- declare module 'react/jsx-runtime' {
57
- namespace JSX {
58
- interface IntrinsicElements extends ThreeElements {
59
- }
60
- }
61
- }
62
- declare module 'react/jsx-dev-runtime' {
63
- namespace JSX {
64
- interface IntrinsicElements extends ThreeElements {
65
- }
66
- }
67
- }
68
- export {};
1
+ import type * as THREE from 'three';
2
+ import type { Args, EventHandlers, InstanceProps, ConstructorRepresentation } from "./core/index.js";
3
+ import type { Overwrite, Mutable } from "./core/utils.js";
4
+ type MutableOrReadonlyParameters<T extends (...args: any) => any> = Parameters<T> | Readonly<Parameters<T>>;
5
+ export interface MathRepresentation {
6
+ set(...args: number[]): any;
7
+ }
8
+ export interface VectorRepresentation extends MathRepresentation {
9
+ setScalar(value: number): any;
10
+ }
11
+ export type MathTypes = MathRepresentation | THREE.Euler | THREE.Color;
12
+ export type MathType<T extends MathTypes> = T extends THREE.Color ? Args<typeof THREE.Color> | THREE.ColorRepresentation : T extends VectorRepresentation | THREE.Layers | THREE.Euler ? T | MutableOrReadonlyParameters<T['set']> | number : T | MutableOrReadonlyParameters<T['set']>;
13
+ export type MathProps<P> = {
14
+ [K in keyof P as P[K] extends MathTypes ? K : never]: P[K] extends MathTypes ? MathType<P[K]> : never;
15
+ };
16
+ export type Vector2 = MathType<THREE.Vector2>;
17
+ export type Vector3 = MathType<THREE.Vector3>;
18
+ export type Vector4 = MathType<THREE.Vector4>;
19
+ export type Color = MathType<THREE.Color>;
20
+ export type Layers = MathType<THREE.Layers>;
21
+ export type Quaternion = MathType<THREE.Quaternion>;
22
+ export type Euler = MathType<THREE.Euler>;
23
+ export type Matrix3 = MathType<THREE.Matrix3>;
24
+ export type Matrix4 = MathType<THREE.Matrix4>;
25
+ export interface RaycastableRepresentation {
26
+ raycast(raycaster: THREE.Raycaster, intersects: THREE.Intersection[]): void;
27
+ }
28
+ export type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : {};
29
+ export interface ReactProps<P> {
30
+ children?: React.ReactNode;
31
+ ref?: React.Ref<P>;
32
+ key?: React.Key;
33
+ }
34
+ export type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P>>>;
35
+ export type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
36
+ export type ThreeToJSXElements<T extends Record<string, any>> = {
37
+ [K in keyof T & string as Uncapitalize<K>]: T[K] extends ConstructorRepresentation ? ThreeElement<T[K]> : never;
38
+ };
39
+ type ThreeExports = typeof THREE;
40
+ type ThreeElementsImpl = ThreeToJSXElements<ThreeExports>;
41
+ export interface ThreeElements extends Omit<ThreeElementsImpl, 'audio' | 'source' | 'line' | 'path'> {
42
+ primitive: Omit<ThreeElement<any>, 'args'> & {
43
+ object: object;
44
+ };
45
+ threeAudio: ThreeElementsImpl['audio'];
46
+ threeSource: ThreeElementsImpl['source'];
47
+ threeLine: ThreeElementsImpl['line'];
48
+ threePath: ThreeElementsImpl['path'];
49
+ }
50
+ declare module 'react' {
51
+ namespace JSX {
52
+ interface IntrinsicElements extends ThreeElements {
53
+ }
54
+ }
55
+ }
56
+ declare module 'react/jsx-runtime' {
57
+ namespace JSX {
58
+ interface IntrinsicElements extends ThreeElements {
59
+ }
60
+ }
61
+ }
62
+ declare module 'react/jsx-dev-runtime' {
63
+ namespace JSX {
64
+ interface IntrinsicElements extends ThreeElements {
65
+ }
66
+ }
67
+ }
68
+ export {};
@@ -1,23 +1,23 @@
1
- import * as React from 'react';
2
- import { Options as ResizeOptions } from 'react-use-measure';
3
- import { RenderProps } from "../core/index.js";
4
- export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
- children?: React.ReactNode;
6
- ref?: React.Ref<HTMLCanvasElement>;
7
- /** Canvas fallback content, similar to img's alt prop */
8
- fallback?: React.ReactNode;
9
- /**
10
- * Options to pass to useMeasure.
11
- * @see https://github.com/pmndrs/react-use-measure#api
12
- */
13
- resize?: ResizeOptions;
14
- /** The target where events are being subscribed to, default: the div that wraps canvas */
15
- eventSource?: HTMLElement | React.RefObject<HTMLElement>;
16
- /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
17
- eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
18
- }
19
- /**
20
- * A DOM canvas which accepts threejs elements as children.
21
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
22
- */
23
- export declare function Canvas(props: CanvasProps): import("react/jsx-runtime").JSX.Element;
1
+ import * as React from 'react';
2
+ import { Options as ResizeOptions } from 'react-use-measure';
3
+ import { RenderProps } from "../core/index.js";
4
+ export interface CanvasProps extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
+ children?: React.ReactNode;
6
+ ref?: React.Ref<HTMLCanvasElement>;
7
+ /** Canvas fallback content, similar to img's alt prop */
8
+ fallback?: React.ReactNode;
9
+ /**
10
+ * Options to pass to useMeasure.
11
+ * @see https://github.com/pmndrs/react-use-measure#api
12
+ */
13
+ resize?: ResizeOptions;
14
+ /** The target where events are being subscribed to, default: the div that wraps canvas */
15
+ eventSource?: HTMLElement | React.RefObject<HTMLElement>;
16
+ /** The event prefix that is cast into canvas pointer x/y events, default: "offset" */
17
+ eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
18
+ }
19
+ /**
20
+ * A DOM canvas which accepts threejs elements as children.
21
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
22
+ */
23
+ export declare function Canvas(props: CanvasProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { RootStore } from "../core/store.js";
2
- import { EventManager } from "../core/events.js";
3
- /** Default R3F event manager for web */
4
- export declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
1
+ import { RootStore } from "../core/store.js";
2
+ import { EventManager } from "../core/events.js";
3
+ /** Default R3F event manager for web */
4
+ export declare function createPointerEvents(store: RootStore): EventManager<HTMLElement>;
@@ -36,17 +36,17 @@ var threeTypes = /*#__PURE__*/Object.freeze({
36
36
  __proto__: null
37
37
  });
38
38
 
39
- /**
40
- * Returns the instance's initial (outmost) root.
39
+ /**
40
+ * Returns the instance's initial (outmost) root.
41
41
  */
42
42
  function findInitialRoot(instance) {
43
43
  let root = instance.root;
44
44
  while (root.getState().previousRoot) root = root.getState().previousRoot;
45
45
  return root;
46
46
  }
47
- /**
48
- * Safely flush async effects when testing, simulating a legacy root.
49
- * @deprecated Import from React instead. import { act } from 'react'
47
+ /**
48
+ * Safely flush async effects when testing, simulating a legacy root.
49
+ * @deprecated Import from React instead. import { act } from 'react'
50
50
  */
51
51
  // Reference with computed key to break Webpack static analysis
52
52
  // https://github.com/webpack/webpack/issues/14814
@@ -55,14 +55,14 @@ const isOrthographicCamera = def => def && def.isOrthographicCamera;
55
55
  const isRef = obj => obj && obj.hasOwnProperty('current');
56
56
  const isColorRepresentation = value => value != null && (typeof value === 'string' || typeof value === 'number' || value.isColor);
57
57
 
58
- /**
59
- * An SSR-friendly useLayoutEffect.
60
- *
61
- * React currently throws a warning when using useLayoutEffect on the server.
62
- * To get around it, we can conditionally useEffect on the server (no-op) and
63
- * useLayoutEffect elsewhere.
64
- *
65
- * @see https://github.com/facebook/react/issues/14927
58
+ /**
59
+ * An SSR-friendly useLayoutEffect.
60
+ *
61
+ * React currently throws a warning when using useLayoutEffect on the server.
62
+ * To get around it, we can conditionally useEffect on the server (no-op) and
63
+ * useLayoutEffect elsewhere.
64
+ *
65
+ * @see https://github.com/facebook/react/issues/14927
66
66
  */
67
67
  const useIsomorphicLayoutEffect = /* @__PURE__ */((_window$document, _window$navigator) => typeof window !== 'undefined' && (((_window$document = window.document) == null ? void 0 : _window$document.createElement) || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative'))() ? React__namespace.useLayoutEffect : React__namespace.useEffect;
68
68
  function useMutableCallback(fn) {
@@ -70,8 +70,8 @@ function useMutableCallback(fn) {
70
70
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
71
71
  return ref;
72
72
  }
73
- /**
74
- * Bridges renderer Context and StrictMode from a primary renderer.
73
+ /**
74
+ * Bridges renderer Context and StrictMode from a primary renderer.
75
75
  */
76
76
  function useBridge() {
77
77
  const fiber = itsFine.useFiber();
@@ -123,8 +123,8 @@ function calculateDpr(dpr) {
123
123
  return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
124
124
  }
125
125
 
126
- /**
127
- * Returns instance root state
126
+ /**
127
+ * Returns instance root state
128
128
  */
129
129
  function getRootState(obj) {
130
130
  var _r3f;
@@ -449,6 +449,19 @@ function applyProps(object, props) {
449
449
  // Otherwise just set single value
450
450
  else target.set(value);
451
451
  }
452
+ // ShaderMaterial uniforms must keep a stable target reference
453
+ else if (root instanceof THREE__namespace.ShaderMaterial && key === 'uniforms' && is.obj(value)) {
454
+ if (!is.obj(root.uniforms)) root.uniforms = {};
455
+ const uniforms = root.uniforms;
456
+ const nextUniforms = value;
457
+ for (const name in nextUniforms) {
458
+ const uniform = nextUniforms[name];
459
+ const targetUniform = uniforms[name];
460
+ if (targetUniform) Object.assign(targetUniform, uniform);else uniforms[name] = {
461
+ ...uniform
462
+ };
463
+ }
464
+ }
452
465
  // Else, just overwrite the value
453
466
  else {
454
467
  var _root$key;
@@ -514,9 +527,9 @@ function makeId(event) {
514
527
  return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
515
528
  }
516
529
 
517
- /**
518
- * Release pointer captures.
519
- * This is called by releasePointerCapture in the API, and when an object is removed.
530
+ /**
531
+ * Release pointer captures.
532
+ * This is called by releasePointerCapture in the API, and when an object is removed.
520
533
  */
521
534
  function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
522
535
  const captureData = captures.get(obj);
@@ -770,7 +783,7 @@ function createEvents(store) {
770
783
  internal
771
784
  } = store.getState();
772
785
  for (const hoveredObj of internal.hovered.values()) {
773
- // When no objects were hit or the the hovered object wasn't found underneath the cursor
786
+ // When no objects were hit or the hovered object wasn't found underneath the cursor
774
787
  // we call onPointerOut and delete the object from the hovered-elements map
775
788
  if (!intersections.length || !intersections.find(hit => hit.object === hoveredObj.object && hit.index === hoveredObj.index && hit.instanceId === hoveredObj.instanceId)) {
776
789
  const eventObject = hoveredObj.eventObject;
@@ -863,19 +876,19 @@ function createEvents(store) {
863
876
  if (!(instance != null && instance.eventCount)) return;
864
877
  const handlers = instance.handlers;
865
878
 
866
- /*
867
- MAYBE TODO, DELETE IF NOT:
868
- Check if the object is captured, captured events should not have intersects running in parallel
869
- But wouldn't it be better to just replace capturedMap with a single entry?
870
- Also, are we OK with straight up making picking up multiple objects impossible?
871
-
872
- const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
873
- if (pointerId !== undefined) {
874
- const capturedMeshSet = internal.capturedMap.get(pointerId)
875
- if (capturedMeshSet) {
876
- const captured = capturedMeshSet.get(eventObject)
877
- if (captured && captured.localState.stopped) return
878
- }
879
+ /*
880
+ MAYBE TODO, DELETE IF NOT:
881
+ Check if the object is captured, captured events should not have intersects running in parallel
882
+ But wouldn't it be better to just replace capturedMap with a single entry?
883
+ Also, are we OK with straight up making picking up multiple objects impossible?
884
+
885
+ const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
886
+ if (pointerId !== undefined) {
887
+ const capturedMeshSet = internal.capturedMap.get(pointerId)
888
+ if (capturedMeshSet) {
889
+ const captured = capturedMeshSet.get(eventObject)
890
+ if (captured && captured.localState.stopped) return
891
+ }
879
892
  }*/
880
893
 
881
894
  if (isPointerMove) {
@@ -1166,11 +1179,11 @@ const createStore = (invalidate, advance) => {
1166
1179
  return rootStore;
1167
1180
  };
1168
1181
 
1169
- /**
1170
- * Exposes an object's {@link Instance}.
1171
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1172
- *
1173
- * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1182
+ /**
1183
+ * Exposes an object's {@link Instance}.
1184
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1185
+ *
1186
+ * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1174
1187
  */
1175
1188
  function useInstanceHandle(ref) {
1176
1189
  const instance = React__namespace.useRef(null);
@@ -1178,9 +1191,9 @@ function useInstanceHandle(ref) {
1178
1191
  return instance;
1179
1192
  }
1180
1193
 
1181
- /**
1182
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1183
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1194
+ /**
1195
+ * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1196
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1184
1197
  */
1185
1198
  function useStore() {
1186
1199
  const store = React__namespace.useContext(context);
@@ -1188,18 +1201,18 @@ function useStore() {
1188
1201
  return store;
1189
1202
  }
1190
1203
 
1191
- /**
1192
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1193
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1204
+ /**
1205
+ * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1206
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1194
1207
  */
1195
1208
  function useThree(selector = state => state, equalityFn) {
1196
1209
  return useStore()(selector, equalityFn);
1197
1210
  }
1198
1211
 
1199
- /**
1200
- * Executes a callback before render in a shared frame loop.
1201
- * Can order effects with render priority or manually render with a positive priority.
1202
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1212
+ /**
1213
+ * Executes a callback before render in a shared frame loop.
1214
+ * Can order effects with render priority or manually render with a positive priority.
1215
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1203
1216
  */
1204
1217
  function useFrame(callback, renderPriority = 0) {
1205
1218
  const store = useStore();
@@ -1211,9 +1224,9 @@ function useFrame(callback, renderPriority = 0) {
1211
1224
  return null;
1212
1225
  }
1213
1226
 
1214
- /**
1215
- * Returns a node graph of an object with named nodes & materials.
1216
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1227
+ /**
1228
+ * Returns a node graph of an object with named nodes & materials.
1229
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1217
1230
  */
1218
1231
  function useGraph(object) {
1219
1232
  return React__namespace.useMemo(() => buildGraph(object), [object]);
@@ -1249,11 +1262,11 @@ function loadingFn(extensions, onProgress) {
1249
1262
  };
1250
1263
  }
1251
1264
 
1252
- /**
1253
- * Synchronously loads and caches assets with a three loader.
1254
- *
1255
- * Note: this hook's caller must be wrapped with `React.Suspense`
1256
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1265
+ /**
1266
+ * Synchronously loads and caches assets with a three loader.
1267
+ *
1268
+ * Note: this hook's caller must be wrapped with `React.Suspense`
1269
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1257
1270
  */
1258
1271
  function useLoader(loader, input, extensions, onProgress) {
1259
1272
  // Use suspense to load async assets
@@ -1265,16 +1278,16 @@ function useLoader(loader, input, extensions, onProgress) {
1265
1278
  return Array.isArray(input) ? results : results[0];
1266
1279
  }
1267
1280
 
1268
- /**
1269
- * Preloads an asset into cache as a side-effect.
1281
+ /**
1282
+ * Preloads an asset into cache as a side-effect.
1270
1283
  */
1271
1284
  useLoader.preload = function (loader, input, extensions) {
1272
1285
  const keys = Array.isArray(input) ? input : [input];
1273
1286
  return suspendReact.preload(loadingFn(extensions), [loader, ...keys]);
1274
1287
  };
1275
1288
 
1276
- /**
1277
- * Removes a loaded asset from cache.
1289
+ /**
1290
+ * Removes a loaded asset from cache.
1278
1291
  */
1279
1292
  useLoader.clear = function (loader, input) {
1280
1293
  const keys = Array.isArray(input) ? input : [input];
@@ -1296,7 +1309,7 @@ useLoader.clear = function (loader, input) {
1296
1309
 
1297
1310
  var packageData = {
1298
1311
  name: "@react-three/fiber",
1299
- version: "9.5.0",
1312
+ version: "9.6.0",
1300
1313
  description: "A React renderer for Threejs",
1301
1314
  keywords: [
1302
1315
  "react",
@@ -7679,10 +7692,10 @@ function Portal({
7679
7692
  children,
7680
7693
  container
7681
7694
  }) {
7682
- /** This has to be a component because it would not be able to call useThree/useStore otherwise since
7683
- * if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
7684
- * the "R3F hooks can only be used within the Canvas component!" warning:
7685
- * <Canvas>
7695
+ /** This has to be a component because it would not be able to call useThree/useStore otherwise since
7696
+ * if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
7697
+ * the "R3F hooks can only be used within the Canvas component!" warning:
7698
+ * <Canvas>
7686
7699
  * {createPortal(...)} */
7687
7700
  const {
7688
7701
  events,
@@ -7763,11 +7776,11 @@ function Portal({
7763
7776
  );
7764
7777
  }
7765
7778
 
7766
- /**
7767
- * Force React to flush any updates inside the provided callback synchronously and immediately.
7768
- * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
7769
- * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
7770
- * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
7779
+ /**
7780
+ * Force React to flush any updates inside the provided callback synchronously and immediately.
7781
+ * All the same caveats documented for react-dom's `flushSync` apply here (see https://react.dev/reference/react-dom/flushSync).
7782
+ * Nevertheless, sometimes one needs to render synchronously, for example to keep DOM and 3D changes in lock-step without
7783
+ * having to revert to a non-React solution. Note: this will only flush updates within the `Canvas` root.
7771
7784
  */
7772
7785
  function flushSync(fn) {
7773
7786
  // @ts-ignore - reconciler types are not maintained
@@ -7785,21 +7798,21 @@ const globalEffects = new Set();
7785
7798
  const globalAfterEffects = new Set();
7786
7799
  const globalTailEffects = new Set();
7787
7800
 
7788
- /**
7789
- * Adds a global render callback which is called each frame.
7790
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
7801
+ /**
7802
+ * Adds a global render callback which is called each frame.
7803
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
7791
7804
  */
7792
7805
  const addEffect = callback => createSubs(callback, globalEffects);
7793
7806
 
7794
- /**
7795
- * Adds a global after-render callback which is called each frame.
7796
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
7807
+ /**
7808
+ * Adds a global after-render callback which is called each frame.
7809
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
7797
7810
  */
7798
7811
  const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
7799
7812
 
7800
- /**
7801
- * Adds a global callback which is called when rendering stops.
7802
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
7813
+ /**
7814
+ * Adds a global callback which is called when rendering stops.
7815
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
7803
7816
  */
7804
7817
  const addTail = callback => createSubs(callback, globalTailEffects);
7805
7818
  function run(effects, timestamp) {
@@ -7887,9 +7900,9 @@ function loop(timestamp) {
7887
7900
  }
7888
7901
  }
7889
7902
 
7890
- /**
7891
- * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
7892
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
7903
+ /**
7904
+ * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
7905
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
7893
7906
  */
7894
7907
  function invalidate(state, frames = 1) {
7895
7908
  var _state$gl$xr2;
@@ -7904,7 +7917,7 @@ function invalidate(state, frames = 1) {
7904
7917
  //called from within a useFrame, it means the user wants an additional frame
7905
7918
  state.internal.frames = 2;
7906
7919
  } else {
7907
- //the user need a new frame, no need to increment further than 1
7920
+ //the user needs a new frame, no need to increment further than 1
7908
7921
  state.internal.frames = 1;
7909
7922
  }
7910
7923
  }
@@ -7916,9 +7929,9 @@ function invalidate(state, frames = 1) {
7916
7929
  }
7917
7930
  }
7918
7931
 
7919
- /**
7920
- * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
7921
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
7932
+ /**
7933
+ * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
7934
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
7922
7935
  */
7923
7936
  function advance(timestamp, runGlobalEffects = true, state, frame) {
7924
7937
  if (runGlobalEffects) flushGlobalEffects('before', timestamp);