Skip to content

Commit

Permalink
Add wasIntersected and wasIntersectedOnMouseDown properties to Intera…
Browse files Browse the repository at this point in the history
…ctiveEvent
  • Loading branch information
markuslerner committed Aug 8, 2024
1 parent e4183a8 commit 5b3ae8f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 25 deletions.
44 changes: 23 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,18 @@ Constructor of InteractionManager instance; if the autoAdd option (still beta) i

**Members:**

Member | Type | Default | Description
:----- | :--- | :------ | :----------
`treatTouchEventsAsMouseEvents` | boolean | true | Whether touch events should fire as mouse events
| Member | Type |  Default |  Description |
| :------------------------------ | :------ | :------- | :----------------------------------------------- |
| `treatTouchEventsAsMouseEvents` | boolean | true | Whether touch events should fire as mouse events |

**Methods:**

Method | Description
:----- | :----------
`add(object, childNames = [])` | Add object(s), optionally select only children of `object` by their names
`remove(object, childNames = [])` | Remove object(s), optionally select only children of `object` by their names
`update()` | Update InteractionManager on each render
`dispose()` | Dispose InteractionManager
| Method | Description |
| :-------------------------------- | :--------------------------------------------------------------------------- |
| `add(object, childNames = [])` | Add object(s), optionally select only children of `object` by their names |
| `remove(object, childNames = [])` | Remove object(s), optionally select only children of `object` by their names |
| `update()` | Update InteractionManager on each render |
| `dispose()` | Dispose InteractionManager |

#### InteractionManagerOptions class

Expand All @@ -169,21 +169,23 @@ Constructor of InteractionManagerOptions instance

**Members:**

Member | Type | Default | Description
:----- | :--- | :------ | :----------
`cancelBubble` | boolean | false | Whether events should continue to bubble
`coords` | THREE.Vector2 | | Mouse/touch coords
`distance` | Number | | Distance of intersected point from camera
`intersected` | boolean | | Whether object is still intersected
`originalEvent` | Event object | | Original event, if available (MouseEvent, TouchEvent or PointerEvent)
`target` | THREE.Object3D | | Target object
`type` | string | |event type: 'click', 'mouseover', 'mouseout', 'mouseenter', 'mouseleave', 'mousedown', 'mousemove', 'mouseup', 'touchstart', 'touchmove', 'touchend', 'pointerdown', 'pointerup', 'pointermove'
| Member | Type |  Default |  Description |
| :-------------------------- | :------------- | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cancelBubble` | boolean | false | Whether events should continue to bubble |
| `coords` | THREE.Vector2 | | Mouse/touch coords |
| `distance` | Number | | Distance of intersected point from camera |
| `intersected` | boolean | | Whether object is still intersected |
| `wasIntersected` | boolean | | Whether object was intersected during the last event or last render |
| `wasIntersectedOnMouseDown` | boolean | | Whether object was intersected during mousedown event |
| `originalEvent` | Event object | | Original event, if available (MouseEvent, TouchEvent or PointerEvent) |
| `target` | THREE.Object3D | | Target object |
| `type` | string | | event type: 'click', 'mouseover', 'mouseout', 'mouseenter', 'mouseleave', 'mousedown', 'mousemove', 'mouseup', 'touchstart', 'touchmove', 'touchend', 'pointerdown', 'pointerup', 'pointermove' |

**Methods:**

Method | Description
:----- | :----------
`stopPropagation` | Stop bubbling of event (cancelBubble), e.g. when only the object closest to the camera is supposed to fire an event
| Method | Description |
| :---------------- | :------------------------------------------------------------------------------------------------------------------ |
| `stopPropagation` | Stop bubbling of event (cancelBubble), e.g. when only the object closest to the camera is supposed to fire an event |

### Editing source

Expand Down
3 changes: 3 additions & 0 deletions build/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export declare class InteractiveObject {
name: string;
intersected: boolean;
wasIntersected: boolean;
wasIntersectedOnMouseDown: boolean;
distance: number;
constructor(target: THREE.Object3D, name: string);
}
Expand All @@ -14,6 +15,8 @@ export declare class InteractiveEvent {
coords: Vector2;
distance: number;
intersected: boolean;
wasIntersected: boolean;
wasIntersectedOnMouseDown: boolean;
constructor(type: string, originalEvent?: Event | null);
stopPropagation(): void;
}
Expand Down
Loading

0 comments on commit 5b3ae8f

Please sign in to comment.