Skip to content

Commit

Permalink
refactor: opt code
Browse files Browse the repository at this point in the history
  • Loading branch information
luzhuang committed Nov 28, 2024
1 parent 1672ab8 commit f8dc9c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/physics/PhysicsMaterial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { PhysicsMaterialCombineMode } from "./enums/PhysicsMaterialCombineMode";
* Material class to represent a set of surface properties.
*/
export class PhysicsMaterial {
private _bounciness = 0.5;
private _dynamicFriction = 0.5;
private _staticFriction = 0.5;
private _bounciness = 0;
private _dynamicFriction = 0.6;
private _staticFriction = 0.6;
private _bounceCombine: PhysicsMaterialCombineMode = PhysicsMaterialCombineMode.Average;
private _frictionCombine: PhysicsMaterialCombineMode = PhysicsMaterialCombineMode.Average;
private _destroyed: boolean;
Expand Down
10 changes: 5 additions & 5 deletions tests/src/core/physics/Collider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe("physics collider test", function () {

expect(collisionScript.onCollisionEnter.mock.calls.length).toBeGreaterThan(1);
expect(collisionScript.onCollisionStay.mock.calls.length).toBeGreaterThan(1);
expect(collisionScript.onCollisionExit.mock.calls.length).toBeGreaterThan(1);
expect(collisionScript.onCollisionExit.mock.calls.length).eq(1);
expect(boxEntity.transform.position.x).not.to.be.equal(5);
});

Expand Down Expand Up @@ -294,7 +294,7 @@ describe("physics collider test", function () {
collider.shapes[0].material.dynamicFriction = 1;
//@ts-ignore
engine.sceneManager.activeScene.physics._update(1);
expect(formatValue(collider.linearVelocity.x)).eq(1.95167);
expect(formatValue(collider.linearVelocity.x)).eq(0.97066);
box.isActive = false;
const ground = rootEntity.findByName("ground");
const newGround = ground.clone();
Expand All @@ -309,7 +309,7 @@ describe("physics collider test", function () {
collider2.shapes[0].material.dynamicFriction = 1;
//@ts-ignore
engine.sceneManager.activeScene.physics._update(1);
expect(formatValue(collider2.linearVelocity.x)).eq(1.95167);
expect(formatValue(collider2.linearVelocity.x)).eq(0.97066);
});

it("clone DynamicCollider", function () {
Expand All @@ -323,13 +323,13 @@ describe("physics collider test", function () {
collider.shapes[0].material.dynamicFriction = 1;
// @ts-ignore
engine.sceneManager.activeScene.physics._update(1);
expect(formatValue(collider.linearVelocity.x)).eq(1.95167);
expect(formatValue(collider.linearVelocity.x)).eq(0.97066);

const box2 = box.clone();
rootEntity.addChild(box2);
box2.transform.position.z = 2;
const collider2 = box2.getComponent(DynamicCollider);
expect(formatValue(collider2.linearVelocity.x)).eq(1.95167);
expect(formatValue(collider2.linearVelocity.x)).eq(0.97066);
expect(collider2.shapes[0].material.dynamicFriction).eq(1);

// @ts-ignore
Expand Down

0 comments on commit f8dc9c4

Please sign in to comment.