@dcl/ecs 7.0.6-4193722527.commit-97eac4a → 7.0.6-4195929129.commit-862da77
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/engine/input.d.ts +1 -1
- package/dist/engine/input.js +20 -3
- package/package.json +3 -3
package/dist/engine/input.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export type IInputSystem = {
|
|
|
14
14
|
* @param entity - the entity to query, ignore for global
|
|
15
15
|
* @returns boolean
|
|
16
16
|
*/
|
|
17
|
-
isTriggered: (inputAction: InputAction, pointerEventType: PointerEventType, entity
|
|
17
|
+
isTriggered: (inputAction: InputAction, pointerEventType: PointerEventType, entity?: Entity) => boolean;
|
|
18
18
|
/**
|
|
19
19
|
* @public
|
|
20
20
|
* Check if an input action is currently being pressed.
|
package/dist/engine/input.js
CHANGED
|
@@ -23,7 +23,8 @@ export function createInputSystem(engine) {
|
|
|
23
23
|
const globalState = {
|
|
24
24
|
previousFrameMaxTimestamp: 0,
|
|
25
25
|
currentFrameMaxTimestamp: 0,
|
|
26
|
-
buttonState: new Map()
|
|
26
|
+
buttonState: new Map(),
|
|
27
|
+
thisFrameCommands: []
|
|
27
28
|
};
|
|
28
29
|
function findLastAction(pointerEventType, inputAction, entity) {
|
|
29
30
|
const ascendingTimestampIterator = PointerEventsResult.get(entity);
|
|
@@ -45,6 +46,9 @@ export function createInputSystem(engine) {
|
|
|
45
46
|
// first store the previous' frame timestamp
|
|
46
47
|
let maxTimestamp = globalState.currentFrameMaxTimestamp;
|
|
47
48
|
globalState.previousFrameMaxTimestamp = maxTimestamp;
|
|
49
|
+
if (globalState.thisFrameCommands.length) {
|
|
50
|
+
globalState.thisFrameCommands = [];
|
|
51
|
+
}
|
|
48
52
|
// then iterate over all new commands
|
|
49
53
|
for (const [, commands] of engine.getEntitiesWith(PointerEventsResult)) {
|
|
50
54
|
// TODO: adapt the gset component to have a cached "reversed" option by default
|
|
@@ -54,6 +58,9 @@ export function createInputSystem(engine) {
|
|
|
54
58
|
if (command.timestamp > maxTimestamp) {
|
|
55
59
|
maxTimestamp = command.timestamp;
|
|
56
60
|
}
|
|
61
|
+
if (command.timestamp > globalState.previousFrameMaxTimestamp) {
|
|
62
|
+
globalState.thisFrameCommands.push(command);
|
|
63
|
+
}
|
|
57
64
|
if (command.state === 0 /* PointerEventType.PET_UP */ || command.state === 1 /* PointerEventType.PET_DOWN */) {
|
|
58
65
|
const prevCommand = globalState.buttonState.get(command.button);
|
|
59
66
|
if (!prevCommand || command.timestamp > prevCommand.timestamp) {
|
|
@@ -145,8 +152,18 @@ export function createInputSystem(engine) {
|
|
|
145
152
|
}
|
|
146
153
|
// returns true if the provided last action was triggered in the last frame
|
|
147
154
|
function isTriggered(inputAction, pointerEventType, entity) {
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
if (entity) {
|
|
156
|
+
const command = findLastAction(pointerEventType, inputAction, entity);
|
|
157
|
+
return (command && timestampIsCurrentFrame(command.timestamp)) || false;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
for (const command of globalState.thisFrameCommands) {
|
|
161
|
+
if (command.button === inputAction && command.state === pointerEventType) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
150
167
|
}
|
|
151
168
|
// returns the global state of the input. This global state is updated from the system
|
|
152
169
|
function isPressed(inputAction) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/ecs",
|
|
3
|
-
"version": "7.0.6-
|
|
3
|
+
"version": "7.0.6-4195929129.commit-862da77",
|
|
4
4
|
"description": "Decentraland ECS",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"ts-proto": "^1.112.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@dcl/js-runtime": "7.0.6-
|
|
30
|
+
"@dcl/js-runtime": "7.0.6-4195929129.commit-862da77",
|
|
31
31
|
"@dcl/protocol": "1.0.0-4177500465.commit-247c87f"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"displayName": "ECS",
|
|
41
41
|
"tsconfig": "./tsconfig.json"
|
|
42
42
|
},
|
|
43
|
-
"commit": "
|
|
43
|
+
"commit": "862da773d86dee8a30e0dcebd90251fa1e74f51f"
|
|
44
44
|
}
|