@react-three/fiber 9.0.0-rc.6 → 9.0.0-rc.7
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/reconciler.d.ts +0 -2
- package/dist/declarations/src/three-types.d.ts +5 -1
- package/dist/{events-06bc1550.esm.js → events-12fa3319.esm.js} +54 -30
- package/dist/{events-4464c9d4.cjs.dev.js → events-56f909a9.cjs.dev.js} +54 -30
- package/dist/{events-79ccf613.cjs.prod.js → events-858f07e7.cjs.prod.js} +54 -30
- package/dist/react-three-fiber.cjs.dev.js +1 -1
- package/dist/react-three-fiber.cjs.prod.js +1 -1
- package/dist/react-three-fiber.esm.js +2 -2
- package/native/dist/react-three-fiber-native.cjs.dev.js +1 -1
- package/native/dist/react-three-fiber-native.cjs.prod.js +1 -1
- package/native/dist/react-three-fiber-native.esm.js +2 -2
- package/package.json +1 -1
|
@@ -25,7 +25,6 @@ type ArgsProp<P> = P extends ConstructorRepresentation ? IsAllOptional<Construct
|
|
|
25
25
|
};
|
|
26
26
|
export type InstanceProps<T = any, P = any> = ArgsProp<P> & {
|
|
27
27
|
object?: T;
|
|
28
|
-
visible?: boolean;
|
|
29
28
|
dispose?: null;
|
|
30
29
|
attach?: AttachType<T>;
|
|
31
30
|
onUpdate?: (self: T) => void;
|
|
@@ -45,7 +44,6 @@ export interface Instance<O = any> {
|
|
|
45
44
|
previousAttach?: any;
|
|
46
45
|
isHidden: boolean;
|
|
47
46
|
}
|
|
48
|
-
export declare const catalogue: Catalogue;
|
|
49
47
|
export declare function extend<T extends ConstructorRepresentation>(objects: T): React.ExoticComponent<ThreeElement<T>>;
|
|
50
48
|
export declare function extend<T extends Catalogue>(objects: T): void;
|
|
51
49
|
export declare const reconciler: Reconciler.Reconciler<RootStore, Instance<any>, void, Instance<any>, any>;
|
|
@@ -33,8 +33,12 @@ export interface ReactProps<P> {
|
|
|
33
33
|
export type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, MathProps<P> & ReactProps<P> & EventProps<P>>>;
|
|
34
34
|
export type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
|
|
35
35
|
type ThreeExports = typeof THREE;
|
|
36
|
+
type DuplicateKeys<T, U> = Extract<keyof T, keyof U>;
|
|
37
|
+
type Conflicts = DuplicateKeys<JSX.IntrinsicElements, {
|
|
38
|
+
[K in keyof ThreeExports as Uncapitalize<K>]: any;
|
|
39
|
+
}>;
|
|
36
40
|
type ThreeElementsImpl = {
|
|
37
|
-
[K in keyof ThreeExports as Uncapitalize<K>]: ThreeExports[K] extends ConstructorRepresentation ? ThreeElement<ThreeExports[K]> : never;
|
|
41
|
+
[K in keyof ThreeExports as Uncapitalize<K> extends Conflicts ? `three${Capitalize<K>}` : Uncapitalize<K>]: ThreeExports[K] extends ConstructorRepresentation ? ThreeElement<ThreeExports[K]> : never;
|
|
38
42
|
};
|
|
39
43
|
export interface ThreeElements extends ThreeElementsImpl {
|
|
40
44
|
primitive: Omit<ThreeElement<any>, 'args'> & {
|
|
@@ -354,6 +354,7 @@ function applyProps(object, props) {
|
|
|
354
354
|
if (instance && EVENT_REGEX.test(prop)) {
|
|
355
355
|
if (typeof value === 'function') instance.handlers[prop] = value;else delete instance.handlers[prop];
|
|
356
356
|
instance.eventCount = Object.keys(instance.handlers).length;
|
|
357
|
+
continue;
|
|
357
358
|
}
|
|
358
359
|
|
|
359
360
|
// Ignore setting undefined props
|
|
@@ -594,7 +595,19 @@ function createEvents(store) {
|
|
|
594
595
|
stopped: false
|
|
595
596
|
};
|
|
596
597
|
for (const hit of intersections) {
|
|
597
|
-
|
|
598
|
+
let state = getRootState(hit.object);
|
|
599
|
+
|
|
600
|
+
// If the object is not managed by R3F, it might be parented to an element which is.
|
|
601
|
+
// Traverse upwards until we find a managed parent and use its state instead.
|
|
602
|
+
if (!state) {
|
|
603
|
+
hit.object.traverseAncestors(obj => {
|
|
604
|
+
const parentState = getRootState(obj);
|
|
605
|
+
if (parentState) {
|
|
606
|
+
state = parentState;
|
|
607
|
+
return false;
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
}
|
|
598
611
|
if (state) {
|
|
599
612
|
const {
|
|
600
613
|
raycaster,
|
|
@@ -1230,6 +1243,8 @@ const NoEventPriority = 0;
|
|
|
1230
1243
|
// https://github.com/microsoft/TypeScript/issues/37079
|
|
1231
1244
|
|
|
1232
1245
|
const catalogue = {};
|
|
1246
|
+
const PREFIX_REGEX = /^three(?=[A-Z])/;
|
|
1247
|
+
const toPascalCase = type => `${type[0].toUpperCase()}${type.slice(1)}`;
|
|
1233
1248
|
let i = 0;
|
|
1234
1249
|
const isConstructor = object => typeof object === 'function';
|
|
1235
1250
|
function extend(objects) {
|
|
@@ -1257,6 +1272,8 @@ function validateInstance(type, props) {
|
|
|
1257
1272
|
}
|
|
1258
1273
|
function createInstance(type, props, root) {
|
|
1259
1274
|
var _props$object;
|
|
1275
|
+
// Remove three* prefix from elements
|
|
1276
|
+
type = type.replace(PREFIX_REGEX, '');
|
|
1260
1277
|
validateInstance(type, props);
|
|
1261
1278
|
|
|
1262
1279
|
// Regenerate the R3F instance for primitives to simulate a new object
|
|
@@ -1300,8 +1317,7 @@ function handleContainerEffects(parent, child, beforeChild) {
|
|
|
1300
1317
|
if (!child.object) {
|
|
1301
1318
|
var _child$props$object, _child$props$args;
|
|
1302
1319
|
// Get target from catalogue
|
|
1303
|
-
const
|
|
1304
|
-
const target = catalogue[name];
|
|
1320
|
+
const target = catalogue[toPascalCase(child.type)];
|
|
1305
1321
|
|
|
1306
1322
|
// Create object
|
|
1307
1323
|
child.object = (_child$props$object = child.props.object) != null ? _child$props$object : new target(...((_child$props$args = child.props.args) != null ? _child$props$args : []));
|
|
@@ -1467,8 +1483,7 @@ function swapInstances() {
|
|
|
1467
1483
|
if (parent) {
|
|
1468
1484
|
var _instance$props$objec, _instance$props$args;
|
|
1469
1485
|
// Get target from catalogue
|
|
1470
|
-
const
|
|
1471
|
-
const target = catalogue[name];
|
|
1486
|
+
const target = catalogue[toPascalCase(instance.type)];
|
|
1472
1487
|
|
|
1473
1488
|
// Create object
|
|
1474
1489
|
instance.object = (_instance$props$objec = instance.props.object) != null ? _instance$props$objec : new target(...((_instance$props$args = instance.props.args) != null ? _instance$props$args : []));
|
|
@@ -1637,20 +1652,6 @@ const shallowLoose = {
|
|
|
1637
1652
|
objects: 'shallow',
|
|
1638
1653
|
strict: false
|
|
1639
1654
|
};
|
|
1640
|
-
async function createRendererInstance(gl, canvas) {
|
|
1641
|
-
const defaultProps = {
|
|
1642
|
-
canvas: canvas,
|
|
1643
|
-
powerPreference: 'high-performance',
|
|
1644
|
-
antialias: true,
|
|
1645
|
-
alpha: true
|
|
1646
|
-
};
|
|
1647
|
-
const customRenderer = typeof gl === 'function' ? await gl(defaultProps) : gl;
|
|
1648
|
-
if (isRenderer(customRenderer)) return customRenderer;
|
|
1649
|
-
return new THREE.WebGLRenderer({
|
|
1650
|
-
...defaultProps,
|
|
1651
|
-
...gl
|
|
1652
|
-
});
|
|
1653
|
-
}
|
|
1654
1655
|
function computeInitialSize(canvas, size) {
|
|
1655
1656
|
if (!size && typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
|
|
1656
1657
|
const {
|
|
@@ -1728,10 +1729,13 @@ function createRoot(canvas) {
|
|
|
1728
1729
|
|
|
1729
1730
|
// Locals
|
|
1730
1731
|
let onCreated;
|
|
1731
|
-
let configured = false;
|
|
1732
1732
|
let lastCamera;
|
|
1733
|
+
let configured = false;
|
|
1734
|
+
let pending = null;
|
|
1733
1735
|
return {
|
|
1734
1736
|
async configure(props = {}) {
|
|
1737
|
+
let resolve;
|
|
1738
|
+
pending = new Promise(_resolve => resolve = _resolve);
|
|
1735
1739
|
let {
|
|
1736
1740
|
gl: glConfig,
|
|
1737
1741
|
size: propsSize,
|
|
@@ -1754,9 +1758,26 @@ function createRoot(canvas) {
|
|
|
1754
1758
|
|
|
1755
1759
|
// Set up renderer (one time only!)
|
|
1756
1760
|
let gl = state.gl;
|
|
1757
|
-
if (!state.gl)
|
|
1758
|
-
|
|
1759
|
-
|
|
1761
|
+
if (!state.gl) {
|
|
1762
|
+
const defaultProps = {
|
|
1763
|
+
canvas: canvas,
|
|
1764
|
+
powerPreference: 'high-performance',
|
|
1765
|
+
antialias: true,
|
|
1766
|
+
alpha: true
|
|
1767
|
+
};
|
|
1768
|
+
const customRenderer = typeof glConfig === 'function' ? await glConfig(defaultProps) : glConfig;
|
|
1769
|
+
if (isRenderer(customRenderer)) {
|
|
1770
|
+
gl = customRenderer;
|
|
1771
|
+
} else {
|
|
1772
|
+
gl = new THREE.WebGLRenderer({
|
|
1773
|
+
...defaultProps,
|
|
1774
|
+
...glConfig
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
state.set({
|
|
1778
|
+
gl
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1760
1781
|
|
|
1761
1782
|
// Set up raycaster (one time only!)
|
|
1762
1783
|
let raycaster = state.raycaster;
|
|
@@ -1935,17 +1956,20 @@ function createRoot(canvas) {
|
|
|
1935
1956
|
// Set locals
|
|
1936
1957
|
onCreated = onCreatedCallback;
|
|
1937
1958
|
configured = true;
|
|
1959
|
+
resolve();
|
|
1938
1960
|
return this;
|
|
1939
1961
|
},
|
|
1940
1962
|
render(children) {
|
|
1941
1963
|
// The root has to be configured before it can be rendered
|
|
1942
|
-
if (!configured
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1964
|
+
if (!configured && !pending) this.configure();
|
|
1965
|
+
pending.then(() => {
|
|
1966
|
+
reconciler.updateContainer( /*#__PURE__*/jsx(Provider, {
|
|
1967
|
+
store: store,
|
|
1968
|
+
children: children,
|
|
1969
|
+
onCreated: onCreated,
|
|
1970
|
+
rootElement: canvas
|
|
1971
|
+
}), fiber, null, () => undefined);
|
|
1972
|
+
});
|
|
1949
1973
|
return store;
|
|
1950
1974
|
},
|
|
1951
1975
|
unmount() {
|
|
@@ -380,6 +380,7 @@ function applyProps(object, props) {
|
|
|
380
380
|
if (instance && EVENT_REGEX.test(prop)) {
|
|
381
381
|
if (typeof value === 'function') instance.handlers[prop] = value;else delete instance.handlers[prop];
|
|
382
382
|
instance.eventCount = Object.keys(instance.handlers).length;
|
|
383
|
+
continue;
|
|
383
384
|
}
|
|
384
385
|
|
|
385
386
|
// Ignore setting undefined props
|
|
@@ -620,7 +621,19 @@ function createEvents(store) {
|
|
|
620
621
|
stopped: false
|
|
621
622
|
};
|
|
622
623
|
for (const hit of intersections) {
|
|
623
|
-
|
|
624
|
+
let state = getRootState(hit.object);
|
|
625
|
+
|
|
626
|
+
// If the object is not managed by R3F, it might be parented to an element which is.
|
|
627
|
+
// Traverse upwards until we find a managed parent and use its state instead.
|
|
628
|
+
if (!state) {
|
|
629
|
+
hit.object.traverseAncestors(obj => {
|
|
630
|
+
const parentState = getRootState(obj);
|
|
631
|
+
if (parentState) {
|
|
632
|
+
state = parentState;
|
|
633
|
+
return false;
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
}
|
|
624
637
|
if (state) {
|
|
625
638
|
const {
|
|
626
639
|
raycaster,
|
|
@@ -1256,6 +1269,8 @@ const NoEventPriority = 0;
|
|
|
1256
1269
|
// https://github.com/microsoft/TypeScript/issues/37079
|
|
1257
1270
|
|
|
1258
1271
|
const catalogue = {};
|
|
1272
|
+
const PREFIX_REGEX = /^three(?=[A-Z])/;
|
|
1273
|
+
const toPascalCase = type => `${type[0].toUpperCase()}${type.slice(1)}`;
|
|
1259
1274
|
let i = 0;
|
|
1260
1275
|
const isConstructor = object => typeof object === 'function';
|
|
1261
1276
|
function extend(objects) {
|
|
@@ -1283,6 +1298,8 @@ function validateInstance(type, props) {
|
|
|
1283
1298
|
}
|
|
1284
1299
|
function createInstance(type, props, root) {
|
|
1285
1300
|
var _props$object;
|
|
1301
|
+
// Remove three* prefix from elements
|
|
1302
|
+
type = type.replace(PREFIX_REGEX, '');
|
|
1286
1303
|
validateInstance(type, props);
|
|
1287
1304
|
|
|
1288
1305
|
// Regenerate the R3F instance for primitives to simulate a new object
|
|
@@ -1326,8 +1343,7 @@ function handleContainerEffects(parent, child, beforeChild) {
|
|
|
1326
1343
|
if (!child.object) {
|
|
1327
1344
|
var _child$props$object, _child$props$args;
|
|
1328
1345
|
// Get target from catalogue
|
|
1329
|
-
const
|
|
1330
|
-
const target = catalogue[name];
|
|
1346
|
+
const target = catalogue[toPascalCase(child.type)];
|
|
1331
1347
|
|
|
1332
1348
|
// Create object
|
|
1333
1349
|
child.object = (_child$props$object = child.props.object) != null ? _child$props$object : new target(...((_child$props$args = child.props.args) != null ? _child$props$args : []));
|
|
@@ -1493,8 +1509,7 @@ function swapInstances() {
|
|
|
1493
1509
|
if (parent) {
|
|
1494
1510
|
var _instance$props$objec, _instance$props$args;
|
|
1495
1511
|
// Get target from catalogue
|
|
1496
|
-
const
|
|
1497
|
-
const target = catalogue[name];
|
|
1512
|
+
const target = catalogue[toPascalCase(instance.type)];
|
|
1498
1513
|
|
|
1499
1514
|
// Create object
|
|
1500
1515
|
instance.object = (_instance$props$objec = instance.props.object) != null ? _instance$props$objec : new target(...((_instance$props$args = instance.props.args) != null ? _instance$props$args : []));
|
|
@@ -1663,20 +1678,6 @@ const shallowLoose = {
|
|
|
1663
1678
|
objects: 'shallow',
|
|
1664
1679
|
strict: false
|
|
1665
1680
|
};
|
|
1666
|
-
async function createRendererInstance(gl, canvas) {
|
|
1667
|
-
const defaultProps = {
|
|
1668
|
-
canvas: canvas,
|
|
1669
|
-
powerPreference: 'high-performance',
|
|
1670
|
-
antialias: true,
|
|
1671
|
-
alpha: true
|
|
1672
|
-
};
|
|
1673
|
-
const customRenderer = typeof gl === 'function' ? await gl(defaultProps) : gl;
|
|
1674
|
-
if (isRenderer(customRenderer)) return customRenderer;
|
|
1675
|
-
return new THREE__namespace.WebGLRenderer({
|
|
1676
|
-
...defaultProps,
|
|
1677
|
-
...gl
|
|
1678
|
-
});
|
|
1679
|
-
}
|
|
1680
1681
|
function computeInitialSize(canvas, size) {
|
|
1681
1682
|
if (!size && typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
|
|
1682
1683
|
const {
|
|
@@ -1754,10 +1755,13 @@ function createRoot(canvas) {
|
|
|
1754
1755
|
|
|
1755
1756
|
// Locals
|
|
1756
1757
|
let onCreated;
|
|
1757
|
-
let configured = false;
|
|
1758
1758
|
let lastCamera;
|
|
1759
|
+
let configured = false;
|
|
1760
|
+
let pending = null;
|
|
1759
1761
|
return {
|
|
1760
1762
|
async configure(props = {}) {
|
|
1763
|
+
let resolve;
|
|
1764
|
+
pending = new Promise(_resolve => resolve = _resolve);
|
|
1761
1765
|
let {
|
|
1762
1766
|
gl: glConfig,
|
|
1763
1767
|
size: propsSize,
|
|
@@ -1780,9 +1784,26 @@ function createRoot(canvas) {
|
|
|
1780
1784
|
|
|
1781
1785
|
// Set up renderer (one time only!)
|
|
1782
1786
|
let gl = state.gl;
|
|
1783
|
-
if (!state.gl)
|
|
1784
|
-
|
|
1785
|
-
|
|
1787
|
+
if (!state.gl) {
|
|
1788
|
+
const defaultProps = {
|
|
1789
|
+
canvas: canvas,
|
|
1790
|
+
powerPreference: 'high-performance',
|
|
1791
|
+
antialias: true,
|
|
1792
|
+
alpha: true
|
|
1793
|
+
};
|
|
1794
|
+
const customRenderer = typeof glConfig === 'function' ? await glConfig(defaultProps) : glConfig;
|
|
1795
|
+
if (isRenderer(customRenderer)) {
|
|
1796
|
+
gl = customRenderer;
|
|
1797
|
+
} else {
|
|
1798
|
+
gl = new THREE__namespace.WebGLRenderer({
|
|
1799
|
+
...defaultProps,
|
|
1800
|
+
...glConfig
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
state.set({
|
|
1804
|
+
gl
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1786
1807
|
|
|
1787
1808
|
// Set up raycaster (one time only!)
|
|
1788
1809
|
let raycaster = state.raycaster;
|
|
@@ -1961,17 +1982,20 @@ function createRoot(canvas) {
|
|
|
1961
1982
|
// Set locals
|
|
1962
1983
|
onCreated = onCreatedCallback;
|
|
1963
1984
|
configured = true;
|
|
1985
|
+
resolve();
|
|
1964
1986
|
return this;
|
|
1965
1987
|
},
|
|
1966
1988
|
render(children) {
|
|
1967
1989
|
// The root has to be configured before it can be rendered
|
|
1968
|
-
if (!configured
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1990
|
+
if (!configured && !pending) this.configure();
|
|
1991
|
+
pending.then(() => {
|
|
1992
|
+
reconciler.updateContainer( /*#__PURE__*/jsxRuntime.jsx(Provider, {
|
|
1993
|
+
store: store,
|
|
1994
|
+
children: children,
|
|
1995
|
+
onCreated: onCreated,
|
|
1996
|
+
rootElement: canvas
|
|
1997
|
+
}), fiber, null, () => undefined);
|
|
1998
|
+
});
|
|
1975
1999
|
return store;
|
|
1976
2000
|
},
|
|
1977
2001
|
unmount() {
|
|
@@ -380,6 +380,7 @@ function applyProps(object, props) {
|
|
|
380
380
|
if (instance && EVENT_REGEX.test(prop)) {
|
|
381
381
|
if (typeof value === 'function') instance.handlers[prop] = value;else delete instance.handlers[prop];
|
|
382
382
|
instance.eventCount = Object.keys(instance.handlers).length;
|
|
383
|
+
continue;
|
|
383
384
|
}
|
|
384
385
|
|
|
385
386
|
// Ignore setting undefined props
|
|
@@ -620,7 +621,19 @@ function createEvents(store) {
|
|
|
620
621
|
stopped: false
|
|
621
622
|
};
|
|
622
623
|
for (const hit of intersections) {
|
|
623
|
-
|
|
624
|
+
let state = getRootState(hit.object);
|
|
625
|
+
|
|
626
|
+
// If the object is not managed by R3F, it might be parented to an element which is.
|
|
627
|
+
// Traverse upwards until we find a managed parent and use its state instead.
|
|
628
|
+
if (!state) {
|
|
629
|
+
hit.object.traverseAncestors(obj => {
|
|
630
|
+
const parentState = getRootState(obj);
|
|
631
|
+
if (parentState) {
|
|
632
|
+
state = parentState;
|
|
633
|
+
return false;
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
}
|
|
624
637
|
if (state) {
|
|
625
638
|
const {
|
|
626
639
|
raycaster,
|
|
@@ -1256,6 +1269,8 @@ const NoEventPriority = 0;
|
|
|
1256
1269
|
// https://github.com/microsoft/TypeScript/issues/37079
|
|
1257
1270
|
|
|
1258
1271
|
const catalogue = {};
|
|
1272
|
+
const PREFIX_REGEX = /^three(?=[A-Z])/;
|
|
1273
|
+
const toPascalCase = type => `${type[0].toUpperCase()}${type.slice(1)}`;
|
|
1259
1274
|
let i = 0;
|
|
1260
1275
|
const isConstructor = object => typeof object === 'function';
|
|
1261
1276
|
function extend(objects) {
|
|
@@ -1283,6 +1298,8 @@ function validateInstance(type, props) {
|
|
|
1283
1298
|
}
|
|
1284
1299
|
function createInstance(type, props, root) {
|
|
1285
1300
|
var _props$object;
|
|
1301
|
+
// Remove three* prefix from elements
|
|
1302
|
+
type = type.replace(PREFIX_REGEX, '');
|
|
1286
1303
|
validateInstance(type, props);
|
|
1287
1304
|
|
|
1288
1305
|
// Regenerate the R3F instance for primitives to simulate a new object
|
|
@@ -1326,8 +1343,7 @@ function handleContainerEffects(parent, child, beforeChild) {
|
|
|
1326
1343
|
if (!child.object) {
|
|
1327
1344
|
var _child$props$object, _child$props$args;
|
|
1328
1345
|
// Get target from catalogue
|
|
1329
|
-
const
|
|
1330
|
-
const target = catalogue[name];
|
|
1346
|
+
const target = catalogue[toPascalCase(child.type)];
|
|
1331
1347
|
|
|
1332
1348
|
// Create object
|
|
1333
1349
|
child.object = (_child$props$object = child.props.object) != null ? _child$props$object : new target(...((_child$props$args = child.props.args) != null ? _child$props$args : []));
|
|
@@ -1493,8 +1509,7 @@ function swapInstances() {
|
|
|
1493
1509
|
if (parent) {
|
|
1494
1510
|
var _instance$props$objec, _instance$props$args;
|
|
1495
1511
|
// Get target from catalogue
|
|
1496
|
-
const
|
|
1497
|
-
const target = catalogue[name];
|
|
1512
|
+
const target = catalogue[toPascalCase(instance.type)];
|
|
1498
1513
|
|
|
1499
1514
|
// Create object
|
|
1500
1515
|
instance.object = (_instance$props$objec = instance.props.object) != null ? _instance$props$objec : new target(...((_instance$props$args = instance.props.args) != null ? _instance$props$args : []));
|
|
@@ -1663,20 +1678,6 @@ const shallowLoose = {
|
|
|
1663
1678
|
objects: 'shallow',
|
|
1664
1679
|
strict: false
|
|
1665
1680
|
};
|
|
1666
|
-
async function createRendererInstance(gl, canvas) {
|
|
1667
|
-
const defaultProps = {
|
|
1668
|
-
canvas: canvas,
|
|
1669
|
-
powerPreference: 'high-performance',
|
|
1670
|
-
antialias: true,
|
|
1671
|
-
alpha: true
|
|
1672
|
-
};
|
|
1673
|
-
const customRenderer = typeof gl === 'function' ? await gl(defaultProps) : gl;
|
|
1674
|
-
if (isRenderer(customRenderer)) return customRenderer;
|
|
1675
|
-
return new THREE__namespace.WebGLRenderer({
|
|
1676
|
-
...defaultProps,
|
|
1677
|
-
...gl
|
|
1678
|
-
});
|
|
1679
|
-
}
|
|
1680
1681
|
function computeInitialSize(canvas, size) {
|
|
1681
1682
|
if (!size && typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement && canvas.parentElement) {
|
|
1682
1683
|
const {
|
|
@@ -1754,10 +1755,13 @@ function createRoot(canvas) {
|
|
|
1754
1755
|
|
|
1755
1756
|
// Locals
|
|
1756
1757
|
let onCreated;
|
|
1757
|
-
let configured = false;
|
|
1758
1758
|
let lastCamera;
|
|
1759
|
+
let configured = false;
|
|
1760
|
+
let pending = null;
|
|
1759
1761
|
return {
|
|
1760
1762
|
async configure(props = {}) {
|
|
1763
|
+
let resolve;
|
|
1764
|
+
pending = new Promise(_resolve => resolve = _resolve);
|
|
1761
1765
|
let {
|
|
1762
1766
|
gl: glConfig,
|
|
1763
1767
|
size: propsSize,
|
|
@@ -1780,9 +1784,26 @@ function createRoot(canvas) {
|
|
|
1780
1784
|
|
|
1781
1785
|
// Set up renderer (one time only!)
|
|
1782
1786
|
let gl = state.gl;
|
|
1783
|
-
if (!state.gl)
|
|
1784
|
-
|
|
1785
|
-
|
|
1787
|
+
if (!state.gl) {
|
|
1788
|
+
const defaultProps = {
|
|
1789
|
+
canvas: canvas,
|
|
1790
|
+
powerPreference: 'high-performance',
|
|
1791
|
+
antialias: true,
|
|
1792
|
+
alpha: true
|
|
1793
|
+
};
|
|
1794
|
+
const customRenderer = typeof glConfig === 'function' ? await glConfig(defaultProps) : glConfig;
|
|
1795
|
+
if (isRenderer(customRenderer)) {
|
|
1796
|
+
gl = customRenderer;
|
|
1797
|
+
} else {
|
|
1798
|
+
gl = new THREE__namespace.WebGLRenderer({
|
|
1799
|
+
...defaultProps,
|
|
1800
|
+
...glConfig
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
state.set({
|
|
1804
|
+
gl
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1786
1807
|
|
|
1787
1808
|
// Set up raycaster (one time only!)
|
|
1788
1809
|
let raycaster = state.raycaster;
|
|
@@ -1961,17 +1982,20 @@ function createRoot(canvas) {
|
|
|
1961
1982
|
// Set locals
|
|
1962
1983
|
onCreated = onCreatedCallback;
|
|
1963
1984
|
configured = true;
|
|
1985
|
+
resolve();
|
|
1964
1986
|
return this;
|
|
1965
1987
|
},
|
|
1966
1988
|
render(children) {
|
|
1967
1989
|
// The root has to be configured before it can be rendered
|
|
1968
|
-
if (!configured
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1990
|
+
if (!configured && !pending) this.configure();
|
|
1991
|
+
pending.then(() => {
|
|
1992
|
+
reconciler.updateContainer( /*#__PURE__*/jsxRuntime.jsx(Provider, {
|
|
1993
|
+
store: store,
|
|
1994
|
+
children: children,
|
|
1995
|
+
onCreated: onCreated,
|
|
1996
|
+
rootElement: canvas
|
|
1997
|
+
}), fiber, null, () => undefined);
|
|
1998
|
+
});
|
|
1975
1999
|
return store;
|
|
1976
2000
|
},
|
|
1977
2001
|
unmount() {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('./events-
|
|
5
|
+
var events = require('./events-56f909a9.cjs.dev.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var useMeasure = require('react-use-measure');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('./events-
|
|
5
|
+
var events = require('./events-858f07e7.cjs.prod.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var useMeasure = require('react-use-measure');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as extend, u as useBridge, a as useMutableCallback, b as useIsomorphicLayoutEffect, c as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents } from './events-
|
|
2
|
-
export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, f as events, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './events-
|
|
1
|
+
import { e as extend, u as useBridge, a as useMutableCallback, b as useIsomorphicLayoutEffect, c as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents } from './events-12fa3319.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, f as events, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from './events-12fa3319.esm.js';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
5
|
import useMeasure from 'react-use-measure';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('../../dist/events-
|
|
5
|
+
var events = require('../../dist/events-56f909a9.cjs.dev.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var reactNative = require('react-native');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var events = require('../../dist/events-
|
|
5
|
+
var events = require('../../dist/events-858f07e7.cjs.prod.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var THREE = require('three');
|
|
8
8
|
var reactNative = require('react-native');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as extend, u as useBridge, a as useMutableCallback, c as createRoot, b as useIsomorphicLayoutEffect, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents, g as createEvents } from '../../dist/events-
|
|
2
|
-
export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/events-
|
|
1
|
+
import { e as extend, u as useBridge, a as useMutableCallback, c as createRoot, b as useIsomorphicLayoutEffect, E as ErrorBoundary, B as Block, d as unmountComponentAtNode, f as createPointerEvents, g as createEvents } from '../../dist/events-12fa3319.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, _ as _roots, w as act, k as addAfterEffect, j as addEffect, l as addTail, n as advance, q as applyProps, x as buildGraph, p as context, g as createEvents, o as createPortal, c as createRoot, v as dispose, e as extend, h as flushGlobalEffects, s as getRootState, m as invalidate, r as reconciler, d as unmountComponentAtNode, C as useFrame, D as useGraph, y as useInstanceHandle, F as useLoader, z as useStore, A as useThree } from '../../dist/events-12fa3319.esm.js';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import * as THREE from 'three';
|
|
5
5
|
import { PanResponder, PixelRatio, StyleSheet, View, Platform, Image, NativeModules } from 'react-native';
|