mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
95a76235b6
`cocos/core` should not depend other modules, so move some files out of `cocos/core`: - move some files from `cocos/core` to `cocos/game` - director.ts - splash-screen.ts - game.ts - move `cocos/core/root.ts` to `cocos/root.ts` as there is not better module to contain `root.ts`. - move `cocos/core/platform/view.ts` to `cocos/ui/view.ts` as screen related logic is moved to `cocos/core/platform/screen.ts`
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { Vec3 } from "../../cocos/core";
|
|
import { physics } from "../../exports/physics-framework";
|
|
import { Node } from "../../cocos/scene-graph";
|
|
import { director } from "../../cocos/game";
|
|
|
|
/**
|
|
* This function is used to test the behavior of different volume ratios
|
|
*/
|
|
export default function (parent: Node, steps = 120, ratios = 0.2) {
|
|
const nodeStatic = new Node('StaticB');
|
|
parent.addChild(nodeStatic);
|
|
nodeStatic.addComponent(physics.BoxCollider);
|
|
nodeStatic.worldScale = new Vec3(20, 0.01, 20);
|
|
nodeStatic.worldPosition = new Vec3(0, -0.005, 0);
|
|
|
|
const high = new Node('high');
|
|
parent.addChild(high);
|
|
const highBody = high.addComponent(physics.RigidBody) as physics.RigidBody;
|
|
high.addComponent(physics.BoxCollider);
|
|
const initPos = new Vec3(0, 0.5 + ratios, 0);
|
|
high.worldPosition = initPos;
|
|
|
|
const low = new Node('low');
|
|
parent.addChild(low);
|
|
low.addComponent(physics.RigidBody);
|
|
low.addComponent(physics.BoxCollider);
|
|
low.worldScale = new Vec3(ratios, ratios, ratios);
|
|
low.worldPosition = new Vec3(0, ratios / 2, 0);
|
|
|
|
const dt = physics.PhysicsSystem.instance.fixedTimeStep;
|
|
for (let i = 0; i < steps; i++) {
|
|
director.tick(dt);
|
|
}
|
|
|
|
expect(high.worldPosition.equals(initPos, 0.01)).toBe(true);
|
|
|
|
parent.destroyAllChildren();
|
|
parent.removeAllChildren();
|
|
}
|