How to use @cocos/ammo - 10 common examples

To help you get started, we’ve selected a few @cocos/ammo 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 / ammo / ammo-shared-body.ts View on Github external
private destroy () {
        AmmoSharedBody.sharedBodesMap.delete(this.node.uuid);
        (this.node as any) = null;
        (this.wrappedWorld as any) = null;

        const bodyStruct = this.bodyStruct;
        Ammo.destroy(bodyStruct.body);
        Ammo.destroy(bodyStruct.localInertia);
        Ammo.destroy(bodyStruct.motionState);
        Ammo.destroy(bodyStruct.rbInfo);
        Ammo.destroy(bodyStruct.shape);
        Ammo.destroy(bodyStruct.startTransform);
        Ammo.destroy(bodyStruct.worldQuat);
        const key0 = 'KEY' + bodyStruct.id;
        delete AmmoInstance.bodyStructs[key0];

        const ghostStruct = this.ghostStruct;
        Ammo.destroy(ghostStruct.ghost);
        Ammo.destroy(ghostStruct.shape);
        Ammo.destroy(ghostStruct.worldQuat);
        const key1 = 'KEY' + ghostStruct.id;
        delete AmmoInstance.bodyStructs[key1];
github cocos-creator / engine / cocos / physics / ammo / ammo-shared-body.ts View on Github external
(this.node as any) = null;
        (this.wrappedWorld as any) = null;

        const bodyStruct = this.bodyStruct;
        Ammo.destroy(bodyStruct.body);
        Ammo.destroy(bodyStruct.localInertia);
        Ammo.destroy(bodyStruct.motionState);
        Ammo.destroy(bodyStruct.rbInfo);
        Ammo.destroy(bodyStruct.shape);
        Ammo.destroy(bodyStruct.startTransform);
        Ammo.destroy(bodyStruct.worldQuat);
        const key0 = 'KEY' + bodyStruct.id;
        delete AmmoInstance.bodyStructs[key0];

        const ghostStruct = this.ghostStruct;
        Ammo.destroy(ghostStruct.ghost);
        Ammo.destroy(ghostStruct.shape);
        Ammo.destroy(ghostStruct.worldQuat);
        const key1 = 'KEY' + ghostStruct.id;
        delete AmmoInstance.bodyStructs[key1];

        (this.bodyStruct as any) = null;
        (this.ghostStruct as any) = null;
    }
github cocos-creator / engine / cocos / physics / ammo / shapes / ammo-shape.ts View on Github external
onDestroy () {
        this._sharedBody.reference = false;
        this._btCompound = null;
        (this._collider as any) = null;

        Ammo.destroy(this._btShape);
        Ammo.destroy(this.transform);
        Ammo.destroy(this.pos);
        Ammo.destroy(this.quat);
        Ammo.destroy(this.scale);
        (this._btShape as any) = null;
        (this.transform as any) = null;
        (this.pos as any) = null;
        (this.quat as any) = null;
        (this.scale as any) = null;
    }
github cocos-creator / engine / cocos / physics / ammo / ammo-shared-body.ts View on Github external
private destroy () {
        AmmoSharedBody.sharedBodesMap.delete(this.node.uuid);
        (this.node as any) = null;
        (this.wrappedWorld as any) = null;

        const bodyStruct = this.bodyStruct;
        Ammo.destroy(bodyStruct.body);
        Ammo.destroy(bodyStruct.localInertia);
        Ammo.destroy(bodyStruct.motionState);
        Ammo.destroy(bodyStruct.rbInfo);
        Ammo.destroy(bodyStruct.shape);
        Ammo.destroy(bodyStruct.startTransform);
        Ammo.destroy(bodyStruct.worldQuat);
        const key0 = 'KEY' + bodyStruct.id;
        delete AmmoInstance.bodyStructs[key0];

        const ghostStruct = this.ghostStruct;
        Ammo.destroy(ghostStruct.ghost);
        Ammo.destroy(ghostStruct.shape);
        Ammo.destroy(ghostStruct.worldQuat);
        const key1 = 'KEY' + ghostStruct.id;
        delete AmmoInstance.bodyStructs[key1];

        (this.bodyStruct as any) = null;
        (this.ghostStruct as any) = null;
    }
