-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathADR-401-drag-pointers
More file actions
67 lines (52 loc) · 2.56 KB
/
Copy pathADR-401-drag-pointers
File metadata and controls
67 lines (52 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
layout: adr
adr: 401
title: Pointer Drag Events
date: 2025-03-03
status: Draft
type: RFC
spdx-license: CC0-1.0
authors:
- robtfm
---
## Pointer Drag Events
Extend the current set of pointer events to include drag events, and provide facilities to manage them from UI and scene interactions.
## PointerEventType
We extend the PointerEventType enum with 3 new cases:
```
// PointerEventType is a kind of interaction that can be detected.
enum PointerEventType {
...
PET_DRAG_LOCKED = 4;
PET_DRAG = 5;
PET_DRAG_END = 6;
}
```
`PET_DRAG` and `PET_DRAG_LOCKED` both provide callbacks when the pointer is in the interaction area for the given entity, the designated input button is pressed, and the pointer input device (e.g. mouse) is moved while the button is held.
The difference between these 2 events is only in the treatment of the pointer during dragging: for `PET_DRAG_LOCKED` the explorer must keep the pointer at the original position, while for `PET_DRAG` the explorer allows the pointer to move around the screen as normal. When the pointer is locked, `PET_DRAG_LOCKED` stops the camera from rotating while dragging, and `PET_DRAG` allows it to rotate as normal.
`PET_DRAG_END` fires a callback when the button is released following a drag event.
`PET_DRAG` and `PET_DRAG_END` callbacks must still be called even if the pointer moves outside of the interaction bounds of the entity during dragging.
The mouse delta (in pixels) since last callback is provided in the `xy` fields of the `direction` field of the `RaycastHit` result passed to the callback.
The SDK `PointerEventsSystem` will provide helpers for these new event types, `onPointerDrag`, `removeOnPointerDrag`, etc.
## UI interactions
The SDK will also provides react ui properties `onMouseDrag`, `onMouseDragLocked` and `onMouseDragEnd`. Note that these callbacks take no parameters, so the drag information is also made available separately via a new `PrimaryPointerInfo` component on the scene root:
```
option (common.ecs_component_id) = 1209;
message PBPrimaryPointerInfo {
optional PointerType pointer_type = 1;
// in pixels
optional decentraland.common.Vector2 screen_coordinates = 2;
// in pixels
optional decentraland.common.Vector2 screen_delta = 3;
// ray direction that can be used with the primary camera origin for
// raycasting from the cursor into the world
optional decentraland.common.Vector3 world_ray_direction = 4;
}
enum PointerType {
POT_NONE = 0;
POT_MOUSE = 1;
POT_PAD = 2;
POT_TOUCH = 3;
POT_WAND = 4;
}
```