@dcl/ecs 7.22.4 → 7.22.5-24779418349.commit-111fd7e
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/component-names.gen.js +0 -1
- package/dist/components/generated/global.gen.d.ts +0 -2
- package/dist/components/generated/global.gen.js +0 -1
- package/dist/components/generated/index.gen.d.ts +0 -4
- package/dist/components/generated/index.gen.js +0 -5
- package/dist/components/generated/pb/decentraland/common/colors.gen.d.ts +0 -15
- package/dist/components/generated/pb/decentraland/common/colors.gen.js +0 -47
- package/dist/components/generated/pb/decentraland/sdk/components/common/input_action.gen.d.ts +1 -10
- package/dist/components/generated/pb/decentraland/sdk/components/common/input_action.gen.js +0 -10
- package/dist/components/generated/pb/decentraland/sdk/components/pointer_events.gen.d.ts +1 -5
- package/dist/components/generated/pb/decentraland/sdk/components/pointer_events.gen.js +1 -20
- package/dist/components/generated/types.gen.d.ts +0 -2
- package/dist/components/generated/types.gen.js +0 -3
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +5 -5
- package/dist/components/manual/CreatedBy.d.ts +9 -0
- package/dist/components/manual/CreatedBy.js +8 -0
- package/dist/components/manual/Transform.d.ts +9 -13
- package/dist/components/manual/Transform.js +3 -11
- package/dist/components/types.d.ts +1 -1
- package/dist/engine/component.d.ts +52 -1
- package/dist/engine/grow-only-value-set-component-definition.js +45 -2
- package/dist/engine/lww-element-set-component-definition.d.ts +5 -3
- package/dist/engine/lww-element-set-component-definition.js +70 -35
- package/dist/index.d.ts +2 -3
- package/dist/index.js +1 -3
- package/dist/runtime/helpers/index.d.ts +0 -1
- package/dist/runtime/helpers/index.js +0 -1
- package/dist/runtime/helpers/tree.d.ts +0 -6
- package/dist/runtime/helpers/tree.js +2 -2
- package/dist/runtime/initialization/index.d.ts +0 -7
- package/dist/runtime/initialization/index.js +0 -6
- package/dist/serialization/crdt/authoritativePutComponent.d.ts +15 -0
- package/dist/serialization/crdt/authoritativePutComponent.js +47 -0
- package/dist/serialization/crdt/index.d.ts +1 -0
- package/dist/serialization/crdt/index.js +1 -0
- package/dist/serialization/crdt/types.d.ts +25 -3
- package/dist/serialization/crdt/types.js +3 -1
- package/dist/systems/crdt/index.d.ts +0 -1
- package/dist/systems/crdt/index.js +55 -146
- package/dist/systems/events.d.ts +0 -65
- package/dist/systems/events.js +8 -70
- package/dist-cjs/components/generated/component-names.gen.js +0 -1
- package/dist-cjs/components/generated/global.gen.d.ts +0 -2
- package/dist-cjs/components/generated/global.gen.js +1 -3
- package/dist-cjs/components/generated/index.gen.d.ts +0 -4
- package/dist-cjs/components/generated/index.gen.js +2 -8
- package/dist-cjs/components/generated/pb/decentraland/common/colors.gen.d.ts +0 -15
- package/dist-cjs/components/generated/pb/decentraland/common/colors.gen.js +1 -48
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/common/input_action.gen.d.ts +1 -10
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/common/input_action.gen.js +1 -11
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/pointer_events.gen.d.ts +1 -5
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/pointer_events.gen.js +1 -20
- package/dist-cjs/components/generated/types.gen.d.ts +0 -2
- package/dist-cjs/components/generated/types.gen.js +0 -5
- package/dist-cjs/components/index.d.ts +5 -2
- package/dist-cjs/components/index.js +7 -7
- package/dist-cjs/components/manual/CreatedBy.d.ts +9 -0
- package/dist-cjs/components/manual/CreatedBy.js +10 -0
- package/dist-cjs/components/manual/Transform.d.ts +9 -13
- package/dist-cjs/components/manual/Transform.js +3 -34
- package/dist-cjs/components/types.d.ts +1 -1
- package/dist-cjs/engine/component.d.ts +52 -1
- package/dist-cjs/engine/grow-only-value-set-component-definition.js +44 -1
- package/dist-cjs/engine/lww-element-set-component-definition.d.ts +5 -3
- package/dist-cjs/engine/lww-element-set-component-definition.js +73 -36
- package/dist-cjs/index.d.ts +2 -3
- package/dist-cjs/index.js +2 -4
- package/dist-cjs/runtime/helpers/index.d.ts +0 -1
- package/dist-cjs/runtime/helpers/index.js +0 -1
- package/dist-cjs/runtime/helpers/tree.d.ts +0 -6
- package/dist-cjs/runtime/helpers/tree.js +2 -3
- package/dist-cjs/runtime/initialization/index.d.ts +0 -7
- package/dist-cjs/runtime/initialization/index.js +1 -7
- package/dist-cjs/serialization/crdt/authoritativePutComponent.d.ts +15 -0
- package/dist-cjs/serialization/crdt/authoritativePutComponent.js +50 -0
- package/dist-cjs/serialization/crdt/index.d.ts +1 -0
- package/dist-cjs/serialization/crdt/index.js +1 -0
- package/dist-cjs/serialization/crdt/types.d.ts +25 -3
- package/dist-cjs/serialization/crdt/types.js +3 -1
- package/dist-cjs/systems/crdt/index.d.ts +0 -1
- package/dist-cjs/systems/crdt/index.js +55 -169
- package/dist-cjs/systems/events.d.ts +0 -65
- package/dist-cjs/systems/events.js +8 -70
- package/package.json +2 -3
- package/dist/components/extended/ParticleSystem.d.ts +0 -24
- package/dist/components/extended/ParticleSystem.js +0 -23
- package/dist/components/generated/ParticleSystem.gen.d.ts +0 -1
- package/dist/components/generated/ParticleSystem.gen.js +0 -25
- package/dist/components/generated/pb/decentraland/common/floats.gen.d.ts +0 -16
- package/dist/components/generated/pb/decentraland/common/floats.gen.js +0 -50
- package/dist/components/generated/pb/decentraland/sdk/components/particle_system.gen.d.ts +0 -241
- package/dist/components/generated/pb/decentraland/sdk/components/particle_system.gen.js +0 -717
- package/dist/runtime/helpers/vectors.d.ts +0 -1
- package/dist/runtime/helpers/vectors.js +0 -36
- package/dist/serialization/crdt/network/utils.d.ts +0 -9
- package/dist/serialization/crdt/network/utils.js +0 -60
- package/dist/systems/physics-force.d.ts +0 -1
- package/dist/systems/physics-force.js +0 -140
- package/dist/systems/physics-impulse.d.ts +0 -12
- package/dist/systems/physics-impulse.js +0 -85
- package/dist/systems/physics.d.ts +0 -77
- package/dist/systems/physics.js +0 -18
- package/dist-cjs/components/extended/ParticleSystem.d.ts +0 -24
- package/dist-cjs/components/extended/ParticleSystem.js +0 -28
- package/dist-cjs/components/generated/ParticleSystem.gen.d.ts +0 -1
- package/dist-cjs/components/generated/ParticleSystem.gen.js +0 -28
- package/dist-cjs/components/generated/pb/decentraland/common/floats.gen.d.ts +0 -16
- package/dist-cjs/components/generated/pb/decentraland/common/floats.gen.js +0 -56
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/particle_system.gen.d.ts +0 -241
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/particle_system.gen.js +0 -723
- package/dist-cjs/runtime/helpers/vectors.d.ts +0 -1
- package/dist-cjs/runtime/helpers/vectors.js +0 -39
- package/dist-cjs/serialization/crdt/network/utils.d.ts +0 -9
- package/dist-cjs/serialization/crdt/network/utils.js +0 -67
- package/dist-cjs/systems/physics-force.d.ts +0 -1
- package/dist-cjs/systems/physics-force.js +0 -167
- package/dist-cjs/systems/physics-impulse.d.ts +0 -12
- package/dist-cjs/systems/physics-impulse.js +0 -112
- package/dist-cjs/systems/physics.d.ts +0 -77
- package/dist-cjs/systems/physics.js +0 -23
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createComponentDefinitionFromSchema = exports.createGetCrdtMessagesForLww = exports.createUpdateLwwFromCrdt = exports.createDumpLwwFunctionFromCrdt = exports.incrementTimestamp = void 0;
|
|
3
|
+
exports.createComponentDefinitionFromSchema = exports.createGetCrdtMessagesForLww = exports.createUpdateLwwFromCrdt = exports.createForceUpdateLwwFromCrdt = exports.createCrdtRuleValidator = exports.createDumpLwwFunctionFromCrdt = exports.incrementTimestamp = void 0;
|
|
4
4
|
const ByteBuffer_1 = require("../serialization/ByteBuffer");
|
|
5
5
|
const crdt_1 = require("../serialization/crdt");
|
|
6
6
|
const utils_1 = require("../systems/crdt/utils");
|
|
@@ -35,16 +35,12 @@ function createDumpLwwFunctionFromCrdt(componentId, timestamps, schema, data) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
exports.createDumpLwwFunctionFromCrdt = createDumpLwwFunctionFromCrdt;
|
|
38
|
-
|
|
38
|
+
const __GLOBAL_ENTITY = '__GLOBAL_ENTITY';
|
|
39
|
+
function createCrdtRuleValidator(timestamps, schema, data) {
|
|
39
40
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* Returns the recieved data if the lamport number was bigger than ours.
|
|
45
|
-
* If it was an outdated message, then we return void
|
|
46
|
-
* @public
|
|
47
|
-
*/
|
|
41
|
+
* Shared CRDT conflict resolution logic
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
48
44
|
function crdtRuleForCurrentState(message) {
|
|
49
45
|
const { entityId, timestamp } = message;
|
|
50
46
|
const currentTimestamp = timestamps.get(entityId);
|
|
@@ -54,7 +50,6 @@ function createUpdateLwwFromCrdt(componentId, timestamps, schema, data, lastSent
|
|
|
54
50
|
}
|
|
55
51
|
// Outdated Message. Resend our state message through the wire.
|
|
56
52
|
if (currentTimestamp > timestamp) {
|
|
57
|
-
// console.log('2', currentTimestamp, timestamp)
|
|
58
53
|
return crdt_1.ProcessMessageResultType.StateOutdatedTimestamp;
|
|
59
54
|
}
|
|
60
55
|
// Deletes are idempotent
|
|
@@ -71,7 +66,6 @@ function createUpdateLwwFromCrdt(componentId, timestamps, schema, data, lastSent
|
|
|
71
66
|
currentDataGreater = (0, utils_1.dataCompare)(null, message.data);
|
|
72
67
|
}
|
|
73
68
|
// Same data, same timestamp. Weirdo echo message.
|
|
74
|
-
// console.log('3', currentDataGreater, writeBuffer.toBinary(), (message as any).data || null)
|
|
75
69
|
if (currentDataGreater === 0) {
|
|
76
70
|
return crdt_1.ProcessMessageResultType.NoChanges;
|
|
77
71
|
}
|
|
@@ -80,10 +74,37 @@ function createUpdateLwwFromCrdt(componentId, timestamps, schema, data, lastSent
|
|
|
80
74
|
return crdt_1.ProcessMessageResultType.StateOutdatedData;
|
|
81
75
|
}
|
|
82
76
|
else {
|
|
83
|
-
//
|
|
77
|
+
// Current data is lower
|
|
84
78
|
return crdt_1.ProcessMessageResultType.StateUpdatedData;
|
|
85
79
|
}
|
|
86
80
|
}
|
|
81
|
+
return crdtRuleForCurrentState;
|
|
82
|
+
}
|
|
83
|
+
exports.createCrdtRuleValidator = createCrdtRuleValidator;
|
|
84
|
+
function createForceUpdateLwwFromCrdt(componentId, timestamps, schema, data) {
|
|
85
|
+
/**
|
|
86
|
+
* Force update component state regardless of timestamp - used for server authoritative messages
|
|
87
|
+
*/
|
|
88
|
+
return (msg) => {
|
|
89
|
+
const buffer = new ByteBuffer_1.ReadWriteByteBuffer(msg.data);
|
|
90
|
+
const deserializedValue = schema.deserialize(buffer);
|
|
91
|
+
data.set(msg.entityId, deserializedValue);
|
|
92
|
+
timestamps.set(msg.entityId, msg.timestamp);
|
|
93
|
+
return [null, deserializedValue];
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
exports.createForceUpdateLwwFromCrdt = createForceUpdateLwwFromCrdt;
|
|
97
|
+
function createUpdateLwwFromCrdt(componentId, timestamps, schema, data) {
|
|
98
|
+
/**
|
|
99
|
+
* Process the received message only if the lamport number recieved is higher
|
|
100
|
+
* than the stored one. If its lower, we spread it to the network to correct the peer.
|
|
101
|
+
* If they are equal, the bigger raw data wins.
|
|
102
|
+
|
|
103
|
+
* Returns the recieved data if the lamport number was bigger than ours.
|
|
104
|
+
* If it was an outdated message, then we return void
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
const crdtRuleForCurrentState = createCrdtRuleValidator(timestamps, schema, data);
|
|
87
108
|
return (msg) => {
|
|
88
109
|
/* istanbul ignore next */
|
|
89
110
|
if (msg.type !== crdt_1.CrdtMessageType.PUT_COMPONENT &&
|
|
@@ -101,11 +122,9 @@ function createUpdateLwwFromCrdt(componentId, timestamps, schema, data, lastSent
|
|
|
101
122
|
if (msg.type === crdt_1.CrdtMessageType.PUT_COMPONENT || msg.type === crdt_1.CrdtMessageType.PUT_COMPONENT_NETWORK) {
|
|
102
123
|
const buf = new ByteBuffer_1.ReadWriteByteBuffer(msg.data);
|
|
103
124
|
data.set(entity, schema.deserialize(buf));
|
|
104
|
-
lastSentData.set(entity, new Uint8Array(msg.data));
|
|
105
125
|
}
|
|
106
126
|
else {
|
|
107
127
|
data.delete(entity);
|
|
108
|
-
lastSentData.delete(entity);
|
|
109
128
|
}
|
|
110
129
|
return [null, data.get(entity)];
|
|
111
130
|
}
|
|
@@ -142,34 +161,23 @@ function createUpdateLwwFromCrdt(componentId, timestamps, schema, data, lastSent
|
|
|
142
161
|
};
|
|
143
162
|
}
|
|
144
163
|
exports.createUpdateLwwFromCrdt = createUpdateLwwFromCrdt;
|
|
145
|
-
function createGetCrdtMessagesForLww(componentId, timestamps, dirtyIterator, schema, data
|
|
164
|
+
function createGetCrdtMessagesForLww(componentId, timestamps, dirtyIterator, schema, data) {
|
|
146
165
|
return function* () {
|
|
147
|
-
const writeBuffer = new ByteBuffer_1.ReadWriteByteBuffer();
|
|
148
166
|
for (const entity of dirtyIterator) {
|
|
167
|
+
const newTimestamp = incrementTimestamp(entity, timestamps);
|
|
149
168
|
if (data.has(entity)) {
|
|
150
|
-
writeBuffer.
|
|
169
|
+
const writeBuffer = new ByteBuffer_1.ReadWriteByteBuffer();
|
|
151
170
|
schema.serialize(data.get(entity), writeBuffer);
|
|
152
|
-
// Compare against last-sent snapshot using the zero-copy subarray view.
|
|
153
|
-
// Only allocate a copy when bytes actually differ.
|
|
154
|
-
const previousBytes = lastSentData.get(entity);
|
|
155
|
-
if (previousBytes && (0, utils_1.dataCompare)(writeBuffer.toBinary(), previousBytes) === 0) {
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
const currentBytes = writeBuffer.toCopiedBinary();
|
|
159
|
-
const newTimestamp = incrementTimestamp(entity, timestamps);
|
|
160
|
-
lastSentData.set(entity, currentBytes);
|
|
161
171
|
const msg = {
|
|
162
172
|
type: crdt_1.CrdtMessageType.PUT_COMPONENT,
|
|
163
173
|
componentId,
|
|
164
174
|
entityId: entity,
|
|
165
|
-
data:
|
|
175
|
+
data: writeBuffer.toBinary(),
|
|
166
176
|
timestamp: newTimestamp
|
|
167
177
|
};
|
|
168
178
|
yield msg;
|
|
169
179
|
}
|
|
170
180
|
else {
|
|
171
|
-
lastSentData.delete(entity);
|
|
172
|
-
const newTimestamp = incrementTimestamp(entity, timestamps);
|
|
173
181
|
const msg = {
|
|
174
182
|
type: crdt_1.CrdtMessageType.DELETE_COMPONENT,
|
|
175
183
|
componentId,
|
|
@@ -190,8 +198,8 @@ function createComponentDefinitionFromSchema(componentName, componentId, schema)
|
|
|
190
198
|
const data = new Map();
|
|
191
199
|
const dirtyIterator = new Set();
|
|
192
200
|
const timestamps = new Map();
|
|
193
|
-
const lastSentData = new Map();
|
|
194
201
|
const onChangeCallbacks = new Map();
|
|
202
|
+
const validateCallbacks = new Map();
|
|
195
203
|
return {
|
|
196
204
|
get componentId() {
|
|
197
205
|
return componentId;
|
|
@@ -212,14 +220,12 @@ function createComponentDefinitionFromSchema(componentName, componentId, schema)
|
|
|
212
220
|
if (data.delete(entity) && markAsDirty) {
|
|
213
221
|
dirtyIterator.add(entity);
|
|
214
222
|
}
|
|
215
|
-
lastSentData.delete(entity);
|
|
216
223
|
return component || null;
|
|
217
224
|
},
|
|
218
225
|
entityDeleted(entity, markAsDirty) {
|
|
219
226
|
if (data.delete(entity) && markAsDirty) {
|
|
220
227
|
dirtyIterator.add(entity);
|
|
221
228
|
}
|
|
222
|
-
lastSentData.delete(entity);
|
|
223
229
|
},
|
|
224
230
|
getOrNull(entity) {
|
|
225
231
|
const component = data.get(entity);
|
|
@@ -246,7 +252,6 @@ function createComponentDefinitionFromSchema(componentName, componentId, schema)
|
|
|
246
252
|
const usedValue = value === undefined ? schema.create() : schema.extend ? schema.extend(value) : value;
|
|
247
253
|
data.set(entity, usedValue);
|
|
248
254
|
dirtyIterator.add(entity);
|
|
249
|
-
lastSentData.delete(entity);
|
|
250
255
|
return usedValue;
|
|
251
256
|
},
|
|
252
257
|
getMutableOrNull(entity) {
|
|
@@ -284,9 +289,41 @@ function createComponentDefinitionFromSchema(componentName, componentId, schema)
|
|
|
284
289
|
yield entity;
|
|
285
290
|
}
|
|
286
291
|
},
|
|
287
|
-
getCrdtUpdates: createGetCrdtMessagesForLww(componentId, timestamps, dirtyIterator, schema, data
|
|
288
|
-
updateFromCrdt: createUpdateLwwFromCrdt(componentId, timestamps, schema, data
|
|
292
|
+
getCrdtUpdates: createGetCrdtMessagesForLww(componentId, timestamps, dirtyIterator, schema, data),
|
|
293
|
+
updateFromCrdt: createUpdateLwwFromCrdt(componentId, timestamps, schema, data),
|
|
294
|
+
__forceUpdateFromCrdt: createForceUpdateLwwFromCrdt(componentId, timestamps, schema, data),
|
|
295
|
+
__dry_run_updateFromCrdt: createCrdtRuleValidator(timestamps, schema, data),
|
|
289
296
|
dumpCrdtStateToBuffer: createDumpLwwFunctionFromCrdt(componentId, timestamps, schema, data),
|
|
297
|
+
validateBeforeChange(entityOrCb, cb) {
|
|
298
|
+
if (arguments.length === 1) {
|
|
299
|
+
// Second overload: just callback (global validation)
|
|
300
|
+
validateCallbacks.set(__GLOBAL_ENTITY, entityOrCb);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
if (cb) {
|
|
304
|
+
validateCallbacks.set(entityOrCb, cb);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
__run_validateBeforeChange(entity, newValue, senderAddress, createdBy) {
|
|
309
|
+
const cb = entity && validateCallbacks.get(entity);
|
|
310
|
+
const globalCb = validateCallbacks.get(__GLOBAL_ENTITY);
|
|
311
|
+
const currentValue = data.get(entity);
|
|
312
|
+
const value = { entity, currentValue, newValue, senderAddress, createdBy };
|
|
313
|
+
const globalResult = globalCb?.(value) ?? true;
|
|
314
|
+
const entityResult = (globalResult && cb?.(value)) ?? true;
|
|
315
|
+
return globalResult && entityResult;
|
|
316
|
+
},
|
|
317
|
+
getCrdtState(entity) {
|
|
318
|
+
const componentData = data.get(entity);
|
|
319
|
+
const timestamp = timestamps.get(entity);
|
|
320
|
+
if (componentData && timestamp !== undefined) {
|
|
321
|
+
const buffer = new ByteBuffer_1.ReadWriteByteBuffer();
|
|
322
|
+
schema.serialize((0, readonly_1.deepReadonly)(componentData), buffer);
|
|
323
|
+
return { data: buffer.toBinary(), timestamp };
|
|
324
|
+
}
|
|
325
|
+
return null;
|
|
326
|
+
},
|
|
290
327
|
onChange(entity, cb) {
|
|
291
328
|
const cbs = onChangeCallbacks.get(entity) ?? [];
|
|
292
329
|
cbs.push(cb);
|
package/dist-cjs/index.d.ts
CHANGED
|
@@ -12,10 +12,9 @@ export * from './systems/assetLoad';
|
|
|
12
12
|
export * from './systems/async-task';
|
|
13
13
|
export * from './systems/tween';
|
|
14
14
|
export * from './systems/triggerArea';
|
|
15
|
-
export * from './systems/physics';
|
|
16
15
|
export * from './engine/entity';
|
|
17
16
|
export * from './components/types';
|
|
18
|
-
import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, AudioSourceComponentDefinitionExtended, AudioStreamComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent, VirtualCameraComponentDefinitionExtended, InputModifierComponentDefinitionExtended, LightSourceComponentDefinitionExtended, TriggerAreaComponentDefinitionExtended,
|
|
17
|
+
import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, AudioSourceComponentDefinitionExtended, AudioStreamComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent, VirtualCameraComponentDefinitionExtended, InputModifierComponentDefinitionExtended, LightSourceComponentDefinitionExtended, TriggerAreaComponentDefinitionExtended, ICreatedBy } from './components/types';
|
|
19
18
|
import { NameComponent } from './components/manual/Name';
|
|
20
19
|
import { TagsComponentDefinitionExtended } from './components/manual/Tags';
|
|
21
20
|
export declare const Transform: TransformComponentExtended;
|
|
@@ -32,7 +31,6 @@ export declare const VirtualCamera: VirtualCameraComponentDefinitionExtended;
|
|
|
32
31
|
export declare const InputModifier: InputModifierComponentDefinitionExtended;
|
|
33
32
|
export declare const LightSource: LightSourceComponentDefinitionExtended;
|
|
34
33
|
export declare const TriggerArea: TriggerAreaComponentDefinitionExtended;
|
|
35
|
-
export declare const ParticleSystem: ParticleSystemComponentDefinitionExtended;
|
|
36
34
|
/**
|
|
37
35
|
* @alpha
|
|
38
36
|
* This is going to be used for sync components through a server.
|
|
@@ -49,6 +47,7 @@ export declare const NetworkEntity: INetowrkEntity;
|
|
|
49
47
|
* Tag a entity to be syncronized through comms
|
|
50
48
|
*/
|
|
51
49
|
export declare const NetworkParent: INetowrkParent;
|
|
50
|
+
export declare const CreatedBy: ICreatedBy;
|
|
52
51
|
export * from './components/generated/global.gen';
|
|
53
52
|
export * from './components/generated/types.gen';
|
|
54
53
|
export * from './serialization/crdt';
|
package/dist-cjs/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.CreatedBy = exports.NetworkParent = exports.NetworkEntity = exports.SyncComponents = exports.TriggerArea = exports.LightSource = exports.InputModifier = exports.VirtualCamera = exports.Tween = exports.Tags = exports.Name = exports.MeshCollider = exports.MeshRenderer = exports.Material = exports.AudioStream = exports.AudioSource = exports.Animator = exports.Transform = exports.components = exports.cyclicParentingChecker = void 0;
|
|
30
30
|
// The order of the following imports matters. Please do not auto-sort
|
|
31
31
|
__exportStar(require("./engine"), exports);
|
|
32
32
|
__exportStar(require("./schemas"), exports);
|
|
@@ -43,7 +43,6 @@ __exportStar(require("./systems/assetLoad"), exports);
|
|
|
43
43
|
__exportStar(require("./systems/async-task"), exports);
|
|
44
44
|
__exportStar(require("./systems/tween"), exports);
|
|
45
45
|
__exportStar(require("./systems/triggerArea"), exports);
|
|
46
|
-
__exportStar(require("./systems/physics"), exports);
|
|
47
46
|
__exportStar(require("./engine/entity"), exports);
|
|
48
47
|
__exportStar(require("./components/types"), exports);
|
|
49
48
|
// @internal
|
|
@@ -65,8 +64,6 @@ exports.VirtualCamera = components.VirtualCamera(initialization_1.engine);
|
|
|
65
64
|
exports.InputModifier = components.InputModifier(initialization_1.engine);
|
|
66
65
|
exports.LightSource = components.LightSource(initialization_1.engine);
|
|
67
66
|
exports.TriggerArea = components.TriggerArea(initialization_1.engine);
|
|
68
|
-
exports.ParticleSystem =
|
|
69
|
-
/* @__PURE__*/ components.ParticleSystem(initialization_1.engine);
|
|
70
67
|
/**
|
|
71
68
|
* @alpha
|
|
72
69
|
* This is going to be used for sync components through a server.
|
|
@@ -83,6 +80,7 @@ exports.NetworkEntity = components.NetworkEntity(initialization_1.engine);
|
|
|
83
80
|
* Tag a entity to be syncronized through comms
|
|
84
81
|
*/
|
|
85
82
|
exports.NetworkParent = components.NetworkParent(initialization_1.engine);
|
|
83
|
+
exports.CreatedBy = components.CreatedBy(initialization_1.engine);
|
|
86
84
|
// export components for global engine
|
|
87
85
|
__exportStar(require("./components/generated/global.gen"), exports);
|
|
88
86
|
__exportStar(require("./components/generated/types.gen"), exports);
|
|
@@ -17,6 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.createTimers = void 0;
|
|
18
18
|
__exportStar(require("./coordinates"), exports);
|
|
19
19
|
__exportStar(require("./tree"), exports);
|
|
20
|
-
__exportStar(require("./vectors"), exports);
|
|
21
20
|
var timers_1 = require("./timers");
|
|
22
21
|
Object.defineProperty(exports, "createTimers", { enumerable: true, get: function () { return timers_1.createTimers; } });
|
|
@@ -2,12 +2,6 @@ import { Entity } from '../../engine/entity';
|
|
|
2
2
|
import { ComponentDefinition, IEngine } from '../../engine';
|
|
3
3
|
import { Vector3Type } from '../../schemas/custom/Vector3';
|
|
4
4
|
import { QuaternionType } from '../../schemas/custom/Quaternion';
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
* Rotate a vector by a quaternion
|
|
8
|
-
* Uses the formula: v' = q * v * q^(-1), optimized version
|
|
9
|
-
*/
|
|
10
|
-
export declare function rotateVectorByQuaternion(v: Vector3Type, q: QuaternionType): Vector3Type;
|
|
11
5
|
/**
|
|
12
6
|
* Get an iterator of entities that follow a tree structure for a component
|
|
13
7
|
* @public
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getWorldRotation = exports.getWorldPosition = exports.getEntitiesWithParent = exports.removeEntityWithChildren = exports.getComponentEntityTree =
|
|
26
|
+
exports.getWorldRotation = exports.getWorldPosition = exports.getEntitiesWithParent = exports.removeEntityWithChildren = exports.getComponentEntityTree = void 0;
|
|
27
27
|
const components = __importStar(require("../../components"));
|
|
28
28
|
/**
|
|
29
29
|
* @internal
|
|
@@ -61,7 +61,7 @@ function multiplyQuaternions(q1, q2) {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* @
|
|
64
|
+
* @internal
|
|
65
65
|
* Rotate a vector by a quaternion
|
|
66
66
|
* Uses the formula: v' = q * v * q^(-1), optimized version
|
|
67
67
|
*/
|
|
@@ -80,7 +80,6 @@ function rotateVectorByQuaternion(v, q) {
|
|
|
80
80
|
z: iz * qw + iw * -qz + ix * -qy - iy * -qx
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
exports.rotateVectorByQuaternion = rotateVectorByQuaternion;
|
|
84
83
|
/** @internal Identity transform values */
|
|
85
84
|
const IDENTITY_POSITION = { x: 0, y: 0, z: 0 };
|
|
86
85
|
const IDENTITY_ROTATION = { x: 0, y: 0, z: 0, w: 1 };
|
|
@@ -12,7 +12,6 @@ import { AssetLoadLoadingStateSystem } from '../../systems/assetLoad';
|
|
|
12
12
|
import { TweenSystem } from '../../systems/tween';
|
|
13
13
|
import { TriggerAreaEventsSystem } from '../../systems/triggerArea';
|
|
14
14
|
import { createTimers, Timers } from '../helpers/timers';
|
|
15
|
-
import { PhysicsSystem } from '../../systems/physics';
|
|
16
15
|
/**
|
|
17
16
|
* @public
|
|
18
17
|
* The engine is the part of the scene that sits in the middle and manages all of the other parts.
|
|
@@ -78,12 +77,6 @@ export { TriggerAreaEventsSystem };
|
|
|
78
77
|
*/
|
|
79
78
|
export declare const timers: Timers;
|
|
80
79
|
export { Timers, createTimers };
|
|
81
|
-
/**
|
|
82
|
-
* @public
|
|
83
|
-
* Physics helpers for applying impulses and forces to the player.
|
|
84
|
-
*/
|
|
85
|
-
export declare const Physics: PhysicsSystem;
|
|
86
|
-
export { PhysicsSystem };
|
|
87
80
|
/**
|
|
88
81
|
* @public
|
|
89
82
|
* Runs an async function
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* init and it'll be changing.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.executeTask = exports.
|
|
7
|
+
exports.executeTask = exports.createTimers = exports.timers = exports.triggerAreaEventsSystem = exports.tweenSystem = exports.assetLoadLoadingStateSystem = exports.videoEventsSystem = exports.raycastSystem = exports.pointerEventsSystem = exports.inputSystem = exports.engine = void 0;
|
|
8
8
|
const engine_1 = require("../../engine");
|
|
9
9
|
const async_task_1 = require("../../systems/async-task");
|
|
10
10
|
const events_1 = require("../../systems/events");
|
|
@@ -18,7 +18,6 @@ const triggerArea_1 = require("../../systems/triggerArea");
|
|
|
18
18
|
const timers_1 = require("../helpers/timers");
|
|
19
19
|
Object.defineProperty(exports, "createTimers", { enumerable: true, get: function () { return timers_1.createTimers; } });
|
|
20
20
|
const globals_1 = require("../globals");
|
|
21
|
-
const physics_1 = require("../../systems/physics");
|
|
22
21
|
/**
|
|
23
22
|
* @public
|
|
24
23
|
* The engine is the part of the scene that sits in the middle and manages all of the other parts.
|
|
@@ -81,11 +80,6 @@ exports.timers = (0, timers_1.createTimers)(exports.engine);
|
|
|
81
80
|
(0, globals_1.setGlobalPolyfill)('clearTimeout', exports.timers.clearTimeout);
|
|
82
81
|
(0, globals_1.setGlobalPolyfill)('setInterval', exports.timers.setInterval);
|
|
83
82
|
(0, globals_1.setGlobalPolyfill)('clearInterval', exports.timers.clearInterval);
|
|
84
|
-
/**
|
|
85
|
-
* @public
|
|
86
|
-
* Physics helpers for applying impulses and forces to the player.
|
|
87
|
-
*/
|
|
88
|
-
exports.Physics = (0, physics_1.createPhysicsSystem)(exports.engine);
|
|
89
83
|
/**
|
|
90
84
|
* Adds pointer event collider system only in DEV env
|
|
91
85
|
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Entity } from '../../engine/entity';
|
|
2
|
+
import { ByteBuffer } from '../ByteBuffer';
|
|
3
|
+
import { AuthoritativePutComponentMessage } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export declare namespace AuthoritativePutComponentOperation {
|
|
8
|
+
const MESSAGE_HEADER_LENGTH = 16;
|
|
9
|
+
/**
|
|
10
|
+
* Call this function for an optimal writing data passing the ByteBuffer
|
|
11
|
+
* already allocated
|
|
12
|
+
*/
|
|
13
|
+
function write(entity: Entity, timestamp: number, componentId: number, data: Uint8Array, buf: ByteBuffer): void;
|
|
14
|
+
function read(buf: ByteBuffer): AuthoritativePutComponentMessage | null;
|
|
15
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthoritativePutComponentOperation = void 0;
|
|
4
|
+
const crdtMessageProtocol_1 = require("./crdtMessageProtocol");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
var AuthoritativePutComponentOperation;
|
|
10
|
+
(function (AuthoritativePutComponentOperation) {
|
|
11
|
+
AuthoritativePutComponentOperation.MESSAGE_HEADER_LENGTH = 16;
|
|
12
|
+
/**
|
|
13
|
+
* Call this function for an optimal writing data passing the ByteBuffer
|
|
14
|
+
* already allocated
|
|
15
|
+
*/
|
|
16
|
+
function write(entity, timestamp, componentId, data, buf) {
|
|
17
|
+
// reserve the beginning
|
|
18
|
+
const startMessageOffset = buf.incrementWriteOffset(types_1.CRDT_MESSAGE_HEADER_LENGTH + AuthoritativePutComponentOperation.MESSAGE_HEADER_LENGTH);
|
|
19
|
+
// write body
|
|
20
|
+
buf.writeBuffer(data, false);
|
|
21
|
+
const messageLength = buf.currentWriteOffset() - startMessageOffset;
|
|
22
|
+
// Write CrdtMessage header
|
|
23
|
+
buf.setUint32(startMessageOffset, messageLength);
|
|
24
|
+
buf.setUint32(startMessageOffset + 4, types_1.CrdtMessageType.AUTHORITATIVE_PUT_COMPONENT);
|
|
25
|
+
// Write ComponentOperation header
|
|
26
|
+
buf.setUint32(startMessageOffset + 8, entity);
|
|
27
|
+
buf.setUint32(startMessageOffset + 12, componentId);
|
|
28
|
+
buf.setUint32(startMessageOffset + 16, timestamp);
|
|
29
|
+
const newLocal = messageLength - AuthoritativePutComponentOperation.MESSAGE_HEADER_LENGTH - types_1.CRDT_MESSAGE_HEADER_LENGTH;
|
|
30
|
+
buf.setUint32(startMessageOffset + 20, newLocal);
|
|
31
|
+
}
|
|
32
|
+
AuthoritativePutComponentOperation.write = write;
|
|
33
|
+
function read(buf) {
|
|
34
|
+
const header = crdtMessageProtocol_1.CrdtMessageProtocol.readHeader(buf);
|
|
35
|
+
if (!header) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (header.type !== types_1.CrdtMessageType.AUTHORITATIVE_PUT_COMPONENT) {
|
|
39
|
+
throw new Error('AuthoritativePutComponentOperation tried to read another message type.');
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
...header,
|
|
43
|
+
entityId: buf.readUint32(),
|
|
44
|
+
componentId: buf.readUint32(),
|
|
45
|
+
timestamp: buf.readUint32(),
|
|
46
|
+
data: buf.readBuffer()
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
AuthoritativePutComponentOperation.read = read;
|
|
50
|
+
})(AuthoritativePutComponentOperation = exports.AuthoritativePutComponentOperation || (exports.AuthoritativePutComponentOperation = {}));
|
|
@@ -23,3 +23,4 @@ __exportStar(require("./network/deleteComponentNetwork"), exports);
|
|
|
23
23
|
__exportStar(require("./network/deleteEntityNetwork"), exports);
|
|
24
24
|
__exportStar(require("./types"), exports);
|
|
25
25
|
__exportStar(require("./crdtMessageProtocol"), exports);
|
|
26
|
+
__exportStar(require("./authoritativePutComponent"), exports);
|
|
@@ -11,7 +11,8 @@ export declare enum CrdtMessageType {
|
|
|
11
11
|
PUT_COMPONENT_NETWORK = 5,
|
|
12
12
|
DELETE_COMPONENT_NETWORK = 6,
|
|
13
13
|
DELETE_ENTITY_NETWORK = 7,
|
|
14
|
-
|
|
14
|
+
AUTHORITATIVE_PUT_COMPONENT = 8,
|
|
15
|
+
MAX_MESSAGE_TYPE = 9
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Min length = 8 bytes
|
|
@@ -48,6 +49,23 @@ export type PutNetworkComponentMessageBody = Omit<PutComponentMessageBody, 'type
|
|
|
48
49
|
type: CrdtMessageType.PUT_COMPONENT_NETWORK;
|
|
49
50
|
networkId: number;
|
|
50
51
|
};
|
|
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
|
+
};
|
|
51
69
|
/**
|
|
52
70
|
* Min. length = header (8 bytes) + 16 bytes = 24 bytes
|
|
53
71
|
*
|
|
@@ -114,6 +132,10 @@ export type AppendValueMessage = CrdtMessageHeader & AppendValueMessageBody;
|
|
|
114
132
|
* @public
|
|
115
133
|
*/
|
|
116
134
|
export type PutComponentMessage = CrdtMessageHeader & PutComponentMessageBody;
|
|
135
|
+
/**
|
|
136
|
+
* @public
|
|
137
|
+
*/
|
|
138
|
+
export type AuthoritativePutComponentMessage = CrdtMessageHeader & AuthoritativePutComponentMessageBody;
|
|
117
139
|
/**
|
|
118
140
|
* @public
|
|
119
141
|
*/
|
|
@@ -137,7 +159,7 @@ export type DeleteEntityNetworkMessage = CrdtMessageHeader & DeleteEntityNetwork
|
|
|
137
159
|
/**
|
|
138
160
|
* @public
|
|
139
161
|
*/
|
|
140
|
-
export type CrdtMessage = PutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
|
|
162
|
+
export type CrdtMessage = PutComponentMessage | AuthoritativePutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
|
|
141
163
|
/**
|
|
142
164
|
* @public
|
|
143
165
|
*/
|
|
@@ -145,7 +167,7 @@ export type CrdtNetworkMessageBody = PutNetworkComponentMessageBody | DeleteComp
|
|
|
145
167
|
/**
|
|
146
168
|
* @public
|
|
147
169
|
*/
|
|
148
|
-
export type CrdtMessageBody = PutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
|
|
170
|
+
export type CrdtMessageBody = PutComponentMessageBody | AuthoritativePutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
|
|
149
171
|
export declare enum ProcessMessageResultType {
|
|
150
172
|
/**
|
|
151
173
|
* Typical message and new state set.
|
|
@@ -16,7 +16,9 @@ var CrdtMessageType;
|
|
|
16
16
|
CrdtMessageType[CrdtMessageType["PUT_COMPONENT_NETWORK"] = 5] = "PUT_COMPONENT_NETWORK";
|
|
17
17
|
CrdtMessageType[CrdtMessageType["DELETE_COMPONENT_NETWORK"] = 6] = "DELETE_COMPONENT_NETWORK";
|
|
18
18
|
CrdtMessageType[CrdtMessageType["DELETE_ENTITY_NETWORK"] = 7] = "DELETE_ENTITY_NETWORK";
|
|
19
|
-
|
|
19
|
+
// Server authoritative operation - forces component state regardless of timestamp
|
|
20
|
+
CrdtMessageType[CrdtMessageType["AUTHORITATIVE_PUT_COMPONENT"] = 8] = "AUTHORITATIVE_PUT_COMPONENT";
|
|
21
|
+
CrdtMessageType[CrdtMessageType["MAX_MESSAGE_TYPE"] = 9] = "MAX_MESSAGE_TYPE";
|
|
20
22
|
})(CrdtMessageType = exports.CrdtMessageType || (exports.CrdtMessageType = {}));
|
|
21
23
|
/**
|
|
22
24
|
* @public
|