@react-three/fiber 8.0.20 → 8.0.21

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,11 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.0.21
4
+
5
+ ### Patch Changes
6
+
7
+ - 3098b9b: fix: resizing in worker contexts, copy over attachments on reconstruct
8
+
3
9
  ## 8.0.20
4
10
 
5
11
  ### Patch Changes
@@ -17,6 +17,7 @@ export declare type Dpr = number | [min: number, max: number];
17
17
  export declare type Size = {
18
18
  width: number;
19
19
  height: number;
20
+ updateStyle?: boolean;
20
21
  };
21
22
  export declare type Viewport = Size & {
22
23
  initialDpr: number;
@@ -80,7 +81,7 @@ export declare type RootState = {
80
81
  invalidate: (frames?: number) => void;
81
82
  advance: (timestamp: number, runGlobalEffects?: boolean) => void;
82
83
  setEvents: (events: Partial<EventManager<any>>) => void;
83
- setSize: (width: number, height: number) => void;
84
+ setSize: (width: number, height: number, updateStyle?: boolean) => void;
84
85
  setDpr: (dpr: Dpr) => void;
85
86
  setFrameloop: (frameloop?: 'always' | 'demand' | 'never') => void;
86
87
  onPointerMissed?: (event: MouseEvent) => void;
@@ -1015,9 +1015,14 @@ function createRenderer(roots, getEventPriority) {
1015
1015
  if (type !== 'primitive' && instance.children) {
1016
1016
  instance.children.forEach(child => appendChild(newInstance, child));
1017
1017
  instance.children = [];
1018
- }
1018
+ } // Copy over child attachments
1019
+
1019
1020
 
1020
- instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
1021
+ for (const child of instance.__r3f.objects) {
1022
+ appendChild(newInstance, child);
1023
+ detach(instance, child, child.__r3f.attach);
1024
+ attach(newInstance, child, child.__r3f.attach);
1025
+ }
1021
1026
 
1022
1027
  instance.__r3f.objects = [];
1023
1028
 
@@ -1031,7 +1036,7 @@ function createRenderer(roots, getEventPriority) {
1031
1036
  const rootState = newInstance.__r3f.root.getState();
1032
1037
 
1033
1038
  rootState.internal.interaction.push(newInstance);
1034
- } // The attach attribute implies that the object attaches itself on the parent
1039
+ } // Attach instance to parent
1035
1040
 
1036
1041
 
1037
1042
  if ((_newInstance$__r3f = newInstance.__r3f) != null && _newInstance$__r3f.attach) {
@@ -1268,7 +1273,8 @@ const createStore = (invalidate, advance) => {
1268
1273
  },
1269
1274
  size: {
1270
1275
  width: 0,
1271
- height: 0
1276
+ height: 0,
1277
+ updateStyle: false
1272
1278
  },
1273
1279
  viewport: {
1274
1280
  initialDpr: 0,
@@ -1285,11 +1291,12 @@ const createStore = (invalidate, advance) => {
1285
1291
  ...events
1286
1292
  }
1287
1293
  })),
