How to use the @cocos/cannon.Quaternion 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 / shapes / cannon-shape.ts View on Github external
}

    set center (v: IVec3Like) {
        const lpos = this._offset as IVec3Like;
        Vec3.copy(lpos, v);
        Vec3.multiply(lpos, lpos, this._collider.node.worldScale);
        if (this._index >= 0) {
            commitShapeUpdates(this._body);
        }
    }

    _collider!: ColliderComponent;

    protected _shape!: CANNON.Shape;
    protected _offset = new CANNON.Vec3();
    protected _orient = new CANNON.Quaternion();
    protected _index: number = -1;
    protected _sharedBody!: CannonSharedBody;
    protected get _body (): CANNON.Body { return this._sharedBody.body; }
    protected onTriggerListener = this.onTrigger.bind(this);

    /** LIFECYCLE */

    __preload (comp: ColliderComponent) {
        this._collider = comp;
        setWrap(this._shape, this);
        this._shape.addEventListener('triggered', this.onTriggerListener);
        this._sharedBody = (PhysicsSystem.instance.physicsWorld as CannonWorld).getSharedBody(this._collider.node as Node);
        this._sharedBody.reference = true;
    }

    onLoad () {