@react-three/fiber 8.0.10 → 8.0.13

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.
@@ -19,14 +19,12 @@ function _interopNamespace(e) {
19
19
  var d = Object.getOwnPropertyDescriptor(e, k);
20
20
  Object.defineProperty(n, k, d.get ? d : {
21
21
  enumerable: true,
22
- get: function () {
23
- return e[k];
24
- }
22
+ get: function () { return e[k]; }
25
23
  });
26
24
  }
27
25
  });
28
26
  }
29
- n['default'] = e;
27
+ n["default"] = e;
30
28
  return Object.freeze(n);
31
29
  }
32
30
 
@@ -95,29 +93,6 @@ const getRootState = obj => {
95
93
 
96
94
  return (_r3f = obj.__r3f) == null ? void 0 : _r3f.root.getState();
97
95
  };
98
- /**
99
- * Picks or omits keys from an object
100
- * `omit` will filter out keys, and otherwise cherry-pick them.
101
- */
102
-
103
- function filterKeys(obj, omit, ...keys) {
104
- const keysToSelect = new Set(keys);
105
- return Object.entries(obj).reduce((acc, [key, value]) => {
106
- const shouldInclude = !omit;
107
- if (keysToSelect.has(key) === shouldInclude) acc[key] = value;
108
- return acc;
109
- }, {});
110
- }
111
- /**
112
- * Clones an object and cherry-picks keys.
113
- */
114
-
115
- const pick = (obj, keys) => filterKeys(obj, false, ...keys);
116
- /**
117
- * Clones an object and prunes or omits keys.
118
- */
119
-
120
- const omit = (obj, keys) => filterKeys(obj, true, ...keys);
121
96
  // A collection of compare functions
122
97
  const is = {
123
98
  obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
@@ -253,7 +228,10 @@ function detach(parent, child, type) {
253
228
  target,
254
229
  key
255
230
  } = resolve(parent, type);
256
- target[key] = child.__r3f.previousAttach;
231
+ const previous = child.__r3f.previousAttach; // When the previous value was undefined, it means the value was never set to begin with
232
+
233
+ if (previous === undefined) delete target[key]; // Otherwise set the previous value
234
+ else target[key] = previous;
257
235
  } else (_child$__r3f = child.__r3f) == null ? void 0 : _child$__r3f.previousAttach == null ? void 0 : _child$__r3f.previousAttach(parent, child);
258
236
 
259
237
  (_child$__r3f2 = child.__r3f) == null ? true : delete _child$__r3f2.previousAttach;
