@react-three/fiber 8.11.6 → 8.11.8
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 +12 -0
- package/dist/declarations/src/core/events.d.ts +71 -71
- package/dist/declarations/src/core/hooks.d.ts +29 -29
- package/dist/declarations/src/core/index.d.ts +57 -57
- package/dist/declarations/src/core/loop.d.ts +14 -14
- package/dist/declarations/src/core/renderer.d.ts +52 -52
- package/dist/declarations/src/core/store.d.ts +95 -95
- package/dist/declarations/src/core/utils.d.ts +89 -89
- package/dist/declarations/src/index.d.ts +12 -12
- package/dist/declarations/src/native/Canvas.d.ts +8 -8
- package/dist/declarations/src/native/events.d.ts +4 -4
- package/dist/declarations/src/native/polyfills.d.ts +1 -1
- package/dist/declarations/src/native.d.ts +12 -12
- package/dist/declarations/src/three-types.d.ts +335 -335
- package/dist/declarations/src/web/Canvas.d.ts +11 -11
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-e8ca37e1.esm.js → index-648b7c70.esm.js} +3 -3
- package/dist/{index-dc07c96b.cjs.prod.js → index-ae10f2b1.cjs.prod.js} +2 -2
- package/dist/{index-e05083bb.cjs.dev.js → index-baacab10.cjs.dev.js} +2 -2
- package/dist/react-three-fiber.cjs.dev.js +49 -49
- package/dist/react-three-fiber.cjs.prod.js +49 -49
- package/dist/react-three-fiber.esm.js +50 -50
- package/native/dist/react-three-fiber-native.cjs.dev.js +1 -1
- package/native/dist/react-three-fiber-native.cjs.prod.js +1 -1
- package/native/dist/react-three-fiber-native.esm.js +2 -2
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
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
|
-
eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
|
|
9
|
-
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
|
|
10
|
-
}
|
|
11
|
-
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
|
+
eventSource?: HTMLElement | React.MutableRefObject<HTMLElement>;
|
|
9
|
+
eventPrefix?: 'offset' | 'client' | 'page' | 'layer' | 'screen';
|
|
10
|
+
}
|
|
11
|
+
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>;
|
|
@@ -1769,8 +1769,8 @@ function createRoot(canvas) {
|
|
|
1769
1769
|
}
|
|
1770
1770
|
});
|
|
1771
1771
|
|
|
1772
|
-
// Create default camera
|
|
1773
|
-
if (!is.equ(lastCamera, shallowLoose)) {
|
|
1772
|
+
// Create default camera, don't overwrite any user-set state
|
|
1773
|
+
if (!state.camera || state.camera === lastCamera && !is.equ(lastCamera, cameraOptions, shallowLoose)) {
|
|
1774
1774
|
lastCamera = cameraOptions;
|
|
1775
1775
|
const isCamera = cameraOptions instanceof THREE.Camera;
|
|
1776
1776
|
const camera = isCamera ? cameraOptions : orthographic ? new THREE.OrthographicCamera(0, 0, 0, 0, 0.1, 1000) : new THREE.PerspectiveCamera(75, 0, 0.1, 1000);
|
|
@@ -2106,4 +2106,4 @@ reconciler.injectIntoDevTools({
|
|
|
2106
2106
|
});
|
|
2107
2107
|
const act = React.unstable_act;
|
|
2108
2108
|
|
|
2109
|
-
export { useFrame as A, Block as B, useGraph as C, useLoader as D, ErrorBoundary as E,
|
|
2109
|
+
export { useFrame as A, Block as B, useGraph as C, useLoader as D, ErrorBoundary as E, useIsomorphicLayoutEffect as a, createRoot as b, createEvents as c, unmountComponentAtNode as d, extend as e, context as f, createPortal as g, reconciler as h, isRef as i, applyProps as j, dispose as k, invalidate as l, advance as m, addEffect as n, addAfterEffect as o, addTail as p, flushGlobalEffects as q, render as r, getRootState as s, threeTypes as t, useMutableCallback as u, act as v, roots as w, useInstanceHandle as x, useStore as y, useThree as z };
|
|
@@ -1796,8 +1796,8 @@ function createRoot(canvas) {
|
|
|
1796
1796
|
}
|
|
1797
1797
|
});
|
|
1798
1798
|
|
|
1799
|
-
// Create default camera
|
|
1800
|
-
if (!is.equ(lastCamera, shallowLoose)) {
|
|
1799
|
+
// Create default camera, don't overwrite any user-set state
|
|
1800
|
+
if (!state.camera || state.camera === lastCamera && !is.equ(lastCamera, cameraOptions, shallowLoose)) {
|
|
1801
1801
|
lastCamera = cameraOptions;
|
|
1802
1802
|
const isCamera = cameraOptions instanceof THREE__namespace.Camera;
|
|
1803
1803
|
const camera = isCamera ? cameraOptions : orthographic ? new THREE__namespace.OrthographicCamera(0, 0, 0, 0, 0.1, 1000) : new THREE__namespace.PerspectiveCamera(75, 0, 0.1, 1000);
|
|
@@ -1796,8 +1796,8 @@ function createRoot(canvas) {
|
|
|
1796
1796
|
}
|
|
1797
1797
|
});
|
|
1798
1798
|
|
|
1799
|
-
// Create default camera
|
|
1800
|
-
if (!is.equ(lastCamera, shallowLoose)) {
|
|
1799
|
+
// Create default camera, don't overwrite any user-set state
|
|
1800
|
+
if (!state.camera || state.camera === lastCamera && !is.equ(lastCamera, cameraOptions, shallowLoose)) {
|
|
1801
1801
|
lastCamera = cameraOptions;
|
|
1802
1802
|
const isCamera = cameraOptions instanceof THREE__namespace.Camera;
|
|
1803
1803
|
const camera = isCamera ? cameraOptions : orthographic ? new THREE__namespace.OrthographicCamera(0, 0, 0, 0, 0.1, 1000) : new THREE__namespace.PerspectiveCamera(75, 0, 0.1, 1000);
|
|
@@ -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-baacab10.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -160,7 +160,6 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
160
160
|
});
|
|
161
161
|
const canvasRef = React__namespace.useRef(null);
|
|
162
162
|
const divRef = React__namespace.useRef(null);
|
|
163
|
-
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
164
163
|
React__namespace.useImperativeHandle(forwardedRef, () => canvasRef.current);
|
|
165
164
|
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
166
165
|
const [block, setBlock] = React__namespace.useState(false);
|
|
@@ -171,56 +170,57 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
171
170
|
// Throw exception outwards if anything within canvas throws
|
|
172
171
|
if (error) throw error;
|
|
173
172
|
const root = React__namespace.useRef(null);
|
|
174
|
-
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
175
|
-
if (!root.current) root.current = index.createRoot(canvas);
|
|
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,
|
|
189
|
-
size: containerRect,
|
|
190
|
-
// Pass mutable reference to onPointerMissed so it's free to update
|
|
191
|
-
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
192
|
-
onCreated: state => {
|
|
193
|
-
// Connect to event source
|
|
194
|
-
state.events.connect == null ? void 0 : state.events.connect(eventSource ? index.isRef(eventSource) ? eventSource.current : eventSource : divRef.current);
|
|
195
|
-
// Set up compute function
|
|
196
|
-
if (eventPrefix) {
|
|
197
|
-
state.setEvents({
|
|
198
|
-
compute: (event, state) => {
|
|
199
|
-
const x = event[eventPrefix + 'X'];
|
|
200
|
-
const y = event[eventPrefix + 'Y'];
|
|
201
|
-
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
202
|
-
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
// Call onCreated callback
|
|
207
|
-
onCreated == null ? void 0 : onCreated(state);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
root.current.render( /*#__PURE__*/React__namespace.createElement(Bridge, null, /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
211
|
-
set: setError
|
|
212
|
-
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
|
|
213
|
-
fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
|
|
214
|
-
set: setBlock
|
|
215
|
-
})
|
|
216
|
-
}, children))));
|
|
217
|
-
}
|
|
218
173
|
index.useIsomorphicLayoutEffect(() => {
|
|
219
|
-
|
|
220
|
-
|
|
174
|
+
const canvas = canvasRef.current;
|
|
175
|
+
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
176
|
+
if (!root.current) root.current = index.createRoot(canvas);
|
|
177
|
+
root.current.configure({
|
|
178
|
+
gl,
|
|
179
|
+
events,
|
|
180
|
+
shadows,
|
|
181
|
+
linear,
|
|
182
|
+
flat,
|
|
183
|
+
legacy,
|
|
184
|
+
orthographic,
|
|
185
|
+
frameloop,
|
|
186
|
+
dpr,
|
|
187
|
+
performance,
|
|
188
|
+
raycaster,
|
|
189
|
+
camera,
|
|
190
|
+
size: containerRect,
|
|
191
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
192
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
193
|
+
onCreated: state => {
|
|
194
|
+
// Connect to event source
|
|
195
|
+
state.events.connect == null ? void 0 : state.events.connect(eventSource ? index.isRef(eventSource) ? eventSource.current : eventSource : divRef.current);
|
|
196
|
+
// Set up compute function
|
|
197
|
+
if (eventPrefix) {
|
|
198
|
+
state.setEvents({
|
|
199
|
+
compute: (event, state) => {
|
|
200
|
+
const x = event[eventPrefix + 'X'];
|
|
201
|
+
const y = event[eventPrefix + 'Y'];
|
|
202
|
+
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
203
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// Call onCreated callback
|
|
208
|
+
onCreated == null ? void 0 : onCreated(state);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
root.current.render( /*#__PURE__*/React__namespace.createElement(Bridge, null, /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
212
|
+
set: setError
|
|
213
|
+
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
|
|
214
|
+
fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
|
|
215
|
+
set: setBlock
|
|
216
|
+
})
|
|
217
|
+
}, children))));
|
|
218
|
+
}
|
|
219
|
+
});
|
|
221
220
|
React__namespace.useEffect(() => {
|
|
221
|
+
const canvas = canvasRef.current;
|
|
222
222
|
if (canvas) return () => index.unmountComponentAtNode(canvas);
|
|
223
|
-
}, [
|
|
223
|
+
}, []);
|
|
224
224
|
|
|
225
225
|
// When the event source is not this div, we need to set pointer-events to none
|
|
226
226
|
// Or else the canvas will block events from reaching the event source
|
|
@@ -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-ae10f2b1.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -160,7 +160,6 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
160
160
|
});
|
|
161
161
|
const canvasRef = React__namespace.useRef(null);
|
|
162
162
|
const divRef = React__namespace.useRef(null);
|
|
163
|
-
const [canvas, setCanvas] = React__namespace.useState(null);
|
|
164
163
|
React__namespace.useImperativeHandle(forwardedRef, () => canvasRef.current);
|
|
165
164
|
const handlePointerMissed = index.useMutableCallback(onPointerMissed);
|
|
166
165
|
const [block, setBlock] = React__namespace.useState(false);
|
|
@@ -171,56 +170,57 @@ const CanvasImpl = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
171
170
|
// Throw exception outwards if anything within canvas throws
|
|
172
171
|
if (error) throw error;
|
|
173
172
|
const root = React__namespace.useRef(null);
|
|
174
|
-
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
175
|
-
if (!root.current) root.current = index.createRoot(canvas);
|
|
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,
|
|
189
|
-
size: containerRect,
|
|
190
|
-
// Pass mutable reference to onPointerMissed so it's free to update
|
|
191
|
-
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
192
|
-
onCreated: state => {
|
|
193
|
-
// Connect to event source
|
|
194
|
-
state.events.connect == null ? void 0 : state.events.connect(eventSource ? index.isRef(eventSource) ? eventSource.current : eventSource : divRef.current);
|
|
195
|
-
// Set up compute function
|
|
196
|
-
if (eventPrefix) {
|
|
197
|
-
state.setEvents({
|
|
198
|
-
compute: (event, state) => {
|
|
199
|
-
const x = event[eventPrefix + 'X'];
|
|
200
|
-
const y = event[eventPrefix + 'Y'];
|
|
201
|
-
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
202
|
-
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
// Call onCreated callback
|
|
207
|
-
onCreated == null ? void 0 : onCreated(state);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
root.current.render( /*#__PURE__*/React__namespace.createElement(Bridge, null, /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
211
|
-
set: setError
|
|
212
|
-
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
|
|
213
|
-
fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
|
|
214
|
-
set: setBlock
|
|
215
|
-
})
|
|
216
|
-
}, children))));
|
|
217
|
-
}
|
|
218
173
|
index.useIsomorphicLayoutEffect(() => {
|
|
219
|
-
|
|
220
|
-
|
|
174
|
+
const canvas = canvasRef.current;
|
|
175
|
+
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
176
|
+
if (!root.current) root.current = index.createRoot(canvas);
|
|
177
|
+
root.current.configure({
|
|
178
|
+
gl,
|
|
179
|
+
events,
|
|
180
|
+
shadows,
|
|
181
|
+
linear,
|
|
182
|
+
flat,
|
|
183
|
+
legacy,
|
|
184
|
+
orthographic,
|
|
185
|
+
frameloop,
|
|
186
|
+
dpr,
|
|
187
|
+
performance,
|
|
188
|
+
raycaster,
|
|
189
|
+
camera,
|
|
190
|
+
size: containerRect,
|
|
191
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
192
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
193
|
+
onCreated: state => {
|
|
194
|
+
// Connect to event source
|
|
195
|
+
state.events.connect == null ? void 0 : state.events.connect(eventSource ? index.isRef(eventSource) ? eventSource.current : eventSource : divRef.current);
|
|
196
|
+
// Set up compute function
|
|
197
|
+
if (eventPrefix) {
|
|
198
|
+
state.setEvents({
|
|
199
|
+
compute: (event, state) => {
|
|
200
|
+
const x = event[eventPrefix + 'X'];
|
|
201
|
+
const y = event[eventPrefix + 'Y'];
|
|
202
|
+
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
203
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// Call onCreated callback
|
|
208
|
+
onCreated == null ? void 0 : onCreated(state);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
root.current.render( /*#__PURE__*/React__namespace.createElement(Bridge, null, /*#__PURE__*/React__namespace.createElement(index.ErrorBoundary, {
|
|
212
|
+
set: setError
|
|
213
|
+
}, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
|
|
214
|
+
fallback: /*#__PURE__*/React__namespace.createElement(index.Block, {
|
|
215
|
+
set: setBlock
|
|
216
|
+
})
|
|
217
|
+
}, children))));
|
|
218
|
+
}
|
|
219
|
+
});
|
|
221
220
|
React__namespace.useEffect(() => {
|
|
221
|
+
const canvas = canvasRef.current;
|
|
222
222
|
if (canvas) return () => index.unmountComponentAtNode(canvas);
|
|
223
|
-
}, [
|
|
223
|
+
}, []);
|
|
224
224
|
|
|
225
225
|
// When the event source is not this div, we need to set pointer-events to none
|
|
226
226
|
// Or else the canvas will block events from reaching the event source
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, i as isRef, E as ErrorBoundary, B as Block,
|
|
2
|
-
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal,
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, a as useIsomorphicLayoutEffect, b as createRoot, i as isRef, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from './index-648b7c70.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from './index-648b7c70.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';
|
|
@@ -133,7 +133,6 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
133
133
|
});
|
|
134
134
|
const canvasRef = React.useRef(null);
|
|
135
135
|
const divRef = React.useRef(null);
|
|
136
|
-
const [canvas, setCanvas] = React.useState(null);
|
|
137
136
|
React.useImperativeHandle(forwardedRef, () => canvasRef.current);
|
|
138
137
|
const handlePointerMissed = useMutableCallback(onPointerMissed);
|
|
139
138
|
const [block, setBlock] = React.useState(false);
|
|
@@ -144,56 +143,57 @@ const CanvasImpl = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
144
143
|
// Throw exception outwards if anything within canvas throws
|
|
145
144
|
if (error) throw error;
|
|
146
145
|
const root = React.useRef(null);
|
|
147
|
-
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
148
|
-
if (!root.current) root.current = createRoot(canvas);
|
|
149
|
-
root.current.configure({
|
|
150
|
-
gl,
|
|
151
|
-
events,
|
|
152
|
-
shadows,
|
|
153
|
-
linear,
|
|
154
|
-
flat,
|
|
155
|
-
legacy,
|
|
156
|
-
orthographic,
|
|
157
|
-
frameloop,
|
|
158
|
-
dpr,
|
|
159
|
-
performance,
|
|
160
|
-
raycaster,
|
|
161
|
-
camera,
|
|
162
|
-
size: containerRect,
|
|
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
|
-
// Connect to event source
|
|
167
|
-
state.events.connect == null ? void 0 : state.events.connect(eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current);
|
|
168
|
-
// Set up compute function
|
|
169
|
-
if (eventPrefix) {
|
|
170
|
-
state.setEvents({
|
|
171
|
-
compute: (event, state) => {
|
|
172
|
-
const x = event[eventPrefix + 'X'];
|
|
173
|
-
const y = event[eventPrefix + 'Y'];
|
|
174
|
-
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
175
|
-
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
// Call onCreated callback
|
|
180
|
-
onCreated == null ? void 0 : onCreated(state);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
root.current.render( /*#__PURE__*/React.createElement(Bridge, null, /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
184
|
-
set: setError
|
|
185
|
-
}, /*#__PURE__*/React.createElement(React.Suspense, {
|
|
186
|
-
fallback: /*#__PURE__*/React.createElement(Block, {
|
|
187
|
-
set: setBlock
|
|
188
|
-
})
|
|
189
|
-
}, children))));
|
|
190
|
-
}
|
|
191
146
|
useIsomorphicLayoutEffect(() => {
|
|
192
|
-
|
|
193
|
-
|
|
147
|
+
const canvas = canvasRef.current;
|
|
148
|
+
if (containerRect.width > 0 && containerRect.height > 0 && canvas) {
|
|
149
|
+
if (!root.current) root.current = createRoot(canvas);
|
|
150
|
+
root.current.configure({
|
|
151
|
+
gl,
|
|
152
|
+
events,
|
|
153
|
+
shadows,
|
|
154
|
+
linear,
|
|
155
|
+
flat,
|
|
156
|
+
legacy,
|
|
157
|
+
orthographic,
|
|
158
|
+
frameloop,
|
|
159
|
+
dpr,
|
|
160
|
+
performance,
|
|
161
|
+
raycaster,
|
|
162
|
+
camera,
|
|
163
|
+
size: containerRect,
|
|
164
|
+
// Pass mutable reference to onPointerMissed so it's free to update
|
|
165
|
+
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
166
|
+
onCreated: state => {
|
|
167
|
+
// Connect to event source
|
|
168
|
+
state.events.connect == null ? void 0 : state.events.connect(eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current);
|
|
169
|
+
// Set up compute function
|
|
170
|
+
if (eventPrefix) {
|
|
171
|
+
state.setEvents({
|
|
172
|
+
compute: (event, state) => {
|
|
173
|
+
const x = event[eventPrefix + 'X'];
|
|
174
|
+
const y = event[eventPrefix + 'Y'];
|
|
175
|
+
state.pointer.set(x / state.size.width * 2 - 1, -(y / state.size.height) * 2 + 1);
|
|
176
|
+
state.raycaster.setFromCamera(state.pointer, state.camera);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
// Call onCreated callback
|
|
181
|
+
onCreated == null ? void 0 : onCreated(state);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
root.current.render( /*#__PURE__*/React.createElement(Bridge, null, /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
185
|
+
set: setError
|
|
186
|
+
}, /*#__PURE__*/React.createElement(React.Suspense, {
|
|
187
|
+
fallback: /*#__PURE__*/React.createElement(Block, {
|
|
188
|
+
set: setBlock
|
|
189
|
+
})
|
|
190
|
+
}, children))));
|
|
191
|
+
}
|
|
192
|
+
});
|
|
194
193
|
React.useEffect(() => {
|
|
194
|
+
const canvas = canvasRef.current;
|
|
195
195
|
if (canvas) return () => unmountComponentAtNode(canvas);
|
|
196
|
-
}, [
|
|
196
|
+
}, []);
|
|
197
197
|
|
|
198
198
|
// When the event source is not this div, we need to set pointer-events to none
|
|
199
199
|
// Or else the canvas will block events from reaching the event source
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../dist/index-
|
|
5
|
+
var index = require('../../dist/index-baacab10.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../dist/index-
|
|
5
|
+
var index = require('../../dist/index-ae10f2b1.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createEvents, e as extend, u as useMutableCallback,
|
|
2
|
-
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal,
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, b as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-648b7c70.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, w as _roots, v as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, c as createEvents, g as createPortal, b as createRoot, k as dispose, e as extend, q as flushGlobalEffects, s as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, A as useFrame, C as useGraph, x as useInstanceHandle, D as useLoader, y as useStore, z as useThree } from '../../dist/index-648b7c70.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';
|