<commit_before>// namespace
var MeshesJS = MeshesJS || {};

;(function() {

    // global settings
    var globalSettings = {
        view: 'default',
        size: {
            width: 800,
            height: 600
        },
        antialias: true,
        color: 0x111111,
        ambientLight: 0x404040,
        buildVolume: {
            size: {
                x: 200,
                y: 200,
                z: 200
            },
            opacity: 0.1,
            color: 0xffaa00
        },
        floor: {
            margin: 10,
            color: 0x000000
        },
        grid: {
            smallCell: {
                size: 10,
                color: 0x333333
            },
            bigCell: {
                size: 100,
                color: 0x444444
            }
        }
    };

    // Constructor
    function Viewer3D(settings) {
        // local settings
        var settings = settings || {};
        this.defaults = _.defaultsDeep({}, settings, Viewer3D.globalSettings);

        // init defaults settings
        this.defaults.floor.size = this.defaults.buildVolume.size;
        this.defaults.grid.size = this.defaults.buildVolume.size;

        // clone settings from defaults
        this.settings = _.defaults({}, this.defaults);

        // self alias
        var self = this;

        // create main objects
        self.scene = new THREE.Scene();
        self.camera = new THREE.PerspectiveCamera();
        self.renderer = new THREE.WebGLRenderer({ antialias: this.defaults.antialias });
        self.canvas = self.renderer.domElement;

        // set camera orbit around Z axis
        self.camera.up = new THREE.Vector3(0, 0, 1);

        // orbit controls
        self.controls = new THREE.OrbitControls(self.camera, self.canvas);
        self.controls.noKeys = true;

        self.controls.addEventListener('change', function() {
            self.render();
        });

        // built in objects
        self.ambientLight = new THREE.AmbientLight(this.defaults.ambientLight);
        self.floor = new MeshesJS.Floor(this.defaults.floor);
        self.grid = new MeshesJS.Grid(this.defaults.grid);
        self.axis = new MeshesJS.Axis(this.defaults.buildVolume);
        self.buildVolume = new MeshesJS.BuildVolume(this.defaults.buildVolume);

        // views controls
        self.view = new MeshesJS.ViewControls({
            target: self.buildVolume,
            controls: self.controls,
            camera: self.camera,
            margin: self.floor.userData.margin
        });

        // compose the scene
        self.scene.add(self.ambientLight);
        self.scene.add(self.floor);
        self.scene.add(self.grid);
        self.scene.add(self.axis);
        self.scene.add(self.buildVolume);

        // set default parameters
        self.setSize(this.defaults.size);
        self.setColor(this.defaults.color);
        self.setView(this.defaults.view);

        // objects collection
        self.objects = {};

        // render
        self.render();
    };

    // methods
    Viewer3D.prototype.setSize = function(size) {
        // default size
        var size = size !== undefined ? size : this.defaults.size;
        this.settings.size = _.defaults(size, this.settings.size);

        // resize the renderer
        this.renderer.setSize(this.settings.size.width, this.settings.size.height);

        // update camera aspect
        this.camera.aspect = this.settings.size.width / this.settings.size.height;
        this.camera.updateProjectionMatrix();

        // update controls
        this.controls.update();
    };

    Viewer3D.prototype.setWidth = function(width) {
        this.setSize({ width: width });
    };

    Viewer3D.prototype.setHeight = function(height) {
        this.setSize({ height: height });<commit_msg>add ambiant lights<commit_after>// namespace
var MeshesJS = MeshesJS || {};

;(function() {

    // global settings
    var globalSettings = {
        view: 'default',
        size: {
            width: 800,
            height: 600
        },
        antialias: true,
        color: 0x111111,
        ambientLight: 0x404040,
        directionalLights: {
            1: { color: 0xefefff, opacity: 0.2, position: { x:  1, y:  1, z: 1 } },
            2: { color: 0xefefff, opacity: 0.4, position: { x:  1, y: -1, z: 1 } },
            3: { color: 0xefefff, opacity: 0.6, position: { x: -1, y: -1, z: 1 } },
            4: { color: 0xefefff, opacity: 0.8, position: { x: -1, y:  1, z: 1 } }
        },
        buildVolume: {
            size: {
                x: 200,
                y: 200,
                z: 200
            },
            opacity: 0.1,
            color: 0xffaa00
        },
        floor: {
            margin: 10,
            color: 0x000000
        },
        grid: {
            smallCell: {
                size: 10,
                color: 0x333333
            },
            bigCell: {
                size: 100,
                color: 0x444444
            }
        }
    };

    // Constructor
    function Viewer3D(settings) {
        // self alias
        var self = this;

        // local settings
        var settings = settings || {};
        self.defaults = _.defaultsDeep({}, settings, Viewer3D.globalSettings);

        // init defaults settings
        self.defaults.floor.size = self.defaults.buildVolume.size;
        self.defaults.grid.size = self.defaults.buildVolume.size;

        // clone settings from defaults
        self.settings = _.defaults({}, self.defaults);

        // create main objects
        self.scene = new THREE.Scene();
        self.camera = new THREE.PerspectiveCamera();
        self.renderer = new THREE.WebGLRenderer({ antialias: self.defaults.antialias });
        self.canvas = self.renderer.domElement;

        // set camera orbit around Z axis
        self.camera.up = new THREE.Vector3(0, 0, 1);

        // orbit controls
        self.controls = new THREE.OrbitControls(self.camera, self.canvas);
        self.controls.noKeys = true;

        self.controls.addEventListener('change', function() {
            self.render();
        });

        // built in objects
        self.ambientLight = new THREE.AmbientLight(self.defaults.ambientLight);
        self.floor = new MeshesJS.Floor(self.defaults.floor);
        self.grid = new MeshesJS.Grid(self.defaults.grid);
        self.axis = new MeshesJS.Axis(self.defaults.buildVolume);
        self.buildVolume = new MeshesJS.BuildVolume(self.defaults.buildVolume);

        // views controls
        self.view = new MeshesJS.ViewControls({
            target: self.buildVolume,
            controls: self.controls,
            camera: self.camera,
            margin: self.floor.userData.margin
        });

        // lightning
        self.directionalLights = {};
        self.scene.add(self.ambientLight);

        for(var num in self.defaults.directionalLights) {
            self.directionalLights[num] = new THREE.DirectionalLight(
                self.defaults.directionalLights[num].color,
                self.defaults.directionalLights[num].opacity
            );
            _.assign(
                self.directionalLights[num].position,
                self.defaults.directionalLights[num].position
            );
            self.scene.add(self.directionalLights[num]);
        }

        // compose the scene
        self.scene.add(self.floor);
        self.scene.add(self.grid);
        self.scene.add(self.axis);
        self.scene.add(self.buildVolume);

        // set default parameters
        self.setSize(self.defaults.size);
        self.setColor(self.defaults.color);
        self.setView(self.defaults.view);

        // objects collection
        self.objects = {};

        // render
        self.render();
    };

    // methods
    Viewer3D.prototype.setSize = function(size) {
        // default size
        var size = size !== undefined ? size : this.defaults.size;
        this.settings.size = _.defaults(size, this.settings.size);

        // resize the renderer
        this.renderer.setSize(this.settings.size.width, this.settings.size.height);

        // update camera aspect
        this.camera.aspect = this.settings.size.width / this.settings.size.height;
        this.camera.updateProjectionMatrix();

        // update controls
        this.controls.update();
    };

    Viewer3D.prototype.setWidth = function(width) {
        this.setSize({ width: width });
    };

    Viewer3D.prototype.setHeight = function(height) {
        this.setSize({ height: height });
{'fraction_non_alphanumeric': 0.11802625410220347, 'fraction_numerical': 0.01992498827941866, 'mean_word_length': 1.6977552956054378, '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': '897735', 'n_tokens_mistral': 2547, 'n_tokens_neox': 2354, 'n_words': 484}