@dcl/ecs 7.27.1-34418200091.commit-06bc595 → 7.27.1-34480514651.commit-2778e4b
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.js +8 -8
- package/dist/schemas/OneOf.js +13 -1
- package/dist-cjs/engine/input.js +8 -8
- package/dist-cjs/schemas/OneOf.js +13 -1
- package/package.json +2 -2
package/dist/engine/input.js
CHANGED
|
@@ -57,22 +57,22 @@ export function createInputSystem(engine) {
|
|
|
57
57
|
const arrayCommands = Array.from(commands);
|
|
58
58
|
for (let i = arrayCommands.length - 1; i >= 0; i--) {
|
|
59
59
|
const command = arrayCommands[i];
|
|
60
|
+
// Commands are kept sorted by timestamp, so this one and every one
|
|
61
|
+
// below it belongs to a frame that was already accounted for. Stopping
|
|
62
|
+
// on the button state instead would end this entity's whole loop over
|
|
63
|
+
// a button another entity had already reported this frame.
|
|
64
|
+
if (command.timestamp <= globalState.previousFrameMaxTimestamp) {
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
60
67
|
if (command.timestamp > maxTimestamp) {
|
|
61
68
|
maxTimestamp = command.timestamp;
|
|
62
69
|
}
|
|
63
|
-
|
|
64
|
-
globalState.thisFrameCommands.push(command);
|
|
65
|
-
}
|
|
70
|
+
globalState.thisFrameCommands.push(command);
|
|
66
71
|
if (command.state === 0 /* PointerEventType.PET_UP */ || command.state === 1 /* PointerEventType.PET_DOWN */) {
|
|
67
72
|
const prevCommand = globalState.buttonState.get(command.button);
|
|
68
73
|
if (!prevCommand || command.timestamp > prevCommand.timestamp) {
|
|
69
74
|
globalState.buttonState.set(command.button, command);
|
|
70
75
|
}
|
|
71
|
-
else {
|
|
72
|
-
// since we are iterating a descending array, we can early finish the
|
|
73
|
-
// loop
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
package/dist/schemas/OneOf.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Reserved case index for a value whose case was never selected. */
|
|
2
|
+
const NO_CASE = 0;
|
|
1
3
|
export const IOneOf = (specs) => {
|
|
2
4
|
const specKeys = Object.keys(specs);
|
|
3
5
|
const keyToIndex = specKeys.reduce((dict, key, index) => {
|
|
@@ -10,12 +12,22 @@ export const IOneOf = (specs) => {
|
|
|
10
12
|
}, {});
|
|
11
13
|
return {
|
|
12
14
|
serialize({ $case, value }, builder) {
|
|
15
|
+
// `create()` selects no case, so a field the scene never set arrives here
|
|
16
|
+
// with an undefined `$case`. Index 0 is free, cases start at 1.
|
|
17
|
+
if ($case === undefined) {
|
|
18
|
+
builder.writeUint8(NO_CASE);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
13
21
|
const _value = keyToIndex[$case.toString()] + 1;
|
|
14
22
|
builder.writeUint8(_value);
|
|
15
23
|
specs[$case].serialize(value, builder);
|
|
16
24
|
},
|
|
17
25
|
deserialize(reader) {
|
|
18
|
-
const
|
|
26
|
+
const caseIndex = reader.readInt8();
|
|
27
|
+
if (caseIndex === NO_CASE) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
const $case = specKeys[caseIndex - 1];
|
|
19
31
|
const value = specs[$case].deserialize(reader);
|
|
20
32
|
return { $case, value };
|
|
21
33
|
},
|
package/dist-cjs/engine/input.js
CHANGED
|
@@ -83,22 +83,22 @@ function createInputSystem(engine) {
|
|
|
83
83
|
const arrayCommands = Array.from(commands);
|
|
84
84
|
for (let i = arrayCommands.length - 1; i >= 0; i--) {
|
|
85
85
|
const command = arrayCommands[i];
|
|
86
|
+
// Commands are kept sorted by timestamp, so this one and every one
|
|
87
|
+
// below it belongs to a frame that was already accounted for. Stopping
|
|
88
|
+
// on the button state instead would end this entity's whole loop over
|
|
89
|
+
// a button another entity had already reported this frame.
|
|
90
|
+
if (command.timestamp <= globalState.previousFrameMaxTimestamp) {
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
86
93
|
if (command.timestamp > maxTimestamp) {
|
|
87
94
|
maxTimestamp = command.timestamp;
|
|
88
95
|
}
|
|
89
|
-
|
|
90
|
-
globalState.thisFrameCommands.push(command);
|
|
91
|
-
}
|
|
96
|
+
globalState.thisFrameCommands.push(command);
|
|
92
97
|
if (command.state === 0 /* PointerEventType.PET_UP */ || command.state === 1 /* PointerEventType.PET_DOWN */) {
|
|
93
98
|
const prevCommand = globalState.buttonState.get(command.button);
|
|
94
99
|
if (!prevCommand || command.timestamp > prevCommand.timestamp) {
|
|
95
100
|
globalState.buttonState.set(command.button, command);
|
|
96
101
|
}
|
|
97
|
-
else {
|
|
98
|
-
// since we are iterating a descending array, we can early finish the
|
|
99
|
-
// loop
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IOneOf = void 0;
|
|
4
|
+
/** Reserved case index for a value whose case was never selected. */
|
|
5
|
+
const NO_CASE = 0;
|
|
4
6
|
const IOneOf = (specs) => {
|
|
5
7
|
const specKeys = Object.keys(specs);
|
|
6
8
|
const keyToIndex = specKeys.reduce((dict, key, index) => {
|
|
@@ -13,12 +15,22 @@ const IOneOf = (specs) => {
|
|
|
13
15
|
}, {});
|
|
14
16
|
return {
|
|
15
17
|
serialize({ $case, value }, builder) {
|
|
18
|
+
// `create()` selects no case, so a field the scene never set arrives here
|
|
19
|
+
// with an undefined `$case`. Index 0 is free, cases start at 1.
|
|
20
|
+
if ($case === undefined) {
|
|
21
|
+
builder.writeUint8(NO_CASE);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
16
24
|
const _value = keyToIndex[$case.toString()] + 1;
|
|
17
25
|
builder.writeUint8(_value);
|
|
18
26
|
specs[$case].serialize(value, builder);
|
|
19
27
|
},
|
|
20
28
|
deserialize(reader) {
|
|
21
|
-
const
|
|
29
|
+
const caseIndex = reader.readInt8();
|
|
30
|
+
if (caseIndex === NO_CASE) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
const $case = specKeys[caseIndex - 1];
|
|
22
34
|
const value = specs[$case].deserialize(reader);
|
|
23
35
|
return { $case, value };
|
|
24
36
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.27.1-
|
|
4
|
+
"version": "7.27.1-34480514651.commit-2778e4b",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/ecs/issues",
|
|
7
7
|
"files": [
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"dependencies": {},
|
|
35
35
|
"types": "./dist/index.d.ts",
|
|
36
36
|
"typings": "./dist/index.d.ts",
|
|
37
|
-
"commit": "
|
|
37
|
+
"commit": "2778e4bb891f1626a98380a8c906e5e793b74024"
|
|
38
38
|
}
|