mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 17:42:41 +08:00
e5488b7d32
* init * tsconfig.json * add box2d-wasm backend to cocos engine. not crash now in 3.8.0. * rigid-body, collider, and joint works now. * back * Joint: SetLinearFrequencyAndDampingRatio * PhysicsRayCastCallback, PhysicsAABBQueryCallback * box2d wasm debugDraw * asm.js * B2PolygonShape uses B2.ConvexPartition * box2d wasm contact disabled works now. * add unit test for physics2d. * b2ContactListenerWrapper::registerContactFixture * tweak * drawPolygon transfer array data from wasm to ts * tweak * contact event performance opt * revert to polygon collider 2d to original implementation. no need for libtess any more. * PostSolve ContactImpulse use raw pointer. * TransformVector2; debugDraw supports transform * enable rtti * WASM_OBJECT_PTR_2_TS_OBJECT, WASM_OBJECT_PTR_2_WASM_OBJECT * fix PreSolve parameter oldManifold error * B2.TransformVector2 --> b2Mul(in ts) * tweaks: code format. * eslint * eslint * remove physics-2d-box2d-wasm from render-config.json * comment tweaks * [opt] debug draw performance opt * tweaks
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
import { director, game, Game } from "../../cocos/game";
|
|
import Utils from "./utilis";
|
|
import * as physics2d from "../../exports/physics-2d-framework";
|
|
import { Node, Scene } from "../../cocos/scene-graph";
|
|
|
|
import waitForBox2dWasmInstantiation from "../../exports/wait-for-box2d-instantiation";
|
|
waitForBox2dWasmInstantiation();
|
|
import "../../exports/physics-2d-box2d-wasm";
|
|
import "../../exports/physics-2d-box2d";
|
|
import "../../exports/physics-2d-builtin";
|
|
|
|
import RigidBodyTest from "./rigid-body";
|
|
import ColliderTest from "./collider";
|
|
import SceneQueryTest from "./scene-query";
|
|
import EventTest from "./events";
|
|
|
|
game.emit(Game.EVENT_PRE_SUBSYSTEM_INIT);
|
|
physics2d.PhysicsSystem2D.constructAndRegister();
|
|
|
|
test(`physics2d test | utils`, done => {
|
|
Utils();
|
|
done();
|
|
});
|
|
|
|
for (const id in physics2d.selector.backend) {
|
|
test(`physics2d test | ${id}`, done => {
|
|
// init test scene (which will also immediately destroy the previous test scene)
|
|
const scene = new Scene('test-' + id);
|
|
director.runSceneImmediate(scene);
|
|
|
|
// switch to backend after the previous scene is immediately destroyed
|
|
physics2d.selector.switchTo(id);
|
|
expect(physics2d.selector.id).toBe(id);
|
|
|
|
const temp0 = new Node();
|
|
scene.addChild(temp0);
|
|
|
|
//test rigid body
|
|
RigidBodyTest(temp0);
|
|
|
|
//test collider
|
|
ColliderTest(temp0);
|
|
|
|
//test scene query
|
|
SceneQueryTest(temp0);
|
|
|
|
//test events
|
|
EventTest(temp0);
|
|
|
|
// destroy test scene
|
|
temp0.destroy();
|
|
scene.destroy();
|
|
// all works done
|
|
done();
|
|
})
|
|
} |