@react-three/fiber 8.7.0 → 8.7.3
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 +18 -0
- package/dist/declarations/src/core/events.d.ts +69 -69
- package/dist/declarations/src/core/hooks.d.ts +25 -25
- package/dist/declarations/src/core/index.d.ts +57 -57
- package/dist/declarations/src/core/loop.d.ts +15 -15
- package/dist/declarations/src/core/renderer.d.ts +51 -51
- package/dist/declarations/src/core/store.d.ts +95 -95
- package/dist/declarations/src/core/utils.d.ts +83 -82
- package/dist/declarations/src/index.d.ts +11 -11
- 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 +10 -10
- package/dist/declarations/src/three-types.d.ts +332 -332
- package/dist/declarations/src/web/Canvas.d.ts +11 -11
- package/dist/declarations/src/web/events.d.ts +4 -4
- package/dist/{index-3b3bed95.esm.js → index-05f8627d.esm.js} +91 -87
- package/dist/{index-b3d1f4d2.cjs.dev.js → index-407f3d70.cjs.dev.js} +91 -86
- package/dist/{index-846c69c6.cjs.prod.js → index-5350eaac.cjs.prod.js} +91 -86
- package/dist/react-three-fiber.cjs.dev.js +7 -3
- package/dist/react-three-fiber.cjs.prod.js +7 -3
- package/dist/react-three-fiber.esm.js +8 -4
- 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
|
@@ -39,6 +39,7 @@ var threeTypes = /*#__PURE__*/Object.freeze({
|
|
|
39
39
|
|
|
40
40
|
var _window$document, _window$navigator;
|
|
41
41
|
const isOrthographicCamera = def => def && def.isOrthographicCamera;
|
|
42
|
+
const isRef = obj => obj && obj.hasOwnProperty('current');
|
|
42
43
|
/**
|
|
43
44
|
* An SSR-friendly useLayoutEffect.
|
|
44
45
|
*
|
|
@@ -503,9 +504,7 @@ function removeInteractivity(store, object) {
|
|
|
503
504
|
});
|
|
504
505
|
}
|
|
505
506
|
function createEvents(store) {
|
|
506
|
-
const temp = new THREE__namespace.Vector3();
|
|
507
507
|
/** Calculates delta */
|
|
508
|
-
|
|
509
508
|
function calculateDistance(event) {
|
|
510
509
|
const {
|
|
511
510
|
internal
|
|
@@ -605,108 +604,113 @@ function createEvents(store) {
|
|
|
605
604
|
|
|
606
605
|
|
|
607
606
|
function handleIntersects(intersections, event, delta, callback) {
|
|
608
|
-
|
|
609
|
-
raycaster,
|
|
610
|
-
pointer,
|
|
611
|
-
camera,
|
|
612
|
-
internal
|
|
613
|
-
} = store.getState(); // If anything has been found, forward it to the event listeners
|
|
614
|
-
|
|
607
|
+
// If anything has been found, forward it to the event listeners
|
|
615
608
|
if (intersections.length) {
|
|
616
|
-
const unprojectedPoint = temp.set(pointer.x, pointer.y, 0).unproject(camera);
|
|
617
609
|
const localState = {
|
|
618
610
|
stopped: false
|
|
619
611
|
};
|
|
620
612
|
|
|
621
613
|
for (const hit of intersections) {
|
|
622
|
-
const
|
|
623
|
-
var _internal$capturedMap, _internal$capturedMap2;
|
|
614
|
+
const state = getRootState(hit.object);
|
|
624
615
|
|
|
625
|
-
|
|
626
|
-
|
|
616
|
+
if (state) {
|
|
617
|
+
const {
|
|
618
|
+
raycaster,
|
|
619
|
+
pointer,
|
|
620
|
+
camera,
|
|
621
|
+
internal
|
|
622
|
+
} = state;
|
|
623
|
+
const unprojectedPoint = new THREE__namespace.Vector3(pointer.x, pointer.y, 0).unproject(camera);
|
|
627
624
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
625
|
+
const hasPointerCapture = id => {
|
|
626
|
+
var _internal$capturedMap, _internal$capturedMap2;
|
|
627
|
+
|
|
628
|
+
return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
|
|
632
629
|
};
|
|
633
630
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
631
|
+
const setPointerCapture = id => {
|
|
632
|
+
const captureData = {
|
|
633
|
+
intersection: hit,
|
|
634
|
+
target: event.target
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
if (internal.capturedMap.has(id)) {
|
|
638
|
+
// if the pointerId was previously captured, we add the hit to the
|
|
639
|
+
// event capturedMap.
|
|
640
|
+
internal.capturedMap.get(id).set(hit.eventObject, captureData);
|
|
641
|
+
} else {
|
|
642
|
+
// if the pointerId was not previously captured, we create a map
|
|
643
|
+
// containing the hitObject, and the hit. hitObject is used for
|
|
644
|
+
// faster access.
|
|
645
|
+
internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
|
|
646
|
+
} // Call the original event now
|
|
647
|
+
event.target.setPointerCapture(id);
|
|
648
|
+
};
|
|
646
649
|
|
|
647
|
-
|
|
648
|
-
|
|
650
|
+
const releasePointerCapture = id => {
|
|
651
|
+
const captures = internal.capturedMap.get(id);
|
|
649
652
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
653
|
+
if (captures) {
|
|
654
|
+
releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
|
|
655
|
+
}
|
|
656
|
+
}; // Add native event props
|
|
654
657
|
|
|
655
658
|
|
|
656
|
-
|
|
659
|
+
let extractEventProps = {}; // This iterates over the event's properties including the inherited ones. Native PointerEvents have most of their props as getters which are inherited, but polyfilled PointerEvents have them all as their own properties (i.e. not inherited). We can't use Object.keys() or Object.entries() as they only return "own" properties; nor Object.getPrototypeOf(event) as that *doesn't* return "own" properties, only inherited ones.
|
|
657
660
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
+
for (let prop in event) {
|
|
662
|
+
let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
|
|
663
|
+
// called as event.nativeEvent.fn()
|
|
661
664
|
|
|
662
|
-
|
|
663
|
-
|
|
665
|
+
if (typeof property !== 'function') extractEventProps[prop] = property;
|
|
666
|
+
}
|
|
664
667
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
668
|
+
let raycastEvent = { ...hit,
|
|
669
|
+
...extractEventProps,
|
|
670
|
+
pointer,
|
|
671
|
+
intersections,
|
|
672
|
+
stopped: localState.stopped,
|
|
673
|
+
delta,
|
|
674
|
+
unprojectedPoint,
|
|
675
|
+
ray: raycaster.ray,
|
|
676
|
+
camera: camera,
|
|
677
|
+
// Hijack stopPropagation, which just sets a flag
|
|
678
|
+
stopPropagation: () => {
|
|
679
|
+
// https://github.com/pmndrs/react-three-fiber/issues/596
|
|
680
|
+
// Events are not allowed to stop propagation if the pointer has been captured
|
|
681
|
+
const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
|
|
682
|
+
|
|
683
|
+
if ( // ...if this pointer hasn't been captured
|
|
684
|
+
!capturesForPointer || // ... or if the hit object is capturing the pointer
|
|
685
|
+
capturesForPointer.has(hit.eventObject)) {
|
|
686
|
+
raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
|
|
687
|
+
// An event handler is only allowed to flush other handlers if it is hovered itself
|
|
688
|
+
|
|
689
|
+
if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
|
|
690
|
+
// Objects cannot flush out higher up objects that have already caught the event
|
|
691
|
+
const higher = intersections.slice(0, intersections.indexOf(hit));
|
|
692
|
+
cancelPointer([...higher, hit]);
|
|
693
|
+
}
|
|
690
694
|
}
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
695
|
+
},
|
|
696
|
+
// there should be a distinction between target and currentTarget
|
|
697
|
+
target: {
|
|
698
|
+
hasPointerCapture,
|
|
699
|
+
setPointerCapture,
|
|
700
|
+
releasePointerCapture
|
|
701
|
+
},
|
|
702
|
+
currentTarget: {
|
|
703
|
+
hasPointerCapture,
|
|
704
|
+
setPointerCapture,
|
|
705
|
+
releasePointerCapture
|
|
706
|
+
},
|
|
707
|
+
nativeEvent: event
|
|
708
|
+
}; // Call subscribers
|
|
709
|
+
|
|
710
|
+
callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
|
|
711
|
+
|
|
712
|
+
if (localState.stopped === true) break;
|
|
713
|
+
}
|
|
710
714
|
}
|
|
711
715
|
}
|
|
712
716
|
|
|
@@ -2172,6 +2176,7 @@ exports.dispose = dispose;
|
|
|
2172
2176
|
exports.extend = extend;
|
|
2173
2177
|
exports.getRootState = getRootState;
|
|
2174
2178
|
exports.invalidate = invalidate;
|
|
2179
|
+
exports.isRef = isRef;
|
|
2175
2180
|
exports.reconciler = reconciler;
|
|
2176
2181
|
exports.render = render;
|
|
2177
2182
|
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-407f3d70.cjs.dev.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -187,7 +187,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
187
187
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
188
188
|
onCreated: state => {
|
|
189
189
|
// Connect to event source
|
|
190
|
-
state.events.connect == null ? void 0 : state.events.connect(eventSource ? eventSource : divRef.current); // Set up compute function
|
|
190
|
+
state.events.connect == null ? void 0 : state.events.connect(eventSource ? index.isRef(eventSource) ? eventSource.current : eventSource : divRef.current); // Set up compute function
|
|
191
191
|
|
|
192
192
|
if (eventPrefix) {
|
|
193
193
|
state.setEvents({
|
|
@@ -218,7 +218,10 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
218
218
|
}, []);
|
|
219
219
|
React__namespace.useEffect(() => {
|
|
220
220
|
if (canvas) return () => index.unmountComponentAtNode(canvas);
|
|
221
|
-
}, [canvas]);
|
|
221
|
+
}, [canvas]); // When the event source is not this div, we need to set pointer-events to none
|
|
222
|
+
// Or else the canvas will block events from reaching the event source
|
|
223
|
+
|
|
224
|
+
const pointerEvents = eventSource ? 'none' : 'auto';
|
|
222
225
|
return /*#__PURE__*/React__namespace.createElement("div", _extends({
|
|
223
226
|
ref: divRef,
|
|
224
227
|
style: {
|
|
@@ -226,6 +229,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
226
229
|
width: '100%',
|
|
227
230
|
height: '100%',
|
|
228
231
|
overflow: 'hidden',
|
|
232
|
+
pointerEvents,
|
|
229
233
|
...style
|
|
230
234
|
}
|
|
231
235
|
}, props), /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -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-5350eaac.cjs.prod.js');
|
|
6
6
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
@@ -187,7 +187,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
187
187
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
188
188
|
onCreated: state => {
|
|
189
189
|
// Connect to event source
|
|
190
|
-
state.events.connect == null ? void 0 : state.events.connect(eventSource ? eventSource : divRef.current); // Set up compute function
|
|
190
|
+
state.events.connect == null ? void 0 : state.events.connect(eventSource ? index.isRef(eventSource) ? eventSource.current : eventSource : divRef.current); // Set up compute function
|
|
191
191
|
|
|
192
192
|
if (eventPrefix) {
|
|
193
193
|
state.setEvents({
|
|
@@ -218,7 +218,10 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
218
218
|
}, []);
|
|
219
219
|
React__namespace.useEffect(() => {
|
|
220
220
|
if (canvas) return () => index.unmountComponentAtNode(canvas);
|
|
221
|
-
}, [canvas]);
|
|
221
|
+
}, [canvas]); // When the event source is not this div, we need to set pointer-events to none
|
|
222
|
+
// Or else the canvas will block events from reaching the event source
|
|
223
|
+
|
|
224
|
+
const pointerEvents = eventSource ? 'none' : 'auto';
|
|
222
225
|
return /*#__PURE__*/React__namespace.createElement("div", _extends({
|
|
223
226
|
ref: divRef,
|
|
224
227
|
style: {
|
|
@@ -226,6 +229,7 @@ const Canvas = /*#__PURE__*/React__namespace.forwardRef(function Canvas({
|
|
|
226
229
|
width: '100%',
|
|
227
230
|
height: '100%',
|
|
228
231
|
overflow: 'hidden',
|
|
232
|
+
pointerEvents,
|
|
229
233
|
...style
|
|
230
234
|
}
|
|
231
235
|
}, props), /*#__PURE__*/React__namespace.createElement("div", {
|
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
2
|
-
export { t as ReactThreeFiber,
|
|
1
|
+
import { c as createEvents, e as extend, u as useMutableCallback, a as createRoot, i as isRef, E as ErrorBoundary, B as Block, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-05f8627d.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, v as _roots, s 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, a as createRoot, k as dispose, e as extend, q as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, w as useInstanceHandle, C as useLoader, x as useStore, y as useThree } from './index-05f8627d.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';
|
|
@@ -160,7 +160,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
160
160
|
onPointerMissed: (...args) => handlePointerMissed.current == null ? void 0 : handlePointerMissed.current(...args),
|
|
161
161
|
onCreated: state => {
|
|
162
162
|
// Connect to event source
|
|
163
|
-
state.events.connect == null ? void 0 : state.events.connect(eventSource ? eventSource : divRef.current); // Set up compute function
|
|
163
|
+
state.events.connect == null ? void 0 : state.events.connect(eventSource ? isRef(eventSource) ? eventSource.current : eventSource : divRef.current); // Set up compute function
|
|
164
164
|
|
|
165
165
|
if (eventPrefix) {
|
|
166
166
|
state.setEvents({
|
|
@@ -191,7 +191,10 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
191
191
|
}, []);
|
|
192
192
|
React.useEffect(() => {
|
|
193
193
|
if (canvas) return () => unmountComponentAtNode(canvas);
|
|
194
|
-
}, [canvas]);
|
|
194
|
+
}, [canvas]); // When the event source is not this div, we need to set pointer-events to none
|
|
195
|
+
// Or else the canvas will block events from reaching the event source
|
|
196
|
+
|
|
197
|
+
const pointerEvents = eventSource ? 'none' : 'auto';
|
|
195
198
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
196
199
|
ref: divRef,
|
|
197
200
|
style: {
|
|
@@ -199,6 +202,7 @@ const Canvas = /*#__PURE__*/React.forwardRef(function Canvas({
|
|
|
199
202
|
width: '100%',
|
|
200
203
|
height: '100%',
|
|
201
204
|
overflow: 'hidden',
|
|
205
|
+
pointerEvents,
|
|
202
206
|
...style
|
|
203
207
|
}
|
|
204
208
|
}, props), /*#__PURE__*/React.createElement("div", {
|
|
@@ -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-407f3d70.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-5350eaac.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, a as createRoot, E as ErrorBoundary, B as Block, d as unmountComponentAtNode } from '../../dist/index-
|
|
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, d as unmountComponentAtNode } from '../../dist/index-05f8627d.esm.js';
|
|
2
|
+
export { t as ReactThreeFiber, v as _roots, s as act, o as addAfterEffect, n as addEffect, p as addTail, m as advance, j as applyProps, f as context, g as createPortal, a as createRoot, k as dispose, e as extend, q as getRootState, l as invalidate, h as reconciler, r as render, d as unmountComponentAtNode, z as useFrame, A as useGraph, w as useInstanceHandle, C as useLoader, x as useStore, y as useThree } from '../../dist/index-05f8627d.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';
|