@react-three/fiber 8.5.0 → 8.6.1
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 +18 -0
- package/dist/declarations/src/web/Canvas.d.ts +2 -0
- package/dist/{index-2bf2b90e.cjs.dev.js → index-9a338808.cjs.dev.js} +15 -8
- package/dist/{index-ea463076.esm.js → index-cecf55e8.esm.js} +15 -8
- package/dist/{index-aea5c5ce.cjs.prod.js → index-f368ca4a.cjs.prod.js} +15 -8
- package/dist/react-three-fiber.cjs.dev.js +18 -2
- package/dist/react-three-fiber.cjs.prod.js +18 -2
- package/dist/react-three-fiber.esm.js +19 -3
- package/native/dist/react-three-fiber-native.cjs.dev.js +1 -1
- package/native/dist/react-three-fiber-native.cjs.prod.js +1 -1
- package/native/dist/react-three-fiber-native.esm.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @react-three/fiber
|
|
2
2
|
|
|
3
|
+
## 8.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7a0b5670: fix(core): don't append to unmounted containers
|
|
8
|
+
|
|
9
|
+
## 8.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 85c80e70: eventsource and eventprefix on the canvas component
|
|
14
|
+
|
|
15
|
+
## 8.5.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 87821d9: fix: null-check instance.children on reconstruct
|
|
20
|
+
|
|
3
21
|
## 8.5.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -5,5 +5,7 @@ export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, Rea
|
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
fallback?: React.ReactNode;
|
|
7
7
|
resize?: ResizeOptions;
|
|
8
|
+
eventSource?: HTMLElement;
|
|
9
|
+
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
|
|
8
10
|
}
|
|
9
11
|
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
@@ -1045,11 +1045,13 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1045
1045
|
// When args change the instance has to be re-constructed, which then
|
|
1046
1046
|
// forces r3f to re-parent the children and non-scene objects
|
|
1047
1047
|
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1048
|
+
if (instance.children) {
|
|
1049
|
+
for (const child of instance.children) {
|
|
1050
|
+
if (child.__r3f) appendChild(newInstance, child);
|
|
1051
|
+
}
|
|
1051
1052
|
|
|
1052
|
-
|
|
1053
|
+
instance.children = instance.children.filter(child => !child.__r3f);
|
|
1054
|
+
}
|
|
1053
1055
|
|
|
1054
1056
|
instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
|
|
1055
1057
|
|
|
@@ -1088,8 +1090,10 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1088
1090
|
supportsHydration: false,
|
|
1089
1091
|
noTimeout: -1,
|
|
1090
1092
|
appendChildToContainer: (container, child) => {
|
|
1091
|
-
if (!child) return;
|
|
1092
|
-
|
|
1093
|
+
if (!child) return; // Don't append to unmounted container
|
|
1094
|
+
|
|
1095
|
+
const scene = container.getState().scene;
|
|
1096
|
+
if (!scene.__r3f) return; // Link current root to the default scene
|
|
1093
1097
|
|
|
1094
1098
|
scene.__r3f.root = container;
|
|
1095
1099
|
appendChild(scene, child);
|
|
@@ -1099,8 +1103,11 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1099
1103
|
removeChild(container.getState().scene, child);
|
|
1100
1104
|
},
|
|
1101
1105
|
insertInContainerBefore: (container, child, beforeChild) => {
|
|
1102
|
-
if (!child || !beforeChild) return;
|
|
1103
|
-
|
|
1106
|
+
if (!child || !beforeChild) return; // Don't append to unmounted container
|
|
1107
|
+
|
|
1108
|
+
const scene = container.getState().scene;
|
|
1109
|
+
if (!scene.__r3f) return;
|
|
1110
|
+
insertBefore(scene, child, beforeChild);
|
|
1104
1111
|
},
|
|
1105
1112
|
getRootHostContext: () => null,
|
|
1106
1113
|
getChildHostContext: parentHostContext => parentHostContext,
|
|
@@ -1018,11 +1018,13 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1018
1018
|
// When args change the instance has to be re-constructed, which then
|
|
1019
1019
|
// forces r3f to re-parent the children and non-scene objects
|
|
1020
1020
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1021
|
+
if (instance.children) {
|
|
1022
|
+
for (const child of instance.children) {
|
|
1023
|
+
if (child.__r3f) appendChild(newInstance, child);
|
|
1024
|
+
}
|
|
1024
1025
|
|
|
1025
|
-
|
|
1026
|
+
instance.children = instance.children.filter(child => !child.__r3f);
|
|
1027
|
+
}
|
|
1026
1028
|
|
|
1027
1029
|
instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
|
|
1028
1030
|
|
|
@@ -1061,8 +1063,10 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1061
1063
|
supportsHydration: false,
|
|
1062
1064
|
noTimeout: -1,
|
|
1063
1065
|
appendChildToContainer: (container, child) => {
|
|
1064
|
-
if (!child) return;
|
|
1065
|
-
|
|
1066
|
+
if (!child) return; // Don't append to unmounted container
|
|
1067
|
+
|
|
1068
|
+
const scene = container.getState().scene;
|
|
1069
|
+
if (!scene.__r3f) return; // Link current root to the default scene
|
|
1066
1070
|
|
|
1067
1071
|
scene.__r3f.root = container;
|
|
1068
1072
|
appendChild(scene, child);
|
|
@@ -1072,8 +1076,11 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1072
1076
|
removeChild(container.getState().scene, child);
|
|
1073
1077
|
},
|
|
1074
1078
|
insertInContainerBefore: (container, child, beforeChild) => {
|
|
1075
|
-
if (!child || !beforeChild) return;
|
|
1076
|
-
|
|
1079
|
+
if (!child || !beforeChild) return; // Don't append to unmounted container
|
|
1080
|
+
|
|
1081
|
+
const scene = container.getState().scene;
|
|
1082
|
+
if (!scene.__r3f) return;
|
|
1083
|
+
insertBefore(scene, child, beforeChild);
|
|
1077
1084
|
},
|
|
1078
1085
|
getRootHostContext: () => null,
|
|
1079
1086
|
getChildHostContext: parentHostContext => parentHostContext,
|
|
@@ -1045,11 +1045,13 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1045
1045
|
// When args change the instance has to be re-constructed, which then
|
|
1046
1046
|
// forces r3f to re-parent the children and non-scene objects
|
|
1047
1047
|
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1048
|
+
if (instance.children) {
|
|
1049
|
+
for (const child of instance.children) {
|
|
1050
|
+
if (child.__r3f) appendChild(newInstance, child);
|
|
1051
|
+
}
|
|
1051
1052
|
|
|
1052
|
-
|
|
1053
|
+
instance.children = instance.children.filter(child => !child.__r3f);
|
|
1054
|
+
}
|
|
1053
1055
|
|
|
1054
1056
|
instance.__r3f.objects.forEach(child => appendChild(newInstance, child));
|
|
1055
1057
|
|
|
@@ -1088,8 +1090,10 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1088
1090
|
supportsHydration: false,
|
|
1089
1091
|
noTimeout: -1,
|
|
1090
1092
|
appendChildToContainer: (container, child) => {
|
|
1091
|
-
if (!child) return;
|
|
1092
|
-
|
|
1093
|
+
if (!child) return; // Don't append to unmounted container
|
|
1094
|
+
|
|
1095
|
+
const scene = container.getState().scene;
|
|
1096
|
+
if (!scene.__r3f) return; // Link current root to the default scene
|
|
1093
1097
|
|
|
1094
1098
|
scene.__r3f.root = container;
|
|
1095
1099
|
appendChild(scene, child);
|
|
@@ -1099,8 +1103,11 @@ function createRenderer(_roots, _getEventPriority) {
|
|
|
1099
1103
|
removeChild(container.getState().scene, child);
|
|
1100
1104
|
},
|
|
1101
1105
|
insertInContainerBefore: (container, child, beforeChild) => {
|
|
1102
|
-
if (!child || !beforeChild) return;
|
|
1103
|
-
|
|
1106
|
+
if (!child || !beforeChild) return; // Don't append to unmounted container
|
|
1107
|
+
|
|
1108
|
+
const scene = container.getState().scene;
|
|
1109
|
+
if (!scene.__r3f) return;
|
|
1110
|
+
insertBefore(scene, child, beforeChild);
|
|
1104
1111
|
},
|
|
1105
1112
|
getRootHostContext: () => null,
|
|
1106
1113
|
getChildHostContext: parentHostContext => parentHostContext,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-9a338808.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -126,6 +126,8 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
126
126
|
style,
|
|
127
127
|
gl,
|
|
128
128
|
events = createPointerEvents,
|
|
129
|
+
eventSource,
|
|
130
|
+
eventPrefix,
|
|
129
131
|
shadows,
|
|
130
132
|
linear,
|
|
131
133
|
flat,
|
|
@@ -184,7 +186,21 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
184
186
|
// Pass mutable reference to onPointerMissed so it's free to update
|
|
185
187
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
186
188
|
onCreated: state => {
|
|
187
|
-
|
|
189
|
+
// Connect to event source
|
|
190
|
+
state.events.connect == null ? void 0 : state.events.connect(eventSource ? eventSource : divRef.current); // Set up compute function
|
|
191
|
+
|
|
192
|
+
if (eventPrefix) {
|
|
193
|
+
state.setEvents({
|
|
194
|
+
compute: (event, state) => {
|
|
195
|
+
const x = event[eventPrefix + 'X'];
|
|
196
|
+
const y = event[eventPrefix + 'Y'];
|
|
197
|
+
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
198
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
} // Call onCreated callback
|
|
202
|
+
|
|
203
|
+
|
|
188
204
|
onCreated == null ? void 0 : onCreated(state);
|
|
189
205
|
}
|
|
190
206
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-f368ca4a.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -126,6 +126,8 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
126
126
|
style,
|
|
127
127
|
gl,
|
|
128
128
|
events = createPointerEvents,
|
|
129
|
+
eventSource,
|
|
130
|
+
eventPrefix,
|
|
129
131
|
shadows,
|
|
130
132
|
linear,
|
|
131
133
|
flat,
|
|
@@ -184,7 +186,21 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
184
186
|
// Pass mutable reference to onPointerMissed so it's free to update
|
|
185
187
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
186
188
|
onCreated: state => {
|
|
187
|
-
|
|
189
|
+
// Connect to event source
|
|
190
|
+
state.events.connect == null ? void 0 : state.events.connect(eventSource ? eventSource : divRef.current); // Set up compute function
|
|
191
|
+
|
|
192
|
+
if (eventPrefix) {
|
|
193
|
+
state.setEvents({
|
|
194
|
+
compute: (event, state) => {
|
|
195
|
+
const x = event[eventPrefix + 'X'];
|
|
196
|
+
const y = event[eventPrefix + 'Y'];
|
|
197
|
+
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
198
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
} // Call onCreated callback
|
|
202
|
+
|
|
203
|
+
|
|
188
204
|
onCreated == null ? void 0 : onCreated(state);
|
|
189
205
|
}
|
|
190
206
|
});
|
|
@@ -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-
|
|
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, c as createEvents, 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-
|
|
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-cecf55e8.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, c as createEvents, 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-cecf55e8.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';
|
|
@@ -99,6 +99,8 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
99
99
|
style,
|
|
100
100
|
gl,
|
|
101
101
|
events = createPointerEvents,
|
|
102
|
+
eventSource,
|
|
103
|
+
eventPrefix,
|
|
102
104
|
shadows,
|
|
103
105
|
linear,
|
|
104
106
|
flat,
|
|
@@ -157,7 +159,21 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
157
159
|
// Pass mutable reference to onPointerMissed so it's free to update
|
|
158
160
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
159
161
|
onCreated: state => {
|
|
160
|
-
|
|
162
|
+
// Connect to event source
|
|
163
|
+
state.events.connect == null ? void 0 : state.events.connect(eventSource ? eventSource : divRef.current); // Set up compute function
|
|
164
|
+
|
|
165
|
+
if (eventPrefix) {
|
|
166
|
+
state.setEvents({
|
|
167
|
+
compute: (event, state) => {
|
|
168
|
+
const x = event[eventPrefix + 'X'];
|
|
169
|
+
const y = event[eventPrefix + 'Y'];
|
|
170
|
+
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
171
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
} // Call onCreated callback
|
|
175
|
+
|
|
176
|
+
|
|
161
177
|
onCreated == null ? void 0 : onCreated(state);
|
|
162
178
|
}
|
|
163
179
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../dist/index-
|
|
5
|
+
var index = require('../../dist/index-9a338808.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-
|
|
5
|
+
var index = require('../../dist/index-f368ca4a.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-
|
|
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-
|
|
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-cecf55e8.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-cecf55e8.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';
|