<commit_before>'use strict';

const COLORS = get_color_range_list(COLOR_FLOATING_WALL_BASE, COLOR_FLOATING_WALL_TOP, 8);

function FloatingWall(width, height, position, normal, world, scalable, default_background_color) {
    this.__init__(width, height, position, normal, world, scalable, default_background_color);
}

FloatingWall.prototype = {

    __init__: function (width, height, position, normal, world, scalable, default_background_color) {
        // Inherit from Attachmentable.
        Attachmentable.call(this, world);
        // Inherit from Animatable.
        Animatable.call(this);

        this.width = width;
        this.height = height;

        this.create_base_mesh();

        if (is_defined(normal)) {
            this.set_normal(normal.x, normal.y, normal.z, false);
        }
        if (is_defined(position)) {
            this.set_position(position.x, position.y, position.z, false);
        }

        // Inherit from Interactive.
        Interactive.call(this);
        // Inherit from Visibility.
        Visibility.call(this);

        this.scalable = scalable;
        if (!is_defined(this.scalable)) {
            this.scalable = false;
        }

        this.world.interactive_objects.push(this);
        this.engable = false;
        if (!this.scalable) {
            this.only_used_for_blocking_input = true;
        }

        if (is_defined(default_background_color)) {
            this.default_background_color = default_background_color;
        } else {
            this.default_background_color = COLOR_FLOATING_WALL_BASE;
        }
        this.set_background_color(this.default_background_color, true);

        //this.make_base_wall_visible();

        // REFACTORING ROWS!!!
        this._2D_rows = [];
        this.max_row_2D = -1;
        this._3D_rows = [];
        this.max_row_3D = 0;

        this.rows = [];

        // Inherit from Saveable but set to false by default.
        Saveable.call(this, ENTITY_TYPE_WALL);
        this.saveable = false;
        this.add_save_field(ENTITY_PROPERTY_WIDTH);
        this.add_save_field(ENTITY_PROPERTY_HEIGHT);
        this.add_save_field(ENTITY_PROPERTY_POSITION);
        this.add_save_field(ENTITY_PROPERTY_NORMAL);
        this.add_save_field(ENTITY_PROPERTY_IS_ROOT_ATTACHABLE);
        this.add_save_field(ENTITY_PROPERTY_3D_ROWS);
        this.add_save_field(ENTITY_PROPERTY_2D_ROWS);
    },

    make_base_wall_invisible: function() {
        this._make_base_wall_visible = false;
        if (is_defined(this.mesh)) {
            this.mesh.visible = false;
        }
    },

    make_base_wall_visible: function() {
        this._make_base_wall_visible = true;
        if (is_defined(this.mesh)) {
            this.mesh.visible = true;
        }
    },

    create_base_mesh: function() {
        // Check if the there is an existing wall that needs to be fully cleaned up.
        // TODO : Refactor this!!!
        //this.resource_cleanup();

        if (!is_defined(this.material)) {
            this.material = new THREE.MeshBasicMaterial({
                // TODO : THE COLOR IS TEMPORARY!!!
                color: COLORS[0],
                //transparent: true,
                //opacity: 0.85,
                side: THREE.DoubleSide
            });
        }

        // Now re-create the base wall.
        this.geometry = new THREE.PlaneGeometry(this.width, this.height);
        this.mesh = new THREE.Mesh(this.geometry, this.material);
        //if (!this._make_base_wall_visible) {
        //    this.mesh.visible = false;
        //}
        this.object3D.add(this.mesh);
    },

    /* ___       __       ___         __                          __                __     ___  ___     ___
      |__  |    /  \  /\   |  | |\ | / _`    |  |  /\  |    |    /__`     /\  |\ | |  \     |  |__  \_/  |
      |    |___ \__/ /~~\  |  | | \| \__>    |/\| /~~\ |___ |___ .__/    /~~\ | \| |__/     |  |___ / \  |  */
    add_close_button: function() {
        var one_pixel_width = 1 / this.width;
        var x_start = 1 - (one_pixel_width * 16);
        var x_stop = 1;
        var total_percentage_of_parent_width = (x_stop - x_start);
        this.close_button = new Floating2DText(one_pixel_width * 16, ICON_CROSS, TYPE_ICON);

        this.close_button.set_attachment_vertical_offset(-8, HALF);
        this.close_button.set_attachment_horizontal_offset(0, -HALF + x_start + total_percentage_of_parent_width / 2);<commit_msg>abstracting floating rows for floating walls 09<commit_after>'use strict';

const COLORS = get_color_range_list(COLOR_FLOATING_WALL_BASE, COLOR_FLOATING_WALL_TOP, 8);

function FloatingWall(width, height, position, normal, world, scalable, default_background_color) {
    this.__init__(width, height, position, normal, world, scalable, default_background_color);
}

FloatingWall.prototype = {

    __init__: function (width, height, position, normal, world, scalable, default_background_color) {
        // Inherit from Attachmentable.
        Attachmentable.call(this, world);
        // Inherit from Animatable.
        Animatable.call(this);

        this.width = width;
        this.height = height;

        this.create_base_mesh();

        if (is_defined(normal)) {
            this.set_normal(normal.x, normal.y, normal.z, false);
        }
        if (is_defined(position)) {
            this.set_position(position.x, position.y, position.z, false);
        }

        // Inherit from Interactive.
        Interactive.call(this);
        // Inherit from Visibility.
        Visibility.call(this);

        this.scalable = scalable;
        if (!is_defined(this.scalable)) {
            this.scalable = false;
        }

        this.world.interactive_objects.push(this);
        this.engable = false;
        if (!this.scalable) {
            this.only_used_for_blocking_input = true;
        }

        if (is_defined(default_background_color)) {
            this.default_background_color = default_background_color;
        } else {
            this.default_background_color = COLOR_FLOATING_WALL_BASE;
        }
        this.set_background_color(this.default_background_color, true);

        //this.make_base_wall_visible();

        // REFACTORING ROWS!!!
        this._2D_rows = [];
        this.max_row_2D = -1;
        this._3D_rows = [];
        this.max_row_3D = 0;

        this.rows = [];

        // Inherit from Saveable but set to false by default.
        Saveable.call(this, ENTITY_TYPE_WALL);
        this.saveable = false;
        this.add_save_field(ENTITY_PROPERTY_WIDTH);
        this.add_save_field(ENTITY_PROPERTY_HEIGHT);
        this.add_save_field(ENTITY_PROPERTY_POSITION);
        this.add_save_field(ENTITY_PROPERTY_NORMAL);
        this.add_save_field(ENTITY_PROPERTY_IS_ROOT_ATTACHABLE);
        this.add_save_field(ENTITY_PROPERTY_3D_ROWS);
        this.add_save_field(ENTITY_PROPERTY_2D_ROWS);
    },

    make_base_wall_invisible: function() {
        this._make_base_wall_visible = false;
        if (is_defined(this.mesh)) {
            this.mesh.visible = false;
        }
    },

    make_base_wall_visible: function() {
        this._make_base_wall_visible = true;
        if (is_defined(this.mesh)) {
            this.mesh.visible = true;
        }
    },

    create_base_mesh: function() {
        // Check if the there is an existing wall that needs to be fully cleaned up.
        // TODO : Refactor this!!!
        //this.resource_cleanup();

        if (!is_defined(this.material)) {
            this.material = new THREE.MeshBasicMaterial({
                // TODO : THE COLOR IS TEMPORARY!!!
                color: COLORS[0],
                //transparent: true,
                //opacity: 0.85,
                side: THREE.DoubleSide
            });
        }

        // Now re-create the base wall.
        this.geometry = new THREE.PlaneGeometry(this.width, this.height);
        this.mesh = new THREE.Mesh(this.geometry, this.material);
        //if (!this._make_base_wall_visible) {
        //    this.mesh.visible = false;
        //}
        this.object3D.add(this.mesh);
    },

    /* ___       __       ___         __                          __                __     ___  ___     ___
      |__  |    /  \  /\   |  | |\ | / _`    |  |  /\  |    |    /__`     /\  |\ | |  \     |  |__  \_/  |
      |    |___ \__/ /~~\  |  | | \| \__>    |/\| /~~\ |___ |___ .__/    /~~\ | \| |__/     |  |___ / \  |  */
    add_close_button: function() {
        var one_pixel_width = 1 / this.width;
        var x_start = 1 - (one_pixel_width * 16);
        var x_stop = 1;
        var total_percentage_of_parent_width = (x_stop - x_start);
        this.close_button = new Floating2DText(one_pixel_width * 16, ICON_CROSS, TYPE_ICON, this.world);

        this.close_button.set_attachment_vertical_offset(-8, HALF);
        this.close_button.set_attachment_horizontal_offset(0, -HALF + x_start + total_percentage_of_parent_width / 2);
{'fraction_non_alphanumeric': 0.11404884606766749, 'fraction_numerical': 0.005825677795205019, 'mean_word_length': 2.014859844647079, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '424423', 'n_tokens_mistral': 2878, 'n_tokens_neox': 2783, 'n_words': 450}