@react-three/fiber 8.13.2 → 8.13.3
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 +6 -0
- package/dist/declarations/src/core/index.d.ts +3 -2
- package/dist/declarations/src/core/store.d.ts +2 -0
- package/dist/{index-948f4806.cjs.prod.js → index-5195c1db.cjs.prod.js} +62 -24
- package/dist/{index-13b06ff5.esm.js → index-76c68185.esm.js} +62 -24
- package/dist/{index-a0deb08b.cjs.dev.js → index-c307a54a.cjs.dev.js} +62 -24
- package/dist/react-three-fiber.cjs.dev.js +1 -1
- package/dist/react-three-fiber.cjs.prod.js +1 -1
- package/dist/react-three-fiber.esm.js +2 -2
- 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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,7 @@ import * as THREE from 'three';
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { UseBoundStore } from 'zustand';
|
|
6
6
|
import * as ReactThreeFiber from '../three-types';
|
|
7
|
-
import { Renderer, context, RootState, Size, Dpr, Performance } from './store';
|
|
7
|
+
import { Renderer, context, RootState, Size, Dpr, Performance, PrivateKeys } from './store';
|
|
8
8
|
import { extend, Root } from './renderer';
|
|
9
9
|
import { addEffect, addAfterEffect, addTail, flushGlobalEffects } from './loop';
|
|
10
10
|
import { EventManager, ComputeFunction } from './events';
|
|
@@ -43,13 +43,14 @@ export declare type ReconcilerRoot<TCanvas extends Canvas> = {
|
|
|
43
43
|
declare function createRoot<TCanvas extends Canvas>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
|
|
44
44
|
declare function render<TCanvas extends Canvas>(children: React.ReactNode, canvas: TCanvas, config: RenderProps<TCanvas>): UseBoundStore<RootState>;
|
|
45
45
|
declare function unmountComponentAtNode<TCanvas extends Canvas>(canvas: TCanvas, callback?: (canvas: TCanvas) => void): void;
|
|
46
|
-
export declare type InjectState = Partial<Omit<RootState,
|
|
46
|
+
export declare type InjectState = Partial<Omit<RootState, PrivateKeys> & {
|
|
47
47
|
events?: {
|
|
48
48
|
enabled?: boolean;
|
|
49
49
|
priority?: number;
|
|
50
50
|
compute?: ComputeFunction;
|
|
51
51
|
connected?: any;
|
|
52
52
|
};
|
|
53
|
+
size?: Size;
|
|
53
54
|
}>;
|
|
54
55
|
declare function createPortal(children: React.ReactNode, container: THREE.Object3D, state?: InjectState): JSX.Element;
|
|
55
56
|
declare const act: any;
|
|
@@ -4,6 +4,8 @@ import * as React from 'react';
|
|
|
4
4
|
import { GetState, SetState, StoreApi, UseBoundStore } from 'zustand';
|
|
5
5
|
import { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from './events';
|
|
6
6
|
import { Camera } from './utils';
|
|
7
|
+
export declare const privateKeys: readonly ["set", "get", "setSize", "setFrameloop", "setDpr", "events", "invalidate", "advance", "size", "viewport"];
|
|
8
|
+
export declare type PrivateKeys = typeof privateKeys[number];
|
|
7
9
|
export interface Intersection extends THREE.Intersection {
|
|
8
10
|
eventObject: THREE.Object3D;
|
|
9
11
|
}
|
|
@@ -1227,6 +1227,8 @@ function createEvents(store) {
|
|
|
1227
1227
|
};
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
|
+
// Keys that shouldn't be copied between R3F stores
|
|
1231
|
+
const privateKeys = ['set', 'get', 'setSize', 'setFrameloop', 'setDpr', 'events', 'invalidate', 'advance', 'size', 'viewport'];
|
|
1230
1232
|
const isRenderer = def => !!(def != null && def.render);
|
|
1231
1233
|
const context = /*#__PURE__*/React__namespace.createContext(null);
|
|
1232
1234
|
const createStore = (invalidate, advance) => {
|
|
@@ -2056,6 +2058,7 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
2056
2058
|
}
|
|
2057
2059
|
function createPortal(children, container, state) {
|
|
2058
2060
|
return /*#__PURE__*/React__namespace.createElement(Portal, {
|
|
2061
|
+
key: container.uuid,
|
|
2059
2062
|
children: children,
|
|
2060
2063
|
container: container,
|
|
2061
2064
|
state: state
|
|
@@ -2079,9 +2082,26 @@ function Portal({
|
|
|
2079
2082
|
const previousRoot = useStore();
|
|
2080
2083
|
const [raycaster] = React__namespace.useState(() => new THREE__namespace.Raycaster());
|
|
2081
2084
|
const [pointer] = React__namespace.useState(() => new THREE__namespace.Vector2());
|
|
2082
|
-
const inject =
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
+
const inject = React__namespace.useCallback((rootState, injectState) => {
|
|
2086
|
+
const intersect = {
|
|
2087
|
+
...rootState
|
|
2088
|
+
}; // all prev state props
|
|
2089
|
+
|
|
2090
|
+
// Only the fields of "rootState" that do not differ from injectState
|
|
2091
|
+
// Some props should be off-limits
|
|
2092
|
+
// Otherwise filter out the props that are different and let the inject layer take precedence
|
|
2093
|
+
Object.keys(rootState).forEach(key => {
|
|
2094
|
+
if (
|
|
2095
|
+
// Some props should be off-limits
|
|
2096
|
+
privateKeys.includes(key) ||
|
|
2097
|
+
// Otherwise filter out the props that are different and let the inject layer take precedence
|
|
2098
|
+
// Unless the inject layer props is undefined, then we keep the root layer
|
|
2099
|
+
rootState[key] !== injectState[key] && injectState[key]) {
|
|
2100
|
+
delete intersect[key];
|
|
2101
|
+
}
|
|
2102
|
+
});
|
|
2103
|
+
let viewport = undefined;
|
|
2104
|
+
if (injectState && size) {
|
|
2085
2105
|
const camera = injectState.camera;
|
|
2086
2106
|
// Calculate the override viewport, if present
|
|
2087
2107
|
viewport = rootState.viewport.getCurrentViewport(camera, new THREE__namespace.Vector3(), size);
|
|
@@ -2090,9 +2110,7 @@ function Portal({
|
|
|
2090
2110
|
}
|
|
2091
2111
|
return {
|
|
2092
2112
|
// The intersect consists of the previous root state
|
|
2093
|
-
...
|
|
2094
|
-
get: injectState.get,
|
|
2095
|
-
set: injectState.set,
|
|
2113
|
+
...intersect,
|
|
2096
2114
|
// Portals have their own scene, which forms the root, a raycaster and a pointer
|
|
2097
2115
|
scene: container,
|
|
2098
2116
|
raycaster,
|
|
@@ -2103,7 +2121,7 @@ function Portal({
|
|
|
2103
2121
|
// Events, size and viewport can be overridden by the inject layer
|
|
2104
2122
|
events: {
|
|
2105
2123
|
...rootState.events,
|
|
2106
|
-
...injectState.events,
|
|
2124
|
+
...(injectState == null ? void 0 : injectState.events),
|
|
2107
2125
|
...events
|
|
2108
2126
|
},
|
|
2109
2127
|
size: {
|
|
@@ -2114,33 +2132,53 @@ function Portal({
|
|
|
2114
2132
|
...rootState.viewport,
|
|
2115
2133
|
...viewport
|
|
2116
2134
|
},
|
|
2135
|
+
...rest
|
|
2136
|
+
};
|
|
2137
|
+
}, [state]);
|
|
2138
|
+
const [usePortalStore] = React__namespace.useState(() => {
|
|
2139
|
+
// Create a mirrored store, based on the previous root with a few overrides ...
|
|
2140
|
+
const previousState = previousRoot.getState();
|
|
2141
|
+
const store = create__default["default"]((set, get) => ({
|
|
2142
|
+
...previousState,
|
|
2143
|
+
scene: container,
|
|
2144
|
+
raycaster,
|
|
2145
|
+
pointer,
|
|
2146
|
+
mouse: pointer,
|
|
2147
|
+
previousRoot,
|
|
2148
|
+
events: {
|
|
2149
|
+
...previousState.events,
|
|
2150
|
+
...events
|
|
2151
|
+
},
|
|
2152
|
+
size: {
|
|
2153
|
+
...previousState.size,
|
|
2154
|
+
...size
|
|
2155
|
+
},
|
|
2156
|
+
...rest,
|
|
2157
|
+
// Set and get refer to this root-state
|
|
2158
|
+
set,
|
|
2159
|
+
get,
|
|
2117
2160
|
// Layers are allowed to override events
|
|
2118
|
-
setEvents: events =>
|
|
2161
|
+
setEvents: events => set(state => ({
|
|
2119
2162
|
...state,
|
|
2120
2163
|
events: {
|
|
2121
2164
|
...state.events,
|
|
2122
2165
|
...events
|
|
2123
2166
|
}
|
|
2124
2167
|
}))
|
|
2125
|
-
};
|
|
2126
|
-
});
|
|
2127
|
-
const usePortalStore = React__namespace.useMemo(() => {
|
|
2128
|
-
const store = create__default["default"]((set, get) => ({
|
|
2129
|
-
...rest,
|
|
2130
|
-
set,
|
|
2131
|
-
get
|
|
2132
2168
|
}));
|
|
2133
|
-
|
|
2134
|
-
// Subscribe to previous root-state and copy changes over to the mirrored portal-state
|
|
2135
|
-
const onMutate = prev => store.setState(state => inject.current(prev, state));
|
|
2136
|
-
onMutate(previousRoot.getState());
|
|
2137
|
-
previousRoot.subscribe(onMutate);
|
|
2138
2169
|
return store;
|
|
2139
|
-
|
|
2140
|
-
|
|
2170
|
+
});
|
|
2171
|
+
React__namespace.useEffect(() => {
|
|
2172
|
+
// Subscribe to previous root-state and copy changes over to the mirrored portal-state
|
|
2173
|
+
const unsub = previousRoot.subscribe(prev => usePortalStore.setState(state => inject(prev, state)));
|
|
2174
|
+
return () => {
|
|
2175
|
+
unsub();
|
|
2176
|
+
usePortalStore.destroy();
|
|
2177
|
+
};
|
|
2178
|
+
}, []);
|
|
2141
2179
|
React__namespace.useEffect(() => {
|
|
2142
|
-
|
|
2143
|
-
}, [
|
|
2180
|
+
usePortalStore.setState(injectState => inject(previousRoot.getState(), injectState));
|
|
2181
|
+
}, [inject]);
|
|
2144
2182
|
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, reconciler.createPortal( /*#__PURE__*/React__namespace.createElement(context.Provider, {
|
|
2145
2183
|
value: usePortalStore
|
|
2146
2184
|
}, children), usePortalStore, null));
|
|
@@ -1200,6 +1200,8 @@ function createEvents(store) {
|
|
|
1200
1200
|
};
|
|
1201
1201
|
}
|
|
1202
1202
|
|
|
1203
|
+
// Keys that shouldn't be copied between R3F stores
|
|
1204
|
+
const privateKeys = ['set', 'get', 'setSize', 'setFrameloop', 'setDpr', 'events', 'invalidate', 'advance', 'size', 'viewport'];
|
|
1203
1205
|
const isRenderer = def => !!(def != null && def.render);
|
|
1204
1206
|
const context = /*#__PURE__*/React.createContext(null);
|
|
1205
1207
|
const createStore = (invalidate, advance) => {
|
|
@@ -2029,6 +2031,7 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
2029
2031
|
}
|
|
2030
2032
|
function createPortal(children, container, state) {
|
|
2031
2033
|
return /*#__PURE__*/React.createElement(Portal, {
|
|
2034
|
+
key: container.uuid,
|
|
2032
2035
|
children: children,
|
|
2033
2036
|
container: container,
|
|
2034
2037
|
state: state
|
|
@@ -2052,9 +2055,26 @@ function Portal({
|
|
|
2052
2055
|
const previousRoot = useStore();
|
|
2053
2056
|
const [raycaster] = React.useState(() => new THREE.Raycaster());
|
|
2054
2057
|
const [pointer] = React.useState(() => new THREE.Vector2());
|
|
2055
|
-
const inject =
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
+
const inject = React.useCallback((rootState, injectState) => {
|
|
2059
|
+
const intersect = {
|
|
2060
|
+
...rootState
|
|
2061
|
+
}; // all prev state props
|
|
2062
|
+
|
|
2063
|
+
// Only the fields of "rootState" that do not differ from injectState
|
|
2064
|
+
// Some props should be off-limits
|
|
2065
|
+
// Otherwise filter out the props that are different and let the inject layer take precedence
|
|
2066
|
+
Object.keys(rootState).forEach(key => {
|
|
2067
|
+
if (
|
|
2068
|
+
// Some props should be off-limits
|
|
2069
|
+
privateKeys.includes(key) ||
|
|
2070
|
+
// Otherwise filter out the props that are different and let the inject layer take precedence
|
|
2071
|
+
// Unless the inject layer props is undefined, then we keep the root layer
|
|
2072
|
+
rootState[key] !== injectState[key] && injectState[key]) {
|
|
2073
|
+
delete intersect[key];
|
|
2074
|
+
}
|
|
2075
|
+
});
|
|
2076
|
+
let viewport = undefined;
|
|
2077
|
+
if (injectState && size) {
|
|
2058
2078
|
const camera = injectState.camera;
|
|
2059
2079
|
// Calculate the override viewport, if present
|
|
2060
2080
|
viewport = rootState.viewport.getCurrentViewport(camera, new THREE.Vector3(), size);
|
|
@@ -2063,9 +2083,7 @@ function Portal({
|
|
|
2063
2083
|
}
|
|
2064
2084
|
return {
|
|
2065
2085
|
// The intersect consists of the previous root state
|
|
2066
|
-
...
|
|
2067
|
-
get: injectState.get,
|
|
2068
|
-
set: injectState.set,
|
|
2086
|
+
...intersect,
|
|
2069
2087
|
// Portals have their own scene, which forms the root, a raycaster and a pointer
|
|
2070
2088
|
scene: container,
|
|
2071
2089
|
raycaster,
|
|
@@ -2076,7 +2094,7 @@ function Portal({
|
|
|
2076
2094
|
// Events, size and viewport can be overridden by the inject layer
|
|
2077
2095
|
events: {
|
|
2078
2096
|
...rootState.events,
|
|
2079
|
-
...injectState.events,
|
|
2097
|
+
...(injectState == null ? void 0 : injectState.events),
|
|
2080
2098
|
...events
|
|
2081
2099
|
},
|
|
2082
2100
|
size: {
|
|
@@ -2087,33 +2105,53 @@ function Portal({
|
|
|
2087
2105
|
...rootState.viewport,
|
|
2088
2106
|
...viewport
|
|
2089
2107
|
},
|
|
2108
|
+
...rest
|
|
2109
|
+
};
|
|
2110
|
+
}, [state]);
|
|
2111
|
+
const [usePortalStore] = React.useState(() => {
|
|
2112
|
+
// Create a mirrored store, based on the previous root with a few overrides ...
|
|
2113
|
+
const previousState = previousRoot.getState();
|
|
2114
|
+
const store = create((set, get) => ({
|
|
2115
|
+
...previousState,
|
|
2116
|
+
scene: container,
|
|
2117
|
+
raycaster,
|
|
2118
|
+
pointer,
|
|
2119
|
+
mouse: pointer,
|
|
2120
|
+
previousRoot,
|
|
2121
|
+
events: {
|
|
2122
|
+
...previousState.events,
|
|
2123
|
+
...events
|
|
2124
|
+
},
|
|
2125
|
+
size: {
|
|
2126
|
+
...previousState.size,
|
|
2127
|
+
...size
|
|
2128
|
+
},
|
|
2129
|
+
...rest,
|
|
2130
|
+
// Set and get refer to this root-state
|
|
2131
|
+
set,
|
|
2132
|
+
get,
|
|
2090
2133
|
// Layers are allowed to override events
|
|
2091
|
-
setEvents: events =>
|
|
2134
|
+
setEvents: events => set(state => ({
|
|
2092
2135
|
...state,
|
|
2093
2136
|
events: {
|
|
2094
2137
|
...state.events,
|
|
2095
2138
|
...events
|
|
2096
2139
|
}
|
|
2097
2140
|
}))
|
|
2098
|
-
};
|
|
2099
|
-
});
|
|
2100
|
-
const usePortalStore = React.useMemo(() => {
|
|
2101
|
-
const store = create((set, get) => ({
|
|
2102
|
-
...rest,
|
|
2103
|
-
set,
|
|
2104
|
-
get
|
|
2105
2141
|
}));
|
|
2106
|
-
|
|
2107
|
-
// Subscribe to previous root-state and copy changes over to the mirrored portal-state
|
|
2108
|
-
const onMutate = prev => store.setState(state => inject.current(prev, state));
|
|
2109
|
-
onMutate(previousRoot.getState());
|
|
2110
|
-
previousRoot.subscribe(onMutate);
|
|
2111
2142
|
return store;
|
|
2112
|
-
|
|
2113
|
-
|
|
2143
|
+
});
|
|
2144
|
+
React.useEffect(() => {
|
|
2145
|
+
// Subscribe to previous root-state and copy changes over to the mirrored portal-state
|
|
2146
|
+
const unsub = previousRoot.subscribe(prev => usePortalStore.setState(state => inject(prev, state)));
|
|
2147
|
+
return () => {
|
|
2148
|
+
unsub();
|
|
2149
|
+
usePortalStore.destroy();
|
|
2150
|
+
};
|
|
2151
|
+
}, []);
|
|
2114
2152
|
React.useEffect(() => {
|
|
2115
|
-
|
|
2116
|
-
}, [
|
|
2153
|
+
usePortalStore.setState(injectState => inject(previousRoot.getState(), injectState));
|
|
2154
|
+
}, [inject]);
|
|
2117
2155
|
return /*#__PURE__*/React.createElement(React.Fragment, null, reconciler.createPortal( /*#__PURE__*/React.createElement(context.Provider, {
|
|
2118
2156
|
value: usePortalStore
|
|
2119
2157
|
}, children), usePortalStore, null));
|
|
@@ -1227,6 +1227,8 @@ function createEvents(store) {
|
|
|
1227
1227
|
};
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
|
+
// Keys that shouldn't be copied between R3F stores
|
|
1231
|
+
const privateKeys = ['set', 'get', 'setSize', 'setFrameloop', 'setDpr', 'events', 'invalidate', 'advance', 'size', 'viewport'];
|
|
1230
1232
|
const isRenderer = def => !!(def != null && def.render);
|
|
1231
1233
|
const context = /*#__PURE__*/React__namespace.createContext(null);
|
|
1232
1234
|
const createStore = (invalidate, advance) => {
|
|
@@ -2056,6 +2058,7 @@ function unmountComponentAtNode(canvas, callback) {
|
|
|
2056
2058
|
}
|
|
2057
2059
|
function createPortal(children, container, state) {
|
|
2058
2060
|
return /*#__PURE__*/React__namespace.createElement(Portal, {
|
|
2061
|
+
key: container.uuid,
|
|
2059
2062
|
children: children,
|
|
2060
2063
|
container: container,
|
|
2061
2064
|
state: state
|
|
@@ -2079,9 +2082,26 @@ function Portal({
|
|
|
2079
2082
|
const previousRoot = useStore();
|
|
2080
2083
|
const [raycaster] = React__namespace.useState(() => new THREE__namespace.Raycaster());
|
|
2081
2084
|
const [pointer] = React__namespace.useState(() => new THREE__namespace.Vector2());
|
|
2082
|
-
const inject =
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
+
const inject = React__namespace.useCallback((rootState, injectState) => {
|
|
2086
|
+
const intersect = {
|
|
2087
|
+
...rootState
|
|
2088
|
+
}; // all prev state props
|
|
2089
|
+
|
|
2090
|
+
// Only the fields of "rootState" that do not differ from injectState
|
|
2091
|
+
// Some props should be off-limits
|
|
2092
|
+
// Otherwise filter out the props that are different and let the inject layer take precedence
|
|
2093
|
+
Object.keys(rootState).forEach(key => {
|
|
2094
|
+
if (
|
|
2095
|
+
// Some props should be off-limits
|
|
2096
|
+
privateKeys.includes(key) ||
|
|
2097
|
+
// Otherwise filter out the props that are different and let the inject layer take precedence
|
|
2098
|
+
// Unless the inject layer props is undefined, then we keep the root layer
|
|
2099
|
+
rootState[key] !== injectState[key] && injectState[key]) {
|
|
2100
|
+
delete intersect[key];
|
|
2101
|
+
}
|
|
2102
|
+
});
|
|
2103
|
+
let viewport = undefined;
|
|
2104
|
+
if (injectState && size) {
|
|
2085
2105
|
const camera = injectState.camera;
|
|
2086
2106
|
// Calculate the override viewport, if present
|
|
2087
2107
|
viewport = rootState.viewport.getCurrentViewport(camera, new THREE__namespace.Vector3(), size);
|
|
@@ -2090,9 +2110,7 @@ function Portal({
|
|
|
2090
2110
|
}
|
|
2091
2111
|
return {
|
|
2092
2112
|
// The intersect consists of the previous root state
|
|
2093
|
-
...
|
|
2094
|
-
get: injectState.get,
|
|
2095
|
-
set: injectState.set,
|
|
2113
|
+
...intersect,
|
|
2096
2114
|
// Portals have their own scene, which forms the root, a raycaster and a pointer
|
|
2097
2115
|
scene: container,
|
|
2098
2116
|
raycaster,
|
|
@@ -2103,7 +2121,7 @@ function Portal({
|
|
|
2103
2121
|
// Events, size and viewport can be overridden by the inject layer
|
|
2104
2122
|
events: {
|
|
2105
2123
|
...rootState.events,
|
|
2106
|
-
...injectState.events,
|
|
2124
|
+
...(injectState == null ? void 0 : injectState.events),
|
|
2107
2125
|
...events
|
|
2108
2126
|
},
|
|
2109
2127
|
size: {
|
|
@@ -2114,33 +2132,53 @@ function Portal({
|
|
|
2114
2132
|
...rootState.viewport,
|
|
2115
2133
|
...viewport
|
|
2116
2134
|
},
|
|
2135
|
+
...rest
|
|
2136
|
+
};
|
|
2137
|
+
}, [state]);
|
|
2138
|
+
const [usePortalStore] = React__namespace.useState(() => {
|
|
2139
|
+
// Create a mirrored store, based on the previous root with a few overrides ...
|
|
2140
|
+
const previousState = previousRoot.getState();
|
|
2141
|
+
const store = create__default["default"]((set, get) => ({
|
|
2142
|
+
...previousState,
|
|
2143
|
+
scene: container,
|
|
2144
|
+
raycaster,
|
|
2145
|
+
pointer,
|
|
2146
|
+
mouse: pointer,
|
|
2147
|
+
previousRoot,
|
|
2148
|
+
events: {
|
|
2149
|
+
...previousState.events,
|
|
2150
|
+
...events
|
|
2151
|
+
},
|
|
2152
|
+
size: {
|
|
2153
|
+
...previousState.size,
|
|
2154
|
+
...size
|
|
2155
|
+
},
|
|
2156
|
+
...rest,
|
|
2157
|
+
// Set and get refer to this root-state
|
|
2158
|
+
set,
|
|
2159
|
+
get,
|
|
2117
2160
|
// Layers are allowed to override events
|
|
2118
|
-
setEvents: events =>
|
|
2161
|
+
setEvents: events => set(state => ({
|
|
2119
2162
|
...state,
|
|
2120
2163
|
events: {
|
|
2121
2164
|
...state.events,
|
|
2122
2165
|
...events
|
|
2123
2166
|
}
|
|
2124
2167
|
}))
|
|
2125
|
-
};
|
|
2126
|
-
});
|
|
2127
|
-
const usePortalStore = React__namespace.useMemo(() => {
|
|
2128
|
-
const store = create__default["default"]((set, get) => ({
|
|
2129
|
-
...rest,
|
|
2130
|
-
set,
|
|
2131
|
-
get
|
|
2132
2168
|
}));
|
|
2133
|
-
|
|
2134
|
-
// Subscribe to previous root-state and copy changes over to the mirrored portal-state
|
|
2135
|
-
const onMutate = prev => store.setState(state => inject.current(prev, state));
|
|
2136
|
-
onMutate(previousRoot.getState());
|
|
2137
|
-
previousRoot.subscribe(onMutate);
|
|
2138
2169
|
return store;
|
|
2139
|
-
|
|
2140
|
-
|
|
2170
|
+
});
|
|
2171
|
+
React__namespace.useEffect(() => {
|
|
2172
|
+
// Subscribe to previous root-state and copy changes over to the mirrored portal-state
|
|
2173
|
+
const unsub = previousRoot.subscribe(prev => usePortalStore.setState(state => inject(prev, state)));
|
|
2174
|
+
return () => {
|
|
2175
|
+
unsub();
|
|
2176
|
+
usePortalStore.destroy();
|
|
2177
|
+
};
|
|
2178
|
+
}, []);
|
|
2141
2179
|
React__namespace.useEffect(() => {
|
|
2142
|
-
|
|
2143
|
-
}, [
|
|
2180
|
+
usePortalStore.setState(injectState => inject(previousRoot.getState(), injectState));
|
|
2181
|
+
}, [inject]);
|
|
2144
2182
|
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, reconciler.createPortal( /*#__PURE__*/React__namespace.createElement(context.Provider, {
|
|
2145
2183
|
value: usePortalStore
|
|
2146
2184
|
}, children), usePortalStore, null));
|
|
@@ -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-c307a54a.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-
|
|
5
|
+
var index = require('./index-5195c1db.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-
|
|
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-
|
|
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-76c68185.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-76c68185.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-
|
|
5
|
+
var index = require('../../dist/index-c307a54a.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-5195c1db.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-
|
|
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-
|
|
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-76c68185.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-76c68185.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.13.
|
|
3
|
+
"version": "8.13.3",
|
|
4
4
|
"description": "A React renderer for Threejs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"react-reconciler": "^0.27.0",
|
|
49
49
|
"react-use-measure": "^2.1.1",
|
|
50
50
|
"scheduler": "^0.21.0",
|
|
51
|
-
"suspend-react": "^0.1.
|
|
51
|
+
"suspend-react": "^0.1.3",
|
|
52
52
|
"zustand": "^3.7.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|