@react-three/fiber 8.13.6 → 8.13.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.13.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 5da26d52: fix(useLoader): dispose loaders
8
+
9
+ ## 8.13.7
10
+
11
+ ### Patch Changes
12
+
13
+ - 37b9502a: fix(Canvas): pass scene prop
14
+
3
15
  ## 8.13.6
4
16
 
5
17
  ### Patch Changes
@@ -1631,16 +1631,21 @@ function useFrame(callback, renderPriority = 0) {
1631
1631
  function useGraph(object) {
1632
1632
  return React.useMemo(() => buildGraph(object), [object]);
1633
1633
  }
1634
+ const memoizedLoaders = new WeakMap();
1634
1635
  function loadingFn(extensions, onProgress) {
1635
1636
  return function (Proto, ...input) {
1636
1637
  // Construct new loader and run extensions
1637
- const loader = new Proto();
1638
+ let loader = memoizedLoaders.get(Proto);
1639
+ if (!loader) {
1640
+ loader = new Proto();
1641
+ memoizedLoaders.set(Proto, loader);
1642
+ }
1638
1643
  if (extensions) extensions(loader);
1639
1644
  // Go through the urls and load them
1640
1645
  return Promise.all(input.map(input => new Promise((res, reject) => loader.load(input, data => {
1641
1646
  if (data.scene) Object.assign(data, buildGraph(data.scene));
1642
1647
  res(data);
1643
- }, onProgress, error => reject(new Error(`Could not load ${input}: ${error.message}`))))));
1648
+ }, onProgress, error => reject(new Error(`Could not load ${input}: ${error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1644
1649
  };
1645
1650
  }
1646
1651
 
@@ -1658,16 +1658,21 @@ function useFrame(callback, renderPriority = 0) {
1658
1658
  function useGraph(object) {
1659
1659
  return React__namespace.useMemo(() => buildGraph(object), [object]);
1660
1660
  }
1661
+ const memoizedLoaders = new WeakMap();
1661
1662
  function loadingFn(extensions, onProgress) {
1662
1663
  return function (Proto, ...input) {
1663
1664
  // Construct new loader and run extensions
1664
- const loader = new Proto();
1665
+ let loader = memoizedLoaders.get(Proto);
1666
+ if (!loader) {
1667
+ loader = new Proto();
1668
+ memoizedLoaders.set(Proto, loader);
1669
+ }
1665
1670
  if (extensions) extensions(loader);
1666
1671
  // Go through the urls and load them
1667
1672
  return Promise.all(input.map(input => new Promise((res, reject) => loader.load(input, data => {
1668
1673
  if (data.scene) Object.assign(data, buildGraph(data.scene));
1669
1674
  res(data);
1670
- }, onProgress, error => reject(new Error(`Could not load ${input}: ${error.message}`))))));
1675
+ }, onProgress, error => reject(new Error(`Could not load ${input}: ${error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1671
1676
  };
1672
1677
  }
1673
1678
 
@@ -1658,16 +1658,21 @@ function useFrame(callback, renderPriority = 0) {
1658
1658
  function useGraph(object) {
1659
1659
  return React__namespace.useMemo(() => buildGraph(object), [object]);
1660
1660
  }
1661
+ const memoizedLoaders = new WeakMap();
1661
1662
  function loadingFn(extensions, onProgress) {
1662
1663
  return function (Proto, ...input) {
1663
1664
  // Construct new loader and run extensions
1664
- const loader = new Proto();
1665
+ let loader = memoizedLoaders.get(Proto);
1666
+ if (!loader) {
1667
+ loader = new Proto();
1668
+ memoizedLoaders.set(Proto, loader);
1669
+ }
1665
1670
  if (extensions) extensions(loader);
1666
1671
  // Go through the urls and load them
1667
1672
  return Promise.all(input.map(input => new Promise((res, reject) => loader.load(input, data => {
1668
1673
  if (data.scene) Object.assign(data, buildGraph(data.scene));
1669
1674
  res(data);
1670
- }, onProgress, error => reject(new Error(`Could not load ${input}: ${error.message}`))))));
1675
+ }, onProgress, error => reject(new Error(`Could not load ${input}: ${error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1671
1676
  };
1672
1677
  }
1673
1678
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-3bf7d7a3.cjs.dev.js');
5
+ var index = require('./index-be1f7f7b.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -141,6 +141,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
141
141
  performance,
142
142
  raycaster,
143
143
  camera,
144
+ scene,
144
145
  onPointerMissed,
145
146
  onCreated,
146
147
  ...props
@@ -187,6 +188,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
187
188
  performance,
188
189
  raycaster,
189
190
  camera,
191
+ scene,
190
192
  size: containerRect,
191
193
  // Pass mutable reference to onPointerMissed so it's free to update
192
194
  onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-e0fec69f.cjs.prod.js');
5
+ var index = require('./index-dad7ba86.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -141,6 +141,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
141
141
  performance,
142
142
  raycaster,
143
143
  camera,
144
+ scene,
144
145
  onPointerMissed,
145
146
  onCreated,
146
147
  ...props
@@ -187,6 +188,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
187
188
  performance,
188
189
  raycaster,
189
190
  camera,
191
+ scene,
190
192
  size: containerRect,
191
193
  // Pass mutable reference to onPointerMissed so it's free to update
192
194
  onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-673ef987.esm.js';
2
- export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-673ef987.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-6662eaf2.esm.js';
2
+ export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-6662eaf2.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';
@@ -114,6 +114,7 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(function Canvas({
114
114
  performance,
115
115
  raycaster,
116
116
  camera,
117
+ scene,
117
118
  onPointerMissed,
118
119
  onCreated,
119
120
  ...props
@@ -160,6 +161,7 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(function Canvas({
160
161
  performance,
161
162
  raycaster,
162
163
  camera,
164
+ scene,
163
165
  size: containerRect,
164
166
  // Pass mutable reference to onPointerMissed so it's free to update
165
167
  onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-3bf7d7a3.cjs.dev.js');
5
+ var index = require('../../dist/index-be1f7f7b.cjs.dev.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -251,6 +251,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
251
251
  performance,
252
252
  raycaster,
253
253
  camera,
254
+ scene,
254
255
  onPointerMissed,
255
256
  onCreated,
256
257
  ...props
@@ -330,6 +331,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
330
331
  performance,
331
332
  raycaster,
332
333
  camera,
334
+ scene,
333
335
  // expo-gl can only render at native dpr/resolution
334
336
  // https://github.com/expo/expo-three/issues/39
335
337
  dpr: reactNative.PixelRatio.get(),
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-e0fec69f.cjs.prod.js');
5
+ var index = require('../../dist/index-dad7ba86.cjs.prod.js');
6
6
  var _extends = require('@babel/runtime/helpers/extends');
7
7
  var React = require('react');
8
8
  var THREE = require('three');
@@ -251,6 +251,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
251
251
  performance,
252
252
  raycaster,
253
253
  camera,
254
+ scene,
254
255
  onPointerMissed,
255
256
  onCreated,
256
257
  ...props
@@ -330,6 +331,7 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(({
330
331
  performance,
331
332
  raycaster,
332
333
  camera,
334
+ scene,
333
335
  // expo-gl can only render at native dpr/resolution
334
336
  // https://github.com/expo/expo-three/issues/39
335
337
  dpr: reactNative.PixelRatio.get(),
@@ -1,5 +1,5 @@
1
- import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-673ef987.esm.js';
2
- export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-673ef987.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-6662eaf2.esm.js';
2
+ export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-6662eaf2.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';
@@ -224,6 +224,7 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(({
224
224
  performance,
225
225
  raycaster,
226
226
  camera,
227
+ scene,
227
228
  onPointerMissed,
228
229
  onCreated,
229
230
  ...props
@@ -303,6 +304,7 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(({
303
304
  performance,
304
305
  raycaster,
305
306
  camera,
307
+ scene,
306
308
  // expo-gl can only render at native dpr/resolution
307
309
  // https://github.com/expo/expo-three/issues/39
308
310
  dpr: PixelRatio.get(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.13.6",
3
+ "version": "8.13.8",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",