@react-three/fiber 9.0.0-rc.3 → 9.0.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +1076 -1076
  2. package/dist/declarations/src/core/events.d.ts +91 -91
  3. package/dist/declarations/src/core/hooks.d.ts +51 -50
  4. package/dist/declarations/src/core/index.d.ts +13 -13
  5. package/dist/declarations/src/core/loop.d.ts +31 -31
  6. package/dist/declarations/src/core/reconciler.d.ts +52 -52
  7. package/dist/declarations/src/core/renderer.d.ts +89 -87
  8. package/dist/declarations/src/core/store.d.ts +130 -130
  9. package/dist/declarations/src/core/utils.d.ts +186 -185
  10. package/dist/declarations/src/index.d.ts +6 -6
  11. package/dist/declarations/src/native/Canvas.d.ts +13 -13
  12. package/dist/declarations/src/native/events.d.ts +4 -4
  13. package/dist/declarations/src/native.d.ts +6 -6
  14. package/dist/declarations/src/three-types.d.ts +62 -62
  15. package/dist/declarations/src/web/Canvas.d.ts +23 -23
  16. package/dist/declarations/src/web/events.d.ts +4 -4
  17. package/dist/declarations/src/web/use-measure.d.ts +34 -34
  18. package/dist/{events-484fb9c5.cjs.prod.js → events-60ed2d7b.cjs.prod.js} +150 -134
  19. package/dist/{events-64d1e225.esm.js → events-a7b08b1a.esm.js} +151 -134
  20. package/dist/{events-c2452172.cjs.dev.js → events-b4061ace.cjs.dev.js} +150 -134
  21. package/dist/react-three-fiber.cjs.dev.js +51 -49
  22. package/dist/react-three-fiber.cjs.prod.js +51 -49
  23. package/dist/react-three-fiber.esm.js +52 -49
  24. package/native/package.json +5 -5
  25. package/package.json +88 -88
  26. package/readme.md +253 -253
  27. package/native/dist/react-three-fiber-native.cjs.d.ts +0 -2
  28. package/native/dist/react-three-fiber-native.cjs.dev.js +0 -550
  29. package/native/dist/react-three-fiber-native.cjs.js +0 -7
  30. package/native/dist/react-three-fiber-native.cjs.prod.js +0 -550
  31. package/native/dist/react-three-fiber-native.esm.js +0 -497
@@ -38,29 +38,29 @@ var threeTypes = /*#__PURE__*/Object.freeze({
38
38
  __proto__: null
39
39
  });
40
40
 
41
- /**
42
- * Returns the instance's initial (outmost) root.
41
+ /**
42
+ * Returns the instance's initial (outmost) root.
43
43
  */
44
44
  function findInitialRoot(instance) {
45
45
  let root = instance.root;
46
46
  while (root.getState().previousRoot) root = root.getState().previousRoot;
47
47
  return root;
48
48
  }
49
- /**
50
- * Safely flush async effects when testing, simulating a legacy root.
49
+ /**
50
+ * Safely flush async effects when testing, simulating a legacy root.
51
51
  */
52
52
  const act = React__namespace.act;
53
53
  const isOrthographicCamera = def => def && def.isOrthographicCamera;
54
54
  const isRef = obj => obj && obj.hasOwnProperty('current');
55
55
 
56
- /**
57
- * An SSR-friendly useLayoutEffect.
58
- *
59
- * React currently throws a warning when using useLayoutEffect on the server.
60
- * To get around it, we can conditionally useEffect on the server (no-op) and
61
- * useLayoutEffect elsewhere.
62
- *
63
- * @see https://github.com/facebook/react/issues/14927
56
+ /**
57
+ * An SSR-friendly useLayoutEffect.
58
+ *
59
+ * React currently throws a warning when using useLayoutEffect on the server.
60
+ * To get around it, we can conditionally useEffect on the server (no-op) and
61
+ * useLayoutEffect elsewhere.
62
+ *
63
+ * @see https://github.com/facebook/react/issues/14927
64
64
  */
