@react-three/fiber 8.0.10 → 8.0.11
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 +2 -2
- package/dist/declarations/src/core/store.d.ts +2 -0
- package/dist/declarations/src/core/utils.d.ts +0 -5
- package/dist/declarations/src/native/Canvas.d.ts +1 -1
- package/dist/declarations/src/three-types.d.ts +1 -1
- package/dist/{index-91152509.esm.js → index-3c7aae97.esm.js} +11 -29
- package/dist/{index-c8c0474b.cjs.prod.js → index-e936c560.cjs.prod.js} +10 -30
- package/dist/{index-018d2d45.cjs.dev.js → index-f7939a95.cjs.dev.js} +10 -30
- package/dist/react-three-fiber.cjs.dev.js +34 -15
- package/dist/react-three-fiber.cjs.prod.js +34 -15
- package/dist/react-three-fiber.esm.js +35 -16
- package/native/dist/react-three-fiber-native.cjs.dev.js +45 -30
- package/native/dist/react-three-fiber-native.cjs.prod.js +45 -30
- package/native/dist/react-three-fiber-native.esm.js +46 -31
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@ import * as THREE from 'three';
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { UseBoundStore } from 'zustand';
|
|
5
5
|
import * as ReactThreeFiber from '../three-types';
|
|
6
|
-
import { Renderer, context, RootState, Size, Dpr, Performance } from './store';
|
|
6
|
+
import { Renderer, context, RootState, Size, Dpr, Performance, PrivateKeys } from './store';
|
|
7
7
|
import { extend, Root } from './renderer';
|
|
8
8
|
import { addEffect, addAfterEffect, addTail } from './loop';
|
|
9
9
|
import { EventManager, ComputeFunction } from './events';
|
|
@@ -42,7 +42,7 @@ export declare type ReconcilerRoot<TCanvas extends Element> = {
|
|
|
42
42
|
declare function createRoot<TCanvas extends Element>(canvas: TCanvas): ReconcilerRoot<TCanvas>;
|
|
43
43
|
declare function render<TCanvas extends Element>(children: React.ReactNode, canvas: TCanvas, config: RenderProps<TCanvas>): UseBoundStore<RootState>;
|
|
44
44
|
declare function unmountComponentAtNode<TElement extends Element>(canvas: TElement, callback?: (canvas: TElement) => void): void;
|
|
45
|
-
export declare type InjectState = Partial<Omit<RootState,
|
|
45
|
+
export declare type InjectState = Partial<Omit<RootState, PrivateKeys> & {
|
|
46
46
|
events?: {
|
|
47
47
|
enabled?: boolean;
|
|
48
48
|
priority?: number;
|
|
@@ -3,6 +3,8 @@ import * as React from 'react';
|
|
|
3
3
|
import { GetState, SetState, StoreApi, UseBoundStore } from 'zustand';
|
|
4
4
|
import { DomEvent, EventManager, PointerCaptureTarget, ThreeEvent } from './events';
|
|
5
5
|
import { Camera } from './utils';
|
|
6
|
+
export declare const privateKeys: readonly ["set", "get", "setSize", "setFrameloop", "setDpr", "events", "invalidate", "advance", "performance", "internal", "size", "viewport"];
|
|
7
|
+
export declare type PrivateKeys = typeof privateKeys[number];
|
|
6
8
|
export interface Intersection extends THREE.Intersection {
|
|
7
9
|
eventObject: THREE.Object3D;
|
|
8
10
|
}
|
|
@@ -47,11 +47,6 @@ export declare type ObjectMap = {
|
|
|
47
47
|
};
|
|
48
48
|
export declare function calculateDpr(dpr: Dpr): number;
|
|
49
49
|
export declare const getRootState: (obj: THREE.Object3D) => RootState | undefined;
|
|
50
|
-
export declare function filterKeys<TObj extends {
|
|
51
|
-
[key: string]: any;
|
|
52
|
-
}, TOmit extends boolean, TKey extends keyof TObj>(obj: TObj, omit: TOmit, ...keys: TKey[]): TOmit extends true ? Omit<TObj, TKey> : Pick<TObj, TKey>;
|
|
53
|
-
export declare const pick: <TObj>(obj: Partial<TObj>, keys: (keyof TObj)[]) => Pick<Partial<TObj>, keyof TObj>;
|
|
54
|
-
export declare const omit: <TObj>(obj: Partial<TObj>, keys: (keyof TObj)[]) => Omit<Partial<TObj>, keyof TObj>;
|
|
55
50
|
export declare type EquConfig = {
|
|
56
51
|
arrays?: 'reference' | 'shallow';
|
|
57
52
|
objects?: 'reference' | 'shallow';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { View, ViewProps, ViewStyle } from 'react-native';
|
|
3
3
|
import { RenderProps } from '../core';
|
|
4
|
-
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, ViewProps {
|
|
4
|
+
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size' | 'dpr'>, ViewProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
style?: ViewStyle;
|
|
7
7
|
}
|
|
@@ -21,7 +21,7 @@ export interface NodeProps<T, P> {
|
|
|
21
21
|
attach?: AttachType;
|
|
22
22
|
args?: Args<P>;
|
|
23
23
|
children?: React.ReactNode;
|
|
24
|
-
ref?: React.
|
|
24
|
+
ref?: React.Ref<T>;
|
|
25
25
|
key?: React.Key;
|
|
26
26
|
onUpdate?: (self: T) => void;
|
|
27
27
|
}
|
|
@@ -66,29 +66,6 @@ const getRootState = obj => {
|
|
|
66
66
|
|
|
67
67
|
return (_r3f = obj.__r3f) == null ? void 0 : _r3f.root.getState();
|
|
68
68
|
};
|
|
69
|
-
/**
|
|
70
|
-
* Picks or omits keys from an object
|
|
71
|
-
* `omit` will filter out keys, and otherwise cherry-pick them.
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
function filterKeys(obj, omit, ...keys) {
|
|
75
|
-
const keysToSelect = new Set(keys);
|
|
76
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
77
|
-
const shouldInclude = !omit;
|
|
78
|
-
if (keysToSelect.has(key) === shouldInclude) acc[key] = value;
|
|
79
|
-
return acc;
|
|
80
|
-
}, {});
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Clones an object and cherry-picks keys.
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
const pick = (obj, keys) => filterKeys(obj, false, ...keys);
|
|
87
|
-
/**
|
|
88
|
-
* Clones an object and prunes or omits keys.
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
const omit = (obj, keys) => filterKeys(obj, true, ...keys);
|
|
92
69
|
// A collection of compare functions
|
|
93
70
|
const is = {
|
|
94
71
|
obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
|
|
@@ -314,12 +291,16 @@ function applyProps$1(instance, data) {
|
|
|
314
291
|
|
|
315
292
|
if (value === DEFAULT + 'remove') {
|
|
316
293
|
if (targetProp && targetProp.constructor) {
|
|
294
|
+
var _memoized$args;
|
|
295
|
+
|
|
317
296
|
// use the prop constructor to find the default it should be
|
|
318
|
-
value = new targetProp.constructor(...memoized.args);
|
|
297
|
+
value = new targetProp.constructor(...((_memoized$args = memoized.args) != null ? _memoized$args : []));
|
|
319
298
|
} else if (currentInstance.constructor) {
|
|
299
|
+
var _currentInstance$__r;
|
|
300
|
+
|
|
320
301
|
// create a blank slate of the instance and copy the particular parameter.
|
|
321
302
|
// @ts-ignore
|
|
322
|
-
const defaultClassCall = new currentInstance.constructor(...currentInstance.__r3f.memoizedProps.args);
|
|
303
|
+
const defaultClassCall = new currentInstance.constructor(...((_currentInstance$__r = currentInstance.__r3f.memoizedProps.args) != null ? _currentInstance$__r : []));
|
|
323
304
|
value = defaultClassCall[targetProp]; // destory the instance
|
|
324
305
|
|
|
325
306
|
if (defaultClassCall.dispose) defaultClassCall.dispose(); // instance does not have constructor, just set it to 0
|
|
@@ -1179,6 +1160,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1179
1160
|
};
|
|
1180
1161
|
}
|
|
1181
1162
|
|
|
1163
|
+
const privateKeys = ['set', 'get', 'setSize', 'setFrameloop', 'setDpr', 'events', 'invalidate', 'advance', 'performance', 'internal', 'size', 'viewport'];
|
|
1182
1164
|
const isRenderer = def => !!(def != null && def.render);
|
|
1183
1165
|
const context = /*#__PURE__*/React.createContext(null);
|
|
1184
1166
|
|
|
@@ -1940,9 +1922,9 @@ function Portal({
|
|
|
1940
1922
|
// Some props should be off-limits
|
|
1941
1923
|
// Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1942
1924
|
Object.keys(state).forEach(key => {
|
|
1943
|
-
if (
|
|
1944
|
-
|
|
1945
|
-
|
|
1925
|
+
if ( // Some props should be off-limits
|
|
1926
|
+
!privateKeys.includes(key) && // Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1927
|
+
state[key] !== injectState[key]) delete intersect[key];
|
|
1946
1928
|
});
|
|
1947
1929
|
}
|
|
1948
1930
|
|
|
@@ -2019,4 +2001,4 @@ reconciler.injectIntoDevTools({
|
|
|
2019
2001
|
});
|
|
2020
2002
|
const act = React.unstable_act;
|
|
2021
2003
|
|
|
2022
|
-
export {
|
|
2004
|
+
export { Block as B, ErrorBoundary as E, createRoot as a, useIsomorphicLayoutEffect as b, createEvents as c, unmountComponentAtNode as d, extend as e, context as f, createPortal as g, reconciler as h, applyProps as i, dispose as j, invalidate as k, advance as l, addEffect as m, addAfterEffect as n, addTail as o, getRootState as p, act as q, render as r, roots as s, threeTypes as t, useMutableCallback as u, useStore as v, useThree as w, useFrame as x, useGraph as y, useLoader as z };
|
|
@@ -95,29 +95,6 @@ const getRootState = obj => {
|
|
|
95
95
|
|
|
96
96
|
return (_r3f = obj.__r3f) == null ? void 0 : _r3f.root.getState();
|
|
97
97
|
};
|
|
98
|
-
/**
|
|
99
|
-
* Picks or omits keys from an object
|
|
100
|
-
* `omit` will filter out keys, and otherwise cherry-pick them.
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
function filterKeys(obj, omit, ...keys) {
|
|
104
|
-
const keysToSelect = new Set(keys);
|
|
105
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
106
|
-
const shouldInclude = !omit;
|
|
107
|
-
if (keysToSelect.has(key) === shouldInclude) acc[key] = value;
|
|
108
|
-
return acc;
|
|
109
|
-
}, {});
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Clones an object and cherry-picks keys.
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
const pick = (obj, keys) => filterKeys(obj, false, ...keys);
|
|
116
|
-
/**
|
|
117
|
-
* Clones an object and prunes or omits keys.
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
|
-
const omit = (obj, keys) => filterKeys(obj, true, ...keys);
|
|
121
98
|
// A collection of compare functions
|
|
122
99
|
const is = {
|
|
123
100
|
obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
|
|
@@ -343,12 +320,16 @@ function applyProps$1(instance, data) {
|
|
|
343
320
|
|
|
344
321
|
if (value === DEFAULT + 'remove') {
|
|
345
322
|
if (targetProp && targetProp.constructor) {
|
|
323
|
+
var _memoized$args;
|
|
324
|
+
|
|
346
325
|
// use the prop constructor to find the default it should be
|
|
347
|
-
value = new targetProp.constructor(...memoized.args);
|
|
326
|
+
value = new targetProp.constructor(...((_memoized$args = memoized.args) != null ? _memoized$args : []));
|
|
348
327
|
} else if (currentInstance.constructor) {
|
|
328
|
+
var _currentInstance$__r;
|
|
329
|
+
|
|
349
330
|
// create a blank slate of the instance and copy the particular parameter.
|
|
350
331
|
// @ts-ignore
|
|
351
|
-
const defaultClassCall = new currentInstance.constructor(...currentInstance.__r3f.memoizedProps.args);
|
|
332
|
+
const defaultClassCall = new currentInstance.constructor(...((_currentInstance$__r = currentInstance.__r3f.memoizedProps.args) != null ? _currentInstance$__r : []));
|
|
352
333
|
value = defaultClassCall[targetProp]; // destory the instance
|
|
353
334
|
|
|
354
335
|
if (defaultClassCall.dispose) defaultClassCall.dispose(); // instance does not have constructor, just set it to 0
|
|
@@ -1208,6 +1189,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1208
1189
|
};
|
|
1209
1190
|
}
|
|
1210
1191
|
|
|
1192
|
+
const privateKeys = ['set', 'get', 'setSize', 'setFrameloop', 'setDpr', 'events', 'invalidate', 'advance', 'performance', 'internal', 'size', 'viewport'];
|
|
1211
1193
|
const isRenderer = def => !!(def != null && def.render);
|
|
1212
1194
|
const context = /*#__PURE__*/React__namespace.createContext(null);
|
|
1213
1195
|
|
|
@@ -1969,9 +1951,9 @@ function Portal({
|
|
|
1969
1951
|
// Some props should be off-limits
|
|
1970
1952
|
// Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1971
1953
|
Object.keys(state).forEach(key => {
|
|
1972
|
-
if (
|
|
1973
|
-
|
|
1974
|
-
|
|
1954
|
+
if ( // Some props should be off-limits
|
|
1955
|
+
!privateKeys.includes(key) && // Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1956
|
+
state[key] !== injectState[key]) delete intersect[key];
|
|
1975
1957
|
});
|
|
1976
1958
|
}
|
|
1977
1959
|
|
|
@@ -2064,8 +2046,6 @@ exports.dispose = dispose;
|
|
|
2064
2046
|
exports.extend = extend;
|
|
2065
2047
|
exports.getRootState = getRootState;
|
|
2066
2048
|
exports.invalidate = invalidate;
|
|
2067
|
-
exports.omit = omit;
|
|
2068
|
-
exports.pick = pick;
|
|
2069
2049
|
exports.reconciler = reconciler;
|
|
2070
2050
|
exports.render = render;
|
|
2071
2051
|
exports.roots = roots;
|
|
@@ -95,29 +95,6 @@ const getRootState = obj => {
|
|
|
95
95
|
|
|
96
96
|
return (_r3f = obj.__r3f) == null ? void 0 : _r3f.root.getState();
|
|
97
97
|
};
|
|
98
|
-
/**
|
|
99
|
-
* Picks or omits keys from an object
|
|
100
|
-
* `omit` will filter out keys, and otherwise cherry-pick them.
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
function filterKeys(obj, omit, ...keys) {
|
|
104
|
-
const keysToSelect = new Set(keys);
|
|
105
|
-
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
106
|
-
const shouldInclude = !omit;
|
|
107
|
-
if (keysToSelect.has(key) === shouldInclude) acc[key] = value;
|
|
108
|
-
return acc;
|
|
109
|
-
}, {});
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Clones an object and cherry-picks keys.
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
const pick = (obj, keys) => filterKeys(obj, false, ...keys);
|
|
116
|
-
/**
|
|
117
|
-
* Clones an object and prunes or omits keys.
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
|
-
const omit = (obj, keys) => filterKeys(obj, true, ...keys);
|
|
121
98
|
// A collection of compare functions
|
|
122
99
|
const is = {
|
|
123
100
|
obj: a => a === Object(a) && !is.arr(a) && typeof a !== 'function',
|
|
@@ -343,12 +320,16 @@ function applyProps$1(instance, data) {
|
|
|
343
320
|
|
|
344
321
|
if (value === DEFAULT + 'remove') {
|
|
345
322
|
if (targetProp && targetProp.constructor) {
|
|
323
|
+
var _memoized$args;
|
|
324
|
+
|
|
346
325
|
// use the prop constructor to find the default it should be
|
|
347
|
-
value = new targetProp.constructor(...memoized.args);
|
|
326
|
+
value = new targetProp.constructor(...((_memoized$args = memoized.args) != null ? _memoized$args : []));
|
|
348
327
|
} else if (currentInstance.constructor) {
|
|
328
|
+
var _currentInstance$__r;
|
|
329
|
+
|
|
349
330
|
// create a blank slate of the instance and copy the particular parameter.
|
|
350
331
|
// @ts-ignore
|
|
351
|
-
const defaultClassCall = new currentInstance.constructor(...currentInstance.__r3f.memoizedProps.args);
|
|
332
|
+
const defaultClassCall = new currentInstance.constructor(...((_currentInstance$__r = currentInstance.__r3f.memoizedProps.args) != null ? _currentInstance$__r : []));
|
|
352
333
|
value = defaultClassCall[targetProp]; // destory the instance
|
|
353
334
|
|
|
354
335
|
if (defaultClassCall.dispose) defaultClassCall.dispose(); // instance does not have constructor, just set it to 0
|
|
@@ -1208,6 +1189,7 @@ function createRenderer(roots, getEventPriority) {
|
|
|
1208
1189
|
};
|
|
1209
1190
|
}
|
|
1210
1191
|
|
|
1192
|
+
const privateKeys = ['set', 'get', 'setSize', 'setFrameloop', 'setDpr', 'events', 'invalidate', 'advance', 'performance', 'internal', 'size', 'viewport'];
|
|
1211
1193
|
const isRenderer = def => !!(def != null && def.render);
|
|
1212
1194
|
const context = /*#__PURE__*/React__namespace.createContext(null);
|
|
1213
1195
|
|
|
@@ -1969,9 +1951,9 @@ function Portal({
|
|
|
1969
1951
|
// Some props should be off-limits
|
|
1970
1952
|
// Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1971
1953
|
Object.keys(state).forEach(key => {
|
|
1972
|
-
if (
|
|
1973
|
-
|
|
1974
|
-
|
|
1954
|
+
if ( // Some props should be off-limits
|
|
1955
|
+
!privateKeys.includes(key) && // Otherwise filter out the props that are different and let the inject layer take precedence
|
|
1956
|
+
state[key] !== injectState[key]) delete intersect[key];
|
|
1975
1957
|
});
|
|
1976
1958
|
}
|
|
1977
1959
|
|
|
@@ -2064,8 +2046,6 @@ exports.dispose = dispose;
|
|
|
2064
2046
|
exports.extend = extend;
|
|
2065
2047
|
exports.getRootState = getRootState;
|
|
2066
2048
|
exports.invalidate = invalidate;
|
|
2067
|
-
exports.omit = omit;
|
|
2068
|
-
exports.pick = pick;
|
|
2069
2049
|
exports.reconciler = reconciler;
|
|
2070
2050
|
exports.render = render;
|
|
2071
2051
|
exports.roots = roots;
|
|
@@ -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-f7939a95.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -119,19 +119,29 @@ function createPointerEvents(store) {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'dpr', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
123
122
|
/**
|
|
124
123
|
* A DOM canvas which accepts threejs elements as children.
|
|
125
124
|
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
126
125
|
*/
|
|
127
|
-
|
|
128
126
|
const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
129
127
|
children,
|
|
130
128
|
fallback,
|
|
131
129
|
resize,
|
|
132
130
|
style,
|
|
133
|
-
|
|
131
|
+
gl,
|
|
134
132
|
events = createPointerEvents,
|
|
133
|
+
shadows,
|
|
134
|
+
linear,
|
|
135
|
+
flat,
|
|
136
|
+
legacy,
|
|
137
|
+
orthographic,
|
|
138
|
+
frameloop,
|
|
139
|
+
dpr,
|
|
140
|
+
performance,
|
|
141
|
+
raycaster,
|
|
142
|
+
camera,
|
|
143
|
+
onPointerMissed,
|
|
144
|
+
onCreated,
|
|
135
145
|
...props
|
|
136
146
|
}, forwardedRef) {
|
|
137
147
|
// Create a known catalogue of Threejs-native elements
|
|
@@ -153,8 +163,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
153
163
|
const meshRef = React__namespace.useRef(null);
|
|
154
164
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
155
165
|
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
156
|
-
const canvasProps = index.pick(props, CANVAS_PROPS);
|
|
157
|
-
const divProps = index.omit(props, CANVAS_PROPS);
|
|
158
166
|
const [block, setBlock] = React__namespace.useState(false);
|
|
159
167
|
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
160
168
|
|
|
@@ -165,18 +173,29 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
165
173
|
|
|
166
174
|
if (width > 0 && height > 0 && canvas) {
|
|
167
175
|
if (!root.current) root.current = index.createRoot(canvas);
|
|
168
|
-
root.current.configure({
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
root.current.configure({
|
|
177
|
+
gl,
|
|
178
|
+
events,
|
|
179
|
+
shadows,
|
|
180
|
+
linear,
|
|
181
|
+
flat,
|
|
182
|
+
legacy,
|
|
183
|
+
orthographic,
|
|
184
|
+
frameloop,
|
|
185
|
+
dpr,
|
|
186
|
+
performance,
|
|
187
|
+
raycaster,
|
|
188
|
+
camera,
|
|
175
189
|
size: {
|
|
176
190
|
width,
|
|
177
191
|
height
|
|
178
192
|
},
|
|
179
|
-
|
|
193
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
194
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
195
|
+
onCreated: state => {
|
|
196
|
+
state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
|
|
197
|
+
onCreated == null ? void 0 : onCreated(state);
|
|
198
|
+
}
|
|
180
199
|
});
|
|
181
200
|
root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
182
201
|
set: setError
|
|
@@ -202,7 +221,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
202
221
|
overflow: 'hidden',
|
|
203
222
|
...style
|
|
204
223
|
}
|
|
205
|
-
},
|
|
224
|
+
}, props), /*#__PURE__*/React__namespace.createElement("canvas", {
|
|
206
225
|
ref: mergeRefs__default['default']([canvasRef, forwardedRef]),
|
|
207
226
|
style: {
|
|
208
227
|
display: 'block'
|
|
@@ -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-e936c560.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -119,19 +119,29 @@ function createPointerEvents(store) {
|
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'dpr', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
123
122
|
/**
|
|
124
123
|
* A DOM canvas which accepts threejs elements as children.
|
|
125
124
|
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
126
125
|
*/
|
|
127
|
-
|
|
128
126
|
const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
129
127
|
children,
|
|
130
128
|
fallback,
|
|
131
129
|
resize,
|
|
132
130
|
style,
|
|
133
|
-
|
|
131
|
+
gl,
|
|
134
132
|
events = createPointerEvents,
|
|
133
|
+
shadows,
|
|
134
|
+
linear,
|
|
135
|
+
flat,
|
|
136
|
+
legacy,
|
|
137
|
+
orthographic,
|
|
138
|
+
frameloop,
|
|
139
|
+
dpr,
|
|
140
|
+
performance,
|
|
141
|
+
raycaster,
|
|
142
|
+
camera,
|
|
143
|
+
onPointerMissed,
|
|
144
|
+
onCreated,
|
|
135
145
|
...props
|
|
136
146
|
}, forwardedRef) {
|
|
137
147
|
// Create a known catalogue of Threejs-native elements
|
|
@@ -153,8 +163,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
153
163
|
const meshRef = React__namespace.useRef(null);
|
|
154
164
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
155
165
|
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
156
|
-
const canvasProps = index.pick(props, CANVAS_PROPS);
|
|
157
|
-
const divProps = index.omit(props, CANVAS_PROPS);
|
|
158
166
|
const [block, setBlock] = React__namespace.useState(false);
|
|
159
167
|
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
160
168
|
|
|
@@ -165,18 +173,29 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
165
173
|
|
|
166
174
|
if (width > 0 && height > 0 && canvas) {
|
|
167
175
|
if (!root.current) root.current = index.createRoot(canvas);
|
|
168
|
-
root.current.configure({
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
root.current.configure({
|
|
177
|
+
gl,
|
|
178
|
+
events,
|
|
179
|
+
shadows,
|
|
180
|
+
linear,
|
|
181
|
+
flat,
|
|
182
|
+
legacy,
|
|
183
|
+
orthographic,
|
|
184
|
+
frameloop,
|
|
185
|
+
dpr,
|
|
186
|
+
performance,
|
|
187
|
+
raycaster,
|
|
188
|
+
camera,
|
|
175
189
|
size: {
|
|
176
190
|
width,
|
|
177
191
|
height
|
|
178
192
|
},
|
|
179
|
-
|
|
193
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
194
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
195
|
+
onCreated: state => {
|
|
196
|
+
state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
|
|
197
|
+
onCreated == null ? void 0 : onCreated(state);
|
|
198
|
+
}
|
|
180
199
|
});
|
|
181
200
|
root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
182
201
|
set: setError
|
|
@@ -202,7 +221,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
202
221
|
overflow: 'hidden',
|
|
203
222
|
...style
|
|
204
223
|
}
|
|
205
|
-
},
|
|
224
|
+
}, props), /*#__PURE__*/React__namespace.createElement("canvas", {
|
|
206
225
|
ref: mergeRefs__default['default']([canvasRef, forwardedRef]),
|
|
207
226
|
style: {
|
|
208
227
|
display: 'block'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMutableCallback,
|
|
2
|
-
export { t as ReactThreeFiber,
|
|
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-3c7aae97.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, s as _roots, q as act, n as addAfterEffect, m as addEffect, o as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, p as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, x as useFrame, y as useGraph, z as useLoader, v as useStore, w as useThree } from './index-3c7aae97.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';
|
|
@@ -89,19 +89,29 @@ function createPointerEvents(store) {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'dpr', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
93
92
|
/**
|
|
94
93
|
* A DOM canvas which accepts threejs elements as children.
|
|
95
94
|
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
96
95
|
*/
|
|
97
|
-
|
|
98
96
|
const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
99
97
|
children,
|
|
100
98
|
fallback,
|
|
101
99
|
resize,
|
|
102
100
|
style,
|
|
103
|
-
|
|
101
|
+
gl,
|
|
104
102
|
events = createPointerEvents,
|
|
103
|
+
shadows,
|
|
104
|
+
linear,
|
|
105
|
+
flat,
|
|
106
|
+
legacy,
|
|
107
|
+
orthographic,
|
|
108
|
+
frameloop,
|
|
109
|
+
dpr,
|
|
110
|
+
performance,
|
|
111
|
+
raycaster,
|
|
112
|
+
camera,
|
|
113
|
+
onPointerMissed,
|
|
114
|
+
onCreated,
|
|
105
115
|
...props
|
|
106
116
|
}, forwardedRef) {
|
|
107
117
|
// Create a known catalogue of Threejs-native elements
|
|
@@ -123,8 +133,6 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
123
133
|
const meshRef = React.useRef(null);
|
|
124
134
|
const [canvas, setCanvas] = React.useState(null);
|
|
125
135
|
const handlePointerMissed = useMutableCallback(onPointerMissed);
|
|
126
|
-
const canvasProps = pick(props, CANVAS_PROPS);
|
|
127
|
-
const divProps = omit(props, CANVAS_PROPS);
|
|
128
136
|
const [block, setBlock] = React.useState(false);
|
|
129
137
|
const [error, setError] = React.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
130
138
|
|
|
@@ -135,18 +143,29 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
135
143
|
|
|
136
144
|
if (width > 0 && height > 0 && canvas) {
|
|
137
145
|
if (!root.current) root.current = createRoot(canvas);
|
|
138
|
-
root.current.configure({
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
root.current.configure({
|
|
147
|
+
gl,
|
|
148
|
+
events,
|
|
149
|
+
shadows,
|
|
150
|
+
linear,
|
|
151
|
+
flat,
|
|
152
|
+
legacy,
|
|
153
|
+
orthographic,
|
|
154
|
+
frameloop,
|
|
155
|
+
dpr,
|
|
156
|
+
performance,
|
|
157
|
+
raycaster,
|
|
158
|
+
camera,
|
|
145
159
|
size: {
|
|
146
160
|
width,
|
|
147
161
|
height
|
|
148
162
|
},
|
|
149
|
-
|
|
163
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
164
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
165
|
+
onCreated: state => {
|
|
166
|
+
state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
|
|
167
|
+
onCreated == null ? void 0 : onCreated(state);
|
|
168
|
+
}
|
|
150
169
|
});
|
|
151
170
|
root.current.render( /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
152
171
|
set: setError
|
|
@@ -172,7 +191,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
172
191
|
overflow: 'hidden',
|
|
173
192
|
...style
|
|
174
193
|
}
|
|
175
|
-
},
|
|
194
|
+
}, props), /*#__PURE__*/React.createElement("canvas", {
|
|
176
195
|
ref: mergeRefs([canvasRef, forwardedRef]),
|
|
177
196
|
style: {
|
|
178
197
|
display: 'block'
|
|
@@ -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-f7939a95.cjs.dev.js');
|
|
8
8
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var mergeRefs = require('react-merge-refs');
|
|
@@ -127,17 +127,26 @@ function createTouchEvents(store) {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
131
130
|
/**
|
|
132
131
|
* A native canvas which accepts threejs elements as children.
|
|
133
132
|
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
134
133
|
*/
|
|
135
|
-
|
|
136
134
|
const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
137
135
|
children,
|
|
138
136
|
style,
|
|
139
|
-
|
|
137
|
+
gl,
|
|
138
|
+
events = createTouchEvents,
|
|
139
|
+
shadows,
|
|
140
|
+
linear,
|
|
141
|
+
flat,
|
|
142
|
+
legacy,
|
|
143
|
+
orthographic,
|
|
144
|
+
frameloop,
|
|
145
|
+
performance,
|
|
146
|
+
raycaster,
|
|
147
|
+
camera,
|
|
140
148
|
onPointerMissed,
|
|
149
|
+
onCreated,
|
|
141
150
|
...props
|
|
142
151
|
}, forwardedRef) => {
|
|
143
152
|
// Create a known catalogue of Threejs-native elements
|
|
@@ -154,8 +163,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
154
163
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
155
164
|
const [bind, setBind] = React__namespace.useState();
|
|
156
165
|
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
157
|
-
const canvasProps = index.pick(props, CANVAS_PROPS);
|
|
158
|
-
const viewProps = index.omit(props, CANVAS_PROPS);
|
|
159
166
|
const [block, setBlock] = React__namespace.useState(false);
|
|
160
167
|
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
161
168
|
|
|
@@ -188,27 +195,19 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
188
195
|
}, []);
|
|
189
196
|
|
|
190
197
|
if (width > 0 && height > 0 && canvas) {
|
|
191
|
-
if (!root.current) root.current = index.createRoot(canvas);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
return canvasProps == null ? void 0 : canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
root.current.configure({ ...canvasProps,
|
|
210
|
-
// Pass mutable reference to onPointerMissed so it's free to update
|
|
211
|
-
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
198
|
+
if (!root.current) root.current = index.createRoot(canvas);
|
|
199
|
+
root.current.configure({
|
|
200
|
+
gl,
|
|
201
|
+
events,
|
|
202
|
+
shadows,
|
|
203
|
+
linear,
|
|
204
|
+
flat,
|
|
205
|
+
legacy,
|
|
206
|
+
orthographic,
|
|
207
|
+
frameloop,
|
|
208
|
+
performance,
|
|
209
|
+
raycaster,
|
|
210
|
+
camera,
|
|
212
211
|
// expo-gl can only render at native dpr/resolution
|
|
213
212
|
// https://github.com/expo/expo-three/issues/39
|
|
214
213
|
dpr: reactNative.PixelRatio.get(),
|
|
@@ -216,8 +215,24 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
216
215
|
width,
|
|
217
216
|
height
|
|
218
217
|
},
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
219
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
220
|
+
// Overwrite onCreated to apply RN bindings
|
|
221
|
+
onCreated: state => {
|
|
222
|
+
// Bind events after creation
|
|
223
|
+
const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
|
|
224
|
+
setBind(handlers); // Bind render to RN bridge
|
|
225
|
+
|
|
226
|
+
const context = state.gl.getContext();
|
|
227
|
+
const renderFrame = state.gl.render.bind(state.gl);
|
|
228
|
+
|
|
229
|
+
state.gl.render = (scene, camera) => {
|
|
230
|
+
renderFrame(scene, camera);
|
|
231
|
+
context.endFrameEXP();
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
return onCreated == null ? void 0 : onCreated(state);
|
|
235
|
+
}
|
|
221
236
|
});
|
|
222
237
|
root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
223
238
|
set: setError
|
|
@@ -233,7 +248,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
233
248
|
return () => index.unmountComponentAtNode(canvas);
|
|
234
249
|
}
|
|
235
250
|
}, [canvas]);
|
|
236
|
-
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({},
|
|
251
|
+
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, props, {
|
|
237
252
|
ref: mergeRefs__default['default']([viewRef, forwardedRef]),
|
|
238
253
|
onLayout: onLayout,
|
|
239
254
|
style: {
|
|
@@ -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-e936c560.cjs.prod.js');
|
|
8
8
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var mergeRefs = require('react-merge-refs');
|
|
@@ -127,17 +127,26 @@ function createTouchEvents(store) {
|
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
131
130
|
/**
|
|
132
131
|
* A native canvas which accepts threejs elements as children.
|
|
133
132
|
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
134
133
|
*/
|
|
135
|
-
|
|
136
134
|
const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
137
135
|
children,
|
|
138
136
|
style,
|
|
139
|
-
|
|
137
|
+
gl,
|
|
138
|
+
events = createTouchEvents,
|
|
139
|
+
shadows,
|
|
140
|
+
linear,
|
|
141
|
+
flat,
|
|
142
|
+
legacy,
|
|
143
|
+
orthographic,
|
|
144
|
+
frameloop,
|
|
145
|
+
performance,
|
|
146
|
+
raycaster,
|
|
147
|
+
camera,
|
|
140
148
|
onPointerMissed,
|
|
149
|
+
onCreated,
|
|
141
150
|
...props
|
|
142
151
|
}, forwardedRef) => {
|
|
143
152
|
// Create a known catalogue of Threejs-native elements
|
|
@@ -154,8 +163,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
154
163
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
155
164
|
const [bind, setBind] = React__namespace.useState();
|
|
156
165
|
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
157
|
-
const canvasProps = index.pick(props, CANVAS_PROPS);
|
|
158
|
-
const viewProps = index.omit(props, CANVAS_PROPS);
|
|
159
166
|
const [block, setBlock] = React__namespace.useState(false);
|
|
160
167
|
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
161
168
|
|
|
@@ -188,27 +195,19 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
188
195
|
}, []);
|
|
189
196
|
|
|
190
197
|
if (width > 0 && height > 0 && canvas) {
|
|
191
|
-
if (!root.current) root.current = index.createRoot(canvas);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
return canvasProps == null ? void 0 : canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
root.current.configure({ ...canvasProps,
|
|
210
|
-
// Pass mutable reference to onPointerMissed so it's free to update
|
|
211
|
-
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
198
|
+
if (!root.current) root.current = index.createRoot(canvas);
|
|
199
|
+
root.current.configure({
|
|
200
|
+
gl,
|
|
201
|
+
events,
|
|
202
|
+
shadows,
|
|
203
|
+
linear,
|
|
204
|
+
flat,
|
|
205
|
+
legacy,
|
|
206
|
+
orthographic,
|
|
207
|
+
frameloop,
|
|
208
|
+
performance,
|
|
209
|
+
raycaster,
|
|
210
|
+
camera,
|
|
212
211
|
// expo-gl can only render at native dpr/resolution
|
|
213
212
|
// https://github.com/expo/expo-three/issues/39
|
|
214
213
|
dpr: reactNative.PixelRatio.get(),
|
|
@@ -216,8 +215,24 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
216
215
|
width,
|
|
217
216
|
height
|
|
218
217
|
},
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
219
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
220
|
+
// Overwrite onCreated to apply RN bindings
|
|
221
|
+
onCreated: state => {
|
|
222
|
+
// Bind events after creation
|
|
223
|
+
const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
|
|
224
|
+
setBind(handlers); // Bind render to RN bridge
|
|
225
|
+
|
|
226
|
+
const context = state.gl.getContext();
|
|
227
|
+
const renderFrame = state.gl.render.bind(state.gl);
|
|
228
|
+
|
|
229
|
+
state.gl.render = (scene, camera) => {
|
|
230
|
+
renderFrame(scene, camera);
|
|
231
|
+
context.endFrameEXP();
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
return onCreated == null ? void 0 : onCreated(state);
|
|
235
|
+
}
|
|
221
236
|
});
|
|
222
237
|
root.current.render( /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
223
238
|
set: setError
|
|
@@ -233,7 +248,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
233
248
|
return () => index.unmountComponentAtNode(canvas);
|
|
234
249
|
}
|
|
235
250
|
}, [canvas]);
|
|
236
|
-
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({},
|
|
251
|
+
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, props, {
|
|
237
252
|
ref: mergeRefs__default['default']([viewRef, forwardedRef]),
|
|
238
253
|
onLayout: onLayout,
|
|
239
254
|
style: {
|
|
@@ -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, u as useMutableCallback,
|
|
4
|
-
export { t as ReactThreeFiber,
|
|
3
|
+
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-3c7aae97.esm.js';
|
|
4
|
+
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-3c7aae97.esm.js';
|
|
5
5
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import mergeRefs from 'react-merge-refs';
|
|
@@ -97,17 +97,26 @@ function createTouchEvents(store) {
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
const CANVAS_PROPS = ['gl', 'events', 'shadows', 'linear', 'flat', 'legacy', 'orthographic', 'frameloop', 'performance', 'raycaster', 'camera', 'onPointerMissed', 'onCreated'];
|
|
101
100
|
/**
|
|
102
101
|
* A native canvas which accepts threejs elements as children.
|
|
103
102
|
* @see https://docs.pmnd.rs/react-three-fiber/api/canvas
|
|
104
103
|
*/
|
|
105
|
-
|
|
106
104
|
const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
107
105
|
children,
|
|
108
106
|
style,
|
|
109
|
-
|
|
107
|
+
gl,
|
|
108
|
+
events = createTouchEvents,
|
|
109
|
+
shadows,
|
|
110
|
+
linear,
|
|
111
|
+
flat,
|
|
112
|
+
legacy,
|
|
113
|
+
orthographic,
|
|
114
|
+
frameloop,
|
|
115
|
+
performance,
|
|
116
|
+
raycaster,
|
|
117
|
+
camera,
|
|
110
118
|
onPointerMissed,
|
|
119
|
+
onCreated,
|
|
111
120
|
...props
|
|
112
121
|
}, forwardedRef) => {
|
|
113
122
|
// Create a known catalogue of Threejs-native elements
|
|
@@ -124,8 +133,6 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
124
133
|
const [canvas, setCanvas] = React.useState(null);
|
|
125
134
|
const [bind, setBind] = React.useState();
|
|
126
135
|
const handlePointerMissed = useMutableCallback(onPointerMissed);
|
|
127
|
-
const canvasProps = pick(props, CANVAS_PROPS);
|
|
128
|
-
const viewProps = omit(props, CANVAS_PROPS);
|
|
129
136
|
const [block, setBlock] = React.useState(false);
|
|
130
137
|
const [error, setError] = React.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
131
138
|
|
|
@@ -158,27 +165,19 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
158
165
|
}, []);
|
|
159
166
|
|
|
160
167
|
if (width > 0 && height > 0 && canvas) {
|
|
161
|
-
if (!root.current) root.current = createRoot(canvas);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
return canvasProps == null ? void 0 : canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
root.current.configure({ ...canvasProps,
|
|
180
|
-
// Pass mutable reference to onPointerMissed so it's free to update
|
|
181
|
-
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
168
|
+
if (!root.current) root.current = createRoot(canvas);
|
|
169
|
+
root.current.configure({
|
|
170
|
+
gl,
|
|
171
|
+
events,
|
|
172
|
+
shadows,
|
|
173
|
+
linear,
|
|
174
|
+
flat,
|
|
175
|
+
legacy,
|
|
176
|
+
orthographic,
|
|
177
|
+
frameloop,
|
|
178
|
+
performance,
|
|
179
|
+
raycaster,
|
|
180
|
+
camera,
|
|
182
181
|
// expo-gl can only render at native dpr/resolution
|
|
183
182
|
// https://github.com/expo/expo-three/issues/39
|
|
184
183
|
dpr: PixelRatio.get(),
|
|
@@ -186,8 +185,24 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
186
185
|
width,
|
|
187
186
|
height
|
|
188
187
|
},
|
|
189
|
-
|
|
190
|
-
|
|
188
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
189
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
190
|
+
// Overwrite onCreated to apply RN bindings
|
|
191
|
+
onCreated: state => {
|
|
192
|
+
// Bind events after creation
|
|
193
|
+
const handlers = state.events.connect == null ? void 0 : state.events.connect(viewRef.current);
|
|
194
|
+
setBind(handlers); // Bind render to RN bridge
|
|
195
|
+
|
|
196
|
+
const context = state.gl.getContext();
|
|
197
|
+
const renderFrame = state.gl.render.bind(state.gl);
|
|
198
|
+
|
|
199
|
+
state.gl.render = (scene, camera) => {
|
|
200
|
+
renderFrame(scene, camera);
|
|
201
|
+
context.endFrameEXP();
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
return onCreated == null ? void 0 : onCreated(state);
|
|
205
|
+
}
|
|
191
206
|
});
|
|
192
207
|
root.current.render( /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
193
208
|
set: setError
|
|
@@ -203,7 +218,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
203
218
|
return () => unmountComponentAtNode(canvas);
|
|
204
219
|
}
|
|
205
220
|
}, [canvas]);
|
|
206
|
-
return /*#__PURE__*/React.createElement(View, _extends({},
|
|
221
|
+
return /*#__PURE__*/React.createElement(View, _extends({}, props, {
|
|
207
222
|
ref: mergeRefs([viewRef, forwardedRef]),
|
|
208
223
|
onLayout: onLayout,
|
|
209
224
|
style: {
|