@series-inc/rundot-syncplay 6.0.0-rc.2 → 6.0.0-rc.21
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/README.md +133 -0
- package/core/deterministic-math.d.ts +75 -1
- package/core/native/instance_ledger.hpp +1095 -0
- package/core/native/legacy_checkpoint_ids.hpp +107 -0
- package/core/native/physics/abi.cpp +39 -211
- package/core/native/physics/abi.hpp +2 -6
- package/core/native/physics/articulation.cpp +1434 -0
- package/core/native/physics/articulation.hpp +279 -0
- package/core/native/physics/buoyancy.cpp +1588 -0
- package/core/native/physics/buoyancy.hpp +254 -0
- package/core/native/physics/capsule_triangle.cpp +168 -0
- package/core/native/physics/capsule_triangle.hpp +40 -0
- package/core/native/physics/capsule_triangle_native.inc +291 -0
- package/core/native/physics/certified_sum.hpp +218 -0
- package/core/native/physics/character.cpp +638 -0
- package/core/native/physics/character.hpp +169 -0
- package/core/native/physics/checkpoint_schema.hpp +379 -0
- package/core/native/physics/cloth.cpp +1401 -0
- package/core/native/physics/cloth.hpp +357 -0
- package/core/native/physics/constraint_rows.cpp +363 -2
- package/core/native/physics/constraint_rows.hpp +72 -1
- package/core/native/physics/deformable_query.cpp +1630 -0
- package/core/native/physics/deformable_query.hpp +578 -0
- package/core/native/physics/distance.cpp +1166 -0
- package/core/native/physics/distance.hpp +151 -0
- package/core/native/physics/exact/exact-applied.cpp +101 -0
- package/core/native/physics/exact/exact-applied.hpp +112 -0
- package/core/native/physics/exact/exact-dyadic.cpp +691 -0
- package/core/native/physics/exact/exact-dyadic.hpp +58 -0
- package/core/native/physics/exact/exact-operation.hpp +51 -0
- package/core/native/physics/exact/word-core.hpp +262 -0
- package/core/native/physics/extended_abi.cpp +1242 -0
- package/core/native/physics/extended_abi.hpp +355 -0
- package/core/native/physics/extended_abi_characters.cpp +261 -0
- package/core/native/physics/extended_abi_characters.hpp +434 -0
- package/core/native/physics/extended_abi_core_features.cpp +713 -0
- package/core/native/physics/extended_abi_core_features.hpp +226 -0
- package/core/native/physics/extended_abi_deformables.cpp +448 -0
- package/core/native/physics/extended_abi_deformables.hpp +867 -0
- package/core/native/physics/extended_abi_vehicles.cpp +411 -0
- package/core/native/physics/extended_abi_vehicles.hpp +222 -0
- package/core/native/physics/fracture.cpp +1981 -0
- package/core/native/physics/fracture.hpp +460 -0
- package/core/native/physics/gear.cpp +563 -0
- package/core/native/physics/gear.hpp +158 -0
- package/core/native/physics/geometry_memory.hpp +476 -0
- package/core/native/physics/geometry_store.cpp +547 -0
- package/core/native/physics/geometry_store.hpp +134 -0
- package/core/native/physics/lag_compensation.cpp +1626 -0
- package/core/native/physics/lag_compensation.hpp +405 -0
- package/core/native/physics/mass_properties.cpp +449 -0
- package/core/native/physics/mass_properties.hpp +23 -0
- package/core/native/physics/material_pose.hpp +988 -0
- package/core/native/physics/particles.cpp +1065 -0
- package/core/native/physics/particles.hpp +261 -0
- package/core/native/physics/path_joint.cpp +781 -0
- package/core/native/physics/path_joint.hpp +154 -0
- package/core/native/physics/physics.cpp +13043 -1065
- package/core/native/physics/physics.hpp +184 -8
- package/core/native/physics/planar_deformable.cpp +2433 -0
- package/core/native/physics/planar_deformable.hpp +889 -0
- package/core/native/physics/platformer_2d.cpp +1353 -0
- package/core/native/physics/platformer_2d.hpp +340 -0
- package/core/native/physics/powered_ragdoll.cpp +1100 -0
- package/core/native/physics/powered_ragdoll.hpp +279 -0
- package/core/native/physics/powertrain.cpp +586 -0
- package/core/native/physics/powertrain.hpp +180 -0
- package/core/native/physics/pulley.cpp +311 -0
- package/core/native/physics/pulley.hpp +121 -0
- package/core/native/physics/ragdoll.cpp +586 -0
- package/core/native/physics/ragdoll.hpp +221 -0
- package/core/native/physics/rope.cpp +692 -0
- package/core/native/physics/rope.hpp +215 -0
- package/core/native/physics/rounded_convex.cpp +1229 -0
- package/core/native/physics/rounded_convex.hpp +287 -0
- package/core/native/physics/sdf_geometry.cpp +1821 -0
- package/core/native/physics/sdf_geometry.hpp +474 -0
- package/core/native/physics/soft_body.cpp +1449 -0
- package/core/native/physics/soft_body.hpp +328 -0
- package/core/native/physics/soft_collision.cpp +1862 -0
- package/core/native/physics/soft_collision.hpp +561 -0
- package/core/native/physics/surface_velocity.cpp +366 -0
- package/core/native/physics/surface_velocity.hpp +243 -0
- package/core/native/physics/topology.cpp +357 -39
- package/core/native/physics/topology.hpp +97 -6
- package/core/native/physics/tracks.cpp +1179 -0
- package/core/native/physics/tracks.hpp +404 -0
- package/core/native/physics/vehicle.cpp +629 -0
- package/core/native/physics/vehicle.hpp +191 -0
- package/core/native/physics/voxel_cooking.cpp +1929 -0
- package/core/native/physics/voxel_cooking.hpp +395 -0
- package/core/native/physics/world.cpp +5290 -854
- package/core/native/physics/world.hpp +796 -24
- package/core/native/physics/world_abi.cpp +3840 -306
- package/core/native/physics/world_abi.hpp +530 -10
- package/core/native/physics/world_digest_visitor.hpp +277 -0
- package/core/native/physics/world_strong_digest.hpp +557 -0
- package/core/native/physics2d/ccd.cpp +1302 -0
- package/core/native/physics2d/ccd.hpp +141 -0
- package/core/native/physics2d/checkpoint_memory.hpp +349 -0
- package/core/native/physics2d/clock_primitives.hpp +138 -0
- package/core/native/physics2d/commands.cpp +174 -28
- package/core/native/physics2d/commands.hpp +3 -1
- package/core/native/physics2d/compound.cpp +581 -0
- package/core/native/physics2d/compound.hpp +248 -0
- package/core/native/physics2d/contour.cpp +325 -0
- package/core/native/physics2d/contour.hpp +143 -0
- package/core/native/physics2d/frame_scope.hpp +124 -0
- package/core/native/physics2d/joint_phases.hpp +93 -0
- package/core/native/physics2d/joints.cpp +587 -150
- package/core/native/physics2d/joints.hpp +5 -0
- package/core/native/physics2d/memory_private.hpp +125 -0
- package/core/native/physics2d/owned_abi.cpp +1354 -879
- package/core/native/physics2d/owned_abi.hpp +190 -52
- package/core/native/physics2d/phase_test_hooks.hpp +17 -0
- package/core/native/physics2d/physics2d.cpp +2073 -120
- package/core/native/physics2d/physics2d.hpp +154 -2
- package/core/native/physics2d/queries.cpp +1055 -79
- package/core/native/physics2d/queries.hpp +71 -5
- package/core/native/physics2d/world.cpp +1313 -353
- package/core/native/physics2d/world.hpp +124 -13
- package/core/native/sha256/sha256_compress_unsigned.hpp +68 -0
- package/core/native/sha256/sha256_fips_constants.hpp +24 -0
- package/core/native/sha256/sha256_length.hpp +56 -0
- package/core/native/sha256/sha256_memo.hpp +48 -0
- package/core/native/sha256/sha256_sink.hpp +234 -0
- package/core/physics2d-owned.d.ts +466 -126
- package/core/runtime.d.ts +192 -19
- package/core/scripts/build-native.mjs +34 -0
- package/core/scripts/build-wasm-physics.mjs +272 -23
- package/core/scripts/extended-physics-profile.mjs +634 -0
- package/core/scripts/generate-physics2d-vectors.mjs +59 -0
- package/core/src/kinetix-deterministic-math.d.ts +2 -0
- package/core/src/kinetix-deterministic-math.mjs +513 -27
- package/core/src/kinetix-owned-runtime-adapter.mjs +788 -0
- package/core/src/kinetix-runtime-adapter-utils.mjs +54 -6
- package/core/src/kinetix-runtime-contract.mjs +55 -9
- package/core/src/kinetix-runtime-identity.mjs +12 -1
- package/core/src/kinetix-session-config.mjs +7 -2
- package/core/src/kinetix-state-report.mjs +36 -0
- package/core/src/physics/abi-constants.mjs +5 -4
- package/core/src/physics/articulation.d.mts +194 -0
- package/core/src/physics/articulation.mjs +1141 -0
- package/core/src/physics/buoyancy.d.mts +143 -0
- package/core/src/physics/buoyancy.mjs +268 -0
- package/core/src/physics/cloth.d.mts +314 -0
- package/core/src/physics/cloth.mjs +1156 -0
- package/core/src/physics/deformable-query.d.mts +217 -0
- package/core/src/physics/deformable-query.mjs +1412 -0
- package/core/src/physics/distance.d.mts +160 -0
- package/core/src/physics/distance.mjs +175 -0
- package/core/src/physics/extended-wasm-instance.d.mts +5 -0
- package/core/src/physics/extended-wasm-instance.mjs +48 -0
- package/core/src/physics/feature-api.d.mts +74 -0
- package/core/src/physics/feature-api.mjs +98 -0
- package/core/src/physics/fracture.d.mts +133 -0
- package/core/src/physics/fracture.mjs +1324 -0
- package/core/src/physics/gear.d.mts +585 -0
- package/core/src/physics/gear.mjs +955 -0
- package/core/src/physics/lag-compensation.d.mts +101 -0
- package/core/src/physics/lag-compensation.mjs +1100 -0
- package/core/src/physics/mass-properties.d.mts +114 -0
- package/core/src/physics/mass-properties.mjs +137 -468
- package/core/src/physics/particles.d.mts +177 -0
- package/core/src/physics/particles.mjs +758 -0
- package/core/src/physics/path-joint.d.mts +171 -0
- package/core/src/physics/path-joint.mjs +1231 -0
- package/core/src/physics/physics-extended-wasm-module.generated.mjs +13 -0
- package/core/src/physics/physics-profile-wasm-module.generated.mjs +48 -0
- package/core/src/physics/physics-wasm-module.generated.mjs +34 -5
- package/core/src/physics/powered-ragdoll.d.mts +188 -0
- package/core/src/physics/powered-ragdoll.mjs +1043 -0
- package/core/src/physics/powertrain.d.mts +260 -0
- package/core/src/physics/powertrain.mjs +621 -0
- package/core/src/physics/pulley.d.mts +98 -0
- package/core/src/physics/pulley.mjs +686 -0
- package/core/src/physics/ragdoll.d.mts +289 -0
- package/core/src/physics/ragdoll.mjs +1323 -0
- package/core/src/physics/rope.d.mts +241 -0
- package/core/src/physics/rope.mjs +319 -0
- package/core/src/physics/rounded-convex.d.mts +328 -0
- package/core/src/physics/rounded-convex.mjs +1404 -0
- package/core/src/physics/sdf-geometry.d.mts +117 -0
- package/core/src/physics/sdf-geometry.mjs +1204 -0
- package/core/src/physics/soft-body.d.mts +144 -0
- package/core/src/physics/soft-body.mjs +1285 -0
- package/core/src/physics/soft-collision.d.mts +651 -0
- package/core/src/physics/soft-collision.mjs +1883 -0
- package/core/src/physics/surface-velocity.d.mts +156 -0
- package/core/src/physics/surface-velocity.mjs +722 -0
- package/core/src/physics/tracks.d.mts +411 -0
- package/core/src/physics/tracks.mjs +1074 -0
- package/core/src/physics/vehicle.d.mts +3 -0
- package/core/src/physics/vehicle.mjs +172 -0
- package/core/src/physics/voxel-cooking.d.mts +219 -0
- package/core/src/physics/voxel-cooking.mjs +1499 -0
- package/core/src/physics/voxel-swept-quad.mjs +110 -0
- package/core/src/physics/wasm-instance.mjs +160 -23
- package/core/src/physics/world.d.mts +62 -0
- package/core/src/physics/world.mjs +1947 -152
- package/core/src/physics2d/body-state.mjs +218 -15
- package/core/src/physics2d/collision.d.mts +52 -0
- package/core/src/physics2d/collision.mjs +234 -0
- package/core/src/physics2d/compound.mjs +454 -0
- package/core/src/physics2d/contour-state.mjs +771 -0
- package/core/src/physics2d/feature-api.d.mts +211 -0
- package/core/src/physics2d/feature-api.mjs +3 -0
- package/core/src/physics2d/fluid-state.mjs +145 -0
- package/core/src/physics2d/joint-state.mjs +1 -1
- package/core/src/physics2d/owned-queries.mjs +3 -1
- package/core/src/physics2d/owned-transport.mjs +268 -122
- package/core/src/physics2d/owned-world.mjs +353 -230
- package/core/src/physics2d/particle-fluid.d.mts +152 -0
- package/core/src/physics2d/particle-fluid.mjs +233 -0
- package/core/src/physics2d/physics2d-wasm-module.generated.mjs +27 -10
- package/core/src/physics2d/query-codec.mjs +61 -13
- package/core/src/physics2d/submerged-geometry.d.mts +51 -0
- package/core/src/physics2d/submerged-geometry.mjs +186 -0
- package/core/src/runtime.mjs +23 -0
- package/core/src/shared/bytes.d.mts +2 -0
- package/core/src/shared/bytes.mjs +33 -0
- package/core/src/shared/sha256.d.mts +3 -0
- package/core/src/shared/sha256.mjs +72 -22
- package/core/units.d.ts +50 -0
- package/core/world.d.ts +253 -5
- package/dist/authority-room.d.ts +9 -0
- package/dist/authority-room.js +45 -16
- package/dist/browser.d.ts +6 -5
- package/dist/browser.js +4 -3
- package/dist/cadence.d.ts +7 -0
- package/dist/cadence.js +19 -0
- package/dist/canonical.d.ts +1 -0
- package/dist/canonical.js +3 -0
- package/dist/checksum-policy.d.ts +10 -0
- package/dist/checksum-policy.js +14 -0
- package/dist/collider-cooking-hull.d.ts +18 -0
- package/dist/collider-cooking-hull.js +248 -0
- package/dist/collider-cooking.d.ts +140 -0
- package/dist/collider-cooking.js +794 -0
- package/dist/compat/v5.d.ts +121 -0
- package/dist/compat/v5.js +479 -0
- package/dist/creator.d.ts +7 -6
- package/dist/creator.js +4 -3
- package/dist/game-byte-section.d.ts +36 -0
- package/dist/game-byte-section.js +350 -0
- package/dist/index.d.ts +13 -6
- package/dist/index.js +9 -4
- package/dist/instant-replay.d.ts +27 -2
- package/dist/instant-replay.js +91 -16
- package/dist/lag-compensation3d.js +11 -10
- package/dist/match-log.d.ts +21 -4
- package/dist/match-log.js +92 -9
- package/dist/math.d.ts +2 -0
- package/dist/math.js +1 -0
- package/dist/modules/character-3d.d.ts +16 -1
- package/dist/modules/character-3d.js +42 -5
- package/dist/modules/combat.js +6 -5
- package/dist/movement3d-revision1.d.ts +2 -0
- package/dist/movement3d-revision1.js +973 -0
- package/dist/movement3d.d.ts +53 -3
- package/dist/movement3d.js +917 -247
- package/dist/networked-client.d.ts +15 -0
- package/dist/networked-client.js +378 -105
- package/dist/node.d.ts +3 -2
- package/dist/node.js +2 -1
- package/dist/physics/2d.d.ts +38 -4
- package/dist/physics/2d.js +57 -36
- package/dist/physics/3d.d.ts +755 -111
- package/dist/physics/3d.js +2355 -158
- package/dist/physics/edit-result-graph.d.ts +36 -0
- package/dist/physics/edit-result-graph.js +141 -0
- package/dist/physics/game-codec3d.d.ts +41 -0
- package/dist/physics/game-codec3d.js +544 -0
- package/dist/physics/installed-checkpoint3d.d.ts +13 -0
- package/dist/physics/installed-checkpoint3d.js +120 -0
- package/dist/physics/installed-runtime3d.d.ts +51 -0
- package/dist/physics/installed-runtime3d.js +372 -0
- package/dist/physics/installed-state-commitment3d.d.ts +2 -0
- package/dist/physics/installed-state-commitment3d.js +24 -0
- package/dist/physics/units.d.ts +38 -0
- package/dist/physics/units.js +56 -0
- package/dist/physics/vehicle-state3d.d.ts +93 -0
- package/dist/physics/vehicle-state3d.js +1191 -0
- package/dist/physics/voxel-body-state.d.ts +61 -0
- package/dist/physics/voxel-body-state.js +410 -0
- package/dist/r3f-render-adapter.d.ts +59 -1
- package/dist/r3f-render-adapter.js +137 -2
- package/dist/replay.d.ts +13 -0
- package/dist/replay.js +95 -70
- package/dist/run-room-transport.js +5 -1
- package/dist/runner.d.ts +17 -2
- package/dist/runner.js +472 -84
- package/dist/runtime-cleanup.d.ts +54 -0
- package/dist/runtime-cleanup.js +266 -0
- package/dist/runtime-lease.d.ts +11 -1
- package/dist/runtime-lease.js +23 -10
- package/dist/runtime-room-metadata.d.ts +2 -8
- package/dist/runtime-room-metadata.js +11 -14
- package/dist/runtime-session.d.ts +8 -0
- package/dist/runtime-session.js +222 -58
- package/dist/schema-codegen.js +3 -0
- package/dist/schema-dsl-binary.d.ts +10 -4
- package/dist/schema-dsl-binary.js +375 -76
- package/dist/scratch-pool.d.ts +32 -0
- package/dist/scratch-pool.js +60 -0
- package/dist/sdk-session.d.ts +1 -0
- package/dist/sdk-session.js +4 -0
- package/dist/secret-config.js +2 -60
- package/dist/secret-crypto.js +70 -36
- package/dist/session-snapshot.d.ts +15 -4
- package/dist/session-snapshot.js +35 -33
- package/dist/session-wire.js +14 -22
- package/dist/sparse-set.d.ts +1 -0
- package/dist/sparse-set.js +22 -0
- package/dist/spatial/spatial-grid-3d.d.ts +41 -0
- package/dist/spatial/spatial-grid-3d.js +115 -0
- package/dist/synctest.d.ts +9 -0
- package/dist/synctest.js +106 -17
- package/dist/testing-network.d.ts +2 -0
- package/dist/testing-network.js +122 -18
- package/dist/testing.d.ts +27 -6
- package/dist/testing.js +297 -56
- package/dist/tools/index.d.ts +3 -2
- package/dist/tools/index.js +3 -2
- package/dist/tools/module-certification.d.ts +6 -0
- package/dist/tools/module-certification.js +26 -2
- package/package.json +18 -5
- package/core/scripts/run-box3d-benchmark.mjs +0 -350
- package/core/src/physics/index.mjs +0 -3169
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Dimensionless,
|
|
3
|
+
KilogramMetersSquared,
|
|
4
|
+
Kilograms,
|
|
5
|
+
KilogramsPerSquareMeter,
|
|
6
|
+
Meters,
|
|
7
|
+
MetersPerSecond,
|
|
8
|
+
Radians,
|
|
9
|
+
RadiansPerSecond,
|
|
10
|
+
SquareMeters,
|
|
11
|
+
} from '../../units.js';
|
|
12
|
+
import type { PhysicsVertex2D } from '../../physics2d-owned.js';
|
|
13
|
+
|
|
14
|
+
export interface PhysicsCompoundTransform2D {
|
|
15
|
+
readonly position: PhysicsVertex2D<Meters>;
|
|
16
|
+
readonly angle: Radians;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type PhysicsCompoundPrimitiveShape2D =
|
|
20
|
+
| { readonly type: 'circle'; readonly radius: Meters }
|
|
21
|
+
| { readonly type: 'box'; readonly halfX: Meters; readonly halfY: Meters }
|
|
22
|
+
| {
|
|
23
|
+
readonly type: 'capsule';
|
|
24
|
+
readonly radius: Meters;
|
|
25
|
+
readonly halfLength: Meters;
|
|
26
|
+
readonly halfX?: Meters;
|
|
27
|
+
}
|
|
28
|
+
| {
|
|
29
|
+
readonly type: 'capsule';
|
|
30
|
+
readonly radius: Meters;
|
|
31
|
+
readonly halfX: Meters;
|
|
32
|
+
readonly halfLength?: Meters;
|
|
33
|
+
}
|
|
34
|
+
| { readonly type: 'polygon'; readonly vertices: readonly PhysicsVertex2D<Meters>[] };
|
|
35
|
+
|
|
36
|
+
export interface PhysicsCompoundMaterialInput2D {
|
|
37
|
+
readonly friction?: Dimensionless;
|
|
38
|
+
readonly restitution?: Dimensionless;
|
|
39
|
+
readonly density?: KilogramsPerSquareMeter;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PhysicsCompoundMaterial2D {
|
|
43
|
+
readonly friction: Dimensionless;
|
|
44
|
+
readonly restitution: Dimensionless;
|
|
45
|
+
readonly density: KilogramsPerSquareMeter;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface PhysicsCompoundFilterInput2D {
|
|
49
|
+
readonly categoryBits?: number;
|
|
50
|
+
readonly layer?: number;
|
|
51
|
+
readonly maskBits?: number;
|
|
52
|
+
readonly mask?: number;
|
|
53
|
+
readonly groupIndex?: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface PhysicsCompoundFilter2D {
|
|
57
|
+
readonly categoryBits: number;
|
|
58
|
+
readonly maskBits: number;
|
|
59
|
+
readonly groupIndex: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface PhysicsCompoundChildFields2D {
|
|
63
|
+
readonly id?: number | string;
|
|
64
|
+
readonly offset?: PhysicsVertex2D<Meters>;
|
|
65
|
+
readonly position?: PhysicsVertex2D<Meters>;
|
|
66
|
+
readonly x?: Meters;
|
|
67
|
+
readonly y?: Meters;
|
|
68
|
+
readonly angle?: Radians;
|
|
69
|
+
readonly rotation?: Radians;
|
|
70
|
+
readonly material?: PhysicsCompoundMaterialInput2D;
|
|
71
|
+
readonly friction?: Dimensionless;
|
|
72
|
+
readonly restitution?: Dimensionless;
|
|
73
|
+
readonly density?: KilogramsPerSquareMeter;
|
|
74
|
+
readonly filter?: PhysicsCompoundFilterInput2D;
|
|
75
|
+
readonly layer?: number;
|
|
76
|
+
readonly mask?: number;
|
|
77
|
+
readonly groupIndex?: number;
|
|
78
|
+
readonly sensor?: boolean;
|
|
79
|
+
readonly isSensor?: boolean;
|
|
80
|
+
readonly mass?: Kilograms;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface PhysicsCompoundChildInput2D extends PhysicsCompoundChildFields2D {
|
|
84
|
+
readonly shape?: PhysicsCompoundPrimitiveShape2D;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type PhysicsCompoundChildSource2D =
|
|
88
|
+
| PhysicsCompoundChildInput2D
|
|
89
|
+
| (PhysicsCompoundPrimitiveShape2D & PhysicsCompoundChildFields2D);
|
|
90
|
+
|
|
91
|
+
export interface PhysicsCompoundChild2D {
|
|
92
|
+
readonly id: number | string;
|
|
93
|
+
readonly shape: PhysicsCompoundPrimitiveShape2D;
|
|
94
|
+
readonly localTransform: PhysicsCompoundTransform2D;
|
|
95
|
+
readonly material: PhysicsCompoundMaterial2D;
|
|
96
|
+
readonly filter: PhysicsCompoundFilter2D;
|
|
97
|
+
readonly isSensor: boolean;
|
|
98
|
+
readonly explicitMass: Kilograms;
|
|
99
|
+
readonly primitiveArea: SquareMeters;
|
|
100
|
+
readonly primitiveCentroid: PhysicsVertex2D<Meters>;
|
|
101
|
+
readonly unitInertia: SquareMeters;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface PhysicsCompoundPrimitiveMass2D {
|
|
105
|
+
readonly area: SquareMeters;
|
|
106
|
+
readonly centroid: PhysicsVertex2D<Meters>;
|
|
107
|
+
readonly unitInertia: SquareMeters;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface PhysicsCompoundChildMass2D {
|
|
111
|
+
readonly childIndex: number;
|
|
112
|
+
readonly mass: Kilograms;
|
|
113
|
+
readonly centroid: PhysicsVertex2D<Meters>;
|
|
114
|
+
readonly inertiaAboutCentroid: KilogramMetersSquared;
|
|
115
|
+
readonly inertiaContributionCOM: KilogramMetersSquared;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface PhysicsCompoundMassProperties2D {
|
|
119
|
+
readonly totalMass: Kilograms;
|
|
120
|
+
readonly totalArea: SquareMeters;
|
|
121
|
+
readonly center: PhysicsVertex2D<Meters>;
|
|
122
|
+
readonly inertia: KilogramMetersSquared;
|
|
123
|
+
readonly inertiaAboutOrigin: KilogramMetersSquared;
|
|
124
|
+
readonly children: readonly PhysicsCompoundChildMass2D[];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface PhysicsCompoundAabb2D {
|
|
128
|
+
readonly minX: Meters;
|
|
129
|
+
readonly maxX: Meters;
|
|
130
|
+
readonly minY: Meters;
|
|
131
|
+
readonly maxY: Meters;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface PhysicsCompoundBodyInput2D {
|
|
135
|
+
readonly id?: number | string;
|
|
136
|
+
readonly kind?: string;
|
|
137
|
+
readonly x?: Meters;
|
|
138
|
+
readonly y?: Meters;
|
|
139
|
+
readonly angle?: Radians;
|
|
140
|
+
readonly vx?: MetersPerSecond;
|
|
141
|
+
readonly vy?: MetersPerSecond;
|
|
142
|
+
readonly angularVelocity?: RadiansPerSecond;
|
|
143
|
+
readonly mass?: Kilograms;
|
|
144
|
+
readonly inertia?: KilogramMetersSquared;
|
|
145
|
+
readonly children?: readonly PhysicsCompoundChildSource2D[];
|
|
146
|
+
readonly shape?: { readonly children?: readonly PhysicsCompoundChildSource2D[] };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface PhysicsCompoundBody2D {
|
|
150
|
+
readonly id: number | string;
|
|
151
|
+
readonly kind: string;
|
|
152
|
+
readonly x: Meters;
|
|
153
|
+
readonly y: Meters;
|
|
154
|
+
readonly angle: Radians;
|
|
155
|
+
readonly vx: MetersPerSecond;
|
|
156
|
+
readonly vy: MetersPerSecond;
|
|
157
|
+
readonly angularVelocity: RadiansPerSecond;
|
|
158
|
+
readonly mass: Kilograms;
|
|
159
|
+
readonly inertia: KilogramMetersSquared;
|
|
160
|
+
readonly centerOfMass: PhysicsVertex2D<Meters>;
|
|
161
|
+
readonly children: readonly PhysicsCompoundChild2D[];
|
|
162
|
+
readonly shape: {
|
|
163
|
+
readonly type: 'compound';
|
|
164
|
+
readonly children: readonly PhysicsCompoundChild2D[];
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface PhysicsCompoundFilterProbe2D {
|
|
169
|
+
readonly groupIndex?: number;
|
|
170
|
+
readonly categoryBits?: number;
|
|
171
|
+
readonly maskBits?: number;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface PhysicsFeatureApi2D {
|
|
175
|
+
readonly compoundAbi: {
|
|
176
|
+
readonly abiVersion: 1;
|
|
177
|
+
readonly maxCompoundChildren: 32;
|
|
178
|
+
readonly defaultDensity: 1;
|
|
179
|
+
};
|
|
180
|
+
rotatePoint(point: PhysicsVertex2D<Meters>, angle: Radians): PhysicsVertex2D<Meters>;
|
|
181
|
+
transformPoint(transform: PhysicsCompoundTransform2D, point: PhysicsVertex2D<Meters>): PhysicsVertex2D<Meters>;
|
|
182
|
+
inverseTransformPoint(transform: PhysicsCompoundTransform2D, point: PhysicsVertex2D<Meters>): PhysicsVertex2D<Meters>;
|
|
183
|
+
multiplyTransforms(parent: PhysicsCompoundTransform2D, child: PhysicsCompoundTransform2D): PhysicsCompoundTransform2D;
|
|
184
|
+
filterMatches(filterA: PhysicsCompoundFilterProbe2D, filterB: PhysicsCompoundFilterProbe2D): boolean;
|
|
185
|
+
combineFriction(frictionA: number, frictionB: number): number;
|
|
186
|
+
combineRestitution(restitutionA: number, restitutionB: number): number;
|
|
187
|
+
computePrimitiveMass(shape: PhysicsCompoundPrimitiveShape2D): PhysicsCompoundPrimitiveMass2D;
|
|
188
|
+
normalizeCompoundChild(input: PhysicsCompoundChildSource2D, index?: number): PhysicsCompoundChild2D;
|
|
189
|
+
computeCompoundMassProperties(
|
|
190
|
+
children: readonly (PhysicsCompoundChildSource2D | PhysicsCompoundChild2D)[],
|
|
191
|
+
totalMassOverride?: Kilograms,
|
|
192
|
+
): PhysicsCompoundMassProperties2D;
|
|
193
|
+
recenterCompoundChildren(
|
|
194
|
+
children: readonly (PhysicsCompoundChildSource2D | PhysicsCompoundChild2D)[],
|
|
195
|
+
centerOfMass: PhysicsVertex2D<Meters>,
|
|
196
|
+
): PhysicsCompoundChild2D[];
|
|
197
|
+
computeChildWorldTransform(
|
|
198
|
+
bodyTransform: PhysicsCompoundTransform2D,
|
|
199
|
+
childTransform: PhysicsCompoundTransform2D,
|
|
200
|
+
): PhysicsCompoundTransform2D;
|
|
201
|
+
computeChildAABB(child: PhysicsCompoundChild2D, bodyTransform: PhysicsCompoundTransform2D): PhysicsCompoundAabb2D;
|
|
202
|
+
computeCompoundAABB(body: {
|
|
203
|
+
readonly children: readonly PhysicsCompoundChild2D[];
|
|
204
|
+
readonly x?: Meters;
|
|
205
|
+
readonly y?: Meters;
|
|
206
|
+
readonly angle?: Radians;
|
|
207
|
+
}): PhysicsCompoundAabb2D;
|
|
208
|
+
normalizeCompoundBody(input: PhysicsCompoundBodyInput2D): PhysicsCompoundBody2D;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export const compound2D: PhysicsFeatureApi2D;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export const fluidAbi = Object.freeze({ version: 1, regionBytes: 112, stateBytes: 7176, maxRegions: 64 });
|
|
2
|
+
|
|
3
|
+
function invalid(detail) {
|
|
4
|
+
throw new Error(`KINETIX_PHYSICS2D_FLUID_INVALID: ${detail}`);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function finite(value, path, fallback) {
|
|
8
|
+
const result = value === undefined ? fallback : value;
|
|
9
|
+
if (typeof result !== 'number' || !Number.isFinite(result)) invalid(`${path} must be finite`);
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function object(value, path) {
|
|
14
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) invalid(`${path} must be an object`);
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function normalizeFluidRegions(inputs = []) {
|
|
19
|
+
if (!Array.isArray(inputs) || inputs.length > fluidAbi.maxRegions) {
|
|
20
|
+
invalid(`fluids must be an array with at most ${fluidAbi.maxRegions} regions`);
|
|
21
|
+
}
|
|
22
|
+
const regions = inputs.map((input, index) => {
|
|
23
|
+
const path = `fluids[${index}]`;
|
|
24
|
+
object(input, path);
|
|
25
|
+
if (typeof input.id !== 'string' || input.id.length === 0) invalid(`${path}.id must be a non-empty string`);
|
|
26
|
+
const bounds = object(input.bounds, `${path}.bounds`);
|
|
27
|
+
const density = finite(input.density, `${path}.density`);
|
|
28
|
+
const linearDragPerSecond = finite(input.linearDragPerSecond, `${path}.linearDragPerSecond`, 0);
|
|
29
|
+
const angularDragPerSecond = finite(input.angularDragPerSecond, `${path}.angularDragPerSecond`, 0);
|
|
30
|
+
if (density < 0 || linearDragPerSecond < 0 || angularDragPerSecond < 0) {
|
|
31
|
+
invalid(`${path} density and drag rates must be non-negative`);
|
|
32
|
+
}
|
|
33
|
+
const normalizedBounds = Object.freeze({
|
|
34
|
+
minX: finite(bounds.minX, `${path}.bounds.minX`),
|
|
35
|
+
maxX: finite(bounds.maxX, `${path}.bounds.maxX`),
|
|
36
|
+
minY: finite(bounds.minY, `${path}.bounds.minY`),
|
|
37
|
+
maxY: finite(bounds.maxY, `${path}.bounds.maxY`),
|
|
38
|
+
});
|
|
39
|
+
const flow = input.flowVelocity === undefined ? {} : object(input.flowVelocity, `${path}.flowVelocity`);
|
|
40
|
+
let plane;
|
|
41
|
+
if (input.plane !== undefined) {
|
|
42
|
+
const source = object(input.plane, `${path}.plane`);
|
|
43
|
+
const normal = object(source.normal, `${path}.plane.normal`);
|
|
44
|
+
plane = Object.freeze({
|
|
45
|
+
normal: Object.freeze({
|
|
46
|
+
x: finite(normal.x, `${path}.plane.normal.x`),
|
|
47
|
+
y: finite(normal.y, `${path}.plane.normal.y`),
|
|
48
|
+
}),
|
|
49
|
+
offset: finite(source.offset, `${path}.plane.offset`),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return Object.freeze({
|
|
53
|
+
id: input.id,
|
|
54
|
+
density,
|
|
55
|
+
linearDragPerSecond,
|
|
56
|
+
angularDragPerSecond,
|
|
57
|
+
flowVelocity: Object.freeze({
|
|
58
|
+
x: finite(flow.x, `${path}.flowVelocity.x`, 0),
|
|
59
|
+
y: finite(flow.y, `${path}.flowVelocity.y`, 0),
|
|
60
|
+
}),
|
|
61
|
+
bounds: normalizedBounds,
|
|
62
|
+
...(plane === undefined ? {} : { plane }),
|
|
63
|
+
});
|
|
64
|
+
}).sort((left, right) => left.id < right.id ? -1 : left.id > right.id ? 1 : 0);
|
|
65
|
+
for (let index = 1; index < regions.length; index += 1) {
|
|
66
|
+
if (regions[index - 1].id === regions[index].id) invalid(`duplicate region id: ${regions[index].id}`);
|
|
67
|
+
}
|
|
68
|
+
return Object.freeze(regions);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function writeFluidState(view, offset, regions) {
|
|
72
|
+
new Uint8Array(view.buffer, view.byteOffset + offset, fluidAbi.stateBytes).fill(0);
|
|
73
|
+
view.setUint32(offset, regions.length, true);
|
|
74
|
+
regions.forEach((region, index) => {
|
|
75
|
+
const start = offset + 8 + index * fluidAbi.regionBytes;
|
|
76
|
+
view.setUint32(start, index + 1, true);
|
|
77
|
+
view.setUint32(start + 4, region.plane === undefined ? 0 : 1, true);
|
|
78
|
+
const values = [
|
|
79
|
+
region.density, region.linearDragPerSecond, region.angularDragPerSecond,
|
|
80
|
+
region.flowVelocity.x, region.flowVelocity.y,
|
|
81
|
+
region.bounds.minX, region.bounds.maxX, region.bounds.minY, region.bounds.maxY,
|
|
82
|
+
region.plane?.normal.x ?? 0, region.plane?.normal.y ?? 0, region.plane?.offset ?? 0,
|
|
83
|
+
];
|
|
84
|
+
values.forEach((value, field) => view.setFloat64(start + 16 + field * 8, value, true));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function checkFluidStatus(status) {
|
|
89
|
+
if (status === 0) return;
|
|
90
|
+
if (status === -8) invalid('native validation rejected a region; check bounds, plane, density, and drag rates');
|
|
91
|
+
if (status === -9) {
|
|
92
|
+
throw new Error('KINETIX_PHYSICS2D_FLUID_OVERLAP_UNSUPPORTED: fluid interiors must not overlap; shared boundaries are allowed');
|
|
93
|
+
}
|
|
94
|
+
if (status === -10) {
|
|
95
|
+
throw new Error('KINETIX_PHYSICS2D_FLUID_NUMERIC_RANGE: reduce coordinate magnitudes, density, drag rates, or the time step');
|
|
96
|
+
}
|
|
97
|
+
if (status === -11) {
|
|
98
|
+
throw new Error('KINETIX_PHYSICS2D_FLUID_ALIASED_BUFFERS: body and fluid memory must not overlap');
|
|
99
|
+
}
|
|
100
|
+
if (status === -12) {
|
|
101
|
+
throw new Error('KINETIX_PHYSICS2D_FLUID_GEOMETRY_FAILED: the submerged shape exceeds the supported geometry range or resolution');
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`KINETIX_PHYSICS2D_FLUID_FAILED: native status ${status}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function readFluidRegion(fluidBytes) {
|
|
107
|
+
const fv = new DataView(fluidBytes.buffer, fluidBytes.byteOffset, fluidBytes.byteLength);
|
|
108
|
+
const id = fv.getUint32(0, true);
|
|
109
|
+
const planeEnabled = fv.getUint32(4, true) === 1;
|
|
110
|
+
|
|
111
|
+
const density = fv.getFloat64(16, true);
|
|
112
|
+
const linearDragPerSecond = fv.getFloat64(24, true);
|
|
113
|
+
const angularDragPerSecond = fv.getFloat64(32, true);
|
|
114
|
+
const flowVelocity = Object.freeze({
|
|
115
|
+
x: fv.getFloat64(40, true),
|
|
116
|
+
y: fv.getFloat64(48, true),
|
|
117
|
+
});
|
|
118
|
+
const bounds = Object.freeze({
|
|
119
|
+
minX: fv.getFloat64(56, true),
|
|
120
|
+
maxX: fv.getFloat64(64, true),
|
|
121
|
+
minY: fv.getFloat64(72, true),
|
|
122
|
+
maxY: fv.getFloat64(80, true),
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
let plane;
|
|
126
|
+
if (planeEnabled) {
|
|
127
|
+
plane = Object.freeze({
|
|
128
|
+
normal: Object.freeze({
|
|
129
|
+
x: fv.getFloat64(88, true),
|
|
130
|
+
y: fv.getFloat64(96, true),
|
|
131
|
+
}),
|
|
132
|
+
offset: fv.getFloat64(104, true),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return Object.freeze({
|
|
137
|
+
id,
|
|
138
|
+
density,
|
|
139
|
+
linearDragPerSecond,
|
|
140
|
+
angularDragPerSecond,
|
|
141
|
+
flowVelocity,
|
|
142
|
+
bounds,
|
|
143
|
+
...(plane !== undefined ? { plane } : {}),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
@@ -214,7 +214,7 @@ function normalizeGear(input) {
|
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
function normalizeJoint(input, bodyIds) {
|
|
217
|
+
export function normalizeJoint(input, bodyIds) {
|
|
218
218
|
object(input, 'joint');
|
|
219
219
|
const type = input.type;
|
|
220
220
|
if (typeof type !== 'string' || !Object.hasOwn(jointTypes, type)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizeShape, shapeCodes } from './body-state.mjs';
|
|
2
2
|
import {
|
|
3
3
|
normalizeRequest, queryAbi, queryFail, readCastHits, readClosestPoints,
|
|
4
|
-
readOverlap, writeFilter, writeQueryRequest,
|
|
4
|
+
readOverlap, readOverlapContacts, writeFilter, writeQueryRequest,
|
|
5
5
|
} from './query-codec.mjs';
|
|
6
6
|
|
|
7
7
|
function bodyId(value, detail) {
|
|
@@ -41,6 +41,7 @@ export function createOwnedPhysics2DQueries(world, bodyCapacity) {
|
|
|
41
41
|
}
|
|
42
42
|
const resultView = new DataView(records.buffer, records.byteOffset, records.byteLength);
|
|
43
43
|
if (kind === 'overlap') return readOverlap(resultView, 0, count, decodeBodyId);
|
|
44
|
+
if (kind === 'overlapContacts') return readOverlapContacts(resultView, 0, count, decodeBodyId);
|
|
44
45
|
if (kind === 'closestPoints') return readClosestPoints(resultView, 0, count, decodeBodyId);
|
|
45
46
|
return readCastHits(resultView, 0, count, decodeBodyId, request.maxDistance);
|
|
46
47
|
}
|
|
@@ -48,6 +49,7 @@ export function createOwnedPhysics2DQueries(world, bodyCapacity) {
|
|
|
48
49
|
return Object.freeze({
|
|
49
50
|
raycast: (input) => query('raycast', input),
|
|
50
51
|
overlap: (input) => query('overlap', input),
|
|
52
|
+
overlapContacts: (input) => query('overlapContacts', input),
|
|
51
53
|
shapeCast: (input) => query('shapeCast', input),
|
|
52
54
|
closestPoints: (input) => query('closestPoints', input),
|
|
53
55
|
});
|