• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

excaliburjs / Excalibur / 15354777440

30 May 2025 08:03PM UTC coverage: 87.858% (-1.5%) from 89.344%
15354777440

Pull #3385

github

web-flow
Merge a00f57733 into e6ec66358
Pull Request #3385: updated Meet action to add tolerance

5002 of 6948 branches covered (71.99%)

3 of 5 new or added lines in 2 files covered. (60.0%)

872 existing lines in 83 files now uncovered.

13661 of 15549 relevant lines covered (87.86%)

25187.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.43
/src/engine/Collision/MotionSystem.ts
1
import type { Entity, Query, World } from '../EntityComponentSystem';
2
import { SystemPriority } from '../EntityComponentSystem';
3
import { MotionComponent } from '../EntityComponentSystem/Components/MotionComponent';
4
import { TransformComponent } from '../EntityComponentSystem/Components/TransformComponent';
5
import { System, SystemType } from '../EntityComponentSystem/System';
6
import { BodyComponent } from './BodyComponent';
7
import { CollisionType } from './CollisionType';
8
import { EulerIntegrator } from './Integrator';
9
import type { PhysicsWorld } from './PhysicsWorld';
10

11
export class MotionSystem extends System {
117✔
12
  static priority = SystemPriority.Higher;
13

14
  public systemType = SystemType.Update;
1,351✔
15
  private _physicsConfigDirty = false;
1,351✔
16
  query: Query<typeof TransformComponent | typeof MotionComponent>;
17
  constructor(
18
    public world: World,
1,351✔
19
    public physics: PhysicsWorld
1,351✔
20
  ) {
21
    super();
1,351✔
22
    physics.$configUpdate.subscribe(() => (this._physicsConfigDirty = true));
1,351✔
23
    this.query = this.world.query([TransformComponent, MotionComponent]);
1,351✔
24
  }
25

26
  update(elapsed: number): void {
27
    let transform: TransformComponent;
28
    let motion: MotionComponent;
29
    const entities = this.query.entities;
1,802✔
30
    const substep = this.physics.config.substep;
1,802✔
31

32
    for (let i = 0; i < entities.length; i++) {
1,802✔
33
      transform = entities[i].get(TransformComponent);
2,354✔
34
      motion = entities[i].get(MotionComponent);
2,354✔
35

36
      const optionalBody = entities[i].get(BodyComponent);
2,354✔
37
      if (this._physicsConfigDirty && optionalBody) {
2,354✔
38
        optionalBody.updatePhysicsConfig(this.physics.config.bodies);
311✔
39
      }
40

41
      if (optionalBody?.isSleeping) {
2,354!
UNCOV
42
        continue;
×
43
      }
44

45
      const totalAcc = motion.acc.clone();
2,354✔
46
      if (optionalBody?.collisionType === CollisionType.Active && optionalBody?.useGravity) {
2,354!
47
        totalAcc.addEqual(this.physics.config.gravity);
329✔
48
      }
49

50
      // capture old transform of this entity and all of its children so that
51
      // any transform properties that derived from their parents are properly captured
52
      if (!entities[i].parent) {
2,354✔
53
        this.captureOldTransformWithChildren(entities[i]);
2,331✔
54
      }
55

56
      // Update transform and motion based on Euler linear algebra
57
      EulerIntegrator.integrate(transform, motion, totalAcc, elapsed / substep);
2,354✔
58
    }
59
    this._physicsConfigDirty = false;
1,802✔
60
  }
61

62
  captureOldTransformWithChildren(entity: Entity) {
63
    entity.get(BodyComponent)?.captureOldTransform();
3,248✔
64

65
    for (let i = 0; i < entity.children.length; i++) {
3,248✔
66
      this.captureOldTransformWithChildren(entity.children[i]);
917✔
67
    }
68
  }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc