@react-three/fiber 8.0.15 → 8.0.18

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.
@@ -1,9 +1,9 @@
1
- import * as React from 'react';
2
- import type { Options as ResizeOptions } from 'react-use-measure';
3
- import { RenderProps } from '../core';
4
- export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
- children: React.ReactNode;
6
- fallback?: React.ReactNode;
7
- resize?: ResizeOptions;
8
- }
9
- export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
1
+ import * as React from 'react';
2
+ import type { Options as ResizeOptions } from 'react-use-measure';
3
+ import { RenderProps } from '../core';
4
+ export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
5
+ children: React.ReactNode;
6
+ fallback?: React.ReactNode;
7
+ resize?: ResizeOptions;
8
+ }
9
+ export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
@@ -1,4 +1,4 @@
1
- import { UseBoundStore } from 'zustand';
2
- import { RootState } from '../core/store';
3
- import { EventManager } from '../core/events';
4
- export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
1
+ import { UseBoundStore } from 'zustand';
2
+ import { RootState } from '../core/store';
3
+ import { EventManager } from '../core/events';
4
+ export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
@@ -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,
@@ -1058,7 +1066,7 @@ function createRenderer(roots, getEventPriority) {
1058
1066
  const localState = (_instance$__r3f3 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f3 : {}; // https://github.com/facebook/react/issues/20271
1059
1067
  // Returning true will trigger commitMount
1060
1068
 
1061
- return !!localState.handlers;
1069
+ return !!localState.handlers || !!localState.attach;
1062
1070
  },
1063
1071
 
1064
1072
  prepareUpdate(instance, type, oldProps, newProps) {
@@ -1104,6 +1112,11 @@ function createRenderer(roots, getEventPriority) {
1104
1112
 
1105
1113
  if (instance.raycast && localState.handlers && localState.eventCount) {
1106
1114
  instance.__r3f.root.getState().internal.interaction.push(instance);
1115
+ } // The attach attribute implies that the object attaches itself on the parent
1116
+
1117
+
1118
+ if (localState.attach) {
1119
+ attach(localState.parent, instance, localState.attach);
1107
1120
  }
1108
1121
  },
1109
1122
 
@@ -1117,27 +1130,11 @@ function createRenderer(roots, getEventPriority) {
1117
1130
  detachDeletedInstance: () => {},
1118
1131
 
1119
1132
  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
1133
  if (instance.isObject3D) instance.visible = false;
1129
1134
  invalidateInstance(instance);
1130
1135
  },
1131
1136
 
1132
1137
  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
1138
  if (instance.isObject3D && props.visible == null || props.visible) instance.visible = true;
1142
1139
  invalidateInstance(instance);
1143
1140
  },
@@ -1566,14 +1563,13 @@ function loadingFn(extensions, onProgress) {
1566
1563
  }, onProgress, error => reject(`Could not load ${input}: ${error.message}`)))));
1567
1564
  };
1568
1565
  }
1566
+
1569
1567
  /**
1570
1568
  * Synchronously loads and caches assets with a three loader.
1571
1569
  *
1572
1570
  * Note: this hook's caller must be wrapped with `React.Suspense`
1573
1571
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1574
1572
  */
1575
-
1576
-
1577
1573
  function useLoader(Proto, input, extensions, onProgress) {
1578
1574
  // Use suspense to load async assets
1579
1575
  const keys = Array.isArray(input) ? input : [input];
@@ -1641,7 +1637,7 @@ function createRoot(canvas) {
1641
1637
 
1642
1638
  const store = prevStore || createStore(invalidate, advance); // Create renderer
1643
1639
 
1644
- const fiber = prevFiber || reconciler.createContainer(store, ConcurrentRoot, null, false, null, null, logRecoverableError, null); // Map it
1640
+ const fiber = prevFiber || reconciler.createContainer(store, ConcurrentRoot, null, false, null, '', logRecoverableError, null); // Map it
1645
1641
 
1646
1642
  if (!prevRoot) roots.set(canvas, {
1647
1643
  fiber,
@@ -1762,11 +1758,12 @@ function createRoot(canvas) {
1762
1758
  if (!isBoolean) Object.assign(gl.shadowMap, shadows);else gl.shadowMap.type = THREE.PCFSoftShadowMap;
1763
1759
  if (old !== gl.shadowMap.enabled) gl.shadowMap.needsUpdate = true;
1764
1760
  }
1765
- } // Set color management
1761
+ } // Safely set color management if available.
1762
+ // Avoid accessing THREE.ColorManagement to play nice with older versions
1766
1763
 
1767
1764
 
1768
- if (THREE.ColorManagement) {
1769
- THREE.ColorManagement.legacyMode = legacy;
1765
+ if ('ColorManagement' in THREE) {
1766
+ setDeep(THREE, legacy, ['ColorManagement', 'legacyMode']);
1770
1767
  }
1771
1768
 
1772
1769
  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,
@@ -1085,7 +1093,7 @@ function createRenderer(roots, getEventPriority) {
1085
1093
  const localState = (_instance$__r3f3 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f3 : {}; // https://github.com/facebook/react/issues/20271
1086
1094
  // Returning true will trigger commitMount
1087
1095
 
1088
- return !!localState.handlers;
1096
+ return !!localState.handlers || !!localState.attach;
1089
1097
  },
1090
1098
 
1091
1099
  prepareUpdate(instance, type, oldProps, newProps) {
@@ -1131,6 +1139,11 @@ function createRenderer(roots, getEventPriority) {
1131
1139
 
1132
1140
  if (instance.raycast && localState.handlers && localState.eventCount) {
1133
1141
  instance.__r3f.root.getState().internal.interaction.push(instance);
1142
+ } // The attach attribute implies that the object attaches itself on the parent
1143
+
1144
+
1145
+ if (localState.attach) {
1146
+ attach(localState.parent, instance, localState.attach);
1134
1147
  }
1135
1148
  },
1136
1149
 
@@ -1144,27 +1157,11 @@ function createRenderer(roots, getEventPriority) {
1144
1157
  detachDeletedInstance: () => {},
1145
1158
 
1146
1159
  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
1160
  if (instance.isObject3D) instance.visible = false;
1156
1161
  invalidateInstance(instance);
1157
1162
  },
1158
1163
 
1159
1164
  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
1165
  if (instance.isObject3D && props.visible == null || props.visible) instance.visible = true;
1169
1166
  invalidateInstance(instance);
1170
1167
  },
@@ -1593,14 +1590,13 @@ function loadingFn(extensions, onProgress) {
1593
1590
  }, onProgress, error => reject(`Could not load ${input}: ${error.message}`)))));
1594
1591
  };
1595
1592
  }
1593
+
1596
1594
  /**
1597
1595
  * Synchronously loads and caches assets with a three loader.
1598
1596
  *
1599
1597
  * Note: this hook's caller must be wrapped with `React.Suspense`
1600
1598
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1601
1599
  */
1602
-
1603
-
1604
1600
  function useLoader(Proto, input, extensions, onProgress) {
1605
1601
  // Use suspense to load async assets
1606
1602
  const keys = Array.isArray(input) ? input : [input];
@@ -1668,7 +1664,7 @@ function createRoot(canvas) {
1668
1664
 
1669
1665
  const store = prevStore || createStore(invalidate, advance); // Create renderer
1670
1666
 
1671
- const fiber = prevFiber || reconciler.createContainer(store, constants.ConcurrentRoot, null, false, null, null, logRecoverableError, null); // Map it
1667
+ const fiber = prevFiber || reconciler.createContainer(store, constants.ConcurrentRoot, null, false, null, '', logRecoverableError, null); // Map it
1672
1668
 
1673
1669
  if (!prevRoot) roots.set(canvas, {
1674
1670
  fiber,
@@ -1789,11 +1785,12 @@ function createRoot(canvas) {
1789
1785
  if (!isBoolean) Object.assign(gl.shadowMap, shadows);else gl.shadowMap.type = THREE__namespace.PCFSoftShadowMap;
1790
1786
  if (old !== gl.shadowMap.enabled) gl.shadowMap.needsUpdate = true;
1791
1787
  }
1792
- } // Set color management
1788
+ } // Safely set color management if available.
1789
+ // Avoid accessing THREE.ColorManagement to play nice with older versions
1793
1790
 
1794
1791
 
1795
- if (THREE__namespace.ColorManagement) {
1796
- THREE__namespace.ColorManagement.legacyMode = legacy;
1792
+ if ('ColorManagement' in THREE__namespace) {
1793
+ setDeep(THREE__namespace, legacy, ['ColorManagement', 'legacyMode']);
1797
1794
  }
1798
1795
 
1799
1796
  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,
@@ -1085,7 +1093,7 @@ function createRenderer(roots, getEventPriority) {
1085
1093
  const localState = (_instance$__r3f3 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f3 : {}; // https://github.com/facebook/react/issues/20271
1086
1094
  // Returning true will trigger commitMount
1087
1095
 
1088
- return !!localState.handlers;
1096
+ return !!localState.handlers || !!localState.attach;
1089
1097
  },
1090
1098
 
1091
1099
  prepareUpdate(instance, type, oldProps, newProps) {
@@ -1131,6 +1139,11 @@ function createRenderer(roots, getEventPriority) {
1131
1139
 
1132
1140
  if (instance.raycast && localState.handlers && localState.eventCount) {
1133
1141
  instance.__r3f.root.getState().internal.interaction.push(instance);
1142
+ } // The attach attribute implies that the object attaches itself on the parent
1143
+
1144
+
1145
+ if (localState.attach) {
1146
+ attach(localState.parent, instance, localState.attach);
1134
1147
  }
1135
1148
  },
1136
1149
 
@@ -1144,27 +1157,11 @@ function createRenderer(roots, getEventPriority) {
1144
1157
  detachDeletedInstance: () => {},
1145
1158
 
1146
1159
  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
1160
  if (instance.isObject3D) instance.visible = false;
1156
1161
  invalidateInstance(instance);
1157
1162
  },
1158
1163
 
1159
1164
  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
1165
  if (instance.isObject3D && props.visible == null || props.visible) instance.visible = true;
1169
1166
  invalidateInstance(instance);
1170
1167
  },
@@ -1593,14 +1590,13 @@ function loadingFn(extensions, onProgress) {
1593
1590
  }, onProgress, error => reject(`Could not load ${input}: ${error.message}`)))));
1594
1591
  };
1595
1592
  }
1593
+
1596
1594
  /**
1597
1595
  * Synchronously loads and caches assets with a three loader.
1598
1596
  *
1599
1597
  * Note: this hook's caller must be wrapped with `React.Suspense`
1600
1598
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1601
1599
  */
1602
-
1603
-
1604
1600
  function useLoader(Proto, input, extensions, onProgress) {
1605
1601
  // Use suspense to load async assets
1606
1602
  const keys = Array.isArray(input) ? input : [input];
@@ -1668,7 +1664,7 @@ function createRoot(canvas) {
1668
1664
 
1669
1665
  const store = prevStore || createStore(invalidate, advance); // Create renderer
1670
1666
 
1671
- const fiber = prevFiber || reconciler.createContainer(store, constants.ConcurrentRoot, null, false, null, null, logRecoverableError, null); // Map it
1667
+ const fiber = prevFiber || reconciler.createContainer(store, constants.ConcurrentRoot, null, false, null, '', logRecoverableError, null); // Map it
1672
1668
 
1673
1669
  if (!prevRoot) roots.set(canvas, {
1674
1670
  fiber,
@@ -1789,11 +1785,12 @@ function createRoot(canvas) {
1789
1785
  if (!isBoolean) Object.assign(gl.shadowMap, shadows);else gl.shadowMap.type = THREE__namespace.PCFSoftShadowMap;
1790
1786
  if (old !== gl.shadowMap.enabled) gl.shadowMap.needsUpdate = true;
1791
1787
  }
1792
- } // Set color management
1788
+ } // Safely set color management if available.
1789
+ // Avoid accessing THREE.ColorManagement to play nice with older versions
1793
1790
 
1794
1791
 
1795
- if (THREE__namespace.ColorManagement) {
1796
- THREE__namespace.ColorManagement.legacyMode = legacy;
1792
+ if ('ColorManagement' in THREE__namespace) {
1793
+ setDeep(THREE__namespace, legacy, ['ColorManagement', 'legacyMode']);
1797
1794
  }
1798
1795
 
1799
1796
  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-606d3385.cjs.dev.js');
5
+ var index = require('./index-c937c162.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-05d06e15.cjs.prod.js');
5
+ var index = require('./index-e2e71da1.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-208291a3.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-208291a3.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-acedf326.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-acedf326.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 };