@vworlds/vecs-client 1.0.16
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/node_modules/@vworlds/vecs-protocol/package.json +14 -0
- package/node_modules/@vworlds/vecs-protocol/src/cid.d.ts +14 -0
- package/node_modules/@vworlds/vecs-protocol/src/cid.js +58 -0
- package/node_modules/@vworlds/vecs-protocol/src/cid.js.map +1 -0
- package/node_modules/@vworlds/vecs-protocol/src/index.d.ts +5 -0
- package/node_modules/@vworlds/vecs-protocol/src/index.js +5 -0
- package/node_modules/@vworlds/vecs-protocol/src/index.js.map +1 -0
- package/node_modules/@vworlds/vecs-protocol/src/messages.d.ts +42 -0
- package/node_modules/@vworlds/vecs-protocol/src/messages.js +149 -0
- package/node_modules/@vworlds/vecs-protocol/src/messages.js.map +1 -0
- package/node_modules/@vworlds/vecs-protocol/src/network_world.d.ts +18 -0
- package/node_modules/@vworlds/vecs-protocol/src/network_world.js +93 -0
- package/node_modules/@vworlds/vecs-protocol/src/network_world.js.map +1 -0
- package/node_modules/@vworlds/vecs-protocol/src/rpc.d.ts +36 -0
- package/node_modules/@vworlds/vecs-protocol/src/rpc.js +140 -0
- package/node_modules/@vworlds/vecs-protocol/src/rpc.js.map +1 -0
- package/node_modules/@vworlds/vecs-protocol/src/transport.d.ts +21 -0
- package/node_modules/@vworlds/vecs-protocol/src/transport.js +2 -0
- package/node_modules/@vworlds/vecs-protocol/src/transport.js.map +1 -0
- package/node_modules/@vworlds/vecs-wire/package.json +14 -0
- package/node_modules/@vworlds/vecs-wire/src/any.d.ts +27 -0
- package/node_modules/@vworlds/vecs-wire/src/any.js +43 -0
- package/node_modules/@vworlds/vecs-wire/src/any.js.map +1 -0
- package/node_modules/@vworlds/vecs-wire/src/decoder.d.ts +31 -0
- package/node_modules/@vworlds/vecs-wire/src/decoder.js +180 -0
- package/node_modules/@vworlds/vecs-wire/src/decoder.js.map +1 -0
- package/node_modules/@vworlds/vecs-wire/src/decorators.d.ts +4 -0
- package/node_modules/@vworlds/vecs-wire/src/decorators.js +139 -0
- package/node_modules/@vworlds/vecs-wire/src/decorators.js.map +1 -0
- package/node_modules/@vworlds/vecs-wire/src/encoder.d.ts +32 -0
- package/node_modules/@vworlds/vecs-wire/src/encoder.js +230 -0
- package/node_modules/@vworlds/vecs-wire/src/encoder.js.map +1 -0
- package/node_modules/@vworlds/vecs-wire/src/index.d.ts +5 -0
- package/node_modules/@vworlds/vecs-wire/src/index.js +5 -0
- package/node_modules/@vworlds/vecs-wire/src/index.js.map +1 -0
- package/package.json +28 -0
- package/vecs-client/src/client_world.d.ts +46 -0
- package/vecs-client/src/client_world.js +129 -0
- package/vecs-client/src/client_world.js.map +1 -0
- package/vecs-client/src/index.d.ts +4 -0
- package/vecs-client/src/index.js +4 -0
- package/vecs-client/src/index.js.map +1 -0
- package/vecs-client/src/interpolator.d.ts +51 -0
- package/vecs-client/src/interpolator.js +305 -0
- package/vecs-client/src/interpolator.js.map +1 -0
- package/vecs-client/src/world_path.d.ts +1 -0
- package/vecs-client/src/world_path.js +4 -0
- package/vecs-client/src/world_path.js.map +1 -0
- package/vecs-protocol/src/cid.d.ts +14 -0
- package/vecs-protocol/src/cid.js +58 -0
- package/vecs-protocol/src/cid.js.map +1 -0
- package/vecs-protocol/src/index.d.ts +5 -0
- package/vecs-protocol/src/index.js +5 -0
- package/vecs-protocol/src/index.js.map +1 -0
- package/vecs-protocol/src/messages.d.ts +42 -0
- package/vecs-protocol/src/messages.js +149 -0
- package/vecs-protocol/src/messages.js.map +1 -0
- package/vecs-protocol/src/network_world.d.ts +18 -0
- package/vecs-protocol/src/network_world.js +93 -0
- package/vecs-protocol/src/network_world.js.map +1 -0
- package/vecs-protocol/src/rpc.d.ts +36 -0
- package/vecs-protocol/src/rpc.js +140 -0
- package/vecs-protocol/src/rpc.js.map +1 -0
- package/vecs-protocol/src/transport.d.ts +21 -0
- package/vecs-protocol/src/transport.js +2 -0
- package/vecs-protocol/src/transport.js.map +1 -0
- package/vecs-wire/src/any.d.ts +27 -0
- package/vecs-wire/src/any.js +43 -0
- package/vecs-wire/src/any.js.map +1 -0
- package/vecs-wire/src/decoder.d.ts +31 -0
- package/vecs-wire/src/decoder.js +180 -0
- package/vecs-wire/src/decoder.js.map +1 -0
- package/vecs-wire/src/decorators.d.ts +4 -0
- package/vecs-wire/src/decorators.js +139 -0
- package/vecs-wire/src/decorators.js.map +1 -0
- package/vecs-wire/src/encoder.d.ts +32 -0
- package/vecs-wire/src/encoder.js +230 -0
- package/vecs-wire/src/encoder.js.map +1 -0
- package/vecs-wire/src/index.d.ts +5 -0
- package/vecs-wire/src/index.js +5 -0
- package/vecs-wire/src/index.js.map +1 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { ALL_COMPONENTS, ComponentSnapshot as WireComponentSnapshot, cid_pack, cid_unpack, } from "@vworlds/vecs-protocol";
|
|
2
|
+
import { Decoder } from "@vworlds/vecs-wire";
|
|
3
|
+
const MAX_LENGTH = 3;
|
|
4
|
+
const POSITION_COMPONENT_TYPE = 1;
|
|
5
|
+
export class ComponentSnapshot {
|
|
6
|
+
constructor(eid, type, payload) {
|
|
7
|
+
this.eid = eid;
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.payload = payload;
|
|
10
|
+
this.cid = cid_pack(eid, type);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class Diff {
|
|
14
|
+
constructor(from, to, removed) {
|
|
15
|
+
this.from = from;
|
|
16
|
+
this.to = to;
|
|
17
|
+
this.removed = removed;
|
|
18
|
+
this.snapshots = [];
|
|
19
|
+
}
|
|
20
|
+
get smap() {
|
|
21
|
+
if (this._smap) {
|
|
22
|
+
return this._smap;
|
|
23
|
+
}
|
|
24
|
+
return (this._smap = new Map((this.snapshots || []).map((s) => [s.cid, s])));
|
|
25
|
+
}
|
|
26
|
+
set smap(v) {
|
|
27
|
+
this._smap = v;
|
|
28
|
+
this.updateSnapshotsFromMap();
|
|
29
|
+
}
|
|
30
|
+
updateSnapshotsFromMap() {
|
|
31
|
+
this.snapshots = [...this.smap.values()];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function diffFromStateDiff(sd) {
|
|
35
|
+
const d = new Diff(sd.fromFrame, sd.toFrame);
|
|
36
|
+
d.snapshots = sd.snapshots.map((snapshot) => {
|
|
37
|
+
const wire = new Decoder(snapshot.bytes).read(WireComponentSnapshot);
|
|
38
|
+
return new ComponentSnapshot(wire.eid, wire.type, wire.payload);
|
|
39
|
+
});
|
|
40
|
+
d.removed = sd.removed.map(([eid, type]) => cid_pack(eid, type));
|
|
41
|
+
return d;
|
|
42
|
+
}
|
|
43
|
+
export class Interpolator {
|
|
44
|
+
constructor(max_length = MAX_LENGTH, // max bucket length
|
|
45
|
+
server_tick_interval = 1000 / 60, // server tick interval FPS configuration
|
|
46
|
+
_decodeComponentSnapshot) {
|
|
47
|
+
this.max_length = max_length;
|
|
48
|
+
this.server_tick_interval = server_tick_interval;
|
|
49
|
+
this._decodeComponentSnapshot = _decodeComponentSnapshot;
|
|
50
|
+
// state contains the state the game is currently rendering.
|
|
51
|
+
this._state = new Map();
|
|
52
|
+
this._stateVersion = 0;
|
|
53
|
+
// first has the version of the first element in the bucket
|
|
54
|
+
// if first is undefined, then the bucket is empty
|
|
55
|
+
this._first = undefined;
|
|
56
|
+
// version indicates the last version received by the server
|
|
57
|
+
// that can be acknowledged
|
|
58
|
+
this.version = -1;
|
|
59
|
+
// tServ tracks the server time approximately
|
|
60
|
+
this._tServ = -1;
|
|
61
|
+
// lastTime contains the timestamp for the last pull() call and is used as
|
|
62
|
+
// the moving interpolation baseline when pull() is called before tServ.
|
|
63
|
+
this._lastTime = -1;
|
|
64
|
+
if (max_length < 2) {
|
|
65
|
+
throw new Error("minimum interpolation bucket length is 2");
|
|
66
|
+
}
|
|
67
|
+
this.bucket = Array(this.max_length).fill(undefined);
|
|
68
|
+
}
|
|
69
|
+
_updateState(sd) {
|
|
70
|
+
// apply diff to current state
|
|
71
|
+
sd.snapshots?.forEach((s) => {
|
|
72
|
+
this._state.set(s.cid, s);
|
|
73
|
+
});
|
|
74
|
+
sd.removed?.forEach((r) => {
|
|
75
|
+
const [eid, type] = cid_unpack(r);
|
|
76
|
+
if (type === ALL_COMPONENTS) {
|
|
77
|
+
this._state.forEach((_, cid) => {
|
|
78
|
+
if (cid_unpack(cid)[0] === eid) {
|
|
79
|
+
this._state.delete(cid);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this._state.delete(r);
|
|
85
|
+
});
|
|
86
|
+
this._stateVersion = sd.to;
|
|
87
|
+
}
|
|
88
|
+
// pop removes the first element of the bucket
|
|
89
|
+
// shifting all elements to the left.
|
|
90
|
+
_pop() {
|
|
91
|
+
for (let j = 0; j < this.bucket.length - 1; j++) {
|
|
92
|
+
this.bucket[j] = this.bucket[j + 1];
|
|
93
|
+
}
|
|
94
|
+
this.bucket[this.bucket.length - 1] = undefined;
|
|
95
|
+
}
|
|
96
|
+
// pull returns a constructed Diff from elements
|
|
97
|
+
// in the bucket + interpolation
|
|
98
|
+
pull(now) {
|
|
99
|
+
const next = this.bucket[0];
|
|
100
|
+
let sd = new Diff(this._stateVersion, this._stateVersion, undefined);
|
|
101
|
+
if (next === undefined) {
|
|
102
|
+
// there is nothing in the buffer, so return an empty diff
|
|
103
|
+
// since we are hitting an empty buffer, allow some extra time for it
|
|
104
|
+
// to replenish, by delaying the server time.
|
|
105
|
+
this._tServ = now + this.server_tick_interval * this.bucket.length;
|
|
106
|
+
this._first = undefined;
|
|
107
|
+
this._lastTime = now;
|
|
108
|
+
return sd; // return empty diff
|
|
109
|
+
}
|
|
110
|
+
if (this._tServ === -1) {
|
|
111
|
+
this._tServ = now;
|
|
112
|
+
}
|
|
113
|
+
// lerpStart is the timestamp of the currently visualized state.
|
|
114
|
+
let lerpStart = this._lastTime;
|
|
115
|
+
// The following loop will incorporate (merge) into the
|
|
116
|
+
// proposed diff (sd) as many snapshots from the bucket
|
|
117
|
+
// as it needs in order to catch up to server time, that is,
|
|
118
|
+
// if we are ahead of the server timestamp, merge
|
|
119
|
+
// snapshots until we are behind
|
|
120
|
+
// or have eaten the whole buffer.
|
|
121
|
+
for (let i = 0; i < this.bucket.length && now >= this._tServ; i++, this._tServ += this.server_tick_interval) {
|
|
122
|
+
// take snapshot on bucket[0] and merge it on to the result:
|
|
123
|
+
sd = merge(sd, this.bucket[0], false);
|
|
124
|
+
lerpStart = this._tServ;
|
|
125
|
+
this._pop(); //remove bucket[0] and shift contents to the left
|
|
126
|
+
}
|
|
127
|
+
// skip bucket items that are undefined. At the end of this
|
|
128
|
+
// loop either bucket[0] has a diff or the whole bucket is empty.
|
|
129
|
+
// we only alter tServ if something was actually in the bucket at all.
|
|
130
|
+
let tsDelta = 0;
|
|
131
|
+
for (let i = 0; i < this.bucket.length; i++) {
|
|
132
|
+
if (this.bucket[0]) {
|
|
133
|
+
this._tServ += tsDelta;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
this._pop();
|
|
137
|
+
tsDelta += this.server_tick_interval;
|
|
138
|
+
}
|
|
139
|
+
// At this point, if something is in the bucket, bucket[0] contains the
|
|
140
|
+
// next target. Position snapshots are blended into the returned diff so
|
|
141
|
+
// callers can render fake frames between server ticks.
|
|
142
|
+
const target = this.bucket[0];
|
|
143
|
+
if (target) {
|
|
144
|
+
this._interpolatePositions(sd, target, lerpStart, this._tServ, now);
|
|
145
|
+
this._first = target.to;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this._first = undefined;
|
|
149
|
+
}
|
|
150
|
+
// incorporate this diff into our visualization of the state prior
|
|
151
|
+
// to handing this diff out to the scene:
|
|
152
|
+
this._updateState(sd);
|
|
153
|
+
this._lastTime = now;
|
|
154
|
+
return sd;
|
|
155
|
+
}
|
|
156
|
+
// push takes diffs coming from the wire and incorporates them
|
|
157
|
+
// to the snapshot bucket in the right position:
|
|
158
|
+
push(diff) {
|
|
159
|
+
// in case of buffer empty or first diff, initialize everything:
|
|
160
|
+
if (this._first === undefined) {
|
|
161
|
+
this.bucket[0] = diff;
|
|
162
|
+
this._first = diff.to;
|
|
163
|
+
this.version = diff.to;
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
// servers should never send a diff we can't handle
|
|
167
|
+
// The below can only happen if the server is ignoring acks:
|
|
168
|
+
if (diff.from > this.version) {
|
|
169
|
+
throw new Error("protocol error");
|
|
170
|
+
}
|
|
171
|
+
// Locate the index position for this diff in the bucket based on the
|
|
172
|
+
// version of the first item in the bucket:
|
|
173
|
+
let index = diff.to - this._first;
|
|
174
|
+
// negative index means this information is too old:
|
|
175
|
+
if (index < 0) {
|
|
176
|
+
return; // too old. Discard
|
|
177
|
+
}
|
|
178
|
+
if (index >= this.bucket.length) {
|
|
179
|
+
// index falls out of the bucket, meaning
|
|
180
|
+
// there is old information in the bucket.
|
|
181
|
+
let d = index - (this.bucket.length - 1);
|
|
182
|
+
if (d >= this.bucket.length) {
|
|
183
|
+
// information in the bucket is extremely old
|
|
184
|
+
// we will merge everything on to bucket[0] + this diff
|
|
185
|
+
this._first = diff.to;
|
|
186
|
+
d = this.bucket.length;
|
|
187
|
+
index = 0;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// information was old, but it can be fixed by
|
|
191
|
+
// merging partially.
|
|
192
|
+
index = this.bucket.length - d;
|
|
193
|
+
}
|
|
194
|
+
// the following loop merges as much as needed to make
|
|
195
|
+
// space for the incoming diff.
|
|
196
|
+
for (let i = 0; i < d; i++) {
|
|
197
|
+
this.bucket[0] = merge(this.bucket[0], this.bucket[1]);
|
|
198
|
+
for (let j = 1; j < this.bucket.length - 1; j++) {
|
|
199
|
+
this.bucket[j] = this.bucket[j + 1];
|
|
200
|
+
}
|
|
201
|
+
this.bucket[this.bucket.length - 1] = undefined;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// merge the incoming diff with whatever is at the target
|
|
205
|
+
// index, normally undefined, but it could be a retransmit
|
|
206
|
+
// of the same frame.
|
|
207
|
+
this.bucket[index] = merge(this.bucket[index], diff);
|
|
208
|
+
// bucket[0] can never be undefined. If so, there is something wrong
|
|
209
|
+
// with the algorithm itself.
|
|
210
|
+
if (this.bucket[0] === undefined) {
|
|
211
|
+
throw new Error("bucket[0] is undefined");
|
|
212
|
+
}
|
|
213
|
+
this._first = this.bucket[0].to;
|
|
214
|
+
// setting `version` allows the session layer to ack this diff.
|
|
215
|
+
if (diff.to > this.version) {
|
|
216
|
+
this.version = diff.to;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
_decodePositionSnapshot(snapshot) {
|
|
220
|
+
if (!(snapshot.payload instanceof Uint8Array)) {
|
|
221
|
+
if (!isPosition(snapshot.payload)) {
|
|
222
|
+
throw new Error(`Component type ${POSITION_COMPONENT_TYPE} must satisfy IPosition`);
|
|
223
|
+
}
|
|
224
|
+
return snapshot.payload;
|
|
225
|
+
}
|
|
226
|
+
if (!this._decodeComponentSnapshot) {
|
|
227
|
+
throw new Error("Position interpolation requires a component snapshot decoder");
|
|
228
|
+
}
|
|
229
|
+
const component = this._decodeComponentSnapshot(snapshot);
|
|
230
|
+
if (!isPosition(component)) {
|
|
231
|
+
throw new Error(`Component type ${POSITION_COMPONENT_TYPE} must satisfy IPosition`);
|
|
232
|
+
}
|
|
233
|
+
return component;
|
|
234
|
+
}
|
|
235
|
+
_interpolatePositions(sd, target, start, end, now) {
|
|
236
|
+
target.snapshots.forEach((targetSnapshot) => {
|
|
237
|
+
if (targetSnapshot.type !== POSITION_COMPONENT_TYPE) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const sourceSnapshot = sd.smap.get(targetSnapshot.cid) ?? this._state.get(targetSnapshot.cid);
|
|
241
|
+
if (!sourceSnapshot) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const sourcePosition = this._decodePositionSnapshot(sourceSnapshot);
|
|
245
|
+
const targetPosition = this._decodePositionSnapshot(targetSnapshot);
|
|
246
|
+
const position = lerp(sourcePosition, targetPosition, start, end, now);
|
|
247
|
+
sd.smap.set(targetSnapshot.cid, new ComponentSnapshot(targetSnapshot.eid, POSITION_COMPONENT_TYPE, position));
|
|
248
|
+
});
|
|
249
|
+
sd.updateSnapshotsFromMap();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function isPosition(component) {
|
|
253
|
+
const candidate = component;
|
|
254
|
+
return typeof candidate.x === "number" && typeof candidate.y === "number";
|
|
255
|
+
}
|
|
256
|
+
function lerp(a, b, start, end, t) {
|
|
257
|
+
if (end === start) {
|
|
258
|
+
return b;
|
|
259
|
+
}
|
|
260
|
+
const d = end - start;
|
|
261
|
+
const position = new b.constructor();
|
|
262
|
+
position.x = a.x + ((b.x - a.x) / d) * (t - start);
|
|
263
|
+
position.y = a.y + ((b.y - a.y) / d) * (t - start);
|
|
264
|
+
return position;
|
|
265
|
+
}
|
|
266
|
+
// helper function to add items to a set
|
|
267
|
+
function addToSet(set, data) {
|
|
268
|
+
if (!data) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
for (const item of data) {
|
|
272
|
+
set.add(item);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
export function merge(a, b, check = true) {
|
|
276
|
+
if (!a) {
|
|
277
|
+
return b;
|
|
278
|
+
}
|
|
279
|
+
if (!b) {
|
|
280
|
+
return a;
|
|
281
|
+
}
|
|
282
|
+
if (check && (b.from || 0) > (a.to || 0)) {
|
|
283
|
+
// This is a protocol error.
|
|
284
|
+
// can only happen if server ignored our ACKs and
|
|
285
|
+
// incremented version counter on its own.
|
|
286
|
+
throw new Error("cannot merge snapshots");
|
|
287
|
+
}
|
|
288
|
+
const m = new Diff(a.from, b.to, undefined);
|
|
289
|
+
const removed = new Set();
|
|
290
|
+
addToSet(removed, a.removed);
|
|
291
|
+
addToSet(removed, b.removed);
|
|
292
|
+
const as = new Map(a.smap);
|
|
293
|
+
const bs = b.smap;
|
|
294
|
+
bs.forEach((s) => {
|
|
295
|
+
as.set(s.cid, s);
|
|
296
|
+
removed.delete(s.cid); // undelete re-added entities
|
|
297
|
+
});
|
|
298
|
+
removed.forEach((r) => as.delete(r));
|
|
299
|
+
if (removed.size) {
|
|
300
|
+
m.removed = [...removed];
|
|
301
|
+
}
|
|
302
|
+
m.smap = as;
|
|
303
|
+
return m;
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=interpolator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolator.js","sourceRoot":"","sources":["../../../src/interpolator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,IAAI,qBAAqB,EAE1C,QAAQ,EACR,UAAU,GAEX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAG7C,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAUlC,MAAM,OAAO,iBAAiB;IAM5B,YAAmB,GAAW,EAAE,IAAY,EAAE,OAAuC;QACnF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;CACF;AAED,MAAM,OAAO,IAAI;IAIf,YACS,IAAY,EACZ,EAAU,EACV,OAAkB;QAFlB,SAAI,GAAJ,IAAI,CAAQ;QACZ,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAW;QANpB,cAAS,GAAwB,EAAE,CAAC;IAOxC,CAAC;IAEJ,IAAW,IAAI;QACb,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;QACD,O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,CAAC;IACrD,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,OAA+B,CAAC,CAAC;IAErD,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC;IAClB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACf,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,6BAA6B;IACtD,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAErC,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC,CAAC,OAAO,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;IAC3B,CAAC;IACD,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IAEZ,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function worldPath(basePath: string | undefined, worldName: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world_path.js","sourceRoot":"","sources":["../../../src/world_path.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,QAAQ,GAAG,eAAe,EAAE,SAAiB;IACrE,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A component id packs an entity id and component type id into a uint32. */
|
|
2
|
+
export type CID = number;
|
|
3
|
+
/** Component type ids below this value can fit into packed wire component ids. */
|
|
4
|
+
export declare let LOCAL_COMPONENT_MIN: number;
|
|
5
|
+
/** Protocol removal marker for all components on an entity. */
|
|
6
|
+
export declare const ALL_COMPONENTS = 0;
|
|
7
|
+
/** Return the configured local component minimum after validating its alignment. */
|
|
8
|
+
export declare function getLocalComponentMin(): number;
|
|
9
|
+
/** Configure the local component type range before constructing networked worlds. */
|
|
10
|
+
export declare function setLocalComponentMin(value: number): void;
|
|
11
|
+
/** Pack an entity id and component type id into a uint32 component id. */
|
|
12
|
+
export declare function cid_pack(eid: number, type: number): CID;
|
|
13
|
+
/** Unpack a uint32 component id into [entity id, component type id]. */
|
|
14
|
+
export declare function cid_unpack(cid: CID): [eid: number, type: number];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** Component type ids below this value can fit into packed wire component ids. */
|
|
2
|
+
export let LOCAL_COMPONENT_MIN = 256;
|
|
3
|
+
/** Protocol removal marker for all components on an entity. */
|
|
4
|
+
export const ALL_COMPONENTS = 0;
|
|
5
|
+
let componentTypeMask = LOCAL_COMPONENT_MIN - 1;
|
|
6
|
+
let componentTypeShift = Math.log2(LOCAL_COMPONENT_MIN);
|
|
7
|
+
let MAX_ENTITY_ID = 2 ** (32 - componentTypeShift) - 1;
|
|
8
|
+
let MAX_COMPONENT_TYPE = componentTypeMask;
|
|
9
|
+
function validateLocalComponentMin(value) {
|
|
10
|
+
if (!isAlignedLocalComponentMin(value)) {
|
|
11
|
+
throw new Error("LOCAL_COMPONENT_MIN must be a power-of-two safe integer >= 2");
|
|
12
|
+
}
|
|
13
|
+
if (Math.log2(value) > 31) {
|
|
14
|
+
throw new Error("LOCAL_COMPONENT_MIN must reserve fewer than 32 component type bits");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isAlignedLocalComponentMin(value) {
|
|
18
|
+
return Number.isSafeInteger(value) && value >= 2 && (value & (value - 1)) === 0;
|
|
19
|
+
}
|
|
20
|
+
/** Return the configured local component minimum after validating its alignment. */
|
|
21
|
+
export function getLocalComponentMin() {
|
|
22
|
+
validateLocalComponentMin(LOCAL_COMPONENT_MIN);
|
|
23
|
+
return LOCAL_COMPONENT_MIN;
|
|
24
|
+
}
|
|
25
|
+
/** Configure the local component type range before constructing networked worlds. */
|
|
26
|
+
export function setLocalComponentMin(value) {
|
|
27
|
+
LOCAL_COMPONENT_MIN = value;
|
|
28
|
+
if (isAlignedLocalComponentMin(value)) {
|
|
29
|
+
getLocalComponentMin();
|
|
30
|
+
componentTypeMask = LOCAL_COMPONENT_MIN - 1;
|
|
31
|
+
componentTypeShift = Math.log2(LOCAL_COMPONENT_MIN);
|
|
32
|
+
MAX_ENTITY_ID = 2 ** (32 - componentTypeShift) - 1;
|
|
33
|
+
MAX_COMPONENT_TYPE = componentTypeMask;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Pack an entity id and component type id into a uint32 component id. */
|
|
37
|
+
export function cid_pack(eid, type) {
|
|
38
|
+
if (eid < 0) {
|
|
39
|
+
throw new Error(`cid_pack: entity id must be non-negative, got ${eid}`);
|
|
40
|
+
}
|
|
41
|
+
if (eid > MAX_ENTITY_ID) {
|
|
42
|
+
throw new Error(`cid_pack: entity id ${eid} exceeds maximum ${MAX_ENTITY_ID} for LOCAL_COMPONENT_MIN=${LOCAL_COMPONENT_MIN}. ` +
|
|
43
|
+
`Increase LOCAL_COMPONENT_MIN or use a smaller entity id.`);
|
|
44
|
+
}
|
|
45
|
+
if (type < 0) {
|
|
46
|
+
throw new Error(`cid_pack: type id must be non-negative, got ${type}`);
|
|
47
|
+
}
|
|
48
|
+
if (type > MAX_COMPONENT_TYPE) {
|
|
49
|
+
throw new Error(`cid_pack: type id ${type} exceeds maximum component type ${MAX_COMPONENT_TYPE}. ` +
|
|
50
|
+
`Ensure type id is less than LOCAL_COMPONENT_MIN=${LOCAL_COMPONENT_MIN}.`);
|
|
51
|
+
}
|
|
52
|
+
return ((eid << componentTypeShift) | (type & componentTypeMask)) >>> 0;
|
|
53
|
+
}
|
|
54
|
+
/** Unpack a uint32 component id into [entity id, component type id]. */
|
|
55
|
+
export function cid_unpack(cid) {
|
|
56
|
+
return [cid >>> componentTypeShift, cid & componentTypeMask];
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=cid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cid.js","sourceRoot":"","sources":["../../../../vecs-protocol/src/cid.ts"],"names":[],"mappings":"AAGA,kFAAkF;AAClF,MAAM,CAAC,IAAI,mBAAmB,GAAG,GAAG,CAAC;AAErC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC,IAAI,iBAAiB,GAAG,mBAAmB,GAAG,CAAC,CAAC;AAChD,IAAI,kBAAkB,GAAG,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;AACxD,IAAI,aAAa,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;AACvD,IAAI,kBAAkB,GAAG,iBAAiB,CAAC;AAE3C,SAAS,yBAAyB,CAAC,KAAa;IAC9C,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;AACH,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAa;IAC/C,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAClF,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,oBAAoB;IAClC,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;IAC/C,OAAO,mBAAmB,CAAC;AAC7B,CA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C,GAAG,KAAK,kBAAkB,EAAE,GAAG,GAAG,iBAAiB,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ALL_COMPONENTS, LOCAL_COMPONENT_MIN, cid_pack, cid_unpack, getLocalComponentMin, setLocalComponentMin, type CID, } from "./cid.js";
|
|
2
|
+
export { NetworkWorld, type NetworkWorldOptions, type RegisteredNetworkComponent, } from "./network_world.js";
|
|
3
|
+
export { Client2Server, ComponentSnapshot, EncodedSnapshot, Server2Client, StateDiff, type RemovedComponent, } from "./messages.js";
|
|
4
|
+
export { FIRST_USER_RPC_ID, RPC, RPC_RESPONSE_ID, RPC_TIMEOUT_ERROR, SessionRPC, type RPCHandler, } from "./rpc.js";
|
|
5
|
+
export type { ConnectionError, VecsSocket, VecsSocketEvents, VecsSocketListener, VecsSocketListenerEvents, } from "./transport.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ALL_COMPONENTS, LOCAL_COMPONENT_MIN, cid_pack, cid_unpack, getLocalComponentMin, setLocalComponentMin, } from "./cid.js";
|
|
2
|
+
export { NetworkWorld, } from "./network_world.js";
|
|
3
|
+
export { Client2Server, ComponentSnapshot, EncodedSnapshot, Server2Client, StateDiff, } from "./messages.js";
|
|
4
|
+
export { FIRST_USER_RPC_ID, RPC, RPC_RESPONSE_ID, RPC_TIMEOUT_ERROR, SessionRPC, } from "./rpc.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../vecs-protocol/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,UAAU,EACV,oBAAoB,EACpB,oBAAoB,GAErB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,SAAS,GAEV,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,iBAAiB,EACjB,GAAG,EACH,eAAe,EACf,iBAAiB,EACjB,UAAU,GAEX,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Decoder, Encoder, type IEncodable } from "@vworlds/vecs-wire";
|
|
2
|
+
import { RPC } from "./rpc.js";
|
|
3
|
+
export declare class ComponentSnapshot implements IEncodable {
|
|
4
|
+
eid: number;
|
|
5
|
+
type: number;
|
|
6
|
+
payload: Uint8Array;
|
|
7
|
+
constructor(values?: Partial<ComponentSnapshot>);
|
|
8
|
+
wireEncode(encoder: Encoder): void;
|
|
9
|
+
static wireDecode(decoder: Decoder): ComponentSnapshot;
|
|
10
|
+
}
|
|
11
|
+
export declare class EncodedSnapshot {
|
|
12
|
+
bytes: Uint8Array;
|
|
13
|
+
eid: number;
|
|
14
|
+
type: number;
|
|
15
|
+
constructor(bytes: Uint8Array, // contains an already-encoded ComponentSnapshot
|
|
16
|
+
eid?: number, type?: number);
|
|
17
|
+
}
|
|
18
|
+
export type RemovedComponent = [eid: number, type: number];
|
|
19
|
+
export declare class StateDiff implements IEncodable {
|
|
20
|
+
toFrame: number;
|
|
21
|
+
fromFrame: number;
|
|
22
|
+
snapshots: EncodedSnapshot[];
|
|
23
|
+
removed: RemovedComponent[];
|
|
24
|
+
constructor(values?: Partial<StateDiff>);
|
|
25
|
+
wireEncode(encoder: Encoder): void;
|
|
26
|
+
static wireDecode(decoder: Decoder): StateDiff;
|
|
27
|
+
}
|
|
28
|
+
export declare class Server2Client implements IEncodable {
|
|
29
|
+
diff: StateDiff | undefined;
|
|
30
|
+
rpc: RPC[];
|
|
31
|
+
constructor(values?: Partial<Server2Client>);
|
|
32
|
+
wireEncode(encoder: Encoder): void;
|
|
33
|
+
static wireDecode(decoder: Decoder): Server2Client;
|
|
34
|
+
}
|
|
35
|
+
export declare class Client2Server implements IEncodable {
|
|
36
|
+
ackFrame: number;
|
|
37
|
+
input: unknown | undefined;
|
|
38
|
+
rpc: RPC[];
|
|
39
|
+
constructor(values?: Partial<Client2Server>);
|
|
40
|
+
wireEncode(encoder: Encoder): void;
|
|
41
|
+
static wireDecode(decoder: Decoder): Client2Server;
|
|
42
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { cid_pack, cid_unpack } from "./cid.js";
|
|
2
|
+
import { RPC } from "./rpc.js";
|
|
3
|
+
const FIELD_DIFF = 1;
|
|
4
|
+
const FIELD_RPC = 2;
|
|
5
|
+
const FIELD_INPUT = 3;
|
|
6
|
+
export class ComponentSnapshot {
|
|
7
|
+
constructor(values) {
|
|
8
|
+
this.eid = 0;
|
|
9
|
+
this.type = 0;
|
|
10
|
+
this.payload = new Uint8Array();
|
|
11
|
+
if (values) {
|
|
12
|
+
Object.assign(this, values);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
wireEncode(encoder) {
|
|
16
|
+
encoder.write_u32(cid_pack(this.eid, this.type));
|
|
17
|
+
encoder.write_buffer(this.payload);
|
|
18
|
+
}
|
|
19
|
+
static wireDecode(decoder) {
|
|
20
|
+
const [eid, type] = cid_unpack(decoder.read_u32());
|
|
21
|
+
return new ComponentSnapshot({
|
|
22
|
+
eid,
|
|
23
|
+
type,
|
|
24
|
+
payload: decoder.read_bytes(),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class EncodedSnapshot {
|
|
29
|
+
constructor(bytes, // contains an already-encoded ComponentSnapshot
|
|
30
|
+
eid = 0, type = 0) {
|
|
31
|
+
this.bytes = bytes;
|
|
32
|
+
this.eid = eid;
|
|
33
|
+
this.type = type;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class StateDiff {
|
|
37
|
+
constructor(values) {
|
|
38
|
+
this.toFrame = 0;
|
|
39
|
+
this.fromFrame = 0;
|
|
40
|
+
this.snapshots = [];
|
|
41
|
+
this.removed = [];
|
|
42
|
+
if (values) {
|
|
43
|
+
Object.assign(this, values);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
wireEncode(encoder) {
|
|
47
|
+
encoder.write_u32(this.toFrame);
|
|
48
|
+
encoder.write_u32(this.fromFrame);
|
|
49
|
+
encoder.write_u32(this.snapshots.length);
|
|
50
|
+
this.snapshots.forEach((snapshot) => encoder.write_buffer(snapshot.bytes));
|
|
51
|
+
encoder.write_u32(this.removed.length);
|
|
52
|
+
this.removed.forEach(([eid, type]) => encoder.write_u32(cid_pack(eid, type)));
|
|
53
|
+
}
|
|
54
|
+
static wireDecode(decoder) {
|
|
55
|
+
const diff = new StateDiff({ toFrame: decoder.read_u32(), fromFrame: decoder.read_u32() });
|
|
56
|
+
const snapshotCount = decoder.read_u32();
|
|
57
|
+
for (let i = 0; i < snapshotCount; i++) {
|
|
58
|
+
diff.snapshots.push(new EncodedSnapshot(decoder.read_bytes()));
|
|
59
|
+
}
|
|
60
|
+
const removedCount = decoder.read_u32();
|
|
61
|
+
for (let i = 0; i < removedCount; i++) {
|
|
62
|
+
diff.removed.push(cid_unpack(decoder.read_u32()));
|
|
63
|
+
}
|
|
64
|
+
return diff;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class Server2Client {
|
|
68
|
+
constructor(values) {
|
|
69
|
+
this.rpc = [];
|
|
70
|
+
if (values) {
|
|
71
|
+
Object.assign(this, values);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
wireEncode(encoder) {
|
|
75
|
+
if (this.diff) {
|
|
76
|
+
encoder.write_u8(FIELD_DIFF);
|
|
77
|
+
encoder.write(this.diff);
|
|
78
|
+
}
|
|
79
|
+
if (this.rpc.length > 0) {
|
|
80
|
+
encoder.write_u8(FIELD_RPC);
|
|
81
|
+
encoder.write_u32(this.rpc.length);
|
|
82
|
+
this.rpc.forEach((rpc) => encoder.write(rpc));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
static wireDecode(decoder) {
|
|
86
|
+
const message = new Server2Client();
|
|
87
|
+
while (!decoder.EOF) {
|
|
88
|
+
const tag = decoder.read_u8();
|
|
89
|
+
switch (tag) {
|
|
90
|
+
case FIELD_DIFF:
|
|
91
|
+
message.diff = decoder.read(StateDiff);
|
|
92
|
+
break;
|
|
93
|
+
case FIELD_RPC: {
|
|
94
|
+
const count = decoder.read_u32();
|
|
95
|
+
for (let i = 0; i < count; i++) {
|
|
96
|
+
message.rpc.push(decoder.read(RPC));
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
default:
|
|
101
|
+
throw new Error(`Invalid Server2Client field tag ${tag}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return message;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export class Client2Server {
|
|
108
|
+
constructor(values) {
|
|
109
|
+
this.ackFrame = 0;
|
|
110
|
+
this.rpc = [];
|
|
111
|
+
if (values) {
|
|
112
|
+
Object.assign(this, values);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
wireEncode(encoder) {
|
|
116
|
+
encoder.write_u32(this.ackFrame);
|
|
117
|
+
if (this.input !== undefined) {
|
|
118
|
+
encoder.write_u8(FIELD_INPUT);
|
|
119
|
+
encoder.write_any(this.input);
|
|
120
|
+
}
|
|
121
|
+
if (this.rpc.length > 0) {
|
|
122
|
+
encoder.write_u8(FIELD_RPC);
|
|
123
|
+
encoder.write_u32(this.rpc.length);
|
|
124
|
+
this.rpc.forEach((rpc) => encoder.write(rpc));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
static wireDecode(decoder) {
|
|
128
|
+
const message = new Client2Server({ ackFrame: decoder.read_u32() });
|
|
129
|
+
while (!decoder.EOF) {
|
|
130
|
+
const tag = decoder.read_u8();
|
|
131
|
+
switch (tag) {
|
|
132
|
+
case FIELD_INPUT:
|
|
133
|
+
message.input = decoder.read_any();
|
|
134
|
+
break;
|
|
135
|
+
case FIELD_RPC: {
|
|
136
|
+
const count = decoder.read_u32();
|
|
137
|
+
for (let i = 0; i < count; i++) {
|
|
138
|
+
message.rpc.push(decoder.read(RPC));
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
default:
|
|
143
|
+
throw new Error(`Invalid Client2Server field tag ${tag}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return message;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../vecs-protocol/src/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,UAAU,GAAG,CAAC,CAAC;AACrB,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAM,OAAO,iBAAiB;IAK5B,YAAmB,MAAmC;QAJ/C,QAAG,GAAG,CAAC,CAAC;QACR,SAAI,GAAG,CAAC,CAAC;QACT,YAAO,GAAG,IAAI,UAAU,EAAE,CAAC;QAGhC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAEM,UAAU,CAAC,OAAgB;QAChC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,OAAgB;QACvC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnD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gBACR,CAAC;gBACD;oBACE,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,EAAE,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { World, type ComponentClass, type WorldOptions } from "@vworlds/vecs";
|
|
2
|
+
export interface RegisteredNetworkComponent {
|
|
3
|
+
Class: ComponentClass;
|
|
4
|
+
type: number;
|
|
5
|
+
}
|
|
6
|
+
export interface NetworkWorldOptions extends Omit<WorldOptions, "idPools"> {
|
|
7
|
+
networkComponents?: readonly ComponentClass[];
|
|
8
|
+
entityIdStart?: number;
|
|
9
|
+
localEntityIdStart?: number;
|
|
10
|
+
networkEntityReuseWaitFrames?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class NetworkWorld extends World {
|
|
13
|
+
readonly localComponentMin: number;
|
|
14
|
+
readonly networkComponents: readonly RegisteredNetworkComponent[];
|
|
15
|
+
private readonly _networkComponentsByType;
|
|
16
|
+
constructor(options?: NetworkWorldOptions);
|
|
17
|
+
getNetworkComponent(type: number): RegisteredNetworkComponent | undefined;
|
|
18
|
+
}
|