@react-three/fiber 8.0.16 → 8.0.19

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,23 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.0.19
4
+
5
+ ### Patch Changes
6
+
7
+ - 360b45a: fix: handle attach on reconstruct
8
+
9
+ ## 8.0.18
10
+
11
+ ### Patch Changes
12
+
13
+ - be567c1: fix: suspense attach and three compat in webpack
14
+
15
+ ## 8.0.17
16
+
17
+ ### Patch Changes
18
+
19
+ - 9e3369e: fix dom resize, improve native tree shaking
20
+
3
21
  ## 8.0.16
4
22
 
5
23
  ### Patch Changes
@@ -79,3 +79,4 @@ export declare function updateInstance(instance: Instance): void;
79
79
  export declare function updateCamera(camera: Camera & {
80
80
  manual?: boolean;
81
81
  }, size: Size): void;
82
+ export declare function setDeep(obj: any, value: any, keys: string[]): any;
@@ -0,0 +1 @@
1
+ export declare function polyfills(): (() => void) | undefined;
@@ -335,7 +335,7 @@ function applyProps$1(instance, data) {
335
335
  // Auto-convert sRGB colors
336
336
  // https://github.com/pmndrs/react-three-fiber/issues/344
337
337
 
338
- const supportsColorManagement = THREE.ColorManagement;
338
+ const supportsColorManagement = ('ColorManagement' in THREE);
339
339
  if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
340
340
  } // Else, just overwrite the value
341
341
 
@@ -391,6 +391,15 @@ function updateCamera(camera, size) {
391
391
  camera.updateMatrixWorld();
392
392
  }
393
393
  }
394
+ /**
395
+ * Safely sets a deeply-nested value on an object.
396
+ */
397
+
398
+ function setDeep(obj, value, keys) {
399
+ const key = keys.pop();
400
+ const target = keys.reduce((acc, key) => acc[key], obj);
401
+ return target[key] = value;
402
+ }
394
403
 
