@react-three/fiber 8.7.1 → 8.7.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @react-three/fiber
2
2
 
3
+ ## 8.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 7f801e60: fix: events in portals carry the wrong raycaster, camera, etc
8
+
3
9
  ## 8.7.1
4
10
 
5
11
  ### Patch Changes
@@ -477,9 +477,7 @@ function removeInteractivity(store, object) {
477
477
  });
478
478
  }
479
479
  function createEvents(store) {
480
- const temp = new THREE.Vector3();
481
480
  /** Calculates delta */
482
-
483
481
  function calculateDistance(event) {
484
482
  const {
485
483
  internal
@@ -579,108 +577,113 @@ function createEvents(store) {
579
577
 
580
578
 
581
579
  function handleIntersects(intersections, event, delta, callback) {
582
- const {
583
- raycaster,
584
- pointer,
585
- camera,
586
- internal
587
- } = store.getState(); // If anything has been found, forward it to the event listeners
588
-
580
+ // If anything has been found, forward it to the event listeners
589
581
  if (intersections.length) {
590
- const unprojectedPoint = temp.set(pointer.x, pointer.y, 0).unproject(camera);
591
582
  const localState = {
592
583
  stopped: false
593
584
  };
594
585
 
595
586
  for (const hit of intersections) {
596
- const hasPointerCapture = id => {
597
- var _internal$capturedMap, _internal$capturedMap2;
587
+ const state = getRootState(hit.object);
598
588
 
599
- return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
600
- };
589
+ if (state) {
590
+ const {
591
+ raycaster,
592
+ pointer,
593
+ camera,
594
+ internal
595
+ } = state;
596
+ const unprojectedPoint = new THREE.Vector3(pointer.x, pointer.y, 0).unproject(camera);
601
597
 
602
- const setPointerCapture = id => {
603
- const captureData = {
604
- intersection: hit,
605
- target: event.target
598
+ const hasPointerCapture = id => {
599
+ var _internal$capturedMap, _internal$capturedMap2;
600
+
601
+ return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
606
602
  };
607
603
 
608
- if (internal.capturedMap.has(id)) {
609
- // if the pointerId was previously captured, we add the hit to the
610
- // event capturedMap.
611
- internal.capturedMap.get(id).set(hit.eventObject, captureData);
612
- } else {
613
- // if the pointerId was not previously captured, we create a map
614
- // containing the hitObject, and the hit. hitObject is used for
615
- // faster access.
616
- internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
617
- } // Call the original event now
618
- event.target.setPointerCapture(id);
619
- };
604
+ const setPointerCapture = id => {
605
+ const captureData = {
606
+ intersection: hit,
607
+ target: event.target
608
+ };
609
+
610
+ if (internal.capturedMap.has(id)) {
611
+ // if the pointerId was previously captured, we add the hit to the
612
+ // event capturedMap.
613
+ internal.capturedMap.get(id).set(hit.eventObject, captureData);
614
+ } else {
615
+ // if the pointerId was not previously captured, we create a map
616
+ // containing the hitObject, and the hit. hitObject is used for
617
+ // faster access.
618
+ internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
619
+ } // Call the original event now
620
+ event.target.setPointerCapture(id);
621
+ };
620
622
 
621
- const releasePointerCapture = id => {
622
- const captures = internal.capturedMap.get(id);
623
+ const releasePointerCapture = id => {
624
+ const captures = internal.capturedMap.get(id);
623
625
 
624
- if (captures) {
625
- releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
626
- }
627
- }; // Add native event props
626
+ if (captures) {
627
+ releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
628
+ }
629
+ }; // Add native event props
628
630
 
629
631
 
630
- 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.
632
+ 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.
631
633
 
632
- for (let prop in event) {
633
- let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
634
- // called as event.nativeEvent.fn()
634
+ for (let prop in event) {
635
+ let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
636
+ // called as event.nativeEvent.fn()
635
637
 
636
- if (typeof property !== 'function') extractEventProps[prop] = property;
637
- }
638
+ if (typeof property !== 'function') extractEventProps[prop] = property;
639
+ }
638
640
 
639
- let raycastEvent = { ...hit,
640
- ...extractEventProps,
641
- pointer,
642
- intersections,
643
- stopped: localState.stopped,
644
- delta,
645
- unprojectedPoint,
646
- ray: raycaster.ray,
647
- camera: camera,
648
- // Hijack stopPropagation, which just sets a flag
649
- stopPropagation: () => {
650
- // https://github.com/pmndrs/react-three-fiber/issues/596
651
- // Events are not allowed to stop propagation if the pointer has been captured
652
- const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
653
-
654
- if ( // ...if this pointer hasn't been captured
655
- !capturesForPointer || // ... or if the hit object is capturing the pointer
656
- capturesForPointer.has(hit.eventObject)) {
657
- raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
658
- // An event handler is only allowed to flush other handlers if it is hovered itself
659
-
660
- if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
661
- // Objects cannot flush out higher up objects that have already caught the event
662
- const higher = intersections.slice(0, intersections.indexOf(hit));
663
- cancelPointer([...higher, hit]);
641
+ let raycastEvent = { ...hit,
642
+ ...extractEventProps,
643
+ pointer,
644
+ intersections,
645
+ stopped: localState.stopped,
646
+ delta,
647
+ unprojectedPoint,
648
+ ray: raycaster.ray,
649
+ camera: camera,
650
+ // Hijack stopPropagation, which just sets a flag
651
+ stopPropagation: () => {
652
+ // https://github.com/pmndrs/react-three-fiber/issues/596
653
+ // Events are not allowed to stop propagation if the pointer has been captured
654
+ const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
655
+
656
+ if ( // ...if this pointer hasn't been captured
657
+ !capturesForPointer || // ... or if the hit object is capturing the pointer
658
+ capturesForPointer.has(hit.eventObject)) {
659
+ raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
660
+ // An event handler is only allowed to flush other handlers if it is hovered itself
661
+
662
+ if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
663
+ // Objects cannot flush out higher up objects that have already caught the event
664
+ const higher = intersections.slice(0, intersections.indexOf(hit));
665
+ cancelPointer([...higher, hit]);
666
+ }
664
667
  }
665
- }
666
- },
667
- // there should be a distinction between target and currentTarget
668
- target: {
669
- hasPointerCapture,
670
- setPointerCapture,
671
- releasePointerCapture
672
- },
673
- currentTarget: {
674
- hasPointerCapture,
675
- setPointerCapture,
676
- releasePointerCapture
677
- },
678
- nativeEvent: event
679
- }; // Call subscribers
680
-
681
- callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
682
-
683
- if (localState.stopped === true) break;
668
+ },
669
+ // there should be a distinction between target and currentTarget
670
+ target: {
671
+ hasPointerCapture,
672
+ setPointerCapture,
673
+ releasePointerCapture
674
+ },
675
+ currentTarget: {
676
+ hasPointerCapture,
677
+ setPointerCapture,
678
+ releasePointerCapture
679
+ },
680
+ nativeEvent: event
681
+ }; // Call subscribers
682
+
683
+ callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
684
+
685
+ if (localState.stopped === true) break;
686
+ }
684
687
  }
685
688
  }
686
689
 
@@ -504,9 +504,7 @@ function removeInteractivity(store, object) {
504
504
  });
505
505
  }
506
506
  function createEvents(store) {
507
- const temp = new THREE__namespace.Vector3();
508
507
  /** Calculates delta */
509
-
510
508
  function calculateDistance(event) {
511
509
  const {
512
510
  internal
@@ -606,108 +604,113 @@ function createEvents(store) {
606
604
 
607
605
 
608
606
  function handleIntersects(intersections, event, delta, callback) {
609
- const {
610
- raycaster,
611
- pointer,
612
- camera,
613
- internal
614
- } = store.getState(); // If anything has been found, forward it to the event listeners
615
-
607
+ // If anything has been found, forward it to the event listeners
616
608
  if (intersections.length) {
617
- const unprojectedPoint = temp.set(pointer.x, pointer.y, 0).unproject(camera);
618
609
  const localState = {
619
610
  stopped: false
620
611
  };
621
612
 
622
613
  for (const hit of intersections) {
623
- const hasPointerCapture = id => {
624
- var _internal$capturedMap, _internal$capturedMap2;
614
+ const state = getRootState(hit.object);
625
615
 
626
- return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
627
- };
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);
628
624
 
629
- const setPointerCapture = id => {
630
- const captureData = {
631
- intersection: hit,
632
- target: event.target
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;
633
629
  };
634
630
 
635
- if (internal.capturedMap.has(id)) {
636
- // if the pointerId was previously captured, we add the hit to the
637
- // event capturedMap.
638
- internal.capturedMap.get(id).set(hit.eventObject, captureData);
639
- } else {
640
- // if the pointerId was not previously captured, we create a map
641
- // containing the hitObject, and the hit. hitObject is used for
642
- // faster access.
643
- internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
644
- } // Call the original event now
645
- event.target.setPointerCapture(id);
646
- };
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
+ };
647
649
 
648
- const releasePointerCapture = id => {
649
- const captures = internal.capturedMap.get(id);
650
+ const releasePointerCapture = id => {
651
+ const captures = internal.capturedMap.get(id);
650
652
 
651
- if (captures) {
652
- releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
653
- }
654
- }; // Add native event props
653
+ if (captures) {
654
+ releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
655
+ }
656
+ }; // Add native event props
655
657
 
656
658
 
657
- 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.
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.
658
660
 
659
- for (let prop in event) {
660
- let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
661
- // called as event.nativeEvent.fn()
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()
662
664
 
663
- if (typeof property !== 'function') extractEventProps[prop] = property;
664
- }
665
+ if (typeof property !== 'function') extractEventProps[prop] = property;
666
+ }
665
667
 
666
- let raycastEvent = { ...hit,
667
- ...extractEventProps,
668
- pointer,
669
- intersections,
670
- stopped: localState.stopped,
671
- delta,
672
- unprojectedPoint,
673
- ray: raycaster.ray,
674
- camera: camera,
675
- // Hijack stopPropagation, which just sets a flag
676
- stopPropagation: () => {
677
- // https://github.com/pmndrs/react-three-fiber/issues/596
678
- // Events are not allowed to stop propagation if the pointer has been captured
679
- const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
680
-
681
- if ( // ...if this pointer hasn't been captured
682
- !capturesForPointer || // ... or if the hit object is capturing the pointer
683
- capturesForPointer.has(hit.eventObject)) {
684
- raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
685
- // An event handler is only allowed to flush other handlers if it is hovered itself
686
-
687
- if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
688
- // Objects cannot flush out higher up objects that have already caught the event
689
- const higher = intersections.slice(0, intersections.indexOf(hit));
690
- cancelPointer([...higher, hit]);
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
+ }
691
694
  }
692
- }
693
- },
694
- // there should be a distinction between target and currentTarget
695
- target: {
696
- hasPointerCapture,
697
- setPointerCapture,
698
- releasePointerCapture
699
- },
700
- currentTarget: {
701
- hasPointerCapture,
702
- setPointerCapture,
703
- releasePointerCapture
704
- },
705
- nativeEvent: event
706
- }; // Call subscribers
707
-
708
- callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
709
-
710
- if (localState.stopped === true) break;
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
+ }
711
714
  }
712
715
  }
713
716
 
@@ -504,9 +504,7 @@ function removeInteractivity(store, object) {
504
504
  });
505
505
  }
