@flighthq/physics3d 0.4.0-edge.1908.751021c
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/broadphase.d.ts +4 -0
- package/dist/broadphase.d.ts.map +1 -0
- package/dist/broadphase.js +158 -0
- package/dist/broadphase.js.map +1 -0
- package/dist/colliderCollision.d.ts +5 -0
- package/dist/colliderCollision.d.ts.map +1 -0
- package/dist/colliderCollision.js +55 -0
- package/dist/colliderCollision.js.map +1 -0
- package/dist/colliderTransform.d.ts +5 -0
- package/dist/colliderTransform.d.ts.map +1 -0
- package/dist/colliderTransform.js +424 -0
- package/dist/colliderTransform.js.map +1 -0
- package/dist/contactIntake.d.ts +5 -0
- package/dist/contactIntake.d.ts.map +1 -0
- package/dist/contactIntake.js +237 -0
- package/dist/contactIntake.js.map +1 -0
- package/dist/contacts.d.ts +4 -0
- package/dist/contacts.d.ts.map +1 -0
- package/dist/contacts.js +64 -0
- package/dist/contacts.js.map +1 -0
- package/dist/continuous.d.ts +5 -0
- package/dist/continuous.d.ts.map +1 -0
- package/dist/continuous.js +829 -0
- package/dist/continuous.js.map +1 -0
- package/dist/contract.d.ts +28 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +28 -0
- package/dist/contract.js.map +1 -0
- package/dist/debugGeometry.d.ts +4 -0
- package/dist/debugGeometry.d.ts.map +1 -0
- package/dist/debugGeometry.js +333 -0
- package/dist/debugGeometry.js.map +1 -0
- package/dist/enablePhysics3DGuards.d.ts +4 -0
- package/dist/enablePhysics3DGuards.d.ts.map +1 -0
- package/dist/enablePhysics3DGuards.js +155 -0
- package/dist/enablePhysics3DGuards.js.map +1 -0
- package/dist/explainPhysics3DCollision.d.ts +3 -0
- package/dist/explainPhysics3DCollision.d.ts.map +1 -0
- package/dist/explainPhysics3DCollision.js +30 -0
- package/dist/explainPhysics3DCollision.js.map +1 -0
- package/dist/explainPhysics3DJoints.d.ts +3 -0
- package/dist/explainPhysics3DJoints.d.ts.map +1 -0
- package/dist/explainPhysics3DJoints.js +32 -0
- package/dist/explainPhysics3DJoints.js.map +1 -0
- package/dist/explainPhysics3DStep.d.ts +3 -0
- package/dist/explainPhysics3DStep.d.ts.map +1 -0
- package/dist/explainPhysics3DStep.js +51 -0
- package/dist/explainPhysics3DStep.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/integrate.d.ts +6 -0
- package/dist/integrate.d.ts.map +1 -0
- package/dist/integrate.js +184 -0
- package/dist/integrate.js.map +1 -0
- package/dist/islands.d.ts +6 -0
- package/dist/islands.d.ts.map +1 -0
- package/dist/islands.js +333 -0
- package/dist/islands.js.map +1 -0
- package/dist/jointBreakage.d.ts +5 -0
- package/dist/jointBreakage.d.ts.map +1 -0
- package/dist/jointBreakage.js +44 -0
- package/dist/jointBreakage.js.map +1 -0
- package/dist/jointCollisionSuppression.d.ts +4 -0
- package/dist/jointCollisionSuppression.d.ts.map +1 -0
- package/dist/jointCollisionSuppression.js +40 -0
- package/dist/jointCollisionSuppression.js.map +1 -0
- package/dist/jointFactories.d.ts +9 -0
- package/dist/jointFactories.d.ts.map +1 -0
- package/dist/jointFactories.js +159 -0
- package/dist/jointFactories.js.map +1 -0
- package/dist/jointMath.d.ts +17 -0
- package/dist/jointMath.d.ts.map +1 -0
- package/dist/jointMath.js +361 -0
- package/dist/jointMath.js.map +1 -0
- package/dist/jointReaction.d.ts +8 -0
- package/dist/jointReaction.d.ts.map +1 -0
- package/dist/jointReaction.js +65 -0
- package/dist/jointReaction.js.map +1 -0
- package/dist/jointRegistry.d.ts +8 -0
- package/dist/jointRegistry.d.ts.map +1 -0
- package/dist/jointRegistry.js +144 -0
- package/dist/jointRegistry.js.map +1 -0
- package/dist/jointRows.d.ts +33 -0
- package/dist/jointRows.d.ts.map +1 -0
- package/dist/jointRows.js +352 -0
- package/dist/jointRows.js.map +1 -0
- package/dist/joints.d.ts +16 -0
- package/dist/joints.d.ts.map +1 -0
- package/dist/joints.js +1060 -0
- package/dist/joints.js.map +1 -0
- package/dist/massProperties.d.ts +13 -0
- package/dist/massProperties.d.ts.map +1 -0
- package/dist/massProperties.js +462 -0
- package/dist/massProperties.js.map +1 -0
- package/dist/material.d.ts +3 -0
- package/dist/material.d.ts.map +1 -0
- package/dist/material.js +13 -0
- package/dist/material.js.map +1 -0
- package/dist/nodeSync.d.ts +3 -0
- package/dist/nodeSync.d.ts.map +1 -0
- package/dist/nodeSync.js +16 -0
- package/dist/nodeSync.js.map +1 -0
- package/dist/ownership.d.ts +8 -0
- package/dist/ownership.d.ts.map +1 -0
- package/dist/ownership.js +26 -0
- package/dist/ownership.js.map +1 -0
- package/dist/physics3DBroadphasePublication.d.ts +5 -0
- package/dist/physics3DBroadphasePublication.d.ts.map +1 -0
- package/dist/physics3DBroadphasePublication.js +49 -0
- package/dist/physics3DBroadphasePublication.js.map +1 -0
- package/dist/physics3DSpatialIndexingGuards.d.ts +4 -0
- package/dist/physics3DSpatialIndexingGuards.d.ts.map +1 -0
- package/dist/physics3DSpatialIndexingGuards.js +11 -0
- package/dist/physics3DSpatialIndexingGuards.js.map +1 -0
- package/dist/registerBuiltInPhysics3DJointSolvers.d.ts +3 -0
- package/dist/registerBuiltInPhysics3DJointSolvers.d.ts.map +1 -0
- package/dist/registerBuiltInPhysics3DJointSolvers.js +15 -0
- package/dist/registerBuiltInPhysics3DJointSolvers.js.map +1 -0
- package/dist/solver.d.ts +8 -0
- package/dist/solver.d.ts.map +1 -0
- package/dist/solver.js +460 -0
- package/dist/solver.js.map +1 -0
- package/dist/step.d.ts +5 -0
- package/dist/step.d.ts.map +1 -0
- package/dist/step.js +302 -0
- package/dist/step.js.map +1 -0
- package/dist/stepValidation.d.ts +13 -0
- package/dist/stepValidation.d.ts.map +1 -0
- package/dist/stepValidation.js +284 -0
- package/dist/stepValidation.js.map +1 -0
- package/dist/symmetricTensor.d.ts +11 -0
- package/dist/symmetricTensor.d.ts.map +1 -0
- package/dist/symmetricTensor.js +150 -0
- package/dist/symmetricTensor.js.map +1 -0
- package/dist/world.d.ts +27 -0
- package/dist/world.d.ts.map +1 -0
- package/dist/world.js +762 -0
- package/dist/world.js.map +1 -0
- package/dist/worldQueries.d.ts +11 -0
- package/dist/worldQueries.d.ts.map +1 -0
- package/dist/worldQueries.js +409 -0
- package/dist/worldQueries.js.map +1 -0
- package/package.json +55 -0
- package/src/broadphase.test.ts +265 -0
- package/src/colliderCollision.test.ts +57 -0
- package/src/colliderTransform.test.ts +221 -0
- package/src/contactIntake.test.ts +370 -0
- package/src/contacts.test.ts +64 -0
- package/src/continuous.test.ts +679 -0
- package/src/debugGeometry.test.ts +288 -0
- package/src/enablePhysics3DGuards.test.ts +206 -0
- package/src/explainPhysics3DCollision.test.ts +78 -0
- package/src/explainPhysics3DJoints.test.ts +101 -0
- package/src/explainPhysics3DStep.test.ts +142 -0
- package/src/integrate.test.ts +279 -0
- package/src/islands.test.ts +384 -0
- package/src/jointBreakage.test.ts +143 -0
- package/src/jointCollisionSuppression.test.ts +94 -0
- package/src/jointFactories.test.ts +244 -0
- package/src/jointMath.test.ts +646 -0
- package/src/jointReaction.test.ts +241 -0
- package/src/jointRegistry.test.ts +229 -0
- package/src/jointRows.test.ts +548 -0
- package/src/joints.test.ts +1066 -0
- package/src/massProperties.test.ts +611 -0
- package/src/material.test.ts +40 -0
- package/src/nodeSync.test.ts +50 -0
- package/src/ownership.test.ts +61 -0
- package/src/physics3DBroadphasePublication.test.ts +63 -0
- package/src/physics3DSpatialIndexingGuards.test.ts +43 -0
- package/src/registerBuiltInPhysics3DJointSolvers.test.ts +51 -0
- package/src/solver.test.ts +567 -0
- package/src/step.test.ts +490 -0
- package/src/stepValidation.test.ts +346 -0
- package/src/stress.test.ts +526 -0
- package/src/symmetricTensor.test.ts +166 -0
- package/src/world.test.ts +1127 -0
- package/src/worldQueries.test.ts +565 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"material.d.ts","sourceRoot":"","sources":["../src/material.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1E;AAID,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE7E"}
|
package/dist/material.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Combines two Coulomb friction coefficients symmetrically. The geometric mean preserves the two
|
|
2
|
+
// properties authoring depends on: equal surfaces keep their coefficient, and either surface choosing
|
|
3
|
+
// zero makes the pair frictionless. Taking each square root before multiplying avoids an intermediate
|
|
4
|
+
// overflow for large but finite coefficients.
|
|
5
|
+
export function mixPhysics3DFriction(first, second) {
|
|
6
|
+
return Math.sqrt(first) * Math.sqrt(second);
|
|
7
|
+
}
|
|
8
|
+
// A contact uses the bouncier surface's restitution. Kept beside friction mixing so callers that author
|
|
9
|
+
// or inspect contacts can predict both combined values without duplicating step internals.
|
|
10
|
+
export function mixPhysics3DRestitution(first, second) {
|
|
11
|
+
return Math.max(first, second);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=material.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"material.js","sourceRoot":"","sources":["../src/material.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,sGAAsG;AACtG,sGAAsG;AACtG,8CAA8C;AAC9C,MAAM,UAAU,oBAAoB,CAAC,KAAa,EAAE,MAAc;IAChE,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,wGAAwG;AACxG,2FAA2F;AAC3F,MAAM,UAAU,uBAAuB,CAAC,KAAa,EAAE,MAAc;IACnE,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeSync.d.ts","sourceRoot":"","sources":["../src/nodeSync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAMpE,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CASzF"}
|
package/dist/nodeSync.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { invalidateNodeLocalTransform } from '@flighthq/node/contract';
|
|
2
|
+
// Copies a rigid body's world pose (position + orientation quaternion) onto a node's local transform
|
|
3
|
+
// fields and invalidates its matrix cache. Call once per frame after `stepPhysics3D` to drive a scene
|
|
4
|
+
// node from a simulation body. Does NOT handle centre-of-mass offset or compound collider transforms —
|
|
5
|
+
// both body and node share the same origin convention (entity centre).
|
|
6
|
+
export function syncPhysics3DBodyToNode3D(body, node) {
|
|
7
|
+
node.position.x = body.x;
|
|
8
|
+
node.position.y = body.y;
|
|
9
|
+
node.position.z = body.z;
|
|
10
|
+
node.rotation.x = body.orientationX;
|
|
11
|
+
node.rotation.y = body.orientationY;
|
|
12
|
+
node.rotation.z = body.orientationZ;
|
|
13
|
+
node.rotation.w = body.orientationW;
|
|
14
|
+
invalidateNodeLocalTransform(node);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=nodeSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeSync.js","sourceRoot":"","sources":["../src/nodeSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAGvE,qGAAqG;AACrG,sGAAsG;AACtG,uGAAuG;AACvG,uEAAuE;AACvE,MAAM,UAAU,yBAAyB,CAAC,IAA2B,EAAE,IAAY;IACjF,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACzB,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACzB,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACzB,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;IACpC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;IACpC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;IACpC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC;IACpC,4BAA4B,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Physics3DCollider, Physics3DJoint, Physics3DWorld, RigidBody3D } from '@flighthq/types/contract';
|
|
2
|
+
export declare const physics3DBodyOwners: WeakMap<RigidBody3D, Physics3DWorld>;
|
|
3
|
+
export declare const physics3DJointOwners: WeakMap<Physics3DJoint, Physics3DWorld>;
|
|
4
|
+
export declare const physics3DColliderOwners: WeakMap<Physics3DCollider, RigidBody3D>;
|
|
5
|
+
export declare const steppingPhysics3DWorlds: WeakSet<Physics3DWorld>;
|
|
6
|
+
export declare function assertPhysics3DBodyNotStepping(body: Readonly<RigidBody3D>): void;
|
|
7
|
+
export declare function assertPhysics3DWorldNotStepping(world: Readonly<Physics3DWorld>): void;
|
|
8
|
+
//# sourceMappingURL=ownership.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../src/ownership.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAO/G,eAAO,MAAM,mBAAmB,sCAA6C,CAAC;AAC9E,eAAO,MAAM,oBAAoB,yCAAgD,CAAC;AAKlF,eAAO,MAAM,uBAAuB,yCAAgD,CAAC;AAKrF,eAAO,MAAM,uBAAuB,yBAAgC,CAAC;AAErE,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAGhF;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,IAAI,CAIrF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Ownership is RUNTIME state rather than serialized entity data. Weak keys make membership follow the
|
|
2
|
+
// explicit add/remove lifecycle without keeping a detached entity alive, and map directly to an owner
|
|
3
|
+
// pointer in the native port. They are what stops one mutable body or joint — and the contact or joint
|
|
4
|
+
// impulse cache that rides on it — from participating in two solve lists at once, where each world's
|
|
5
|
+
// iterations would overwrite the other's state every step.
|
|
6
|
+
export const physics3DBodyOwners = new WeakMap();
|
|
7
|
+
export const physics3DJointOwners = new WeakMap();
|
|
8
|
+
// The same rule one level down. A collider carries the world-space shape its body's pose is written
|
|
9
|
+
// into, so sharing one between two bodies would have each step's transform overwrite the other's — and
|
|
10
|
+
// the narrow phase would then test both bodies against whichever pose happened to be written last.
|
|
11
|
+
export const physics3DColliderOwners = new WeakMap();
|
|
12
|
+
// A world step is a strict mutation boundary. Contact hooks run inside it and may change only the contact
|
|
13
|
+
// fields their contract names: adding or removing a body, contact, or joint while an array is being solved
|
|
14
|
+
// can skip a constraint, partially integrate a newly-added body, or invalidate the iterator outright.
|
|
15
|
+
export const steppingPhysics3DWorlds = new WeakSet();
|
|
16
|
+
export function assertPhysics3DBodyNotStepping(body) {
|
|
17
|
+
const world = physics3DBodyOwners.get(body);
|
|
18
|
+
if (world !== undefined)
|
|
19
|
+
assertPhysics3DWorldNotStepping(world);
|
|
20
|
+
}
|
|
21
|
+
export function assertPhysics3DWorldNotStepping(world) {
|
|
22
|
+
if (steppingPhysics3DWorlds.has(world)) {
|
|
23
|
+
throw new Error('Cannot mutate a physics world while it is stepping');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ownership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownership.js","sourceRoot":"","sources":["../src/ownership.ts"],"names":[],"mappings":"AAEA,sGAAsG;AACtG,sGAAsG;AACtG,uGAAuG;AACvG,qGAAqG;AACrG,2DAA2D;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAA+B,CAAC;AAC9E,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,OAAO,EAAkC,CAAC;AAElF,oGAAoG;AACpG,uGAAuG;AACvG,mGAAmG;AACnG,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAAkC,CAAC;AAErF,0GAA0G;AAC1G,2GAA2G;AAC3G,sGAAsG;AACtG,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,OAAO,EAAkB,CAAC;AAErE,MAAM,UAAU,8BAA8B,CAAC,IAA2B;IACxE,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,IAAmB,CAAC,CAAC;IAC3D,IAAI,KAAK,KAAK,SAAS;QAAE,+BAA+B,CAAC,KAAK,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,KAA+B;IAC7E,IAAI,uBAAuB,CAAC,GAAG,CAAC,KAAuB,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Physics3DWorld, SpatialAabb3D } from '@flighthq/types/contract';
|
|
2
|
+
export declare function getPhysics3DBroadphaseBodyIndices(world: Physics3DWorld): Set<number>;
|
|
3
|
+
export declare function publishPhysics3DBroadphaseBody(world: Physics3DWorld, bodyIndex: number, bounds: Readonly<SpatialAabb3D>, bodyIndices?: Set<number>): void;
|
|
4
|
+
export declare function withdrawPhysics3DBroadphaseBody(world: Physics3DWorld, bodyIndex: number, bodyIndices?: Set<number>): void;
|
|
5
|
+
//# sourceMappingURL=physics3DBroadphasePublication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"physics3DBroadphasePublication.d.ts","sourceRoot":"","sources":["../src/physics3DBroadphasePublication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9E,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,CAepF;AAMD,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC/B,WAAW,cAA2C,GACrD,IAAI,CAaN;AAKD,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,cAAc,EACrB,SAAS,EAAE,MAAM,EACjB,WAAW,cAA2C,GACrD,IAAI,CAQN"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export function getPhysics3DBroadphaseBodyIndices(world) {
|
|
2
|
+
const existing = physics3DBroadphasePublicationByWorld.get(world);
|
|
3
|
+
if (existing !== undefined && existing.index === world.index)
|
|
4
|
+
return existing.bodyIndices;
|
|
5
|
+
// A hydrated world or a caller-supplied pre-populated backend can already hold bodies before this
|
|
6
|
+
// module has observed it. Rebuild once when the world/index pairing is first seen (and whenever the
|
|
7
|
+
// public backend reference changes), then maintain the set alongside physics3d's own operations.
|
|
8
|
+
const bodyIndices = new Set();
|
|
9
|
+
for (let bodyIndex = 0; bodyIndex < world.bodies.length; bodyIndex += 1) {
|
|
10
|
+
const id = world.bodies[bodyIndex].index;
|
|
11
|
+
if (world.index.explainSpatialIndexing(id).mode !== 'absent')
|
|
12
|
+
bodyIndices.add(id);
|
|
13
|
+
}
|
|
14
|
+
const created = { bodyIndices, index: world.index };
|
|
15
|
+
physics3DBroadphasePublicationByWorld.set(world, created);
|
|
16
|
+
return created.bodyIndices;
|
|
17
|
+
}
|
|
18
|
+
// Uses the backend's distinct insert/update vocabulary even though update is contractually an upsert. The
|
|
19
|
+
// latter is result-correct, but spatial diagnostics deliberately report update of a missing id as a
|
|
20
|
+
// lifecycle fault. Physics3d knows whether it has published each body, so preserving that information
|
|
21
|
+
// keeps a supported add-body-then-add-collider sequence silent without paying explain() on the hot path.
|
|
22
|
+
export function publishPhysics3DBroadphaseBody(world, bodyIndex, bounds, bodyIndices = getPhysics3DBroadphaseBodyIndices(world)) {
|
|
23
|
+
if (bodyIndices.has(bodyIndex)) {
|
|
24
|
+
const updated = world.index.updateSpatialObject(bodyIndex, bounds);
|
|
25
|
+
if (!updated && world.index.explainSpatialIndexing(bodyIndex).mode === 'absent') {
|
|
26
|
+
bodyIndices.delete(bodyIndex);
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const inserted = world.index.insertSpatialObject(bodyIndex, bounds);
|
|
31
|
+
if (inserted || world.index.explainSpatialIndexing(bodyIndex).mode !== 'absent') {
|
|
32
|
+
bodyIndices.add(bodyIndex);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Removes a body's publication only when physics3d previously placed it in the backend. A colliderless
|
|
36
|
+
// body is valid authored state, and repeatedly asking the backend to remove its never-published id would
|
|
37
|
+
// turn that ordinary state into a false `missing-id` lifecycle notice whenever spatial diagnostics are on.
|
|
38
|
+
export function withdrawPhysics3DBroadphaseBody(world, bodyIndex, bodyIndices = getPhysics3DBroadphaseBodyIndices(world)) {
|
|
39
|
+
if (!bodyIndices.delete(bodyIndex)) {
|
|
40
|
+
// A caller-supplied backend may already contain the id when physics3d first sees it. Consult the
|
|
41
|
+
// backend only on this uncommon withdrawal path so stale external publication is still removed
|
|
42
|
+
// without adding another map lookup to every moving body on every step.
|
|
43
|
+
if (world.index.explainSpatialIndexing(bodyIndex).mode === 'absent')
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
world.index.removeSpatialObject(bodyIndex);
|
|
47
|
+
}
|
|
48
|
+
const physics3DBroadphasePublicationByWorld = new WeakMap();
|
|
49
|
+
//# sourceMappingURL=physics3DBroadphasePublication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"physics3DBroadphasePublication.js","sourceRoot":"","sources":["../src/physics3DBroadphasePublication.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,iCAAiC,CAAC,KAAqB;IACrE,MAAM,QAAQ,GAAG,qCAAqC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAClE,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK;QAAE,OAAO,QAAQ,CAAC,WAAW,CAAC;IAE1F,kGAAkG;IAClG,oGAAoG;IACpG,iGAAiG;IACjG,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,KAAK,IAAI,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE,CAAC;QACxE,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC;QACzC,IAAI,KAAK,CAAC,KAAK,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,QAAQ;YAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;IACD,MAAM,OAAO,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IACpD,qCAAqC,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC1D,OAAO,OAAO,CAAC,WAAW,CAAC;AAC7B,CAAC;AAED,0GAA0G;AAC1G,oGAAoG;AACpG,sGAAsG;AACtG,yGAAyG;AACzG,MAAM,UAAU,8BAA8B,CAC5C,KAAqB,EACrB,SAAiB,EACjB,MAA+B,EAC/B,WAAW,GAAG,iCAAiC,CAAC,KAAK,CAAC;IAEtD,IAAI,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACnE,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAChF,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC;QACD,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACpE,IAAI,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAChF,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,uGAAuG;AACvG,yGAAyG;AACzG,2GAA2G;AAC3G,MAAM,UAAU,+BAA+B,CAC7C,KAAqB,EACrB,SAAiB,EACjB,WAAW,GAAG,iCAAiC,CAAC,KAAK,CAAC;IAEtD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;QACnC,iGAAiG;QACjG,+FAA+F;QAC/F,wEAAwE;QACxE,IAAI,KAAK,CAAC,KAAK,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO;IAC9E,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC;AAOD,MAAM,qCAAqC,GAAG,IAAI,OAAO,EAAkD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Physics3DWorld } from '@flighthq/types/contract';
|
|
2
|
+
export declare function reportPhysics3DSpatialIndexing(world: Readonly<Physics3DWorld>): void;
|
|
3
|
+
export declare function setPhysics3DSpatialIndexingGuard(guard: ((world: Readonly<Physics3DWorld>) => void) | null): void;
|
|
4
|
+
//# sourceMappingURL=physics3DSpatialIndexingGuards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"physics3DSpatialIndexingGuards.d.ts","sourceRoot":"","sources":["../src/physics3DSpatialIndexingGuards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK/D,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,IAAI,CAEpF;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC,GAAG,IAAI,GAAG,IAAI,CAEhH"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The core-side seam for physics3d's spatial outcome diagnostics. It is deliberately local rather than
|
|
2
|
+
// installing spatial's global caller-composed guard: doing that would overwrite application policy and
|
|
3
|
+
// receive notices from every unrelated 2D and 3D index in the process.
|
|
4
|
+
export function reportPhysics3DSpatialIndexing(world) {
|
|
5
|
+
physics3DSpatialIndexingGuard?.(world);
|
|
6
|
+
}
|
|
7
|
+
export function setPhysics3DSpatialIndexingGuard(guard) {
|
|
8
|
+
physics3DSpatialIndexingGuard = guard;
|
|
9
|
+
}
|
|
10
|
+
let physics3DSpatialIndexingGuard = null;
|
|
11
|
+
//# sourceMappingURL=physics3DSpatialIndexingGuards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"physics3DSpatialIndexingGuards.js","sourceRoot":"","sources":["../src/physics3DSpatialIndexingGuards.ts"],"names":[],"mappings":"AAEA,uGAAuG;AACvG,uGAAuG;AACvG,uEAAuE;AACvE,MAAM,UAAU,8BAA8B,CAAC,KAA+B;IAC5E,6BAA6B,EAAE,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,KAAyD;IACxG,6BAA6B,GAAG,KAAK,CAAC;AACxC,CAAC;AAED,IAAI,6BAA6B,GAAuD,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerBuiltInPhysics3DJointSolvers.d.ts","sourceRoot":"","sources":["../src/registerBuiltInPhysics3DJointSolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAuB/D,wBAAgB,oCAAoC,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAQhF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { registerPhysics3DJointSolver } from './jointRegistry';
|
|
2
|
+
import { physics3DBallAndSocketJointSolver, physics3DConeTwistJointSolver, physics3DDistanceJointSolver, physics3DFixedJointSolver, physics3DGeneric6DofJointSolver, physics3DHingeJointSolver, physics3DSliderJointSolver, Physics3DBallAndSocketJointKind, Physics3DConeTwistJointKind, Physics3DDistanceJointKind, Physics3DFixedJointKind, Physics3DGeneric6DofJointKind, Physics3DHingeJointKind, Physics3DSliderJointKind, } from './joints';
|
|
3
|
+
// Installs the complete built-in joint bank into one world. Kept as an explicit assembly rather than as part
|
|
4
|
+
// of `createPhysics3DWorld`: importing or constructing a world still links no constraint math, and a caller
|
|
5
|
+
// may register only the kinds it uses. Importing this function opts into all six at once.
|
|
6
|
+
export function registerBuiltInPhysics3DJointSolvers(world) {
|
|
7
|
+
registerPhysics3DJointSolver(world, Physics3DBallAndSocketJointKind, physics3DBallAndSocketJointSolver);
|
|
8
|
+
registerPhysics3DJointSolver(world, Physics3DConeTwistJointKind, physics3DConeTwistJointSolver);
|
|
9
|
+
registerPhysics3DJointSolver(world, Physics3DDistanceJointKind, physics3DDistanceJointSolver);
|
|
10
|
+
registerPhysics3DJointSolver(world, Physics3DFixedJointKind, physics3DFixedJointSolver);
|
|
11
|
+
registerPhysics3DJointSolver(world, Physics3DGeneric6DofJointKind, physics3DGeneric6DofJointSolver);
|
|
12
|
+
registerPhysics3DJointSolver(world, Physics3DHingeJointKind, physics3DHingeJointSolver);
|
|
13
|
+
registerPhysics3DJointSolver(world, Physics3DSliderJointKind, physics3DSliderJointSolver);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=registerBuiltInPhysics3DJointSolvers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerBuiltInPhysics3DJointSolvers.js","sourceRoot":"","sources":["../src/registerBuiltInPhysics3DJointSolvers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,iCAAiC,EACjC,6BAA6B,EAC7B,4BAA4B,EAC5B,yBAAyB,EACzB,+BAA+B,EAC/B,yBAAyB,EACzB,0BAA0B,EAC1B,+BAA+B,EAC/B,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,6BAA6B,EAC7B,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAElB,6GAA6G;AAC7G,4GAA4G;AAC5G,0FAA0F;AAC1F,MAAM,UAAU,oCAAoC,CAAC,KAAqB;IACxE,4BAA4B,CAAC,KAAK,EAAE,+BAA+B,EAAE,iCAAiC,CAAC,CAAC;IACxG,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,EAAE,6BAA6B,CAAC,CAAC;IAChG,4BAA4B,CAAC,KAAK,EAAE,0BAA0B,EAAE,4BAA4B,CAAC,CAAC;IAC9F,4BAA4B,CAAC,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,CAAC,CAAC;IACxF,4BAA4B,CAAC,KAAK,EAAE,6BAA6B,EAAE,+BAA+B,CAAC,CAAC;IACpG,4BAA4B,CAAC,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,CAAC,CAAC;IACxF,4BAA4B,CAAC,KAAK,EAAE,wBAAwB,EAAE,0BAA0B,CAAC,CAAC;AAC5F,CAAC"}
|
package/dist/solver.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Physics3DContactConstraint, Physics3DContactConstraintPoint, Physics3DWorld } from '@flighthq/types/contract';
|
|
2
|
+
export declare function createPhysics3DContactConstraint(): Physics3DContactConstraint;
|
|
3
|
+
export declare function createPhysics3DContactConstraintPoint(): Physics3DContactConstraintPoint;
|
|
4
|
+
export declare function preparePhysics3DContactConstraints(world: Physics3DWorld): void;
|
|
5
|
+
export declare function solvePhysics3DContactPositions(world: Physics3DWorld): number;
|
|
6
|
+
export declare function solvePhysics3DContactVelocities(world: Physics3DWorld): void;
|
|
7
|
+
export declare function warmStartPhysics3DContacts(world: Physics3DWorld): void;
|
|
8
|
+
//# sourceMappingURL=solver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solver.d.ts","sourceRoot":"","sources":["../src/solver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,0BAA0B,EAC1B,+BAA+B,EAC/B,cAAc,EAEf,MAAM,0BAA0B,CAAC;AAiBlC,wBAAgB,gCAAgC,IAAI,0BAA0B,CAY7E;AAID,wBAAgB,qCAAqC,IAAI,+BAA+B,CAWvF;AA+BD,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAqI9E;AAqBD,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAO5E;AAoFD,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAuG3E;AAOD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAmCtE"}
|