395
404
  function makeId(event) {
396
405
  return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
@@ -857,7 +866,7 @@ function createRenderer(roots, getEventPriority) {
857
866
  type,
858
867
  root,
859
868
  attach,
860
- // TODO: Figure out what this is for
869
+ // Save args in case we need to reconstruct later for HMR
861
870
  memoizedProps: {
862
871
  args
863
872
  }
@@ -878,10 +887,9 @@ function createRenderer(roots, getEventPriority) {
878
887
  if (child) {
879
888
  var _child$__r3f, _parentInstance$__r3f;
880
889
 
881
- // The attach attribute implies that the object attaches itself on the parent
882
- if ((_child$__r3f = child.__r3f) != null && _child$__r3f.attach) {
883
- attach(parentInstance, child, child.__r3f.attach);
884
- } else if (child.isObject3D && parentInstance.isObject3D) {
890
+ // The attach attribute implies that the object attaches itself on the parent.
891
+ // That is handled at commit to avoid duplication during Suspense
892
+ if (!((_child$__r3f = child.__r3f) != null && _child$__r3f.attach) && child.isObject3D && parentInstance.isObject3D) {
885
893
  // add in the usual parent-child way
886
894
  parentInstance.add(child);
887
895
  added = true;
@@ -947,7 +955,7 @@ function createRenderer(roots, getEventPriority) {
947
955
  if ((_child$__r3f4 = child.__r3f) != null && _child$__r3f4.root) {
948
956
  removeInteractivity(child.__r3f.root, child);
949
957
  }
950
- } // Allow objects to bail out of recursive dispose alltogether by passing dispose={null}
958
+ } // Allow objects to bail out of recursive dispose altogether by passing dispose={null}
951
959
  // Never dispose of primitives because their state may be kept outside of React!
952
960
  // In order for an object to be able to dispose it has to have
953
961
  // - a dispose method,
@@ -994,7 +1002,7 @@ function createRenderer(roots, getEventPriority) {
994
1002
  }
995
1003
 
996
1004
  function switchInstance(instance, type, newProps, fiber) {
997
- var _instance$__r3f, _instance$__r3f2;
1005
+ var _instance$__r3f, _instance$__r3f2, _newInstance$__r3f;
998
1006
 
999
1007
  const parent = (_instance$__r3f = instance.__r3f) == null ? void 0 : _instance$__r3f.parent;
1000
1008
  if (!parent) return;
@@ -1018,6 +1026,11 @@ function createRenderer(roots, getEventPriority) {
1018
1026
  const rootState = newInstance.__r3f.root.getState();
1019
1027
 
1020
1028
  rootState.internal.interaction.push(newInstance);
1029
+ } // The attach attribute implies that the object attaches itself on the parent
1030
+
1031
+
1032
+ if ((_newInstance$__r3f = newInstance.__r3f) != null && _newInstance$__r3f.attach) {
1033
+ attach(parent, newInstance, newInstance.__r3f.attach);
1021
1034
  } // This evil hack switches the react-internal fiber node
1022
1035
  [fiber, fiber.alternate].forEach(fiber => {
1023
1036
  if (fiber !== null) {
@@ -1058,7 +1071,7 @@ function createRenderer(roots, getEventPriority) {
1058
1071
  const localState = (_instance$__r3f3 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f3 : {}; // https://github.com/facebook/react/issues/20271
1059
1072
  // Returning true will trigger commitMount
1060
1073
 
1061
- return !!localState.handlers;
1074
+ return !!localState.handlers || !!localState.attach;
1062
1075
  },
1063
1076
 
1064
1077
  prepareUpdate(instance, type, oldProps, newProps) {
@@ -1104,6 +1117,11 @@ function createRenderer(roots, getEventPriority) {
1104
1117
 
1105
1118
  if (instance.raycast && localState.handlers && localState.eventCount) {
1106
1119
  instance.__r3f.root.getState().internal.interaction.push(instance);
1120
+ } // The attach attribute implies that the object attaches itself on the parent
1121
+
1122
+
1123
+ if (localState.attach) {
1124
+ attach(localState.parent, instance, localState.attach);
1107
1125
  }
1108
1126
  },
1109
1127
 
@@ -1117,27 +1135,11 @@ function createRenderer(roots, getEventPriority) {
1117
1135
  detachDeletedInstance: () => {},
1118
1136
 
1119
1137
  hideInstance(instance) {
1120
- var _instance$__r3f5;
1121
-
1122
- // Deatch while the instance is hidden
1123
- const {
1124
- attach: type,
1125
- parent
1126
- } = (_instance$__r3f5 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f5 : {};
1127
- if (type && parent) detach(parent, instance, type);
1128
1138
  if (instance.isObject3D) instance.visible = false;
1129
1139
  invalidateInstance(instance);
1130
1140
  },
1131
1141
 
1132
1142
  unhideInstance(instance, props) {
1133
- var _instance$__r3f6;
1134
-
1135
- // Re-attach when the instance is unhidden
1136
- const {
1137
- attach: type,
1138
- parent
1139
- } = (_instance$__r3f6 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f6 : {};
1140
- if (type && parent) attach(parent, instance, type);
1141
1143
  if (instance.isObject3D && props.visible == null || props.visible) instance.visible = true;
1142
1144
  invalidateInstance(instance);
1143
1145
  },
@@ -1761,11 +1763,12 @@ function createRoot(canvas) {
1761
1763
  if (!isBoolean) Object.assign(gl.shadowMap, shadows);else gl.shadowMap.type = THREE.PCFSoftShadowMap;
1762
1764
  if (old !== gl.shadowMap.enabled) gl.shadowMap.needsUpdate = true;
1763
1765
  }
1764
- } // Set color management
1766
+ } // Safely set color management if available.
1767
+ // Avoid accessing THREE.ColorManagement to play nice with older versions
1765
1768
 
1766
1769
 
1767
- if (THREE.ColorManagement) {
1768
- THREE.ColorManagement.legacyMode = legacy;
1770
+ if ('ColorManagement' in THREE) {
1771
+ setDeep(THREE, legacy, ['ColorManagement', 'legacyMode']);
1769
1772
  }
1770
1773
 
1771
1774
  const outputEncoding = linear ? THREE.LinearEncoding : THREE.sRGBEncoding;
@@ -362,7 +362,7 @@ function applyProps$1(instance, data) {
362
362
  // Auto-convert sRGB colors
363
363
  // https://github.com/pmndrs/react-three-fiber/issues/344
364
364
 
365
- const supportsColorManagement = THREE__namespace.ColorManagement;
365
+ const supportsColorManagement = ('ColorManagement' in THREE__namespace);
366
366
  if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
367
367
  } // Else, just overwrite the value
368
368
 
@@ -418,6 +418,15 @@ function updateCamera(camera, size) {
418
418
  camera.updateMatrixWorld();
419
419
  }
420
420
  }
421
+ /**
422
+ * Safely sets a deeply-nested value on an object.
423
+ */
424
+
425
+ function setDeep(obj, value, keys) {
426
+ const key = keys.pop();
427
+ const target = keys.reduce((acc, key) => acc[key], obj);
428
+ return target[key] = value;
429
+ }
421
430
 
422
431
  function makeId(event) {
423
432
  return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
@@ -884,7 +893,7 @@ function createRenderer(roots, getEventPriority) {
884
893
  type,
885
894
  root,
886
895
  attach,
887
- // TODO: Figure out what this is for
896
+ // Save args in case we need to reconstruct later for HMR
888
897
  memoizedProps: {
889
898
  args
890
899
  }
@@ -905,10 +914,9 @@ function createRenderer(roots, getEventPriority) {
905
914
  if (child) {
906
915
  var _child$__r3f, _parentInstance$__r3f;
907
916
 
908
- // The attach attribute implies that the object attaches itself on the parent
909
- if ((_child$__r3f = child.__r3f) != null && _child$__r3f.attach) {
910
- attach(parentInstance, child, child.__r3f.attach);
911
- } else if (child.isObject3D && parentInstance.isObject3D) {
917
+ // The attach attribute implies that the object attaches itself on the parent.
918
+ // That is handled at commit to avoid duplication during Suspense
919
+ if (!((_child$__r3f = child.__r3f) != null && _child$__r3f.attach) && child.isObject3D && parentInstance.isObject3D) {
912
920
  // add in the usual parent-child way
913
921
  parentInstance.add(child);
914
922
  added = true;
@@ -974,7 +982,7 @@ function createRenderer(roots, getEventPriority) {
974
982
  if ((_child$__r3f4 = child.__r3f) != null && _child$__r3f4.root) {
975
983
  removeInteractivity(child.__r3f.root, child);
976
984
  }
977
- } // Allow objects to bail out of recursive dispose alltogether by passing dispose={null}
985
+ } // Allow objects to bail out of recursive dispose altogether by passing dispose={null}
978
986
  // Never dispose of primitives because their state may be kept outside of React!
979
987
  // In order for an object to be able to dispose it has to have
980
988
  // - a dispose method,
@@ -1021,7 +1029,7 @@ function createRenderer(roots, getEventPriority) {
1021
1029
  }
1022
1030
 
1023
1031
  function switchInstance(instance, type, newProps, fiber) {
1024
- var _instance$__r3f, _instance$__r3f2;
1032
+ var _instance$__r3f, _instance$__r3f2, _newInstance$__r3f;
1025
1033
 
1026
1034
  const parent = (_instance$__r3f = instance.__r3f) == null ? void 0 : _instance$__r3f.parent;
1027
1035
  if (!parent) return;
@@ -1045,6 +1053,11 @@ function createRenderer(roots, getEventPriority) {
1045
1053
  const rootState = newInstance.__r3f.root.getState();
1046
1054
 
1047
1055
  rootState.internal.interaction.push(newInstance);
1056
+ } // The attach attribute implies that the object attaches itself on the parent
1057
+
1058
+
1059
+ if ((_newInstance$__r3f = newInstance.__r3f) != null && _newInstance$__r3f.attach) {
1060
+ attach(parent, newInstance, newInstance.__r3f.attach);
1048
1061
  } // This evil hack switches the react-internal fiber node
1049
1062
  [fiber, fiber.alternate].forEach(fiber => {
1050
1063
  if (fiber !== null) {
@@ -1085,7 +1098,7 @@ function createRenderer(roots, getEventPriority) {
1085
1098
  const localState = (_instance$__r3f3 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f3 : {}; // https://github.com/facebook/react/issues/20271
1086
1099
  // Returning true will trigger commitMount
1087
1100
 
1088
- return !!localState.handlers;
1101
+ return !!localState.handlers || !!localState.attach;
1089
1102
  },
1090
1103
 
1091
1104
  prepareUpdate(instance, type, oldProps, newProps) {
@@ -1131,6 +1144,11 @@ function createRenderer(roots, getEventPriority) {
1131
1144
 
1132
1145
  if (instance.raycast && localState.handlers && localState.eventCount) {
1133
1146
  instance.__r3f.root.getState().internal.interaction.push(instance);
1147
+ } // The attach attribute implies that the object attaches itself on the parent
1148
+
1149
+
1150
+ if (localState.attach) {
1151
+ attach(localState.parent, instance, localState.attach);
1134
1152
  }
1135
1153
  },
1136
1154
 
@@ -1144,27 +1162,11 @@ function createRenderer(roots, getEventPriority) {
1144
1162
  detachDeletedInstance: () => {},
1145
1163
 
1146
1164
  hideInstance(instance) {
1147
- var _instance$__r3f5;
1148
-
1149
- // Deatch while the instance is hidden
1150
- const {
1151
- attach: type,
1152
- parent
1153
- } = (_instance$__r3f5 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f5 : {};
1154
- if (type && parent) detach(parent, instance, type);
1155
1165
  if (instance.isObject3D) instance.visible = false;
1156
1166
  invalidateInstance(instance);
1157
1167
  },
1158
1168
 
1159
1169
  unhideInstance(instance, props) {
1160
- var _instance$__r3f6;
1161
-
1162
- // Re-attach when the instance is unhidden
1163
- const {
1164
- attach: type,
1165
- parent
1166
- } = (_instance$__r3f6 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f6 : {};
1167
- if (type && parent) attach(parent, instance, type);
1168
1170
  if (instance.isObject3D && props.visible == null || props.visible) instance.visible = true;
1169
1171
  invalidateInstance(instance);
1170
1172
  },
@@ -1788,11 +1790,12 @@ function createRoot(canvas) {
1788
1790
  if (!isBoolean) Object.assign(gl.shadowMap, shadows);else gl.shadowMap.type = THREE__namespace.PCFSoftShadowMap;
1789
1791
  if (old !== gl.shadowMap.enabled) gl.shadowMap.needsUpdate = true;
1790
1792
  }
1791
- } // Set color management
1793
+ } // Safely set color management if available.
1794
+ // Avoid accessing THREE.ColorManagement to play nice with older versions
1792
1795
 
1793
1796
 
1794
- if (THREE__namespace.ColorManagement) {
1795
- THREE__namespace.ColorManagement.legacyMode = legacy;
1797
+ if ('ColorManagement' in THREE__namespace) {
1798
+ setDeep(THREE__namespace, legacy, ['ColorManagement', 'legacyMode']);
1796
1799
  }
1797
1800
 
1798
1801
  const outputEncoding = linear ? THREE__namespace.LinearEncoding : THREE__namespace.sRGBEncoding;
@@ -362,7 +362,7 @@ function applyProps$1(instance, data) {
362
362
  // Auto-convert sRGB colors
363
363
  // https://github.com/pmndrs/react-three-fiber/issues/344
364
364
 
365
- const supportsColorManagement = THREE__namespace.ColorManagement;
365
+ const supportsColorManagement = ('ColorManagement' in THREE__namespace);
366
366
  if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
367
367
  } // Else, just overwrite the value
368
368
 
@@ -418,6 +418,15 @@ function updateCamera(camera, size) {
418
418
  camera.updateMatrixWorld();
419
419
  }
420
420
  }
421
+ /**
422
+ * Safely sets a deeply-nested value on an object.
423
+ */
424
+
425
+ function setDeep(obj, value, keys) {
426
+ const key = keys.pop();
427
+ const target = keys.reduce((acc, key) => acc[key], obj);
428
+ return target[key] = value;
429
+ }
421
430
 
422
431
  function makeId(event) {
423
432
  return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
@@ -884,7 +893,7 @@ function createRenderer(roots, getEventPriority) {
884
893
  type,
885
894
  root,
886
895
  attach,
887
- // TODO: Figure out what this is for
896
+ // Save args in case we need to reconstruct later for HMR
888
897
  memoizedProps: {
889
898
  args
890
899
  }
@@ -905,10 +914,9 @@ function createRenderer(roots, getEventPriority) {
905
914
  if (child) {
906
915
  var _child$__r3f, _parentInstance$__r3f;
907
916
 
908
- // The attach attribute implies that the object attaches itself on the parent
909
- if ((_child$__r3f = child.__r3f) != null && _child$__r3f.attach) {
910
- attach(parentInstance, child, child.__r3f.attach);
911
- } else if (child.isObject3D && parentInstance.isObject3D) {
917
+ // The attach attribute implies that the object attaches itself on the parent.
918
+ // That is handled at commit to avoid duplication during Suspense
919
+ if (!((_child$__r3f = child.__r3f) != null && _child$__r3f.attach) && child.isObject3D && parentInstance.isObject3D) {
912
920
  // add in the usual parent-child way
913
921
  parentInstance.add(child);
914
922
  added = true;
@@ -974,7 +982,7 @@ function createRenderer(roots, getEventPriority) {
974
982
  if ((_child$__r3f4 = child.__r3f) != null && _child$__r3f4.root) {
975
983
  removeInteractivity(child.__r3f.root, child);
976
984
  }
977
- } // Allow objects to bail out of recursive dispose alltogether by passing dispose={null}
985
+ } // Allow objects to bail out of recursive dispose altogether by passing dispose={null}
978
986
  // Never dispose of primitives because their state may be kept outside of React!
979
987
  // In order for an object to be able to dispose it has to have
980
988
  // - a dispose method,
@@ -1021,7 +1029,7 @@ function createRenderer(roots, getEventPriority) {
1021
1029
  }
1022
1030
 
1023
1031
  function switchInstance(instance, type, newProps, fiber) {
1024
- var _instance$__r3f, _instance$__r3f2;
1032
+ var _instance$__r3f, _instance$__r3f2, _newInstance$__r3f;
1025
1033
 
1026
1034
  const parent = (_instance$__r3f = instance.__r3f) == null ? void 0 : _instance$__r3f.parent;
1027
1035
  if (!parent) return;
@@ -1045,6 +1053,11 @@ function createRenderer(roots, getEventPriority) {
1045
1053
  const rootState = newInstance.__r3f.root.getState();
1046
1054
 
1047
1055
  rootState.internal.interaction.push(newInstance);
1056
+ } // The attach attribute implies that the object attaches itself on the parent
1057
+
1058
+
1059
+ if ((_newInstance$__r3f = newInstance.__r3f) != null && _newInstance$__r3f.attach) {
1060
+ attach(parent, newInstance, newInstance.__r3f.attach);
1048
1061
  } // This evil hack switches the react-internal fiber node
1049
1062
  [fiber, fiber.alternate].forEach(fiber => {
1050
1063
  if (fiber !== null) {
@@ -1085,7 +1098,7 @@ function createRenderer(roots, getEventPriority) {
1085
1098
  const localState = (_instance$__r3f3 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f3 : {}; // https://github.com/facebook/react/issues/20271
1086
1099
  // Returning true will trigger commitMount
1087
1100
 
1088
- return !!localState.handlers;
1101
+ return !!localState.handlers || !!localState.attach;
1089
1102
  },
1090
1103
 
1091
1104
  prepareUpdate(instance, type, oldProps, newProps) {
@@ -1131,6 +1144,11 @@ function createRenderer(roots, getEventPriority) {
1131
1144
 
1132
1145
  if (instance.raycast && localState.handlers && localState.eventCount) {
1133
1146
  instance.__r3f.root.getState().internal.interaction.push(instance);
1147
+ } // The attach attribute implies that the object attaches itself on the parent
1148
+
1149
+
1150
+ if (localState.attach) {
1151
+ attach(localState.parent, instance, localState.attach);
1134
1152
  }
1135
1153
  },
1136
1154
 
@@ -1144,27 +1162,11 @@ function createRenderer(roots, getEventPriority) {
1144
1162
  detachDeletedInstance: () => {},
1145
1163
 
1146
1164
  hideInstance(instance) {
1147
- var _instance$__r3f5;
1148
-
1149
- // Deatch while the instance is hidden
1150
- const {
1151
- attach: type,
1152
- parent
1153
- } = (_instance$__r3f5 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f5 : {};
1154
- if (type && parent) detach(parent, instance, type);
1155
1165
  if (instance.isObject3D) instance.visible = false;
1156
1166
  invalidateInstance(instance);
1157
1167
  },
1158
1168
 
1159
1169
  unhideInstance(instance, props) {
1160
- var _instance$__r3f6;
1161
-
1162
- // Re-attach when the instance is unhidden
1163
- const {
1164
- attach: type,
1165
- parent
1166
- } = (_instance$__r3f6 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f6 : {};
1167
- if (type && parent) attach(parent, instance, type);
1168
1170
  if (instance.isObject3D && props.visible == null || props.visible) instance.visible = true;
1169
1171
  invalidateInstance(instance);
1170
1172
  },
@@ -1788,11 +1790,12 @@ function createRoot(canvas) {
1788
1790
  if (!isBoolean) Object.assign(gl.shadowMap, shadows);else gl.shadowMap.type = THREE__namespace.PCFSoftShadowMap;
1789
1791
  if (old !== gl.shadowMap.enabled) gl.shadowMap.needsUpdate = true;
1790
1792
  }
1791
- } // Set color management
1793
+ } // Safely set color management if available.
1794
+ // Avoid accessing THREE.ColorManagement to play nice with older versions
1792
1795
 
1793
1796
 
1794
- if (THREE__namespace.ColorManagement) {
1795
- THREE__namespace.ColorManagement.legacyMode = legacy;
1797
+ if ('ColorManagement' in THREE__namespace) {
1798
+ setDeep(THREE__namespace, legacy, ['ColorManagement', 'legacyMode']);
1796
1799
  }
1797
1800
 
1798
1801
  const outputEncoding = linear ? THREE__namespace.LinearEncoding : THREE__namespace.sRGBEncoding;
@@ -2,11 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-f3176a33.cjs.dev.js');
5
+ var index = require('./index-88f08658.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
9
- var mergeRefs = require('react-merge-refs');
10
9
  var useMeasure = require('react-use-measure');
11
10
  require('react-reconciler/constants');
12
11
  require('zustand');
@@ -36,7 +35,6 @@ function _interopNamespace(e) {
36
35
 
37
36
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
38
37
  var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
39
- var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
40
38
  var useMeasure__default = /*#__PURE__*/_interopDefault(useMeasure);
41
39
 
42
40
  const DOM_EVENTS = {
@@ -158,8 +156,9 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
158
156
  ...resize
159
157
  });
160
158
  const canvasRef = React__namespace.useRef(null);
161
- const meshRef = React__namespace.useRef(null);
159
+ const divRef = React__namespace.useRef(null);
162
160
  const [canvas, setCanvas] = React__namespace.useState(null);
161
+ React__namespace.useImperativeHandle(forwardedRef, () => canvasRef.current);
163
162
  const handlePointerMissed = index.useMutableCallback(onPointerMissed);
164
163
  const [block, setBlock] = React__namespace.useState(false);
165
164
  const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
@@ -191,7 +190,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
191
190
  // Pass mutable reference to onPointerMissed so it's free to update
192
191
  onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
193
192
  onCreated: state => {
194
- state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
193
+ state.events.connect == null ? void 0 : state.events.connect(divRef.current);
195
194
  onCreated == null ? void 0 : onCreated(state);
196
195
  }
197
196
  });
@@ -211,7 +210,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
211
210
  if (canvas) return () => index.unmountComponentAtNode(canvas);
212
211
  }, [canvas]);
213
212
  return /*#__PURE__*/React__namespace.createElement("div", _extends({
214
- ref: mergeRefs__default["default"]([meshRef, containerRef]),
213
+ ref: divRef,
215
214
  style: {
216
215
  position: 'relative',
217
216
  width: '100%',
@@ -219,12 +218,18 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
219
218
  overflow: 'hidden',
220
219
  ...style
221
220
  }
222
- }, props), /*#__PURE__*/React__namespace.createElement("canvas", {
223
- ref: mergeRefs__default["default"]([canvasRef, forwardedRef]),
221
+ }, props), /*#__PURE__*/React__namespace.createElement("div", {
222
+ ref: containerRef,
223
+ style: {
224
+ width: '100%',
225
+ height: '100%'
226
+ }
227
+ }, /*#__PURE__*/React__namespace.createElement("canvas", {
228
+ ref: canvasRef,
224
229
  style: {
225
230
  display: 'block'
226
231
  }
227
- }, fallback));
232
+ }, fallback)));
228
233
  });
229
234
 
230
235
  exports.ReactThreeFiber = index.threeTypes;
@@ -2,11 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-4e1c76e5.cjs.prod.js');
5
+ var index = require('./index-dcd9befe.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
9
- var mergeRefs = require('react-merge-refs');
10
9
  var useMeasure = require('react-use-measure');
11
10
  require('react-reconciler/constants');
12
11
  require('zustand');
@@ -36,7 +35,6 @@ function _interopNamespace(e) {
36
35
 
37
36
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
38
37
  var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
39
- var mergeRefs__default = /*#__PURE__*/_interopDefault(mergeRefs);
40
38
  var useMeasure__default = /*#__PURE__*/_interopDefault(useMeasure);
41
39
 
42
40
  const DOM_EVENTS = {
@@ -158,8 +156,9 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
158
156
  ...resize
159
157
  });
160
158
  const canvasRef = React__namespace.useRef(null);
161
- const meshRef = React__namespace.useRef(null);
159
+ const divRef = React__namespace.useRef(null);
162
160
  const [canvas, setCanvas] = React__namespace.useState(null);
161
+ React__namespace.useImperativeHandle(forwardedRef, () => canvasRef.current);
163
162
  const handlePointerMissed = index.useMutableCallback(onPointerMissed);
164
163
  const [block, setBlock] = React__namespace.useState(false);
165
164
  const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
@@ -191,7 +190,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
191
190
  // Pass mutable reference to onPointerMissed so it's free to update
192
191
  onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
193
192
  onCreated: state => {
194
- state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
193
+ state.events.connect == null ? void 0 : state.events.connect(divRef.current);
195
194
  onCreated == null ? void 0 : onCreated(state);
196
195
  }
197
196
  });
@@ -211,7 +210,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
211
210
  if (canvas) return () => index.unmountComponentAtNode(canvas);
212
211
  }, [canvas]);
213
212
  return /*#__PURE__*/React__namespace.createElement("div", _extends({
214
- ref: mergeRefs__default["default"]([meshRef, containerRef]),
213
+ ref: divRef,
215
214
  style: {
216
215
  position: 'relative',
217
216
  width: '100%',
@@ -219,12 +218,18 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
219
218
  overflow: 'hidden',
220
219
  ...style
221
220
  }
222
- }, props), /*#__PURE__*/React__namespace.createElement("canvas", {
223
- ref: mergeRefs__default["default"]([canvasRef, forwardedRef]),
221
+ }, props), /*#__PURE__*/React__namespace.createElement("div", {
222
+ ref: containerRef,
223
+ style: {
224
+ width: '100%',
225
+ height: '100%'
226
+ }
227
+ }, /*#__PURE__*/React__namespace.createElement("canvas", {
228
+ ref: canvasRef,
224
229
  style: {
225
230
  display: 'block'
226
231
  }
227
- }, fallback));
232
+ }, fallback)));
228
233
  });
229
234
 
230
235
  exports.ReactThreeFiber = index.threeTypes;
@@ -1,9 +1,8 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-136ca0b0.esm.js';
2
- export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-136ca0b0.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-1e2a4313.esm.js';
2
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-1e2a4313.esm.js';
3
3
  import _extends from '@babel/runtime/helpers/esm/extends';
4
4
  import * as React from 'react';
5
5
  import * as THREE from 'three';
6
- import mergeRefs from 'react-merge-refs';
7
6
  import useMeasure from 'react-use-measure';
8
7
  import 'react-reconciler/constants';
9
8
  import 'zustand';
@@ -130,8 +129,9 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
130
129
  ...resize
131
130
  });
132
131
  const canvasRef = React.useRef(null);
133
- const meshRef = React.useRef(null);
132
+ const divRef = React.useRef(null);
134
133
  const [canvas, setCanvas] = React.useState(null);
134
+ React.useImperativeHandle(forwardedRef, () => canvasRef.current);
135
135
  const handlePointerMissed = useMutableCallback(onPointerMissed);
136
136
  const [block, setBlock] = React.useState(false);
137
137
  const [error, setError] = React.useState(false); // Suspend this component if block is a promise (2nd run)
@@ -163,7 +163,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
163
163
  // Pass mutable reference to onPointerMissed so it's free to update
164
164
  onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
165
165
  onCreated: state => {
166
- state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
166
+ state.events.connect == null ? void 0 : state.events.connect(divRef.current);
167
167
  onCreated == null ? void 0 : onCreated(state);
168
168
  }
169
169
  });
@@ -183,7 +183,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
183
183
  if (canvas) return () => unmountComponentAtNode(canvas);
184
184
  }, [canvas]);
185
185
  return /*#__PURE__*/React.createElement("div", _extends({
186
- ref: mergeRefs([meshRef, containerRef]),
186
+ ref: divRef,
187
187
  style: {
188
188
  position: 'relative',
189
189
  width: '100%',
@@ -191,12 +191,18 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
191
191
  overflow: 'hidden',
192
192
  ...style
193
193
  }
194
- }, props), /*#__PURE__*/React.createElement("canvas", {
195
- ref: mergeRefs([canvasRef, forwardedRef]),
194
+ }, props), /*#__PURE__*/React.createElement("div", {
195
+ ref: containerRef,
196
+ style: {
197
+ width: '100%',
198
+ height: '100%'
199
+ }
200
+ }, /*#__PURE__*/React.createElement("canvas", {
201
+ ref: canvasRef,
196
202
  style: {
197
203
  display: 'block'
198
204
  }
199
- }, fallback));
205
+ }, fallback)));
200
206
  });
201
207
 
202
208
  export { Canvas, createPointerEvents as events };