@woosh/meep-engine 2.138.0 → 2.138.1
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/build/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/package.json +1 -1
- package/src/core/assert.d.ts +6 -0
- package/src/core/assert.d.ts.map +1 -1
- package/src/core/assert.js +16 -3
- package/src/core/binary/half_to_float_uint16.js +1 -1
- package/src/core/binary/to_half_float_uint16.d.ts.map +1 -1
- package/src/core/binary/to_half_float_uint16.js +9 -4
- package/src/core/collection/table/RowFirstTableSpec.js +1 -1
- package/src/core/events/signal/Signal.d.ts.map +1 -1
- package/src/core/events/signal/Signal.js +53 -0
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts +3 -3
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.js +3 -3
- package/src/engine/Clock.d.ts +2 -2
- package/src/engine/Clock.js +2 -2
- package/src/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/highlight/system/RenderableHighlightSystem.js +17 -29
- package/src/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.js +18 -31
- package/src/engine/network/NetworkSession.d.ts +386 -0
- package/src/engine/network/NetworkSession.d.ts.map +1 -0
- package/src/engine/network/NetworkSession.js +1841 -0
- package/src/engine/network/PriorityFetch.d.ts.map +1 -1
- package/src/engine/network/PriorityFetch.js +3 -2
- package/src/engine/network/adapters/QuaternionInterpolationAdapter.d.ts +14 -0
- package/src/engine/network/adapters/QuaternionInterpolationAdapter.d.ts.map +1 -0
- package/src/engine/network/adapters/QuaternionInterpolationAdapter.js +44 -0
- package/src/engine/network/adapters/TransformInterpolationAdapter.d.ts +18 -0
- package/src/engine/network/adapters/TransformInterpolationAdapter.d.ts.map +1 -0
- package/src/engine/network/adapters/TransformInterpolationAdapter.js +79 -0
- package/src/engine/network/adapters/TransformReplicationAdapter.d.ts +37 -0
- package/src/engine/network/adapters/TransformReplicationAdapter.d.ts.map +1 -0
- package/src/engine/network/adapters/TransformReplicationAdapter.js +87 -0
- package/src/engine/network/adapters/Vector3InterpolationAdapter.d.ts +18 -0
- package/src/engine/network/adapters/Vector3InterpolationAdapter.d.ts.map +1 -0
- package/src/engine/network/adapters/Vector3InterpolationAdapter.js +46 -0
- package/src/engine/network/convertPathToURL.js +107 -107
- package/src/engine/network/core/quantize/quantize_float.d.ts +54 -0
- package/src/engine/network/core/quantize/quantize_float.d.ts.map +1 -0
- package/src/engine/network/core/quantize/quantize_float.js +66 -0
- package/src/engine/network/core/quantize/quantize_position.d.ts +44 -0
- package/src/engine/network/core/quantize/quantize_position.d.ts.map +1 -0
- package/src/engine/network/core/quantize/quantize_position.js +54 -0
- package/src/engine/network/core/sequence/ack_bitfield.d.ts +47 -0
- package/src/engine/network/core/sequence/ack_bitfield.d.ts.map +1 -0
- package/src/engine/network/core/sequence/ack_bitfield.js +77 -0
- package/src/engine/network/core/sequence/seq16.d.ts +53 -0
- package/src/engine/network/core/sequence/seq16.d.ts.map +1 -0
- package/src/engine/network/core/sequence/seq16.js +69 -0
- package/src/engine/network/core/sequence/seq32.d.ts +55 -0
- package/src/engine/network/core/sequence/seq32.d.ts.map +1 -0
- package/src/engine/network/core/sequence/seq32.js +73 -0
- package/src/engine/network/diagnostics/BandwidthMeter.d.ts +76 -0
- package/src/engine/network/diagnostics/BandwidthMeter.d.ts.map +1 -0
- package/src/engine/network/diagnostics/BandwidthMeter.js +155 -0
- package/src/engine/network/diagnostics/ReplayLog.d.ts +74 -0
- package/src/engine/network/diagnostics/ReplayLog.d.ts.map +1 -0
- package/src/engine/network/diagnostics/ReplayLog.js +137 -0
- package/src/engine/network/diagnostics/SyncTest.d.ts +74 -0
- package/src/engine/network/diagnostics/SyncTest.d.ts.map +1 -0
- package/src/engine/network/diagnostics/SyncTest.js +151 -0
- package/src/engine/network/ecs/NetworkSystem.d.ts +57 -0
- package/src/engine/network/ecs/NetworkSystem.d.ts.map +1 -0
- package/src/engine/network/ecs/NetworkSystem.js +84 -0
- package/src/engine/network/ecs/components/NetworkIdentity.d.ts +58 -0
- package/src/engine/network/ecs/components/NetworkIdentity.d.ts.map +1 -0
- package/src/engine/network/ecs/components/NetworkIdentity.js +73 -0
- package/src/engine/network/ecs/serialization/NetworkIdentitySerializationAdapter.d.ts +40 -0
- package/src/engine/network/ecs/serialization/NetworkIdentitySerializationAdapter.d.ts.map +1 -0
- package/src/engine/network/ecs/serialization/NetworkIdentitySerializationAdapter.js +64 -0
- package/src/engine/network/orchestrator/NetworkPeer.d.ts +389 -0
- package/src/engine/network/orchestrator/NetworkPeer.d.ts.map +1 -0
- package/src/engine/network/orchestrator/NetworkPeer.js +1107 -0
- package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts +260 -0
- package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts.map +1 -0
- package/src/engine/network/orchestrator/ServerAuthoritativeClient.js +425 -0
- package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts +217 -0
- package/src/engine/network/orchestrator/ServerAuthoritativeServer.d.ts.map +1 -0
- package/src/engine/network/orchestrator/ServerAuthoritativeServer.js +562 -0
- package/src/engine/network/replication/Replicator.d.ts +134 -0
- package/src/engine/network/replication/Replicator.d.ts.map +1 -0
- package/src/engine/network/replication/Replicator.js +334 -0
- package/src/engine/network/replication/ScopeFilter.d.ts +64 -0
- package/src/engine/network/replication/ScopeFilter.d.ts.map +1 -0
- package/src/engine/network/replication/ScopeFilter.js +71 -0
- package/src/engine/network/sim/ActionLog.d.ts +94 -0
- package/src/engine/network/sim/ActionLog.d.ts.map +1 -0
- package/src/engine/network/sim/ActionLog.js +189 -0
- package/src/engine/network/sim/BinaryInterpolationAdapter.d.ts +58 -0
- package/src/engine/network/sim/BinaryInterpolationAdapter.d.ts.map +1 -0
- package/src/engine/network/sim/BinaryInterpolationAdapter.js +56 -0
- package/src/engine/network/sim/InterpolationLog.d.ts +165 -0
- package/src/engine/network/sim/InterpolationLog.d.ts.map +1 -0
- package/src/engine/network/sim/InterpolationLog.js +583 -0
- package/src/engine/network/sim/ReplicatedComponentRegistry.d.ts +59 -0
- package/src/engine/network/sim/ReplicatedComponentRegistry.d.ts.map +1 -0
- package/src/engine/network/sim/ReplicatedComponentRegistry.js +140 -0
- package/src/engine/network/sim/RewindEngine.d.ts +66 -0
- package/src/engine/network/sim/RewindEngine.d.ts.map +1 -0
- package/src/engine/network/sim/RewindEngine.js +182 -0
- package/src/engine/network/sim/SimAction.d.ts +133 -0
- package/src/engine/network/sim/SimAction.d.ts.map +1 -0
- package/src/engine/network/sim/SimAction.js +273 -0
- package/src/engine/network/sim/SimActionExecutor.d.ts +109 -0
- package/src/engine/network/sim/SimActionExecutor.d.ts.map +1 -0
- package/src/engine/network/sim/SimActionExecutor.js +238 -0
- package/src/engine/network/sim/SimActionRegistry.d.ts +60 -0
- package/src/engine/network/sim/SimActionRegistry.d.ts.map +1 -0
- package/src/engine/network/sim/SimActionRegistry.js +128 -0
- package/src/engine/network/sim/SmoothingState.d.ts +87 -0
- package/src/engine/network/sim/SmoothingState.d.ts.map +1 -0
- package/src/engine/network/sim/SmoothingState.js +223 -0
- package/src/engine/network/sim/Snapshotter.d.ts +98 -0
- package/src/engine/network/sim/Snapshotter.d.ts.map +1 -0
- package/src/engine/network/sim/Snapshotter.js +206 -0
- package/src/engine/network/sim/SpeculationLog.d.ts +53 -0
- package/src/engine/network/sim/SpeculationLog.d.ts.map +1 -0
- package/src/engine/network/sim/SpeculationLog.js +84 -0
- package/src/engine/network/state/Baseline.d.ts +48 -0
- package/src/engine/network/state/Baseline.d.ts.map +1 -0
- package/src/engine/network/state/Baseline.js +83 -0
- package/src/engine/network/state/ChangedEntitySet.d.ts +94 -0
- package/src/engine/network/state/ChangedEntitySet.d.ts.map +1 -0
- package/src/engine/network/state/ChangedEntitySet.js +256 -0
- package/src/engine/network/state/InputRing.d.ts +90 -0
- package/src/engine/network/state/InputRing.d.ts.map +1 -0
- package/src/engine/network/state/InputRing.js +173 -0
- package/src/engine/network/state/MutationLedger.d.ts +82 -0
- package/src/engine/network/state/MutationLedger.d.ts.map +1 -0
- package/src/engine/network/state/MutationLedger.js +182 -0
- package/src/engine/network/state/PriorityAccumulator.d.ts +104 -0
- package/src/engine/network/state/PriorityAccumulator.d.ts.map +1 -0
- package/src/engine/network/state/PriorityAccumulator.js +180 -0
- package/src/engine/network/state/ReplicationSlotTable.d.ts +78 -0
- package/src/engine/network/state/ReplicationSlotTable.d.ts.map +1 -0
- package/src/engine/network/state/ReplicationSlotTable.js +211 -0
- package/src/engine/network/time/AdaptiveRenderDelay.d.ts +128 -0
- package/src/engine/network/time/AdaptiveRenderDelay.d.ts.map +1 -0
- package/src/engine/network/time/AdaptiveRenderDelay.js +258 -0
- package/src/engine/network/time/JitterBuffer.d.ts +58 -0
- package/src/engine/network/time/JitterBuffer.d.ts.map +1 -0
- package/src/engine/network/time/JitterBuffer.js +116 -0
- package/src/engine/network/time/TimeDilation.d.ts +49 -0
- package/src/engine/network/time/TimeDilation.d.ts.map +1 -0
- package/src/engine/network/time/TimeDilation.js +62 -0
- package/src/engine/network/time/TimeSync.d.ts +68 -0
- package/src/engine/network/time/TimeSync.d.ts.map +1 -0
- package/src/engine/network/time/TimeSync.js +153 -0
- package/src/engine/network/transport/Channel.d.ts +74 -0
- package/src/engine/network/transport/Channel.d.ts.map +1 -0
- package/src/engine/network/transport/Channel.js +272 -0
- package/src/engine/network/transport/LoopbackTransport.d.ts +59 -0
- package/src/engine/network/transport/LoopbackTransport.d.ts.map +1 -0
- package/src/engine/network/transport/LoopbackTransport.js +194 -0
- package/src/engine/network/transport/ReliableCommandPipeline.d.ts +139 -0
- package/src/engine/network/transport/ReliableCommandPipeline.d.ts.map +1 -0
- package/src/engine/network/transport/ReliableCommandPipeline.js +291 -0
- package/src/engine/network/transport/Transport.d.ts +109 -0
- package/src/engine/network/transport/Transport.d.ts.map +1 -0
- package/src/engine/network/transport/Transport.js +119 -0
- package/src/engine/network/transport/adapters/NodeUDPTransport.d.ts +60 -0
- package/src/engine/network/transport/adapters/NodeUDPTransport.d.ts.map +1 -0
- package/src/engine/network/transport/adapters/NodeUDPTransport.js +206 -0
- package/src/engine/network/transport/adapters/SimulatedTransport.d.ts +110 -0
- package/src/engine/network/transport/adapters/SimulatedTransport.d.ts.map +1 -0
- package/src/engine/network/transport/adapters/SimulatedTransport.js +252 -0
- package/src/engine/network/transport/adapters/WebRTCDataChannelTransport.d.ts +33 -0
- package/src/engine/network/transport/adapters/WebRTCDataChannelTransport.d.ts.map +1 -0
- package/src/engine/network/transport/adapters/WebRTCDataChannelTransport.js +131 -0
- package/src/engine/network/transport/adapters/WebSocketTransport.d.ts +49 -0
- package/src/engine/network/transport/adapters/WebSocketTransport.d.ts.map +1 -0
- package/src/engine/network/transport/adapters/WebSocketTransport.js +180 -0
- package/src/engine/network/transport/adapters/WebTransportTransport.d.ts +73 -0
- package/src/engine/network/transport/adapters/WebTransportTransport.d.ts.map +1 -0
- package/src/engine/network/transport/adapters/WebTransportTransport.js +210 -0
- package/src/engine/network/transport/fragments/FragmentAssembler.d.ts +104 -0
- package/src/engine/network/transport/fragments/FragmentAssembler.d.ts.map +1 -0
- package/src/engine/network/transport/fragments/FragmentAssembler.js +291 -0
- package/src/engine/network/transport/fragments/FragmentRetention.d.ts +103 -0
- package/src/engine/network/transport/fragments/FragmentRetention.d.ts.map +1 -0
- package/src/engine/network/transport/fragments/FragmentRetention.js +194 -0
- package/src/engine/network/transport/fragments/fragment_send.d.ts +53 -0
- package/src/engine/network/transport/fragments/fragment_send.d.ts.map +1 -0
- package/src/engine/network/transport/fragments/fragment_send.js +147 -0
- package/src/engine/network/transport/fragments/packet_size.d.ts +93 -0
- package/src/engine/network/transport/fragments/packet_size.d.ts.map +1 -0
- package/src/engine/network/transport/fragments/packet_size.js +101 -0
- package/src/engine/network/xhr.js +23 -23
- package/src/engine/simulation/Ticker.d.ts +7 -0
- package/src/engine/simulation/Ticker.d.ts.map +1 -1
- package/src/engine/simulation/Ticker.js +15 -4
- package/src/engine/network/DataChannel.js +0 -1210
- package/src/engine/network/RemoteController.d.ts +0 -23
- package/src/engine/network/RemoteController.d.ts.map +0 -1
- package/src/engine/network/RemoteController.js +0 -114
- package/src/engine/network/remoteEditor.d.ts +0 -2
- package/src/engine/network/remoteEditor.d.ts.map +0 -1
- package/src/engine/network/remoteEditor.js +0 -142
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PriorityFetch.d.ts","sourceRoot":"","sources":["../../../../src/engine/network/PriorityFetch.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PriorityFetch.d.ts","sourceRoot":"","sources":["../../../../src/engine/network/PriorityFetch.js"],"names":[],"mappings":"AAgFA;;;GAGG;AACH;IACI;;;OA+BC;IA3BG;;;;OAIG;IACH,sBAAgC;IAEhC;;;;OAIG;IACH,gBAAiD;IAEjD;;;;OAIG;IACH,sBAA8B;IAE9B;;;;OAIG;IACH,kBAAwB;IAG5B;;;OAGG;IACH,2BAEC;IAED;;;OAGG;IACH,6BAMC;IAED;;;OAGG;IACH,0BAEC;IAED;;;;OAIG;IACH,mBAoBC;IAED,eAMC;IAED,iDAUC;CACJ;qBA9LoB,6BAA6B"}
|
|
@@ -26,9 +26,8 @@ function extract_priority_from_resource(p) {
|
|
|
26
26
|
|
|
27
27
|
if (v === undefined) {
|
|
28
28
|
console.warn(`Unsupported request priority value '${p}', defaulting to 'auto'`);
|
|
29
|
+
v = priority_value_map['auto'];
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
-
v = priority_value_map['auto'];
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
return v;
|
|
@@ -151,6 +150,8 @@ export class PriorityFetch {
|
|
|
151
150
|
* @private
|
|
152
151
|
*/
|
|
153
152
|
__dispatch(req) {
|
|
153
|
+
this.__pending_set.add(req);
|
|
154
|
+
|
|
154
155
|
const promise = this.__adapter(req.__resource, req.__options);
|
|
155
156
|
|
|
156
157
|
promise.finally(() => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shortest-path nlerp for a 4 × Float32 quaternion payload (16 bytes).
|
|
3
|
+
* Switch to a slerp variant if you need it for wide per-tick angular
|
|
4
|
+
* steps (animation-blended joints, slow snapshot rate).
|
|
5
|
+
*
|
|
6
|
+
* @author Alex Goldring
|
|
7
|
+
* @copyright Company Named Limited (c) 2025
|
|
8
|
+
*/
|
|
9
|
+
export class QuaternionInterpolationAdapter extends BinaryInterpolationAdapter {
|
|
10
|
+
/** @inheritdoc */
|
|
11
|
+
interpolate(out_buffer: any, source: any, first_offset: any, second_offset: any, t: any): void;
|
|
12
|
+
}
|
|
13
|
+
import { BinaryInterpolationAdapter } from "../sim/BinaryInterpolationAdapter.js";
|
|
14
|
+
//# sourceMappingURL=QuaternionInterpolationAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuaternionInterpolationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/network/adapters/QuaternionInterpolationAdapter.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH;IAEI,kBAAkB;IAClB,+FA6BC;CACJ;2CA3C0C,sCAAsC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BinaryInterpolationAdapter } from "../sim/BinaryInterpolationAdapter.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shortest-path nlerp for a 4 × Float32 quaternion payload (16 bytes).
|
|
5
|
+
* Switch to a slerp variant if you need it for wide per-tick angular
|
|
6
|
+
* steps (animation-blended joints, slow snapshot rate).
|
|
7
|
+
*
|
|
8
|
+
* @author Alex Goldring
|
|
9
|
+
* @copyright Company Named Limited (c) 2025
|
|
10
|
+
*/
|
|
11
|
+
export class QuaternionInterpolationAdapter extends BinaryInterpolationAdapter {
|
|
12
|
+
|
|
13
|
+
/** @inheritdoc */
|
|
14
|
+
interpolate(out_buffer, source, first_offset, second_offset, t) {
|
|
15
|
+
source.position = first_offset;
|
|
16
|
+
const ax = source.readFloat32();
|
|
17
|
+
const ay = source.readFloat32();
|
|
18
|
+
const az = source.readFloat32();
|
|
19
|
+
const aw = source.readFloat32();
|
|
20
|
+
|
|
21
|
+
source.position = second_offset;
|
|
22
|
+
let bx = source.readFloat32();
|
|
23
|
+
let by = source.readFloat32();
|
|
24
|
+
let bz = source.readFloat32();
|
|
25
|
+
let bw = source.readFloat32();
|
|
26
|
+
|
|
27
|
+
if (ax * bx + ay * by + az * bz + aw * bw < 0) {
|
|
28
|
+
bx = -bx; by = -by; bz = -bz; bw = -bw;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let qx = ax + (bx - ax) * t;
|
|
32
|
+
let qy = ay + (by - ay) * t;
|
|
33
|
+
let qz = az + (bz - az) * t;
|
|
34
|
+
let qw = aw + (bw - aw) * t;
|
|
35
|
+
|
|
36
|
+
const len2 = qx * qx + qy * qy + qz * qz + qw * qw;
|
|
37
|
+
const inv_len = len2 > 0 ? 1 / Math.sqrt(len2) : 1;
|
|
38
|
+
|
|
39
|
+
out_buffer.writeFloat32(qx * inv_len);
|
|
40
|
+
out_buffer.writeFloat32(qy * inv_len);
|
|
41
|
+
out_buffer.writeFloat32(qz * inv_len);
|
|
42
|
+
out_buffer.writeFloat32(qw * inv_len);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linear-blend interpolation for {@link Transform}, matching the wire
|
|
3
|
+
* layout of {@link TransformReplicationAdapter}: 3×Float32 position +
|
|
4
|
+
* uint32 packed quaternion + equality-encoded scale.
|
|
5
|
+
*
|
|
6
|
+
* Position lerps componentwise; rotation nlerps with shortest-path
|
|
7
|
+
* correction; scale decodes/lerps/re-encodes (output is still valid
|
|
8
|
+
* equality-encoded).
|
|
9
|
+
*
|
|
10
|
+
* @author Alex Goldring
|
|
11
|
+
* @copyright Company Named Limited (c) 2025
|
|
12
|
+
*/
|
|
13
|
+
export class TransformInterpolationAdapter extends BinaryInterpolationAdapter {
|
|
14
|
+
/** @inheritdoc */
|
|
15
|
+
interpolate(out_buffer: any, source: any, first_offset: any, second_offset: any, t: any): void;
|
|
16
|
+
}
|
|
17
|
+
import { BinaryInterpolationAdapter } from "../sim/BinaryInterpolationAdapter.js";
|
|
18
|
+
//# sourceMappingURL=TransformInterpolationAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransformInterpolationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/network/adapters/TransformInterpolationAdapter.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;GAWG;AACH;IAEI,kBAAkB;IAClB,+FAiDC;CACJ;2CA1E0C,sCAAsC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { quat_decode_from_uint32 } from "../../../core/geom/3d/quaternion/quat_decode_from_uint32.js";
|
|
2
|
+
import { quat_encode_to_uint32 } from "../../../core/geom/3d/quaternion/quat_encode_to_uint32.js";
|
|
3
|
+
import { v3_binary_equality_decode } from "../../../core/geom/vec3/serialization/v3_binary_equality_decode.js";
|
|
4
|
+
import { v3_binary_equality_encode } from "../../../core/geom/vec3/serialization/v3_binary_equality_encode.js";
|
|
5
|
+
import { BinaryInterpolationAdapter } from "../sim/BinaryInterpolationAdapter.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Module-level scratch. Layout: `[aq.xyzw, bq.xyzw, as.xyz, bs.xyz]`.
|
|
9
|
+
* Safe because `interpolate` is synchronous and non-reentrant.
|
|
10
|
+
* @type {Float32Array}
|
|
11
|
+
*/
|
|
12
|
+
const scratch = new Float32Array(16);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Linear-blend interpolation for {@link Transform}, matching the wire
|
|
16
|
+
* layout of {@link TransformReplicationAdapter}: 3×Float32 position +
|
|
17
|
+
* uint32 packed quaternion + equality-encoded scale.
|
|
18
|
+
*
|
|
19
|
+
* Position lerps componentwise; rotation nlerps with shortest-path
|
|
20
|
+
* correction; scale decodes/lerps/re-encodes (output is still valid
|
|
21
|
+
* equality-encoded).
|
|
22
|
+
*
|
|
23
|
+
* @author Alex Goldring
|
|
24
|
+
* @copyright Company Named Limited (c) 2025
|
|
25
|
+
*/
|
|
26
|
+
export class TransformInterpolationAdapter extends BinaryInterpolationAdapter {
|
|
27
|
+
|
|
28
|
+
/** @inheritdoc */
|
|
29
|
+
interpolate(out_buffer, source, first_offset, second_offset, t) {
|
|
30
|
+
// ---- Decode sample A ----
|
|
31
|
+
source.position = first_offset;
|
|
32
|
+
const ax = source.readFloat32();
|
|
33
|
+
const ay = source.readFloat32();
|
|
34
|
+
const az = source.readFloat32();
|
|
35
|
+
const a_quat_packed = source.readUint32();
|
|
36
|
+
quat_decode_from_uint32(scratch, 0, a_quat_packed); // → scratch[0..3]
|
|
37
|
+
v3_binary_equality_decode(source, scratch, 8); // → scratch[8..10]
|
|
38
|
+
|
|
39
|
+
// ---- Decode sample B ----
|
|
40
|
+
source.position = second_offset;
|
|
41
|
+
const bx = source.readFloat32();
|
|
42
|
+
const by = source.readFloat32();
|
|
43
|
+
const bz = source.readFloat32();
|
|
44
|
+
const b_quat_packed = source.readUint32();
|
|
45
|
+
quat_decode_from_uint32(scratch, 4, b_quat_packed); // → scratch[4..7]
|
|
46
|
+
v3_binary_equality_decode(source, scratch, 11); // → scratch[11..13]
|
|
47
|
+
|
|
48
|
+
// ---- Position lerp ----
|
|
49
|
+
const out_x = ax + (bx - ax) * t;
|
|
50
|
+
const out_y = ay + (by - ay) * t;
|
|
51
|
+
const out_z = az + (bz - az) * t;
|
|
52
|
+
|
|
53
|
+
// ---- Rotation nlerp with shortest-path correction ----
|
|
54
|
+
const aqx = scratch[0], aqy = scratch[1], aqz = scratch[2], aqw = scratch[3];
|
|
55
|
+
let bqx = scratch[4], bqy = scratch[5], bqz = scratch[6], bqw = scratch[7];
|
|
56
|
+
if (aqx * bqx + aqy * bqy + aqz * bqz + aqw * bqw < 0) {
|
|
57
|
+
bqx = -bqx; bqy = -bqy; bqz = -bqz; bqw = -bqw;
|
|
58
|
+
}
|
|
59
|
+
let qx = aqx + (bqx - aqx) * t;
|
|
60
|
+
let qy = aqy + (bqy - aqy) * t;
|
|
61
|
+
let qz = aqz + (bqz - aqz) * t;
|
|
62
|
+
let qw = aqw + (bqw - aqw) * t;
|
|
63
|
+
const len2 = qx * qx + qy * qy + qz * qz + qw * qw;
|
|
64
|
+
const inv_len = len2 > 0 ? 1 / Math.sqrt(len2) : 1;
|
|
65
|
+
qx *= inv_len; qy *= inv_len; qz *= inv_len; qw *= inv_len;
|
|
66
|
+
|
|
67
|
+
// ---- Scale lerp ----
|
|
68
|
+
const out_sx = scratch[8] + (scratch[11] - scratch[8]) * t;
|
|
69
|
+
const out_sy = scratch[9] + (scratch[12] - scratch[9]) * t;
|
|
70
|
+
const out_sz = scratch[10] + (scratch[13] - scratch[10]) * t;
|
|
71
|
+
|
|
72
|
+
// ---- Re-encode to TransformReplicationAdapter wire layout ----
|
|
73
|
+
out_buffer.writeFloat32(out_x);
|
|
74
|
+
out_buffer.writeFloat32(out_y);
|
|
75
|
+
out_buffer.writeFloat32(out_z);
|
|
76
|
+
out_buffer.writeUint32(quat_encode_to_uint32(qx, qy, qz, qw));
|
|
77
|
+
v3_binary_equality_encode(out_buffer, out_sx, out_sy, out_sz);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network-replication adapter for {@link Transform}. Mirrors
|
|
3
|
+
* {@link TransformSerializationAdapter} but uses Float32 for position instead
|
|
4
|
+
* of Float64, halving the per-component cost (12 B vs 24 B) for a precision
|
|
5
|
+
* loss that is below visible threshold for typical action-game scales.
|
|
6
|
+
*
|
|
7
|
+
* Wire layout (typical 17 B, 13 B if scale is identity):
|
|
8
|
+
* - position: 3 × Float32 = 12 bytes
|
|
9
|
+
* - rotation: smallest-three uint32 = 4 bytes
|
|
10
|
+
* - scale: `v3_binary_equality_encode` = 1 byte (identity) or 13 bytes (full)
|
|
11
|
+
*
|
|
12
|
+
* Total: 17 bytes typical, 29 bytes max.
|
|
13
|
+
*
|
|
14
|
+
* Distinct from {@link TransformSerializationAdapter} so save-game files keep
|
|
15
|
+
* Float64 position precision while wire packets stay tight.
|
|
16
|
+
*
|
|
17
|
+
* @author Alex Goldring
|
|
18
|
+
* @copyright Company Named Limited (c) 2025
|
|
19
|
+
*/
|
|
20
|
+
export class TransformReplicationAdapter extends BinaryClassSerializationAdapter<any> {
|
|
21
|
+
constructor();
|
|
22
|
+
klass: typeof Transform;
|
|
23
|
+
version: number;
|
|
24
|
+
/**
|
|
25
|
+
* @param {BinaryBuffer} buffer
|
|
26
|
+
* @param {Transform} value
|
|
27
|
+
*/
|
|
28
|
+
serialize(buffer: BinaryBuffer, value: Transform): void;
|
|
29
|
+
/**
|
|
30
|
+
* @param {BinaryBuffer} buffer
|
|
31
|
+
* @param {Transform} value
|
|
32
|
+
*/
|
|
33
|
+
deserialize(buffer: BinaryBuffer, value: Transform): void;
|
|
34
|
+
}
|
|
35
|
+
import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
36
|
+
import { Transform } from "../../ecs/transform/Transform.js";
|
|
37
|
+
//# sourceMappingURL=TransformReplicationAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransformReplicationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/network/adapters/TransformReplicationAdapter.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;GAkBG;AACH;;IAEI,wBAAkB;IAClB,gBAAY;IAEZ;;;OAGG;IACH,uCAFW,SAAS,QAoBnB;IAED;;;OAGG;IACH,yCAFW,SAAS,QAmBnB;CACJ;gDAlF+C,6DAA6D;0BACnF,kCAAkC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { quat_decode_from_uint32 } from "../../../core/geom/3d/quaternion/quat_decode_from_uint32.js";
|
|
2
|
+
import { quat_encode_to_uint32 } from "../../../core/geom/3d/quaternion/quat_encode_to_uint32.js";
|
|
3
|
+
import { v3_binary_equality_decode } from "../../../core/geom/vec3/serialization/v3_binary_equality_decode.js";
|
|
4
|
+
import { v3_binary_equality_encode } from "../../../core/geom/vec3/serialization/v3_binary_equality_encode.js";
|
|
5
|
+
import { BinaryClassSerializationAdapter } from "../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
6
|
+
import { Transform } from "../../ecs/transform/Transform.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Decode scratch for {@link TransformReplicationAdapter#deserialize}. Decoders
|
|
10
|
+
* write into indexed slots; we then publish the final value to each field
|
|
11
|
+
* via `.set(...)` so the `onChanged` signal fires once with the assembled
|
|
12
|
+
* value rather than not at all (direct-write) or partially per intermediate.
|
|
13
|
+
* @type {Float32Array}
|
|
14
|
+
*/
|
|
15
|
+
const decode_scratch = new Float32Array(4);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Network-replication adapter for {@link Transform}. Mirrors
|
|
19
|
+
* {@link TransformSerializationAdapter} but uses Float32 for position instead
|
|
20
|
+
* of Float64, halving the per-component cost (12 B vs 24 B) for a precision
|
|
21
|
+
* loss that is below visible threshold for typical action-game scales.
|
|
22
|
+
*
|
|
23
|
+
* Wire layout (typical 17 B, 13 B if scale is identity):
|
|
24
|
+
* - position: 3 × Float32 = 12 bytes
|
|
25
|
+
* - rotation: smallest-three uint32 = 4 bytes
|
|
26
|
+
* - scale: `v3_binary_equality_encode` = 1 byte (identity) or 13 bytes (full)
|
|
27
|
+
*
|
|
28
|
+
* Total: 17 bytes typical, 29 bytes max.
|
|
29
|
+
*
|
|
30
|
+
* Distinct from {@link TransformSerializationAdapter} so save-game files keep
|
|
31
|
+
* Float64 position precision while wire packets stay tight.
|
|
32
|
+
*
|
|
33
|
+
* @author Alex Goldring
|
|
34
|
+
* @copyright Company Named Limited (c) 2025
|
|
35
|
+
*/
|
|
36
|
+
export class TransformReplicationAdapter extends BinaryClassSerializationAdapter {
|
|
37
|
+
|
|
38
|
+
klass = Transform;
|
|
39
|
+
version = 1;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {BinaryBuffer} buffer
|
|
43
|
+
* @param {Transform} value
|
|
44
|
+
*/
|
|
45
|
+
serialize(buffer, value) {
|
|
46
|
+
|
|
47
|
+
const position = value.position;
|
|
48
|
+
const rotation = value.rotation;
|
|
49
|
+
const scale = value.scale;
|
|
50
|
+
|
|
51
|
+
buffer.writeFloat32(position.x);
|
|
52
|
+
buffer.writeFloat32(position.y);
|
|
53
|
+
buffer.writeFloat32(position.z);
|
|
54
|
+
|
|
55
|
+
buffer.writeUint32(quat_encode_to_uint32(
|
|
56
|
+
rotation.x,
|
|
57
|
+
rotation.y,
|
|
58
|
+
rotation.z,
|
|
59
|
+
rotation.w
|
|
60
|
+
));
|
|
61
|
+
|
|
62
|
+
v3_binary_equality_encode(buffer, scale.x, scale.y, scale.z);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param {BinaryBuffer} buffer
|
|
67
|
+
* @param {Transform} value
|
|
68
|
+
*/
|
|
69
|
+
deserialize(buffer, value) {
|
|
70
|
+
|
|
71
|
+
const positionX = buffer.readFloat32();
|
|
72
|
+
const positionY = buffer.readFloat32();
|
|
73
|
+
const positionZ = buffer.readFloat32();
|
|
74
|
+
|
|
75
|
+
const encoded_rotation = buffer.readUint32();
|
|
76
|
+
|
|
77
|
+
const s = decode_scratch;
|
|
78
|
+
|
|
79
|
+
v3_binary_equality_decode(buffer, s, 0);
|
|
80
|
+
value.scale.set(s[0], s[1], s[2]);
|
|
81
|
+
|
|
82
|
+
quat_decode_from_uint32(s, 0, encoded_rotation);
|
|
83
|
+
value.rotation.set(s[0], s[1], s[2], s[3]);
|
|
84
|
+
|
|
85
|
+
value.position.set(positionX, positionY, positionZ);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Componentwise lerp of a 3-Float32 position payload.
|
|
3
|
+
*
|
|
4
|
+
* Wire layout (matching whatever serialization adapter wrote it):
|
|
5
|
+
* - Float32 x
|
|
6
|
+
* - Float32 y
|
|
7
|
+
* - Float32 z
|
|
8
|
+
*
|
|
9
|
+
* 12 bytes per snapshot. Pair with a serialization adapter that uses this
|
|
10
|
+
* same format (the simplest "naked Vector3" encoding).
|
|
11
|
+
*
|
|
12
|
+
* @author Alex Goldring
|
|
13
|
+
* @copyright Company Named Limited (c) 2025
|
|
14
|
+
*/
|
|
15
|
+
export class Vector3InterpolationAdapter extends BinaryInterpolationAdapter {
|
|
16
|
+
}
|
|
17
|
+
import { BinaryInterpolationAdapter } from "../sim/BinaryInterpolationAdapter.js";
|
|
18
|
+
//# sourceMappingURL=Vector3InterpolationAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Vector3InterpolationAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/network/adapters/Vector3InterpolationAdapter.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH;CA4BC;2CA5C0C,sCAAsC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { lerp } from "../../../core/math/lerp.js";
|
|
2
|
+
import { BinaryInterpolationAdapter } from "../sim/BinaryInterpolationAdapter.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Componentwise lerp of a 3-Float32 position payload.
|
|
6
|
+
*
|
|
7
|
+
* Wire layout (matching whatever serialization adapter wrote it):
|
|
8
|
+
* - Float32 x
|
|
9
|
+
* - Float32 y
|
|
10
|
+
* - Float32 z
|
|
11
|
+
*
|
|
12
|
+
* 12 bytes per snapshot. Pair with a serialization adapter that uses this
|
|
13
|
+
* same format (the simplest "naked Vector3" encoding).
|
|
14
|
+
*
|
|
15
|
+
* @author Alex Goldring
|
|
16
|
+
* @copyright Company Named Limited (c) 2025
|
|
17
|
+
*/
|
|
18
|
+
export class Vector3InterpolationAdapter extends BinaryInterpolationAdapter {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {BinaryBuffer} out_buffer
|
|
22
|
+
* @param {BinaryBuffer} source
|
|
23
|
+
* @param {number} first_offset
|
|
24
|
+
* @param {number} second_offset
|
|
25
|
+
* @param {number} t
|
|
26
|
+
*/
|
|
27
|
+
interpolate(out_buffer, source, first_offset, second_offset, t) {
|
|
28
|
+
source.position = first_offset;
|
|
29
|
+
const ax = source.readFloat32();
|
|
30
|
+
const ay = source.readFloat32();
|
|
31
|
+
const az = source.readFloat32();
|
|
32
|
+
|
|
33
|
+
source.position = second_offset;
|
|
34
|
+
const bx = source.readFloat32();
|
|
35
|
+
const by = source.readFloat32();
|
|
36
|
+
const bz = source.readFloat32();
|
|
37
|
+
|
|
38
|
+
const out_x = lerp(ax, bx, t);
|
|
39
|
+
const out_y = lerp(ay, by, t);
|
|
40
|
+
const out_z = lerp(az, bz, t);
|
|
41
|
+
|
|
42
|
+
out_buffer.writeFloat32(out_x);
|
|
43
|
+
out_buffer.writeFloat32(out_y);
|
|
44
|
+
out_buffer.writeFloat32(out_z);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
import { assert } from "../../core/assert.js";
|
|
2
|
-
|
|
3
|
-
const rx_url_schema = /[a-zA-Z0-9_\-]+\:\/\//;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
* @param {string} path
|
|
8
|
-
* @return {boolean}
|
|
9
|
-
*/
|
|
10
|
-
function isGlobalPath(path) {
|
|
11
|
-
//search for URL schema at the start of the path
|
|
12
|
-
return path.search(rx_url_schema) === 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// *** Environment setup code ***
|
|
16
|
-
const ENVIRONMENT_IS_WEB = typeof window === 'object';
|
|
17
|
-
const ENVIRONMENT_IS_NODE = typeof process === 'object' && !ENVIRONMENT_IS_WEB;
|
|
18
|
-
const ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
|
|
19
|
-
const ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @param {string} path
|
|
24
|
-
* @return {string}
|
|
25
|
-
*/
|
|
26
|
-
function localPathToGlobal(path) {
|
|
27
|
-
/**
|
|
28
|
-
* @type {Window|DedicatedWorkerGlobalScope}
|
|
29
|
-
*/
|
|
30
|
-
let scope;
|
|
31
|
-
|
|
32
|
-
if (ENVIRONMENT_IS_WEB) {
|
|
33
|
-
scope = window;
|
|
34
|
-
} else if (ENVIRONMENT_IS_WORKER) {
|
|
35
|
-
scope = self;
|
|
36
|
-
} else if (ENVIRONMENT_IS_NODE) {
|
|
37
|
-
|
|
38
|
-
let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
|
|
39
|
-
|
|
40
|
-
// remove multiple sequential slashes
|
|
41
|
-
normalized_path = normalized_path.replace(/\/+/g, '/');
|
|
42
|
-
|
|
43
|
-
if (normalized_path[0] !== '/') {
|
|
44
|
-
// Windows drive letter must be prefixed with a slash.
|
|
45
|
-
normalized_path = `/${normalized_path}`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
scope = {
|
|
49
|
-
location: {
|
|
50
|
-
pathname: normalized_path,
|
|
51
|
-
host: '',
|
|
52
|
-
protocol: 'file:'
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
} else {
|
|
56
|
-
throw new Error('Unknown environment');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const location = scope.location;
|
|
60
|
-
const pathname = location.pathname;
|
|
61
|
-
|
|
62
|
-
let directoryPath;
|
|
63
|
-
|
|
64
|
-
/*
|
|
65
|
-
path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
|
|
66
|
-
we need to extract directory to load relative path
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
if (pathname.endsWith('/')) {
|
|
70
|
-
//path is to a directory, strip last slash
|
|
71
|
-
directoryPath = pathname.substring(0, pathname.length - 1);
|
|
72
|
-
} else {
|
|
73
|
-
//path is to a file
|
|
74
|
-
const i = pathname.lastIndexOf('/');
|
|
75
|
-
|
|
76
|
-
if (i === -1) {
|
|
77
|
-
//root level file
|
|
78
|
-
directoryPath = ""
|
|
79
|
-
} else {
|
|
80
|
-
directoryPath = pathname.substring(0, i);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
|
|
85
|
-
return urlBase + path;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Given a path, which may be a local path, produce a fully qualified URL
|
|
90
|
-
* @example '/path' -> 'http://example.com/path'
|
|
91
|
-
* @example 'some/local/path' -> 'http://example.com/current_path/some/local/path'
|
|
92
|
-
* @param {string} path
|
|
93
|
-
* @return {string}
|
|
94
|
-
*/
|
|
95
|
-
export function convertPathToURL(path) {
|
|
96
|
-
assert.isString(path, 'path');
|
|
97
|
-
|
|
98
|
-
const is_global = isGlobalPath(path);
|
|
99
|
-
|
|
100
|
-
let result = path;
|
|
101
|
-
|
|
102
|
-
if (!is_global) {
|
|
103
|
-
result = localPathToGlobal(path);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
1
|
+
import { assert } from "../../core/assert.js";
|
|
2
|
+
|
|
3
|
+
const rx_url_schema = /[a-zA-Z0-9_\-]+\:\/\//;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {string} path
|
|
8
|
+
* @return {boolean}
|
|
9
|
+
*/
|
|
10
|
+
function isGlobalPath(path) {
|
|
11
|
+
//search for URL schema at the start of the path
|
|
12
|
+
return path.search(rx_url_schema) === 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// *** Environment setup code ***
|
|
16
|
+
const ENVIRONMENT_IS_WEB = typeof window === 'object';
|
|
17
|
+
const ENVIRONMENT_IS_NODE = typeof process === 'object' && !ENVIRONMENT_IS_WEB;
|
|
18
|
+
const ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
|
|
19
|
+
const ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {string} path
|
|
24
|
+
* @return {string}
|
|
25
|
+
*/
|
|
26
|
+
function localPathToGlobal(path) {
|
|
27
|
+
/**
|
|
28
|
+
* @type {Window|DedicatedWorkerGlobalScope}
|
|
29
|
+
*/
|
|
30
|
+
let scope;
|
|
31
|
+
|
|
32
|
+
if (ENVIRONMENT_IS_WEB) {
|
|
33
|
+
scope = window;
|
|
34
|
+
} else if (ENVIRONMENT_IS_WORKER) {
|
|
35
|
+
scope = self;
|
|
36
|
+
} else if (ENVIRONMENT_IS_NODE) {
|
|
37
|
+
|
|
38
|
+
let normalized_path = `${process.cwd()}/`.replace(/\\/g, '/');
|
|
39
|
+
|
|
40
|
+
// remove multiple sequential slashes
|
|
41
|
+
normalized_path = normalized_path.replace(/\/+/g, '/');
|
|
42
|
+
|
|
43
|
+
if (normalized_path[0] !== '/') {
|
|
44
|
+
// Windows drive letter must be prefixed with a slash.
|
|
45
|
+
normalized_path = `/${normalized_path}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
scope = {
|
|
49
|
+
location: {
|
|
50
|
+
pathname: normalized_path,
|
|
51
|
+
host: '',
|
|
52
|
+
protocol: 'file:'
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
} else {
|
|
56
|
+
throw new Error('Unknown environment');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const location = scope.location;
|
|
60
|
+
const pathname = location.pathname;
|
|
61
|
+
|
|
62
|
+
let directoryPath;
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
path name contains file name also, there are two options here, "a/b" or "a/b/" second is a directory
|
|
66
|
+
we need to extract directory to load relative path
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
if (pathname.endsWith('/')) {
|
|
70
|
+
//path is to a directory, strip last slash
|
|
71
|
+
directoryPath = pathname.substring(0, pathname.length - 1);
|
|
72
|
+
} else {
|
|
73
|
+
//path is to a file
|
|
74
|
+
const i = pathname.lastIndexOf('/');
|
|
75
|
+
|
|
76
|
+
if (i === -1) {
|
|
77
|
+
//root level file
|
|
78
|
+
directoryPath = ""
|
|
79
|
+
} else {
|
|
80
|
+
directoryPath = pathname.substring(0, i);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const urlBase = location.protocol + "//" + location.host + directoryPath + "/";
|
|
85
|
+
return urlBase + path;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Given a path, which may be a local path, produce a fully qualified URL
|
|
90
|
+
* @example '/path' -> 'http://example.com/path'
|
|
91
|
+
* @example 'some/local/path' -> 'http://example.com/current_path/some/local/path'
|
|
92
|
+
* @param {string} path
|
|
93
|
+
* @return {string}
|
|
94
|
+
*/
|
|
95
|
+
export function convertPathToURL(path) {
|
|
96
|
+
assert.isString(path, 'path');
|
|
97
|
+
|
|
98
|
+
const is_global = isGlobalPath(path);
|
|
99
|
+
|
|
100
|
+
let result = path;
|
|
101
|
+
|
|
102
|
+
if (!is_global) {
|
|
103
|
+
result = localPathToGlobal(path);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uniform float quantization to an N-bit unsigned integer.
|
|
3
|
+
*
|
|
4
|
+
* Maps `[min, max]` linearly to `[0, 2^bits - 1]` using nearest-integer rounding.
|
|
5
|
+
* Values outside the range are clamped. Round-trip error is bounded by
|
|
6
|
+
* `(max - min) / (2 * (2^bits - 1))`.
|
|
7
|
+
*
|
|
8
|
+
* Pure functions; safe to call on the hot path. Caller is responsible for
|
|
9
|
+
* passing the same `min`, `max`, and `bits` on both sender and receiver — there
|
|
10
|
+
* is no on-wire metadata.
|
|
11
|
+
*
|
|
12
|
+
* @author Alex Goldring
|
|
13
|
+
* @copyright Company Named Limited (c) 2025
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Quantize `value` from the inclusive range `[min, max]` to an unsigned integer
|
|
17
|
+
* in `[0, 2^bits - 1]`.
|
|
18
|
+
*
|
|
19
|
+
* Passing `NaN` for `value` returns `NaN` (both clamp comparisons are false on
|
|
20
|
+
* NaN, so `Math.round(NaN * max_int)` propagates). Callers must guard against
|
|
21
|
+
* NaN at the boundary — a downstream `DataView.setUintXX` will silently coerce
|
|
22
|
+
* NaN to 0, hiding the upstream bug.
|
|
23
|
+
*
|
|
24
|
+
* @param {number} value
|
|
25
|
+
* @param {number} min
|
|
26
|
+
* @param {number} max must be > min
|
|
27
|
+
* @param {number} bits 1..30 (keep below 31 to stay in safe signed-shift territory)
|
|
28
|
+
* @returns {number} unsigned integer in [0, 2^bits - 1]
|
|
29
|
+
*/
|
|
30
|
+
export function quantize_float(value: number, min: number, max: number, bits: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* Inverse of {@link quantize_float}. Decodes an unsigned integer back into a float
|
|
33
|
+
* in `[min, max]`.
|
|
34
|
+
*
|
|
35
|
+
* @param {number} quantized
|
|
36
|
+
* @param {number} min
|
|
37
|
+
* @param {number} max
|
|
38
|
+
* @param {number} bits
|
|
39
|
+
* @returns {number}
|
|
40
|
+
*/
|
|
41
|
+
export function dequantize_float(quantized: number, min: number, max: number, bits: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Round-trip a value through quantize+dequantize. Useful when sender and receiver
|
|
44
|
+
* must simulate from the same quantized state to remain in sync (state-sync /
|
|
45
|
+
* deterministic rollback).
|
|
46
|
+
*
|
|
47
|
+
* @param {number} value
|
|
48
|
+
* @param {number} min
|
|
49
|
+
* @param {number} max
|
|
50
|
+
* @param {number} bits
|
|
51
|
+
* @returns {number}
|
|
52
|
+
*/
|
|
53
|
+
export function quantize_then_dequantize_float(value: number, min: number, max: number, bits: number): number;
|
|
54
|
+
//# sourceMappingURL=quantize_float.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quantize_float.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/network/core/quantize/quantize_float.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;GAcG;AACH,sCANW,MAAM,OACN,MAAM,OACN,MAAM,QACN,MAAM,GACJ,MAAM,CAOlB;AAED;;;;;;;;;GASG;AACH,4CANW,MAAM,OACN,MAAM,OACN,MAAM,QACN,MAAM,GACJ,MAAM,CAKlB;AAED;;;;;;;;;;GAUG;AACH,sDANW,MAAM,OACN,MAAM,OACN,MAAM,QACN,MAAM,GACJ,MAAM,CAIlB"}
|