@react-three/fiber 8.13.7 → 8.13.9

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.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 44d57b3c: fix(native): TextureLoader should remain consistent with FileLoader
8
+
9
+ ## 8.13.8
10
+
11
+ ### Patch Changes
12
+
13
+ - 5da26d52: fix(useLoader): dispose loaders
14
+
3
15
  ## 8.13.7
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');
@@ -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');
@@ -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';
@@ -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');
@@ -166,6 +166,7 @@ function polyfills() {
166
166
  // There's no Image in native, so create a data texture instead
167
167
  const prevTextureLoad = THREE__namespace.TextureLoader.prototype.load;
168
168
  THREE__namespace.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
169
+ if (this.path) url = this.path + url;
169
170
  const texture = new THREE__namespace.Texture();
170
171
 
171
172
  // @ts-ignore
@@ -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');
@@ -166,6 +166,7 @@ function polyfills() {
166
166
  // There's no Image in native, so create a data texture instead
167
167
  const prevTextureLoad = THREE__namespace.TextureLoader.prototype.load;
168
168
  THREE__namespace.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
169
+ if (this.path) url = this.path + url;
169
170
  const texture = new THREE__namespace.Texture();
170
171
 
171
172
  // @ts-ignore
@@ -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';
@@ -139,6 +139,7 @@ function polyfills() {
139
139
  // There's no Image in native, so create a data texture instead
140
140
  const prevTextureLoad = THREE.TextureLoader.prototype.load;
141
141
  THREE.TextureLoader.prototype.load = function load(url, onLoad, onProgress, onError) {
142
+ if (this.path) url = this.path + url;
142
143
  const texture = new THREE.Texture();
143
144
 
144
145
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.13.7",
3
+ "version": "8.13.9",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",