@esengine/network 9.0.0 → 10.0.0
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/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +227 -0
- package/dist/index.js.map +1 -1
- package/dist/sync/fixed/FixedClientPrediction.d.ts +245 -0
- package/dist/sync/fixed/FixedClientPrediction.d.ts.map +1 -0
- package/dist/sync/fixed/FixedSnapshotBuffer.d.ts +141 -0
- package/dist/sync/fixed/FixedSnapshotBuffer.d.ts.map +1 -0
- package/dist/sync/fixed/FixedTransformInterpolator.d.ts +90 -0
- package/dist/sync/fixed/FixedTransformInterpolator.d.ts.map +1 -0
- package/dist/sync/fixed/FixedTransformState.d.ts +145 -0
- package/dist/sync/fixed/FixedTransformState.d.ts.map +1 -0
- package/dist/sync/fixed/index.d.ts +12 -0
- package/dist/sync/fixed/index.d.ts.map +1 -0
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.d.ts.map +1 -1
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type { NetworkPredictionConfig, MovementInput, PredictedTransform, } from
|
|
|
25
25
|
export { NetworkAOISystem, createNetworkAOISystem, } from './systems/NetworkAOISystem';
|
|
26
26
|
export type { NetworkAOIConfig, NetworkAOIEvent, NetworkAOIEventType, NetworkAOIEventListener, } from './systems/NetworkAOISystem';
|
|
27
27
|
export type { IStateSnapshot, ITransformState, ITransformStateWithVelocity, ISnapshotBufferConfig, ISnapshotBuffer, } from './sync';
|
|
28
|
-
export type { IInterpolator, IExtrapolator, IInputSnapshot, IPredictedState, IPredictor, ClientPredictionConfig, EntityDeltaState, DeltaSyncData, DeltaCompressionConfig, ComponentSyncEventType, ComponentSyncEvent, ComponentSyncEventListener, ComponentSyncConfig, } from './sync';
|
|
29
|
-
export { lerp, lerpAngle, smoothDamp, SnapshotBuffer, createSnapshotBuffer, TransformInterpolator, HermiteTransformInterpolator, createTransformInterpolator, createHermiteTransformInterpolator, ClientPrediction, createClientPrediction, DeltaFlags, StateDeltaCompressor, createStateDeltaCompressor, ComponentSyncSystem, createComponentSyncSystem, } from './sync';
|
|
28
|
+
export type { IInterpolator, IExtrapolator, IInputSnapshot, IPredictedState, IPredictor, ClientPredictionConfig, EntityDeltaState, DeltaSyncData, DeltaCompressionConfig, ComponentSyncEventType, ComponentSyncEvent, ComponentSyncEventListener, ComponentSyncConfig, IFixedTransformStateRaw, IFixedTransformStateWithVelocityRaw, IFixedInterpolator, IFixedExtrapolator, } from './sync';
|
|
29
|
+
export { lerp, lerpAngle, smoothDamp, SnapshotBuffer, createSnapshotBuffer, TransformInterpolator, HermiteTransformInterpolator, createTransformInterpolator, createHermiteTransformInterpolator, ClientPrediction, createClientPrediction, DeltaFlags, StateDeltaCompressor, createStateDeltaCompressor, ComponentSyncSystem, createComponentSyncSystem, FixedTransformState, FixedTransformStateWithVelocity, createZeroFixedTransformState, createZeroFixedTransformStateWithVelocity, FixedTransformInterpolator, FixedHermiteTransformInterpolator, createFixedTransformInterpolator, createFixedHermiteTransformInterpolator, } from './sync';
|
|
30
30
|
export { IsLocalPlayerTemplate, IsServerTemplate, HasAuthorityTemplate, GetNetworkIdTemplate, GetLocalPlayerIdTemplate, IsLocalPlayerExecutor, IsServerExecutor, HasAuthorityExecutor, GetNetworkIdExecutor, GetLocalPlayerIdExecutor, NetworkNodeDefinitions, } from './nodes';
|
|
31
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,YAAY,EACR,WAAW,EACX,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ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OAAO,EACH,gBAAgB,EAChB,sBAAsB,GACzB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EACR,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,uBAAuB,GAC1B,MAAM,4BAA4B,CAAA;AAMnC,YAAY,EACR,cAAc,EACd,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,EACrB,eAAe,GAClB,MAAM,QAAQ,CAAA;AAEf,YAAY,EACR,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,UAAU,EACV,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EAEtB,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACnC,YAAY,EACR,WAAW,EACX,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,GACX,MAAM,eAAe,CAAA;AAMtB,OAAO,EACH,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACzB,MAAM,YAAY,CAAA;AAMnB,OAAO,EACH,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,qBAAqB,GACxB,MAAM,UAAU,CAAA;AAMjB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAM/C,OAAO,EACH,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,oBAAoB,GACvB,MAAM,2BAA2B,C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SAAS,EACT,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC3B,kCAAkC,EAClC,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,EACV,oBAAoB,EACpB,0BAA0B,EAE1B,mBAAmB,EACnB,yBAAyB,EAEzB,mBAAmB,EACnB,+BAA+B,EAC/B,6BAA6B,EAC7B,yCAAyC,EACzC,0BAA0B,EAC1B,iCAAiC,EACjC,gCAAgC,EAChC,uCAAuC,GAC1C,MAAM,QAAQ,CAAA;AAMf,OAAO,EACH,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,sBAAsB,GACzB,MAAM,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1307,6 +1307,225 @@ function createComponentSyncSystem(config, isServer = false) {
|
|
|
1307
1307
|
}
|
|
1308
1308
|
__name(createComponentSyncSystem, "createComponentSyncSystem");
|
|
1309
1309
|
|
|
1310
|
+
// src/sync/fixed/FixedTransformState.ts
|
|
1311
|
+
import { Fixed32, FixedVector2 } from "@esengine/ecs-framework-math";
|
|
1312
|
+
var _FixedTransformState = class _FixedTransformState {
|
|
1313
|
+
constructor(position, rotation) {
|
|
1314
|
+
__publicField(this, "position");
|
|
1315
|
+
__publicField(this, "rotation");
|
|
1316
|
+
this.position = position;
|
|
1317
|
+
this.rotation = rotation;
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* @zh 从原始值创建
|
|
1321
|
+
* @en Create from raw values
|
|
1322
|
+
*/
|
|
1323
|
+
static fromRaw(raw) {
|
|
1324
|
+
return new _FixedTransformState(FixedVector2.fromRaw(raw.x, raw.y), Fixed32.fromRaw(raw.rotation));
|
|
1325
|
+
}
|
|
1326
|
+
/**
|
|
1327
|
+
* @zh 从浮点数创建
|
|
1328
|
+
* @en Create from floating-point numbers
|
|
1329
|
+
*/
|
|
1330
|
+
static from(x, y, rotation) {
|
|
1331
|
+
return new _FixedTransformState(FixedVector2.from(x, y), Fixed32.from(rotation));
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* @zh 转换为原始值(用于网络传输)
|
|
1335
|
+
* @en Convert to raw values (for network transmission)
|
|
1336
|
+
*/
|
|
1337
|
+
toRaw() {
|
|
1338
|
+
return {
|
|
1339
|
+
x: this.position.x.toRaw(),
|
|
1340
|
+
y: this.position.y.toRaw(),
|
|
1341
|
+
rotation: this.rotation.toRaw()
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* @zh 转换为浮点数对象(用于渲染)
|
|
1346
|
+
* @en Convert to floating-point object (for rendering)
|
|
1347
|
+
*/
|
|
1348
|
+
toFloat() {
|
|
1349
|
+
return {
|
|
1350
|
+
x: this.position.x.toNumber(),
|
|
1351
|
+
y: this.position.y.toNumber(),
|
|
1352
|
+
rotation: this.rotation.toNumber()
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* @zh 检查是否相等
|
|
1357
|
+
* @en Check equality
|
|
1358
|
+
*/
|
|
1359
|
+
equals(other) {
|
|
1360
|
+
return this.position.equals(other.position) && this.rotation.eq(other.rotation);
|
|
1361
|
+
}
|
|
1362
|
+
};
|
|
1363
|
+
__name(_FixedTransformState, "FixedTransformState");
|
|
1364
|
+
var FixedTransformState = _FixedTransformState;
|
|
1365
|
+
var _FixedTransformStateWithVelocity = class _FixedTransformStateWithVelocity {
|
|
1366
|
+
constructor(position, rotation, velocity, angularVelocity) {
|
|
1367
|
+
__publicField(this, "position");
|
|
1368
|
+
__publicField(this, "rotation");
|
|
1369
|
+
__publicField(this, "velocity");
|
|
1370
|
+
__publicField(this, "angularVelocity");
|
|
1371
|
+
this.position = position;
|
|
1372
|
+
this.rotation = rotation;
|
|
1373
|
+
this.velocity = velocity;
|
|
1374
|
+
this.angularVelocity = angularVelocity;
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* @zh 从原始值创建
|
|
1378
|
+
* @en Create from raw values
|
|
1379
|
+
*/
|
|
1380
|
+
static fromRaw(raw) {
|
|
1381
|
+
return new _FixedTransformStateWithVelocity(FixedVector2.fromRaw(raw.x, raw.y), Fixed32.fromRaw(raw.rotation), FixedVector2.fromRaw(raw.velocityX, raw.velocityY), Fixed32.fromRaw(raw.angularVelocity));
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* @zh 从浮点数创建
|
|
1385
|
+
* @en Create from floating-point numbers
|
|
1386
|
+
*/
|
|
1387
|
+
static from(x, y, rotation, velocityX, velocityY, angularVelocity) {
|
|
1388
|
+
return new _FixedTransformStateWithVelocity(FixedVector2.from(x, y), Fixed32.from(rotation), FixedVector2.from(velocityX, velocityY), Fixed32.from(angularVelocity));
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* @zh 转换为原始值
|
|
1392
|
+
* @en Convert to raw values
|
|
1393
|
+
*/
|
|
1394
|
+
toRaw() {
|
|
1395
|
+
return {
|
|
1396
|
+
x: this.position.x.toRaw(),
|
|
1397
|
+
y: this.position.y.toRaw(),
|
|
1398
|
+
rotation: this.rotation.toRaw(),
|
|
1399
|
+
velocityX: this.velocity.x.toRaw(),
|
|
1400
|
+
velocityY: this.velocity.y.toRaw(),
|
|
1401
|
+
angularVelocity: this.angularVelocity.toRaw()
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* @zh 转换为浮点数对象
|
|
1406
|
+
* @en Convert to floating-point object
|
|
1407
|
+
*/
|
|
1408
|
+
toFloat() {
|
|
1409
|
+
return {
|
|
1410
|
+
x: this.position.x.toNumber(),
|
|
1411
|
+
y: this.position.y.toNumber(),
|
|
1412
|
+
rotation: this.rotation.toNumber(),
|
|
1413
|
+
velocityX: this.velocity.x.toNumber(),
|
|
1414
|
+
velocityY: this.velocity.y.toNumber(),
|
|
1415
|
+
angularVelocity: this.angularVelocity.toNumber()
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* @zh 检查是否相等
|
|
1420
|
+
* @en Check equality
|
|
1421
|
+
*/
|
|
1422
|
+
equals(other) {
|
|
1423
|
+
return this.position.equals(other.position) && this.rotation.eq(other.rotation) && this.velocity.equals(other.velocity) && this.angularVelocity.eq(other.angularVelocity);
|
|
1424
|
+
}
|
|
1425
|
+
};
|
|
1426
|
+
__name(_FixedTransformStateWithVelocity, "FixedTransformStateWithVelocity");
|
|
1427
|
+
var FixedTransformStateWithVelocity = _FixedTransformStateWithVelocity;
|
|
1428
|
+
function createZeroFixedTransformState() {
|
|
1429
|
+
return new FixedTransformState(FixedVector2.ZERO, Fixed32.ZERO);
|
|
1430
|
+
}
|
|
1431
|
+
__name(createZeroFixedTransformState, "createZeroFixedTransformState");
|
|
1432
|
+
function createZeroFixedTransformStateWithVelocity() {
|
|
1433
|
+
return new FixedTransformStateWithVelocity(FixedVector2.ZERO, Fixed32.ZERO, FixedVector2.ZERO, Fixed32.ZERO);
|
|
1434
|
+
}
|
|
1435
|
+
__name(createZeroFixedTransformStateWithVelocity, "createZeroFixedTransformStateWithVelocity");
|
|
1436
|
+
|
|
1437
|
+
// src/sync/fixed/FixedTransformInterpolator.ts
|
|
1438
|
+
import { Fixed32 as Fixed322, FixedVector2 as FixedVector22, FixedMath } from "@esengine/ecs-framework-math";
|
|
1439
|
+
var _FixedTransformInterpolator = class _FixedTransformInterpolator {
|
|
1440
|
+
/**
|
|
1441
|
+
* @zh 在两个变换状态之间插值
|
|
1442
|
+
* @en Interpolate between two transform states
|
|
1443
|
+
*/
|
|
1444
|
+
interpolate(from, to, t) {
|
|
1445
|
+
return new FixedTransformState(from.position.lerp(to.position, t), FixedMath.lerpAngle(from.rotation, to.rotation, t));
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* @zh 基于速度外推变换状态
|
|
1449
|
+
* @en Extrapolate transform state based on velocity
|
|
1450
|
+
*/
|
|
1451
|
+
extrapolate(state, deltaTime) {
|
|
1452
|
+
return new FixedTransformStateWithVelocity(state.position.add(state.velocity.mul(deltaTime)), state.rotation.add(state.angularVelocity.mul(deltaTime)), state.velocity, state.angularVelocity);
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* @zh 使用原始值进行插值
|
|
1456
|
+
* @en Interpolate using raw values
|
|
1457
|
+
*/
|
|
1458
|
+
interpolateRaw(from, to, t) {
|
|
1459
|
+
const fromState = FixedTransformState.fromRaw(from);
|
|
1460
|
+
const toState = FixedTransformState.fromRaw(to);
|
|
1461
|
+
const tFixed = Fixed322.from(t);
|
|
1462
|
+
return this.interpolate(fromState, toState, tFixed).toRaw();
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* @zh 使用原始值进行外推
|
|
1466
|
+
* @en Extrapolate using raw values
|
|
1467
|
+
*/
|
|
1468
|
+
extrapolateRaw(state, deltaTimeMs) {
|
|
1469
|
+
const fixedState = FixedTransformStateWithVelocity.fromRaw(state);
|
|
1470
|
+
const deltaTime = Fixed322.from(deltaTimeMs / 1e3);
|
|
1471
|
+
return this.extrapolate(fixedState, deltaTime).toRaw();
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
__name(_FixedTransformInterpolator, "FixedTransformInterpolator");
|
|
1475
|
+
var FixedTransformInterpolator = _FixedTransformInterpolator;
|
|
1476
|
+
var _FixedHermiteTransformInterpolator = class _FixedHermiteTransformInterpolator {
|
|
1477
|
+
constructor(snapshotIntervalMs = 100) {
|
|
1478
|
+
/**
|
|
1479
|
+
* @zh 快照间隔时间(秒)
|
|
1480
|
+
* @en Snapshot interval in seconds
|
|
1481
|
+
*/
|
|
1482
|
+
__publicField(this, "snapshotInterval");
|
|
1483
|
+
this.snapshotInterval = Fixed322.from(snapshotIntervalMs / 1e3);
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* @zh 使用赫尔米特插值
|
|
1487
|
+
* @en Use Hermite interpolation
|
|
1488
|
+
*/
|
|
1489
|
+
interpolate(from, to, t) {
|
|
1490
|
+
const t2 = t.mul(t);
|
|
1491
|
+
const t3 = t2.mul(t);
|
|
1492
|
+
const two = Fixed322.from(2);
|
|
1493
|
+
const three = Fixed322.from(3);
|
|
1494
|
+
const six = Fixed322.from(6);
|
|
1495
|
+
const four = Fixed322.from(4);
|
|
1496
|
+
const h00 = two.mul(t3).sub(three.mul(t2)).add(Fixed322.ONE);
|
|
1497
|
+
const h10 = t3.sub(two.mul(t2)).add(t);
|
|
1498
|
+
const h01 = two.neg().mul(t3).add(three.mul(t2));
|
|
1499
|
+
const h11 = t3.sub(t2);
|
|
1500
|
+
const dt = this.snapshotInterval;
|
|
1501
|
+
const x = h00.mul(from.position.x).add(h10.mul(from.velocity.x).mul(dt)).add(h01.mul(to.position.x)).add(h11.mul(to.velocity.x).mul(dt));
|
|
1502
|
+
const y = h00.mul(from.position.y).add(h10.mul(from.velocity.y).mul(dt)).add(h01.mul(to.position.y)).add(h11.mul(to.velocity.y).mul(dt));
|
|
1503
|
+
const dh00 = six.mul(t2).sub(six.mul(t));
|
|
1504
|
+
const dh10 = three.mul(t2).sub(four.mul(t)).add(Fixed322.ONE);
|
|
1505
|
+
const dh01 = six.neg().mul(t2).add(six.mul(t));
|
|
1506
|
+
const dh11 = three.mul(t2).sub(two.mul(t));
|
|
1507
|
+
const velocityX = dh00.mul(from.position.x).add(dh10.mul(from.velocity.x).mul(dt)).add(dh01.mul(to.position.x)).add(dh11.mul(to.velocity.x).mul(dt)).div(dt);
|
|
1508
|
+
const velocityY = dh00.mul(from.position.y).add(dh10.mul(from.velocity.y).mul(dt)).add(dh01.mul(to.position.y)).add(dh11.mul(to.velocity.y).mul(dt)).div(dt);
|
|
1509
|
+
return new FixedTransformStateWithVelocity(new FixedVector22(x, y), FixedMath.lerpAngle(from.rotation, to.rotation, t), new FixedVector22(velocityX, velocityY), Fixed322.lerp(from.angularVelocity, to.angularVelocity, t));
|
|
1510
|
+
}
|
|
1511
|
+
};
|
|
1512
|
+
__name(_FixedHermiteTransformInterpolator, "FixedHermiteTransformInterpolator");
|
|
1513
|
+
var FixedHermiteTransformInterpolator = _FixedHermiteTransformInterpolator;
|
|
1514
|
+
function createFixedTransformInterpolator() {
|
|
1515
|
+
return new FixedTransformInterpolator();
|
|
1516
|
+
}
|
|
1517
|
+
__name(createFixedTransformInterpolator, "createFixedTransformInterpolator");
|
|
1518
|
+
function createFixedHermiteTransformInterpolator(snapshotIntervalMs) {
|
|
1519
|
+
return new FixedHermiteTransformInterpolator(snapshotIntervalMs);
|
|
1520
|
+
}
|
|
1521
|
+
__name(createFixedHermiteTransformInterpolator, "createFixedHermiteTransformInterpolator");
|
|
1522
|
+
|
|
1523
|
+
// src/sync/fixed/FixedSnapshotBuffer.ts
|
|
1524
|
+
import { Fixed32 as Fixed323 } from "@esengine/ecs-framework-math";
|
|
1525
|
+
|
|
1526
|
+
// src/sync/fixed/FixedClientPrediction.ts
|
|
1527
|
+
import { Fixed32 as Fixed324, FixedVector2 as FixedVector23 } from "@esengine/ecs-framework-math";
|
|
1528
|
+
|
|
1310
1529
|
// src/systems/NetworkSyncSystem.ts
|
|
1311
1530
|
var DEFAULT_CONFIG3 = {
|
|
1312
1531
|
bufferSize: 30,
|
|
@@ -2957,6 +3176,10 @@ export {
|
|
|
2957
3176
|
ClientPrediction,
|
|
2958
3177
|
ComponentSyncSystem,
|
|
2959
3178
|
DeltaFlags,
|
|
3179
|
+
FixedHermiteTransformInterpolator,
|
|
3180
|
+
FixedTransformInterpolator,
|
|
3181
|
+
FixedTransformState,
|
|
3182
|
+
FixedTransformStateWithVelocity,
|
|
2960
3183
|
GameNetworkService,
|
|
2961
3184
|
GetLocalPlayerIdExecutor,
|
|
2962
3185
|
GetLocalPlayerIdTemplate,
|
|
@@ -2992,6 +3215,8 @@ export {
|
|
|
2992
3215
|
TransformInterpolator,
|
|
2993
3216
|
createClientPrediction,
|
|
2994
3217
|
createComponentSyncSystem,
|
|
3218
|
+
createFixedHermiteTransformInterpolator,
|
|
3219
|
+
createFixedTransformInterpolator,
|
|
2995
3220
|
createHermiteTransformInterpolator,
|
|
2996
3221
|
createNetworkAOISystem,
|
|
2997
3222
|
createNetworkInputSystem,
|
|
@@ -3000,6 +3225,8 @@ export {
|
|
|
3000
3225
|
createSnapshotBuffer,
|
|
3001
3226
|
createStateDeltaCompressor,
|
|
3002
3227
|
createTransformInterpolator,
|
|
3228
|
+
createZeroFixedTransformState,
|
|
3229
|
+
createZeroFixedTransformStateWithVelocity,
|
|
3003
3230
|
gameProtocol,
|
|
3004
3231
|
lerp,
|
|
3005
3232
|
lerpAngle,
|