<commit_before>
(function (plugin, core, scene) {

    var DEFAULTS = {
        color: new THREE.Color('#0277BD'),
        size: 2
    };

    //Shader
    var POINTS = {
        uniforms: THREE.UniformsUtils.merge([
            {
                "size": {type: "f", value: DEFAULTS.size},
                "color": {type: "c", value: DEFAULTS.color}
            }
        ]),
        vertexShader: [
            "uniform float size;",
            "uniform vec3 color;",
            "varying vec3 vColor;",
            "void main() {",
            "   vColor = color;",
            "   vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
            "   gl_PointSize = size;",
            "   gl_Position = projectionMatrix * mvPosition;",
            "   gl_Position.z -= (size / 1000.0);",
            "}"

        ].join("\n"),
        fragmentShader: [
            "uniform vec3 color;",
            "varying vec3 vColor;",
            "void main() {",
            "   gl_FragColor = vec4( color * vColor, 1.0 );",
            "}"

        ].join("\n")

    };

    var plug = new plugin.Rendering({
        name: "Points",
        tooltip: "Points Tooltip",
        icon: "img/icons/points.png",
        toggle: true,
        on: false
    }, DEFAULTS);


    var pointColorWidget, pointSizeWidget;
    plug._init = function (guiBuilder) {
        pointColorWidget = guiBuilder.Color({
            label: "Color",
            tooltip: "The color of points",
            color: "#" + DEFAULTS.color.getHexString(),
            bindTo: "color"
        });

        pointSizeWidget = guiBuilder.Float({
            label: "Size",
            tooltip: "The size of the points",
            min: 1, max: 10, step: 0.5,
            defval: DEFAULTS.size,
            bindTo: "size"
        });
    };

    plug._applyTo = function (meshFile, on) {

        if (on) {
            var geom = meshFile.getThreeMesh().geometry.clone();
            var uniforms = THREE.UniformsUtils.clone(POINTS.uniforms);
            var params = meshFile.overlaysParams.getByKey(plug.getName());

            uniforms.color.value = params.color;
            uniforms.size.value = params.size;                        
            
            var parameters = {
                fragmentShader: POINTS.fragmentShader,
                vertexShader: POINTS.vertexShader,
                uniforms: uniforms
            };

            var mat = new THREE.ShaderMaterial(parameters);
            var points = new THREE.PointCloud(geom, mat);
            scene.addOverlayLayer(meshFile, plug.getName(), points);

        } else {
            scene.removeOverlayLayer(meshFile, plug.getName());
        }

    };

    plugin.Manager.install(plug);

})(MLJ.core.plugin, MLJ.core, MLJ.core.Scene);<commit_msg>Small refactoring in applyTo function<commit_after>
(function (plugin, core, scene) {

    var DEFAULTS = {
        color: new THREE.Color('#0277BD'),
        size: 2
    };

    //Shader
    var POINTS = {
        uniforms: THREE.UniformsUtils.merge([
            {
                "size": {type: "f", value: DEFAULTS.size},
                "color": {type: "c", value: DEFAULTS.color}
            }
        ]),
        vertexShader: [
            "uniform float size;",
            "uniform vec3 color;",
            "varying vec3 vColor;",
            "void main() {",
            "   vColor = color;",
            "   vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
            "   gl_PointSize = size;",
            "   gl_Position = projectionMatrix * mvPosition;",
            "   gl_Position.z -= (size / 1000.0);",
            "}"

        ].join("\n"),
        fragmentShader: [
            "uniform vec3 color;",
            "varying vec3 vColor;",
            "void main() {",
            "   gl_FragColor = vec4( color * vColor, 1.0 );",
            "}"

        ].join("\n")

    };

    var plug = new plugin.Rendering({
        name: "Points",
        tooltip: "Points Tooltip",
        icon: "img/icons/points.png",
        toggle: true,
        on: false
    }, DEFAULTS);


    var pointColorWidget, pointSizeWidget;
    plug._init = function (guiBuilder) {
        pointColorWidget = guiBuilder.Color({
            label: "Color",
            tooltip: "The color of points",
            color: "#" + DEFAULTS.color.getHexString(),
            bindTo: "color"
        });

        pointSizeWidget = guiBuilder.Float({
            label: "Size",
            tooltip: "The size of the points",
            min: 1, max: 10, step: 0.5,
            defval: DEFAULTS.size,
            bindTo: "size"
        });
    };

    plug._applyTo = function (meshFile, on) {

        if (on == false) {
            scene.removeOverlayLayer(meshFile, plug.getName());
            return;
        }
        var geom = meshFile.getThreeMesh().geometry.clone();
        var uniforms = THREE.UniformsUtils.clone(POINTS.uniforms);
        var params = meshFile.overlaysParams.getByKey(plug.getName());

        uniforms.color.value = params.color;
        uniforms.size.value = params.size;

        var parameters = {
            fragmentShader: POINTS.fragmentShader,
            vertexShader: POINTS.vertexShader,
            uniforms: uniforms
        };

        var mat = new THREE.ShaderMaterial(parameters);
        var points = new THREE.PointCloud(geom, mat);
        scene.addOverlayLayer(meshFile, plug.getName(), points);


    };

    plugin.Manager.install(plug);

})(MLJ.core.plugin, MLJ.core, MLJ.core.Scene);
{'fraction_non_alphanumeric': 0.13088341781317886, 'fraction_numerical': 0.00941346850108617, 'mean_word_length': 1.6197249881460407, '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': '5305390', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1577, 'n_words': 348}