github cocos-creator / engine / cocos / physics / ammo / ammo-shared-body.ts View on Github external
private destroy () {
        AmmoSharedBody.sharedBodesMap.delete(this.node.uuid);
        (this.node as any) = null;
        (this.wrappedWorld as any) = null;

        const bodyStruct = this.bodyStruct;
        Ammo.destroy(bodyStruct.body);
        Ammo.destroy(bodyStruct.localInertia);
        Ammo.destroy(bodyStruct.motionState);
        Ammo.destroy(bodyStruct.rbInfo);
        Ammo.destroy(bodyStruct.shape);
        Ammo.destroy(bodyStruct.startTransform);
        Ammo.destroy(bodyStruct.worldQuat);
        const key0 = 'KEY' + bodyStruct.id;
        delete AmmoInstance.bodyStructs[key0];

        const ghostStruct = this.ghostStruct;
        Ammo.destroy(ghostStruct.ghost);
        Ammo.destroy(ghostStruct.shape);
        Ammo.destroy(ghostStruct.worldQuat);
        const key1 = 'KEY' + ghostStruct.id;
        delete AmmoInstance.bodyStructs[key1];

        (this.bodyStruct as any) = null;
        (this.ghostStruct as any) = null;
github cocos-creator / engine / cocos / physics / ammo / shapes / ammo-shape.ts View on Github external
onDestroy () {
        this._sharedBody.reference = false;
        this._btCompound = null;
        (this._collider as any) = null;

        Ammo.destroy(this._btShape);
        Ammo.destroy(this.transform);
        Ammo.destroy(this.pos);
        Ammo.destroy(this.quat);
        Ammo.destroy(this.scale);
        (this._btShape as any) = null;
        (this.transform as any) = null;
        (this.pos as any) = null;
        (this.quat as any) = null;
        (this.scale as any) = null;
    }
github cocos-creator / engine / cocos / physics / ammo / shapes / ammo-shape.ts View on Github external
onDestroy () {
        this._sharedBody.reference = false;
        this._btCompound = null;
        (this._collider as any) = null;

        Ammo.destroy(this._btShape);
        Ammo.destroy(this.transform);
        Ammo.destroy(this.pos);
        Ammo.destroy(this.quat);
        Ammo.destroy(this.scale);
        (this._btShape as any) = null;
        (this.transform as any) = null;
        (this.pos as any) = null;
        (this.quat as any) = null;
        (this.scale as any) = null;
    }
github cocos-creator / engine / cocos / physics / ammo / ammo-shared-body.ts View on Github external
private destroy () {
        AmmoSharedBody.sharedBodesMap.delete(this.node.uuid);
        (this.node as any) = null;
        (this.wrappedWorld as any) = null;

        const bodyStruct = this.bodyStruct;
        Ammo.destroy(bodyStruct.body);
        Ammo.destroy(bodyStruct.localInertia);
        Ammo.destroy(bodyStruct.motionState);
        Ammo.destroy(bodyStruct.rbInfo);
        Ammo.destroy(bodyStruct.shape);
        Ammo.destroy(bodyStruct.startTransform);
        Ammo.destroy(bodyStruct.worldQuat);
        const key0 = 'KEY' + bodyStruct.id;
        delete AmmoInstance.bodyStructs[key0];

        const ghostStruct = this.ghostStruct;
        Ammo.destroy(ghostStruct.ghost);
        Ammo.destroy(ghostStruct.shape);
        Ammo.destroy(ghostStruct.worldQuat);
        const key1 = 'KEY' + ghostStruct.id;
        delete AmmoInstance.bodyStructs[key1];

        (this.bodyStruct as any) = null;
        (this.ghostStruct as any) = null;
    }
github cocos-creator / engine / cocos / physics / ammo / ammo-shared-body.ts View on Github external
private destroy () {
        AmmoSharedBody.sharedBodesMap.delete(this.node.uuid);
        (this.node as any) = null;
        (this.wrappedWorld as any) = null;

        const bodyStruct = this.bodyStruct;
        Ammo.destroy(bodyStruct.body);
        Ammo.destroy(bodyStruct.localInertia);
        Ammo.destroy(bodyStruct.motionState);
        Ammo.destroy(bodyStruct.rbInfo);
        Ammo.destroy(bodyStruct.shape);
        Ammo.destroy(bodyStruct.startTransform);
        Ammo.destroy(bodyStruct.worldQuat);
        const key0 = 'KEY' + bodyStruct.id;
        delete AmmoInstance.bodyStructs[key0];

        const ghostStruct = this.ghostStruct;
        Ammo.destroy(ghostStruct.ghost);
        Ammo.destroy(ghostStruct.shape);
        Ammo.destroy(ghostStruct.worldQuat);
        const key1 = 'KEY' + ghostStruct.id;
        delete AmmoInstance.bodyStructs[key1];

        (this.bodyStruct as any) = null;
        (this.ghostStruct as any) = null;
    }
github cocos-creator / engine / cocos / physics / ammo / ammo-shared-body.ts View on Github external
'worldQuat': bodyQuat,
            'wrappedShapes': []
        }
        AmmoInstance.bodyStructs['KEY' + this.bodyStruct.id] = this.bodyStruct;
        this.body.setUserIndex(this.bodyStruct.id);

        /** ghost struct */
        const ghost = new Ammo.btCollisionObject();
        const ghostShape = new Ammo.btCompoundShape();
        ghost.setCollisionShape(ghostShape);
        ghost.setCollisionFlags(AmmoCollisionFlags.CF_NO_CONTACT_RESPONSE);
        this.ghostStruct = {
            'id': sharedIDCounter++,
            'ghost': ghost,
            'shape': ghostShape,
            'worldQuat': new Ammo.btQuaternion(),
            'wrappedShapes': []
        }
        AmmoInstance.ghostStructs['KEY' + this.ghostStruct.id] = this.ghostStruct;
        this.ghost.setUserIndex(this.ghostStruct.id);

        /** DEBUG */
        this.body.setActivationState(AmmoCollisionObjectStates.DISABLE_DEACTIVATION);
        this.ghost.setActivationState(AmmoCollisionObjectStates.DISABLE_DEACTIVATION);
    }

@cocos/ammo

Direct port of the Bullet physics engine to JavaScript using Emscripten

Unrecognized
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis

Similar packages