1288
- setSize: (width, height) => {
1294
+ setSize: (width, height, updateStyle) => {
1289
1295
  const camera = get().camera;
1290
1296
  const size = {
1291
1297
  width,
1292
- height
1298
+ height,
1299
+ updateStyle
1293
1300
  };
1294
1301
  set(state => ({
1295
1302
  size,
@@ -1379,7 +1386,7 @@ const createStore = (invalidate, advance) => {
1379
1386
  updateCamera(camera, size); // Update renderer
1380
1387
 
1381
1388
  gl.setPixelRatio(viewport.dpr);
1382
- gl.setSize(size.width, size.height);
1389
+ gl.setSize(size.width, size.height, size.updateStyle);
1383
1390
  oldSize = size;
1384
1391
  oldDpr = viewport.dpr;
1385
1392
  }
@@ -1801,7 +1808,7 @@ function createRoot(canvas) {
1801
1808
  width: (_canvas$parentElement = (_canvas$parentElement2 = canvas.parentElement) == null ? void 0 : _canvas$parentElement2.clientWidth) != null ? _canvas$parentElement : 0,
1802
1809
  height: (_canvas$parentElement3 = (_canvas$parentElement4 = canvas.parentElement) == null ? void 0 : _canvas$parentElement4.clientHeight) != null ? _canvas$parentElement3 : 0
1803
1810
  };
1804
- if (!is.equ(size, state.size, shallowLoose)) state.setSize(size.width, size.height); // Check frameloop
1811
+ if (!is.equ(size, state.size, shallowLoose)) state.setSize(size.width, size.height, size.updateStyle); // Check frameloop
1805
1812
 
1806
1813
  if (state.frameloop !== frameloop) state.setFrameloop(frameloop); // Check pointer missed
1807
1814
 
@@ -1042,9 +1042,14 @@ function createRenderer(roots, getEventPriority) {
1042
1042
  if (type !== 'primitive' && instance.children) {
1043
1043
  instance.children.forEach(child => appendChild(newInstance, child));
1044
1044
  instance.children = [];
1045
- }
1045
+ } // Copy over child attachments
1046
+
1046
1047
 
1047
- instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
1048
+ for (const child of instance.__r3f.objects) {
1049
+ appendChild(newInstance, child);
1050
+ detach(instance, child, child.__r3f.attach);
1051
+ attach(newInstance, child, child.__r3f.attach);
1052
+ }
1048
1053
 
1049
1054
  instance.__r3f.objects = [];
1050
1055
 
@@ -1058,7 +1063,7 @@ function createRenderer(roots, getEventPriority) {
1058
1063
  const rootState = newInstance.__r3f.root.getState();
1059
1064
 
1060
1065
  rootState.internal.interaction.push(newInstance);
1061
- } // The attach attribute implies that the object attaches itself on the parent
1066
+ } // Attach instance to parent
1062
1067
 
1063
1068
 
1064
1069
  if ((_newInstance$__r3f = newInstance.__r3f) != null && _newInstance$__r3f.attach) {
@@ -1295,7 +1300,8 @@ const createStore = (invalidate, advance) => {
1295
1300
  },
1296
1301
  size: {
1297
1302
  width: 0,
1298
- height: 0
1303
+ height: 0,
1304
+ updateStyle: false
1299
1305
  },
1300
1306
  viewport: {
1301
1307
  initialDpr: 0,
@@ -1312,11 +1318,12 @@ const createStore = (invalidate, advance) => {
1312
1318
  ...events
1313
1319
  }
1314
1320
  })),
1315
- setSize: (width, height) => {
1321
+ setSize: (width, height, updateStyle) => {
1316
1322
  const camera = get().camera;
1317
1323
  const size = {
1318
1324
  width,
1319
- height
1325
+ height,
1326
+ updateStyle
1320
1327
  };
1321
1328
  set(state => ({
1322
1329
  size,
@@ -1406,7 +1413,7 @@ const createStore = (invalidate, advance) => {
1406
1413
  updateCamera(camera, size); // Update renderer
1407
1414
 
1408
1415
  gl.setPixelRatio(viewport.dpr);
1409
- gl.setSize(size.width, size.height);
1416
+ gl.setSize(size.width, size.height, size.updateStyle);
1410
1417
  oldSize = size;
1411
1418
  oldDpr = viewport.dpr;
1412
1419
  }
@@ -1828,7 +1835,7 @@ function createRoot(canvas) {
1828
1835
  width: (_canvas$parentElement = (_canvas$parentElement2 = canvas.parentElement) == null ? void 0 : _canvas$parentElement2.clientWidth) != null ? _canvas$parentElement : 0,
1829
1836
  height: (_canvas$parentElement3 = (_canvas$parentElement4 = canvas.parentElement) == null ? void 0 : _canvas$parentElement4.clientHeight) != null ? _canvas$parentElement3 : 0
1830
1837
  };
1831
- if (!is.equ(size, state.size, shallowLoose)) state.setSize(size.width, size.height); // Check frameloop
1838
+ if (!is.equ(size, state.size, shallowLoose)) state.setSize(size.width, size.height, size.updateStyle); // Check frameloop
1832
1839
 
1833
1840
  if (state.frameloop !== frameloop) state.setFrameloop(frameloop); // Check pointer missed
1834
1841
 
@@ -1042,9 +1042,14 @@ function createRenderer(roots, getEventPriority) {
1042
1042
  if (type !== 'primitive' && instance.children) {
1043
1043
  instance.children.forEach(child => appendChild(newInstance, child));
1044
1044
  instance.children = [];
1045
- }
1045
+ } // Copy over child attachments
1046
+
1046
1047
 
1047
- instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
1048
+ for (const child of instance.__r3f.objects) {
1049
+ appendChild(newInstance, child);
1050
+ detach(instance, child, child.__r3f.attach);
1051
+ attach(newInstance, child, child.__r3f.attach);
1052
+ }
1048
1053
 
1049
1054
  instance.__r3f.objects = [];
1050
1055
 
@@ -1058,7 +1063,7 @@ function createRenderer(roots, getEventPriority) {
1058
1063
  const rootState = newInstance.__r3f.root.getState();
1059
1064
 
1060
1065
  rootState.internal.interaction.push(newInstance);
1061
- } // The attach attribute implies that the object attaches itself on the parent
1066
+ } // Attach instance to parent
1062
1067
 
1063
1068
 
1064
1069
  if ((_newInstance$__r3f = newInstance.__r3f) != null && _newInstance$__r3f.attach) {
@@ -1295,7 +1300,8 @@ const createStore = (invalidate, advance) => {
1295
1300
  },
1296
1301
  size: {
1297
1302
  width: 0,
1298
- height: 0
1303
+ height: 0,
1304
+ updateStyle: false
1299
1305
  },
1300
1306
  viewport: {
1301
1307
  initialDpr: 0,
@@ -1312,11 +1318,12 @@ const createStore = (invalidate, advance) => {
1312
1318
  ...events
1313
1319
  }
1314
1320
  })),
1315
- setSize: (width, height) => {
1321
+ setSize: (width, height, updateStyle) => {
1316
1322
  const camera = get().camera;
1317
1323
  const size = {
1318
1324
  width,
1319
- height
1325
+ height,
1326
+ updateStyle
1320
1327
  };
1321
1328
  set(state => ({
1322
1329
  size,
@@ -1406,7 +1413,7 @@ const createStore = (invalidate, advance) => {
1406
1413
  updateCamera(camera, size); // Update renderer
1407
1414
 
1408
1415
  gl.setPixelRatio(viewport.dpr);
1409
- gl.setSize(size.width, size.height);
1416
+ gl.setSize(size.width, size.height, size.updateStyle);
1410
1417
  oldSize = size;
1411
1418
  oldDpr = viewport.dpr;
1412
1419
  }
@@ -1828,7 +1835,7 @@ function createRoot(canvas) {
1828
1835
  width: (_canvas$parentElement = (_canvas$parentElement2 = canvas.parentElement) == null ? void 0 : _canvas$parentElement2.clientWidth) != null ? _canvas$parentElement : 0,
1829
1836
  height: (_canvas$parentElement3 = (_canvas$parentElement4 = canvas.parentElement) == null ? void 0 : _canvas$parentElement4.clientHeight) != null ? _canvas$parentElement3 : 0
1830
1837
  };
1831
- if (!is.equ(size, state.size, shallowLoose)) state.setSize(size.width, size.height); // Check frameloop
1838
+ if (!is.equ(size, state.size, shallowLoose)) state.setSize(size.width, size.height, size.updateStyle); // Check frameloop
1832
1839
 
1833
1840
  if (state.frameloop !== frameloop) state.setFrameloop(frameloop); // Check pointer missed
1834
1841
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-f796b922.cjs.dev.js');
5
+ var index = require('./index-8e20caed.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-d2826534.cjs.prod.js');
5
+ var index = require('./index-786a40b6.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 createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-2de7e188.esm.js';
2
- export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-2de7e188.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-30926efc.esm.js';
2
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-30926efc.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-f796b922.cjs.dev.js');
5
+ var index = require('../../dist/index-8e20caed.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-d2826534.cjs.prod.js');
5
+ var index = require('../../dist/index-786a40b6.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 createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-2de7e188.esm.js';
2
- export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-2de7e188.esm.js';
1
+ import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-30926efc.esm.js';
2
+ export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from '../../dist/index-30926efc.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.0.20",
3
+ "version": "8.0.21",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",