* This function is used to test the api of the CharacterController
(cct: physics.CharacterController)
| 8 | * This function is used to test the api of the CharacterController |
| 9 | */ |
| 10 | function testCharacterControllerAPIs(cct: physics.CharacterController){ |
| 11 | cct.minMoveDistance = 0.001; |
| 12 | expect(cct.minMoveDistance === 0.001).toBe(true); |
| 13 | |
| 14 | cct.stepOffset = 0.5; |
| 15 | expect(cct.stepOffset === 0.5).toBe(true); |
| 16 | |
| 17 | cct.slopeLimit = 60; |
| 18 | expect(cct.slopeLimit === 60).toBe(true); |
| 19 | |
| 20 | cct.skinWidth = 0.01; |
| 21 | expect(cct.skinWidth === 0.01).toBe(true); |
| 22 | |
| 23 | cct.center = new Vec3(0, 0.5, 0); |
| 24 | expect(Vec3.equals(cct.center, new Vec3(0, 0.5, 0))).toBe(true); |
| 25 | |
| 26 | let targetPos = new Vec3(0, 10, 0); |
| 27 | cct.centerWorldPosition = targetPos; |
| 28 | let newPos = new Vec3(); |
| 29 | newPos.set(cct.centerWorldPosition); |
| 30 | expect(Vec3.equals(newPos, targetPos)).toBe(true); |
| 31 | |
| 32 | { |
| 33 | cct.move(new Vec3(0, 0, 0)); |
| 34 | const dt = physics.PhysicsSystem.instance.fixedTimeStep; |
| 35 | director.tick(dt); |
| 36 | let newPos = new Vec3(); |
| 37 | newPos.set(cct.centerWorldPosition); |
| 38 | expect(Vec3.equals(newPos, targetPos)).toBe(true); |
| 39 | } |
| 40 | { |
| 41 | let movement = new Vec3(0, 10, 0); |
| 42 | Vec3.add(targetPos, targetPos, movement); |
| 43 | cct.move(movement); |
| 44 | const dt = physics.PhysicsSystem.instance.fixedTimeStep; |
| 45 | director.tick(dt); |
| 46 | let newPos = new Vec3(); |
| 47 | newPos.set(cct.centerWorldPosition); |
| 48 | expect(Vec3.equals(newPos, targetPos)).toBe(true); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | export default function (env: PhysicsTestEnv, _steps = 0) { |
| 53 | //skip builtin and cannon.js for now |