<commit_before>var TransformableAdapter = require("./transformable.js");

/**
 * @constructor
 */
var MeshRenderAdapter = function (factory, node) {
    TransformableAdapter.call(this, factory, node, true, true);
    this.createRenderNode();
};

XML3D.createClass(MeshRenderAdapter, TransformableAdapter, {

    createRenderNode: function () {
        var dataAdapter = XML3D.base.resourceManager.getAdapter(this.node, XML3D.data);

        var parent = this.getParentRenderAdapter();
        var parentNode = parent.getRenderNode && parent.getRenderNode();

        this.renderNode = this.getScene().createRenderObject({
            parent: parentNode, node: this.node, object: {
                data: dataAdapter.getXflowNode(), type: this.getMeshType()
            }, name: this.node.id, shaderHandle: this.getShaderHandle(), visible: !this.node.visible ? false : undefined
        });
        this.updateLocalMatrix();
    },

    getMeshType: function () {
        return this.node.hasAttribute("type") ? this.node.getAttribute("type") : "triangles";
    },

    /**
     * @param {XML3D.events.Notification} evt
     */
    notifyChanged: function (evt) {
        TransformableAdapter.prototype.notifyChanged.call(this, evt);
        switch (evt.type) {
            case  XML3D.events.NODE_INSERTED:
                return;
            case XML3D.events.THIS_REMOVED:
                this.dispose();
                return;
            case XML3D.events.NODE_REMOVED:
                // this.createPerObjectData();
                return;
            case XML3D.events.VALUE_MODIFIED:
                this.valueChanged(evt.mutation);
        }
    }, /**
     * @param {MutationEvent} evt
     */
    valueChanged: function (mutation) {
        var target = evt.attributeName;
        switch (target) {
            case "src":
                // Handled by data component
                break;

            case "type":
                this.renderNode.setType(mutation.target.getAttribute("type"));
                break;
        }

    }, dispose: function () {
        this.getRenderNode().remove();
        this.clearAdapterHandles();
    }
});


// Interface methods

XML3D.extend(MeshRenderAdapter.prototype, {
    /**
     * @return {Window.XML3DBox}
     */
    getBoundingBox: function () {
        if (this.renderNode) {
            var bbox = new XML3D.math.bbox.create();
            this.renderNode.getObjectSpaceBoundingBox(bbox);
            return XML3D.math.bbox.asXML3DBox(bbox);
        }

        return new window.XML3DBox();
    },

    /**
     * @return {Window.XML3DMatrix}
     */
    getWorldMatrix: function () {
        var m = new window.XML3DMatrix(), obj = this.renderNode;
        if (obj) {
            obj.getWorldMatrix(m._data);
        }
        return m;
    }
});

// Export
module.exports = MeshRenderAdapter;

<commit_msg>Fix refactoring artifact in mesh adapter<commit_after>var TransformableAdapter = require("./transformable.js");

/**
 * @constructor
 */
var MeshRenderAdapter = function (factory, node) {
    TransformableAdapter.call(this, factory, node, true, true);
    this.createRenderNode();
};

XML3D.createClass(MeshRenderAdapter, TransformableAdapter, {

    createRenderNode: function () {
        var dataAdapter = XML3D.base.resourceManager.getAdapter(this.node, XML3D.data);

        var parent = this.getParentRenderAdapter();
        var parentNode = parent.getRenderNode && parent.getRenderNode();

        this.renderNode = this.getScene().createRenderObject({
            parent: parentNode, node: this.node, object: {
                data: dataAdapter.getXflowNode(), type: this.getMeshType()
            }, name: this.node.id, shaderHandle: this.getShaderHandle(), visible: !this.node.visible ? false : undefined
        });
        this.updateLocalMatrix();
    },

    getMeshType: function () {
        return this.node.hasAttribute("type") ? this.node.getAttribute("type") : "triangles";
    },

    /**
     * @param {XML3D.events.Notification} evt
     */
    notifyChanged: function (evt) {
        TransformableAdapter.prototype.notifyChanged.call(this, evt);
        switch (evt.type) {
            case  XML3D.events.NODE_INSERTED:
                return;
            case XML3D.events.THIS_REMOVED:
                this.dispose();
                return;
            case XML3D.events.NODE_REMOVED:
                // this.createPerObjectData();
                return;
            case XML3D.events.VALUE_MODIFIED:
                this.valueChanged(evt.mutation);
        }
    }, /**
     * @param {MutationEvent} evt
     */
    valueChanged: function (mutation) {
        var target = mutation.attributeName;
        switch (target) {
            case "src":
                // Handled by data component
                break;

            case "type":
                this.renderNode.setType(mutation.target.getAttribute("type"));
                break;
        }

    }, dispose: function () {
        this.getRenderNode().remove();
        this.clearAdapterHandles();
    }
});


// Interface methods

XML3D.extend(MeshRenderAdapter.prototype, {
    /**
     * @return {Window.XML3DBox}
     */
    getBoundingBox: function () {
        if (this.renderNode) {
            var bbox = new XML3D.math.bbox.create();
            this.renderNode.getObjectSpaceBoundingBox(bbox);
            return XML3D.math.bbox.asXML3DBox(bbox);
        }

        return new window.XML3DBox();
    },

    /**
     * @return {Window.XML3DMatrix}
     */
    getWorldMatrix: function () {
        var m = new window.XML3DMatrix(), obj = this.renderNode;
        if (obj) {
            obj.getWorldMatrix(m._data);
        }
        return m;
    }
});

// Export
module.exports = MeshRenderAdapter;


{'fraction_non_alphanumeric': 0.12300762300762301, 'fraction_numerical': 0.005544005544005544, 'mean_word_length': 2.0805763073639274, 'pattern_counts': {'":': 4, '<': 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': '3089569', 'n_tokens_mistral': 1690, 'n_tokens_neox': 1643, 'n_words': 291}