<commit_before>pc.extend(pc, function () {

    var ammoVec1, ammoQuat;

    /**
    * @private
    * @name pc.Trigger
    * @class Creates a trigger object used to create internal physics objects that interact with
    * rigid bodies and trigger collision events with no collision response
    * @param {pc.Application} app The running {pc.Application}
    * @param {pc.Component} component The component for which the trigger will be created
    * @param {pc.ComponentData} data The data for the component
    */
    var Trigger = function Trigger (app, component, data) {
        this.entity = component.entity;
        this.component = component;
        this.app = app;

        if (typeof Ammo !== 'undefined') {
            ammoVec1 = new Ammo.btVector3();
            ammoQuat = new Ammo.btQuaternion();
        }

        this.initialize(data);
    };

    Trigger.prototype =  {
        initialize: function (data) {
            var entity = this.entity;
            var shape = data.shape;

            if (shape && typeof Ammo !== 'undefined') {
                if (entity.trigger) {
                    entity.trigger.destroy();
                }

                var mass = 1;

                var localInertia = new Ammo.btVector3(0, 0, 0);
                shape.calculateLocalInertia(mass, localInertia);

                var pos = entity.getPosition();
                var rot = entity.getRotation();
                ammoQuat.setValue(rot.x, rot.y, rot.z, rot.w);

                var startTransform = new Ammo.btTransform();
                startTransform.setIdentity();
                startTransform.getOrigin().setValue(pos.x, pos.y, pos.z);
                startTransform.setRotation(ammoQuat);

                var motionState = new Ammo.btDefaultMotionState(startTransform);
                var bodyInfo = new Ammo.btRigidBodyConstructionInfo(mass, motionState, shape, localInertia);

                var body = new Ammo.btRigidBody(bodyInfo);
                this.body = body;

                body.setRestitution(0);
                body.setFriction(0);
                body.setDamping(0, 0);
                ammoVec1.setValue(0,0,0);
                body.setLinearFactor(ammoVec1);
                body.setAngularFactor(ammoVec1);

                body.setCollisionFlags(body.getCollisionFlags() | pc.BODYFLAG_NORESPONSE_OBJECT);
                body.entity = entity;

                if (this.component.enabled && entity.enabled) {
                    this.enable();
                }
            }
        },

        destroy: function () {
            if (this.body) {
                this.app.systems.rigidbody.removeBody(this.body);
            }
        },

        syncEntityToBody: function () {
            var body = this.body;
            if (body) {
                var position = this.entity.getPosition();
                var rotation = this.entity.getRotation();

                var transform = body.getWorldTransform();
                transform.getOrigin().setValue(position.x, position.y, position.z);

                ammoQuat.setValue(rotation.x, rotation.y, rotation.z, rotation.w);
                transform.setRotation(ammoQuat);
                body.activate();
            }
        },

        enable: function () {
            var body = this.body;
            this.app.systems.rigidbody.addBody(body, pc.BODYGROUP_TRIGGER, pc.BODYMASK_NOT_STATIC ^ pc.BODYGROUP_TRIGGER);

            // set the body's activation state to active so that it is
            // simulated properly again
            body.forceActivationState(pc.BODYSTATE_ACTIVE_TAG);

            body.activate();
        },

        disable: function () {
            var body = this.body;
            this.app.systems.rigidbody.removeBody(body);

            // set the body's activation state to disable simulation so<commit_msg>Fix exceptions when disabling / enabling triggers in Editor<commit_after>pc.extend(pc, function () {

    var ammoVec1, ammoQuat;

    /**
    * @private
    * @name pc.Trigger
    * @class Creates a trigger object used to create internal physics objects that interact with
    * rigid bodies and trigger collision events with no collision response
    * @param {pc.Application} app The running {pc.Application}
    * @param {pc.Component} component The component for which the trigger will be created
    * @param {pc.ComponentData} data The data for the component
    */
    var Trigger = function Trigger (app, component, data) {
        this.entity = component.entity;
        this.component = component;
        this.app = app;

        if (typeof Ammo !== 'undefined') {
            ammoVec1 = new Ammo.btVector3();
            ammoQuat = new Ammo.btQuaternion();
        }

        this.initialize(data);
    };

    Trigger.prototype =  {
        initialize: function (data) {
            var entity = this.entity;
            var shape = data.shape;

            if (shape && typeof Ammo !== 'undefined') {
                if (entity.trigger) {
                    entity.trigger.destroy();
                }

                var mass = 1;

                var localInertia = new Ammo.btVector3(0, 0, 0);
                shape.calculateLocalInertia(mass, localInertia);

                var pos = entity.getPosition();
                var rot = entity.getRotation();
                ammoQuat.setValue(rot.x, rot.y, rot.z, rot.w);

                var startTransform = new Ammo.btTransform();
                startTransform.setIdentity();
                startTransform.getOrigin().setValue(pos.x, pos.y, pos.z);
                startTransform.setRotation(ammoQuat);

                var motionState = new Ammo.btDefaultMotionState(startTransform);
                var bodyInfo = new Ammo.btRigidBodyConstructionInfo(mass, motionState, shape, localInertia);

                var body = new Ammo.btRigidBody(bodyInfo);
                this.body = body;

                body.setRestitution(0);
                body.setFriction(0);
                body.setDamping(0, 0);
                ammoVec1.setValue(0,0,0);
                body.setLinearFactor(ammoVec1);
                body.setAngularFactor(ammoVec1);

                body.setCollisionFlags(body.getCollisionFlags() | pc.BODYFLAG_NORESPONSE_OBJECT);
                body.entity = entity;

                if (this.component.enabled && entity.enabled) {
                    this.enable();
                }
            }
        },

        destroy: function () {
            if (this.body) {
                this.app.systems.rigidbody.removeBody(this.body);
            }
        },

        syncEntityToBody: function () {
            var body = this.body;
            if (body) {
                var position = this.entity.getPosition();
                var rotation = this.entity.getRotation();

                var transform = body.getWorldTransform();
                transform.getOrigin().setValue(position.x, position.y, position.z);

                ammoQuat.setValue(rotation.x, rotation.y, rotation.z, rotation.w);
                transform.setRotation(ammoQuat);
                body.activate();
            }
        },

        enable: function () {
            var body = this.body;
            if (!body) return;

            this.app.systems.rigidbody.addBody(body, pc.BODYGROUP_TRIGGER, pc.BODYMASK_NOT_STATIC ^ pc.BODYGROUP_TRIGGER);

            // set the body's activation state to active so that it is
            // simulated properly again
            body.forceActivationState(pc.BODYSTATE_ACTIVE_TAG);

            body.activate();
        },

        disable: function () {
            var body = this.body;
            if (!body) return;

            this.app.systems.rigidbody.removeBody(body);

            // set the body's activation state to disable simulation so
{'fraction_non_alphanumeric': 0.09971838197644649, 'fraction_numerical': 0.004608294930875576, 'mean_word_length': 1.6978591160220995, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2275576', 'n_tokens_mistral': 2187, 'n_tokens_neox': 2050, 'n_words': 476}