@dcl/ecs 7.23.4-26106700711.commit-2afa13b → 7.23.4-26110424113.commit-4b40cec
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/generated/pb/decentraland/sdk/components/avatar_locomotion_settings.gen.d.ts +6 -0
- package/dist/components/generated/pb/decentraland/sdk/components/avatar_locomotion_settings.gen.js +30 -0
- package/dist/components/generated/pb/decentraland/sdk/components/avatar_shape.gen.d.ts +8 -0
- package/dist/components/generated/pb/decentraland/sdk/components/avatar_shape.gen.js +9 -0
- package/dist/components/generated/pb/decentraland/sdk/components/virtual_camera.gen.d.ts +3 -0
- package/dist/components/generated/pb/decentraland/sdk/components/virtual_camera.gen.js +10 -1
- package/dist/components/index.d.ts +0 -5
- package/dist/components/index.js +2 -5
- package/dist/components/manual/Transform.d.ts +0 -9
- package/dist/components/manual/Transform.js +3 -3
- package/dist/components/types.d.ts +0 -1
- package/dist/engine/component.d.ts +1 -52
- package/dist/engine/grow-only-value-set-component-definition.js +2 -45
- package/dist/engine/lww-element-set-component-definition.d.ts +1 -3
- package/dist/engine/lww-element-set-component-definition.js +12 -64
- package/dist/index.d.ts +1 -2
- package/dist/index.js +0 -1
- package/dist/serialization/crdt/index.d.ts +0 -1
- package/dist/serialization/crdt/index.js +0 -1
- package/dist/serialization/crdt/network/utils.d.ts +9 -0
- package/dist/serialization/crdt/network/utils.js +60 -0
- package/dist/serialization/crdt/types.d.ts +3 -25
- package/dist/serialization/crdt/types.js +1 -3
- package/dist/systems/crdt/index.d.ts +1 -0
- package/dist/systems/crdt/index.js +146 -55
- package/dist/systems/triggerArea.js +1 -2
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_locomotion_settings.gen.d.ts +6 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_locomotion_settings.gen.js +30 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_shape.gen.d.ts +8 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/avatar_shape.gen.js +10 -1
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/virtual_camera.gen.d.ts +3 -0
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/virtual_camera.gen.js +10 -1
- package/dist-cjs/components/index.d.ts +0 -5
- package/dist-cjs/components/index.js +3 -7
- package/dist-cjs/components/manual/Transform.d.ts +0 -9
- package/dist-cjs/components/manual/Transform.js +3 -3
- package/dist-cjs/components/types.d.ts +0 -1
- package/dist-cjs/engine/component.d.ts +1 -52
- package/dist-cjs/engine/grow-only-value-set-component-definition.js +1 -44
- package/dist-cjs/engine/lww-element-set-component-definition.d.ts +1 -3
- package/dist-cjs/engine/lww-element-set-component-definition.js +13 -67
- package/dist-cjs/index.d.ts +1 -2
- package/dist-cjs/index.js +1 -2
- package/dist-cjs/serialization/crdt/index.d.ts +0 -1
- package/dist-cjs/serialization/crdt/index.js +0 -1
- package/dist-cjs/serialization/crdt/network/utils.d.ts +9 -0
- package/dist-cjs/serialization/crdt/network/utils.js +67 -0
- package/dist-cjs/serialization/crdt/types.d.ts +3 -25
- package/dist-cjs/serialization/crdt/types.js +1 -3
- package/dist-cjs/systems/crdt/index.d.ts +1 -0
- package/dist-cjs/systems/crdt/index.js +169 -55
- package/dist-cjs/systems/triggerArea.js +1 -2
- package/package.json +2 -2
- package/dist/components/manual/CreatedBy.d.ts +0 -9
- package/dist/components/manual/CreatedBy.js +0 -8
- package/dist/serialization/crdt/authoritativePutComponent.d.ts +0 -15
- package/dist/serialization/crdt/authoritativePutComponent.js +0 -47
- package/dist-cjs/components/manual/CreatedBy.d.ts +0 -9
- package/dist-cjs/components/manual/CreatedBy.js +0 -10
- package/dist-cjs/serialization/crdt/authoritativePutComponent.d.ts +0 -15
- package/dist-cjs/serialization/crdt/authoritativePutComponent.js +0 -50
|
@@ -11,8 +11,7 @@ export declare enum CrdtMessageType {
|
|
|
11
11
|
PUT_COMPONENT_NETWORK = 5,
|
|
12
12
|
DELETE_COMPONENT_NETWORK = 6,
|
|
13
13
|
DELETE_ENTITY_NETWORK = 7,
|
|
14
|
-
|
|
15
|
-
MAX_MESSAGE_TYPE = 9
|
|
14
|
+
MAX_MESSAGE_TYPE = 8
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
17
|
* Min length = 8 bytes
|
|
@@ -49,23 +48,6 @@ export type PutNetworkComponentMessageBody = Omit<PutComponentMessageBody, 'type
|
|
|
49
48
|
type: CrdtMessageType.PUT_COMPONENT_NETWORK;
|
|
50
49
|
networkId: number;
|
|
51
50
|
};
|
|
52
|
-
/**
|
|
53
|
-
* Server authoritative message - identical to PutComponentMessageBody but with forced processing
|
|
54
|
-
* Min. length = header (8 bytes) + 16 bytes = 24 bytes
|
|
55
|
-
*
|
|
56
|
-
* @param entity - Uint32 number of the entity
|
|
57
|
-
* @param componentId - Uint32 number of id
|
|
58
|
-
* @param timestamp - Uint32 Lamport timestamp (server's authoritative timestamp)
|
|
59
|
-
* @param data - Uint8[] data of component => length(4 bytes) + block of bytes[0..length-1]
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
export type AuthoritativePutComponentMessageBody = {
|
|
63
|
-
type: CrdtMessageType.AUTHORITATIVE_PUT_COMPONENT;
|
|
64
|
-
entityId: Entity;
|
|
65
|
-
componentId: number;
|
|
66
|
-
timestamp: number;
|
|
67
|
-
data: Uint8Array;
|
|
68
|
-
};
|
|
69
51
|
/**
|
|
70
52
|
* Min. length = header (8 bytes) + 16 bytes = 24 bytes
|
|
71
53
|
*
|
|
@@ -132,10 +114,6 @@ export type AppendValueMessage = CrdtMessageHeader & AppendValueMessageBody;
|
|
|
132
114
|
* @public
|
|
133
115
|
*/
|
|
134
116
|
export type PutComponentMessage = CrdtMessageHeader & PutComponentMessageBody;
|
|
135
|
-
/**
|
|
136
|
-
* @public
|
|
137
|
-
*/
|
|
138
|
-
export type AuthoritativePutComponentMessage = CrdtMessageHeader & AuthoritativePutComponentMessageBody;
|
|
139
117
|
/**
|
|
140
118
|
* @public
|
|
141
119
|
*/
|
|
@@ -159,7 +137,7 @@ export type DeleteEntityNetworkMessage = CrdtMessageHeader & DeleteEntityNetwork
|
|
|
159
137
|
/**
|
|
160
138
|
* @public
|
|
161
139
|
*/
|
|
162
|
-
export type CrdtMessage = PutComponentMessage |
|
|
140
|
+
export type CrdtMessage = PutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
|
|
163
141
|
/**
|
|
164
142
|
* @public
|
|
165
143
|
*/
|
|
@@ -167,7 +145,7 @@ export type CrdtNetworkMessageBody = PutNetworkComponentMessageBody | DeleteComp
|
|
|
167
145
|
/**
|
|
168
146
|
* @public
|
|
169
147
|
*/
|
|
170
|
-
export type CrdtMessageBody = PutComponentMessageBody |
|
|
148
|
+
export type CrdtMessageBody = PutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
|
|
171
149
|
export declare enum ProcessMessageResultType {
|
|
172
150
|
/**
|
|
173
151
|
* Typical message and new state set.
|
|
@@ -13,9 +13,7 @@ export var CrdtMessageType;
|
|
|
13
13
|
CrdtMessageType[CrdtMessageType["PUT_COMPONENT_NETWORK"] = 5] = "PUT_COMPONENT_NETWORK";
|
|
14
14
|
CrdtMessageType[CrdtMessageType["DELETE_COMPONENT_NETWORK"] = 6] = "DELETE_COMPONENT_NETWORK";
|
|
15
15
|
CrdtMessageType[CrdtMessageType["DELETE_ENTITY_NETWORK"] = 7] = "DELETE_ENTITY_NETWORK";
|
|
16
|
-
|
|
17
|
-
CrdtMessageType[CrdtMessageType["AUTHORITATIVE_PUT_COMPONENT"] = 8] = "AUTHORITATIVE_PUT_COMPONENT";
|
|
18
|
-
CrdtMessageType[CrdtMessageType["MAX_MESSAGE_TYPE"] = 9] = "MAX_MESSAGE_TYPE";
|
|
16
|
+
CrdtMessageType[CrdtMessageType["MAX_MESSAGE_TYPE"] = 8] = "MAX_MESSAGE_TYPE";
|
|
19
17
|
})(CrdtMessageType || (CrdtMessageType = {}));
|
|
20
18
|
/**
|
|
21
19
|
* @public
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { EntityState } from '../../engine/entity';
|
|
2
2
|
import { ReadWriteByteBuffer } from '../../serialization/ByteBuffer';
|
|
3
|
-
import { AppendValueOperation, CrdtMessageProtocol } from '../../serialization/crdt';
|
|
3
|
+
import { AppendValueOperation, CrdtMessageProtocol, DeleteComponentNetwork, DeleteEntityNetwork } from '../../serialization/crdt';
|
|
4
4
|
import { DeleteComponent } from '../../serialization/crdt/deleteComponent';
|
|
5
5
|
import { DeleteEntity } from '../../serialization/crdt/deleteEntity';
|
|
6
6
|
import { PutComponentOperation } from '../../serialization/crdt/putComponent';
|
|
7
|
-
import { AuthoritativePutComponentOperation } from '../../serialization/crdt/authoritativePutComponent';
|
|
8
7
|
import { CrdtMessageType } from '../../serialization/crdt/types';
|
|
8
|
+
import { PutNetworkComponentOperation } from '../../serialization/crdt/network/putComponentNetwork';
|
|
9
|
+
import { NetworkEntity as defineNetworkEntity, NetworkParent as defineNetworkParent, Transform as defineTransform } from '../../components';
|
|
10
|
+
import * as networkUtils from '../../serialization/crdt/network/utils';
|
|
11
|
+
// NetworkMessages can only have a MAX_SIZE of 12kb. So we need to send it in chunks.
|
|
12
|
+
export const LIVEKIT_MAX_SIZE = 12;
|
|
9
13
|
/**
|
|
10
14
|
* @internal
|
|
11
15
|
*/
|
|
12
16
|
export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
13
17
|
const transports = [];
|
|
14
|
-
//
|
|
18
|
+
// Components that we used on this system
|
|
19
|
+
const NetworkEntity = defineNetworkEntity(engine);
|
|
20
|
+
const NetworkParent = defineNetworkParent(engine);
|
|
21
|
+
const Transform = defineTransform(engine);
|
|
15
22
|
// Messages that we received at transport.onMessage waiting to be processed
|
|
16
23
|
const receivedMessages = [];
|
|
17
24
|
// Messages already processed by the engine but that we need to broadcast to other transports.
|
|
@@ -36,20 +43,27 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
36
43
|
if (header.type === CrdtMessageType.DELETE_COMPONENT) {
|
|
37
44
|
message = DeleteComponent.read(buffer);
|
|
38
45
|
}
|
|
46
|
+
else if (header.type === CrdtMessageType.DELETE_COMPONENT_NETWORK) {
|
|
47
|
+
message = DeleteComponentNetwork.read(buffer);
|
|
48
|
+
}
|
|
39
49
|
else if (header.type === CrdtMessageType.PUT_COMPONENT) {
|
|
40
50
|
message = PutComponentOperation.read(buffer);
|
|
41
51
|
}
|
|
42
|
-
else if (header.type === CrdtMessageType.
|
|
43
|
-
message =
|
|
52
|
+
else if (header.type === CrdtMessageType.PUT_COMPONENT_NETWORK) {
|
|
53
|
+
message = PutNetworkComponentOperation.read(buffer);
|
|
44
54
|
}
|
|
45
55
|
else if (header.type === CrdtMessageType.DELETE_ENTITY) {
|
|
46
56
|
message = DeleteEntity.read(buffer);
|
|
47
57
|
}
|
|
58
|
+
else if (header.type === CrdtMessageType.DELETE_ENTITY_NETWORK) {
|
|
59
|
+
message = DeleteEntityNetwork.read(buffer);
|
|
60
|
+
}
|
|
48
61
|
else if (header.type === CrdtMessageType.APPEND_VALUE) {
|
|
49
62
|
message = AppendValueOperation.read(buffer);
|
|
63
|
+
// Unknown message, we skip it
|
|
50
64
|
}
|
|
51
65
|
else {
|
|
52
|
-
//
|
|
66
|
+
// consume the message
|
|
53
67
|
buffer.incrementReadOffset(header.length);
|
|
54
68
|
}
|
|
55
69
|
if (message) {
|
|
@@ -70,6 +84,22 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
70
84
|
const messagesToProcess = value.splice(0, value.length);
|
|
71
85
|
return messagesToProcess;
|
|
72
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Find the local entityId associated to the network component message.
|
|
89
|
+
* It's a mapping Network -> to Local
|
|
90
|
+
* If it's not a network message, return the entityId received by the message
|
|
91
|
+
*/
|
|
92
|
+
function findNetworkId(msg) {
|
|
93
|
+
const hasNetworkId = 'networkId' in msg;
|
|
94
|
+
if (hasNetworkId) {
|
|
95
|
+
for (const [entityId, network] of engine.getEntitiesWith(NetworkEntity)) {
|
|
96
|
+
if (network.networkId === msg.networkId && network.entityId === msg.entityId) {
|
|
97
|
+
return { entityId, network };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return { entityId: msg.entityId };
|
|
102
|
+
}
|
|
73
103
|
/**
|
|
74
104
|
* This fn will be called on every tick.
|
|
75
105
|
* Process all the messages queue received by the transport
|
|
@@ -78,52 +108,46 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
78
108
|
const messagesToProcess = getMessages(receivedMessages);
|
|
79
109
|
const entitiesShouldBeCleaned = [];
|
|
80
110
|
for (const msg of messagesToProcess) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
111
|
+
let { entityId, network } = findNetworkId(msg);
|
|
112
|
+
// We receive a new Entity. Create the localEntity and map it to the NetworkEntity component
|
|
113
|
+
if (networkUtils.isNetworkMessage(msg) && !network) {
|
|
114
|
+
entityId = engine.addEntity();
|
|
115
|
+
network = { entityId: msg.entityId, networkId: msg.networkId };
|
|
116
|
+
NetworkEntity.createOrReplace(entityId, network);
|
|
117
|
+
}
|
|
118
|
+
if (msg.type === CrdtMessageType.DELETE_ENTITY || msg.type === CrdtMessageType.DELETE_ENTITY_NETWORK) {
|
|
119
|
+
entitiesShouldBeCleaned.push(entityId);
|
|
84
120
|
broadcastMessages.push(msg);
|
|
85
121
|
}
|
|
86
122
|
else {
|
|
87
|
-
const entityState = engine.entityContainer.getEntityState(
|
|
88
|
-
// Skip updates from removed
|
|
123
|
+
const entityState = engine.entityContainer.getEntityState(entityId);
|
|
124
|
+
// Skip updates from removed entityes
|
|
89
125
|
if (entityState === EntityState.Removed)
|
|
90
126
|
continue;
|
|
91
|
-
// Entities with unknown
|
|
127
|
+
// Entities with unknown entities should update its entity state
|
|
92
128
|
if (entityState === EntityState.Unknown) {
|
|
93
|
-
engine.entityContainer.updateUsedEntity(
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
? component.__forceUpdateFromCrdt(msg)
|
|
104
|
-
: component.updateFromCrdt(msg);
|
|
105
|
-
}
|
|
106
|
-
catch (e) {
|
|
107
|
-
console.error('[receiveMessages] ERROR processing message', msg, e);
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const result = tryUpdate();
|
|
112
|
-
if (!result)
|
|
113
|
-
continue;
|
|
114
|
-
const [conflictMessage, value] = result;
|
|
115
|
-
if (!conflictMessage) {
|
|
116
|
-
// Add message to broadcast queue when no conflict
|
|
117
|
-
broadcastMessages.push(msg);
|
|
118
|
-
onProcessEntityComponentChange && onProcessEntityComponentChange(msg.entityId, msg.type, component, value);
|
|
119
|
-
}
|
|
129
|
+
engine.entityContainer.updateUsedEntity(entityId);
|
|
130
|
+
}
|
|
131
|
+
const component = engine.getComponentOrNull(msg.componentId);
|
|
132
|
+
/* istanbul ignore else */
|
|
133
|
+
if (component) {
|
|
134
|
+
if (msg.type === CrdtMessageType.PUT_COMPONENT &&
|
|
135
|
+
component.componentId === Transform.componentId &&
|
|
136
|
+
NetworkEntity.has(entityId) &&
|
|
137
|
+
NetworkParent.has(entityId)) {
|
|
138
|
+
msg.data = networkUtils.fixTransformParent(msg);
|
|
120
139
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
140
|
+
const [conflictMessage, value] = component.updateFromCrdt({ ...msg, entityId });
|
|
141
|
+
if (!conflictMessage) {
|
|
142
|
+
// Add message to transport queue to be processed by others transports
|
|
124
143
|
broadcastMessages.push(msg);
|
|
144
|
+
onProcessEntityComponentChange && onProcessEntityComponentChange(entityId, msg.type, component, value);
|
|
125
145
|
}
|
|
126
146
|
}
|
|
147
|
+
else {
|
|
148
|
+
// TODO: test this line, it is fundammental to make the editor work
|
|
149
|
+
broadcastMessages.push(msg);
|
|
150
|
+
}
|
|
127
151
|
}
|
|
128
152
|
}
|
|
129
153
|
// the last stage of the syncrhonization is to delete the entities
|
|
@@ -137,17 +161,16 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
137
161
|
}
|
|
138
162
|
}
|
|
139
163
|
/**
|
|
140
|
-
*
|
|
164
|
+
* Iterates the dirty map and generates crdt messages to be send
|
|
141
165
|
*/
|
|
142
166
|
async function sendMessages(entitiesDeletedThisTick) {
|
|
143
|
-
//
|
|
167
|
+
// CRDT Messages will be the merge between the recieved transport messages and the new crdt messages
|
|
144
168
|
const crdtMessages = getMessages(broadcastMessages);
|
|
145
169
|
const buffer = new ReadWriteByteBuffer();
|
|
146
|
-
// Generate CRDT messages from component updates
|
|
147
170
|
for (const component of engine.componentsIter()) {
|
|
148
171
|
for (const message of component.getCrdtUpdates()) {
|
|
149
172
|
const offset = buffer.currentWriteOffset();
|
|
150
|
-
//
|
|
173
|
+
// Avoid creating messages if there is no transport that will handle it
|
|
151
174
|
if (transports.some((t) => t.filter(message))) {
|
|
152
175
|
if (message.type === CrdtMessageType.PUT_COMPONENT) {
|
|
153
176
|
PutComponentOperation.write(message.entityId, message.timestamp, message.componentId, message.data, buffer);
|
|
@@ -171,7 +194,7 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
171
194
|
}
|
|
172
195
|
}
|
|
173
196
|
}
|
|
174
|
-
//
|
|
197
|
+
// After all updates, I execute the DeletedEntity messages
|
|
175
198
|
for (const entityId of entitiesDeletedThisTick) {
|
|
176
199
|
const offset = buffer.currentWriteOffset();
|
|
177
200
|
DeleteEntity.write(entityId, buffer);
|
|
@@ -182,19 +205,87 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
182
205
|
});
|
|
183
206
|
onProcessEntityComponentChange && onProcessEntityComponentChange(entityId, CrdtMessageType.DELETE_ENTITY);
|
|
184
207
|
}
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
|
|
208
|
+
// Send CRDT messages to transports
|
|
209
|
+
const transportBuffer = new ReadWriteByteBuffer();
|
|
210
|
+
for (const index in transports) {
|
|
211
|
+
const __NetworkMessagesBuffer = [];
|
|
212
|
+
const transportIndex = Number(index);
|
|
213
|
+
const transport = transports[transportIndex];
|
|
214
|
+
const isRendererTransport = transport.type === 'renderer';
|
|
215
|
+
const isNetworkTransport = transport.type === 'network';
|
|
216
|
+
// Reset Buffer for each Transport
|
|
217
|
+
transportBuffer.resetBuffer();
|
|
218
|
+
const buffer = new ReadWriteByteBuffer();
|
|
219
|
+
// Then we send all the new crdtMessages that the transport needs to process
|
|
188
220
|
for (const message of crdtMessages) {
|
|
189
221
|
// Avoid echo messages
|
|
190
|
-
if (message.transportId ===
|
|
222
|
+
if (message.transportId === transportIndex)
|
|
191
223
|
continue;
|
|
192
|
-
//
|
|
193
|
-
if (transport.filter(message))
|
|
194
|
-
|
|
224
|
+
// Redundant message for the transport
|
|
225
|
+
if (!transport.filter(message))
|
|
226
|
+
continue;
|
|
227
|
+
// Check if adding this message would exceed the size limit
|
|
228
|
+
const currentBufferSize = transportBuffer.toBinary().byteLength;
|
|
229
|
+
const messageSize = message.messageBuffer.byteLength;
|
|
230
|
+
if (isNetworkTransport && (currentBufferSize + messageSize) / 1024 > LIVEKIT_MAX_SIZE) {
|
|
231
|
+
// If the current buffer has content, save it as a chunk
|
|
232
|
+
if (currentBufferSize > 0) {
|
|
233
|
+
__NetworkMessagesBuffer.push(transportBuffer.toCopiedBinary());
|
|
234
|
+
transportBuffer.resetBuffer();
|
|
235
|
+
}
|
|
236
|
+
// If the message itself is larger than the limit, we need to handle it specially
|
|
237
|
+
// For now, we'll skip it to prevent infinite loops
|
|
238
|
+
if (messageSize / 1024 > LIVEKIT_MAX_SIZE) {
|
|
239
|
+
console.error(`Message too large (${messageSize} bytes), skipping message for entity ${message.entityId}`);
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
195
242
|
}
|
|
243
|
+
const { entityId } = findNetworkId(message);
|
|
244
|
+
const transformNeedsFix = 'componentId' in message &&
|
|
245
|
+
message.componentId === Transform.componentId &&
|
|
246
|
+
Transform.has(entityId) &&
|
|
247
|
+
NetworkParent.has(entityId) &&
|
|
248
|
+
NetworkEntity.has(entityId);
|
|
249
|
+
// If there was a LOCAL change in the transform. Add the parent to that transform
|
|
250
|
+
if (isRendererTransport && message.type === CrdtMessageType.PUT_COMPONENT && transformNeedsFix) {
|
|
251
|
+
const parent = findNetworkId(NetworkParent.get(entityId));
|
|
252
|
+
const transformData = networkUtils.fixTransformParent(message, Transform.get(entityId), parent.entityId);
|
|
253
|
+
const offset = buffer.currentWriteOffset();
|
|
254
|
+
PutComponentOperation.write(entityId, message.timestamp, message.componentId, transformData, buffer);
|
|
255
|
+
transportBuffer.writeBuffer(buffer.buffer().subarray(offset, buffer.currentWriteOffset()), false);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
if (isRendererTransport && networkUtils.isNetworkMessage(message)) {
|
|
259
|
+
// If it's the renderer transport and its a NetworkMessage, we need to fix the entityId field and convert it to a known Message.
|
|
260
|
+
// PUT_NETWORK_COMPONENT -> PUT_COMPONENT
|
|
261
|
+
let transformData = 'data' in message ? message.data : new Uint8Array();
|
|
262
|
+
if (transformNeedsFix) {
|
|
263
|
+
const parent = findNetworkId(NetworkParent.get(entityId));
|
|
264
|
+
transformData = networkUtils.fixTransformParent(message, Transform.get(entityId), parent.entityId);
|
|
265
|
+
}
|
|
266
|
+
networkUtils.networkMessageToLocal({ ...message, data: transformData }, entityId, buffer, transportBuffer);
|
|
267
|
+
// Iterate the next message
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
// If its a network transport and its a PUT_COMPONENT that has a NetworkEntity component, we need to send this message
|
|
271
|
+
// through comms with the EntityID and NetworkID from ther NetworkEntity so everyone can recieve this message and map to their custom entityID.
|
|
272
|
+
if (isNetworkTransport && !networkUtils.isNetworkMessage(message)) {
|
|
273
|
+
const networkData = NetworkEntity.getOrNull(message.entityId);
|
|
274
|
+
// If it has networkData convert the message to PUT_NETWORK_COMPONENT.
|
|
275
|
+
if (networkData) {
|
|
276
|
+
networkUtils.localMessageToNetwork(message, networkData, buffer, transportBuffer);
|
|
277
|
+
// Iterate the next message
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Common message
|
|
282
|
+
transportBuffer.writeBuffer(message.messageBuffer, false);
|
|
283
|
+
}
|
|
284
|
+
if (isNetworkTransport && transportBuffer.currentWriteOffset()) {
|
|
285
|
+
__NetworkMessagesBuffer.push(transportBuffer.toBinary());
|
|
196
286
|
}
|
|
197
|
-
|
|
287
|
+
const message = isNetworkTransport ? __NetworkMessagesBuffer : transportBuffer.toBinary();
|
|
288
|
+
await transport.send(message);
|
|
198
289
|
}
|
|
199
290
|
}
|
|
200
291
|
/**
|
|
@@ -177,8 +177,7 @@ export function createTriggerAreaEventsSystem(engine) {
|
|
|
177
177
|
// Pass 2: synthesize per-tick onStay callbacks
|
|
178
178
|
// -----------------------------------------------------------------------
|
|
179
179
|
// Only run if an onStay callback is registered and there are tracked triggerers.
|
|
180
|
-
if (data.triggerCallbackMap.has(1 /* TriggerAreaEventType.TAET_STAY */) &&
|
|
181
|
-
data.insideTriggerers.size > 0) {
|
|
180
|
+
if (data.triggerCallbackMap.has(1 /* TriggerAreaEventType.TAET_STAY */) && data.insideTriggerers.size > 0) {
|
|
182
181
|
const onStay = data.triggerCallbackMap.get(1 /* TriggerAreaEventType.TAET_STAY */);
|
|
183
182
|
const currentTimestamp = Date.now();
|
|
184
183
|
for (const [triggererEntity, cachedResult] of data.insideTriggerers) {
|
|
@@ -19,6 +19,12 @@ export interface PBAvatarLocomotionSettings {
|
|
|
19
19
|
runJumpHeight?: number | undefined;
|
|
20
20
|
/** Cooldown time after a hard landing before the avatar can move again (in seconds) */
|
|
21
21
|
hardLandingCooldown?: number | undefined;
|
|
22
|
+
/** Height of the double jump (in meters) */
|
|
23
|
+
doubleJumpHeight?: number | undefined;
|
|
24
|
+
/** Maximum speed when gliding (in meters per second) */
|
|
25
|
+
glidingSpeed?: number | undefined;
|
|
26
|
+
/** Maximum falling speed when gliding (in meters per second) */
|
|
27
|
+
glidingFallingSpeed?: number | undefined;
|
|
22
28
|
}
|
|
23
29
|
/**
|
|
24
30
|
* @public
|
|
@@ -15,6 +15,9 @@ function createBasePBAvatarLocomotionSettings() {
|
|
|
15
15
|
jumpHeight: undefined,
|
|
16
16
|
runJumpHeight: undefined,
|
|
17
17
|
hardLandingCooldown: undefined,
|
|
18
|
+
doubleJumpHeight: undefined,
|
|
19
|
+
glidingSpeed: undefined,
|
|
20
|
+
glidingFallingSpeed: undefined,
|
|
18
21
|
};
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
@@ -41,6 +44,15 @@ var PBAvatarLocomotionSettings;
|
|
|
41
44
|
if (message.hardLandingCooldown !== undefined) {
|
|
42
45
|
writer.uint32(53).float(message.hardLandingCooldown);
|
|
43
46
|
}
|
|
47
|
+
if (message.doubleJumpHeight !== undefined) {
|
|
48
|
+
writer.uint32(61).float(message.doubleJumpHeight);
|
|
49
|
+
}
|
|
50
|
+
if (message.glidingSpeed !== undefined) {
|
|
51
|
+
writer.uint32(69).float(message.glidingSpeed);
|
|
52
|
+
}
|
|
53
|
+
if (message.glidingFallingSpeed !== undefined) {
|
|
54
|
+
writer.uint32(77).float(message.glidingFallingSpeed);
|
|
55
|
+
}
|
|
44
56
|
return writer;
|
|
45
57
|
}
|
|
46
58
|
PBAvatarLocomotionSettings.encode = encode;
|
|
@@ -87,6 +99,24 @@ var PBAvatarLocomotionSettings;
|
|
|
87
99
|
}
|
|
88
100
|
message.hardLandingCooldown = reader.float();
|
|
89
101
|
continue;
|
|
102
|
+
case 7:
|
|
103
|
+
if (tag !== 61) {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
message.doubleJumpHeight = reader.float();
|
|
107
|
+
continue;
|
|
108
|
+
case 8:
|
|
109
|
+
if (tag !== 69) {
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
message.glidingSpeed = reader.float();
|
|
113
|
+
continue;
|
|
114
|
+
case 9:
|
|
115
|
+
if (tag !== 77) {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
message.glidingFallingSpeed = reader.float();
|
|
119
|
+
continue;
|
|
90
120
|
}
|
|
91
121
|
if ((tag & 7) === 4 || tag === 0) {
|
|
92
122
|
break;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import _m0 from "protobufjs/minimal";
|
|
2
2
|
import { Color3 } from "../../common/colors.gen";
|
|
3
|
+
/** Mask for which bones an animation applies to. */
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare const enum AvatarEmoteMask {
|
|
8
|
+
AEM_FULL_BODY = 0,
|
|
9
|
+
AEM_UPPER_BODY = 1
|
|
10
|
+
}
|
|
3
11
|
/**
|
|
4
12
|
* The AvatarShape component contains the information required to draw and animate avatar, acting as
|
|
5
13
|
* a simplified GLTF container for this specific case.
|
|
@@ -3,12 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PBAvatarShape = void 0;
|
|
6
|
+
exports.PBAvatarShape = exports.AvatarEmoteMask = void 0;
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
const long_1 = __importDefault(require("long"));
|
|
9
9
|
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
10
10
|
const colors_gen_1 = require("../../common/colors.gen");
|
|
11
11
|
const protobufPackageSarasa = "decentraland.sdk.components";
|
|
12
|
+
/** Mask for which bones an animation applies to. */
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
var AvatarEmoteMask;
|
|
17
|
+
(function (AvatarEmoteMask) {
|
|
18
|
+
AvatarEmoteMask[AvatarEmoteMask["AEM_FULL_BODY"] = 0] = "AEM_FULL_BODY";
|
|
19
|
+
AvatarEmoteMask[AvatarEmoteMask["AEM_UPPER_BODY"] = 1] = "AEM_UPPER_BODY";
|
|
20
|
+
})(AvatarEmoteMask = exports.AvatarEmoteMask || (exports.AvatarEmoteMask = {}));
|
|
12
21
|
function createBasePBAvatarShape() {
|
|
13
22
|
return {
|
|
14
23
|
id: "",
|
package/dist-cjs/components/generated/pb/decentraland/sdk/components/virtual_camera.gen.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { CameraTransition } from "./common/camera_transition.gen";
|
|
|
6
6
|
* an 'instant' transition (like using speed/time = 0)
|
|
7
7
|
* * The lookAtEntity defines to which entity the Camera has to look at constantly (independent from
|
|
8
8
|
* the holding entity transform).
|
|
9
|
+
* * The fov defines the Field of View of the virtual camera
|
|
9
10
|
*/
|
|
10
11
|
/**
|
|
11
12
|
* @public
|
|
@@ -13,6 +14,8 @@ import { CameraTransition } from "./common/camera_transition.gen";
|
|
|
13
14
|
export interface PBVirtualCamera {
|
|
14
15
|
defaultTransition?: CameraTransition | undefined;
|
|
15
16
|
lookAtEntity?: number | undefined;
|
|
17
|
+
/** default: 60 */
|
|
18
|
+
fov?: number | undefined;
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
21
|
* @public
|
|
@@ -9,7 +9,7 @@ const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
|
9
9
|
const camera_transition_gen_1 = require("./common/camera_transition.gen");
|
|
10
10
|
const protobufPackageSarasa = "decentraland.sdk.components";
|
|
11
11
|
function createBasePBVirtualCamera() {
|
|
12
|
-
return { defaultTransition: undefined, lookAtEntity: undefined };
|
|
12
|
+
return { defaultTransition: undefined, lookAtEntity: undefined, fov: undefined };
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* @public
|
|
@@ -23,6 +23,9 @@ var PBVirtualCamera;
|
|
|
23
23
|
if (message.lookAtEntity !== undefined) {
|
|
24
24
|
writer.uint32(16).uint32(message.lookAtEntity);
|
|
25
25
|
}
|
|
26
|
+
if (message.fov !== undefined) {
|
|
27
|
+
writer.uint32(29).float(message.fov);
|
|
28
|
+
}
|
|
26
29
|
return writer;
|
|
27
30
|
}
|
|
28
31
|
PBVirtualCamera.encode = encode;
|
|
@@ -45,6 +48,12 @@ var PBVirtualCamera;
|
|
|
45
48
|
}
|
|
46
49
|
message.lookAtEntity = reader.uint32();
|
|
47
50
|
continue;
|
|
51
|
+
case 3:
|
|
52
|
+
if (tag !== 29) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
message.fov = reader.float();
|
|
56
|
+
continue;
|
|
48
57
|
}
|
|
49
58
|
if ((tag & 7) === 4 || tag === 0) {
|
|
50
59
|
break;
|
|
@@ -22,7 +22,6 @@ import { LightSourceComponentDefinitionExtended } from './extended/LightSource';
|
|
|
22
22
|
import { TriggerAreaComponentDefinitionExtended } from './extended/TriggerArea';
|
|
23
23
|
import { ParticleSystemComponentDefinitionExtended } from './extended/ParticleSystem';
|
|
24
24
|
import { TagsComponentDefinitionExtended } from './manual/Tags';
|
|
25
|
-
import { ICreatedByType } from './manual/CreatedBy';
|
|
26
25
|
export * from './generated/index.gen';
|
|
27
26
|
export type { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition, LwwComponentGetter, GSetComponentGetter };
|
|
28
27
|
export declare const Transform: LwwComponentGetter<TransformComponentExtended>;
|
|
@@ -56,9 +55,5 @@ export declare const NetworkEntity: (engine: Pick<IEngine, 'defineComponent'>) =
|
|
|
56
55
|
* @alpha
|
|
57
56
|
*/
|
|
58
57
|
export declare const NetworkParent: (engine: Pick<IEngine, 'defineComponent'>) => LastWriteWinElementSetComponentDefinition<INetowrkParentType>;
|
|
59
|
-
/**
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
export declare const CreatedBy: (engine: Pick<IEngine, 'defineComponent'>) => LastWriteWinElementSetComponentDefinition<ICreatedByType>;
|
|
63
58
|
export { MediaState };
|
|
64
59
|
export type { AudioAnalysisView };
|
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.MediaState = exports.
|
|
20
|
+
exports.MediaState = exports.NetworkParent = exports.NetworkEntity = exports.SyncComponents = exports.Tags = exports.Name = exports.ParticleSystem = exports.TriggerArea = exports.LightSource = exports.InputModifier = exports.VirtualCamera = exports.Tween = exports.MeshCollider = exports.MeshRenderer = exports.AudioStream = exports.AudioAnalysis = exports.AudioSource = exports.Animator = exports.Material = exports.Transform = void 0;
|
|
21
21
|
const Animator_1 = require("./extended/Animator");
|
|
22
22
|
const AudioSource_1 = require("./extended/AudioSource");
|
|
23
23
|
const AudioAnalysis_1 = require("./extended/AudioAnalysis");
|
|
@@ -39,7 +39,6 @@ const LightSource_1 = require("./extended/LightSource");
|
|
|
39
39
|
const TriggerArea_1 = require("./extended/TriggerArea");
|
|
40
40
|
const ParticleSystem_1 = require("./extended/ParticleSystem");
|
|
41
41
|
const Tags_1 = __importDefault(require("./manual/Tags"));
|
|
42
|
-
const CreatedBy_1 = __importDefault(require("./manual/CreatedBy"));
|
|
43
42
|
__exportStar(require("./generated/index.gen"), exports);
|
|
44
43
|
/* @__PURE__ */
|
|
45
44
|
const Transform = (engine) => (0, Transform_1.defineTransformComponent)(engine);
|
|
@@ -101,15 +100,12 @@ exports.SyncComponents = SyncComponents;
|
|
|
101
100
|
/**
|
|
102
101
|
* @alpha
|
|
103
102
|
*/
|
|
103
|
+
/* @__PURE__ */
|
|
104
104
|
const NetworkEntity = (engine) => (0, NetworkEntity_1.default)(engine);
|
|
105
105
|
exports.NetworkEntity = NetworkEntity;
|
|
106
106
|
/**
|
|
107
107
|
* @alpha
|
|
108
108
|
*/
|
|
109
|
+
/* @__PURE__ */
|
|
109
110
|
const NetworkParent = (engine) => (0, NetworkParent_1.default)(engine);
|
|
110
111
|
exports.NetworkParent = NetworkParent;
|
|
111
|
-
/**
|
|
112
|
-
* @public
|
|
113
|
-
*/
|
|
114
|
-
const CreatedBy = (engine) => (0, CreatedBy_1.default)(engine);
|
|
115
|
-
exports.CreatedBy = CreatedBy;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LastWriteWinElementSetComponentDefinition, IEngine } from '../../engine';
|
|
2
2
|
import { Entity } from '../../engine/entity';
|
|
3
|
-
import type { ISchema } from '../../schemas/ISchema';
|
|
4
3
|
import type { Vector3Type } from '../../schemas/custom/Vector3';
|
|
5
4
|
/**
|
|
6
5
|
* @public
|
|
@@ -25,10 +24,6 @@ export interface TransformComponentExtended extends TransformComponent {
|
|
|
25
24
|
*/
|
|
26
25
|
localToWorldDirection(entity: Entity, localDirection: Vector3Type): Vector3Type;
|
|
27
26
|
}
|
|
28
|
-
/**
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
export declare const COMPONENT_ID = 1;
|
|
32
27
|
/**
|
|
33
28
|
* @public
|
|
34
29
|
*/
|
|
@@ -51,10 +46,6 @@ export type TransformType = {
|
|
|
51
46
|
};
|
|
52
47
|
parent?: Entity;
|
|
53
48
|
};
|
|
54
|
-
/** @public */
|
|
55
|
-
export declare const TRANSFORM_LENGTH = 44;
|
|
56
|
-
/** @public */
|
|
57
|
-
export declare const TransformSchema: ISchema<TransformType>;
|
|
58
49
|
/**
|
|
59
50
|
* @public
|
|
60
51
|
*/
|
|
@@ -29,12 +29,12 @@ exports.defineTransformComponent = exports.TransformSchema = exports.TRANSFORM_L
|
|
|
29
29
|
// getters via __importStar in CJS), so by the time methods are called all exports are available.
|
|
30
30
|
const treeHelpers = __importStar(require("../../runtime/helpers/tree"));
|
|
31
31
|
/**
|
|
32
|
-
* @
|
|
32
|
+
* @internal
|
|
33
33
|
*/
|
|
34
34
|
exports.COMPONENT_ID = 1;
|
|
35
|
-
/** @
|
|
35
|
+
/** @internal */
|
|
36
36
|
exports.TRANSFORM_LENGTH = 44;
|
|
37
|
-
/** @
|
|
37
|
+
/** @internal */
|
|
38
38
|
exports.TransformSchema = {
|
|
39
39
|
serialize(value, builder) {
|
|
40
40
|
const ptr = builder.incrementWriteOffset(exports.TRANSFORM_LENGTH);
|
|
@@ -13,7 +13,6 @@ export type { TagsComponentDefinitionExtended, TagsType } from './manual/Tags';
|
|
|
13
13
|
export type { ISyncComponents, ISyncComponentsType } from './manual/SyncComponents';
|
|
14
14
|
export type { INetowrkEntity, INetowrkEntityType } from './manual/NetworkEntity';
|
|
15
15
|
export type { INetowrkParent, INetowrkParentType } from './manual/NetworkParent';
|
|
16
|
-
export type { ICreatedBy, ICreatedByType } from './manual/CreatedBy';
|
|
17
16
|
export type { InputModifierHelper, InputModifierComponentDefinitionExtended } from './extended/InputModifier';
|
|
18
17
|
export type { LightSourceHelper, LightSourceComponentDefinitionExtended } from './extended/LightSource';
|
|
19
18
|
export type { TriggerAreaComponentDefinitionExtended } from './extended/TriggerArea';
|