@react-three/fiber 8.15.9 → 8.15.11

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.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 3d9af04d: fix: update import from three examples
8
+
9
+ ## 8.15.10
10
+
11
+ ### Patch Changes
12
+
13
+ - 49158164: fix: don't recursively dispose primitives
14
+
3
15
  ## 8.15.9
4
16
 
5
17
  ### Patch Changes
@@ -86,7 +86,7 @@ export interface PointerCaptureTarget {
86
86
  intersection: Intersection;
87
87
  target: Element;
88
88
  }
89
- export declare function getEventPriority(): 1 | 16 | 4;
89
+ export declare function getEventPriority(): 1 | 4 | 16;
90
90
  export declare function removeInteractivity(store: UseBoundStore<RootState>, object: THREE.Object3D): void;
91
91
  export declare function createEvents(store: UseBoundStore<RootState>): {
92
92
  handlePointer: (name: string) => (event: DomEvent) => void;
@@ -1,7 +1,7 @@
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';
4
+ import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
5
5
  import { RootState, RenderCallback } from './store';
6
6
  import { ObjectMap } from './utils';
7
7
  import { LocalState } from './renderer';
@@ -10,7 +10,7 @@ export declare type _XRFrame = THREE.WebGLRenderTargetOptions extends {
10
10
  /**
11
11
  * Returns `true` with correct TS type inference if an object has a configurable color space (since r152).
12
12
  */
13
- export declare const hasColorSpace: <T extends object | Renderer | THREE.Texture, P = T extends Renderer ? {
13
+ export declare const hasColorSpace: <T extends object | THREE.Texture | Renderer, P = T extends Renderer ? {
14
14
  outputColorSpace: string;
15
15
  } : {
16
16
  colorSpace: string;
@@ -166,7 +166,7 @@ function createRenderer(_roots, _getEventPriority) {
166
166
  // Since disposal is recursive, we can check the optional dispose arg, which will be undefined
167
167
  // when the reconciler calls it, but then carry our own check recursively
168
168
  const isPrimitive = (_child$__r3f5 = child.__r3f) == null ? void 0 : _child$__r3f5.primitive;
169
- const shouldDispose = dispose === undefined ? child.dispose !== null && !isPrimitive : dispose;
169
+ const shouldDispose = !isPrimitive && (dispose === undefined ? child.dispose !== null : dispose);
170
170
 
171
171
  // Remove nested child objects. Primitives should not have objects and children that are
172
172
  // attached to them declaratively ...
@@ -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
  }
@@ -2170,7 +2177,9 @@ function Portal({
2170
2177
  },
2171
2178
  ...rest
2172
2179
  };
2173
- }, [state]);
2180
+ },
2181
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2182
+ [state]);
2174
2183
  const [usePortalStore] = React__namespace.useState(() => {
2175
2184
  // Create a mirrored store, based on the previous root with a few overrides ...
2176
2185
  const previousState = previousRoot.getState();
@@ -2211,9 +2220,11 @@ function Portal({
2211
2220
  unsub();
2212
2221
  usePortalStore.destroy();
2213
2222
  };
2223
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2214
2224
  }, []);
2215
2225
  React__namespace.useEffect(() => {
2216
2226
  usePortalStore.setState(injectState => inject(previousRoot.getState(), injectState));
2227
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2217
2228
  }, [inject]);
2218
2229
  return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, reconciler.createPortal( /*#__PURE__*/React__namespace.createElement(context.Provider, {
2219
2230
  value: usePortalStore
@@ -139,7 +139,7 @@ function createRenderer(_roots, _getEventPriority) {
139
139
  // Since disposal is recursive, we can check the optional dispose arg, which will be undefined
140
140
  // when the reconciler calls it, but then carry our own check recursively
141
141
  const isPrimitive = (_child$__r3f5 = child.__r3f) == null ? void 0 : _child$__r3f5.primitive;
142
- const shouldDispose = dispose === undefined ? child.dispose !== null && !isPrimitive : dispose;
142
+ const shouldDispose = !isPrimitive && (dispose === undefined ? child.dispose !== null : dispose);
143
143
 
144
144
  // Remove nested child objects. Primitives should not have objects and children that are
145
145
  // attached to them declaratively ...
@@ -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
  }
@@ -2143,7 +2150,9 @@ function Portal({
2143
2150
  },
2144
2151
  ...rest
2145
2152
  };
2146
- }, [state]);
2153
+ },
2154
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2155
+ [state]);
2147
2156
  const [usePortalStore] = React.useState(() => {
2148
2157
  // Create a mirrored store, based on the previous root with a few overrides ...
2149
2158
  const previousState = previousRoot.getState();
@@ -2184,9 +2193,11 @@ function Portal({
2184
2193
  unsub();
2185
2194
  usePortalStore.destroy();
2186
2195
  };
2196
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2187
2197
  }, []);
2188
2198
  React.useEffect(() => {
2189
2199
  usePortalStore.setState(injectState => inject(previousRoot.getState(), injectState));
2200
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2190
2201
  }, [inject]);
2191
2202
  return /*#__PURE__*/React.createElement(React.Fragment, null, reconciler.createPortal( /*#__PURE__*/React.createElement(context.Provider, {
2192
2203
  value: usePortalStore
@@ -166,7 +166,7 @@ function createRenderer(_roots, _getEventPriority) {
166
166
  // Since disposal is recursive, we can check the optional dispose arg, which will be undefined
167
167
  // when the reconciler calls it, but then carry our own check recursively
168
168
  const isPrimitive = (_child$__r3f5 = child.__r3f) == null ? void 0 : _child$__r3f5.primitive;
169
- const shouldDispose = dispose === undefined ? child.dispose !== null && !isPrimitive : dispose;
169
+ const shouldDispose = !isPrimitive && (dispose === undefined ? child.dispose !== null : dispose);
170
170
 
171
171
  // Remove nested child objects. Primitives should not have objects and children that are
172
172
  // attached to them declaratively ...
@@ -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
  }
@@ -2170,7 +2177,9 @@ function Portal({
2170
2177
  },
2171
2178
  ...rest
2172
2179
  };
2173
- }, [state]);
2180
+ },
2181
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2182
+ [state]);
2174
2183
  const [usePortalStore] = React__namespace.useState(() => {
2175
2184
  // Create a mirrored store, based on the previous root with a few overrides ...
2176
2185
  const previousState = previousRoot.getState();
@@ -2211,9 +2220,11 @@ function Portal({
2211
2220
  unsub();
2212
2221
  usePortalStore.destroy();
2213
2222
  };
2223
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2214
2224
  }, []);
2215
2225
  React__namespace.useEffect(() => {
2216
2226
  usePortalStore.setState(injectState => inject(previousRoot.getState(), injectState));
2227
+ // eslint-disable-next-line react-hooks/exhaustive-deps
2217
2228
  }, [inject]);
2218
2229
  return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, reconciler.createPortal( /*#__PURE__*/React__namespace.createElement(context.Provider, {
2219
2230
  value: usePortalStore
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-d26c5c57.cjs.dev.js');
5
+ var index = require('./index-b3e44f21.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-e6d64601.cjs.prod.js');
5
+ var index = require('./index-e462a173.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-594193f5.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-594193f5.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-db8af450.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-db8af450.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-d26c5c57.cjs.dev.js');
5
+ var index = require('../../dist/index-b3e44f21.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-e6d64601.cjs.prod.js');
5
+ var index = require('../../dist/index-e462a173.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-594193f5.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-594193f5.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-db8af450.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-db8af450.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.9",
3
+ "version": "8.15.11",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",