@needle-tools/engine 3.2.7-alpha → 3.2.8-alpha
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/CHANGELOG.md +4 -0
- package/dist/needle-engine.js +935 -918
- package/dist/needle-engine.min.js +83 -83
- package/dist/needle-engine.umd.cjs +53 -53
- package/lib/engine/engine_input.d.ts +3 -0
- package/lib/engine/engine_input.js +19 -0
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_physics.js +3 -1
- package/lib/engine/engine_physics.js.map +1 -1
- package/lib/engine-components/ui/EventSystem.js +4 -4
- package/lib/engine-components/ui/EventSystem.js.map +1 -1
- package/lib/engine-components/ui/PointerEvents.d.ts +2 -1
- package/lib/engine-components/ui/PointerEvents.js +6 -1
- package/lib/engine-components/ui/PointerEvents.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/engine/engine_input.ts +18 -0
- package/src/engine/engine_physics.ts +3 -1
- package/src/engine-components/ui/EventSystem.ts +4 -4
- package/src/engine-components/ui/PointerEvents.ts +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.8-alpha",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in",
|
|
5
5
|
"main": "dist/needle-engine.umd.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -79,6 +79,20 @@ export class Input extends EventTarget {
|
|
|
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 @@ export class Input extends EventTarget {
|
|
|
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 @@ export class Input extends EventTarget {
|
|
|
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 @@ import {
|
|
|
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 @@ export class Physics {
|
|
|
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 @@ export class EventSystem extends Behaviour {
|
|
|
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 @@ export class EventSystem extends Behaviour {
|
|
|
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 @@ export class EventSystem extends Behaviour {
|
|
|
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 @@ export class EventSystem extends Behaviour {
|
|
|
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 @@ export interface IInputEventArgs {
|
|
|
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 @@ export class PointerEventData implements IInputEventArgs {
|
|
|
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
|
}
|
|
35
42
|
|