@@ -343,12 +321,16 @@ function applyProps$1(instance, data) {
343
321
 
344
322
  if (value === DEFAULT + 'remove') {
345
323
  if (targetProp && targetProp.constructor) {
324
+ var _memoized$args;
325
+
346
326
  // use the prop constructor to find the default it should be
347
- value = new targetProp.constructor(...memoized.args);
327
+ value = new targetProp.constructor(...((_memoized$args = memoized.args) != null ? _memoized$args : []));
348
328
  } else if (currentInstance.constructor) {
329
+ var _currentInstance$__r;
330
+
349
331
  // create a blank slate of the instance and copy the particular parameter.
350
332
  // @ts-ignore
351
- const defaultClassCall = new currentInstance.constructor(...currentInstance.__r3f.memoizedProps.args);
333
+ const defaultClassCall = new currentInstance.constructor(...((_currentInstance$__r = currentInstance.__r3f.memoizedProps.args) != null ? _currentInstance$__r : []));
352
334
  value = defaultClassCall[targetProp]; // destory the instance
353
335
 
354
336
  if (defaultClassCall.dispose) defaultClassCall.dispose(); // instance does not have constructor, just set it to 0
@@ -363,35 +345,35 @@ function applyProps$1(instance, data) {
363
345
  localState.eventCount = Object.keys(localState.handlers).length;
364
346
  } // Special treatment for objects with support for set/copy, and layers
365
347
  else if (targetProp && targetProp.set && (targetProp.copy || targetProp instanceof THREE__namespace.Layers)) {
366
- // If value is an array
367
- if (Array.isArray(value)) {
368
- if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
369
- } // Test again target.copy(class) next ...
370
- else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) {
371
- targetProp.copy(value);
372
- } // If nothing else fits, just set the single value, ignore undefined
373
- // https://github.com/pmndrs/react-three-fiber/issues/274
374
- else if (value !== undefined) {
375
- const isColor = targetProp instanceof THREE__namespace.Color; // Allow setting array scalars
376
-
377
- if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
378
- else if (targetProp instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) targetProp.mask = value.mask; // Otherwise just set ...
379
- else targetProp.set(value); // For versions of three which don't support THREE.ColorManagement,
380
- // Auto-convert sRGB colors
381
- // https://github.com/pmndrs/react-three-fiber/issues/344
382
-
383
- const supportsColorManagement = THREE__namespace.ColorManagement;
384
- if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
385
- } // Else, just overwrite the value
386
-
387
- } else {
388
- currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
348
+ // If value is an array
349
+ if (Array.isArray(value)) {
350
+ if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
351
+ } // Test again target.copy(class) next ...
352
+ else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) {
353
+ targetProp.copy(value);
354
+ } // If nothing else fits, just set the single value, ignore undefined
355
+ // https://github.com/pmndrs/react-three-fiber/issues/274
356
+ else if (value !== undefined) {
357
+ const isColor = targetProp instanceof THREE__namespace.Color; // Allow setting array scalars
358
+
359
+ if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
360
+ else if (targetProp instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) targetProp.mask = value.mask; // Otherwise just set ...
361
+ else targetProp.set(value); // For versions of three which don't support THREE.ColorManagement,
362
+ // Auto-convert sRGB colors
389
363
  // https://github.com/pmndrs/react-three-fiber/issues/344
390
364
 
391
- if (!rootState.linear && currentInstance[key] instanceof THREE__namespace.Texture) {
392
- currentInstance[key].encoding = THREE__namespace.sRGBEncoding;
393
- }
365
+ const supportsColorManagement = THREE__namespace.ColorManagement;
366
+ if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
367
+ } // Else, just overwrite the value
368
+
369
+ } else {
370
+ currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
371
+ // https://github.com/pmndrs/react-three-fiber/issues/344
372
+
373
+ if (!rootState.linear && currentInstance[key] instanceof THREE__namespace.Texture) {
374
+ currentInstance[key].encoding = THREE__namespace.sRGBEncoding;
394
375
  }
376
+ }
395
377
 
396
378
  invalidateInstance(instance);
397
379
  });
@@ -1075,7 +1057,7 @@ function createRenderer(roots, getEventPriority) {
1075
1057
  });
1076
1058
  }
1077
1059
 
