<commit_before>/**
 A **BoundaryGeometry** is a {{#crossLink "Geometry"}}{{/crossLink}} that shows the object-aligned wireframe bounding box (OBB)
 of a {{#crossLink "Boundary3D"}}{{/crossLink}}.

 ## Example

 ````javascript

 ````

 @class BoundaryGeometry
 @module XEO
 @submodule geometry
 @constructor
 @param [scene] {Scene} Parent {{#crossLink "Scene"}}Scene{{/crossLink}} - creates this BoundaryGeometry in the default
 {{#crossLink "Scene"}}Scene{{/crossLink}} when omitted.
 @param [cfg] {*} Configs
 @param [cfg.id] {String} Optional ID, unique among all components in the parent {{#crossLink "Scene"}}Scene{{/crossLink}},
 generated automatically when omitted.
 @param [cfg.meta] {String:Object} Optional map of user-defined metadata to attach to this BoundaryGeometry.
 @param [cfg.boundary] {Boundary3D} ID or instance of a {{#crossLink "Boundary3D"}}{{/crossLink}}
 @extends Component
 */
(function () {

    "use strict";

    XEO.BoundaryGeometry = XEO.Geometry.extend({

        type: "XEO.BoundaryGeometry",

        _init: function (cfg) {

            this._super(cfg);

            this.primitive = cfg.primitive || "lines";

            this.indices = [
                0, 1, 1, 2, 2, 3, 3, 0, 4,
                5, 5, 6, 6, 7, 7, 4, 0, 4,
                1, 5, 2, 6, 3, 7
            ];

            if (cfg.boundary) {
                this.boundary = cfg.boundary;

            } else if (cfg.obb) {
                this.obb = cfg.obb;

            } else if (cfg.aabb) {
                this.aabb = cfg.aabb;

            } else if (cfg.positions) {
                this.positions = cfg.positions;

            } else {
                this.positions = [
                    1.0, 1.0, 1.0,
                    1.0, -1.0, 1.0,
                    -1.0, -1.0, 1.0,
                    -1.0, 1.0, 1.0,
                    1.0, 1.0, -1.0,
                    1.0, -1.0, -1.0,
                    -1.0, -1.0, -1.0,
                    -1.0, 1.0, -1.0
                ];
            }
        },

        _props: {

            /**
             * The {{#crossLink "Boundary3D"}}{{/crossLink}} we are showing.
             *
             * Fires a {{#crossLink "BoundaryGeometry/boundary:event"}}{{/crossLink}} event on change.
             *
             * @property Boundary3D
             * @type Boundary3D
             */
            boundary: {

                set: function (value) {

                    // Unsubscribe from old boundary's events

                    var oldBoundary = this._children.boundary;

                    if (oldBoundary) {

                        if ((!value || (value.id !== undefined ? value.id : value) !== oldBoundary.id)) {
                            oldBoundary.off(this._onBoundaryUpdated);
                            oldBoundary.off(this._onBoundaryDestroyed);
                        }
                    }

                    /**
                     * Fired whenever this BoundaryGeometry's  {{#crossLink "BoundaryGeometry/boundary:property"}}{{/crossLink}} property changes.
                     *
                     * @event boundary
                     * @param value The property's new value
                     */
                    this._setChild("boundary", value);

                    var boundary = this._children.boundary;

                    if (boundary) {

                        var self = this;
                        var geometryDirty = false;

                        // Whenever the new boundary fires a change event,
                        // schedule a geometry rebuild for the next 'tick'.

                        this._onBoundaryUpdated = boundary.on("updated",
                            function () {
                                if (geometryDirty) {
                                    return;
                                }
                                geometryDirty = true;
                                XEO.scheduleTask(function () {
                                        self._setPositionsFromOBB(boundary.obb);
                                        geometryDirty = false;
                                    });
                            });

                        this._onBoundaryDestroyed = boundary.on("destroyed",
                            function () {
                                self.boundary = null; // Unsubscribes from old boundary's events
                            });

                        this._setPositionsFromOBB(boundary.obb);
                    }
                },

                get: function () {
                    return this._children.boundary;
                }
            },

            /**
             * The {{#crossLink "Boundary3D"}}{{/crossLink}} we are showing.
             *
             * Fires a {{#crossLink "BoundaryGeometry/boundary:event"}}{{/crossLink}} event on change.
             *
             * @property Boundary3D
             * @type Boundary3D
             */
            obb: {

                set: function (value) {

                    if (!value) {
                        return;
                    }

                    if (this._children.boundary) {
                        this.boundary = null;
                    }

                    this._setPositionsFromOBB(value);
                }
            },

            /**
             * Assign to an Axis-aligned bounding-box
             *
             * @property aabb
             * @type Boundary3D
             */
            aabb: {

                set: function (value) {

                    if (!value) {
                        return;
                    }

                    if (this._children.boundary) {
                        this.boundary = null;
                    }

                    this._setPositionsFromAABB(value);
                }
            }
        },

        _setPositionsFromOBB: function (obb) {
            this.positions = [
                obb[2][0], obb[2][1], obb[4][2],
                obb[2][0], obb[4][1], obb[4][2],
                obb[0][0], obb[4][1], obb[4][2],
                obb[0][0], obb[2][1], obb[4][2],
                obb[2][0], obb[2][1], obb[3][2],
                obb[2][0], obb[4][1], obb[3][2],
                obb[0][0], obb[4][1], obb[3][2],
                obb[0][0], obb[2][1], obb[3][2]
            ];
        },

        _setPositionsFromAABB: function (aabb) {
            this.positions = [
                aabb.max[0], aabb.max[1], aabb.max[2],
                aabb.max[0], aabb.min[1], aabb.max[2],
                aabb.min[0], aabb.min[1], aabb.max[2],
                aabb.min[0], aabb.max[1], aabb.max[2],
                aabb.max[0], aabb.max[1], aabb.min[2],
                aabb.max[0], aabb.min[1], aabb.min[2],
                aabb.min[0], aabb.min[1], aabb.min[2],
                aabb.min[0], aabb.max[1], aabb.min[2]
            ];
        },<commit_msg>Fix obb property setter for XEO.BoundaryGeometry<commit_after>/**
 A **BoundaryGeometry** is a {{#crossLink "Geometry"}}{{/crossLink}} that shows the object-aligned wireframe bounding box (OBB)
 of a {{#crossLink "Boundary3D"}}{{/crossLink}}.

 ## Example

 ````javascript

 ````

 @class BoundaryGeometry
 @module XEO
 @submodule geometry
 @constructor
 @param [scene] {Scene} Parent {{#crossLink "Scene"}}Scene{{/crossLink}} - creates this BoundaryGeometry in the default
 {{#crossLink "Scene"}}Scene{{/crossLink}} when omitted.
 @param [cfg] {*} Configs
 @param [cfg.id] {String} Optional ID, unique among all components in the parent {{#crossLink "Scene"}}Scene{{/crossLink}},
 generated automatically when omitted.
 @param [cfg.meta] {String:Object} Optional map of user-defined metadata to attach to this BoundaryGeometry.
 @param [cfg.boundary] {Boundary3D} ID or instance of a {{#crossLink "Boundary3D"}}{{/crossLink}}
 @extends Component
 */
(function () {

    "use strict";

    XEO.BoundaryGeometry = XEO.Geometry.extend({

        type: "XEO.BoundaryGeometry",

        _init: function (cfg) {

            this._super(cfg);

            this.primitive = cfg.primitive || "lines";

            this.indices = [
                0, 1, 1, 2, 2, 3, 3, 0, 4,
                5, 5, 6, 6, 7, 7, 4, 0, 4,
                1, 5, 2, 6, 3, 7
            ];

            if (cfg.boundary) {
                this.boundary = cfg.boundary;

            } else if (cfg.obb) {
                this.obb = cfg.obb;

            } else if (cfg.aabb) {
                this.aabb = cfg.aabb;

            } else if (cfg.positions) {
                this.positions = cfg.positions;

            } else {
                this.positions = [
                    1.0, 1.0, 1.0,
                    1.0, -1.0, 1.0,
                    -1.0, -1.0, 1.0,
                    -1.0, 1.0, 1.0,
                    1.0, 1.0, -1.0,
                    1.0, -1.0, -1.0,
                    -1.0, -1.0, -1.0,
                    -1.0, 1.0, -1.0
                ];
            }
        },

        _props: {

            /**
             * The {{#crossLink "Boundary3D"}}{{/crossLink}} we are showing.
             *
             * Fires a {{#crossLink "BoundaryGeometry/boundary:event"}}{{/crossLink}} event on change.
             *
             * @property Boundary3D
             * @type Boundary3D
             */
            boundary: {

                set: function (value) {

                    // Unsubscribe from old boundary's events

                    var oldBoundary = this._children.boundary;

                    if (oldBoundary) {

                        if ((!value || (value.id !== undefined ? value.id : value) !== oldBoundary.id)) {
                            oldBoundary.off(this._onBoundaryUpdated);
                            oldBoundary.off(this._onBoundaryDestroyed);
                        }
                    }

                    /**
                     * Fired whenever this BoundaryGeometry's  {{#crossLink "BoundaryGeometry/boundary:property"}}{{/crossLink}} property changes.
                     *
                     * @event boundary
                     * @param value The property's new value
                     */
                    this._setChild("boundary", value);

                    var boundary = this._children.boundary;

                    if (boundary) {

                        var self = this;
                        var geometryDirty = false;

                        // Whenever the new boundary fires a change event,
                        // schedule a geometry rebuild for the next 'tick'.

                        this._onBoundaryUpdated = boundary.on("updated",
                            function () {
                                if (geometryDirty) {
                                    return;
                                }
                                geometryDirty = true;
                                XEO.scheduleTask(function () {
                                        self._setPositionsFromOBB(boundary.obb);
                                        geometryDirty = false;
                                    });
                            });

                        this._onBoundaryDestroyed = boundary.on("destroyed",
                            function () {
                                self.boundary = null; // Unsubscribes from old boundary's events
                            });

                        this._setPositionsFromOBB(boundary.obb);
                    }
                },

                get: function () {
                    return this._children.boundary;
                }
            },

            /**
             * The {{#crossLink "Boundary3D"}}{{/crossLink}} we are showing.
             *
             * Fires a {{#crossLink "BoundaryGeometry/boundary:event"}}{{/crossLink}} event on change.
             *
             * @property Boundary3D
             * @type Boundary3D
             */
            obb: {

                set: function (value) {

                    if (!value) {
                        return;
                    }

                    if (this._children.boundary) {
                        this.boundary = null;
                    }

                    this._setPositionsFromOBB(value);
                }
            },

            /**
             * Assign to an Axis-aligned bounding-box
             *
             * @property aabb
             * @type Boundary3D
             */
            aabb: {

                set: function (value) {

                    if (!value) {
                        return;
                    }

                    if (this._children.boundary) {
                        this.boundary = null;
                    }

                    this._setPositionsFromAABB(value);
                }
            }
        },

        _setPositionsFromOBB: function (obb) {
            this.positions = [
                obb[0][0], obb[0][1], obb[0][2],
                obb[1][0], obb[1][1], obb[1][2],
                obb[2][0], obb[2][1], obb[2][2],
                obb[3][0], obb[3][1], obb[3][2],
                obb[4][0], obb[4][1], obb[4][2],
                obb[5][0], obb[5][1], obb[5][2],
                obb[6][0], obb[6][1], obb[6][2],
                obb[7][0], obb[7][1], obb[7][2]
            ];
        },

        _setPositionsFromAABB: function (aabb) {
            this.positions = [
                aabb.max[0], aabb.max[1], aabb.max[2],
                aabb.max[0], aabb.min[1], aabb.max[2],
                aabb.min[0], aabb.min[1], aabb.max[2],
                aabb.min[0], aabb.max[1], aabb.max[2],
                aabb.max[0], aabb.max[1], aabb.min[2],
                aabb.max[0], aabb.min[1], aabb.min[2],
                aabb.min[0], aabb.min[1], aabb.min[2],
                aabb.min[0], aabb.max[1], aabb.min[2]
            ];
        },
{'fraction_non_alphanumeric': 0.1259302073549599, 'fraction_numerical': 0.0222527274040893, 'mean_word_length': 1.0699865410497982, '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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7227228', 'n_tokens_mistral': 4077, 'n_tokens_neox': 3665, 'n_words': 791}