1 line
16 KiB
Plaintext
1 line
16 KiB
Plaintext
|
{"version":3,"file":"AxisAlignedBoundingBox-2a0ca7ef.js","sources":["../../../../Source/Core/AxisAlignedBoundingBox.js"],"sourcesContent":["import Cartesian3 from \"./Cartesian3.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport Intersect from \"./Intersect.js\";\n\n/**\n * Creates an instance of an AxisAlignedBoundingBox from the minimum and maximum points along the x, y, and z axes.\n * @alias AxisAlignedBoundingBox\n * @constructor\n *\n * @param {Cartesian3} [minimum=Cartesian3.ZERO] The minimum point along the x, y, and z axes.\n * @param {Cartesian3} [maximum=Cartesian3.ZERO] The maximum point along the x, y, and z axes.\n * @param {Cartesian3} [center] The center of the box; automatically computed if not supplied.\n *\n * @see BoundingSphere\n * @see BoundingRectangle\n */\nfunction AxisAlignedBoundingBox(minimum, maximum, center) {\n /**\n * The minimum point defining the bounding box.\n * @type {Cartesian3}\n * @default {@link Cartesian3.ZERO}\n */\n this.minimum = Cartesian3.clone(defaultValue(minimum, Cartesian3.ZERO));\n\n /**\n * The maximum point defining the bounding box.\n * @type {Cartesian3}\n * @default {@link Cartesian3.ZERO}\n */\n this.maximum = Cartesian3.clone(defaultValue(maximum, Cartesian3.ZERO));\n\n // If center was not defined, compute it.\n if (!defined(center)) {\n center = Cartesian3.midpoint(this.minimum, this.maximum, new Cartesian3());\n } else {\n center = Cartesian3.clone(center);\n }\n\n /**\n * The center point of the bounding box.\n * @type {Cartesian3}\n */\n this.center = center;\n}\n\n/**\n * Creates an instance of an AxisAlignedBoundingBox from its corners.\n *\n * @param {Cartesian3} minimum The minimum point along the x, y, and z axes.\n * @param {Cartesian3} maximum The maximum point along the x, y, and z axes.\n * @param {AxisAlignedBoundingBox} [result] The object onto which to store the result.\n * @returns {AxisAlignedBoundingBox} The modified result parameter or a new AxisAlignedBoundingBox instance if one was not provided.\n *\n * @example\n * // Compute an axis aligned bounding box from the two corners.\n * const box = Cesium.AxisAlignedBoundingBox.fromCorners(new Cesium.Cartesian3(-1, -1, -1), new Cesium.Cartesian3(1, 1, 1));\n */\nAxisAlignedBoundingBox.fromCorners = function (minimum, maximum, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"minimum\", minimum);\n Check.defined(\"maximum\", maximum);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new AxisAlignedBoundingBox();\n }\n\n result.minimum = Cartesian3.clone(minimum, result.minimum);\n result.maximum = Cartesian3.clone(maximum, result.maximum);\n result.center = Cartesian3.midpoint(minimum, maximum, result.center);\n\n return result;\n};\n\n/**\n * Computes an instance of an AxisAlignedBoundingBox. The box is determined by\n * finding the points spaced the farthest apart on the x, y, and z axes.\n *\n * @param {Cartesian3[]} positions List of points that the bounding box will enclose. Each point must have a <code>x</code>, <code>y</code>, and <code>z</code> properties.\n * @param {AxisAlignedBoundingBox} [result] The object onto which to store the result.\n * @returns {AxisAlignedBoundingBox} The modified result parameter or a new AxisAlignedBoundingBox instance if one was not provided.\n *\n * @example\n * // Compute an axis aligned bounding box enclosing two points.\n * const box = Cesium.AxisAlignedBoundingBox.fromPoints([new Cesium.Cartesian3(2, 0, 0), new Cesium.Cartesian3(-2, 0, 0)]);\n */\nAxisAlignedBoundingBox.fromPoints = function (positions, result) {\n if (!defined(result)) {\n result = new AxisAlignedBoundingBox();\n }\n\n if (!defined(positions) || positions.length === 0) {\n result.minimum = Cartesian3.clone(Cartesian3.ZERO, result.minimum);\n result.maximum = Cartesian3.clone(Cartesian3.ZERO, result.maximum);\n result.center = Cartesian3.clone(Cartesian3.ZERO, result.center);\n return result;\n
|