@react-three/fiber 8.8.1 → 8.8.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.
@@ -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>;
@@ -609,113 +609,111 @@ function createEvents(store) {
609
609
 
610
610
 
611
611
  function handleIntersects(intersections, event, delta, callback) {
612
- // If anything has been found, forward it to the event listeners
612
+ const rootState = store.getState(); // If anything has been found, forward it to the event listeners
613
+
613
614
  if (intersections.length) {
614
615
  const localState = {
615
616
  stopped: false
616
617
  };
617
618
 
618
619
  for (const hit of intersections) {
619
- const state = getRootState(hit.object);
620
+ const state = getRootState(hit.object) || rootState;
621
+ const {
622
+ raycaster,
623
+ pointer,
624
+ camera,
625
+ internal
626
+ } = state;
627
+ const unprojectedPoint = new THREE__namespace.Vector3(pointer.x, pointer.y, 0).unproject(camera);
620
628
 
621
- if (state) {
622
- const {
623
- raycaster,
624
- pointer,
625
- camera,
626
- internal
627
- } = state;
628
- const unprojectedPoint = new THREE__namespace.Vector3(pointer.x, pointer.y, 0).unproject(camera);
629
+ const hasPointerCapture = id => {
630
+ var _internal$capturedMap, _internal$capturedMap2;
629
631
 
630
- const hasPointerCapture = id => {
631
- var _internal$capturedMap, _internal$capturedMap2;
632
+ return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
633
+ };
632
634
 
633
- return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
635
+ const setPointerCapture = id => {
636
+ const captureData = {
637
+ intersection: hit,
638
+ target: event.target
634
639
  };
635
640
 
636
- const setPointerCapture = id => {
637
- const captureData = {
638
- intersection: hit,
639
- target: event.target
640
- };
641
-
642
- if (internal.capturedMap.has(id)) {
643
- // if the pointerId was previously captured, we add the hit to the
644
- // event capturedMap.
645
- internal.capturedMap.get(id).set(hit.eventObject, captureData);
646
- } else {
647
- // if the pointerId was not previously captured, we create a map
648
- // containing the hitObject, and the hit. hitObject is used for
649
- // faster access.
650
- internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
651
- } // Call the original event now
652
- event.target.setPointerCapture(id);
653
- };
641
+ if (internal.capturedMap.has(id)) {
642
+ // if the pointerId was previously captured, we add the hit to the
643
+ // event capturedMap.
644
+ internal.capturedMap.get(id).set(hit.eventObject, captureData);
645
+ } else {
646
+ // if the pointerId was not previously captured, we create a map
647
+ // containing the hitObject, and the hit. hitObject is used for
648
+ // faster access.
649
+ internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
650
+ } // Call the original event now
651
+ event.target.setPointerCapture(id);
652
+ };
654
653
 
655
- const releasePointerCapture = id => {
656
- const captures = internal.capturedMap.get(id);
654
+ const releasePointerCapture = id => {
655
+ const captures = internal.capturedMap.get(id);
657
656
 
658
- if (captures) {
659
- releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
660
- }
661
- }; // Add native event props
657
+ if (captures) {
658
+ releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
659
+ }
660
+ }; // Add native event props
662
661
 
663
662
 
664
- 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.
663
+ 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.
665
664
 
666
- for (let prop in event) {
667
- let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
668
- // called as event.nativeEvent.fn()
665
+ for (let prop in event) {
666
+ let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
667
+ // called as event.nativeEvent.fn()
669
668
 
670
- if (typeof property !== 'function') extractEventProps[prop] = property;
671
- }
669
+ if (typeof property !== 'function') extractEventProps[prop] = property;
670
+ }
672
671
 
673
- let raycastEvent = { ...hit,
674
- ...extractEventProps,
675
- pointer,
676
- intersections,
677
- stopped: localState.stopped,
678
- delta,
679
- unprojectedPoint,
680
- ray: raycaster.ray,
681
- camera: camera,
682
- // Hijack stopPropagation, which just sets a flag
683
- stopPropagation: () => {
684
- // https://github.com/pmndrs/react-three-fiber/issues/596
685
- // Events are not allowed to stop propagation if the pointer has been captured
686
- const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
687
-
688
- if ( // ...if this pointer hasn't been captured
689
- !capturesForPointer || // ... or if the hit object is capturing the pointer
690
- capturesForPointer.has(hit.eventObject)) {
691
- raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
692
- // An event handler is only allowed to flush other handlers if it is hovered itself
693
-
694
- if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
695
- // Objects cannot flush out higher up objects that have already caught the event
696
- const higher = intersections.slice(0, intersections.indexOf(hit));
697
- cancelPointer([...higher, hit]);
698
- }
672
+ let raycastEvent = { ...hit,
673
+ ...extractEventProps,
674
+ pointer,
675
+ intersections,
676
+ stopped: localState.stopped,
677
+ delta,
678
+ unprojectedPoint,
679
+ ray: raycaster.ray,
680
+ camera: camera,
681
+ // Hijack stopPropagation, which just sets a flag
682
+ stopPropagation: () => {
683
+ // https://github.com/pmndrs/react-three-fiber/issues/596
684
+ // Events are not allowed to stop propagation if the pointer has been captured
685
+ const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
686
+
687
+ if ( // ...if this pointer hasn't been captured
688
+ !capturesForPointer || // ... or if the hit object is capturing the pointer
689
+ capturesForPointer.has(hit.eventObject)) {
690
+ raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
691
+ // An event handler is only allowed to flush other handlers if it is hovered itself
692
+
693
+ if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
694
+ // Objects cannot flush out higher up objects that have already caught the event
695
+ const higher = intersections.slice(0, intersections.indexOf(hit));
696
+ cancelPointer([...higher, hit]);
699
697
  }
700
- },
701
- // there should be a distinction between target and currentTarget
702
- target: {
703
- hasPointerCapture,
704
- setPointerCapture,
705
- releasePointerCapture
706
- },
707
- currentTarget: {
708
- hasPointerCapture,
709
- setPointerCapture,
710
- releasePointerCapture
711
- },
712
- nativeEvent: event
713
- }; // Call subscribers
714
-
715
- callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
716
-
717
- if (localState.stopped === true) break;
718
- }
698
+ }
699
+ },
700
+ // there should be a distinction between target and currentTarget
701
+ target: {
702
+ hasPointerCapture,
703
+ setPointerCapture,
704
+ releasePointerCapture
705
+ },
706
+ currentTarget: {
707
+ hasPointerCapture,
708
+ setPointerCapture,
709
+ releasePointerCapture
710
+ },
711
+ nativeEvent: event
712
+ }; // Call subscribers
713
+
714
+ callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
715
+
716
+ if (localState.stopped === true) break;
719
717
  }
720
718
  }
721
719
 
@@ -609,113 +609,111 @@ function createEvents(store) {
609
609
 
610
610
 
611
611
  function handleIntersects(intersections, event, delta, callback) {
612
- // If anything has been found, forward it to the event listeners
612
+ const rootState = store.getState(); // If anything has been found, forward it to the event listeners
613
+
613
614
  if (intersections.length) {
614
615
  const localState = {
615
616
  stopped: false
616
617
  };
617
618
 
618
619
  for (const hit of intersections) {
619
- const state = getRootState(hit.object);
620
+ const state = getRootState(hit.object) || rootState;
621
+ const {
622
+ raycaster,
623
+ pointer,
624
+ camera,
625
+ internal
626
+ } = state;
627
+ const unprojectedPoint = new THREE__namespace.Vector3(pointer.x, pointer.y, 0).unproject(camera);
620
628
 
621
- if (state) {
622
- const {
623
- raycaster,
624
- pointer,
625
- camera,
626
- internal
627
- } = state;
628
- const unprojectedPoint = new THREE__namespace.Vector3(pointer.x, pointer.y, 0).unproject(camera);
629
+ const hasPointerCapture = id => {
630
+ var _internal$capturedMap, _internal$capturedMap2;
629
631
 
630
- const hasPointerCapture = id => {
631
- var _internal$capturedMap, _internal$capturedMap2;
632
+ return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
633
+ };
632
634
 
633
- return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
635
+ const setPointerCapture = id => {
636
+ const captureData = {
637
+ intersection: hit,
638
+ target: event.target
634
639
  };
635
640
 
636
- const setPointerCapture = id => {
637
- const captureData = {
638
- intersection: hit,
639
- target: event.target
640
- };
641
-
642
- if (internal.capturedMap.has(id)) {
643
- // if the pointerId was previously captured, we add the hit to the
644
- // event capturedMap.
645
- internal.capturedMap.get(id).set(hit.eventObject, captureData);
646
- } else {
647
- // if the pointerId was not previously captured, we create a map
648
- // containing the hitObject, and the hit. hitObject is used for
649
- // faster access.
650
- internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
651
- } // Call the original event now
652
- event.target.setPointerCapture(id);
653
- };
641
+ if (internal.capturedMap.has(id)) {
642
+ // if the pointerId was previously captured, we add the hit to the
643
+ // event capturedMap.
644
+ internal.capturedMap.get(id).set(hit.eventObject, captureData);
645
+ } else {
646
+ // if the pointerId was not previously captured, we create a map
647
+ // containing the hitObject, and the hit. hitObject is used for
648
+ // faster access.
649
+ internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
650
+ } // Call the original event now
651
+ event.target.setPointerCapture(id);
652
+ };
654
653
 
655
- const releasePointerCapture = id => {
656
- const captures = internal.capturedMap.get(id);
654
+ const releasePointerCapture = id => {
655
+ const captures = internal.capturedMap.get(id);
657
656
 
658
- if (captures) {
659
- releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
660
- }
661
- }; // Add native event props
657
+ if (captures) {
658
+ releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
659
+ }
660
+ }; // Add native event props
662
661
 
663
662
 
664
- 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.
663
+ 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.
665
664
 
666
- for (let prop in event) {
667
- let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
668
- // called as event.nativeEvent.fn()
665
+ for (let prop in event) {
666
+ let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
667
+ // called as event.nativeEvent.fn()
669
668
 
670
- if (typeof property !== 'function') extractEventProps[prop] = property;
671
- }
669
+ if (typeof property !== 'function') extractEventProps[prop] = property;
670
+ }
672
671
 
673
- let raycastEvent = { ...hit,
674
- ...extractEventProps,
675
- pointer,
676
- intersections,
677
- stopped: localState.stopped,
678
- delta,
679
- unprojectedPoint,
680
- ray: raycaster.ray,
681
- camera: camera,
682
- // Hijack stopPropagation, which just sets a flag
683
- stopPropagation: () => {
684
- // https://github.com/pmndrs/react-three-fiber/issues/596
685
- // Events are not allowed to stop propagation if the pointer has been captured
686
- const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
687
-
688
- if ( // ...if this pointer hasn't been captured
689
- !capturesForPointer || // ... or if the hit object is capturing the pointer
690
- capturesForPointer.has(hit.eventObject)) {
691
- raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
692
- // An event handler is only allowed to flush other handlers if it is hovered itself
693
-
694
- if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
695
- // Objects cannot flush out higher up objects that have already caught the event
696
- const higher = intersections.slice(0, intersections.indexOf(hit));
697
- cancelPointer([...higher, hit]);
698
- }
672
+ let raycastEvent = { ...hit,
673
+ ...extractEventProps,
674
+ pointer,
675
+ intersections,
676
+ stopped: localState.stopped,
677
+ delta,
678
+ unprojectedPoint,
679
+ ray: raycaster.ray,
680
+ camera: camera,
681
+ // Hijack stopPropagation, which just sets a flag
682
+ stopPropagation: () => {
683
+ // https://github.com/pmndrs/react-three-fiber/issues/596
684
+ // Events are not allowed to stop propagation if the pointer has been captured
685
+ const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
686
+
687
+ if ( // ...if this pointer hasn't been captured
688
+ !capturesForPointer || // ... or if the hit object is capturing the pointer
689
+ capturesForPointer.has(hit.eventObject)) {
690
+ raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
691
+ // An event handler is only allowed to flush other handlers if it is hovered itself
692
+
693
+ if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
694
+ // Objects cannot flush out higher up objects that have already caught the event
695
+ const higher = intersections.slice(0, intersections.indexOf(hit));
696
+ cancelPointer([...higher, hit]);
699
697
  }
700
- },
701
- // there should be a distinction between target and currentTarget
702
- target: {
703
- hasPointerCapture,
704
- setPointerCapture,
705
- releasePointerCapture
706
- },
707
- currentTarget: {
708
- hasPointerCapture,
709
- setPointerCapture,
710
- releasePointerCapture
711
- },
712
- nativeEvent: event
713
- }; // Call subscribers
714
-
715
- callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
716
-
717
- if (localState.stopped === true) break;
718
- }
698
+ }
699
+ },
700
+ // there should be a distinction between target and currentTarget
701
+ target: {
702
+ hasPointerCapture,
703
+ setPointerCapture,
704
+ releasePointerCapture
705
+ },
706
+ currentTarget: {
707
+ hasPointerCapture,
708
+ setPointerCapture,
709
+ releasePointerCapture
710
+ },
711
+ nativeEvent: event
712
+ }; // Call subscribers
713
+
714
+ callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
715
+
716
+ if (localState.stopped === true) break;
719
717
  }
720
718
  }
721
719
 
@@ -582,113 +582,111 @@ function createEvents(store) {
582
582
 
583
583
 
584
584
  function handleIntersects(intersections, event, delta, callback) {
585
- // If anything has been found, forward it to the event listeners
585
+ const rootState = store.getState(); // If anything has been found, forward it to the event listeners
586
+
586
587
  if (intersections.length) {
587
588
  const localState = {
588
589
  stopped: false
589
590
  };
590
591
 
591
592
  for (const hit of intersections) {
592
- const state = getRootState(hit.object);
593
+ const state = getRootState(hit.object) || rootState;
594
+ const {
595
+ raycaster,
596
+ pointer,
597
+ camera,
598
+ internal
599
+ } = state;
600
+ const unprojectedPoint = new THREE.Vector3(pointer.x, pointer.y, 0).unproject(camera);
593
601
 
594
- if (state) {
595
- const {
596
- raycaster,
597
- pointer,
598
- camera,
599
- internal
600
- } = state;
601
- const unprojectedPoint = new THREE.Vector3(pointer.x, pointer.y, 0).unproject(camera);
602
+ const hasPointerCapture = id => {
603
+ var _internal$capturedMap, _internal$capturedMap2;
602
604
 
603
- const hasPointerCapture = id => {
604
- var _internal$capturedMap, _internal$capturedMap2;
605
+ return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
606
+ };
605
607
 
606
- return (_internal$capturedMap = (_internal$capturedMap2 = internal.capturedMap.get(id)) == null ? void 0 : _internal$capturedMap2.has(hit.eventObject)) != null ? _internal$capturedMap : false;
608
+ const setPointerCapture = id => {
609
+ const captureData = {
610
+ intersection: hit,
611
+ target: event.target
607
612
  };
608
613
 
609
- const setPointerCapture = id => {
610
- const captureData = {
611
- intersection: hit,
612
- target: event.target
613
- };
614
-
615
- if (internal.capturedMap.has(id)) {
616
- // if the pointerId was previously captured, we add the hit to the
617
- // event capturedMap.
618
- internal.capturedMap.get(id).set(hit.eventObject, captureData);
619
- } else {
620
- // if the pointerId was not previously captured, we create a map
621
- // containing the hitObject, and the hit. hitObject is used for
622
- // faster access.
623
- internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
624
- } // Call the original event now
625
- event.target.setPointerCapture(id);
626
- };
614
+ if (internal.capturedMap.has(id)) {
615
+ // if the pointerId was previously captured, we add the hit to the
616
+ // event capturedMap.
617
+ internal.capturedMap.get(id).set(hit.eventObject, captureData);
618
+ } else {
619
+ // if the pointerId was not previously captured, we create a map
620
+ // containing the hitObject, and the hit. hitObject is used for
621
+ // faster access.
622
+ internal.capturedMap.set(id, new Map([[hit.eventObject, captureData]]));
623
+ } // Call the original event now
624
+ event.target.setPointerCapture(id);
625
+ };
627
626
 
628
- const releasePointerCapture = id => {
629
- const captures = internal.capturedMap.get(id);
627
+ const releasePointerCapture = id => {
628
+ const captures = internal.capturedMap.get(id);
630
629
 
631
- if (captures) {
632
- releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
633
- }
634
- }; // Add native event props
630
+ if (captures) {
631
+ releaseInternalPointerCapture(internal.capturedMap, hit.eventObject, captures, id);
632
+ }
633
+ }; // Add native event props
635
634
 
636
635
 
637
- 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.
636
+ 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.
638
637
 
639
- for (let prop in event) {
640
- let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
641
- // called as event.nativeEvent.fn()
638
+ for (let prop in event) {
639
+ let property = event[prop]; // Only copy over atomics, leave functions alone as these should be
640
+ // called as event.nativeEvent.fn()
642
641
 
643
- if (typeof property !== 'function') extractEventProps[prop] = property;
644
- }
642
+ if (typeof property !== 'function') extractEventProps[prop] = property;
643
+ }
645
644
 
646
- let raycastEvent = { ...hit,
647
- ...extractEventProps,
648
- pointer,
649
- intersections,
650
- stopped: localState.stopped,
651
- delta,
652
- unprojectedPoint,
653
- ray: raycaster.ray,
654
- camera: camera,
655
- // Hijack stopPropagation, which just sets a flag
656
- stopPropagation: () => {
657
- // https://github.com/pmndrs/react-three-fiber/issues/596
658
- // Events are not allowed to stop propagation if the pointer has been captured
659
- const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
660
-
661
- if ( // ...if this pointer hasn't been captured
662
- !capturesForPointer || // ... or if the hit object is capturing the pointer
663
- capturesForPointer.has(hit.eventObject)) {
664
- raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
665
- // An event handler is only allowed to flush other handlers if it is hovered itself
666
-
667
- if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
668
- // Objects cannot flush out higher up objects that have already caught the event
669
- const higher = intersections.slice(0, intersections.indexOf(hit));
670
- cancelPointer([...higher, hit]);
671
- }
645
+ let raycastEvent = { ...hit,
646
+ ...extractEventProps,
647
+ pointer,
648
+ intersections,
649
+ stopped: localState.stopped,
650
+ delta,
651
+ unprojectedPoint,
652
+ ray: raycaster.ray,
653
+ camera: camera,
654
+ // Hijack stopPropagation, which just sets a flag
655
+ stopPropagation: () => {
656
+ // https://github.com/pmndrs/react-three-fiber/issues/596
657
+ // Events are not allowed to stop propagation if the pointer has been captured
658
+ const capturesForPointer = 'pointerId' in event && internal.capturedMap.get(event.pointerId); // We only authorize stopPropagation...
659
+
660
+ if ( // ...if this pointer hasn't been captured
661
+ !capturesForPointer || // ... or if the hit object is capturing the pointer
662
+ capturesForPointer.has(hit.eventObject)) {
663
+ raycastEvent.stopped = localState.stopped = true; // Propagation is stopped, remove all other hover records
664
+ // An event handler is only allowed to flush other handlers if it is hovered itself
665
+
666
+ if (internal.hovered.size && Array.from(internal.hovered.values()).find(i => i.eventObject === hit.eventObject)) {
667
+ // Objects cannot flush out higher up objects that have already caught the event
668
+ const higher = intersections.slice(0, intersections.indexOf(hit));
669
+ cancelPointer([...higher, hit]);
672
670
  }
673
- },
674
- // there should be a distinction between target and currentTarget
675
- target: {
676
- hasPointerCapture,
677
- setPointerCapture,
678
- releasePointerCapture
679
- },
680
- currentTarget: {
681
- hasPointerCapture,
682
- setPointerCapture,
683
- releasePointerCapture
684
- },
685
- nativeEvent: event
686
- }; // Call subscribers
687
-
688
- callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
689
-
690
- if (localState.stopped === true) break;
691
- }
671
+ }
672
+ },
673
+ // there should be a distinction between target and currentTarget
674
+ target: {
675
+ hasPointerCapture,
676
+ setPointerCapture,
677
+ releasePointerCapture
678
+ },
679
+ currentTarget: {
680
+ hasPointerCapture,
681
+ setPointerCapture,
682
+ releasePointerCapture
683
+ },
684
+ nativeEvent: event
685
+ }; // Call subscribers
686
+
687
+ callback(raycastEvent); // Event bubbling may be interrupted by stopPropagation
688
+
689
+ if (localState.stopped === true) break;
692
690
  }
693
691
  }
694
692