1078
- const reconciler = Reconciler__default['default']({
1060
+ const reconciler = Reconciler__default["default"]({
1079
1061
  createInstance,
1080
1062
  removeChild,
1081
1063
  appendChild,
@@ -1160,7 +1142,6 @@ function createRenderer(roots, getEventPriority) {
1160
1142
  shouldSetTextContent: () => false,
1161
1143
  clearContainer: () => false,
1162
1144
  detachDeletedInstance: () => {},
1163
- createTextInstance: () => {},
1164
1145
 
1165
1146
  hideInstance(instance) {
1166
1147
  var _instance$__r3f5;
@@ -1188,10 +1169,11 @@ function createRenderer(roots, getEventPriority) {
1188
1169
  invalidateInstance(instance);
1189
1170
  },
1190
1171
 
1172
+ createTextInstance: () => {},
1191
1173
  hideTextInstance: () => {
1192
1174
  throw new Error('Text is not allowed in the R3F tree.');
1193
1175
  },
1194
- // prettier-ignore
1176
+ unhideTextInstance: () => {},
1195
1177
  getCurrentEventPriority: () => getEventPriority ? getEventPriority() : constants.DefaultEventPriority,
1196
1178
  // @ts-ignore
1197
1179
  now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : undefined,
@@ -1208,11 +1190,12 @@ function createRenderer(roots, getEventPriority) {
1208
1190
  };
1209
1191
  }
1210
1192
 
1193
+ const privateKeys = ['set', 'get', 'setSize', 'setFrameloop', 'setDpr', 'events', 'invalidate', 'advance', 'size', 'viewport'];
1211
1194
  const isRenderer = def => !!(def != null && def.render);
1212
1195
  const context = /*#__PURE__*/React__namespace.createContext(null);
1213
1196
 
1214
1197
  const createStore = (invalidate, advance) => {
1215
- const rootState = create__default['default']((set, get) => {
1198
+ const rootState = create__default["default"]((set, get) => {
1216
1199
  const position = new THREE__namespace.Vector3();
1217
1200
  const defaultTarget = new THREE__namespace.Vector3();
1218
1201
  const tempTarget = new THREE__namespace.Vector3();
@@ -1960,29 +1943,28 @@ function Portal({
1960
1943
  const previousRoot = useStore();
1961
1944
  const [raycaster] = React__namespace.useState(() => new THREE__namespace.Raycaster());
1962
1945
  const [pointer] = React__namespace.useState(() => new THREE__namespace.Vector2());
1963
- const inject = React__namespace.useCallback((state, injectState) => {
1964
- const intersect = { ...state
1965
- };
1966
-
1967
- if (injectState) {
1968
- // Only the fields of "state" that do not differ from injectState
1969
- // Some props should be off-limits
1970
- // Otherwise filter out the props that are different and let the inject layer take precedence
1971
- Object.keys(state).forEach(key => {
1972
- if (state[key] !== injectState[key] && !['internal', 'performance'].includes(key)) {
1973
- delete intersect[key];
1974
- }
1975
- });
1976
- }
1977
-
1946
+ const inject = React__namespace.useCallback((rootState, injectState) => {
1947
+ const intersect = { ...rootState
1948
+ }; // all prev state props
1949
+ // Only the fields of "rootState" that do not differ from injectState
1950
+ // Some props should be off-limits
1951
+ // Otherwise filter out the props that are different and let the inject layer take precedence
1952
+
1953
+ Object.keys(rootState).forEach(key => {
1954
+ if ( // Some props should be off-limits
1955
+ privateKeys.includes(key) || // Otherwise filter out the props that are different and let the inject layer take precedence
1956
+ rootState[key] !== injectState[key]) {
1957
+ delete intersect[key];
1958
+ }
1959
+ });
1978
1960
  let viewport = undefined;
1979
1961
 
1980
1962
  if (injectState && size) {
1981
1963
  const camera = injectState.camera; // Calculate the override viewport, if present
1982
1964
 
1983
- viewport = state.viewport.getCurrentViewport(camera, new THREE__namespace.Vector3(), size); // Update the portal camera, if it differs from the previous layer
1965
+ viewport = rootState.viewport.getCurrentViewport(camera, new THREE__namespace.Vector3(), size); // Update the portal camera, if it differs from the previous layer
1984
1966
 
1985
- if (camera !== state.camera) updateCamera(camera, size);
1967
+ if (camera !== rootState.camera) updateCamera(camera, size);
1986
1968
  }
1987
1969
 
1988
1970
  return { // The intersect consists of the previous root state
@@ -1995,14 +1977,14 @@ function Portal({
1995
1977
  // Their previous root is the layer before it
1996
1978
  previousRoot,
1997
1979
  // Events, size and viewport can be overridden by the inject layer
1998
- events: { ...state.events,
1980
+ events: { ...rootState.events,
1999
1981
  ...(injectState == null ? void 0 : injectState.events),
2000
1982
  ...events
2001
1983
  },
2002
- size: { ...state.size,
1984
+ size: { ...rootState.size,
2003
1985
  ...size
2004
1986
  },
2005
- viewport: { ...state.viewport,
1987
+ viewport: { ...rootState.viewport,
2006
1988
  ...viewport
2007
1989
  },
2008
1990
  ...rest
@@ -2010,9 +1992,20 @@ function Portal({
2010
1992
  }, [state]);
2011
1993
  const [usePortalStore] = React__namespace.useState(() => {
2012
1994
  // Create a mirrored store, based on the previous root with a few overrides ...
2013
- new THREE__namespace.Vector3();
2014
1995
  const previousState = previousRoot.getState();
2015
- const store = create__default['default']((set, get) => ({ ...inject(previousState),
1996
+ const store = create__default["default"]((set, get) => ({ ...previousState,
1997
+ scene: container,
1998
+ raycaster,
1999
+ pointer,
2000
+ mouse: pointer,
2001
+ previousRoot,
2002
+ events: { ...previousState.events,
2003
+ ...events
2004
+ },
2005
+ size: { ...previousState.size,
2006
+ ...size
2007
+ },
2008
+ ...rest,
2016
2009
  // Set and get refer to this root-state
2017
2010
  set,
2018
2011
  get,
@@ -2064,8 +2057,6 @@ exports.dispose = dispose;
2064
2057
  exports.extend = extend;
2065
2058
  exports.getRootState = getRootState;
2066
2059
  exports.invalidate = invalidate;
2067
- exports.omit = omit;
2068
- exports.pick = pick;
2069
2060
  exports.reconciler = reconciler;
2070
2061
  exports.render = render;
2071
2062
  exports.roots = roots;
@@ -66,29 +66,6 @@ const getRootState = obj => {
66
66
 
67
67
  return (_r3f = obj.__r3f) == null ? void 0 : _r3f.root.getState();
68
68
  };
69
- /**
70
- * Picks or omits keys from an object
71
- * `omit` will filter out keys, and otherwise cherry-pick them.
72
- */
73
-
74
- function filterKeys(obj, omit, ...keys) {
75
- const keysToSelect = new Set(keys);
76
- return Object.entries(obj).reduce((acc, [key, value]) => {
77
- const shouldInclude = !omit;
78
- if (keysToSelect.has(key) === shouldInclude) acc[key] = value;
79
- return acc;
80
- }, {});
81
- }
82
- /**
83
- * Clones an object and cherry-picks keys.
84
- */
85
-
86
- const pick = (obj, keys) => filterKeys(obj, false, ...keys);
87
- /**
88
- * Clones an object and prunes or omits keys.
89
- */
90
-
91
- const omit = (obj, keys) => filterKeys(obj, true, ...keys);
92
69
  // A collection of compare functions
93
70
  const is = {
94
71
  obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
@@ -224,7 +201,10 @@ function detach(parent, child, type) {
224
201
  target,
225
202
  key
226
203
  } = resolve(parent, type);
227
- target[key] = child.__r3f.previousAttach;
204
+ const previous = child.__r3f.previousAttach; // When the previous value was undefined, it means the value was never set to begin with
205
+
206
+ if (previous === undefined) delete target[key]; // Otherwise set the previous value
207
+ else target[key] = previous;
228
208
  } else (_child$__r3f = child.__r3f) == null ? void 0 : _child$__r3f.previousAttach == null ? void 0 : _child$__r3f.previousAttach(parent, child);
229
209
 
230
210
  (_child$__r3f2 = child.__r3f) == null ? true : delete _child$__r3f2.previousAttach;
@@ -314,12 +294,16 @@ function applyProps$1(instance, data) {
314
294
 
315
295
  if (value === DEFAULT + 'remove') {
316
296
  if (targetProp && targetProp.constructor) {
297
+ var _memoized$args;
298
+
317
299
  // use the prop constructor to find the default it should be
318
- value = new targetProp.constructor(...memoized.args);
300
+ value = new targetProp.constructor(...((_memoized$args = memoized.args) != null ? _memoized$args : []));
319
301
  } else if (currentInstance.constructor) {
302
+ var _currentInstance$__r;
303
+
320
304
  // create a blank slate of the instance and copy the particular parameter.
321
305
  // @ts-ignore
322
- const defaultClassCall = new currentInstance.constructor(...currentInstance.__r3f.memoizedProps.args);
306
+ const defaultClassCall = new currentInstance.constructor(...((_currentInstance$__r = currentInstance.__r3f.memoizedProps.args) != null ? _currentInstance$__r : []));
323
307
  value = defaultClassCall[targetProp]; // destory the instance
324
308
 
325
309
  if (defaultClassCall.dispose) defaultClassCall.dispose(); // instance does not have constructor, just set it to 0
@@ -334,35 +318,35 @@ function applyProps$1(instance, data) {
334
318
  localState.eventCount = Object.keys(localState.handlers).length;
335
319
  } // Special treatment for objects with support for set/copy, and layers
336
320
  else if (targetProp && targetProp.set && (targetProp.copy || targetProp instanceof THREE.Layers)) {
337
- // If value is an array
338
- if (Array.isArray(value)) {
339
- if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
340
- } // Test again target.copy(class) next ...
341
- else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) {
342
- targetProp.copy(value);
343
- } // If nothing else fits, just set the single value, ignore undefined
344
- // https://github.com/pmndrs/react-three-fiber/issues/274
345
- else if (value !== undefined) {
346
- const isColor = targetProp instanceof THREE.Color; // Allow setting array scalars
347
-
348
- if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
349
- else if (targetProp instanceof THREE.Layers && value instanceof THREE.Layers) targetProp.mask = value.mask; // Otherwise just set ...
350
- else targetProp.set(value); // For versions of three which don't support THREE.ColorManagement,
351
- // Auto-convert sRGB colors
352
- // https://github.com/pmndrs/react-three-fiber/issues/344
353
-
354
- const supportsColorManagement = THREE.ColorManagement;
355
- if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
356
- } // Else, just overwrite the value
357
-
358
- } else {
359
- currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
321
+ // If value is an array
322
+ if (Array.isArray(value)) {
323
+ if (targetProp.fromArray) targetProp.fromArray(value);else targetProp.set(...value);
324
+ } // Test again target.copy(class) next ...
325
+ else if (targetProp.copy && value && value.constructor && targetProp.constructor.name === value.constructor.name) {
326
+ targetProp.copy(value);
327
+ } // If nothing else fits, just set the single value, ignore undefined
328
+ // https://github.com/pmndrs/react-three-fiber/issues/274
329
+ else if (value !== undefined) {
330
+ const isColor = targetProp instanceof THREE.Color; // Allow setting array scalars
331
+
332
+ if (!isColor && targetProp.setScalar) targetProp.setScalar(value); // Layers have no copy function, we must therefore copy the mask property
333
+ else if (targetProp instanceof THREE.Layers && value instanceof THREE.Layers) targetProp.mask = value.mask; // Otherwise just set ...
334
+ else targetProp.set(value); // For versions of three which don't support THREE.ColorManagement,
335
+ // Auto-convert sRGB colors
360
336
  // https://github.com/pmndrs/react-three-fiber/issues/344
361
337
 
362
- if (!rootState.linear && currentInstance[key] instanceof THREE.Texture) {
363
- currentInstance[key].encoding = THREE.sRGBEncoding;
364
- }
338
+ const supportsColorManagement = THREE.ColorManagement;
339
+ if (!supportsColorManagement && !rootState.linear && isColor) targetProp.convertSRGBToLinear();
340
+ } // Else, just overwrite the value
341
+
342
+ } else {
343
+ currentInstance[key] = value; // Auto-convert sRGB textures, for now ...
344
+ // https://github.com/pmndrs/react-three-fiber/issues/344
345
+
346
+ if (!rootState.linear && currentInstance[key] instanceof THREE.Texture) {
347
+ currentInstance[key].encoding = THREE.sRGBEncoding;
365
348
  }
349
+ }
366
350
 
367
351
  invalidateInstance(instance);
368
352
  });
@@ -1131,7 +1115,6 @@ function createRenderer(roots, getEventPriority) {
1131
1115
  shouldSetTextContent: () => false,
1132
1116
  clearContainer: () => false,
1133
1117
  detachDeletedInstance: () => {},
1134
- createTextInstance: () => {},
1135
1118
 
1136
1119
  hideInstance(instance) {
1137
1120
  var _instance$__r3f5;
@@ -1159,10 +1142,11 @@ function createRenderer(roots, getEventPriority) {
1159
1142
  invalidateInstance(instance);
1160
1143
  },
1161
1144
 
1145
+ createTextInstance: () => {},
1162
1146
  hideTextInstance: () => {
1163
1147
  throw new Error('Text is not allowed in the R3F tree.');
1164
1148
  },
1165
- // prettier-ignore
1149
+ unhideTextInstance: () => {},
1166
1150
  getCurrentEventPriority: () => getEventPriority ? getEventPriority() : DefaultEventPriority,
1167
1151
  // @ts-ignore
1168
1152
  now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : undefined,
@@ -1179,6 +1163,7 @@ function createRenderer(roots, getEventPriority) {
1179
1163
  };
1180
1164
  }
1181
1165
 
1166
+ const privateKeys = ['set', 'get', 'setSize', 'setFrameloop', 'setDpr', 'events', 'invalidate', 'advance', 'size', 'viewport'];
1182
1167
  const isRenderer = def => !!(def != null && def.render);
1183
1168
  const context = /*#__PURE__*/React.createContext(null);
1184
1169
 
@@ -1931,29 +1916,28 @@ function Portal({
1931
1916
  const previousRoot = useStore();
1932
1917
  const [raycaster] = React.useState(() => new THREE.Raycaster());
1933
1918
  const [pointer] = React.useState(() => new THREE.Vector2());
1934
- const inject = React.useCallback((state, injectState) => {
1935
- const intersect = { ...state
1936
- };
1937
-
1938
- if (injectState) {
1939
- // Only the fields of "state" that do not differ from injectState
1940
- // Some props should be off-limits
1941
- // Otherwise filter out the props that are different and let the inject layer take precedence
1942
- Object.keys(state).forEach(key => {
1943
- if (state[key] !== injectState[key] && !['internal', 'performance'].includes(key)) {
1944
- delete intersect[key];
1945
- }
1946
- });
1947
- }
1948
-
1919
+ const inject = React.useCallback((rootState, injectState) => {
1920
+ const intersect = { ...rootState
1921
+ }; // all prev state props
1922
+ // Only the fields of "rootState" that do not differ from injectState
1923
+ // Some props should be off-limits
1924
+ // Otherwise filter out the props that are different and let the inject layer take precedence
1925
+
1926
+ Object.keys(rootState).forEach(key => {
1927
+ if ( // Some props should be off-limits
1928
+ privateKeys.includes(key) || // Otherwise filter out the props that are different and let the inject layer take precedence
1929
+ rootState[key] !== injectState[key]) {
1930
+ delete intersect[key];
1931
+ }
1932
+ });
1949
1933
  let viewport = undefined;
1950
1934
 
1951
1935
  if (injectState && size) {
1952
1936
  const camera = injectState.camera; // Calculate the override viewport, if present
1953
1937
 
1954
- viewport = state.viewport.getCurrentViewport(camera, new THREE.Vector3(), size); // Update the portal camera, if it differs from the previous layer
1938
+ viewport = rootState.viewport.getCurrentViewport(camera, new THREE.Vector3(), size); // Update the portal camera, if it differs from the previous layer
1955
1939
 
1956
- if (camera !== state.camera) updateCamera(camera, size);
1940
+ if (camera !== rootState.camera) updateCamera(camera, size);
1957
1941
  }
1958
1942
 
1959
1943
  return { // The intersect consists of the previous root state
@@ -1966,14 +1950,14 @@ function Portal({
1966
1950
  // Their previous root is the layer before it
1967
1951
  previousRoot,
1968
1952
  // Events, size and viewport can be overridden by the inject layer
1969
- events: { ...state.events,
1953
+ events: { ...rootState.events,
1970
1954
  ...(injectState == null ? void 0 : injectState.events),
1971
1955
  ...events
1972
1956
  },
1973
- size: { ...state.size,
1957
+ size: { ...rootState.size,
1974
1958
  ...size
1975
1959
  },
1976
- viewport: { ...state.viewport,
1960
+ viewport: { ...rootState.viewport,
1977
1961
  ...viewport
1978
1962
  },
1979
1963
  ...rest
@@ -1981,9 +1965,20 @@ function Portal({
1981
1965
  }, [state]);
1982
1966
  const [usePortalStore] = React.useState(() => {
1983
1967
  // Create a mirrored store, based on the previous root with a few overrides ...
1984
- new THREE.Vector3();
1985
1968
  const previousState = previousRoot.getState();
1986
- const store = create((set, get) => ({ ...inject(previousState),
1969
+ const store = create((set, get) => ({ ...previousState,
1970
+ scene: container,
1971
+ raycaster,
1972
+ pointer,
1973
+ mouse: pointer,
1974
+ previousRoot,
1975
+ events: { ...previousState.events,
1976
+ ...events
1977
+ },
1978
+ size: { ...previousState.size,
1979
+ ...size
1980
+ },
1981
+ ...rest,
1987
1982
  // Set and get refer to this root-state
1988
1983
  set,
1989
1984
  get,
@@ -2019,4 +2014,4 @@ reconciler.injectIntoDevTools({
2019
2014
  });
2020
2015
  const act = React.unstable_act;
2021
2016
 
2022
- export { useGraph as A, Block as B, useLoader as C, ErrorBoundary as E, createRoot as a, useIsomorphicLayoutEffect as b, createEvents as c, unmountComponentAtNode as d, extend as e, context as f, createPortal as g, reconciler as h, applyProps as i, dispose as j, invalidate as k, advance as l, addEffect as m, addAfterEffect as n, omit as o, pick as p, addTail as q, render as r, getRootState as s, threeTypes as t, useMutableCallback as u, act as v, roots as w, useStore as x, useThree as y, useFrame as z };
2017
+ export { Block as B, ErrorBoundary as E, createRoot as a, useIsomorphicLayoutEffect as b, createEvents as c, unmountComponentAtNode as d, extend as e, context as f, createPortal as g, reconciler as h, applyProps as i, dispose as j, invalidate as k, advance as l, addEffect as m, addAfterEffect as n, addTail as o, getRootState as p, act as q, render as r, roots as s, threeTypes as t, useMutableCallback as u, useStore as v, useThree as w, useFrame as x, useGraph as y, useLoader as z };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-018d2d45.cjs.dev.js');
5
+ var index = require('./index-9ced08b3.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -25,14 +25,12 @@ function _interopNamespace(e) {
25
25
  var d = Object.getOwnPropertyDescriptor(e, k);
26
26
  Object.defineProperty(n, k, d.get ? d : {
27
27
  enumerable: true,
28
- get: function () {
29
- return e[k];
30
- }
28
+ get: function () { return e[k]; }
31
29
  });
32
30
  }
33
31
  });
34
32
  }
35
- n['default'] = e;
33
+ n["default"] = e;
36
34
  return Object.freeze(n);
37
35
  }
38
36
 
@@ -119,19 +117,29 @@ function createPointerEvents(store) {
119
117
  };
120
118
  }
121
119
 
122
- const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'dpr', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
123
120
  /**
124
121
  * A DOM canvas which accepts threejs elements as children.
125
122
  * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
126
123
  */
127
-
128
124
  const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
129
125
  children,
130
126
  fallback,
131
127
  resize,
132
128
  style,
133
- onPointerMissed,
129
+ gl,
134
130
  events = createPointerEvents,
131
+ shadows,
132
+ linear,
133
+ flat,
134
+ legacy,
135
+ orthographic,
136
+ frameloop,
137
+ dpr,
138
+ performance,
139
+ raycaster,
140
+ camera,
141
+ onPointerMissed,
142
+ onCreated,
135
143
  ...props
136
144
  }, forwardedRef) {
137
145
  // Create a known catalogue of Threejs-native elements
@@ -141,7 +149,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
141
149
  const [containerRef, {
142
150
  width,
143
151
  height
144
- }] = useMeasure__default['default']({
152
+ }] = useMeasure__default["default"]({
145
153
  scroll: true,
146
154
  debounce: {
147
155
  scroll: 50,
@@ -153,8 +161,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
153
161
  const meshRef = React__namespace.useRef(null);
154
162
  const [canvas, setCanvas] = React__namespace.useState(null);
155
163
  const handlePointerMissed = index.useMutableCallback(onPointerMissed);
156
- const canvasProps = index.pick(props, CANVAS_PROPS);
157
- const divProps = index.omit(props, CANVAS_PROPS);
158
164
  const [block, setBlock] = React__namespace.useState(false);
159
165
  const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
160
166
 
@@ -165,18 +171,29 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
165
171
 
166
172
  if (width > 0 && height > 0 && canvas) {
167
173
  if (!root.current) root.current = index.createRoot(canvas);
168
- root.current.configure({ ...canvasProps,
169
- // Pass mutable reference to onPointerMissed so it's free to update
170
- onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
171
- onCreated: state => {
172
- state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
173
- canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
174
- },
174
+ root.current.configure({
175
+ gl,
176
+ events,
177
+ shadows,
178
+ linear,
179
+ flat,
180
+ legacy,
181
+ orthographic,
182
+ frameloop,
183
+ dpr,
184
+ performance,
185
+ raycaster,
186
+ camera,
175
187
  size: {
176
188
  width,
177
189
  height
178
190
  },
179
- events
191
+ // Pass mutable reference to onPointerMissed so it's free to update
192
+ onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
193
+ onCreated: state => {
194
+ state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
195
+ onCreated == null ? void 0 : onCreated(state);
196
+ }
180
197
  });
181
198
  root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
182
199
  set: setError
@@ -194,7 +211,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
194
211
  if (canvas) return () => index.unmountComponentAtNode(canvas);
195
212
  }, [canvas]);
196
213
  return /*#__PURE__*/React__namespace.createElement("div", _extends({
197
- ref: mergeRefs__default['default']([meshRef, containerRef]),
214
+ ref: mergeRefs__default["default"]([meshRef, containerRef]),
198
215
  style: {
199
216
  position: 'relative',
200
217
  width: '100%',
@@ -202,8 +219,8 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
202
219
  overflow: 'hidden',
203
220
  ...style
204
221
  }
205
- }, divProps), /*#__PURE__*/React__namespace.createElement("canvas", {
206
- ref: mergeRefs__default['default']([canvasRef, forwardedRef]),
222
+ }, props), /*#__PURE__*/React__namespace.createElement("canvas", {
223
+ ref: mergeRefs__default["default"]([canvasRef, forwardedRef]),
207
224
  style: {
208
225
  display: 'block'
209
226
  }