@react-three/fiber 8.0.8 → 8.0.9
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/events.d.ts +69 -69
- package/dist/declarations/src/core/hooks.d.ts +21 -21
- package/dist/declarations/src/core/index.d.ts +56 -56
- package/dist/declarations/src/core/loop.d.ts +13 -13
- package/dist/declarations/src/core/renderer.d.ts +51 -51
- package/dist/declarations/src/core/store.d.ts +91 -91
- package/dist/declarations/src/core/utils.d.ts +80 -83
- package/dist/declarations/src/index.d.ts +10 -10
- package/dist/declarations/src/native/Canvas.d.ts +8 -8
- package/dist/declarations/src/native/events.d.ts +4 -4
- package/dist/declarations/src/native.d.ts +10 -10
- package/dist/declarations/src/three-types.d.ts +327 -327
- package/dist/declarations/src/web/Canvas.d.ts +9 -9
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-b8ee55f0.cjs.dev.js → index-49237346.cjs.dev.js} +9 -10
- package/dist/{index-c4e0ac66.cjs.prod.js → index-4dae9cc6.cjs.prod.js} +9 -10
- package/dist/{index-548cf96a.esm.js → index-4e14a95b.esm.js} +9 -10
- package/dist/react-three-fiber.cjs.dev.js +10 -10
- package/dist/react-three-fiber.cjs.prod.js +10 -10
- package/dist/react-three-fiber.esm.js +11 -11
- package/native/dist/react-three-fiber-native.cjs.dev.js +8 -9
- package/native/dist/react-three-fiber-native.cjs.prod.js +8 -9
- package/native/dist/react-three-fiber-native.esm.js +9 -10
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
-
import { RenderProps } from '../core';
|
|
4
|
-
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
fallback?: React.ReactNode;
|
|
7
|
-
resize?: ResizeOptions;
|
|
8
|
-
}
|
|
9
|
-
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { Options as ResizeOptions } from 'react-use-measure';
|
|
3
|
+
import { RenderProps } from '../core';
|
|
4
|
+
export interface Props extends Omit<RenderProps<HTMLCanvasElement>, 'size'>, React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
fallback?: React.ReactNode;
|
|
7
|
+
resize?: ResizeOptions;
|
|
8
|
+
}
|
|
9
|
+
export declare const Canvas: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLCanvasElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseBoundStore } from 'zustand';
|
|
2
|
-
import { RootState } from '../core/store';
|
|
3
|
-
import { EventManager } from '../core/events';
|
|
4
|
-
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
1
|
+
import { UseBoundStore } from 'zustand';
|
|
2
|
+
import { RootState } from '../core/store';
|
|
3
|
+
import { EventManager } from '../core/events';
|
|
4
|
+
export declare function createPointerEvents(store: UseBoundStore<RootState>): EventManager<HTMLElement>;
|
|
@@ -44,6 +44,11 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
44
44
|
// useLayoutEffect on the client.
|
|
45
45
|
const isSSR = typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
|
|
46
46
|
const useIsomorphicLayoutEffect = isSSR ? React__namespace.useEffect : React__namespace.useLayoutEffect;
|
|
47
|
+
function useMutableCallback(fn) {
|
|
48
|
+
const ref = React__namespace.useRef(fn);
|
|
49
|
+
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
50
|
+
return ref;
|
|
51
|
+
}
|
|
47
52
|
function Block({
|
|
48
53
|
set
|
|
49
54
|
}) {
|
|
@@ -75,11 +80,6 @@ ErrorBoundary.getDerivedStateFromError = () => ({
|
|
|
75
80
|
error: true
|
|
76
81
|
});
|
|
77
82
|
|
|
78
|
-
function useMemoizedFn(fn) {
|
|
79
|
-
const fnRef = React__namespace.useRef(fn);
|
|
80
|
-
useIsomorphicLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
81
|
-
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
82
|
-
}
|
|
83
83
|
const DEFAULT = '__default';
|
|
84
84
|
const isDiffSet = def => def && !!def.memoized && !!def.changes;
|
|
85
85
|
function calculateDpr(dpr) {
|
|
@@ -1580,12 +1580,11 @@ function useThree(selector = state => state, equalityFn) {
|
|
|
1580
1580
|
|
|
1581
1581
|
function useFrame(callback, renderPriority = 0) {
|
|
1582
1582
|
const store = useStore();
|
|
1583
|
-
const subscribe = store.getState().internal.subscribe; //
|
|
1583
|
+
const subscribe = store.getState().internal.subscribe; // Memoize ref
|
|
1584
1584
|
|
|
1585
|
-
const ref =
|
|
1586
|
-
React__namespace.useLayoutEffect(() => void (ref.current = callback), [callback]); // Subscribe on mount, unsubscribe on unmount
|
|
1585
|
+
const ref = useMutableCallback(callback); // Subscribe on mount, unsubscribe on unmount
|
|
1587
1586
|
|
|
1588
|
-
|
|
1587
|
+
useIsomorphicLayoutEffect(() => subscribe(ref, renderPriority, store), [renderPriority, subscribe, store]);
|
|
1589
1588
|
return null;
|
|
1590
1589
|
}
|
|
1591
1590
|
/**
|
|
@@ -2039,6 +2038,6 @@ exports.useFrame = useFrame;
|
|
|
2039
2038
|
exports.useGraph = useGraph;
|
|
2040
2039
|
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
2041
2040
|
exports.useLoader = useLoader;
|
|
2042
|
-
exports.
|
|
2041
|
+
exports.useMutableCallback = useMutableCallback;
|
|
2043
2042
|
exports.useStore = useStore;
|
|
2044
2043
|
exports.useThree = useThree;
|
|
@@ -44,6 +44,11 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
44
44
|
// useLayoutEffect on the client.
|
|
45
45
|
const isSSR = typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
|
|
46
46
|
const useIsomorphicLayoutEffect = isSSR ? React__namespace.useEffect : React__namespace.useLayoutEffect;
|
|
47
|
+
function useMutableCallback(fn) {
|
|
48
|
+
const ref = React__namespace.useRef(fn);
|
|
49
|
+
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
50
|
+
return ref;
|
|
51
|
+
}
|
|
47
52
|
function Block({
|
|
48
53
|
set
|
|
49
54
|
}) {
|
|
@@ -75,11 +80,6 @@ ErrorBoundary.getDerivedStateFromError = () => ({
|
|
|
75
80
|
error: true
|
|
76
81
|
});
|
|
77
82
|
|
|
78
|
-
function useMemoizedFn(fn) {
|
|
79
|
-
const fnRef = React__namespace.useRef(fn);
|
|
80
|
-
useIsomorphicLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
81
|
-
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
82
|
-
}
|
|
83
83
|
const DEFAULT = '__default';
|
|
84
84
|
const isDiffSet = def => def && !!def.memoized && !!def.changes;
|
|
85
85
|
function calculateDpr(dpr) {
|
|
@@ -1580,12 +1580,11 @@ function useThree(selector = state => state, equalityFn) {
|
|
|
1580
1580
|
|
|
1581
1581
|
function useFrame(callback, renderPriority = 0) {
|
|
1582
1582
|
const store = useStore();
|
|
1583
|
-
const subscribe = store.getState().internal.subscribe; //
|
|
1583
|
+
const subscribe = store.getState().internal.subscribe; // Memoize ref
|
|
1584
1584
|
|
|
1585
|
-
const ref =
|
|
1586
|
-
React__namespace.useLayoutEffect(() => void (ref.current = callback), [callback]); // Subscribe on mount, unsubscribe on unmount
|
|
1585
|
+
const ref = useMutableCallback(callback); // Subscribe on mount, unsubscribe on unmount
|
|
1587
1586
|
|
|
1588
|
-
|
|
1587
|
+
useIsomorphicLayoutEffect(() => subscribe(ref, renderPriority, store), [renderPriority, subscribe, store]);
|
|
1589
1588
|
return null;
|
|
1590
1589
|
}
|
|
1591
1590
|
/**
|
|
@@ -2039,6 +2038,6 @@ exports.useFrame = useFrame;
|
|
|
2039
2038
|
exports.useGraph = useGraph;
|
|
2040
2039
|
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
2041
2040
|
exports.useLoader = useLoader;
|
|
2042
|
-
exports.
|
|
2041
|
+
exports.useMutableCallback = useMutableCallback;
|
|
2043
2042
|
exports.useStore = useStore;
|
|
2044
2043
|
exports.useThree = useThree;
|
|
@@ -15,6 +15,11 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
15
15
|
// useLayoutEffect on the client.
|
|
16
16
|
const isSSR = typeof window === 'undefined' || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent);
|
|
17
17
|
const useIsomorphicLayoutEffect = isSSR ? React.useEffect : React.useLayoutEffect;
|
|
18
|
+
function useMutableCallback(fn) {
|
|
19
|
+
const ref = React.useRef(fn);
|
|
20
|
+
useIsomorphicLayoutEffect(() => void (ref.current = fn), [fn]);
|
|
21
|
+
return ref;
|
|
22
|
+
}
|
|
18
23
|
function Block({
|
|
19
24
|
set
|
|
20
25
|
}) {
|
|
@@ -46,11 +51,6 @@ ErrorBoundary.getDerivedStateFromError = () => ({
|
|
|
46
51
|
error: true
|
|
47
52
|
});
|
|
48
53
|
|
|
49
|
-
function useMemoizedFn(fn) {
|
|
50
|
-
const fnRef = React.useRef(fn);
|
|
51
|
-
useIsomorphicLayoutEffect(() => void (fnRef.current = fn), [fn]);
|
|
52
|
-
return (...args) => fnRef.current == null ? void 0 : fnRef.current(...args);
|
|
53
|
-
}
|
|
54
54
|
const DEFAULT = '__default';
|
|
55
55
|
const isDiffSet = def => def && !!def.memoized && !!def.changes;
|
|
56
56
|
function calculateDpr(dpr) {
|
|
@@ -1551,12 +1551,11 @@ function useThree(selector = state => state, equalityFn) {
|
|
|
1551
1551
|
|
|
1552
1552
|
function useFrame(callback, renderPriority = 0) {
|
|
1553
1553
|
const store = useStore();
|
|
1554
|
-
const subscribe = store.getState().internal.subscribe; //
|
|
1554
|
+
const subscribe = store.getState().internal.subscribe; // Memoize ref
|
|
1555
1555
|
|
|
1556
|
-
const ref =
|
|
1557
|
-
React.useLayoutEffect(() => void (ref.current = callback), [callback]); // Subscribe on mount, unsubscribe on unmount
|
|
1556
|
+
const ref = useMutableCallback(callback); // Subscribe on mount, unsubscribe on unmount
|
|
1558
1557
|
|
|
1559
|
-
|
|
1558
|
+
useIsomorphicLayoutEffect(() => subscribe(ref, renderPriority, store), [renderPriority, subscribe, store]);
|
|
1560
1559
|
return null;
|
|
1561
1560
|
}
|
|
1562
1561
|
/**
|
|
@@ -1983,4 +1982,4 @@ reconciler.injectIntoDevTools({
|
|
|
1983
1982
|
});
|
|
1984
1983
|
const act = React.unstable_act;
|
|
1985
1984
|
|
|
1986
|
-
export { useGraph as A, Block as B, useLoader as C, 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, omit as o, pick as p, addTail as q, render as r, getRootState as s, threeTypes as t,
|
|
1985
|
+
export { useGraph as A, Block as B, useLoader as C, 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, omit as o, pick as p, addTail as q, render as r, getRootState as s, threeTypes as t, useMutableCallback as u, act as v, roots as w, useStore as x, useThree as y, useFrame as z };
|
|
@@ -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-49237346.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -130,6 +130,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
130
130
|
fallback,
|
|
131
131
|
resize,
|
|
132
132
|
style,
|
|
133
|
+
onPointerMissed,
|
|
133
134
|
events = createPointerEvents,
|
|
134
135
|
...props
|
|
135
136
|
}, forwardedRef) {
|
|
@@ -137,7 +138,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
137
138
|
// This will include the entire THREE namespace by default, users can extend
|
|
138
139
|
// their own elements by using the createRoot API instead
|
|
139
140
|
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
140
|
-
const onPointerMissed = index.useMemoizedFn(props.onPointerMissed);
|
|
141
141
|
const [containerRef, {
|
|
142
142
|
width,
|
|
143
143
|
height
|
|
@@ -152,12 +152,9 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
152
152
|
const meshRef = React__namespace.useRef(null);
|
|
153
153
|
const canvasRef = React__namespace.useRef(null);
|
|
154
154
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const divProps = index.omit({ ...props,
|
|
159
|
-
onPointerMissed
|
|
160
|
-
}, CANVAS_PROPS);
|
|
155
|
+
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
156
|
+
const canvasProps = index.pick(props, CANVAS_PROPS);
|
|
157
|
+
const divProps = index.omit(props, CANVAS_PROPS);
|
|
161
158
|
const [block, setBlock] = React__namespace.useState(false);
|
|
162
159
|
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
163
160
|
|
|
@@ -169,6 +166,8 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
169
166
|
if (width > 0 && height > 0 && canvas) {
|
|
170
167
|
if (!root.current) root.current = index.createRoot(canvas);
|
|
171
168
|
root.current.configure({ ...canvasProps,
|
|
169
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
170
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
172
171
|
onCreated: state => {
|
|
173
172
|
state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
|
|
174
173
|
canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
|
|
@@ -189,8 +188,9 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
189
188
|
}
|
|
190
189
|
|
|
191
190
|
index.useIsomorphicLayoutEffect(() => {
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
setCanvas(canvasRef.current);
|
|
192
|
+
}, []);
|
|
193
|
+
React__namespace.useEffect(() => {
|
|
194
194
|
return () => index.unmountComponentAtNode(canvas);
|
|
195
195
|
}, []);
|
|
196
196
|
return /*#__PURE__*/React__namespace.createElement("div", _extends({
|
|
@@ -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-4dae9cc6.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -130,6 +130,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
130
130
|
fallback,
|
|
131
131
|
resize,
|
|
132
132
|
style,
|
|
133
|
+
onPointerMissed,
|
|
133
134
|
events = createPointerEvents,
|
|
134
135
|
...props
|
|
135
136
|
}, forwardedRef) {
|
|
@@ -137,7 +138,6 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
137
138
|
// This will include the entire THREE namespace by default, users can extend
|
|
138
139
|
// their own elements by using the createRoot API instead
|
|
139
140
|
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
140
|
-
const onPointerMissed = index.useMemoizedFn(props.onPointerMissed);
|
|
141
141
|
const [containerRef, {
|
|
142
142
|
width,
|
|
143
143
|
height
|
|
@@ -152,12 +152,9 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
152
152
|
const meshRef = React__namespace.useRef(null);
|
|
153
153
|
const canvasRef = React__namespace.useRef(null);
|
|
154
154
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const divProps = index.omit({ ...props,
|
|
159
|
-
onPointerMissed
|
|
160
|
-
}, CANVAS_PROPS);
|
|
155
|
+
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
156
|
+
const canvasProps = index.pick(props, CANVAS_PROPS);
|
|
157
|
+
const divProps = index.omit(props, CANVAS_PROPS);
|
|
161
158
|
const [block, setBlock] = React__namespace.useState(false);
|
|
162
159
|
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
163
160
|
|
|
@@ -169,6 +166,8 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
169
166
|
if (width > 0 && height > 0 && canvas) {
|
|
170
167
|
if (!root.current) root.current = index.createRoot(canvas);
|
|
171
168
|
root.current.configure({ ...canvasProps,
|
|
169
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
170
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
172
171
|
onCreated: state => {
|
|
173
172
|
state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
|
|
174
173
|
canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
|
|
@@ -189,8 +188,9 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
189
188
|
}
|
|
190
189
|
|
|
191
190
|
index.useIsomorphicLayoutEffect(() => {
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
setCanvas(canvasRef.current);
|
|
192
|
+
}, []);
|
|
193
|
+
React__namespace.useEffect(() => {
|
|
194
194
|
return () => index.unmountComponentAtNode(canvas);
|
|
195
195
|
}, []);
|
|
196
196
|
return /*#__PURE__*/React__namespace.createElement("div", _extends({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as
|
|
2
|
-
export { t as ReactThreeFiber, w as _roots, v as act, n as addAfterEffect, m as addEffect, q as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, s as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, C as useLoader, x as useStore, y as useThree } from './index-
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, p as pick, o as omit, a as createRoot, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-4e14a95b.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, w as _roots, v as act, n as addAfterEffect, m as addEffect, q as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, s as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, C as useLoader, x as useStore, y as useThree } from './index-4e14a95b.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';
|
|
@@ -100,6 +100,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
100
100
|
fallback,
|
|
101
101
|
resize,
|
|
102
102
|
style,
|
|
103
|
+
onPointerMissed,
|
|
103
104
|
events = createPointerEvents,
|
|
104
105
|
...props
|
|
105
106
|
}, forwardedRef) {
|
|
@@ -107,7 +108,6 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
107
108
|
// This will include the entire THREE namespace by default, users can extend
|
|
108
109
|
// their own elements by using the createRoot API instead
|
|
109
110
|
React.useMemo(() => extend(THREE), []);
|
|
110
|
-
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
111
111
|
const [containerRef, {
|
|
112
112
|
width,
|
|
113
113
|
height
|
|
@@ -122,12 +122,9 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
122
122
|
const meshRef = React.useRef(null);
|
|
123
123
|
const canvasRef = React.useRef(null);
|
|
124
124
|
const [canvas, setCanvas] = React.useState(null);
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const divProps = omit({ ...props,
|
|
129
|
-
onPointerMissed
|
|
130
|
-
}, CANVAS_PROPS);
|
|
125
|
+
const handlePointerMissed = useMutableCallback(onPointerMissed);
|
|
126
|
+
const canvasProps = pick(props, CANVAS_PROPS);
|
|
127
|
+
const divProps = omit(props, CANVAS_PROPS);
|
|
131
128
|
const [block, setBlock] = React.useState(false);
|
|
132
129
|
const [error, setError] = React.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
133
130
|
|
|
@@ -139,6 +136,8 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
139
136
|
if (width > 0 && height > 0 && canvas) {
|
|
140
137
|
if (!root.current) root.current = createRoot(canvas);
|
|
141
138
|
root.current.configure({ ...canvasProps,
|
|
139
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
140
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
142
141
|
onCreated: state => {
|
|
143
142
|
state.events.connect == null ? void 0 : state.events.connect(meshRef.current);
|
|
144
143
|
canvasProps.onCreated == null ? void 0 : canvasProps.onCreated(state);
|
|
@@ -159,8 +158,9 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
useIsomorphicLayoutEffect(() => {
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
setCanvas(canvasRef.current);
|
|
162
|
+
}, []);
|
|
163
|
+
React.useEffect(() => {
|
|
164
164
|
return () => unmountComponentAtNode(canvas);
|
|
165
165
|
}, []);
|
|
166
166
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
@@ -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-49237346.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');
|
|
@@ -137,13 +137,13 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
137
137
|
children,
|
|
138
138
|
style,
|
|
139
139
|
events,
|
|
140
|
+
onPointerMissed,
|
|
140
141
|
...props
|
|
141
142
|
}, forwardedRef) => {
|
|
142
143
|
// Create a known catalogue of Threejs-native elements
|
|
143
144
|
// This will include the entire THREE namespace by default, users can extend
|
|
144
145
|
// their own elements by using the createRoot API instead
|
|
145
146
|
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
146
|
-
const onPointerMissed = index.useMemoizedFn(props.onPointerMissed);
|
|
147
147
|
const [{
|
|
148
148
|
width,
|
|
149
149
|
height
|
|
@@ -153,12 +153,9 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
153
153
|
});
|
|
154
154
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
155
155
|
const [bind, setBind] = React__namespace.useState();
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const viewProps = index.omit({ ...props,
|
|
160
|
-
onPointerMissed
|
|
161
|
-
}, CANVAS_PROPS);
|
|
156
|
+
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
157
|
+
const canvasProps = index.pick(props, CANVAS_PROPS);
|
|
158
|
+
const viewProps = index.omit(props, CANVAS_PROPS);
|
|
162
159
|
const [block, setBlock] = React__namespace.useState(false);
|
|
163
160
|
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
164
161
|
|
|
@@ -210,6 +207,8 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
210
207
|
};
|
|
211
208
|
|
|
212
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),
|
|
213
212
|
// expo-gl can only render at native dpr/resolution
|
|
214
213
|
// https://github.com/expo/expo-three/issues/39
|
|
215
214
|
dpr: reactNative.PixelRatio.get(),
|
|
@@ -231,7 +230,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
231
230
|
|
|
232
231
|
React__namespace.useEffect(() => {
|
|
233
232
|
return () => index.unmountComponentAtNode(canvas);
|
|
234
|
-
}, [
|
|
233
|
+
}, []);
|
|
235
234
|
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, viewProps, {
|
|
236
235
|
ref: mergeRefs__default['default']([viewRef, forwardedRef]),
|
|
237
236
|
onLayout: onLayout,
|
|
@@ -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-4dae9cc6.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');
|
|
@@ -137,13 +137,13 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
137
137
|
children,
|
|
138
138
|
style,
|
|
139
139
|
events,
|
|
140
|
+
onPointerMissed,
|
|
140
141
|
...props
|
|
141
142
|
}, forwardedRef) => {
|
|
142
143
|
// Create a known catalogue of Threejs-native elements
|
|
143
144
|
// This will include the entire THREE namespace by default, users can extend
|
|
144
145
|
// their own elements by using the createRoot API instead
|
|
145
146
|
React__namespace.useMemo(() => index.extend(THREE__namespace), []);
|
|
146
|
-
const onPointerMissed = index.useMemoizedFn(props.onPointerMissed);
|
|
147
147
|
const [{
|
|
148
148
|
width,
|
|
149
149
|
height
|
|
@@ -153,12 +153,9 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
153
153
|
});
|
|
154
154
|
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
155
155
|
const [bind, setBind] = React__namespace.useState();
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const viewProps = index.omit({ ...props,
|
|
160
|
-
onPointerMissed
|
|
161
|
-
}, CANVAS_PROPS);
|
|
156
|
+
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
157
|
+
const canvasProps = index.pick(props, CANVAS_PROPS);
|
|
158
|
+
const viewProps = index.omit(props, CANVAS_PROPS);
|
|
162
159
|
const [block, setBlock] = React__namespace.useState(false);
|
|
163
160
|
const [error, setError] = React__namespace.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
164
161
|
|
|
@@ -210,6 +207,8 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
210
207
|
};
|
|
211
208
|
|
|
212
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),
|
|
213
212
|
// expo-gl can only render at native dpr/resolution
|
|
214
213
|
// https://github.com/expo/expo-three/issues/39
|
|
215
214
|
dpr: reactNative.PixelRatio.get(),
|
|
@@ -231,7 +230,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
231
230
|
|
|
232
231
|
React__namespace.useEffect(() => {
|
|
233
232
|
return () => index.unmountComponentAtNode(canvas);
|
|
234
|
-
}, [
|
|
233
|
+
}, []);
|
|
235
234
|
return /*#__PURE__*/React__namespace.createElement(reactNative.View, _extends({}, viewProps, {
|
|
236
235
|
ref: mergeRefs__default['default']([viewRef, forwardedRef]),
|
|
237
236
|
onLayout: onLayout,
|
|
@@ -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
|
|
4
|
-
export { t as ReactThreeFiber, w as _roots, v as act, n as addAfterEffect, m as addEffect, q as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, s as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, C as useLoader, x as useStore, y as useThree } from '../../dist/index-
|
|
3
|
+
import { c as createEvents, e as extend, u as useMutableCallback, p as pick, o as omit, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-4e14a95b.esm.js';
|
|
4
|
+
export { t as ReactThreeFiber, w as _roots, v as act, n as addAfterEffect, m as addEffect, q as addTail, l as advance, i as applyProps, f as context, g as createPortal, a as createRoot, j as dispose, e as extend, s as getRootState, k as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, C as useLoader, x as useStore, y as useThree } from '../../dist/index-4e14a95b.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';
|
|
@@ -107,13 +107,13 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
107
107
|
children,
|
|
108
108
|
style,
|
|
109
109
|
events,
|
|
110
|
+
onPointerMissed,
|
|
110
111
|
...props
|
|
111
112
|
}, forwardedRef) => {
|
|
112
113
|
// Create a known catalogue of Threejs-native elements
|
|
113
114
|
// This will include the entire THREE namespace by default, users can extend
|
|
114
115
|
// their own elements by using the createRoot API instead
|
|
115
116
|
React.useMemo(() => extend(THREE), []);
|
|
116
|
-
const onPointerMissed = useMemoizedFn(props.onPointerMissed);
|
|
117
117
|
const [{
|
|
118
118
|
width,
|
|
119
119
|
height
|
|
@@ -123,12 +123,9 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
123
123
|
});
|
|
124
124
|
const [canvas, setCanvas] = React.useState(null);
|
|
125
125
|
const [bind, setBind] = React.useState();
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const viewProps = omit({ ...props,
|
|
130
|
-
onPointerMissed
|
|
131
|
-
}, CANVAS_PROPS);
|
|
126
|
+
const handlePointerMissed = useMutableCallback(onPointerMissed);
|
|
127
|
+
const canvasProps = pick(props, CANVAS_PROPS);
|
|
128
|
+
const viewProps = omit(props, CANVAS_PROPS);
|
|
132
129
|
const [block, setBlock] = React.useState(false);
|
|
133
130
|
const [error, setError] = React.useState(false); // Suspend this component if block is a promise (2nd run)
|
|
134
131
|
|
|
@@ -180,6 +177,8 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
180
177
|
};
|
|
181
178
|
|
|
182
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),
|
|
183
182
|
// expo-gl can only render at native dpr/resolution
|
|
184
183
|
// https://github.com/expo/expo-three/issues/39
|
|
185
184
|
dpr: PixelRatio.get(),
|
|
@@ -201,7 +200,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(({
|
|
|
201
200
|
|
|
202
201
|
React.useEffect(() => {
|
|
203
202
|
return () => unmountComponentAtNode(canvas);
|
|
204
|
-
}, [
|
|
203
|
+
}, []);
|
|
205
204
|
return /*#__PURE__*/React.createElement(View, _extends({}, viewProps, {
|
|
206
205
|
ref: mergeRefs([viewRef, forwardedRef]),
|
|
207
206
|
onLayout: onLayout,
|