65
65
  const useIsomorphicLayoutEffect = /* @__PURE__ */((_window$document, _window$navigator) => typeof window !== 'undefined' && (((_window$document = window.document) == null ? void 0 : _window$document.createElement) || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative'))() ? React__namespace.useLayoutEffect : React__namespace.useEffect;
66
66
  function useMutableCallback(fn) {
@@ -68,8 +68,8 @@ function useMutableCallback(fn) {
68
68
  useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
69
69
  return ref;
70
70
  }
71
- /**
72
- * Bridges renderer Context and StrictMode from a primary renderer.
71
+ /**
72
+ * Bridges renderer Context and StrictMode from a primary renderer.
73
73
  */
74
74
  function useBridge() {
75
75
  const fiber = itsFine.useFiber();
@@ -121,8 +121,8 @@ function calculateDpr(dpr) {
121
121
  return Array.isArray(dpr) ? Math.min(Math.max(dpr[0], target), dpr[1]) : dpr;
122
122
  }
123
123
 
124
- /**
125
- * Returns instance root state
124
+ /**
125
+ * Returns instance root state
126
126
  */
127
127
  function getRootState(obj) {
128
128
  var _r3f;
@@ -136,6 +136,7 @@ const is = {
136
136
  num: a => typeof a === 'number',
137
137
  boo: a => typeof a === 'boolean',
138
138
  und: a => a === void 0,
139
+ nul: a => a === null,
139
140
  arr: a => Array.isArray(a),
140
141
  equ(a, b, {
141
142
  arrays = 'shallow',
@@ -304,6 +305,18 @@ const RESERVED_PROPS = [...REACT_INTERNAL_PROPS,
304
305
  // Behavior flags
305
306
  'dispose'];
306
307
  const MEMOIZED_PROTOTYPES = new Map();
308
+ function getMemoizedPrototype(root) {
309
+ let ctor = MEMOIZED_PROTOTYPES.get(root.constructor);
310
+ try {
311
+ if (!ctor) {
312
+ ctor = new root.constructor();
313
+ MEMOIZED_PROTOTYPES.set(root.constructor, ctor);
314
+ }
315
+ } catch (e) {
316
+ // ...
317
+ }
318
+ return ctor;
319
+ }
307
320
 
308
321
  // This function prepares a set of changes to be applied to the instance
309
322
  function diffProps(instance, newProps) {
@@ -340,12 +353,8 @@ function diffProps(instance, newProps) {
340
353
  // For removed props, try to set default values, if possible
341
354
  if (root.constructor && root.constructor.length === 0) {
342
355
  // create a blank slate of the instance and copy the particular parameter.
343
- let ctor = MEMOIZED_PROTOTYPES.get(root.constructor);
344
- if (!ctor) {
345
- ctor = new root.constructor();
346
- MEMOIZED_PROTOTYPES.set(root.constructor, ctor);
347
- }
348
- changedProps[key] = ctor[key];
356
+ const ctor = getMemoizedPrototype(root);
357
+ if (!is.und(ctor)) changedProps[key] = ctor[key];
349
358
  } else {
350
359
  // instance does not have constructor, just set it to 0
351
360
  changedProps[key] = 0;
@@ -387,7 +396,13 @@ function applyProps(object, props) {
387
396
 
388
397
  // Copy if properties match signatures
389
398
  if (target != null && target.copy && value != null && value.constructor && target.constructor === value.constructor) {
390
- target.copy(value);
399
+ // fetch the default state of the target
400
+ const ctor = getMemoizedPrototype(root);
401
+ // The target key was originally null or undefined, which indicates that the object which
402
+ // is now present was externally set by the user, we should therefore assign the value directly
403
+ if (!is.und(ctor) && (is.und(ctor[key]) || is.nul(ctor[key]))) root[key] = value;
404
+ // Otherwise copy is correct
405
+ else target.copy(value);
391
406
  }
392
407
  // Layers have no copy function, we must therefore copy the mask property
393
408
  else if (target instanceof THREE__namespace.Layers && value instanceof THREE__namespace.Layers) {
@@ -470,9 +485,9 @@ function makeId(event) {
470
485
  return (event.eventObject || event.object).uuid + '/' + event.index + event.instanceId;
471
486
  }
472
487
 
473
- /**
474
- * Release pointer captures.
475
- * This is called by releasePointerCapture in the API, and when an object is removed.
488
+ /**
489
+ * Release pointer captures.
490
+ * This is called by releasePointerCapture in the API, and when an object is removed.
476
491
  */
477
492
  function releaseInternalPointerCapture(capturedMap, obj, captures, pointerId) {
478
493
  const captureData = captures.get(obj);
@@ -807,19 +822,19 @@ function createEvents(store) {
807
822
  if (!(instance != null && instance.eventCount)) return;
808
823
  const handlers = instance.handlers;
809
824
 
810
- /*
811
- MAYBE TODO, DELETE IF NOT:
812
- Check if the object is captured, captured events should not have intersects running in parallel
813
- But wouldn't it be better to just replace capturedMap with a single entry?
814
- Also, are we OK with straight up making picking up multiple objects impossible?
815
-
816
- const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
817
- if (pointerId !== undefined) {
818
- const capturedMeshSet = internal.capturedMap.get(pointerId)
819
- if (capturedMeshSet) {
820
- const captured = capturedMeshSet.get(eventObject)
821
- if (captured && captured.localState.stopped) return
822
- }
825
+ /*
826
+ MAYBE TODO, DELETE IF NOT:
827
+ Check if the object is captured, captured events should not have intersects running in parallel
828
+ But wouldn't it be better to just replace capturedMap with a single entry?
829
+ Also, are we OK with straight up making picking up multiple objects impossible?
830
+
831
+ const pointerId = (data as ThreeEvent<PointerEvent>).pointerId
832
+ if (pointerId !== undefined) {
833
+ const capturedMeshSet = internal.capturedMap.get(pointerId)
834
+ if (capturedMeshSet) {
835
+ const captured = capturedMeshSet.get(eventObject)
836
+ if (captured && captured.localState.stopped) return
837
+ }
823
838
  }*/
824
839
 
825
840
  if (isPointerMove) {
@@ -1085,7 +1100,7 @@ const createStore = (invalidate, advance) => {
1085
1100
  oldDpr = viewport.dpr;
1086
1101
  // Update camera & renderer
1087
1102
  updateCamera(camera, size);
1088
- gl.setPixelRatio(viewport.dpr);
1103
+ if (viewport.dpr > 0) gl.setPixelRatio(viewport.dpr);
1089
1104
  const updateStyle = typeof HTMLCanvasElement !== 'undefined' && gl.domElement instanceof HTMLCanvasElement;
1090
1105
  gl.setSize(size.width, size.height, updateStyle);
1091
1106
  }
@@ -1110,11 +1125,11 @@ const createStore = (invalidate, advance) => {
1110
1125
  return rootStore;
1111
1126
  };
1112
1127
 
1113
- /**
1114
- * Exposes an object's {@link Instance}.
1115
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1116
- *
1117
- * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1128
+ /**
1129
+ * Exposes an object's {@link Instance}.
1130
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#useInstanceHandle
1131
+ *
1132
+ * **Note**: this is an escape hatch to react-internal fields. Expect this to change significantly between versions.
1118
1133
  */
1119
1134
  function useInstanceHandle(ref) {
1120
1135
  const instance = React__namespace.useRef(null);
@@ -1122,9 +1137,9 @@ function useInstanceHandle(ref) {
1122
1137
  return instance;
1123
1138
  }
1124
1139
 
1125
- /**
1126
- * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1127
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1140
+ /**
1141
+ * Returns the R3F Canvas' Zustand store. Useful for [transient updates](https://github.com/pmndrs/zustand#transient-updates-for-often-occurring-state-changes).
1142
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usestore
1128
1143
  */
1129
1144
  function useStore() {
1130
1145
  const store = React__namespace.useContext(context);
@@ -1132,18 +1147,18 @@ function useStore() {
1132
1147
  return store;
1133
1148
  }
1134
1149
 
1135
- /**
1136
- * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1137
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1150
+ /**
1151
+ * Accesses R3F's internal state, containing renderer, canvas, scene, etc.
1152
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usethree
1138
1153
  */
1139
1154
  function useThree(selector = state => state, equalityFn) {
1140
1155
  return useStore()(selector, equalityFn);
1141
1156
  }
1142
1157
 
1143
- /**
1144
- * Executes a callback before render in a shared frame loop.
1145
- * Can order effects with render priority or manually render with a positive priority.
1146
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1158
+ /**
1159
+ * Executes a callback before render in a shared frame loop.
1160
+ * Can order effects with render priority or manually render with a positive priority.
1161
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe
1147
1162
  */
1148
1163
  function useFrame(callback, renderPriority = 0) {
1149
1164
  const store = useStore();
@@ -1155,9 +1170,9 @@ function useFrame(callback, renderPriority = 0) {
1155
1170
  return null;
1156
1171
  }
1157
1172
 
1158
- /**
1159
- * Returns a node graph of an object with named nodes & materials.
1160
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1173
+ /**
1174
+ * Returns a node graph of an object with named nodes & materials.
1175
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
1161
1176
  */
1162
1177
  function useGraph(object) {
1163
1178
  return React__namespace.useMemo(() => buildGraph(object), [object]);
@@ -1193,11 +1208,11 @@ function loadingFn(extensions, onProgress) {
1193
1208
  };
1194
1209
  }
1195
1210
 
1196
- /**
1197
- * Synchronously loads and caches assets with a three loader.
1198
- *
1199
- * Note: this hook's caller must be wrapped with `React.Suspense`
1200
- * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1211
+ /**
1212
+ * Synchronously loads and caches assets with a three loader.
1213
+ *
1214
+ * Note: this hook's caller must be wrapped with `React.Suspense`
1215
+ * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
1201
1216
  */
1202
1217
  function useLoader(loader, input, extensions, onProgress) {
1203
1218
  // Use suspense to load async assets
@@ -1209,16 +1224,16 @@ function useLoader(loader, input, extensions, onProgress) {
1209
1224
  return Array.isArray(input) ? results : results[0];
1210
1225
  }
1211
1226
 
1212
- /**
1213
- * Preloads an asset into cache as a side-effect.
1227
+ /**
1228
+ * Preloads an asset into cache as a side-effect.
1214
1229
  */
1215
1230
  useLoader.preload = function (loader, input, extensions) {
1216
1231
  const keys = Array.isArray(input) ? input : [input];
1217
1232
  return suspendReact.preload(loadingFn(extensions), [loader, ...keys]);
1218
1233
  };
1219
1234
 
1220
- /**
1221
- * Removes a loaded asset from cache.
1235
+ /**
1236
+ * Removes a loaded asset from cache.
1222
1237
  */
1223
1238
  useLoader.clear = function (loader, input) {
1224
1239
  const keys = Array.isArray(input) ? input : [input];
@@ -1336,7 +1351,7 @@ function handleContainerEffects(parent, child, beforeChild) {
1336
1351
  child.object.dispatchEvent({
1337
1352
  type: 'added'
1338
1353
  });
1339
- // @ts-expect-error https://github.com/mrdoob/three.js/pull/16934
1354
+ // expect-error https://github.com/mrdoob/three.js/pull/16934
1340
1355
  parent.object.dispatchEvent({
1341
1356
  type: 'childadded',
1342
1357
  child: child.object
@@ -1652,17 +1667,20 @@ const shallowLoose = {
1652
1667
  objects: 'shallow',
1653
1668
  strict: false
1654
1669
  };
1655
- const createRendererInstance = (gl, canvas) => {
1656
- const customRenderer = typeof gl === 'function' ? gl(canvas) : gl;
1657
- if (isRenderer(customRenderer)) return customRenderer;
1658
- return new THREE__namespace.WebGLRenderer({
1659
- powerPreference: 'high-performance',
1670
+ async function createRendererInstance(gl, canvas) {
1671
+ const defaultProps = {
1660
1672
  canvas: canvas,
1673
+ powerPreference: 'high-performance',
1661
1674
  antialias: true,
1662
- alpha: true,
1675
+ alpha: true
1676
+ };
1677
+ const customRenderer = typeof gl === 'function' ? await gl(defaultProps) : gl;
1678
+ if (isRenderer(customRenderer)) return customRenderer;
1679
+ return new THREE__namespace.WebGLRenderer({
1680
+ ...defaultProps,
1663
1681
  ...gl
1664
1682
  });
1665
- };
1683
+ }
1666
1684
  function computeInitialSize(canvas, size) {
1667
1685
  if (!size && typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
1668
1686
  const {
@@ -1743,7 +1761,7 @@ function createRoot(canvas) {
1743
1761
  let configured = false;
1744
1762
  let lastCamera;
1745
1763
  return {
1746
- configure(props = {}) {
1764
+ async configure(props = {}) {
1747
1765
  let {
1748
1766
  gl: glConfig,
1749
1767
  size: propsSize,
@@ -1767,7 +1785,7 @@ function createRoot(canvas) {
1767
1785
  // Set up renderer (one time only!)
1768
1786
  let gl = state.gl;
1769
1787
  if (!state.gl) state.set({
1770
- gl: gl = createRendererInstance(glConfig, canvas)
1788
+ gl: gl = await createRendererInstance(glConfig, canvas)
1771
1789
  });
1772
1790
 
1773
1791
  // Set up raycaster (one time only!)
@@ -1837,6 +1855,31 @@ function createRoot(canvas) {
1837
1855
  });
1838
1856
  }
1839
1857
 
1858
+ // Store events internally
1859
+ if (events && !state.events.handlers) state.set({
1860
+ events: events(store)
1861
+ });
1862
+ // Check size, allow it to take on container bounds initially
1863
+ const size = computeInitialSize(canvas, propsSize);
1864
+ if (!is.equ(size, state.size, shallowLoose)) {
1865
+ state.setSize(size.width, size.height, size.top, size.left);
1866
+ }
1867
+ // Check pixelratio
1868
+ if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
1869
+ // Check frameloop
1870
+ if (state.frameloop !== frameloop) state.setFrameloop(frameloop);
1871
+ // Check pointer missed
1872
+ if (!state.onPointerMissed) state.set({
1873
+ onPointerMissed
1874
+ });
1875
+ // Check performance
1876
+ if (performance && !is.equ(performance, state.performance, shallowLoose)) state.set(state => ({
1877
+ performance: {
1878
+ ...state.performance,
1879
+ ...performance
1880
+ }
1881
+ }));
1882
+
1840
1883
  // Set up XR (one time only!)
1841
1884
  if (!state.xr) {
1842
1885
  var _gl$xr;
@@ -1918,30 +1961,6 @@ function createRoot(canvas) {
1918
1961
 
1919
1962
  // Set gl props
1920
1963
  if (glConfig && !is.fun(glConfig) && !isRenderer(glConfig) && !is.equ(glConfig, gl, shallowLoose)) applyProps(gl, glConfig);
1921
- // Store events internally
1922
- if (events && !state.events.handlers) state.set({
1923
- events: events(store)
1924
- });
1925
- // Check size, allow it to take on container bounds initially
1926
- const size = computeInitialSize(canvas, propsSize);
1927
- if (!is.equ(size, state.size, shallowLoose)) {
1928
- state.setSize(size.width, size.height, size.top, size.left);
1929
- }
1930
- // Check pixelratio
1931
- if (dpr && state.viewport.dpr !== calculateDpr(dpr)) state.setDpr(dpr);
1932
- // Check frameloop
1933
- if (state.frameloop !== frameloop) state.setFrameloop(frameloop);
1934
- // Check pointer missed
1935
- if (!state.onPointerMissed) state.set({
1936
- onPointerMissed
1937
- });
1938
- // Check performance
1939
- if (performance && !is.equ(performance, state.performance, shallowLoose)) state.set(state => ({
1940
- performance: {
1941
- ...state.performance,
1942
- ...performance
1943
- }
1944
- }));
1945
1964
 
1946
1965
  // Set locals
1947
1966
  onCreated = onCreatedCallback;
@@ -1950,7 +1969,7 @@ function createRoot(canvas) {
1950
1969
  },
1951
1970
  render(children) {
1952
1971
  // The root has to be configured before it can be rendered
1953
- if (!configured) this.configure();
1972
+ if (!configured) throw "The root has to be configured before it can be rendered, call 'configure' first!";
1954
1973
  reconciler.updateContainer( /*#__PURE__*/jsxRuntime.jsx(Provider, {
1955
1974
  store: store,
1956
1975
  children: children,
@@ -1964,12 +1983,6 @@ function createRoot(canvas) {
1964
1983
  }
1965
1984
  };
1966
1985
  }
1967
- function render(children, canvas, config) {
1968
- console.warn('R3F.render is no longer supported in React 18. Use createRoot instead!');
1969
- const root = createRoot(canvas);
1970
- root.configure(config);
1971
- return root.render(children);
1972
- }
1973
1986
  function Provider({
1974
1987
  store,
1975
1988
  children,
@@ -2035,10 +2048,10 @@ function Portal({
2035
2048
  children,
2036
2049
  container
2037
2050
  }) {
2038
- /** This has to be a component because it would not be able to call useThree/useStore otherwise since
2039
- * if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
2040
- * the "R3F hooks can only be used within the Canvas component!" warning:
2041
- * <Canvas>
2051
+ /** This has to be a component because it would not be able to call useThree/useStore otherwise since
2052
+ * if this is our environment, then we are not in r3f's renderer but in react-dom, it would trigger
2053
+ * the "R3F hooks can only be used within the Canvas component!" warning:
2054
+ * <Canvas>
2042
2055
  * {createPortal(...)} */
2043
2056
  const {
2044
2057
  events,
@@ -2107,12 +2120,16 @@ function Portal({
2107
2120
  return store;
2108
2121
  // eslint-disable-next-line react-hooks/exhaustive-deps
2109
2122
  }, [previousRoot, container]);
2110
- return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
2111
- children: reconciler.createPortal( /*#__PURE__*/jsxRuntime.jsx(context.Provider, {
2112
- value: usePortalStore,
2113
- children: children
2114
- }), usePortalStore, null)
2115
- });
2123
+ return (
2124
+ /*#__PURE__*/
2125
+ // @ts-ignore, reconciler types are not maintained
2126
+ jsxRuntime.jsx(jsxRuntime.Fragment, {
2127
+ children: reconciler.createPortal( /*#__PURE__*/jsxRuntime.jsx(context.Provider, {
2128
+ value: usePortalStore,
2129
+ children: children
2130
+ }), usePortalStore, null)
2131
+ })
2132
+ );
2116
2133
  }
2117
2134
 
2118
2135
  function createSubs(callback, subs) {
@@ -2126,21 +2143,21 @@ const globalEffects = new Set();
2126
2143
  const globalAfterEffects = new Set();
2127
2144
  const globalTailEffects = new Set();
2128
2145
 
2129
- /**
2130
- * Adds a global render callback which is called each frame.
2131
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
2146
+ /**
2147
+ * Adds a global render callback which is called each frame.
2148
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addEffect
2132
2149
  */
2133
2150
  const addEffect = callback => createSubs(callback, globalEffects);
2134
2151
 
2135
- /**
2136
- * Adds a global after-render callback which is called each frame.
2137
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
2152
+ /**
2153
+ * Adds a global after-render callback which is called each frame.
2154
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addAfterEffect
2138
2155
  */
2139
2156
  const addAfterEffect = callback => createSubs(callback, globalAfterEffects);
2140
2157
 
2141
- /**
2142
- * Adds a global callback which is called when rendering stops.
2143
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
2158
+ /**
2159
+ * Adds a global callback which is called when rendering stops.
2160
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#addTail
2144
2161
  */
2145
2162
  const addTail = callback => createSubs(callback, globalTailEffects);
2146
2163
  function run(effects, timestamp) {
@@ -2228,9 +2245,9 @@ function loop(timestamp) {
2228
2245
  }
2229
2246
  }
2230
2247
 
2231
- /**
2232
- * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
2233
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
2248
+ /**
2249
+ * Invalidates the view, requesting a frame to be rendered. Will globally invalidate unless passed a root's state.
2250
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#invalidate
2234
2251
  */
2235
2252
  function invalidate(state, frames = 1) {
2236
2253
  var _state$gl$xr2;
@@ -2257,9 +2274,9 @@ function invalidate(state, frames = 1) {
2257
2274
  }
2258
2275
  }
2259
2276
 
2260
- /**
2261
- * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
2262
- * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2277
+ /**
2278
+ * Advances the frameloop and runs render effects, useful for when manually rendering via `frameloop="never"`.
2279
+ * @see https://docs.pmnd.rs/react-three-fiber/api/additional-exports#advance
2263
2280
  */
2264
2281
  function advance(timestamp, runGlobalEffects = true, state, frame) {
2265
2282
  if (runGlobalEffects) flushGlobalEffects('before', timestamp);
@@ -2375,7 +2392,6 @@ exports.getRootState = getRootState;
2375
2392
  exports.invalidate = invalidate;
2376
2393
  exports.isRef = isRef;
2377
2394
  exports.reconciler = reconciler;
2378
- exports.render = render;
2379
2395
  exports.threeTypes = threeTypes;
2380
2396
  exports.unmountComponentAtNode = unmountComponentAtNode;
2381
2397
  exports.useBridge = useBridge;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var events = require('./events-c2452172.cjs.dev.js');
5
+ var events = require('./events-b4061ace.cjs.dev.js');
6
6
  var React = require('react');
7
7
  var THREE = require('three');
8
8
  var createDebounce = require('debounce');
@@ -286,52 +286,55 @@ function CanvasImpl({
286
286
  const canvas = canvasRef.current;
287
287
  if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
288
288
  if (!root.current) root.current = events.createRoot(canvas);
289
- root.current.configure({
290
- gl,
291
- scene,
292
- events: events$1,
293
- shadows,
294
- linear,
295
- flat,
296
- legacy,
297
- orthographic,
298
- frameloop,
299
- dpr,
300
- performance,
301
- raycaster,
302
- camera,
303
- size: containerRect,
304
- // Pass mutable reference to onPointerMissed so it's free to update
305
- onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
306
- onCreated: state => {
307
- // Connect to event source
308
- state.events.connect == null ? void 0 : state.events.connect(eventSource ? events.isRef(eventSource) ? eventSource.current : eventSource : divRef.current);
309
- // Set up compute function
310
- if (eventPrefix) {
311
- state.setEvents({
312
- compute: (event, state) => {
313
- const x = event[eventPrefix + 'X'];
314
- const y = event[eventPrefix + 'Y'];
315
- state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
316
- state.raycaster.setFromCamera(state.pointer, state.camera);
317
- }
318
- });
289
+ async function run() {
290
+ await root.current.configure({
291
+ gl,
292
+ scene,
293
+ events: events$1,
294
+ shadows,
295
+ linear,
296
+ flat,
297
+ legacy,
298
+ orthographic,
299
+ frameloop,
300
+ dpr,
301
+ performance,
302
+ raycaster,
303
+ camera,
304
+ size: containerRect,
305
+ // Pass mutable reference to onPointerMissed so it's free to update
306
+ onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
307
+ onCreated: state => {
308
+ // Connect to event source
309
+ state.events.connect == null ? void 0 : state.events.connect(eventSource ? events.isRef(eventSource) ? eventSource.current : eventSource : divRef.current);
310
+ // Set up compute function
311
+ if (eventPrefix) {
312
+ state.setEvents({
313
+ compute: (event, state) => {
314
+ const x = event[eventPrefix + 'X'];
315
+ const y = event[eventPrefix + 'Y'];
316
+ state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
317
+ state.raycaster.setFromCamera(state.pointer, state.camera);
318
+ }
319
+ });
320
+ }
321
+ // Call onCreated callback
322
+ onCreated == null ? void 0 : onCreated(state);
319
323
  }
320
- // Call onCreated callback
321
- onCreated == null ? void 0 : onCreated(state);
322
- }
323
- });
324
- root.current.render( /*#__PURE__*/jsxRuntime.jsx(Bridge, {
325
- children: /*#__PURE__*/jsxRuntime.jsx(events.ErrorBoundary, {
326
- set: setError,
327
- children: /*#__PURE__*/jsxRuntime.jsx(React__namespace.Suspense, {
328
- fallback: /*#__PURE__*/jsxRuntime.jsx(events.Block, {
329
- set: setBlock
330
- }),
331
- children: children
324
+ });
325
+ root.current.render( /*#__PURE__*/jsxRuntime.jsx(Bridge, {
326
+ children: /*#__PURE__*/jsxRuntime.jsx(events.ErrorBoundary, {
327
+ set: setError,
328
+ children: /*#__PURE__*/jsxRuntime.jsx(React__namespace.Suspense, {
329
+ fallback: /*#__PURE__*/jsxRuntime.jsx(events.Block, {
330
+ set: setBlock
331
+ }),
332
+ children: children
333
+ })
332
334
  })
333
- })
334
- }));
335
+ }));
336
+ }
337
+ run();
335
338
  }
336
339
  });
337
340
  React__namespace.useEffect(() => {
@@ -370,9 +373,9 @@ function CanvasImpl({
370
373
  });
371
374
  }
372
375
 
373
- /**
374
- * A DOM canvas which accepts threejs elements as children.
375
- * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
376
+ /**
377
+ * A DOM canvas which accepts threejs elements as children.
378
+ * @see https://docs.pmnd.rs/react-three-fiber/api/canvas
376
379
  */
377
380
  function Canvas(props) {
378
381
  return /*#__PURE__*/jsxRuntime.jsx(itsFine.FiberProvider, {
@@ -402,7 +405,6 @@ exports.flushGlobalEffects = events.flushGlobalEffects;
402
405
  exports.getRootState = events.getRootState;
403
406
  exports.invalidate = events.invalidate;
404
407
  exports.reconciler = events.reconciler;
405
- exports.render = events.render;
406
408
  exports.unmountComponentAtNode = events.unmountComponentAtNode;
407
409
  exports.useFrame = events.useFrame;
408
410
  exports.useGraph = events.useGraph;