How to use the @cocos/cannon.Vec3 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
//  addContactMaterial (contactMaterial: ContactMaterial) {
    //     this._cannonWorld.addContactMaterial(contactMaterial._getImpl());
    // }

    addConstraint (constraint: CannonConstraint) {
        this._world.addConstraint(constraint.impl);
    }

    removeConstraint (constraint: CannonConstraint) {
        this._world.removeConstraint(constraint.impl);
    }
}

const from = new CANNON.Vec3();
const to = new CANNON.Vec3();
function setupFromAndTo (worldRay: ray, distance: number) {
    Vec3.copy(from, worldRay.o);
    worldRay.computeHit(to, distance);
}

const raycastOpt: CANNON.IRaycastOptions = {
    'checkCollisionResponse': false,
    'collisionFilterGroup': -1,
    'collisionFilterMask': -1,
    'skipBackFaces': false
}
github cocos-creator / engine / cocos / physics / cannon / cannon-world.ts View on Github external
}

    //  addContactMaterial (contactMaterial: ContactMaterial) {
    //     this._cannonWorld.addContactMaterial(contactMaterial._getImpl());
    // }

    addConstraint (constraint: CannonConstraint) {
        this._world.addConstraint(constraint.impl);
    }

    removeConstraint (constraint: CannonConstraint) {
        this._world.removeConstraint(constraint.impl);
    }
}

const from = new CANNON.Vec3();
const to = new CANNON.Vec3();
function setupFromAndTo (worldRay: ray, distance: number) {
    Vec3.copy(from, worldRay.o);
    worldRay.computeHit(to, distance);
}

const raycastOpt: CANNON.IRaycastOptions = {
    'checkCollisionResponse': false,
    'collisionFilterGroup': -1,
    'collisionFilterMask': -1,
    'skipBackFaces': false
}
github cocos-creator / engine / cocos / physics / cannon / cannon-body.ts View on Github external
}

const CollisionEventObject = {
    type: 'onCollisionEnter' as ICollisionEventType,
    selfCollider: null,
    otherCollider: null,
    // selfRigidBody: null,
    // otherRigidBody: null,
    contacts: [] as any,
};

const contactsPool = [] as any;

const _tCannonV1 = new CANNON.Vec3();

const _tCannonV2 = new CANNON.Vec3();
github cocos-creator / engine / cocos / physics / cannon / cannon-body.ts View on Github external
}

}

const CollisionEventObject = {
    type: 'onCollisionEnter' as ICollisionEventType,
    selfCollider: null,
    otherCollider: null,
    // selfRigidBody: null,
    // otherRigidBody: null,
    contacts: [] as any,
};

const contactsPool = [] as any;

const _tCannonV1 = new CANNON.Vec3();

const _tCannonV2 = new CANNON.Vec3();
github cocos-creator / engine / cocos / physics / cannon / constraint / cannon-point-to-point-constraint.ts View on Github external
constructor (first: CannonSharedBody, firstPivot: Vec3, second: CannonSharedBody, secondPivot: Vec3, options?: any) {
        super(new CANNON.PointToPointConstraint(
            first.body,
            Vec3.copy(new CANNON.Vec3(), firstPivot),
            second.body,
            Vec3.copy(new CANNON.Vec3(), secondPivot),
            options === undefined ? undefined : options.maxForce));
    }
}