@react-three/fiber 8.0.0-beta.1 → 8.0.0-beta.4
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/dist/declarations/src/core/hooks.d.ts +1 -1
- package/dist/declarations/src/core/renderer.d.ts +10 -0
- package/dist/declarations/src/core/store.d.ts +1 -1
- package/dist/declarations/src/three-types.d.ts +23 -0
- package/dist/{index-05ebefd3.cjs.dev.js → index-2b21ab4b.cjs.dev.js} +116 -58
- package/dist/{index-e78dd2f0.esm.js → index-3d7af2b7.esm.js} +116 -58
- package/dist/{index-85b2df17.cjs.prod.js → index-a9d2810c.cjs.prod.js} +116 -58
- 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 +9 -8
|
@@ -10,7 +10,7 @@ export declare type Extensions = (loader: THREE.Loader) => void;
|
|
|
10
10
|
export declare type LoaderResult<T> = T extends any[] ? Loader<T[number]> : Loader<T>;
|
|
11
11
|
export declare type ConditionalType<Child, Parent, Truthy, Falsy> = Child extends Parent ? Truthy : Falsy;
|
|
12
12
|
export declare type BranchingReturn<T, Parent, Coerced> = ConditionalType<T, Parent, Coerced, T>;
|
|
13
|
-
export declare function useStore(): import("zustand").UseStore<RootState
|
|
13
|
+
export declare function useStore(): import("zustand").UseStore<RootState, import("zustand").StoreApi<RootState>>;
|
|
14
14
|
export declare function useThree<T = RootState>(selector?: StateSelector<RootState, T>, equalityFn?: EqualityChecker<T>): T;
|
|
15
15
|
export declare function useFrame(callback: RenderCallback, renderPriority?: number): null;
|
|
16
16
|
export declare function useGraph(object: THREE.Object3D): ObjectMap;
|
|
@@ -8,8 +8,18 @@ export declare type Root = {
|
|
|
8
8
|
fiber: Reconciler.FiberRoot;
|
|
9
9
|
store: UseStore<RootState>;
|
|
10
10
|
};
|
|
11
|
+
export declare type HostContext = React.MutableRefObject<{
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
} | null>;
|
|
11
14
|
export declare type LocalState = {
|
|
15
|
+
type: string;
|
|
12
16
|
root: UseStore<RootState>;
|
|
17
|
+
context: React.MutableRefObject<{
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
} | null>;
|
|
20
|
+
getContext: () => {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
13
23
|
objects: Instance[];
|
|
14
24
|
parent: Instance | null;
|
|
15
25
|
primitive?: boolean;
|
|
@@ -110,6 +110,6 @@ export declare type StoreProps = {
|
|
|
110
110
|
};
|
|
111
111
|
onPointerMissed?: (event: MouseEvent) => void;
|
|
112
112
|
};
|
|
113
|
-
declare const context: React.Context<UseStore<RootState
|
|
113
|
+
declare const context: React.Context<UseStore<RootState, import("zustand").StoreApi<RootState>>>;
|
|
114
114
|
declare const createStore: (invalidate: (state?: RootState | undefined) => void, advance: (timestamp: number, runGlobalEffects?: boolean | undefined, state?: RootState | undefined, frame?: THREE.XRFrame | undefined) => void) => UseStore<RootState>;
|
|
115
115
|
export { createStore, context };
|
|
@@ -41,6 +41,7 @@ export declare type Object3DNode<T, P> = Overwrite<Node<T, P>, {
|
|
|
41
41
|
export declare type BufferGeometryNode<T extends THREE.BufferGeometry, P> = Node<T, P>;
|
|
42
42
|
export declare type MaterialNode<T extends THREE.Material, P> = Node<T, P>;
|
|
43
43
|
export declare type LightNode<T extends THREE.Light, P> = Object3DNode<T, P>;
|
|
44
|
+
export declare type Object3DProps = Object3DNode<THREE.Object3D, typeof THREE.Object3D>;
|
|
44
45
|
export declare type AudioListenerProps = Object3DNode<THREE.AudioListener, typeof THREE.AudioListener>;
|
|
45
46
|
export declare type PositionalAudioProps = Object3DNode<THREE.PositionalAudio, typeof THREE.PositionalAudio>;
|
|
46
47
|
export declare type MeshProps = Object3DNode<THREE.Mesh, typeof THREE.Mesh>;
|
|
@@ -166,7 +167,15 @@ export declare type Matrix3Props = Node<THREE.Matrix3, typeof THREE.Matrix3>;
|
|
|
166
167
|
export declare type Matrix4Props = Node<THREE.Matrix4, typeof THREE.Matrix4>;
|
|
167
168
|
export declare type QuaternionProps = Node<THREE.Quaternion, typeof THREE.Quaternion>;
|
|
168
169
|
export declare type BufferAttributeProps = Node<THREE.BufferAttribute, typeof THREE.BufferAttribute>;
|
|
170
|
+
export declare type Float16BufferAttributeProps = Node<THREE.Float16BufferAttribute, typeof THREE.Float16BufferAttribute>;
|
|
169
171
|
export declare type Float32BufferAttributeProps = Node<THREE.Float32BufferAttribute, typeof THREE.Float32BufferAttribute>;
|
|
172
|
+
export declare type Float64BufferAttributeProps = Node<THREE.Float64BufferAttribute, typeof THREE.Float64BufferAttribute>;
|
|
173
|
+
export declare type Int8BufferAttributeProps = Node<THREE.Int8BufferAttribute, typeof THREE.Int8BufferAttribute>;
|
|
174
|
+
export declare type Int16BufferAttributeProps = Node<THREE.Int16BufferAttribute, typeof THREE.Int16BufferAttribute>;
|
|
175
|
+
export declare type Int32BufferAttributeProps = Node<THREE.Int32BufferAttribute, typeof THREE.Int32BufferAttribute>;
|
|
176
|
+
export declare type Uint8BufferAttributeProps = Node<THREE.Uint8BufferAttribute, typeof THREE.Uint8BufferAttribute>;
|
|
177
|
+
export declare type Uint16BufferAttributeProps = Node<THREE.Uint16BufferAttribute, typeof THREE.Uint16BufferAttribute>;
|
|
178
|
+
export declare type Uint32BufferAttributeProps = Node<THREE.Uint32BufferAttribute, typeof THREE.Uint32BufferAttribute>;
|
|
170
179
|
export declare type InstancedBufferAttributeProps = Node<THREE.InstancedBufferAttribute, typeof THREE.InstancedBufferAttribute>;
|
|
171
180
|
export declare type ColorProps = Node<THREE.Color, ColorArray>;
|
|
172
181
|
export declare type FogProps = Node<THREE.Fog, typeof THREE.Fog>;
|
|
@@ -175,6 +184,7 @@ export declare type ShapeProps = Node<THREE.Shape, typeof THREE.Shape>;
|
|
|
175
184
|
declare global {
|
|
176
185
|
namespace JSX {
|
|
177
186
|
interface IntrinsicElements {
|
|
187
|
+
object3D: Object3DProps;
|
|
178
188
|
audioListener: AudioListenerProps;
|
|
179
189
|
positionalAudio: PositionalAudioProps;
|
|
180
190
|
mesh: MeshProps;
|
|
@@ -296,12 +306,25 @@ declare global {
|
|
|
296
306
|
matrix4: Matrix4Props;
|
|
297
307
|
quaternion: QuaternionProps;
|
|
298
308
|
bufferAttribute: BufferAttributeProps;
|
|
309
|
+
float16BufferAttribute: Float16BufferAttributeProps;
|
|
299
310
|
float32BufferAttribute: Float32BufferAttributeProps;
|
|
311
|
+
float64BufferAttribute: Float64BufferAttributeProps;
|
|
312
|
+
int8BufferAttribute: Int8BufferAttributeProps;
|
|
313
|
+
int16BufferAttribute: Int16BufferAttributeProps;
|
|
314
|
+
int32BufferAttribute: Int32BufferAttributeProps;
|
|
315
|
+
uint8BufferAttribute: Uint8BufferAttributeProps;
|
|
316
|
+
uint16BufferAttribute: Uint16BufferAttributeProps;
|
|
317
|
+
uint32BufferAttribute: Uint32BufferAttributeProps;
|
|
300
318
|
instancedBufferAttribute: InstancedBufferAttributeProps;
|
|
301
319
|
color: ColorProps;
|
|
302
320
|
fog: FogProps;
|
|
303
321
|
fogExp2: FogExp2Props;
|
|
304
322
|
shape: ShapeProps;
|
|
323
|
+
inject: {
|
|
324
|
+
children: React.ReactNode;
|
|
325
|
+
} & {
|
|
326
|
+
[key: string]: any;
|
|
327
|
+
};
|
|
305
328
|
}
|
|
306
329
|
}
|
|
307
330
|
}
|
|
@@ -138,6 +138,30 @@ function prepare(object, state) {
|
|
|
138
138
|
|
|
139
139
|
if (state != null && state.primitive || !instance.__r3f) {
|
|
140
140
|
instance.__r3f = {
|
|
141
|
+
type: '',
|
|
142
|
+
context: {
|
|
143
|
+
current: null
|
|
144
|
+
},
|
|
145
|
+
getContext: () => {
|
|
146
|
+
const injects = [];
|
|
147
|
+
let inject = instance.__r3f.context.current;
|
|
148
|
+
|
|
149
|
+
while (inject) {
|
|
150
|
+
var _inject$memoizedProps, _inject, _inject$context;
|
|
151
|
+
|
|
152
|
+
const {
|
|
153
|
+
children,
|
|
154
|
+
args,
|
|
155
|
+
...props
|
|
156
|
+
} = (_inject$memoizedProps = (_inject = inject) == null ? void 0 : _inject.memoizedProps) != null ? _inject$memoizedProps : {};
|
|
157
|
+
injects.push(props);
|
|
158
|
+
inject = (_inject$context = inject.context) == null ? void 0 : _inject$context.current;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return injects.reverse().reduce((prev, cur) => ({ ...prev,
|
|
162
|
+
...cur
|
|
163
|
+
}), {});
|
|
164
|
+
},
|
|
141
165
|
root: null,
|
|
142
166
|
memoizedProps: {},
|
|
143
167
|
eventCount: 0,
|
|
@@ -279,11 +303,11 @@ function applyProps$1(instance, data) {
|
|
|
279
303
|
if (value === DEFAULT + 'remove') {
|
|
280
304
|
if (targetProp && targetProp.constructor) {
|
|
281
305
|
// use the prop constructor to find the default it should be
|
|
282
|
-
value = new targetProp.constructor(memoized.args);
|
|
306
|
+
value = new targetProp.constructor(...memoized.args);
|
|
283
307
|
} else if (currentInstance.constructor) {
|
|
284
308
|
// create a blank slate of the instance and copy the particular parameter.
|
|
285
309
|
// @ts-ignore
|
|
286
|
-
const defaultClassCall = new currentInstance.constructor(currentInstance.__r3f.memoizedProps.args);
|
|
310
|
+
const defaultClassCall = new currentInstance.constructor(...currentInstance.__r3f.memoizedProps.args);
|
|
287
311
|
value = defaultClassCall[targetProp]; // destory the instance
|
|
288
312
|
|
|
289
313
|
if (defaultClassCall.dispose) defaultClassCall.dispose(); // instance does not have constructor, just set it to 0
|
|
@@ -798,12 +822,16 @@ let extend = objects => void (catalogue = { ...catalogue,
|
|
|
798
822
|
...objects
|
|
799
823
|
});
|
|
800
824
|
|
|
825
|
+
extend({
|
|
826
|
+
Inject: THREE__namespace.Group
|
|
827
|
+
});
|
|
828
|
+
|
|
801
829
|
function createRenderer(roots, getEventPriority) {
|
|
802
830
|
function createInstance(type, {
|
|
803
831
|
args = [],
|
|
804
832
|
attach,
|
|
805
833
|
...props
|
|
806
|
-
}, root,
|
|
834
|
+
}, root, context, internalInstanceHandle) {
|
|
807
835
|
let name = `${type[0].toUpperCase()}${type.slice(1)}`;
|
|
808
836
|
let instance; // https://github.com/facebook/react/issues/17147
|
|
809
837
|
// Portals do not give us a root, they are themselves treated as a root by the reconciler
|
|
@@ -828,7 +856,9 @@ function createRenderer(roots, getEventPriority) {
|
|
|
828
856
|
if (props.object === undefined) throw `Primitives without 'object' are invalid!`;
|
|
829
857
|
const object = props.object;
|
|
830
858
|
instance = prepare(object, {
|
|
859
|
+
type,
|
|
831
860
|
root,
|
|
861
|
+
context,
|
|
832
862
|
attach,
|
|
833
863
|
primitive: true
|
|
834
864
|
});
|
|
@@ -844,23 +874,35 @@ function createRenderer(roots, getEventPriority) {
|
|
|
844
874
|
// Append memoized props with args so it's not forgotten
|
|
845
875
|
|
|
846
876
|
instance = prepare(new target(...args), {
|
|
877
|
+
type,
|
|
847
878
|
root,
|
|
879
|
+
context,
|
|
848
880
|
attach,
|
|
849
881
|
// TODO: Figure out what this is for
|
|
850
882
|
memoizedProps: {
|
|
851
|
-
args
|
|
883
|
+
args
|
|
852
884
|
}
|
|
853
885
|
});
|
|
854
886
|
} // It should NOT call onUpdate on object instanciation, because it hasn't been added to the
|
|
855
887
|
// view yet. If the callback relies on references for instance, they won't be ready yet, this is
|
|
856
888
|
// why it passes "true" here
|
|
889
|
+
// There is no reason to apply props to injects
|
|
857
890
|
|
|
858
891
|
|
|
859
|
-
applyProps$1(instance, props);
|
|
892
|
+
if (name !== 'inject') applyProps$1(instance, props);
|
|
860
893
|
return instance;
|
|
861
894
|
}
|
|
862
895
|
|
|
863
896
|
function appendChild(parentInstance, child) {
|
|
897
|
+
// https://github.com/facebook/react/issues/24138
|
|
898
|
+
// Injects are special purpose "onion layers" that inject contextual information into the scene graph.
|
|
899
|
+
// Since react-reconciler does not allow us to access the current host context we trick it by leading
|
|
900
|
+
// back to it from the first child that is added to it. We just connect the inject to it's own host context.
|
|
901
|
+
if ((parentInstance == null ? void 0 : parentInstance.__r3f.type) === 'inject') {
|
|
902
|
+
const context = child == null ? void 0 : child.__r3f.context;
|
|
903
|
+
if (context) context.current = parentInstance.__r3f;
|
|
904
|
+
}
|
|
905
|
+
|
|
864
906
|
let added = false;
|
|
865
907
|
|
|
866
908
|
if (child) {
|
|
@@ -956,6 +998,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
956
998
|
|
|
957
999
|
if (child.__r3f) {
|
|
958
1000
|
delete child.__r3f.root;
|
|
1001
|
+
delete child.__r3f.context;
|
|
959
1002
|
delete child.__r3f.objects;
|
|
960
1003
|
delete child.__r3f.handlers;
|
|
961
1004
|
delete child.__r3f.memoizedProps;
|
|
@@ -1015,6 +1058,16 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1015
1058
|
}
|
|
1016
1059
|
|
|
1017
1060
|
const reconciler = Reconciler__default['default']({
|
|
1061
|
+
createInstance,
|
|
1062
|
+
removeChild,
|
|
1063
|
+
appendChild,
|
|
1064
|
+
appendInitialChild: appendChild,
|
|
1065
|
+
insertBefore,
|
|
1066
|
+
supportsMicrotask: true,
|
|
1067
|
+
warnsIfNotActing: true,
|
|
1068
|
+
supportsMutation: true,
|
|
1069
|
+
isPrimaryRenderer: false,
|
|
1070
|
+
noTimeout: -1,
|
|
1018
1071
|
appendChildToContainer: (parentInstance, child) => {
|
|
1019
1072
|
const {
|
|
1020
1073
|
container,
|
|
@@ -1026,8 +1079,35 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1026
1079
|
},
|
|
1027
1080
|
removeChildFromContainer: (parentInstance, child) => removeChild(getContainer(parentInstance, child).container, child),
|
|
1028
1081
|
insertInContainerBefore: (parentInstance, child, beforeChild) => insertBefore(getContainer(parentInstance, child).container, child, beforeChild),
|
|
1082
|
+
getRootHostContext: () => ({
|
|
1083
|
+
current: null
|
|
1084
|
+
}),
|
|
1085
|
+
getChildHostContext: (parentHostContext, type) => {
|
|
1086
|
+
// This is a little misleading, this function does not determine the host context for the element at hand,
|
|
1087
|
+
// but rather for all the children of it. The context for an inject is and will be the scene, everything
|
|
1088
|
+
// within an inject is contextual to it.
|
|
1089
|
+
if (type === 'inject') return {
|
|
1090
|
+
current: null
|
|
1091
|
+
};
|
|
1092
|
+
return parentHostContext;
|
|
1093
|
+
},
|
|
1094
|
+
|
|
1095
|
+
finalizeInitialChildren(instance) {
|
|
1096
|
+
var _instance$__r3f2;
|
|
1097
|
+
|
|
1098
|
+
const localState = (_instance$__r3f2 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f2 : {}; // https://github.com/facebook/react/issues/20271
|
|
1099
|
+
// Returning true will trigger commitMount
|
|
1100
|
+
|
|
1101
|
+
return !!localState.handlers;
|
|
1102
|
+
},
|
|
1029
1103
|
|
|
1030
1104
|
prepareUpdate(instance, type, oldProps, newProps) {
|
|
1105
|
+
// Injects are special purpose "onion layers" that inject contextual information into the scene graph
|
|
1106
|
+
// Because the context of an inject is still the scene we have to rely on children to give us the inject-context
|
|
1107
|
+
// so that we can set up props.
|
|
1108
|
+
if (type === 'inject' && instance.children.length) ; // Create diff-sets
|
|
1109
|
+
|
|
1110
|
+
|
|
1031
1111
|
if (instance.__r3f.primitive && newProps.object && newProps.object !== instance) {
|
|
1032
1112
|
return [true];
|
|
1033
1113
|
} else {
|
|
@@ -1060,40 +1140,58 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1060
1140
|
else applyProps$1(instance, diff);
|
|
1061
1141
|
},
|
|
1062
1142
|
|
|
1143
|
+
commitMount(instance, type, props, int) {
|
|
1144
|
+
var _instance$__r3f3;
|
|
1145
|
+
|
|
1146
|
+
// https://github.com/facebook/react/issues/20271
|
|
1147
|
+
// This will make sure events are only added once to the central container
|
|
1148
|
+
const localState = (_instance$__r3f3 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f3 : {};
|
|
1149
|
+
|
|
1150
|
+
if (instance.raycast && localState.handlers && localState.eventCount) {
|
|
1151
|
+
instance.__r3f.root.getState().internal.interaction.push(instance);
|
|
1152
|
+
}
|
|
1153
|
+
},
|
|
1154
|
+
|
|
1155
|
+
getPublicInstance: instance => instance,
|
|
1156
|
+
shouldDeprioritizeSubtree: () => false,
|
|
1157
|
+
prepareForCommit: () => null,
|
|
1158
|
+
preparePortalMount: containerInfo => prepare(containerInfo),
|
|
1159
|
+
resetAfterCommit: () => {},
|
|
1160
|
+
shouldSetTextContent: () => false,
|
|
1161
|
+
clearContainer: () => false,
|
|
1162
|
+
detachDeletedInstance: () => {},
|
|
1163
|
+
createTextInstance: () => {},
|
|
1164
|
+
|
|
1063
1165
|
hideInstance(instance) {
|
|
1064
|
-
var _instance$
|
|
1166
|
+
var _instance$__r3f4;
|
|
1065
1167
|
|
|
1066
1168
|
// Deatch while the instance is hidden
|
|
1067
1169
|
const {
|
|
1068
1170
|
attach: type,
|
|
1069
1171
|
parent
|
|
1070
|
-
} = (_instance$
|
|
1172
|
+
} = (_instance$__r3f4 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f4 : {};
|
|
1071
1173
|
if (type && parent) detach(parent, instance, type);
|
|
1072
1174
|
if (instance.isObject3D) instance.visible = false;
|
|
1073
1175
|
invalidateInstance(instance);
|
|
1074
1176
|
},
|
|
1075
1177
|
|
|
1076
1178
|
unhideInstance(instance, props) {
|
|
1077
|
-
var _instance$
|
|
1179
|
+
var _instance$__r3f5;
|
|
1078
1180
|
|
|
1079
1181
|
// Re-attach when the instance is unhidden
|
|
1080
1182
|
const {
|
|
1081
1183
|
attach: type,
|
|
1082
1184
|
parent
|
|
1083
|
-
} = (_instance$
|
|
1185
|
+
} = (_instance$__r3f5 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f5 : {};
|
|
1084
1186
|
if (type && parent) attach(parent, instance, type);
|
|
1085
1187
|
if (instance.isObject3D && props.visible == null || props.visible) instance.visible = true;
|
|
1086
1188
|
invalidateInstance(instance);
|
|
1087
1189
|
},
|
|
1088
1190
|
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
insertBefore,
|
|
1094
|
-
warnsIfNotActing: true,
|
|
1095
|
-
supportsMutation: true,
|
|
1096
|
-
isPrimaryRenderer: false,
|
|
1191
|
+
hideTextInstance: () => {
|
|
1192
|
+
throw new Error('Text is not allowed in the R3F tree.');
|
|
1193
|
+
},
|
|
1194
|
+
// prettier-ignore
|
|
1097
1195
|
getCurrentEventPriority: () => getEventPriority ? getEventPriority() : constants.DefaultEventPriority,
|
|
1098
1196
|
// @ts-ignore
|
|
1099
1197
|
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : undefined,
|
|
@@ -1102,47 +1200,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1102
1200
|
// @ts-ignore
|
|
1103
1201
|
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
|
|
1104
1202
|
setTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1105
|
-
clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1106
|
-
noTimeout: -1,
|
|
1107
|
-
hideTextInstance: () => {
|
|
1108
|
-
throw new Error('Text is not allowed in the R3F tree.');
|
|
1109
|
-
},
|
|
1110
|
-
// prettier-ignore
|
|
1111
|
-
getPublicInstance: instance => instance,
|
|
1112
|
-
getRootHostContext: () => null,
|
|
1113
|
-
getChildHostContext: parentHostContext => parentHostContext,
|
|
1114
|
-
createTextInstance: () => {},
|
|
1115
|
-
|
|
1116
|
-
finalizeInitialChildren(instance) {
|
|
1117
|
-
var _instance$__r3f4;
|
|
1118
|
-
|
|
1119
|
-
// https://github.com/facebook/react/issues/20271
|
|
1120
|
-
// Returning true will trigger commitMount
|
|
1121
|
-
const localState = (_instance$__r3f4 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f4 : {};
|
|
1122
|
-
return !!localState.handlers;
|
|
1123
|
-
},
|
|
1124
|
-
|
|
1125
|
-
commitMount(instance)
|
|
1126
|
-
/*, type, props*/
|
|
1127
|
-
{
|
|
1128
|
-
var _instance$__r3f5;
|
|
1129
|
-
|
|
1130
|
-
// https://github.com/facebook/react/issues/20271
|
|
1131
|
-
// This will make sure events are only added once to the central container
|
|
1132
|
-
const localState = (_instance$__r3f5 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f5 : {};
|
|
1133
|
-
|
|
1134
|
-
if (instance.raycast && localState.handlers && localState.eventCount) {
|
|
1135
|
-
instance.__r3f.root.getState().internal.interaction.push(instance);
|
|
1136
|
-
}
|
|
1137
|
-
},
|
|
1138
|
-
|
|
1139
|
-
shouldDeprioritizeSubtree: () => false,
|
|
1140
|
-
prepareForCommit: () => null,
|
|
1141
|
-
preparePortalMount: containerInfo => prepare(containerInfo),
|
|
1142
|
-
resetAfterCommit: () => {},
|
|
1143
|
-
shouldSetTextContent: () => false,
|
|
1144
|
-
clearContainer: () => false,
|
|
1145
|
-
detachDeletedInstance: () => {}
|
|
1203
|
+
clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1146
1204
|
});
|
|
1147
1205
|
return {
|
|
1148
1206
|
reconciler,
|
|
@@ -109,6 +109,30 @@ function prepare(object, state) {
|
|
|
109
109
|
|
|
110
110
|
if (state != null && state.primitive || !instance.__r3f) {
|
|
111
111
|
instance.__r3f = {
|
|
112
|
+
type: '',
|
|
113
|
+
context: {
|
|
114
|
+
current: null
|
|
115
|
+
},
|
|
116
|
+
getContext: () => {
|
|
117
|
+
const injects = [];
|
|
118
|
+
let inject = instance.__r3f.context.current;
|
|
119
|
+
|
|
120
|
+
while (inject) {
|
|
121
|
+
var _inject$memoizedProps, _inject, _inject$context;
|
|
122
|
+
|
|
123
|
+
const {
|
|
124
|
+
children,
|
|
125
|
+
args,
|
|
126
|
+
...props
|
|
127
|
+
} = (_inject$memoizedProps = (_inject = inject) == null ? void 0 : _inject.memoizedProps) != null ? _inject$memoizedProps : {};
|
|
128
|
+
injects.push(props);
|
|
129
|
+
inject = (_inject$context = inject.context) == null ? void 0 : _inject$context.current;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return injects.reverse().reduce((prev, cur) => ({ ...prev,
|
|
133
|
+
...cur
|
|
134
|
+
}), {});
|
|
135
|
+
},
|
|
112
136
|
root: null,
|
|
113
137
|
memoizedProps: {},
|
|
114
138
|
eventCount: 0,
|
|
@@ -250,11 +274,11 @@ function applyProps$1(instance, data) {
|
|
|
250
274
|
if (value === DEFAULT + 'remove') {
|
|
251
275
|
if (targetProp && targetProp.constructor) {
|
|
252
276
|
// use the prop constructor to find the default it should be
|
|
253
|
-
value = new targetProp.constructor(memoized.args);
|
|
277
|
+
value = new targetProp.constructor(...memoized.args);
|
|
254
278
|
} else if (currentInstance.constructor) {
|
|
255
279
|
// create a blank slate of the instance and copy the particular parameter.
|
|
256
280
|
// @ts-ignore
|
|
257
|
-
const defaultClassCall = new currentInstance.constructor(currentInstance.__r3f.memoizedProps.args);
|
|
281
|
+
const defaultClassCall = new currentInstance.constructor(...currentInstance.__r3f.memoizedProps.args);
|
|
258
282
|
value = defaultClassCall[targetProp]; // destory the instance
|
|
259
283
|
|
|
260
284
|
if (defaultClassCall.dispose) defaultClassCall.dispose(); // instance does not have constructor, just set it to 0
|
|
@@ -769,12 +793,16 @@ let extend = objects => void (catalogue = { ...catalogue,
|
|
|
769
793
|
...objects
|
|
770
794
|
});
|
|
771
795
|
|
|
796
|
+
extend({
|
|
797
|
+
Inject: THREE.Group
|
|
798
|
+
});
|
|
799
|
+
|
|
772
800
|
function createRenderer(roots, getEventPriority) {
|
|
773
801
|
function createInstance(type, {
|
|
774
802
|
args = [],
|
|
775
803
|
attach,
|
|
776
804
|
...props
|
|
777
|
-
}, root,
|
|
805
|
+
}, root, context, internalInstanceHandle) {
|
|
778
806
|
let name = `${type[0].toUpperCase()}${type.slice(1)}`;
|
|
779
807
|
let instance; // https://github.com/facebook/react/issues/17147
|
|
780
808
|
// Portals do not give us a root, they are themselves treated as a root by the reconciler
|
|
@@ -799,7 +827,9 @@ function createRenderer(roots, getEventPriority) {
|
|
|
799
827
|
if (props.object === undefined) throw `Primitives without 'object' are invalid!`;
|
|
800
828
|
const object = props.object;
|
|
801
829
|
instance = prepare(object, {
|
|
830
|
+
type,
|
|
802
831
|
root,
|
|
832
|
+
context,
|
|
803
833
|
attach,
|
|
804
834
|
primitive: true
|
|
805
835
|
});
|
|
@@ -815,23 +845,35 @@ function createRenderer(roots, getEventPriority) {
|
|
|
815
845
|
// Append memoized props with args so it's not forgotten
|
|
816
846
|
|
|
817
847
|
instance = prepare(new target(...args), {
|
|
848
|
+
type,
|
|
818
849
|
root,
|
|
850
|
+
context,
|
|
819
851
|
attach,
|
|
820
852
|
// TODO: Figure out what this is for
|
|
821
853
|
memoizedProps: {
|
|
822
|
-
args
|
|
854
|
+
args
|
|
823
855
|
}
|
|
824
856
|
});
|
|
825
857
|
} // It should NOT call onUpdate on object instanciation, because it hasn't been added to the
|
|
826
858
|
// view yet. If the callback relies on references for instance, they won't be ready yet, this is
|
|
827
859
|
// why it passes "true" here
|
|
860
|
+
// There is no reason to apply props to injects
|
|
828
861
|
|
|
829
862
|
|
|
830
|
-
applyProps$1(instance, props);
|
|
863
|
+
if (name !== 'inject') applyProps$1(instance, props);
|
|
831
864
|
return instance;
|
|
832
865
|
}
|
|
833
866
|
|
|
834
867
|
function appendChild(parentInstance, child) {
|
|
868
|
+
// https://github.com/facebook/react/issues/24138
|
|
869
|
+
// Injects are special purpose "onion layers" that inject contextual information into the scene graph.
|
|
870
|
+
// Since react-reconciler does not allow us to access the current host context we trick it by leading
|
|
871
|
+
// back to it from the first child that is added to it. We just connect the inject to it's own host context.
|
|
872
|
+
if ((parentInstance == null ? void 0 : parentInstance.__r3f.type) === 'inject') {
|
|
873
|
+
const context = child == null ? void 0 : child.__r3f.context;
|
|
874
|
+
if (context) context.current = parentInstance.__r3f;
|
|
875
|
+
}
|
|
876
|
+
|
|
835
877
|
let added = false;
|
|
836
878
|
|
|
837
879
|
if (child) {
|
|
@@ -927,6 +969,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
927
969
|
|
|
928
970
|
if (child.__r3f) {
|
|
929
971
|
delete child.__r3f.root;
|
|
972
|
+
delete child.__r3f.context;
|
|
930
973
|
delete child.__r3f.objects;
|
|
931
974
|
delete child.__r3f.handlers;
|
|
932
975
|
delete child.__r3f.memoizedProps;
|
|
@@ -986,6 +1029,16 @@ function createRenderer(roots, getEventPriority) {
|
|
|
986
1029
|
}
|
|
987
1030
|
|
|
988
1031
|
const reconciler = Reconciler({
|
|
1032
|
+
createInstance,
|
|
1033
|
+
removeChild,
|
|
1034
|
+
appendChild,
|
|
1035
|
+
appendInitialChild: appendChild,
|
|
1036
|
+
insertBefore,
|
|
1037
|
+
supportsMicrotask: true,
|
|
1038
|
+
warnsIfNotActing: true,
|
|
1039
|
+
supportsMutation: true,
|
|
1040
|
+
isPrimaryRenderer: false,
|
|
1041
|
+
noTimeout: -1,
|
|
989
1042
|
appendChildToContainer: (parentInstance, child) => {
|
|
990
1043
|
const {
|
|
991
1044
|
container,
|
|
@@ -997,8 +1050,35 @@ function createRenderer(roots, getEventPriority) {
|
|
|
997
1050
|
},
|
|
998
1051
|
removeChildFromContainer: (parentInstance, child) => removeChild(getContainer(parentInstance, child).container, child),
|
|
999
1052
|
insertInContainerBefore: (parentInstance, child, beforeChild) => insertBefore(getContainer(parentInstance, child).container, child, beforeChild),
|
|
1053
|
+
getRootHostContext: () => ({
|
|
1054
|
+
current: null
|
|
1055
|
+
}),
|
|
1056
|
+
getChildHostContext: (parentHostContext, type) => {
|
|
1057
|
+
// This is a little misleading, this function does not determine the host context for the element at hand,
|
|
1058
|
+
// but rather for all the children of it. The context for an inject is and will be the scene, everything
|
|
1059
|
+
// within an inject is contextual to it.
|
|
1060
|
+
if (type === 'inject') return {
|
|
1061
|
+
current: null
|
|
1062
|
+
};
|
|
1063
|
+
return parentHostContext;
|
|
1064
|
+
},
|
|
1065
|
+
|
|
1066
|
+
finalizeInitialChildren(instance) {
|
|
1067
|
+
var _instance$__r3f2;
|
|
1068
|
+
|
|
1069
|
+
const localState = (_instance$__r3f2 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f2 : {}; // https://github.com/facebook/react/issues/20271
|
|
1070
|
+
// Returning true will trigger commitMount
|
|
1071
|
+
|
|
1072
|
+
return !!localState.handlers;
|
|
1073
|
+
},
|
|
1000
1074
|
|
|
1001
1075
|
prepareUpdate(instance, type, oldProps, newProps) {
|
|
1076
|
+
// Injects are special purpose "onion layers" that inject contextual information into the scene graph
|
|
1077
|
+
// Because the context of an inject is still the scene we have to rely on children to give us the inject-context
|
|
1078
|
+
// so that we can set up props.
|
|
1079
|
+
if (type === 'inject' && instance.children.length) ; // Create diff-sets
|
|
1080
|
+
|
|
1081
|
+
|
|
1002
1082
|
if (instance.__r3f.primitive && newProps.object && newProps.object !== instance) {
|
|
1003
1083
|
return [true];
|
|
1004
1084
|
} else {
|
|
@@ -1031,40 +1111,58 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1031
1111
|
else applyProps$1(instance, diff);
|
|
1032
1112
|
},
|
|
1033
1113
|
|
|
1114
|
+
commitMount(instance, type, props, int) {
|
|
1115
|
+
var _instance$__r3f3;
|
|
1116
|
+
|
|
1117
|
+
// https://github.com/facebook/react/issues/20271
|
|
1118
|
+
// This will make sure events are only added once to the central container
|
|
1119
|
+
const localState = (_instance$__r3f3 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f3 : {};
|
|
1120
|
+
|
|
1121
|
+
if (instance.raycast && localState.handlers && localState.eventCount) {
|
|
1122
|
+
instance.__r3f.root.getState().internal.interaction.push(instance);
|
|
1123
|
+
}
|
|
1124
|
+
},
|
|
1125
|
+
|
|
1126
|
+
getPublicInstance: instance => instance,
|
|
1127
|
+
shouldDeprioritizeSubtree: () => false,
|
|
1128
|
+
prepareForCommit: () => null,
|
|
1129
|
+
preparePortalMount: containerInfo => prepare(containerInfo),
|
|
1130
|
+
resetAfterCommit: () => {},
|
|
1131
|
+
shouldSetTextContent: () => false,
|
|
1132
|
+
clearContainer: () => false,
|
|
1133
|
+
detachDeletedInstance: () => {},
|
|
1134
|
+
createTextInstance: () => {},
|
|
1135
|
+
|
|
1034
1136
|
hideInstance(instance) {
|
|
1035
|
-
var _instance$
|
|
1137
|
+
var _instance$__r3f4;
|
|
1036
1138
|
|
|
1037
1139
|
// Deatch while the instance is hidden
|
|
1038
1140
|
const {
|
|
1039
1141
|
attach: type,
|
|
1040
1142
|
parent
|
|
1041
|
-
} = (_instance$
|
|
1143
|
+
} = (_instance$__r3f4 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f4 : {};
|
|
1042
1144
|
if (type && parent) detach(parent, instance, type);
|
|
1043
1145
|
if (instance.isObject3D) instance.visible = false;
|
|
1044
1146
|
invalidateInstance(instance);
|
|
1045
1147
|
},
|
|
1046
1148
|
|
|
1047
1149
|
unhideInstance(instance, props) {
|
|
1048
|
-
var _instance$
|
|
1150
|
+
var _instance$__r3f5;
|
|
1049
1151
|
|
|
1050
1152
|
// Re-attach when the instance is unhidden
|
|
1051
1153
|
const {
|
|
1052
1154
|
attach: type,
|
|
1053
1155
|
parent
|
|
1054
|
-
} = (_instance$
|
|
1156
|
+
} = (_instance$__r3f5 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f5 : {};
|
|
1055
1157
|
if (type && parent) attach(parent, instance, type);
|
|
1056
1158
|
if (instance.isObject3D && props.visible == null || props.visible) instance.visible = true;
|
|
1057
1159
|
invalidateInstance(instance);
|
|
1058
1160
|
},
|
|
1059
1161
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
insertBefore,
|
|
1065
|
-
warnsIfNotActing: true,
|
|
1066
|
-
supportsMutation: true,
|
|
1067
|
-
isPrimaryRenderer: false,
|
|
1162
|
+
hideTextInstance: () => {
|
|
1163
|
+
throw new Error('Text is not allowed in the R3F tree.');
|
|
1164
|
+
},
|
|
1165
|
+
// prettier-ignore
|
|
1068
1166
|
getCurrentEventPriority: () => getEventPriority ? getEventPriority() : DefaultEventPriority,
|
|
1069
1167
|
// @ts-ignore
|
|
1070
1168
|
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : undefined,
|
|
@@ -1073,47 +1171,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1073
1171
|
// @ts-ignore
|
|
1074
1172
|
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
|
|
1075
1173
|
setTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1076
|
-
clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1077
|
-
noTimeout: -1,
|
|
1078
|
-
hideTextInstance: () => {
|
|
1079
|
-
throw new Error('Text is not allowed in the R3F tree.');
|
|
1080
|
-
},
|
|
1081
|
-
// prettier-ignore
|
|
1082
|
-
getPublicInstance: instance => instance,
|
|
1083
|
-
getRootHostContext: () => null,
|
|
1084
|
-
getChildHostContext: parentHostContext => parentHostContext,
|
|
1085
|
-
createTextInstance: () => {},
|
|
1086
|
-
|
|
1087
|
-
finalizeInitialChildren(instance) {
|
|
1088
|
-
var _instance$__r3f4;
|
|
1089
|
-
|
|
1090
|
-
// https://github.com/facebook/react/issues/20271
|
|
1091
|
-
// Returning true will trigger commitMount
|
|
1092
|
-
const localState = (_instance$__r3f4 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f4 : {};
|
|
1093
|
-
return !!localState.handlers;
|
|
1094
|
-
},
|
|
1095
|
-
|
|
1096
|
-
commitMount(instance)
|
|
1097
|
-
/*, type, props*/
|
|
1098
|
-
{
|
|
1099
|
-
var _instance$__r3f5;
|
|
1100
|
-
|
|
1101
|
-
// https://github.com/facebook/react/issues/20271
|
|
1102
|
-
// This will make sure events are only added once to the central container
|
|
1103
|
-
const localState = (_instance$__r3f5 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f5 : {};
|
|
1104
|
-
|
|
1105
|
-
if (instance.raycast && localState.handlers && localState.eventCount) {
|
|
1106
|
-
instance.__r3f.root.getState().internal.interaction.push(instance);
|
|
1107
|
-
}
|
|
1108
|
-
},
|
|
1109
|
-
|
|
1110
|
-
shouldDeprioritizeSubtree: () => false,
|
|
1111
|
-
prepareForCommit: () => null,
|
|
1112
|
-
preparePortalMount: containerInfo => prepare(containerInfo),
|
|
1113
|
-
resetAfterCommit: () => {},
|
|
1114
|
-
shouldSetTextContent: () => false,
|
|
1115
|
-
clearContainer: () => false,
|
|
1116
|
-
detachDeletedInstance: () => {}
|
|
1174
|
+
clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1117
1175
|
});
|
|
1118
1176
|
return {
|
|
1119
1177
|
reconciler,
|
|
@@ -138,6 +138,30 @@ function prepare(object, state) {
|
|
|
138
138
|
|
|
139
139
|
if (state != null && state.primitive || !instance.__r3f) {
|
|
140
140
|
instance.__r3f = {
|
|
141
|
+
type: '',
|
|
142
|
+
context: {
|
|
143
|
+
current: null
|
|
144
|
+
},
|
|
145
|
+
getContext: () => {
|
|
146
|
+
const injects = [];
|
|
147
|
+
let inject = instance.__r3f.context.current;
|
|
148
|
+
|
|
149
|
+
while (inject) {
|
|
150
|
+
var _inject$memoizedProps, _inject, _inject$context;
|
|
151
|
+
|
|
152
|
+
const {
|
|
153
|
+
children,
|
|
154
|
+
args,
|
|
155
|
+
...props
|
|
156
|
+
} = (_inject$memoizedProps = (_inject = inject) == null ? void 0 : _inject.memoizedProps) != null ? _inject$memoizedProps : {};
|
|
157
|
+
injects.push(props);
|
|
158
|
+
inject = (_inject$context = inject.context) == null ? void 0 : _inject$context.current;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return injects.reverse().reduce((prev, cur) => ({ ...prev,
|
|
162
|
+
...cur
|
|
163
|
+
}), {});
|
|
164
|
+
},
|
|
141
165
|
root: null,
|
|
142
166
|
memoizedProps: {},
|
|
143
167
|
eventCount: 0,
|
|
@@ -279,11 +303,11 @@ function applyProps$1(instance, data) {
|
|
|
279
303
|
if (value === DEFAULT + 'remove') {
|
|
280
304
|
if (targetProp && targetProp.constructor) {
|
|
281
305
|
// use the prop constructor to find the default it should be
|
|
282
|
-
value = new targetProp.constructor(memoized.args);
|
|
306
|
+
value = new targetProp.constructor(...memoized.args);
|
|
283
307
|
} else if (currentInstance.constructor) {
|
|
284
308
|
// create a blank slate of the instance and copy the particular parameter.
|
|
285
309
|
// @ts-ignore
|
|
286
|
-
const defaultClassCall = new currentInstance.constructor(currentInstance.__r3f.memoizedProps.args);
|
|
310
|
+
const defaultClassCall = new currentInstance.constructor(...currentInstance.__r3f.memoizedProps.args);
|
|
287
311
|
value = defaultClassCall[targetProp]; // destory the instance
|
|
288
312
|
|
|
289
313
|
if (defaultClassCall.dispose) defaultClassCall.dispose(); // instance does not have constructor, just set it to 0
|
|
@@ -798,12 +822,16 @@ let extend = objects => void (catalogue = { ...catalogue,
|
|
|
798
822
|
...objects
|
|
799
823
|
});
|
|
800
824
|
|
|
825
|
+
extend({
|
|
826
|
+
Inject: THREE__namespace.Group
|
|
827
|
+
});
|
|
828
|
+
|
|
801
829
|
function createRenderer(roots, getEventPriority) {
|
|
802
830
|
function createInstance(type, {
|
|
803
831
|
args = [],
|
|
804
832
|
attach,
|
|
805
833
|
...props
|
|
806
|
-
}, root,
|
|
834
|
+
}, root, context, internalInstanceHandle) {
|
|
807
835
|
let name = `${type[0].toUpperCase()}${type.slice(1)}`;
|
|
808
836
|
let instance; // https://github.com/facebook/react/issues/17147
|
|
809
837
|
// Portals do not give us a root, they are themselves treated as a root by the reconciler
|
|
@@ -828,7 +856,9 @@ function createRenderer(roots, getEventPriority) {
|
|
|
828
856
|
if (props.object === undefined) throw `Primitives without 'object' are invalid!`;
|
|
829
857
|
const object = props.object;
|
|
830
858
|
instance = prepare(object, {
|
|
859
|
+
type,
|
|
831
860
|
root,
|
|
861
|
+
context,
|
|
832
862
|
attach,
|
|
833
863
|
primitive: true
|
|
834
864
|
});
|
|
@@ -844,23 +874,35 @@ function createRenderer(roots, getEventPriority) {
|
|
|
844
874
|
// Append memoized props with args so it's not forgotten
|
|
845
875
|
|
|
846
876
|
instance = prepare(new target(...args), {
|
|
877
|
+
type,
|
|
847
878
|
root,
|
|
879
|
+
context,
|
|
848
880
|
attach,
|
|
849
881
|
// TODO: Figure out what this is for
|
|
850
882
|
memoizedProps: {
|
|
851
|
-
args
|
|
883
|
+
args
|
|
852
884
|
}
|
|
853
885
|
});
|
|
854
886
|
} // It should NOT call onUpdate on object instanciation, because it hasn't been added to the
|
|
855
887
|
// view yet. If the callback relies on references for instance, they won't be ready yet, this is
|
|
856
888
|
// why it passes "true" here
|
|
889
|
+
// There is no reason to apply props to injects
|
|
857
890
|
|
|
858
891
|
|
|
859
|
-
applyProps$1(instance, props);
|
|
892
|
+
if (name !== 'inject') applyProps$1(instance, props);
|
|
860
893
|
return instance;
|
|
861
894
|
}
|
|
862
895
|
|
|
863
896
|
function appendChild(parentInstance, child) {
|
|
897
|
+
// https://github.com/facebook/react/issues/24138
|
|
898
|
+
// Injects are special purpose "onion layers" that inject contextual information into the scene graph.
|
|
899
|
+
// Since react-reconciler does not allow us to access the current host context we trick it by leading
|
|
900
|
+
// back to it from the first child that is added to it. We just connect the inject to it's own host context.
|
|
901
|
+
if ((parentInstance == null ? void 0 : parentInstance.__r3f.type) === 'inject') {
|
|
902
|
+
const context = child == null ? void 0 : child.__r3f.context;
|
|
903
|
+
if (context) context.current = parentInstance.__r3f;
|
|
904
|
+
}
|
|
905
|
+
|
|
864
906
|
let added = false;
|
|
865
907
|
|
|
866
908
|
if (child) {
|
|
@@ -956,6 +998,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
956
998
|
|
|
957
999
|
if (child.__r3f) {
|
|
958
1000
|
delete child.__r3f.root;
|
|
1001
|
+
delete child.__r3f.context;
|
|
959
1002
|
delete child.__r3f.objects;
|
|
960
1003
|
delete child.__r3f.handlers;
|
|
961
1004
|
delete child.__r3f.memoizedProps;
|
|
@@ -1015,6 +1058,16 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1015
1058
|
}
|
|
1016
1059
|
|
|
1017
1060
|
const reconciler = Reconciler__default['default']({
|
|
1061
|
+
createInstance,
|
|
1062
|
+
removeChild,
|
|
1063
|
+
appendChild,
|
|
1064
|
+
appendInitialChild: appendChild,
|
|
1065
|
+
insertBefore,
|
|
1066
|
+
supportsMicrotask: true,
|
|
1067
|
+
warnsIfNotActing: true,
|
|
1068
|
+
supportsMutation: true,
|
|
1069
|
+
isPrimaryRenderer: false,
|
|
1070
|
+
noTimeout: -1,
|
|
1018
1071
|
appendChildToContainer: (parentInstance, child) => {
|
|
1019
1072
|
const {
|
|
1020
1073
|
container,
|
|
@@ -1026,8 +1079,35 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1026
1079
|
},
|
|
1027
1080
|
removeChildFromContainer: (parentInstance, child) => removeChild(getContainer(parentInstance, child).container, child),
|
|
1028
1081
|
insertInContainerBefore: (parentInstance, child, beforeChild) => insertBefore(getContainer(parentInstance, child).container, child, beforeChild),
|
|
1082
|
+
getRootHostContext: () => ({
|
|
1083
|
+
current: null
|
|
1084
|
+
}),
|
|
1085
|
+
getChildHostContext: (parentHostContext, type) => {
|
|
1086
|
+
// This is a little misleading, this function does not determine the host context for the element at hand,
|
|
1087
|
+
// but rather for all the children of it. The context for an inject is and will be the scene, everything
|
|
1088
|
+
// within an inject is contextual to it.
|
|
1089
|
+
if (type === 'inject') return {
|
|
1090
|
+
current: null
|
|
1091
|
+
};
|
|
1092
|
+
return parentHostContext;
|
|
1093
|
+
},
|
|
1094
|
+
|
|
1095
|
+
finalizeInitialChildren(instance) {
|
|
1096
|
+
var _instance$__r3f2;
|
|
1097
|
+
|
|
1098
|
+
const localState = (_instance$__r3f2 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f2 : {}; // https://github.com/facebook/react/issues/20271
|
|
1099
|
+
// Returning true will trigger commitMount
|
|
1100
|
+
|
|
1101
|
+
return !!localState.handlers;
|
|
1102
|
+
},
|
|
1029
1103
|
|
|
1030
1104
|
prepareUpdate(instance, type, oldProps, newProps) {
|
|
1105
|
+
// Injects are special purpose "onion layers" that inject contextual information into the scene graph
|
|
1106
|
+
// Because the context of an inject is still the scene we have to rely on children to give us the inject-context
|
|
1107
|
+
// so that we can set up props.
|
|
1108
|
+
if (type === 'inject' && instance.children.length) ; // Create diff-sets
|
|
1109
|
+
|
|
1110
|
+
|
|
1031
1111
|
if (instance.__r3f.primitive && newProps.object && newProps.object !== instance) {
|
|
1032
1112
|
return [true];
|
|
1033
1113
|
} else {
|
|
@@ -1060,40 +1140,58 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1060
1140
|
else applyProps$1(instance, diff);
|
|
1061
1141
|
},
|
|
1062
1142
|
|
|
1143
|
+
commitMount(instance, type, props, int) {
|
|
1144
|
+
var _instance$__r3f3;
|
|
1145
|
+
|
|
1146
|
+
// https://github.com/facebook/react/issues/20271
|
|
1147
|
+
// This will make sure events are only added once to the central container
|
|
1148
|
+
const localState = (_instance$__r3f3 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f3 : {};
|
|
1149
|
+
|
|
1150
|
+
if (instance.raycast && localState.handlers && localState.eventCount) {
|
|
1151
|
+
instance.__r3f.root.getState().internal.interaction.push(instance);
|
|
1152
|
+
}
|
|
1153
|
+
},
|
|
1154
|
+
|
|
1155
|
+
getPublicInstance: instance => instance,
|
|
1156
|
+
shouldDeprioritizeSubtree: () => false,
|
|
1157
|
+
prepareForCommit: () => null,
|
|
1158
|
+
preparePortalMount: containerInfo => prepare(containerInfo),
|
|
1159
|
+
resetAfterCommit: () => {},
|
|
1160
|
+
shouldSetTextContent: () => false,
|
|
1161
|
+
clearContainer: () => false,
|
|
1162
|
+
detachDeletedInstance: () => {},
|
|
1163
|
+
createTextInstance: () => {},
|
|
1164
|
+
|
|
1063
1165
|
hideInstance(instance) {
|
|
1064
|
-
var _instance$
|
|
1166
|
+
var _instance$__r3f4;
|
|
1065
1167
|
|
|
1066
1168
|
// Deatch while the instance is hidden
|
|
1067
1169
|
const {
|
|
1068
1170
|
attach: type,
|
|
1069
1171
|
parent
|
|
1070
|
-
} = (_instance$
|
|
1172
|
+
} = (_instance$__r3f4 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f4 : {};
|
|
1071
1173
|
if (type && parent) detach(parent, instance, type);
|
|
1072
1174
|
if (instance.isObject3D) instance.visible = false;
|
|
1073
1175
|
invalidateInstance(instance);
|
|
1074
1176
|
},
|
|
1075
1177
|
|
|
1076
1178
|
unhideInstance(instance, props) {
|
|
1077
|
-
var _instance$
|
|
1179
|
+
var _instance$__r3f5;
|
|
1078
1180
|
|
|
1079
1181
|
// Re-attach when the instance is unhidden
|
|
1080
1182
|
const {
|
|
1081
1183
|
attach: type,
|
|
1082
1184
|
parent
|
|
1083
|
-
} = (_instance$
|
|
1185
|
+
} = (_instance$__r3f5 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f5 : {};
|
|
1084
1186
|
if (type && parent) attach(parent, instance, type);
|
|
1085
1187
|
if (instance.isObject3D && props.visible == null || props.visible) instance.visible = true;
|
|
1086
1188
|
invalidateInstance(instance);
|
|
1087
1189
|
},
|
|
1088
1190
|
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
insertBefore,
|
|
1094
|
-
warnsIfNotActing: true,
|
|
1095
|
-
supportsMutation: true,
|
|
1096
|
-
isPrimaryRenderer: false,
|
|
1191
|
+
hideTextInstance: () => {
|
|
1192
|
+
throw new Error('Text is not allowed in the R3F tree.');
|
|
1193
|
+
},
|
|
1194
|
+
// prettier-ignore
|
|
1097
1195
|
getCurrentEventPriority: () => getEventPriority ? getEventPriority() : constants.DefaultEventPriority,
|
|
1098
1196
|
// @ts-ignore
|
|
1099
1197
|
now: typeof performance !== 'undefined' && is.fun(performance.now) ? performance.now : is.fun(Date.now) ? Date.now : undefined,
|
|
@@ -1102,47 +1200,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1102
1200
|
// @ts-ignore
|
|
1103
1201
|
cancelTimeout: is.fun(clearTimeout) ? clearTimeout : undefined,
|
|
1104
1202
|
setTimeout: is.fun(setTimeout) ? setTimeout : undefined,
|
|
1105
|
-
clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1106
|
-
noTimeout: -1,
|
|
1107
|
-
hideTextInstance: () => {
|
|
1108
|
-
throw new Error('Text is not allowed in the R3F tree.');
|
|
1109
|
-
},
|
|
1110
|
-
// prettier-ignore
|
|
1111
|
-
getPublicInstance: instance => instance,
|
|
1112
|
-
getRootHostContext: () => null,
|
|
1113
|
-
getChildHostContext: parentHostContext => parentHostContext,
|
|
1114
|
-
createTextInstance: () => {},
|
|
1115
|
-
|
|
1116
|
-
finalizeInitialChildren(instance) {
|
|
1117
|
-
var _instance$__r3f4;
|
|
1118
|
-
|
|
1119
|
-
// https://github.com/facebook/react/issues/20271
|
|
1120
|
-
// Returning true will trigger commitMount
|
|
1121
|
-
const localState = (_instance$__r3f4 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f4 : {};
|
|
1122
|
-
return !!localState.handlers;
|
|
1123
|
-
},
|
|
1124
|
-
|
|
1125
|
-
commitMount(instance)
|
|
1126
|
-
/*, type, props*/
|
|
1127
|
-
{
|
|
1128
|
-
var _instance$__r3f5;
|
|
1129
|
-
|
|
1130
|
-
// https://github.com/facebook/react/issues/20271
|
|
1131
|
-
// This will make sure events are only added once to the central container
|
|
1132
|
-
const localState = (_instance$__r3f5 = instance == null ? void 0 : instance.__r3f) != null ? _instance$__r3f5 : {};
|
|
1133
|
-
|
|
1134
|
-
if (instance.raycast && localState.handlers && localState.eventCount) {
|
|
1135
|
-
instance.__r3f.root.getState().internal.interaction.push(instance);
|
|
1136
|
-
}
|
|
1137
|
-
},
|
|
1138
|
-
|
|
1139
|
-
shouldDeprioritizeSubtree: () => false,
|
|
1140
|
-
prepareForCommit: () => null,
|
|
1141
|
-
preparePortalMount: containerInfo => prepare(containerInfo),
|
|
1142
|
-
resetAfterCommit: () => {},
|
|
1143
|
-
shouldSetTextContent: () => false,
|
|
1144
|
-
clearContainer: () => false,
|
|
1145
|
-
detachDeletedInstance: () => {}
|
|
1203
|
+
clearTimeout: is.fun(clearTimeout) ? clearTimeout : undefined
|
|
1146
1204
|
});
|
|
1147
1205
|
return {
|
|
1148
1206
|
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-2b21ab4b.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-a9d2810c.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, p as pick, o as omit, a as createRoot, u as unmountComponentAtNode } from './index-
|
|
2
|
-
export { t as ReactThreeFiber, q as _roots, n as act, l as addAfterEffect, k as addEffect, m as addTail, j as advance, g as applyProps, b as context, d as createPortal, a as createRoot, h as dispose, e as extend, i as invalidate, f as reconciler, r as render, u as unmountComponentAtNode, w as useFrame, x as useGraph, y as useLoader, s as useStore, v as useThree } from './index-
|
|
1
|
+
import { c as createEvents, e as extend, p as pick, o as omit, a as createRoot, u as unmountComponentAtNode } from './index-3d7af2b7.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, q as _roots, n as act, l as addAfterEffect, k as addEffect, m as addTail, j as advance, g as applyProps, b as context, d as createPortal, a as createRoot, h as dispose, e as extend, i as invalidate, f as reconciler, r as render, u as unmountComponentAtNode, w as useFrame, x as useGraph, y as useLoader, s as useStore, v as useThree } from './index-3d7af2b7.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';
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var THREE = require('three');
|
|
6
6
|
var expoAsset = require('expo-asset');
|
|
7
|
-
var index = require('../../dist/index-
|
|
7
|
+
var index = require('../../dist/index-2b21ab4b.cjs.dev.js');
|
|
8
8
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var reactNative = require('react-native');
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var THREE = require('three');
|
|
6
6
|
var expoAsset = require('expo-asset');
|
|
7
|
-
var index = require('../../dist/index-
|
|
7
|
+
var index = require('../../dist/index-a9d2810c.cjs.prod.js');
|
|
8
8
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var reactNative = require('react-native');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import { Asset } from 'expo-asset';
|
|
3
|
-
import { c as createEvents, e as extend, p as pick, o as omit, a as createRoot, u as unmountComponentAtNode } from '../../dist/index-
|
|
4
|
-
export { t as ReactThreeFiber, q as _roots, n as act, l as addAfterEffect, k as addEffect, m as addTail, j as advance, g as applyProps, b as context, d as createPortal, a as createRoot, h as dispose, e as extend, i as invalidate, f as reconciler, r as render, u as unmountComponentAtNode, w as useFrame, x as useGraph, y as useLoader, s as useStore, v as useThree } from '../../dist/index-
|
|
3
|
+
import { c as createEvents, e as extend, p as pick, o as omit, a as createRoot, u as unmountComponentAtNode } from '../../dist/index-3d7af2b7.esm.js';
|
|
4
|
+
export { t as ReactThreeFiber, q as _roots, n as act, l as addAfterEffect, k as addEffect, m as addTail, j as advance, g as applyProps, b as context, d as createPortal, a as createRoot, h as dispose, e as extend, i as invalidate, f as reconciler, r as render, u as unmountComponentAtNode, w as useFrame, x as useGraph, y as useLoader, s as useStore, v as useThree } from '../../dist/index-3d7af2b7.esm.js';
|
|
5
5
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import { PixelRatio, View, StyleSheet } from 'react-native';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/fiber",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.4",
|
|
4
4
|
"description": "A React renderer for Threejs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -42,21 +42,22 @@
|
|
|
42
42
|
"prebuild": "cp ../../readme.md readme.md"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@babel/runtime": "^7.
|
|
45
|
+
"@babel/runtime": "^7.17.2",
|
|
46
|
+
"@types/react-reconciler": "^0.26.4",
|
|
46
47
|
"react-merge-refs": "^1.1.0",
|
|
47
|
-
"react-reconciler": "^0.27.0-rc.
|
|
48
|
+
"react-reconciler": "^0.27.0-rc.2",
|
|
48
49
|
"react-use-measure": "^2.1.1",
|
|
49
|
-
"scheduler": "0.21.0-rc.
|
|
50
|
+
"scheduler": "^0.21.0-rc.2",
|
|
50
51
|
"suspend-react": "^0.0.8",
|
|
51
|
-
"zustand": "^3.
|
|
52
|
+
"zustand": "^3.7.1"
|
|
52
53
|
},
|
|
53
54
|
"peerDependencies": {
|
|
54
|
-
"react": ">=18.0",
|
|
55
|
-
"react-dom": ">=18.0",
|
|
56
|
-
"react-native": ">=0.64",
|
|
57
55
|
"expo": ">=43.0",
|
|
58
56
|
"expo-asset": ">=8.4",
|
|
59
57
|
"expo-gl": ">=11.0",
|
|
58
|
+
"react": ">=18.0",
|
|
59
|
+
"react-dom": ">=18.0",
|
|
60
|
+
"react-native": ">=0.64",
|
|
60
61
|
"three": ">=0.133"
|
|
61
62
|
},
|
|
62
63
|
"peerDependenciesMeta": {
|