@react-three/fiber 8.1.0 → 8.2.2
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/core/events.d.ts +69 -69
- package/dist/declarations/src/core/hooks.d.ts +21 -21
- package/dist/declarations/src/core/index.d.ts +57 -57
- package/dist/declarations/src/core/loop.d.ts +13 -13
- package/dist/declarations/src/core/renderer.d.ts +51 -51
- package/dist/declarations/src/core/store.d.ts +95 -95
- package/dist/declarations/src/core/utils.d.ts +82 -82
- package/dist/declarations/src/index.d.ts +11 -11
- package/dist/declarations/src/native/Canvas.d.ts +8 -8
- package/dist/declarations/src/native/events.d.ts +4 -4
- package/dist/declarations/src/native/polyfills.d.ts +1 -1
- package/dist/declarations/src/native.d.ts +10 -10
- package/dist/declarations/src/three-types.d.ts +331 -329
- package/dist/declarations/src/web/Canvas.d.ts +9 -9
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-c13c7c31.cjs.dev.js → index-2a5b06d3.cjs.dev.js} +44 -30
- package/dist/{index-ab905875.cjs.prod.js → index-876a6569.cjs.prod.js} +44 -30
- package/dist/{index-9b4af973.esm.js → index-af244448.esm.js} +44 -30
- 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 +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
-
import { RenderProps } from '../core';
|
|
4
|
-
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
fallback?: React.ReactNode;
|
|
7
|
-
resize?: ResizeOptions;
|
|
8
|
-
}
|
|
9
|
-
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
+
import { RenderProps } from '../core';
|
|
4
|
+
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
fallback?: React.ReactNode;
|
|
7
|
+
resize?: ResizeOptions;
|
|
8
|
+
}
|
|
9
|
+
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseBoundStore } from 'zustand';
|
|
2
|
-
import { RootState } from '../core/store';
|
|
3
|
-
import { EventManager } from '../core/events';
|
|
4
|
-
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
1
|
+
import { UseBoundStore } from 'zustand';
|
|
2
|
+
import { RootState } from '../core/store';
|
|
3
|
+
import { EventManager } from '../core/events';
|
|
4
|
+
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
@@ -37,12 +37,19 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
37
37
|
__proto__: null
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
var _window$document, _window$navigator;
|
|
41
|
+
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
42
|
+
/**
|
|
43
|
+
* An SSR-friendly useLayoutEffect.
|
|
44
|
+
*
|
|
45
|
+
* React currently throws a warning when using useLayoutEffect on the server.
|
|
46
|
+
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
47
|
+
* useLayoutEffect elsewhere.
|
|
48
|
+
*
|
|
49
|
+
* @see https://github.com/facebook/react/issues/14927
|
|
50
|
+
*/
|
|
43
51
|
|
|
44
|
-
const
|
|
45
|
-
const useIsomorphicLayoutEffect = isSSR ? React__namespace.useEffect : React__namespace.useLayoutEffect;
|
|
52
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
46
53
|
function useMutableCallback(fn) {
|
|
47
54
|
const ref = React__namespace.useRef(fn);
|
|
48
55
|
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
@@ -855,7 +862,7 @@ let extend = objects => void (catalogue = { ...catalogue,
|
|
|
855
862
|
...objects
|
|
856
863
|
});
|
|
857
864
|
|
|
858
|
-
function createRenderer(
|
|
865
|
+
function createRenderer(_roots, _getEventPriority) {
|
|
859
866
|
function createInstance(type, {
|
|
860
867
|
args = [],
|
|
861
868
|
attach,
|
|
@@ -1063,7 +1070,10 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1063
1070
|
}
|
|
1064
1071
|
}
|
|
1065
1072
|
});
|
|
1066
|
-
}
|
|
1073
|
+
} // Don't handle text instances, warn on undefined behavior
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
const handleTextInstance = () => console.warn('Text is not allowed in the R3F tree! This could be stray whitespace or characters.');
|
|
1067
1077
|
|
|
1068
1078
|
const reconciler = Reconciler__default["default"]({
|
|
1069
1079
|
createInstance,
|
|
@@ -1071,19 +1081,26 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1071
1081
|
appendChild,
|
|
1072
1082
|
appendInitialChild: appendChild,
|
|
1073
1083
|
insertBefore,
|
|
1074
|
-
supportsMicrotask: true,
|
|
1075
|
-
warnsIfNotActing: true,
|
|
1076
1084
|
supportsMutation: true,
|
|
1077
1085
|
isPrimaryRenderer: false,
|
|
1086
|
+
supportsPersistence: false,
|
|
1087
|
+
supportsHydration: false,
|
|
1078
1088
|
noTimeout: -1,
|
|
1079
1089
|
appendChildToContainer: (container, child) => {
|
|
1090
|
+
if (!child) return;
|
|
1080
1091
|
const scene = container.getState().scene; // Link current root to the default scene
|
|
1081
1092
|
|
|
1082
1093
|
scene.__r3f.root = container;
|
|
1083
1094
|
appendChild(scene, child);
|
|
1084
1095
|
},
|
|
1085
|
-
removeChildFromContainer: (container, child) =>
|
|
1086
|
-
|
|
1096
|
+
removeChildFromContainer: (container, child) => {
|
|
1097
|
+
if (!child) return;
|
|
1098
|
+
removeChild(container.getState().scene, child);
|
|
1099
|
+
},
|
|
1100
|
+
insertInContainerBefore: (container, child, beforeChild) => {
|
|
1101
|
+
if (!child || !beforeChild) return;
|
|
1102
|
+
insertBefore(container.getState().scene, child, beforeChild);
|
|
1103
|
+
},
|
|
1087
1104
|
getRootHostContext: () => null,
|
|
1088
1105
|
getChildHostContext: parentHostContext => parentHostContext,
|
|
1089
1106
|
|
|
@@ -1093,10 +1110,10 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1093
1110
|
const localState = (_instance$__r3f2 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f2 : {}; // https://github.com/facebook/react/issues/20271
|
|
1094
1111
|
// Returning true will trigger commitMount
|
|
1095
1112
|
|
|
1096
|
-
return
|
|
1113
|
+
return Boolean(localState.handlers);
|
|
1097
1114
|
},
|
|
1098
1115
|
|
|
1099
|
-
prepareUpdate(instance,
|
|
1116
|
+
prepareUpdate(instance, _type, oldProps, newProps) {
|
|
1100
1117
|
// Create diff-sets
|
|
1101
1118
|
if (instance.__r3f.primitive && newProps.object && newProps.object !== instance) {
|
|
1102
1119
|
return [true];
|
|
@@ -1113,7 +1130,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1113
1130
|
...restOld
|
|
1114
1131
|
} = oldProps; // Throw if an object or literal was passed for args
|
|
1115
1132
|
|
|
1116
|
-
if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-
|
|
1133
|
+
if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-instantiated
|
|
1117
1134
|
|
|
1118
1135
|
if (argsNew.some((value, index) => value !== argsOld[index])) return [true]; // Create a diff-set, flag if there are any changes
|
|
1119
1136
|
|
|
@@ -1124,13 +1141,13 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1124
1141
|
}
|
|
1125
1142
|
},
|
|
1126
1143
|
|
|
1127
|
-
commitUpdate(instance, [reconstruct, diff], type,
|
|
1144
|
+
commitUpdate(instance, [reconstruct, diff], type, _oldProps, newProps, fiber) {
|
|
1128
1145
|
// Reconstruct when args or <primitive object={...} have changes
|
|
1129
1146
|
if (reconstruct) switchInstance(instance, type, newProps, fiber); // Otherwise just overwrite props
|
|
1130
1147
|
else applyProps$1(instance, diff);
|
|
1131
1148
|
},
|
|
1132
1149
|
|
|
1133
|
-
commitMount(instance,
|
|
1150
|
+
commitMount(instance, _type, _props, _int) {
|
|
1134
1151
|
var _instance$__r3f3;
|
|
1135
1152
|
|
|
1136
1153
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1143,13 +1160,11 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1143
1160
|
},
|
|
1144
1161
|
|
|
1145
1162
|
getPublicInstance: instance => instance,
|
|
1146
|
-
shouldDeprioritizeSubtree: () => false,
|
|
1147
1163
|
prepareForCommit: () => null,
|
|
1148
1164
|
preparePortalMount: container => prepare(container.getState().scene),
|
|
1149
1165
|
resetAfterCommit: () => {},
|
|
1150
1166
|
shouldSetTextContent: () => false,
|
|
1151
1167
|
clearContainer: () => false,
|
|
1152
|
-
detachDeletedInstance: () => {},
|
|
1153
1168
|
|
|
1154
1169
|
hideInstance(instance) {
|
|
1155
1170
|
var _instance$__r3f4;
|
|
@@ -1177,20 +1192,19 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1177
1192
|
invalidateInstance(instance);
|
|
1178
1193
|
},
|
|
1179
1194
|
|
|
1180
|
-
createTextInstance:
|
|
1181
|
-
hideTextInstance:
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
unhideTextInstance: () => {},
|
|
1185
|
-
getCurrentEventPriority: () => getEventPriority ? getEventPriority() : constants.DefaultEventPriority,
|
|
1186
|
-
// @ts-ignore
|
|
1187
|
-
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : undefined,
|
|
1195
|
+
createTextInstance: handleTextInstance,
|
|
1196
|
+
hideTextInstance: handleTextInstance,
|
|
1197
|
+
unhideTextInstance: handleTextInstance,
|
|
1198
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
|
|
1188
1199
|
// @ts-ignore
|
|
1200
|
+
getCurrentEventPriority: () => _getEventPriority ? _getEventPriority() : constants.DefaultEventPriority,
|
|
1201
|
+
beforeActiveInstanceBlur: () => {},
|
|
1202
|
+
afterActiveInstanceBlur: () => {},
|
|
1203
|
+
detachDeletedInstance: () => {},
|
|
1204
|
+
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : () => 0,
|
|
1205
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r920883503
|
|
1189
1206
|
scheduleTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1190
|
-
|
|
1191
|
-
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
|
|
1192
|
-
setTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1193
|
-
clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1207
|
+
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1194
1208
|
});
|
|
1195
1209
|
return {
|
|
1196
1210
|
reconciler,
|
|
@@ -37,12 +37,19 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
37
37
|
__proto__: null
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
var _window$document, _window$navigator;
|
|
41
|
+
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
42
|
+
/**
|
|
43
|
+
* An SSR-friendly useLayoutEffect.
|
|
44
|
+
*
|
|
45
|
+
* React currently throws a warning when using useLayoutEffect on the server.
|
|
46
|
+
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
47
|
+
* useLayoutEffect elsewhere.
|
|
48
|
+
*
|
|
49
|
+
* @see https://github.com/facebook/react/issues/14927
|
|
50
|
+
*/
|
|
43
51
|
|
|
44
|
-
const
|
|
45
|
-
const useIsomorphicLayoutEffect = isSSR ? React__namespace.useEffect : React__namespace.useLayoutEffect;
|
|
52
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
46
53
|
function useMutableCallback(fn) {
|
|
47
54
|
const ref = React__namespace.useRef(fn);
|
|
48
55
|
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
@@ -855,7 +862,7 @@ let extend = objects => void (catalogue = { ...catalogue,
|
|
|
855
862
|
...objects
|
|
856
863
|
});
|
|
857
864
|
|
|
858
|
-
function createRenderer(
|
|
865
|
+
function createRenderer(_roots, _getEventPriority) {
|
|
859
866
|
function createInstance(type, {
|
|
860
867
|
args = [],
|
|
861
868
|
attach,
|
|
@@ -1063,7 +1070,10 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1063
1070
|
}
|
|
1064
1071
|
}
|
|
1065
1072
|
});
|
|
1066
|
-
}
|
|
1073
|
+
} // Don't handle text instances, warn on undefined behavior
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
const handleTextInstance = () => console.warn('Text is not allowed in the R3F tree! This could be stray whitespace or characters.');
|
|
1067
1077
|
|
|
1068
1078
|
const reconciler = Reconciler__default["default"]({
|
|
1069
1079
|
createInstance,
|
|
@@ -1071,19 +1081,26 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1071
1081
|
appendChild,
|
|
1072
1082
|
appendInitialChild: appendChild,
|
|
1073
1083
|
insertBefore,
|
|
1074
|
-
supportsMicrotask: true,
|
|
1075
|
-
warnsIfNotActing: true,
|
|
1076
1084
|
supportsMutation: true,
|
|
1077
1085
|
isPrimaryRenderer: false,
|
|
1086
|
+
supportsPersistence: false,
|
|
1087
|
+
supportsHydration: false,
|
|
1078
1088
|
noTimeout: -1,
|
|
1079
1089
|
appendChildToContainer: (container, child) => {
|
|
1090
|
+
if (!child) return;
|
|
1080
1091
|
const scene = container.getState().scene; // Link current root to the default scene
|
|
1081
1092
|
|
|
1082
1093
|
scene.__r3f.root = container;
|
|
1083
1094
|
appendChild(scene, child);
|
|
1084
1095
|
},
|
|
1085
|
-
removeChildFromContainer: (container, child) =>
|
|
1086
|
-
|
|
1096
|
+
removeChildFromContainer: (container, child) => {
|
|
1097
|
+
if (!child) return;
|
|
1098
|
+
removeChild(container.getState().scene, child);
|
|
1099
|
+
},
|
|
1100
|
+
insertInContainerBefore: (container, child, beforeChild) => {
|
|
1101
|
+
if (!child || !beforeChild) return;
|
|
1102
|
+
insertBefore(container.getState().scene, child, beforeChild);
|
|
1103
|
+
},
|
|
1087
1104
|
getRootHostContext: () => null,
|
|
1088
1105
|
getChildHostContext: parentHostContext => parentHostContext,
|
|
1089
1106
|
|
|
@@ -1093,10 +1110,10 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1093
1110
|
const localState = (_instance$__r3f2 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f2 : {}; // https://github.com/facebook/react/issues/20271
|
|
1094
1111
|
// Returning true will trigger commitMount
|
|
1095
1112
|
|
|
1096
|
-
return
|
|
1113
|
+
return Boolean(localState.handlers);
|
|
1097
1114
|
},
|
|
1098
1115
|
|
|
1099
|
-
prepareUpdate(instance,
|
|
1116
|
+
prepareUpdate(instance, _type, oldProps, newProps) {
|
|
1100
1117
|
// Create diff-sets
|
|
1101
1118
|
if (instance.__r3f.primitive && newProps.object && newProps.object !== instance) {
|
|
1102
1119
|
return [true];
|
|
@@ -1113,7 +1130,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1113
1130
|
...restOld
|
|
1114
1131
|
} = oldProps; // Throw if an object or literal was passed for args
|
|
1115
1132
|
|
|
1116
|
-
if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-
|
|
1133
|
+
if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-instantiated
|
|
1117
1134
|
|
|
1118
1135
|
if (argsNew.some((value, index) => value !== argsOld[index])) return [true]; // Create a diff-set, flag if there are any changes
|
|
1119
1136
|
|
|
@@ -1124,13 +1141,13 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1124
1141
|
}
|
|
1125
1142
|
},
|
|
1126
1143
|
|
|
1127
|
-
commitUpdate(instance, [reconstruct, diff], type,
|
|
1144
|
+
commitUpdate(instance, [reconstruct, diff], type, _oldProps, newProps, fiber) {
|
|
1128
1145
|
// Reconstruct when args or <primitive object={...} have changes
|
|
1129
1146
|
if (reconstruct) switchInstance(instance, type, newProps, fiber); // Otherwise just overwrite props
|
|
1130
1147
|
else applyProps$1(instance, diff);
|
|
1131
1148
|
},
|
|
1132
1149
|
|
|
1133
|
-
commitMount(instance,
|
|
1150
|
+
commitMount(instance, _type, _props, _int) {
|
|
1134
1151
|
var _instance$__r3f3;
|
|
1135
1152
|
|
|
1136
1153
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1143,13 +1160,11 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1143
1160
|
},
|
|
1144
1161
|
|
|
1145
1162
|
getPublicInstance: instance => instance,
|
|
1146
|
-
shouldDeprioritizeSubtree: () => false,
|
|
1147
1163
|
prepareForCommit: () => null,
|
|
1148
1164
|
preparePortalMount: container => prepare(container.getState().scene),
|
|
1149
1165
|
resetAfterCommit: () => {},
|
|
1150
1166
|
shouldSetTextContent: () => false,
|
|
1151
1167
|
clearContainer: () => false,
|
|
1152
|
-
detachDeletedInstance: () => {},
|
|
1153
1168
|
|
|
1154
1169
|
hideInstance(instance) {
|
|
1155
1170
|
var _instance$__r3f4;
|
|
@@ -1177,20 +1192,19 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1177
1192
|
invalidateInstance(instance);
|
|
1178
1193
|
},
|
|
1179
1194
|
|
|
1180
|
-
createTextInstance:
|
|
1181
|
-
hideTextInstance:
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
unhideTextInstance: () => {},
|
|
1185
|
-
getCurrentEventPriority: () => getEventPriority ? getEventPriority() : constants.DefaultEventPriority,
|
|
1186
|
-
// @ts-ignore
|
|
1187
|
-
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : undefined,
|
|
1195
|
+
createTextInstance: handleTextInstance,
|
|
1196
|
+
hideTextInstance: handleTextInstance,
|
|
1197
|
+
unhideTextInstance: handleTextInstance,
|
|
1198
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
|
|
1188
1199
|
// @ts-ignore
|
|
1200
|
+
getCurrentEventPriority: () => _getEventPriority ? _getEventPriority() : constants.DefaultEventPriority,
|
|
1201
|
+
beforeActiveInstanceBlur: () => {},
|
|
1202
|
+
afterActiveInstanceBlur: () => {},
|
|
1203
|
+
detachDeletedInstance: () => {},
|
|
1204
|
+
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : () => 0,
|
|
1205
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r920883503
|
|
1189
1206
|
scheduleTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1190
|
-
|
|
1191
|
-
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
|
|
1192
|
-
setTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1193
|
-
clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1207
|
+
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1194
1208
|
});
|
|
1195
1209
|
return {
|
|
1196
1210
|
reconciler,
|
|
@@ -10,12 +10,19 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
10
10
|
__proto__: null
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
var _window$document, _window$navigator;
|
|
14
|
+
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
15
|
+
/**
|
|
16
|
+
* An SSR-friendly useLayoutEffect.
|
|
17
|
+
*
|
|
18
|
+
* React currently throws a warning when using useLayoutEffect on the server.
|
|
19
|
+
* To get around it, we can conditionally useEffect on the server (no-op) and
|
|
20
|
+
* useLayoutEffect elsewhere.
|
|
21
|
+
*
|
|
22
|
+
* @see https://github.com/facebook/react/issues/14927
|
|
23
|
+
*/
|
|
16
24
|
|
|
17
|
-
const
|
|
18
|
-
const useIsomorphicLayoutEffect = isSSR ? React.useEffect : React.useLayoutEffect;
|
|
25
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' && ((_window$document = window.document) != null && _window$document.createElement || ((_window$navigator = window.navigator) == null ? void 0 : _window$navigator.product) === 'ReactNative') ? React.useLayoutEffect : React.useEffect;
|
|
19
26
|
function useMutableCallback(fn) {
|
|
20
27
|
const ref = React.useRef(fn);
|
|
21
28
|
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
@@ -828,7 +835,7 @@ let extend = objects => void (catalogue = { ...catalogue,
|
|
|
828
835
|
...objects
|
|
829
836
|
});
|
|
830
837
|
|
|
831
|
-
function createRenderer(
|
|
838
|
+
function createRenderer(_roots, _getEventPriority) {
|
|
832
839
|
function createInstance(type, {
|
|
833
840
|
args = [],
|
|
834
841
|
attach,
|
|
@@ -1036,7 +1043,10 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1036
1043
|
}
|
|
1037
1044
|
}
|
|
1038
1045
|
});
|
|
1039
|
-
}
|
|
1046
|
+
} // Don't handle text instances, warn on undefined behavior
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
const handleTextInstance = () => console.warn('Text is not allowed in the R3F tree! This could be stray whitespace or characters.');
|
|
1040
1050
|
|
|
1041
1051
|
const reconciler = Reconciler({
|
|
1042
1052
|
createInstance,
|
|
@@ -1044,19 +1054,26 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1044
1054
|
appendChild,
|
|
1045
1055
|
appendInitialChild: appendChild,
|
|
1046
1056
|
insertBefore,
|
|
1047
|
-
supportsMicrotask: true,
|
|
1048
|
-
warnsIfNotActing: true,
|
|
1049
1057
|
supportsMutation: true,
|
|
1050
1058
|
isPrimaryRenderer: false,
|
|
1059
|
+
supportsPersistence: false,
|
|
1060
|
+
supportsHydration: false,
|
|
1051
1061
|
noTimeout: -1,
|
|
1052
1062
|
appendChildToContainer: (container, child) => {
|
|
1063
|
+
if (!child) return;
|
|
1053
1064
|
const scene = container.getState().scene; // Link current root to the default scene
|
|
1054
1065
|
|
|
1055
1066
|
scene.__r3f.root = container;
|
|
1056
1067
|
appendChild(scene, child);
|
|
1057
1068
|
},
|
|
1058
|
-
removeChildFromContainer: (container, child) =>
|
|
1059
|
-
|
|
1069
|
+
removeChildFromContainer: (container, child) => {
|
|
1070
|
+
if (!child) return;
|
|
1071
|
+
removeChild(container.getState().scene, child);
|
|
1072
|
+
},
|
|
1073
|
+
insertInContainerBefore: (container, child, beforeChild) => {
|
|
1074
|
+
if (!child || !beforeChild) return;
|
|
1075
|
+
insertBefore(container.getState().scene, child, beforeChild);
|
|
1076
|
+
},
|
|
1060
1077
|
getRootHostContext: () => null,
|
|
1061
1078
|
getChildHostContext: parentHostContext => parentHostContext,
|
|
1062
1079
|
|
|
@@ -1066,10 +1083,10 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1066
1083
|
const localState = (_instance$__r3f2 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f2 : {}; // https://github.com/facebook/react/issues/20271
|
|
1067
1084
|
// Returning true will trigger commitMount
|
|
1068
1085
|
|
|
1069
|
-
return
|
|
1086
|
+
return Boolean(localState.handlers);
|
|
1070
1087
|
},
|
|
1071
1088
|
|
|
1072
|
-
prepareUpdate(instance,
|
|
1089
|
+
prepareUpdate(instance, _type, oldProps, newProps) {
|
|
1073
1090
|
// Create diff-sets
|
|
1074
1091
|
if (instance.__r3f.primitive && newProps.object && newProps.object !== instance) {
|
|
1075
1092
|
return [true];
|
|
@@ -1086,7 +1103,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1086
1103
|
...restOld
|
|
1087
1104
|
} = oldProps; // Throw if an object or literal was passed for args
|
|
1088
1105
|
|
|
1089
|
-
if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-
|
|
1106
|
+
if (!Array.isArray(argsNew)) throw 'The args prop must be an array!'; // If it has new props or arguments, then it needs to be re-instantiated
|
|
1090
1107
|
|
|
1091
1108
|
if (argsNew.some((value, index) => value !== argsOld[index])) return [true]; // Create a diff-set, flag if there are any changes
|
|
1092
1109
|
|
|
@@ -1097,13 +1114,13 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1097
1114
|
}
|
|
1098
1115
|
},
|
|
1099
1116
|
|
|
1100
|
-
commitUpdate(instance, [reconstruct, diff], type,
|
|
1117
|
+
commitUpdate(instance, [reconstruct, diff], type, _oldProps, newProps, fiber) {
|
|
1101
1118
|
// Reconstruct when args or <primitive object={...} have changes
|
|
1102
1119
|
if (reconstruct) switchInstance(instance, type, newProps, fiber); // Otherwise just overwrite props
|
|
1103
1120
|
else applyProps$1(instance, diff);
|
|
1104
1121
|
},
|
|
1105
1122
|
|
|
1106
|
-
commitMount(instance,
|
|
1123
|
+
commitMount(instance, _type, _props, _int) {
|
|
1107
1124
|
var _instance$__r3f3;
|
|
1108
1125
|
|
|
1109
1126
|
// https://github.com/facebook/react/issues/20271
|
|
@@ -1116,13 +1133,11 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1116
1133
|
},
|
|
1117
1134
|
|
|
1118
1135
|
getPublicInstance: instance => instance,
|
|
1119
|
-
shouldDeprioritizeSubtree: () => false,
|
|
1120
1136
|
prepareForCommit: () => null,
|
|
1121
1137
|
preparePortalMount: container => prepare(container.getState().scene),
|
|
1122
1138
|
resetAfterCommit: () => {},
|
|
1123
1139
|
shouldSetTextContent: () => false,
|
|
1124
1140
|
clearContainer: () => false,
|
|
1125
|
-
detachDeletedInstance: () => {},
|
|
1126
1141
|
|
|
1127
1142
|
hideInstance(instance) {
|
|
1128
1143
|
var _instance$__r3f4;
|
|
@@ -1150,20 +1165,19 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1150
1165
|
invalidateInstance(instance);
|
|
1151
1166
|
},
|
|
1152
1167
|
|
|
1153
|
-
createTextInstance:
|
|
1154
|
-
hideTextInstance:
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
unhideTextInstance: () => {},
|
|
1158
|
-
getCurrentEventPriority: () => getEventPriority ? getEventPriority() : DefaultEventPriority,
|
|
1159
|
-
// @ts-ignore
|
|
1160
|
-
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : undefined,
|
|
1168
|
+
createTextInstance: handleTextInstance,
|
|
1169
|
+
hideTextInstance: handleTextInstance,
|
|
1170
|
+
unhideTextInstance: handleTextInstance,
|
|
1171
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r916356874
|
|
1161
1172
|
// @ts-ignore
|
|
1173
|
+
getCurrentEventPriority: () => _getEventPriority ? _getEventPriority() : DefaultEventPriority,
|
|
1174
|
+
beforeActiveInstanceBlur: () => {},
|
|
1175
|
+
afterActiveInstanceBlur: () => {},
|
|
1176
|
+
detachDeletedInstance: () => {},
|
|
1177
|
+
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : () => 0,
|
|
1178
|
+
// https://github.com/pmndrs/react-three-fiber/pull/2360#discussion_r920883503
|
|
1162
1179
|
scheduleTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1163
|
-
|
|
1164
|
-
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
|
|
1165
|
-
setTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1166
|
-
clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1180
|
+
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1167
1181
|
});
|
|
1168
1182
|
return {
|
|
1169
1183
|
reconciler,
|
|
@@ -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-2a5b06d3.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-876a6569.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-
|
|
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-af244448.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-af244448.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-2a5b06d3.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-876a6569.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-af244448.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-af244448.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';
|