@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,61 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
assertPhysics3DBodyNotStepping,
|
|
5
|
+
assertPhysics3DWorldNotStepping,
|
|
6
|
+
physics3DBodyOwners,
|
|
7
|
+
physics3DJointOwners,
|
|
8
|
+
steppingPhysics3DWorlds,
|
|
9
|
+
} from './ownership';
|
|
10
|
+
import { addPhysics3DBody, createPhysics3DWorld, createRigidBody3D } from './world';
|
|
11
|
+
|
|
12
|
+
describe('assertPhysics3DBodyNotStepping', () => {
|
|
13
|
+
it('resolves the owning world and refuses mutation during its step', () => {
|
|
14
|
+
const world = createPhysics3DWorld();
|
|
15
|
+
const body = createRigidBody3D();
|
|
16
|
+
addPhysics3DBody(world, body);
|
|
17
|
+
steppingPhysics3DWorlds.add(world);
|
|
18
|
+
|
|
19
|
+
expect(() => assertPhysics3DBodyNotStepping(body)).toThrow();
|
|
20
|
+
|
|
21
|
+
steppingPhysics3DWorlds.delete(world);
|
|
22
|
+
expect(() => assertPhysics3DBodyNotStepping(body)).not.toThrow();
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('assertPhysics3DWorldNotStepping', () => {
|
|
27
|
+
it('permits a mutation outside the step', () => {
|
|
28
|
+
expect(() => assertPhysics3DWorldNotStepping(createPhysics3DWorld())).not.toThrow();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('refuses a mutation while the world is stepping', () => {
|
|
32
|
+
const world = createPhysics3DWorld();
|
|
33
|
+
steppingPhysics3DWorlds.add(world);
|
|
34
|
+
|
|
35
|
+
expect(() => assertPhysics3DWorldNotStepping(world)).toThrow();
|
|
36
|
+
|
|
37
|
+
steppingPhysics3DWorlds.delete(world);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('tracks each world separately', () => {
|
|
41
|
+
const stepping = createPhysics3DWorld();
|
|
42
|
+
const idle = createPhysics3DWorld();
|
|
43
|
+
steppingPhysics3DWorlds.add(stepping);
|
|
44
|
+
|
|
45
|
+
expect(() => assertPhysics3DWorldNotStepping(idle)).not.toThrow();
|
|
46
|
+
|
|
47
|
+
steppingPhysics3DWorlds.delete(stepping);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('keeps joint ownership out of the serializable world record', () => {
|
|
51
|
+
// Ownership is runtime state: a world reconstructed by a format layer carries no owner map, and rebuilding
|
|
52
|
+
// one is the add path's job rather than something the record has to round-trip.
|
|
53
|
+
expect(physics3DJointOwners).toBeInstanceOf(WeakMap);
|
|
54
|
+
expect(Object.keys(createPhysics3DWorld())).not.toContain('jointOwners');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('keeps body ownership out of the serializable world record', () => {
|
|
58
|
+
expect(physics3DBodyOwners).toBeInstanceOf(WeakMap);
|
|
59
|
+
expect(Object.keys(createPhysics3DWorld())).not.toContain('bodyOwners');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createBvhSpatialBackend3D, setSpatialIndexingGuard } from '@flighthq/spatial/contract';
|
|
2
|
+
import type { SpatialAabb3D, SpatialIndexingNotice } from '@flighthq/types/contract';
|
|
3
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
getPhysics3DBroadphaseBodyIndices,
|
|
7
|
+
publishPhysics3DBroadphaseBody,
|
|
8
|
+
withdrawPhysics3DBroadphaseBody,
|
|
9
|
+
} from './physics3DBroadphasePublication';
|
|
10
|
+
import { createPhysics3DWorld } from './world';
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
setSpatialIndexingGuard(null);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe('getPhysics3DBroadphaseBodyIndices', () => {
|
|
17
|
+
it('retains publication state for one backend and rebuilds it when the backend changes', () => {
|
|
18
|
+
const world = createPhysics3DWorld();
|
|
19
|
+
const first = getPhysics3DBroadphaseBodyIndices(world);
|
|
20
|
+
first.add(7);
|
|
21
|
+
expect(getPhysics3DBroadphaseBodyIndices(world)).toBe(first);
|
|
22
|
+
|
|
23
|
+
world.index = createBvhSpatialBackend3D();
|
|
24
|
+
|
|
25
|
+
const replaced = getPhysics3DBroadphaseBodyIndices(world);
|
|
26
|
+
expect(replaced).not.toBe(first);
|
|
27
|
+
expect(replaced.size).toBe(0);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('publishPhysics3DBroadphaseBody', () => {
|
|
32
|
+
it('inserts once and then updates without reporting a missing-id lifecycle fault', () => {
|
|
33
|
+
const notices: SpatialIndexingNotice[] = [];
|
|
34
|
+
setSpatialIndexingGuard((notice) => notices.push({ ...notice }));
|
|
35
|
+
const world = createPhysics3DWorld();
|
|
36
|
+
|
|
37
|
+
publishPhysics3DBroadphaseBody(world, 7, box(0));
|
|
38
|
+
publishPhysics3DBroadphaseBody(world, 7, box(1));
|
|
39
|
+
|
|
40
|
+
expect(world.index.explainSpatialIndexing(7).mode).toBe('cells');
|
|
41
|
+
expect(notices.filter((notice) => notice.reason === 'missing-id')).toEqual([]);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('withdrawPhysics3DBroadphaseBody', () => {
|
|
46
|
+
it('removes a publication once and leaves a never-published id alone', () => {
|
|
47
|
+
const notices: SpatialIndexingNotice[] = [];
|
|
48
|
+
setSpatialIndexingGuard((notice) => notices.push({ ...notice }));
|
|
49
|
+
const world = createPhysics3DWorld();
|
|
50
|
+
|
|
51
|
+
withdrawPhysics3DBroadphaseBody(world, 8);
|
|
52
|
+
publishPhysics3DBroadphaseBody(world, 7, box(0));
|
|
53
|
+
withdrawPhysics3DBroadphaseBody(world, 7);
|
|
54
|
+
withdrawPhysics3DBroadphaseBody(world, 7);
|
|
55
|
+
|
|
56
|
+
expect(world.index.explainSpatialIndexing(7).mode).toBe('absent');
|
|
57
|
+
expect(notices.filter((notice) => notice.reason === 'missing-id')).toEqual([]);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
function box(offset: number): SpatialAabb3D {
|
|
62
|
+
return { minX: offset, minY: 0, minZ: 0, maxX: offset + 1, maxY: 1, maxZ: 1 };
|
|
63
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Physics3DWorld } from '@flighthq/types/contract';
|
|
2
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { reportPhysics3DSpatialIndexing, setPhysics3DSpatialIndexingGuard } from './physics3DSpatialIndexingGuards';
|
|
5
|
+
import { createPhysics3DWorld } from './world';
|
|
6
|
+
|
|
7
|
+
afterEach(() => {
|
|
8
|
+
setPhysics3DSpatialIndexingGuard(null);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
describe('reportPhysics3DSpatialIndexing', () => {
|
|
12
|
+
it('reports the world only while the optional seam is installed', () => {
|
|
13
|
+
const world = createPhysics3DWorld();
|
|
14
|
+
const received: Readonly<Physics3DWorld>[] = [];
|
|
15
|
+
|
|
16
|
+
reportPhysics3DSpatialIndexing(world);
|
|
17
|
+
setPhysics3DSpatialIndexingGuard((reported) => received.push(reported));
|
|
18
|
+
reportPhysics3DSpatialIndexing(world);
|
|
19
|
+
setPhysics3DSpatialIndexingGuard(null);
|
|
20
|
+
reportPhysics3DSpatialIndexing(world);
|
|
21
|
+
|
|
22
|
+
expect(received).toEqual([world]);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('setPhysics3DSpatialIndexingGuard', () => {
|
|
27
|
+
it('replaces the previous guard instead of accumulating callbacks', () => {
|
|
28
|
+
const world = createPhysics3DWorld();
|
|
29
|
+
let firstCalls = 0;
|
|
30
|
+
let secondCalls = 0;
|
|
31
|
+
setPhysics3DSpatialIndexingGuard(() => {
|
|
32
|
+
firstCalls += 1;
|
|
33
|
+
});
|
|
34
|
+
setPhysics3DSpatialIndexingGuard(() => {
|
|
35
|
+
secondCalls += 1;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
reportPhysics3DSpatialIndexing(world);
|
|
39
|
+
|
|
40
|
+
expect(firstCalls).toBe(0);
|
|
41
|
+
expect(secondCalls).toBe(1);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { getPhysics3DJointSolver } from './jointRegistry';
|
|
4
|
+
import {
|
|
5
|
+
physics3DBallAndSocketJointSolver,
|
|
6
|
+
physics3DConeTwistJointSolver,
|
|
7
|
+
physics3DDistanceJointSolver,
|
|
8
|
+
physics3DFixedJointSolver,
|
|
9
|
+
physics3DGeneric6DofJointSolver,
|
|
10
|
+
physics3DHingeJointSolver,
|
|
11
|
+
physics3DSliderJointSolver,
|
|
12
|
+
Physics3DBallAndSocketJointKind,
|
|
13
|
+
Physics3DConeTwistJointKind,
|
|
14
|
+
Physics3DDistanceJointKind,
|
|
15
|
+
Physics3DFixedJointKind,
|
|
16
|
+
Physics3DGeneric6DofJointKind,
|
|
17
|
+
Physics3DHingeJointKind,
|
|
18
|
+
Physics3DSliderJointKind,
|
|
19
|
+
} from './joints';
|
|
20
|
+
import { registerBuiltInPhysics3DJointSolvers } from './registerBuiltInPhysics3DJointSolvers';
|
|
21
|
+
import { createPhysics3DWorld } from './world';
|
|
22
|
+
|
|
23
|
+
describe('registerBuiltInPhysics3DJointSolvers', () => {
|
|
24
|
+
it('binds every built-in kind to its own solver', () => {
|
|
25
|
+
const world = createPhysics3DWorld();
|
|
26
|
+
|
|
27
|
+
registerBuiltInPhysics3DJointSolvers(world);
|
|
28
|
+
|
|
29
|
+
expect(getPhysics3DJointSolver(world, Physics3DBallAndSocketJointKind)).toBe(physics3DBallAndSocketJointSolver);
|
|
30
|
+
expect(getPhysics3DJointSolver(world, Physics3DConeTwistJointKind)).toBe(physics3DConeTwistJointSolver);
|
|
31
|
+
expect(getPhysics3DJointSolver(world, Physics3DDistanceJointKind)).toBe(physics3DDistanceJointSolver);
|
|
32
|
+
expect(getPhysics3DJointSolver(world, Physics3DFixedJointKind)).toBe(physics3DFixedJointSolver);
|
|
33
|
+
expect(getPhysics3DJointSolver(world, Physics3DGeneric6DofJointKind)).toBe(physics3DGeneric6DofJointSolver);
|
|
34
|
+
expect(getPhysics3DJointSolver(world, Physics3DHingeJointKind)).toBe(physics3DHingeJointSolver);
|
|
35
|
+
expect(getPhysics3DJointSolver(world, Physics3DSliderJointKind)).toBe(physics3DSliderJointSolver);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('registers the whole bank and nothing else', () => {
|
|
39
|
+
const world = createPhysics3DWorld();
|
|
40
|
+
|
|
41
|
+
registerBuiltInPhysics3DJointSolvers(world);
|
|
42
|
+
|
|
43
|
+
expect(world.jointSolvers.size).toBe(7);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('leaves a world that never calls it with no solvers at all', () => {
|
|
47
|
+
// Registration is explicit rather than part of world construction, so constructing a world links no
|
|
48
|
+
// constraint math and a caller may register only the kinds it uses.
|
|
49
|
+
expect(createPhysics3DWorld().jointSolvers.size).toBe(0);
|
|
50
|
+
});
|
|
51
|
+
});
|