@dcl-regenesislabs/ecs 7.33.1-45463223330.commit-bb0e4a4 → 7.33.1-45493173181.commit-4abbc35
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/dist/components/extended/MeshCollider.d.ts +10 -0
- package/dist/components/extended/MeshCollider.js +6 -0
- package/dist/components/extended/MeshRenderer.d.ts +9 -0
- package/dist/components/extended/MeshRenderer.js +5 -0
- package/dist/systems/events.d.ts +51 -0
- package/dist/systems/events.js +52 -1
- package/dist/systems/raycast.d.ts +5 -1
- package/dist/systems/raycast.js +5 -1
- package/dist-cjs/components/extended/MeshCollider.d.ts +10 -0
- package/dist-cjs/components/extended/MeshCollider.js +6 -0
- package/dist-cjs/components/extended/MeshRenderer.d.ts +9 -0
- package/dist-cjs/components/extended/MeshRenderer.js +5 -0
- package/dist-cjs/systems/events.d.ts +51 -0
- package/dist-cjs/systems/events.js +52 -1
- package/dist-cjs/systems/raycast.d.ts +5 -1
- package/dist-cjs/systems/raycast.js +5 -1
- package/package.json +1 -1
|
@@ -34,5 +34,15 @@ export interface MeshColliderComponentDefinitionExtended extends LastWriteWinEle
|
|
|
34
34
|
* @param colliderMask - the set of layer where the collider reacts, default: Physics and Pointer
|
|
35
35
|
*/
|
|
36
36
|
setSphere(entity: Entity, colliderLayers?: ColliderLayer | ColliderLayer[]): void;
|
|
37
|
+
/**
|
|
38
|
+
* @public
|
|
39
|
+
* Set a mesh from inside a gltf in the MeshCollider component.
|
|
40
|
+
* Supported only by the Bevy Explorer; other clients ignore it.
|
|
41
|
+
* @param entity - entity to create or replace the MeshCollider component
|
|
42
|
+
* @param source - the path to the gltf
|
|
43
|
+
* @param meshName - the name of the mesh in the gltf (see GltfContainerLoadingState.meshNames)
|
|
44
|
+
* @param colliderMask - the set of layer where the collider reacts, default: Physics and Pointer
|
|
45
|
+
*/
|
|
46
|
+
setGltfMesh(entity: Entity, source: string, meshName: string, colliderLayers?: ColliderLayer | ColliderLayer[]): void;
|
|
37
47
|
}
|
|
38
48
|
export declare function defineMeshColliderComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): MeshColliderComponentDefinitionExtended;
|
|
@@ -34,6 +34,12 @@ export function defineMeshColliderComponent(engine) {
|
|
|
34
34
|
mesh: { $case: 'sphere', sphere: {} },
|
|
35
35
|
collisionMask: getCollisionMask(colliderLayers)
|
|
36
36
|
});
|
|
37
|
+
},
|
|
38
|
+
setGltfMesh(entity, source, meshName, colliderLayers) {
|
|
39
|
+
theComponent.createOrReplace(entity, {
|
|
40
|
+
mesh: { $case: 'gltf', gltf: { gltfSrc: source, name: meshName } },
|
|
41
|
+
collisionMask: getCollisionMask(colliderLayers)
|
|
42
|
+
});
|
|
37
43
|
}
|
|
38
44
|
};
|
|
39
45
|
}
|
|
@@ -32,5 +32,14 @@ export interface MeshRendererComponentDefinitionExtended extends LastWriteWinEle
|
|
|
32
32
|
* @param entity - entity to create or replace the MeshRenderer component
|
|
33
33
|
*/
|
|
34
34
|
setSphere(entity: Entity): void;
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
* Set a mesh from inside a gltf in the MeshRenderer component.
|
|
38
|
+
* Supported only by the Bevy Explorer; other clients ignore it.
|
|
39
|
+
* @param entity - entity to create or replace the MeshRenderer component
|
|
40
|
+
* @param source - the path to the gltf
|
|
41
|
+
* @param meshName - the name of the mesh in the gltf (see GltfContainerLoadingState.meshNames)
|
|
42
|
+
*/
|
|
43
|
+
setGltfMesh(entity: Entity, source: string, meshName: string): void;
|
|
35
44
|
}
|
|
36
45
|
export declare function defineMeshRendererComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): MeshRendererComponentDefinitionExtended;
|
|
@@ -22,6 +22,11 @@ export function defineMeshRendererComponent(engine) {
|
|
|
22
22
|
theComponent.createOrReplace(entity, {
|
|
23
23
|
mesh: { $case: 'sphere', sphere: {} }
|
|
24
24
|
});
|
|
25
|
+
},
|
|
26
|
+
setGltfMesh(entity, source, meshName) {
|
|
27
|
+
theComponent.createOrReplace(entity, {
|
|
28
|
+
mesh: { $case: 'gltf', gltf: { gltfSrc: source, name: meshName } }
|
|
29
|
+
});
|
|
25
30
|
}
|
|
26
31
|
};
|
|
27
32
|
}
|
package/dist/systems/events.d.ts
CHANGED
|
@@ -50,6 +50,24 @@ export interface PointerEventsSystem {
|
|
|
50
50
|
* @param entity - Entity where the callback was attached
|
|
51
51
|
*/
|
|
52
52
|
removeOnPointerHoverLeave(entity: Entity): void;
|
|
53
|
+
/**
|
|
54
|
+
* @public
|
|
55
|
+
* Remove the callback for onPointerDrag event
|
|
56
|
+
* @param entity - Entity where the callback was attached
|
|
57
|
+
*/
|
|
58
|
+
removeOnPointerDrag(entity: Entity): void;
|
|
59
|
+
/**
|
|
60
|
+
* @public
|
|
61
|
+
* Remove the callback for onPointerDragLocked event
|
|
62
|
+
* @param entity - Entity where the callback was attached
|
|
63
|
+
*/
|
|
64
|
+
removeOnPointerDragLocked(entity: Entity): void;
|
|
65
|
+
/**
|
|
66
|
+
* @public
|
|
67
|
+
* Remove the callback for onPointerDragEnd event
|
|
68
|
+
* @param entity - Entity where the callback was attached
|
|
69
|
+
*/
|
|
70
|
+
removeOnPointerDragEnd(entity: Entity): void;
|
|
53
71
|
/**
|
|
54
72
|
* @public
|
|
55
73
|
* Remove the callback for onProximityDown event
|
|
@@ -128,6 +146,39 @@ export interface PointerEventsSystem {
|
|
|
128
146
|
entity: Entity;
|
|
129
147
|
opts?: Partial<EventSystemOptions>;
|
|
130
148
|
}, cb: EventSystemCallback): void;
|
|
149
|
+
/**
|
|
150
|
+
* @public
|
|
151
|
+
* Execute callback while the user holds the button pressed and moves the pointer, having pressed it on the entity.
|
|
152
|
+
* Supported only by the Bevy Explorer; other clients ignore it.
|
|
153
|
+
* @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button
|
|
154
|
+
* @param cb - Function to execute on every drag update
|
|
155
|
+
*/
|
|
156
|
+
onPointerDrag(pointerData: {
|
|
157
|
+
entity: Entity;
|
|
158
|
+
opts?: Partial<EventSystemOptions>;
|
|
159
|
+
}, cb: EventSystemCallback): void;
|
|
160
|
+
/**
|
|
161
|
+
* @public
|
|
162
|
+
* Same as onPointerDrag, but the cursor is locked in place for the duration of the drag.
|
|
163
|
+
* Supported only by the Bevy Explorer; other clients ignore it.
|
|
164
|
+
* @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button
|
|
165
|
+
* @param cb - Function to execute on every drag update
|
|
166
|
+
*/
|
|
167
|
+
onPointerDragLocked(pointerData: {
|
|
168
|
+
entity: Entity;
|
|
169
|
+
opts?: Partial<EventSystemOptions>;
|
|
170
|
+
}, cb: EventSystemCallback): void;
|
|
171
|
+
/**
|
|
172
|
+
* @public
|
|
173
|
+
* Execute callback when the user releases the button after a drag that started on the entity.
|
|
174
|
+
* Supported only by the Bevy Explorer; other clients ignore it.
|
|
175
|
+
* @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button
|
|
176
|
+
* @param cb - Function to execute when the drag ends
|
|
177
|
+
*/
|
|
178
|
+
onPointerDragEnd(pointerData: {
|
|
179
|
+
entity: Entity;
|
|
180
|
+
opts?: Partial<EventSystemOptions>;
|
|
181
|
+
}, cb: EventSystemCallback): void;
|
|
131
182
|
/**
|
|
132
183
|
* @public
|
|
133
184
|
* Execute callback when the user presses the proximity button on the entity
|
package/dist/systems/events.js
CHANGED
|
@@ -20,6 +20,9 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
20
20
|
EventType[EventType["HoverLeave"] = 4] = "HoverLeave";
|
|
21
21
|
EventType[EventType["ProximityEnter"] = 5] = "ProximityEnter";
|
|
22
22
|
EventType[EventType["ProximityLeave"] = 6] = "ProximityLeave";
|
|
23
|
+
EventType[EventType["Drag"] = 7] = "Drag";
|
|
24
|
+
EventType[EventType["DragLocked"] = 8] = "DragLocked";
|
|
25
|
+
EventType[EventType["DragEnd"] = 9] = "DragEnd";
|
|
23
26
|
})(EventType || (EventType = {}));
|
|
24
27
|
const eventsMap = new Map();
|
|
25
28
|
function getEvent(entity) {
|
|
@@ -90,6 +93,15 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
90
93
|
else if (eventType === EventType.ProximityLeave) {
|
|
91
94
|
return 5 /* PointerEventType.PET_PROXIMITY_LEAVE */;
|
|
92
95
|
}
|
|
96
|
+
else if (eventType === EventType.Drag) {
|
|
97
|
+
return 7 /* PointerEventType.PET_DRAG */;
|
|
98
|
+
}
|
|
99
|
+
else if (eventType === EventType.DragLocked) {
|
|
100
|
+
return 6 /* PointerEventType.PET_DRAG_LOCKED */;
|
|
101
|
+
}
|
|
102
|
+
else if (eventType === EventType.DragEnd) {
|
|
103
|
+
return 8 /* PointerEventType.PET_DRAG_END */;
|
|
104
|
+
}
|
|
93
105
|
return 1 /* PointerEventType.PET_DOWN */;
|
|
94
106
|
}
|
|
95
107
|
function removeEvent(entity, type, interactionType = 0 /* InteractionType.CURSOR */) {
|
|
@@ -122,7 +134,10 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
122
134
|
eventType === EventType.HoverEnter ||
|
|
123
135
|
eventType === EventType.HoverLeave ||
|
|
124
136
|
eventType === EventType.ProximityEnter ||
|
|
125
|
-
eventType === EventType.ProximityLeave
|
|
137
|
+
eventType === EventType.ProximityLeave ||
|
|
138
|
+
eventType === EventType.Drag ||
|
|
139
|
+
eventType === EventType.DragLocked ||
|
|
140
|
+
eventType === EventType.DragEnd) {
|
|
126
141
|
const command = inputSystem.getInputCommand(opts.button, getPointerEvent(eventType), entity);
|
|
127
142
|
if (command) {
|
|
128
143
|
checkNotThenable(cb(command), 'Event handler returned a thenable. Only synchronous functions are allowed');
|
|
@@ -169,6 +184,30 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
169
184
|
setEvent(entity, EventType.HoverLeave, cb, options);
|
|
170
185
|
setPointerEvent(entity, 3 /* PointerEventType.PET_HOVER_LEAVE */, options);
|
|
171
186
|
};
|
|
187
|
+
const onPointerDrag = (...args) => {
|
|
188
|
+
const [data, cb] = args;
|
|
189
|
+
const { entity, opts } = data;
|
|
190
|
+
const options = getDefaultOpts(opts);
|
|
191
|
+
removeEvent(entity, EventType.Drag);
|
|
192
|
+
setEvent(entity, EventType.Drag, cb, options);
|
|
193
|
+
setPointerEvent(entity, 7 /* PointerEventType.PET_DRAG */, options);
|
|
194
|
+
};
|
|
195
|
+
const onPointerDragLocked = (...args) => {
|
|
196
|
+
const [data, cb] = args;
|
|
197
|
+
const { entity, opts } = data;
|
|
198
|
+
const options = getDefaultOpts(opts);
|
|
199
|
+
removeEvent(entity, EventType.DragLocked);
|
|
200
|
+
setEvent(entity, EventType.DragLocked, cb, options);
|
|
201
|
+
setPointerEvent(entity, 6 /* PointerEventType.PET_DRAG_LOCKED */, options);
|
|
202
|
+
};
|
|
203
|
+
const onPointerDragEnd = (...args) => {
|
|
204
|
+
const [data, cb] = args;
|
|
205
|
+
const { entity, opts } = data;
|
|
206
|
+
const options = getDefaultOpts(opts);
|
|
207
|
+
removeEvent(entity, EventType.DragEnd);
|
|
208
|
+
setEvent(entity, EventType.DragEnd, cb, options);
|
|
209
|
+
setPointerEvent(entity, 8 /* PointerEventType.PET_DRAG_END */, options);
|
|
210
|
+
};
|
|
172
211
|
const onProximityDown = (...args) => {
|
|
173
212
|
const [data, cb] = args;
|
|
174
213
|
const { entity, opts } = data;
|
|
@@ -217,6 +256,15 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
217
256
|
removeOnPointerHoverLeave(entity) {
|
|
218
257
|
removeEvent(entity, EventType.HoverLeave);
|
|
219
258
|
},
|
|
259
|
+
removeOnPointerDrag(entity) {
|
|
260
|
+
removeEvent(entity, EventType.Drag);
|
|
261
|
+
},
|
|
262
|
+
removeOnPointerDragLocked(entity) {
|
|
263
|
+
removeEvent(entity, EventType.DragLocked);
|
|
264
|
+
},
|
|
265
|
+
removeOnPointerDragEnd(entity) {
|
|
266
|
+
removeEvent(entity, EventType.DragEnd);
|
|
267
|
+
},
|
|
220
268
|
removeOnProximityDown(entity) {
|
|
221
269
|
removeEvent(entity, EventType.Down, 1 /* InteractionType.PROXIMITY */);
|
|
222
270
|
},
|
|
@@ -242,6 +290,9 @@ export function createPointerEventsSystem(engine, inputSystem) {
|
|
|
242
290
|
onPointerUp,
|
|
243
291
|
onPointerHoverEnter,
|
|
244
292
|
onPointerHoverLeave,
|
|
293
|
+
onPointerDrag,
|
|
294
|
+
onPointerDragLocked,
|
|
295
|
+
onPointerDragEnd,
|
|
245
296
|
onProximityDown,
|
|
246
297
|
onProximityUp,
|
|
247
298
|
onProximityEnter,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RaycastQueryType, PBRaycastResult } from '../components';
|
|
1
|
+
import { RaycastQueryType, RaycastShape, PBRaycastResult } from '../components';
|
|
2
2
|
import { DeepReadonlyObject, Entity } from '../engine';
|
|
3
3
|
import { Vector3 } from '../components/generated/pb/decentraland/common/vectors.gen';
|
|
4
4
|
/**
|
|
@@ -14,6 +14,10 @@ export type RaycastSystemOptions = {
|
|
|
14
14
|
queryType: RaycastQueryType;
|
|
15
15
|
continuous?: boolean | undefined;
|
|
16
16
|
collisionMask?: number | undefined;
|
|
17
|
+
/** shape to sweep along the ray, default RS_RAY (a point). Supported only by the Bevy Explorer; other clients ignore it. */
|
|
18
|
+
shape?: RaycastShape | undefined;
|
|
19
|
+
/** include colliders from other scenes, default false. Supported only by the Bevy Explorer; other clients ignore it. */
|
|
20
|
+
includeWorld?: boolean | undefined;
|
|
17
21
|
};
|
|
18
22
|
export type LocalDirectionRaycastSystemOptions = {
|
|
19
23
|
direction?: Vector3;
|
package/dist/systems/raycast.js
CHANGED
|
@@ -12,7 +12,9 @@ export function createRaycastSystem(engine) {
|
|
|
12
12
|
queryType: 0 /* RaycastQueryType.RQT_HIT_FIRST */,
|
|
13
13
|
continuous: false,
|
|
14
14
|
originOffset: { x: 0, y: 0, z: 0 },
|
|
15
|
-
collisionMask: 2 /* ColliderLayer.CL_PHYSICS
|
|
15
|
+
collisionMask: 2 /* ColliderLayer.CL_PHYSICS */,
|
|
16
|
+
shape: 0 /* RaycastShape.RS_RAY */,
|
|
17
|
+
includeWorld: false
|
|
16
18
|
};
|
|
17
19
|
const getLocalDirectionRaycastDefaultOptions = (options = {}) => ({
|
|
18
20
|
...defaultOptions,
|
|
@@ -58,6 +60,8 @@ export function createRaycastSystem(engine) {
|
|
|
58
60
|
raycast.direction = raycastValue.directionRawValue;
|
|
59
61
|
raycast.continuous = raycastValue.continuous;
|
|
60
62
|
raycast.queryType = raycastValue.queryType;
|
|
63
|
+
raycast.shape = raycastValue.shape;
|
|
64
|
+
raycast.includeWorld = raycastValue.includeWorld;
|
|
61
65
|
entitiesCallbackResultMap.set(entity, { callback: callback });
|
|
62
66
|
};
|
|
63
67
|
nextTickRaycasts.push(onNextTick);
|
|
@@ -34,5 +34,15 @@ export interface MeshColliderComponentDefinitionExtended extends LastWriteWinEle
|
|
|
34
34
|
* @param colliderMask - the set of layer where the collider reacts, default: Physics and Pointer
|
|
35
35
|
*/
|
|
36
36
|
setSphere(entity: Entity, colliderLayers?: ColliderLayer | ColliderLayer[]): void;
|
|
37
|
+
/**
|
|
38
|
+
* @public
|
|
39
|
+
* Set a mesh from inside a gltf in the MeshCollider component.
|
|
40
|
+
* Supported only by the Bevy Explorer; other clients ignore it.
|
|
41
|
+
* @param entity - entity to create or replace the MeshCollider component
|
|
42
|
+
* @param source - the path to the gltf
|
|
43
|
+
* @param meshName - the name of the mesh in the gltf (see GltfContainerLoadingState.meshNames)
|
|
44
|
+
* @param colliderMask - the set of layer where the collider reacts, default: Physics and Pointer
|
|
45
|
+
*/
|
|
46
|
+
setGltfMesh(entity: Entity, source: string, meshName: string, colliderLayers?: ColliderLayer | ColliderLayer[]): void;
|
|
37
47
|
}
|
|
38
48
|
export declare function defineMeshColliderComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): MeshColliderComponentDefinitionExtended;
|
|
@@ -37,6 +37,12 @@ function defineMeshColliderComponent(engine) {
|
|
|
37
37
|
mesh: { $case: 'sphere', sphere: {} },
|
|
38
38
|
collisionMask: getCollisionMask(colliderLayers)
|
|
39
39
|
});
|
|
40
|
+
},
|
|
41
|
+
setGltfMesh(entity, source, meshName, colliderLayers) {
|
|
42
|
+
theComponent.createOrReplace(entity, {
|
|
43
|
+
mesh: { $case: 'gltf', gltf: { gltfSrc: source, name: meshName } },
|
|
44
|
+
collisionMask: getCollisionMask(colliderLayers)
|
|
45
|
+
});
|
|
40
46
|
}
|
|
41
47
|
};
|
|
42
48
|
}
|
|
@@ -32,5 +32,14 @@ export interface MeshRendererComponentDefinitionExtended extends LastWriteWinEle
|
|
|
32
32
|
* @param entity - entity to create or replace the MeshRenderer component
|
|
33
33
|
*/
|
|
34
34
|
setSphere(entity: Entity): void;
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
* Set a mesh from inside a gltf in the MeshRenderer component.
|
|
38
|
+
* Supported only by the Bevy Explorer; other clients ignore it.
|
|
39
|
+
* @param entity - entity to create or replace the MeshRenderer component
|
|
40
|
+
* @param source - the path to the gltf
|
|
41
|
+
* @param meshName - the name of the mesh in the gltf (see GltfContainerLoadingState.meshNames)
|
|
42
|
+
*/
|
|
43
|
+
setGltfMesh(entity: Entity, source: string, meshName: string): void;
|
|
35
44
|
}
|
|
36
45
|
export declare function defineMeshRendererComponent(engine: Pick<IEngine, 'defineComponentFromSchema'>): MeshRendererComponentDefinitionExtended;
|
|
@@ -25,6 +25,11 @@ function defineMeshRendererComponent(engine) {
|
|
|
25
25
|
theComponent.createOrReplace(entity, {
|
|
26
26
|
mesh: { $case: 'sphere', sphere: {} }
|
|
27
27
|
});
|
|
28
|
+
},
|
|
29
|
+
setGltfMesh(entity, source, meshName) {
|
|
30
|
+
theComponent.createOrReplace(entity, {
|
|
31
|
+
mesh: { $case: 'gltf', gltf: { gltfSrc: source, name: meshName } }
|
|
32
|
+
});
|
|
28
33
|
}
|
|
29
34
|
};
|
|
30
35
|
}
|
|
@@ -50,6 +50,24 @@ export interface PointerEventsSystem {
|
|
|
50
50
|
* @param entity - Entity where the callback was attached
|
|
51
51
|
*/
|
|
52
52
|
removeOnPointerHoverLeave(entity: Entity): void;
|
|
53
|
+
/**
|
|
54
|
+
* @public
|
|
55
|
+
* Remove the callback for onPointerDrag event
|
|
56
|
+
* @param entity - Entity where the callback was attached
|
|
57
|
+
*/
|
|
58
|
+
removeOnPointerDrag(entity: Entity): void;
|
|
59
|
+
/**
|
|
60
|
+
* @public
|
|
61
|
+
* Remove the callback for onPointerDragLocked event
|
|
62
|
+
* @param entity - Entity where the callback was attached
|
|
63
|
+
*/
|
|
64
|
+
removeOnPointerDragLocked(entity: Entity): void;
|
|
65
|
+
/**
|
|
66
|
+
* @public
|
|
67
|
+
* Remove the callback for onPointerDragEnd event
|
|
68
|
+
* @param entity - Entity where the callback was attached
|
|
69
|
+
*/
|
|
70
|
+
removeOnPointerDragEnd(entity: Entity): void;
|
|
53
71
|
/**
|
|
54
72
|
* @public
|
|
55
73
|
* Remove the callback for onProximityDown event
|
|
@@ -128,6 +146,39 @@ export interface PointerEventsSystem {
|
|
|
128
146
|
entity: Entity;
|
|
129
147
|
opts?: Partial<EventSystemOptions>;
|
|
130
148
|
}, cb: EventSystemCallback): void;
|
|
149
|
+
/**
|
|
150
|
+
* @public
|
|
151
|
+
* Execute callback while the user holds the button pressed and moves the pointer, having pressed it on the entity.
|
|
152
|
+
* Supported only by the Bevy Explorer; other clients ignore it.
|
|
153
|
+
* @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button
|
|
154
|
+
* @param cb - Function to execute on every drag update
|
|
155
|
+
*/
|
|
156
|
+
onPointerDrag(pointerData: {
|
|
157
|
+
entity: Entity;
|
|
158
|
+
opts?: Partial<EventSystemOptions>;
|
|
159
|
+
}, cb: EventSystemCallback): void;
|
|
160
|
+
/**
|
|
161
|
+
* @public
|
|
162
|
+
* Same as onPointerDrag, but the cursor is locked in place for the duration of the drag.
|
|
163
|
+
* Supported only by the Bevy Explorer; other clients ignore it.
|
|
164
|
+
* @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button
|
|
165
|
+
* @param cb - Function to execute on every drag update
|
|
166
|
+
*/
|
|
167
|
+
onPointerDragLocked(pointerData: {
|
|
168
|
+
entity: Entity;
|
|
169
|
+
opts?: Partial<EventSystemOptions>;
|
|
170
|
+
}, cb: EventSystemCallback): void;
|
|
171
|
+
/**
|
|
172
|
+
* @public
|
|
173
|
+
* Execute callback when the user releases the button after a drag that started on the entity.
|
|
174
|
+
* Supported only by the Bevy Explorer; other clients ignore it.
|
|
175
|
+
* @param pointerData - Entity to attach the callback - Opts to trigger Feedback and Button
|
|
176
|
+
* @param cb - Function to execute when the drag ends
|
|
177
|
+
*/
|
|
178
|
+
onPointerDragEnd(pointerData: {
|
|
179
|
+
entity: Entity;
|
|
180
|
+
opts?: Partial<EventSystemOptions>;
|
|
181
|
+
}, cb: EventSystemCallback): void;
|
|
131
182
|
/**
|
|
132
183
|
* @public
|
|
133
184
|
* Execute callback when the user presses the proximity button on the entity
|
|
@@ -47,6 +47,9 @@ function createPointerEventsSystem(engine, inputSystem) {
|
|
|
47
47
|
EventType[EventType["HoverLeave"] = 4] = "HoverLeave";
|
|
48
48
|
EventType[EventType["ProximityEnter"] = 5] = "ProximityEnter";
|
|
49
49
|
EventType[EventType["ProximityLeave"] = 6] = "ProximityLeave";
|
|
50
|
+
EventType[EventType["Drag"] = 7] = "Drag";
|
|
51
|
+
EventType[EventType["DragLocked"] = 8] = "DragLocked";
|
|
52
|
+
EventType[EventType["DragEnd"] = 9] = "DragEnd";
|
|
50
53
|
})(EventType || (EventType = {}));
|
|
51
54
|
const eventsMap = new Map();
|
|
52
55
|
function getEvent(entity) {
|
|
@@ -117,6 +120,15 @@ function createPointerEventsSystem(engine, inputSystem) {
|
|
|
117
120
|
else if (eventType === EventType.ProximityLeave) {
|
|
118
121
|
return 5 /* PointerEventType.PET_PROXIMITY_LEAVE */;
|
|
119
122
|
}
|
|
123
|
+
else if (eventType === EventType.Drag) {
|
|
124
|
+
return 7 /* PointerEventType.PET_DRAG */;
|
|
125
|
+
}
|
|
126
|
+
else if (eventType === EventType.DragLocked) {
|
|
127
|
+
return 6 /* PointerEventType.PET_DRAG_LOCKED */;
|
|
128
|
+
}
|
|
129
|
+
else if (eventType === EventType.DragEnd) {
|
|
130
|
+
return 8 /* PointerEventType.PET_DRAG_END */;
|
|
131
|
+
}
|
|
120
132
|
return 1 /* PointerEventType.PET_DOWN */;
|
|
121
133
|
}
|
|
122
134
|
function removeEvent(entity, type, interactionType = 0 /* InteractionType.CURSOR */) {
|
|
@@ -149,7 +161,10 @@ function createPointerEventsSystem(engine, inputSystem) {
|
|
|
149
161
|
eventType === EventType.HoverEnter ||
|
|
150
162
|
eventType === EventType.HoverLeave ||
|
|
151
163
|
eventType === EventType.ProximityEnter ||
|
|
152
|
-
eventType === EventType.ProximityLeave
|
|
164
|
+
eventType === EventType.ProximityLeave ||
|
|
165
|
+
eventType === EventType.Drag ||
|
|
166
|
+
eventType === EventType.DragLocked ||
|
|
167
|
+
eventType === EventType.DragEnd) {
|
|
153
168
|
const command = inputSystem.getInputCommand(opts.button, getPointerEvent(eventType), entity);
|
|
154
169
|
if (command) {
|
|
155
170
|
(0, invariant_1.checkNotThenable)(cb(command), 'Event handler returned a thenable. Only synchronous functions are allowed');
|
|
@@ -196,6 +211,30 @@ function createPointerEventsSystem(engine, inputSystem) {
|
|
|
196
211
|
setEvent(entity, EventType.HoverLeave, cb, options);
|
|
197
212
|
setPointerEvent(entity, 3 /* PointerEventType.PET_HOVER_LEAVE */, options);
|
|
198
213
|
};
|
|
214
|
+
const onPointerDrag = (...args) => {
|
|
215
|
+
const [data, cb] = args;
|
|
216
|
+
const { entity, opts } = data;
|
|
217
|
+
const options = (0, exports.getDefaultOpts)(opts);
|
|
218
|
+
removeEvent(entity, EventType.Drag);
|
|
219
|
+
setEvent(entity, EventType.Drag, cb, options);
|
|
220
|
+
setPointerEvent(entity, 7 /* PointerEventType.PET_DRAG */, options);
|
|
221
|
+
};
|
|
222
|
+
const onPointerDragLocked = (...args) => {
|
|
223
|
+
const [data, cb] = args;
|
|
224
|
+
const { entity, opts } = data;
|
|
225
|
+
const options = (0, exports.getDefaultOpts)(opts);
|
|
226
|
+
removeEvent(entity, EventType.DragLocked);
|
|
227
|
+
setEvent(entity, EventType.DragLocked, cb, options);
|
|
228
|
+
setPointerEvent(entity, 6 /* PointerEventType.PET_DRAG_LOCKED */, options);
|
|
229
|
+
};
|
|
230
|
+
const onPointerDragEnd = (...args) => {
|
|
231
|
+
const [data, cb] = args;
|
|
232
|
+
const { entity, opts } = data;
|
|
233
|
+
const options = (0, exports.getDefaultOpts)(opts);
|
|
234
|
+
removeEvent(entity, EventType.DragEnd);
|
|
235
|
+
setEvent(entity, EventType.DragEnd, cb, options);
|
|
236
|
+
setPointerEvent(entity, 8 /* PointerEventType.PET_DRAG_END */, options);
|
|
237
|
+
};
|
|
199
238
|
const onProximityDown = (...args) => {
|
|
200
239
|
const [data, cb] = args;
|
|
201
240
|
const { entity, opts } = data;
|
|
@@ -244,6 +283,15 @@ function createPointerEventsSystem(engine, inputSystem) {
|
|
|
244
283
|
removeOnPointerHoverLeave(entity) {
|
|
245
284
|
removeEvent(entity, EventType.HoverLeave);
|
|
246
285
|
},
|
|
286
|
+
removeOnPointerDrag(entity) {
|
|
287
|
+
removeEvent(entity, EventType.Drag);
|
|
288
|
+
},
|
|
289
|
+
removeOnPointerDragLocked(entity) {
|
|
290
|
+
removeEvent(entity, EventType.DragLocked);
|
|
291
|
+
},
|
|
292
|
+
removeOnPointerDragEnd(entity) {
|
|
293
|
+
removeEvent(entity, EventType.DragEnd);
|
|
294
|
+
},
|
|
247
295
|
removeOnProximityDown(entity) {
|
|
248
296
|
removeEvent(entity, EventType.Down, 1 /* InteractionType.PROXIMITY */);
|
|
249
297
|
},
|
|
@@ -269,6 +317,9 @@ function createPointerEventsSystem(engine, inputSystem) {
|
|
|
269
317
|
onPointerUp,
|
|
270
318
|
onPointerHoverEnter,
|
|
271
319
|
onPointerHoverLeave,
|
|
320
|
+
onPointerDrag,
|
|
321
|
+
onPointerDragLocked,
|
|
322
|
+
onPointerDragEnd,
|
|
272
323
|
onProximityDown,
|
|
273
324
|
onProximityUp,
|
|
274
325
|
onProximityEnter,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RaycastQueryType, PBRaycastResult } from '../components';
|
|
1
|
+
import { RaycastQueryType, RaycastShape, PBRaycastResult } from '../components';
|
|
2
2
|
import { DeepReadonlyObject, Entity } from '../engine';
|
|
3
3
|
import { Vector3 } from '../components/generated/pb/decentraland/common/vectors.gen';
|
|
4
4
|
/**
|
|
@@ -14,6 +14,10 @@ export type RaycastSystemOptions = {
|
|
|
14
14
|
queryType: RaycastQueryType;
|
|
15
15
|
continuous?: boolean | undefined;
|
|
16
16
|
collisionMask?: number | undefined;
|
|
17
|
+
/** shape to sweep along the ray, default RS_RAY (a point). Supported only by the Bevy Explorer; other clients ignore it. */
|
|
18
|
+
shape?: RaycastShape | undefined;
|
|
19
|
+
/** include colliders from other scenes, default false. Supported only by the Bevy Explorer; other clients ignore it. */
|
|
20
|
+
includeWorld?: boolean | undefined;
|
|
17
21
|
};
|
|
18
22
|
export type LocalDirectionRaycastSystemOptions = {
|
|
19
23
|
direction?: Vector3;
|
|
@@ -38,7 +38,9 @@ function createRaycastSystem(engine) {
|
|
|
38
38
|
queryType: 0 /* RaycastQueryType.RQT_HIT_FIRST */,
|
|
39
39
|
continuous: false,
|
|
40
40
|
originOffset: { x: 0, y: 0, z: 0 },
|
|
41
|
-
collisionMask: 2 /* ColliderLayer.CL_PHYSICS
|
|
41
|
+
collisionMask: 2 /* ColliderLayer.CL_PHYSICS */,
|
|
42
|
+
shape: 0 /* RaycastShape.RS_RAY */,
|
|
43
|
+
includeWorld: false
|
|
42
44
|
};
|
|
43
45
|
const getLocalDirectionRaycastDefaultOptions = (options = {}) => ({
|
|
44
46
|
...defaultOptions,
|
|
@@ -84,6 +86,8 @@ function createRaycastSystem(engine) {
|
|
|
84
86
|
raycast.direction = raycastValue.directionRawValue;
|
|
85
87
|
raycast.continuous = raycastValue.continuous;
|
|
86
88
|
raycast.queryType = raycastValue.queryType;
|
|
89
|
+
raycast.shape = raycastValue.shape;
|
|
90
|
+
raycast.includeWorld = raycastValue.includeWorld;
|
|
87
91
|
entitiesCallbackResultMap.set(entity, { callback: callback });
|
|
88
92
|
};
|
|
89
93
|
nextTickRaycasts.push(onNextTick);
|
package/package.json
CHANGED