506
506
  function createEvents(store) {
507
- const temp = new THREE__namespace.Vector3();
508
507
  /** Calculates delta */
509
-
510
508
  function calculateDistance(event) {
511
509
  const {
512
510
  internal
@@ -606,108 +604,113 @@ function createEvents(store) {
606
604
 
607
605
 
608
606
  function handleIntersects(intersections, event, delta, callback) {
609
- const {
610
- raycaster,
611
- pointer,
612
- camera,
613
- internal
614
- } = store.getState(); // If anything has been found, forward it to the event listeners
615
-
607
+ // If anything has been found, forward it to the event listeners
616
608
  if (intersections.length) {
617
- const unprojectedPoint = temp.set(pointer.x, pointer.y, 0).unproject(camera);
618
609
  const localState = {
619
610
  stopped: false
620
611
  };
621
612
 
622
613
  for (const hit of intersections) {
623
- const hasPointerCapture = id => {
624
- var _internal$capturedMap, _internal$capturedMap2;
614
+ const state = getRootState(hit.object);
625
615
 
626
- return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
627
- };
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);
628
624
 
629
- const setPointerCapture = id => {
630
- const captureData = {
631
- intersection: hit,
632
- target: event.target
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;
633
629
  };
634
630
 
635
- if (internal.capturedMap.has(id)) {
636
- // if the pointerId was previously captured, we add the hit to the
637
- // event capturedMap.
638
- internal.capturedMap.get(id).set(hit.eventObject, captureData);
639
- } else {
640
- // if the pointerId was not previously captured, we create a map
641
- // containing the hitObject, and the hit. hitObject is used for
642
- // faster access.
643
- internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
644
- } // Call the original event now
645
- event.target.setPointerCapture(id);
646
- };
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
+ };
647
649
 
648
- const releasePointerCapture = id => {
649
- const captures = internal.capturedMap.get(id);
650
+ const releasePointerCapture = id => {
651
+ const captures = internal.capturedMap.get(id);
650
652
 
651
- if (captures) {
652
- releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
653
- }
654
- }; // Add native event props
653
+ if (captures) {
654
+ releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
655
+ }
656
+ }; // Add native event props
655
657
 
656
658
 
657
- 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.
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.
658
660
 
659
- for (let prop in event) {
660
- let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
661
- // called as event.nativeEvent.fn()
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()
662
664
 
663
- if (typeof property !== 'function') extractEventProps[prop] = property;
664
- }
665
+ if (typeof property !== 'function') extractEventProps[prop] = property;
666
+ }
665
667
 
666
- let raycastEvent = { ...hit,
667
- ...extractEventProps,
668
- pointer,
669
- intersections,
670
- stopped: localState.stopped,
671
- delta,
672
- unprojectedPoint,
673
- ray: raycaster.ray,
674
- camera: camera,
675
- // Hijack stopPropagation, which just sets a flag
676
- stopPropagation: () => {
677
- // https://github.com/pmndrs/react-three-fiber/issues/596
678
- // Events are not allowed to stop propagation if the pointer has been captured
679
- const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
680
-
681
- if ( // ...if this pointer hasn't been captured
682
- !capturesForPointer || // ... or if the hit object is capturing the pointer
683
- capturesForPointer.has(hit.eventObject)) {
684
- raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
685
- // An event handler is only allowed to flush other handlers if it is hovered itself
686
-
687
- if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
688
- // Objects cannot flush out higher up objects that have already caught the event
689
- const higher = intersections.slice(0, intersections.indexOf(hit));
690
- cancelPointer([...higher, hit]);
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
+ }
691
694
  }
692
- }
693
- },
694
- // there should be a distinction between target and currentTarget
695
- target: {
696
- hasPointerCapture,
697
- setPointerCapture,
698
- releasePointerCapture
699
- },
700
- currentTarget: {
701
- hasPointerCapture,
702
- setPointerCapture,
703
- releasePointerCapture
704
- },
705
- nativeEvent: event
706
- }; // Call subscribers
707
-
708
- callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
709
-
710
- if (localState.stopped === true) break;
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
+ }
711
714
  }
712
715
  }
713
716
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-f9709241.cjs.dev.js');
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');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-af0d582a.cjs.prod.js');
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');
@@ -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, b as useIsomorphicLayoutEffect, d as unmountComponentAtNode } from './index-44001bdc.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-44001bdc.esm.js';
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';
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('../../dist/index-f9709241.cjs.dev.js');
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-af0d582a.cjs.prod.js');
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-44001bdc.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-44001bdc.esm.js';
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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/fiber",
3
- "version": "8.7.1",
3
+ "version": "8.7.2",
4
4
  "description": "A React renderer for Threejs",
5
5
  "keywords": [
6
6
  "react",