@react-three/fiber 8.15.10 → 8.15.12

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.15.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 496d6f0d: fix: useLoader and XRFrame type fixes
8
+
9
+ ## 8.15.11
10
+
11
+ ### Patch Changes
12
+
13
+ - 3d9af04d: fix: update import from three examples
14
+
3
15
  ## 8.15.10
4
16
 
5
17
  ### Patch Changes
@@ -1,7 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import * as React from 'react';
3
3
  import { StateSelector, EqualityChecker } from 'zustand';
4
- import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
5
4
  import { RootState, RenderCallback } from './store';
6
5
  import { ObjectMap } from './utils';
7
6
  import { LocalState } from './renderer';
@@ -41,14 +40,18 @@ export declare function useFrame(callback: RenderCallback, renderPriority?: numb
41
40
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#usegraph
42
41
  */
43
42
  export declare function useGraph(object: THREE.Object3D): ObjectMap;
43
+ declare type GLTFLike = {
44
+ scene: THREE.Object3D;
45
+ };
44
46
  /**
45
47
  * Synchronously loads and caches assets with a three loader.
46
48
  *
47
49
  * Note: this hook's caller must be wrapped with `React.Suspense`
48
50
  * @see https://docs.pmnd.rs/react-three-fiber/api/hooks#useloader
49
51
  */
50
- export declare function useLoader<T, U extends string | string[], L extends LoaderProto<T>, R = LoaderReturnType<T, L>>(Proto: L, input: U, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): U extends any[] ? BranchingReturn<R, GLTF, GLTF & ObjectMap>[] : BranchingReturn<R, GLTF, GLTF & ObjectMap>;
52
+ export declare function useLoader<T, U extends string | string[], L extends LoaderProto<T>, R = LoaderReturnType<T, L>>(Proto: L, input: U, extensions?: Extensions<L>, onProgress?: (event: ProgressEvent<EventTarget>) => void): U extends any[] ? BranchingReturn<R, GLTFLike, R & ObjectMap>[] : BranchingReturn<R, GLTFLike, R & ObjectMap>;
51
53
  export declare namespace useLoader {
52
54
  var preload: <T, U extends string | string[], L extends LoaderProto<T>>(Proto: L, input: U, extensions?: Extensions<L> | undefined) => undefined;
53
55
  var clear: <T, U extends string | string[], L extends LoaderProto<T>>(Proto: L, input: U) => void;
54
56
  }
57
+ export {};
@@ -3,6 +3,7 @@ import * as THREE from 'three';
3
3
  import * as React from 'react';
4
4
  import { AttachType, Instance, InstanceProps, LocalState } from './renderer';
5
5
  import { Dpr, Renderer, RootState, Size } from './store';
6
+ /** @ts-ignore */
6
7
  declare type _DeprecatedXRFrame = THREE.XRFrame;
7
8
  export declare type _XRFrame = THREE.WebGLRenderTargetOptions extends {
8
9
  samples?: number;
@@ -154,13 +154,20 @@ function createRenderer(_roots, _getEventPriority) {
154
154
 
155
155
  // Dispose item whenever the reconciler feels like it
156
156
  if (shouldDispose && child.dispose && child.type !== 'Scene') {
157
- unstable_scheduleCallback(unstable_IdlePriority, () => {
157
+ const callback = () => {
158
158
  try {
159
159
  child.dispose();
160
160
  } catch (e) {
161
161
  /* ... */
162
162
  }
163
- });
163
+ };
164
+
165
+ // Schedule async at runtime, flush sync in testing
166
+ if (typeof IS_REACT_ACT_ENVIRONMENT === 'undefined') {
167
+ unstable_scheduleCallback(unstable_IdlePriority, callback);
168
+ } else {
169
+ callback();
170
+ }
164
171
  }
165
172
  invalidateInstance(parentInstance);
166
173
  }
@@ -1656,7 +1663,6 @@ function loadingFn(extensions, onProgress) {
1656
1663
  }, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1657
1664
  };
1658
1665
  }
1659
-
1660
1666
  /**
1661
1667
  * Synchronously loads and caches assets with a three loader.
1662
1668
  *
@@ -181,13 +181,20 @@ function createRenderer(_roots, _getEventPriority) {
181
181
 
182
182
  // Dispose item whenever the reconciler feels like it
183
183
  if (shouldDispose && child.dispose && child.type !== 'Scene') {
184
- scheduler.unstable_scheduleCallback(scheduler.unstable_IdlePriority, () => {
184
+ const callback = () => {
185
185
  try {
186
186
  child.dispose();
187
187
  } catch (e) {
188
188
  /* ... */
189
189
  }
190
- });
190
+ };
191
+
192
+ // Schedule async at runtime, flush sync in testing
193
+ if (typeof IS_REACT_ACT_ENVIRONMENT === 'undefined') {
194
+ scheduler.unstable_scheduleCallback(scheduler.unstable_IdlePriority, callback);
195
+ } else {
196
+ callback();
197
+ }
191
198
  }
192
199
  invalidateInstance(parentInstance);
193
200
  }
@@ -1683,7 +1690,6 @@ function loadingFn(extensions, onProgress) {
1683
1690
  }, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1684
1691
  };
1685
1692
  }
1686
-
1687
1693
  /**
1688
1694
  * Synchronously loads and caches assets with a three loader.
1689
1695
  *
@@ -181,13 +181,20 @@ function createRenderer(_roots, _getEventPriority) {
181
181
 
182
182
  // Dispose item whenever the reconciler feels like it
183
183
  if (shouldDispose && child.dispose && child.type !== 'Scene') {
184
- scheduler.unstable_scheduleCallback(scheduler.unstable_IdlePriority, () => {
184
+ const callback = () => {
185
185
  try {
186
186
  child.dispose();
187
187
  } catch (e) {
188
188
  /* ... */
189
189
  }
190
- });
190
+ };
191
+
192
+ // Schedule async at runtime, flush sync in testing
193
+ if (typeof IS_REACT_ACT_ENVIRONMENT === 'undefined') {
194
+ scheduler.unstable_scheduleCallback(scheduler.unstable_IdlePriority, callback);
195
+ } else {
196
+ callback();
197
+ }
191
198
  }
192
199
  invalidateInstance(parentInstance);
193
200
  }
@@ -1683,7 +1690,6 @@ function loadingFn(extensions, onProgress) {
1683
1690
  }, onProgress, error => reject(new Error(`Could not load ${input}: ${error == null ? void 0 : error.message}`)))))).finally(() => loader.dispose == null ? void 0 : loader.dispose());
1684
1691
  };
1685
1692
  }
1686
-
1687
1693
  /**
1688
1694
  * Synchronously loads and caches assets with a three loader.
1689
1695
  *
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-28e9146f.cjs.dev.js');
5
+ var index = require('./index-e9909912.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-ae8ad041.cjs.prod.js');
5
+ var index = require('./index-710e63a4.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-0c28a0fd.esm.js';
2
- export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, 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, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './index-0c28a0fd.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-5bde93f1.esm.js';
2
+ export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, 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, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './index-5bde93f1.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-28e9146f.cjs.dev.js');
5
+ var index = require('../../dist/index-e9909912.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('../../dist/index-ae8ad041.cjs.prod.js');
5
+ var index = require('../../dist/index-710e63a4.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, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-0c28a0fd.esm.js';
2
- export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, 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, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/index-0c28a0fd.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-5bde93f1.esm.js';
2
+ export { t as ReactThreeFiber, x as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, w as buildGraph, 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, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/index-5bde93f1.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.15.10",
3
+ "version": "8.15.12",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",