How to use the @cocos/cannon.RaycastResult function in @cocos/cannon

To help you get started, we’ve selected a few @cocos/cannon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cocos-creator / engine / cocos / physics / cannon / cannon-world.ts View on Github external
set allowSleep (v: boolean) {
        this._world.allowSleep = v;
    }

    set gravity (gravity: Vec3) {
        Vec3.copy(this._world.gravity, gravity);
    }

    // get defaultContactMaterial () {
    //     return this._defaultContactMaterial;
    // }

    readonly bodies: CannonSharedBody[] = [];

    private _world: CANNON.World;
    private _raycastResult = new CANNON.RaycastResult();

    constructor () {
        this._world = new CANNON.World();
        this._world.broadphase = new CANNON.NaiveBroadphase();
    }

    step (deltaTime: number, timeSinceLastCalled?: number, maxSubStep?: number) {
        // sync scene to physics
        for (let i = 0; i < this.bodies.length; i++) {
            this.bodies[i].syncSceneToPhysics();
        }

        this._world.step(deltaTime, timeSinceLastCalled, maxSubStep);

        // sync physics to scene
        for (let i = 0; i < this.bodies.length; i++) {