@@ -79,6 +79,20 @@
|
|
79
79
|
this.context.domElement.style.cursor = "default";
|
80
80
|
}
|
81
81
|
|
82
|
+
setPointerUsed(i: number, used: boolean = true) {
|
83
|
+
if (i >= this._pointerUsed.length) {
|
84
|
+
if (i >= this._pointerIds.length)
|
85
|
+
return;
|
86
|
+
while (this._pointerUsed.length <= i) {
|
87
|
+
this._pointerUsed.push(false);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
this._pointerUsed[i] = used;
|
91
|
+
}
|
92
|
+
getPointerUsed(i: number) {
|
93
|
+
if (i >= this._pointerUsed.length) return false;
|
94
|
+
return this._pointerUsed[i];
|
95
|
+
}
|
82
96
|
/** how many pointers are currently pressed */
|
83
97
|
getPointerPressedCount(): number {
|
84
98
|
let count = 0;
|
@@ -225,6 +239,7 @@
|
|
225
239
|
private _mouseWheelChanged: boolean[] = [false];
|
226
240
|
private _mouseWheelDeltaY: number[] = [0];
|
227
241
|
private _pointerEvent: Event[] = [];
|
242
|
+
private _pointerUsed: boolean[] = [];
|
228
243
|
|
229
244
|
getKeyDown(): string | null {
|
230
245
|
for (const key in this.keysPressed) {
|
@@ -545,6 +560,9 @@
|
|
545
560
|
// }
|
546
561
|
this.setPointerState(evt.button, this._pointerUp, true);
|
547
562
|
|
563
|
+
while (evt.button >= this._pointerUsed.length) this._pointerUsed.push(false);
|
564
|
+
this.setPointerState(evt.button, this._pointerUsed, false);
|
565
|
+
|
548
566
|
this.updatePointerPosition(evt);
|
549
567
|
|
550
568
|
if (!this._pointerPositionDown[evt.button]) {
|
@@ -15,7 +15,7 @@
|
|
15
15
|
import { InstancingUtil } from './engine_instancing';
|
16
16
|
import { foreachComponent } from './engine_gameobject';
|
17
17
|
|
18
|
-
import RAPIER, { ActiveEvents, CoefficientCombineRule, Collider, ColliderDesc, EventQueue, JointData, QueryFilterFlags, RigidBody, RigidBodyType, ShapeColliderTOI, World } from '@dimforge/rapier3d-compat';
|
18
|
+
import RAPIER, { ActiveCollisionTypes, ActiveEvents, CoefficientCombineRule, Collider, ColliderDesc, EventQueue, JointData, QueryFilterFlags, RigidBody, RigidBodyType, ShapeColliderTOI, World } from '@dimforge/rapier3d-compat';
|
19
19
|
import { CollisionDetectionMode, PhysicsMaterialCombine } from '../engine/engine_physics.types';
|
20
20
|
import { Gizmos } from './engine_gizmos';
|
21
21
|
import { Mathf } from './engine_math';
|
@@ -645,6 +645,8 @@
|
|
645
645
|
col[$componentKey] = collider;
|
646
646
|
collider[$bodyKey] = col;
|
647
647
|
col.setActiveEvents(ActiveEvents.COLLISION_EVENTS);
|
648
|
+
// We want to receive collisitons between two triggers too
|
649
|
+
col.setActiveCollisionTypes(ActiveCollisionTypes.ALL);
|
648
650
|
|
649
651
|
// const objectLayerMask = collider.gameObject.layers.mask;
|
650
652
|
// const mask = objectLayerMask & ~2;
|
@@ -113,7 +113,7 @@
|
|
113
113
|
this._selectStartFn ??= (ctrl, args: { grab: THREE.Object3D | null }) => {
|
114
114
|
if (!args.grab) return;
|
115
115
|
MeshUIHelper.resetLastSelected();
|
116
|
-
const opts = new PointerEventData();
|
116
|
+
const opts = new PointerEventData(this.context.input);
|
117
117
|
opts.inputSource = ctrl;
|
118
118
|
opts.isDown = ctrl.selectionDown;
|
119
119
|
opts.isUp = ctrl.selectionUp;
|
@@ -126,7 +126,7 @@
|
|
126
126
|
}
|
127
127
|
this._selectEndFn ??= (ctrl, args: { grab: THREE.Object3D }) => {
|
128
128
|
if (!args.grab) return;
|
129
|
-
const opts = new PointerEventData();
|
129
|
+
const opts = new PointerEventData(this.context.input);
|
130
130
|
opts.inputSource = ctrl;
|
131
131
|
opts.isDown = ctrl.selectionDown;
|
132
132
|
opts.isUp = ctrl.selectionUp;
|
@@ -155,7 +155,7 @@
|
|
155
155
|
controllerRcOpts.ray = _ctrl.getRay();
|
156
156
|
const rc = this.performRaycast(controllerRcOpts);
|
157
157
|
if (!rc) return;
|
158
|
-
const opts = new PointerEventData();
|
158
|
+
const opts = new PointerEventData(this.context.input);
|
159
159
|
opts.inputSource = _ctrl;
|
160
160
|
this.handleIntersections(rc, opts);
|
161
161
|
};
|
@@ -230,7 +230,7 @@
|
|
230
230
|
|
231
231
|
const ptr = this.context.input.getPointerEvent(pointerId);
|
232
232
|
// console.log(ptr);
|
233
|
-
const args: PointerEventData = new PointerEventData(ptr);
|
233
|
+
const args: PointerEventData = new PointerEventData(this.context.input, ptr);
|
234
234
|
args.inputSource = this.context.input;
|
235
235
|
args.pointerId = pointerId;
|
236
236
|
args.isClicked = this.context.input.getPointerClicked(pointerId)
|
@@ -7,10 +7,14 @@
|
|
7
7
|
}
|
8
8
|
|
9
9
|
export class PointerEventData implements IInputEventArgs {
|
10
|
+
|
11
|
+
// TODO: should we make this a getter and return the input used state instead? -> this.context.getPointerUsed(this.pointerId);
|
10
12
|
used: boolean = false;
|
11
13
|
|
12
14
|
Use() {
|
13
15
|
this.used = true;
|
16
|
+
if (this.pointerId !== undefined)
|
17
|
+
this.input.setPointerUsed(this.pointerId);
|
14
18
|
}
|
15
19
|
|
16
20
|
StopPropagation() {
|
@@ -26,10 +30,13 @@
|
|
26
30
|
isPressed: boolean | undefined;
|
27
31
|
isClicked: boolean | undefined;
|
28
32
|
|
33
|
+
private input: Input;
|
34
|
+
|
29
35
|
private event?: Event;
|
30
36
|
|
31
|
-
constructor(events?: Event) {
|
37
|
+
constructor(input: Input, events?: Event) {
|
32
38
|
this.event = events;
|
39
|
+
this.input = input;
|
33
40
|
}
|
34
41
|
}
|