@react-three/fiber 7.0.21 → 7.0.22

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 7.0.22
4
+
5
+ ### Patch Changes
6
+
7
+ - 259e1fa: add camera:manual
8
+
3
9
  ## 7.0.21
4
10
 
5
11
  ### Patch Changes
@@ -4,7 +4,7 @@ import type { RootState } from './store';
4
4
  export interface Intersection extends THREE.Intersection {
5
5
  eventObject: THREE.Object3D;
6
6
  }
7
- export interface IntesectionEvent<TSourceEvent> extends Intersection {
7
+ export interface IntersectionEvent<TSourceEvent> extends Intersection {
8
8
  intersections: Intersection[];
9
9
  stopped: boolean;
10
10
  unprojectedPoint: THREE.Vector3;
@@ -18,8 +18,8 @@ export interface IntesectionEvent<TSourceEvent> extends Intersection {
18
18
  spaceY: number;
19
19
  }
20
20
  export declare type Camera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
21
- export declare type ThreeEvent<TEvent> = TEvent & IntesectionEvent<TEvent>;
22
- export declare type DomEvent = ThreeEvent<PointerEvent | MouseEvent | WheelEvent>;
21
+ export declare type ThreeEvent<TEvent> = IntersectionEvent<TEvent>;
22
+ export declare type DomEvent = PointerEvent | MouseEvent | WheelEvent;
23
23
  export declare type Events = {
24
24
  onClick: EventListener;
25
25
  onContextMenu: EventListener;
@@ -43,7 +43,7 @@ export declare type EventHandlers = {
43
43
  onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
44
44
  onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
45
45
  onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
46
- onPointerMissed?: (event: ThreeEvent<PointerEvent>) => void;
46
+ onPointerMissed?: (event: MouseEvent) => void;
47
47
  onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
48
48
  onWheel?: (event: ThreeEvent<WheelEvent>) => void;
49
49
  };
@@ -47,9 +47,9 @@ export declare type InternalState = {
47
47
  priority: number;
48
48
  frames: number;
49
49
  lastProps: StoreProps;
50
- lastEvent: React.MutableRefObject<DomEvent>;
50
+ lastEvent: React.MutableRefObject<DomEvent | null>;
51
51
  interaction: THREE.Object3D[];
52
- hovered: Map<string, DomEvent>;
52
+ hovered: Map<string, ThreeEvent<DomEvent>>;
53
53
  subscribers: Subscription[];
54
54
  capturedMap: Map<number, Map<THREE.Object3D, PointerCaptureTarget>>;
55
55
  initialClick: [x: number, y: number];
@@ -59,7 +59,9 @@ export declare type InternalState = {
59
59
  export declare type RootState = {
60
60
  gl: THREE.WebGLRenderer;
61
61
  scene: THREE.Scene;
62
- camera: Camera;
62
+ camera: Camera & {
63
+ manual?: boolean;
64
+ };
63
65
  controls: THREE.EventDispatcher | null;
64
66
  raycaster: Raycaster;
65
67
  mouse: THREE.Vector2;
@@ -79,7 +81,8 @@ export declare type RootState = {
79
81
  advance: (timestamp: number, runGlobalEffects?: boolean) => void;
80
82
  setSize: (width: number, height: number) => void;
81
83
  setDpr: (dpr: Dpr) => void;
82
- onPointerMissed?: (event: ThreeEvent<PointerEvent>) => void;
84
+ setFrameloop: (frameloop?: 'always' | 'demand' | 'never') => void;
85
+ onPointerMissed?: (event: MouseEvent) => void;
83
86
  events: EventManager<any>;
84
87
  internal: InternalState;
85
88
  };
@@ -101,8 +104,10 @@ export declare type StoreProps = {
101
104
  dpr?: Dpr;
102
105
  clock?: THREE.Clock;
103
106
  raycaster?: Partial<Raycaster>;
104
- camera?: Camera | Partial<ReactThreeFiber.Object3DNode<THREE.Camera, typeof THREE.Camera> & ReactThreeFiber.Object3DNode<THREE.PerspectiveCamera, typeof THREE.PerspectiveCamera> & ReactThreeFiber.Object3DNode<THREE.OrthographicCamera, typeof THREE.OrthographicCamera>>;
105
- onPointerMissed?: (event: ThreeEvent<PointerEvent>) => void;
107
+ camera?: (Camera | Partial<ReactThreeFiber.Object3DNode<THREE.Camera, typeof THREE.Camera> & ReactThreeFiber.Object3DNode<THREE.PerspectiveCamera, typeof THREE.PerspectiveCamera> & ReactThreeFiber.Object3DNode<THREE.OrthographicCamera, typeof THREE.OrthographicCamera>>) & {
108
+ manual?: boolean;
109
+ };
110
+ onPointerMissed?: (event: MouseEvent) => void;
106
111
  };
107
112
  export declare type ApplyProps = (instance: Instance, newProps: InstanceProps) => void;
108
113
  export declare function calculateDpr(dpr: Dpr): number;
@@ -23,7 +23,7 @@ export interface NodeProps<T, P> {
23
23
  attachFns?: [AttachCallback, AttachCallback];
24
24
  args?: Args<P>;
25
25
  children?: React.ReactNode;
26
- ref?: React.Ref<React.ReactNode>;
26
+ ref?: React.RefCallback<T> | React.RefObject<React.ReactNode> | null;
27
27
  key?: React.Key;
28
28
  onUpdate?: (self: T) => void;
29
29
  }
@@ -174,6 +174,7 @@ export declare type Matrix3Props = Node<THREE.Matrix3, typeof THREE.Matrix3>;
174
174
  export declare type Matrix4Props = Node<THREE.Matrix4, typeof THREE.Matrix4>;
175
175
  export declare type QuaternionProps = Node<THREE.Quaternion, typeof THREE.Quaternion>;
176
176
  export declare type BufferAttributeProps = Node<THREE.BufferAttribute, typeof THREE.BufferAttribute>;
177
+ export declare type Float32BufferAttributeProps = Node<THREE.Float32BufferAttribute, typeof THREE.Float32BufferAttribute>;
177
178
  export declare type InstancedBufferAttributeProps = Node<THREE.InstancedBufferAttribute, typeof THREE.InstancedBufferAttribute>;
178
179
  export declare type ColorProps = Node<THREE.Color, ColorArray>;
179
180
  export declare type FogProps = Node<THREE.Fog, typeof THREE.Fog>;
@@ -307,6 +308,7 @@ declare global {
307
308
  matrix4: Matrix4Props;
308
309
  quaternion: QuaternionProps;
309
310
  bufferAttribute: BufferAttributeProps;
311
+ float32BufferAttribute: Float32BufferAttributeProps;
310
312
  instancedBufferAttribute: InstancedBufferAttributeProps;
311
313
  color: ColorProps;
312
314
  fog: FogProps;
@@ -436,12 +436,17 @@ function createEvents(store) {
436
436
  if (handler) {
437
437
  // Forward all events back to their respective handlers with the exception of click events,
438
438
  // which must use the initial target
439
- if (name !== 'onClick' && name !== 'onContextMenu' && name !== 'onDoubleClick' || internal.initialHits.includes(eventObject)) {
439
+ if (!isClickEvent || internal.initialHits.includes(eventObject)) {
440
440
  // Missed events have to come first
441
441
  pointerMissed(event, internal.interaction.filter(object => !internal.initialHits.includes(object))); // Now call the handler
442
442
 
443
443
  handler(data);
444
444
  }
445
+ } else {
446
+ // Trigger onPointerMissed on all elements that have pointer over/out handlers, but not click and weren't hit
447
+ if (isClickEvent && internal.initialHits.includes(eventObject)) {
448
+ pointerMissed(event, internal.interaction.filter(object => !internal.initialHits.includes(object)));
449
+ }
445
450
  }
446
451
  }
447
452
  });
@@ -644,7 +649,7 @@ function createRenderer(roots) {
644
649
  invalidateInstance(instance);
645
650
  });
646
651
 
647
- if (rootState.internal && instance.raycast && prevHandlers !== localState.eventCount) {
652
+ if (localState.parent && rootState.internal && instance.raycast && prevHandlers !== localState.eventCount) {
648
653
  // Pre-emptively remove the instance from the interaction manager
649
654
  const index = rootState.internal.interaction.indexOf(instance);
650
655
  if (index > -1) rootState.internal.interaction.splice(index, 1); // Add the instance to the interaction manager only when it has handlers
@@ -697,7 +702,9 @@ function createRenderer(roots) {
697
702
  });
698
703
  } else {
699
704
  const target = catalogue[name] || THREE__namespace[name];
700
- if (!target) throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`; // Instanciate new object, link it to the root
705
+ if (!target) throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`; // Throw if an object or literal was passed for args
706
+
707
+ if (!Array.isArray(args)) throw 'The args prop must be an array!'; // Instanciate new object, link it to the root
701
708
  // Append memoized props with args so it's not forgotten
702
709
 
703
710
  instance = prepare(new target(...args), {
@@ -971,7 +978,9 @@ function createRenderer(roots) {
971
978
  args: argsOld = [],
972
979
  children: cO,
973
980
  ...restOld
974
- } = oldProps; // If it has new props or arguments, then it needs to be re-instanciated
981
+ } = oldProps; // Throw if an object or literal was passed for args
982
+
983
+ if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-instanciated
975
984
 
976
985
  if (argsNew.some((value, index) => value !== argsOld[index])) return [true]; // Create a diff-set, flag if there are any changes
977
986
 
@@ -1021,11 +1030,24 @@ function createRenderer(roots) {
1021
1030
 
1022
1031
  createTextInstance() {},
1023
1032
 
1024
- finalizeInitialChildren() {
1025
- return false;
1033
+ finalizeInitialChildren(instance) {
1034
+ var _instance$__r3f7;
1035
+
1036
+ // https://github.com/facebook/react/issues/20271
1037
+ // Returning true will trigger commitMount
1038
+ const localState = (_instance$__r3f7 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f7 : {};
1039
+ return !!localState.handlers;
1026
1040
  },
1027
1041
 
1028
- commitMount() {// noop
1042
+ commitMount(instance)
1043
+ /*, type, props*/
1044
+ {
1045
+ var _instance$__r3f8;
1046
+
1047
+ // https://github.com/facebook/react/issues/20271
1048
+ // This will make sure events are only added once to the central container
1049
+ const localState = (_instance$__r3f8 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f8 : {};
1050
+ if (instance.raycast && localState.handlers && localState.eventCount) instance.__r3f.root.getState().internal.interaction.push(instance);
1029
1051
  },
1030
1052
 
1031
1053
  shouldDeprioritizeSubtree() {
@@ -1232,6 +1254,9 @@ const createStore = (applyProps, invalidate, advance, props) => {
1232
1254
  dpr: calculateDpr(dpr)
1233
1255
  }
1234
1256
  })),
1257
+ setFrameloop: (frameloop = 'always') => set(() => ({
1258
+ frameloop
1259
+ })),
1235
1260
  events: {
1236
1261
  connected: false
1237
1262
  },
@@ -1240,7 +1265,7 @@ const createStore = (applyProps, invalidate, advance, props) => {
1240
1265
  priority: 0,
1241
1266
  frames: 0,
1242
1267
  lastProps: props,
1243
- lastEvent: /*#__PURE__*/React__namespace.createRef(null),
1268
+ lastEvent: /*#__PURE__*/React__namespace.createRef(),
1244
1269
  interaction: [],
1245
1270
  hovered: new Map(),
1246
1271
  subscribers: [],
@@ -1296,7 +1321,9 @@ const createStore = (applyProps, invalidate, advance, props) => {
1296
1321
  if (size !== oldSize || viewport.dpr !== oldDpr) {
1297
1322
  // https://github.com/pmndrs/react-three-fiber/issues/92
1298
1323
  // Do not mess with the camera if it belongs to the user
1299
- if (!(internal.lastProps.camera instanceof THREE__namespace.Camera)) {
1324
+ if (!camera.manual && !(internal.lastProps.camera instanceof THREE__namespace.Camera)) {
1325
+ console.log('update camera');
1326
+
1300
1327
  if (isOrthographicCamera(camera)) {
1301
1328
  camera.left = size.width / -2;
1302
1329
  camera.right = size.width / 2;
@@ -1721,7 +1748,9 @@ function render(element, canvas, {
1721
1748
  // Check pixelratio
1722
1749
  if (props.dpr !== undefined && !is.equ(state.viewport.dpr, calculateDpr(props.dpr))) state.setDpr(props.dpr); // Check size
1723
1750
 
1724
- if (state.size.width !== size.width || state.size.height !== size.height) state.setSize(size.width, size.height); // For some props we want to reset the entire root
1751
+ if (state.size.width !== size.width || state.size.height !== size.height) state.setSize(size.width, size.height); // Check frameloop
1752
+
1753
+ if (state.frameloop !== props.frameloop) state.setFrameloop(props.frameloop); // For some props we want to reset the entire root
1725
1754
  // Changes to the color-space
1726
1755
 
1727
1756
  const linearChanged = props.linear !== state.internal.lastProps.linear;
@@ -436,12 +436,17 @@ function createEvents(store) {
436
436
  if (handler) {
437
437
  // Forward all events back to their respective handlers with the exception of click events,
438
438
  // which must use the initial target
439
- if (name !== 'onClick' && name !== 'onContextMenu' && name !== 'onDoubleClick' || internal.initialHits.includes(eventObject)) {
439
+ if (!isClickEvent || internal.initialHits.includes(eventObject)) {
440
440
  // Missed events have to come first
441
441
  pointerMissed(event, internal.interaction.filter(object => !internal.initialHits.includes(object))); // Now call the handler
442
442
 
443
443
  handler(data);
444
444
  }
445
+ } else {
446
+ // Trigger onPointerMissed on all elements that have pointer over/out handlers, but not click and weren't hit
447
+ if (isClickEvent && internal.initialHits.includes(eventObject)) {
448
+ pointerMissed(event, internal.interaction.filter(object => !internal.initialHits.includes(object)));
449
+ }
445
450
  }
446
451
  }
447
452
  });
@@ -644,7 +649,7 @@ function createRenderer(roots) {
644
649
  invalidateInstance(instance);
645
650
  });
646
651
 
647
- if (rootState.internal && instance.raycast && prevHandlers !== localState.eventCount) {
652
+ if (localState.parent && rootState.internal && instance.raycast && prevHandlers !== localState.eventCount) {
648
653
  // Pre-emptively remove the instance from the interaction manager
649
654
  const index = rootState.internal.interaction.indexOf(instance);
650
655
  if (index > -1) rootState.internal.interaction.splice(index, 1); // Add the instance to the interaction manager only when it has handlers
@@ -697,7 +702,9 @@ function createRenderer(roots) {
697
702
  });
698
703
  } else {
699
704
  const target = catalogue[name] || THREE__namespace[name];
700
- if (!target) throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`; // Instanciate new object, link it to the root
705
+ if (!target) throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`; // Throw if an object or literal was passed for args
706
+
707
+ if (!Array.isArray(args)) throw 'The args prop must be an array!'; // Instanciate new object, link it to the root
701
708
  // Append memoized props with args so it's not forgotten
702
709
 
703
710
  instance = prepare(new target(...args), {
@@ -971,7 +978,9 @@ function createRenderer(roots) {
971
978
  args: argsOld = [],
972
979
  children: cO,
973
980
  ...restOld
974
- } = oldProps; // If it has new props or arguments, then it needs to be re-instanciated
981
+ } = oldProps; // Throw if an object or literal was passed for args
982
+
983
+ if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-instanciated
975
984
 
976
985
  if (argsNew.some((value, index) => value !== argsOld[index])) return [true]; // Create a diff-set, flag if there are any changes
977
986
 
@@ -1021,11 +1030,24 @@ function createRenderer(roots) {
1021
1030
 
1022
1031
  createTextInstance() {},
1023
1032
 
1024
- finalizeInitialChildren() {
1025
- return false;
1033
+ finalizeInitialChildren(instance) {
1034
+ var _instance$__r3f7;
1035
+
1036
+ // https://github.com/facebook/react/issues/20271
1037
+ // Returning true will trigger commitMount
1038
+ const localState = (_instance$__r3f7 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f7 : {};
1039
+ return !!localState.handlers;
1026
1040
  },
1027
1041
 
1028
- commitMount() {// noop
1042
+ commitMount(instance)
1043
+ /*, type, props*/
1044
+ {
1045
+ var _instance$__r3f8;
1046
+
1047
+ // https://github.com/facebook/react/issues/20271
1048
+ // This will make sure events are only added once to the central container
1049
+ const localState = (_instance$__r3f8 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f8 : {};
1050
+ if (instance.raycast && localState.handlers && localState.eventCount) instance.__r3f.root.getState().internal.interaction.push(instance);
1029
1051
  },
1030
1052
 
1031
1053
  shouldDeprioritizeSubtree() {
@@ -1232,6 +1254,9 @@ const createStore = (applyProps, invalidate, advance, props) => {
1232
1254
  dpr: calculateDpr(dpr)
1233
1255
  }
1234
1256
  })),
1257
+ setFrameloop: (frameloop = 'always') => set(() => ({
1258
+ frameloop
1259
+ })),
1235
1260
  events: {
1236
1261
  connected: false
1237
1262
  },
@@ -1240,7 +1265,7 @@ const createStore = (applyProps, invalidate, advance, props) => {
1240
1265
  priority: 0,
1241
1266
  frames: 0,
1242
1267
  lastProps: props,
1243
- lastEvent: /*#__PURE__*/React__namespace.createRef(null),
1268
+ lastEvent: /*#__PURE__*/React__namespace.createRef(),
1244
1269
  interaction: [],
1245
1270
  hovered: new Map(),
1246
1271
  subscribers: [],
@@ -1296,7 +1321,9 @@ const createStore = (applyProps, invalidate, advance, props) => {
1296
1321
  if (size !== oldSize || viewport.dpr !== oldDpr) {
1297
1322
  // https://github.com/pmndrs/react-three-fiber/issues/92
1298
1323
  // Do not mess with the camera if it belongs to the user
1299
- if (!(internal.lastProps.camera instanceof THREE__namespace.Camera)) {
1324
+ if (!camera.manual && !(internal.lastProps.camera instanceof THREE__namespace.Camera)) {
1325
+ console.log('update camera');
1326
+
1300
1327
  if (isOrthographicCamera(camera)) {
1301
1328
  camera.left = size.width / -2;
1302
1329
  camera.right = size.width / 2;
@@ -1721,7 +1748,9 @@ function render(element, canvas, {
1721
1748
  // Check pixelratio
1722
1749
  if (props.dpr !== undefined && !is.equ(state.viewport.dpr, calculateDpr(props.dpr))) state.setDpr(props.dpr); // Check size
1723
1750
 
1724
- if (state.size.width !== size.width || state.size.height !== size.height) state.setSize(size.width, size.height); // For some props we want to reset the entire root
1751
+ if (state.size.width !== size.width || state.size.height !== size.height) state.setSize(size.width, size.height); // Check frameloop
1752
+
1753
+ if (state.frameloop !== props.frameloop) state.setFrameloop(props.frameloop); // For some props we want to reset the entire root
1725
1754
  // Changes to the color-space
1726
1755
 
1727
1756
  const linearChanged = props.linear !== state.internal.lastProps.linear;
@@ -403,12 +403,17 @@ function createEvents(store) {
403
403
  if (handler) {
404
404
  // Forward all events back to their respective handlers with the exception of click events,
405
405
  // which must use the initial target
406
- if (name !== 'onClick' && name !== 'onContextMenu' && name !== 'onDoubleClick' || internal.initialHits.includes(eventObject)) {
406
+ if (!isClickEvent || internal.initialHits.includes(eventObject)) {
407
407
  // Missed events have to come first
408
408
  pointerMissed(event, internal.interaction.filter(object => !internal.initialHits.includes(object))); // Now call the handler
409
409
 
410
410
  handler(data);
411
411
  }
412
+ } else {
413
+ // Trigger onPointerMissed on all elements that have pointer over/out handlers, but not click and weren't hit
414
+ if (isClickEvent && internal.initialHits.includes(eventObject)) {
415
+ pointerMissed(event, internal.interaction.filter(object => !internal.initialHits.includes(object)));
416
+ }
412
417
  }
413
418
  }
414
419
  });
@@ -611,7 +616,7 @@ function createRenderer(roots) {
611
616
  invalidateInstance(instance);
612
617
  });
613
618
 
614
- if (rootState.internal && instance.raycast && prevHandlers !== localState.eventCount) {
619
+ if (localState.parent && rootState.internal && instance.raycast && prevHandlers !== localState.eventCount) {
615
620
  // Pre-emptively remove the instance from the interaction manager
616
621
  const index = rootState.internal.interaction.indexOf(instance);
617
622
  if (index > -1) rootState.internal.interaction.splice(index, 1); // Add the instance to the interaction manager only when it has handlers
@@ -664,7 +669,9 @@ function createRenderer(roots) {
664
669
  });
665
670
  } else {
666
671
  const target = catalogue[name] || THREE[name];
667
- if (!target) throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`; // Instanciate new object, link it to the root
672
+ if (!target) throw `${name} is not part of the THREE namespace! Did you forget to extend? See: https://github.com/pmndrs/react-three-fiber/blob/master/markdown/api.md#using-3rd-party-objects-declaratively`; // Throw if an object or literal was passed for args
673
+
674
+ if (!Array.isArray(args)) throw 'The args prop must be an array!'; // Instanciate new object, link it to the root
668
675
  // Append memoized props with args so it's not forgotten
669
676
 
670
677
  instance = prepare(new target(...args), {
@@ -938,7 +945,9 @@ function createRenderer(roots) {
938
945
  args: argsOld = [],
939
946
  children: cO,
940
947
  ...restOld
941
- } = oldProps; // If it has new props or arguments, then it needs to be re-instanciated
948
+ } = oldProps; // Throw if an object or literal was passed for args
949
+
950
+ if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-instanciated
942
951
 
943
952
  if (argsNew.some((value, index) => value !== argsOld[index])) return [true]; // Create a diff-set, flag if there are any changes
944
953
 
@@ -988,11 +997,24 @@ function createRenderer(roots) {
988
997
 
989
998
  createTextInstance() {},
990
999
 
991
- finalizeInitialChildren() {
992
- return false;
1000
+ finalizeInitialChildren(instance) {
1001
+ var _instance$__r3f7;
1002
+
1003
+ // https://github.com/facebook/react/issues/20271
1004
+ // Returning true will trigger commitMount
1005
+ const localState = (_instance$__r3f7 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f7 : {};
1006
+ return !!localState.handlers;
993
1007
  },
994
1008
 
995
- commitMount() {// noop
1009
+ commitMount(instance)
1010
+ /*, type, props*/
1011
+ {
1012
+ var _instance$__r3f8;
1013
+
1014
+ // https://github.com/facebook/react/issues/20271
1015
+ // This will make sure events are only added once to the central container
1016
+ const localState = (_instance$__r3f8 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f8 : {};
1017
+ if (instance.raycast && localState.handlers && localState.eventCount) instance.__r3f.root.getState().internal.interaction.push(instance);
996
1018
  },
997
1019
 
998
1020
  shouldDeprioritizeSubtree() {
@@ -1199,6 +1221,9 @@ const createStore = (applyProps, invalidate, advance, props) => {
1199
1221
  dpr: calculateDpr(dpr)
1200
1222
  }
1201
1223
  })),
1224
+ setFrameloop: (frameloop = 'always') => set(() => ({
1225
+ frameloop
1226
+ })),
1202
1227
  events: {
1203
1228
  connected: false
1204
1229
  },
@@ -1207,7 +1232,7 @@ const createStore = (applyProps, invalidate, advance, props) => {
1207
1232
  priority: 0,
1208
1233
  frames: 0,
1209
1234
  lastProps: props,
1210
- lastEvent: /*#__PURE__*/React.createRef(null),
1235
+ lastEvent: /*#__PURE__*/React.createRef(),
1211
1236
  interaction: [],
1212
1237
  hovered: new Map(),
1213
1238
  subscribers: [],
@@ -1263,7 +1288,9 @@ const createStore = (applyProps, invalidate, advance, props) => {
1263
1288
  if (size !== oldSize || viewport.dpr !== oldDpr) {
1264
1289
  // https://github.com/pmndrs/react-three-fiber/issues/92
1265
1290
  // Do not mess with the camera if it belongs to the user
1266
- if (!(internal.lastProps.camera instanceof THREE.Camera)) {
1291
+ if (!camera.manual && !(internal.lastProps.camera instanceof THREE.Camera)) {
1292
+ console.log('update camera');
1293
+
1267
1294
  if (isOrthographicCamera(camera)) {
1268
1295
  camera.left = size.width / -2;
1269
1296
  camera.right = size.width / 2;
@@ -1688,7 +1715,9 @@ function render(element, canvas, {
1688
1715
  // Check pixelratio
1689
1716
  if (props.dpr !== undefined && !is.equ(state.viewport.dpr, calculateDpr(props.dpr))) state.setDpr(props.dpr); // Check size
1690
1717
 
1691
- if (state.size.width !== size.width || state.size.height !== size.height) state.setSize(size.width, size.height); // For some props we want to reset the entire root
1718
+ if (state.size.width !== size.width || state.size.height !== size.height) state.setSize(size.width, size.height); // Check frameloop
1719
+
1720
+ if (state.frameloop !== props.frameloop) state.setFrameloop(props.frameloop); // For some props we want to reset the entire root
1692
1721
  // Changes to the color-space
1693
1722
 
1694
1723
  const linearChanged = props.linear !== state.internal.lastProps.linear;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "7.0.21",
3
+ "version": "7.0.22",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",
@@ -12,7 +12,8 @@
12
12
  "author": "Paul Henschel (https://github.com/drcmda)",
13
13
  "license": "MIT",
14
14
  "maintainers": [
15
- "Josh Ellis (https://github.com/joshuaellis)"
15
+ "Josh Ellis (https://github.com/joshuaellis)",
16
+ "Cody Bennett (https://github.com/codyjasonbennett)"
16
17
  ],
17
18
  "bugs": {
18
19
  "url": "https://github.com/pmndrs/react-three-fiber/issues"