| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 | /* This file is automatically rebuilt by the Cesium build process. */define(['./defaultValue-94c3e563', './Transforms-323408fe', './Matrix2-69c32d33', './RuntimeError-c581ca93', './ComponentDatatype-b1ea011a', './FrustumGeometry-9ff1d87f', './GeometryAttribute-cb73bb3f', './GeometryAttributes-7df9bef6', './_commonjsHelpers-3aae1032-f55dc0c4', './combine-761d9c3f', './WebGLConstants-7dccdc96', './Plane-069b6800', './VertexFormat-e46f29d6'], (function (defaultValue, Transforms, Matrix2, RuntimeError, ComponentDatatype, FrustumGeometry, GeometryAttribute, GeometryAttributes, _commonjsHelpers3aae1032, combine, WebGLConstants, Plane, VertexFormat) { 'use strict';  const PERSPECTIVE = 0;  const ORTHOGRAPHIC = 1;  /**   * A description of the outline of a frustum with the given the origin and orientation.   *   * @alias FrustumOutlineGeometry   * @constructor   *   * @param {Object} options Object with the following properties:   * @param {PerspectiveFrustum|OrthographicFrustum} options.frustum The frustum.   * @param {Cartesian3} options.origin The origin of the frustum.   * @param {Quaternion} options.orientation The orientation of the frustum.   */  function FrustumOutlineGeometry(options) {    //>>includeStart('debug', pragmas.debug);    RuntimeError.Check.typeOf.object("options", options);    RuntimeError.Check.typeOf.object("options.frustum", options.frustum);    RuntimeError.Check.typeOf.object("options.origin", options.origin);    RuntimeError.Check.typeOf.object("options.orientation", options.orientation);    //>>includeEnd('debug');    const frustum = options.frustum;    const orientation = options.orientation;    const origin = options.origin;    // This is private because it is used by DebugCameraPrimitive to draw a multi-frustum by    // creating multiple FrustumOutlineGeometrys. This way the near plane of one frustum doesn't overlap    // the far plane of another.    const drawNearPlane = defaultValue.defaultValue(options._drawNearPlane, true);    let frustumType;    let frustumPackedLength;    if (frustum instanceof FrustumGeometry.PerspectiveFrustum) {      frustumType = PERSPECTIVE;      frustumPackedLength = FrustumGeometry.PerspectiveFrustum.packedLength;    } else if (frustum instanceof FrustumGeometry.OrthographicFrustum) {      frustumType = ORTHOGRAPHIC;      frustumPackedLength = FrustumGeometry.OrthographicFrustum.packedLength;    }    this._frustumType = frustumType;    this._frustum = frustum.clone();    this._origin = Matrix2.Cartesian3.clone(origin);    this._orientation = Transforms.Quaternion.clone(orientation);    this._drawNearPlane = drawNearPlane;    this._workerName = "createFrustumOutlineGeometry";    /**     * The number of elements used to pack the object into an array.     * @type {Number}     */    this.packedLength =      2 + frustumPackedLength + Matrix2.Cartesian3.packedLength + Transforms.Quaternion.packedLength;  }  /**   * Stores the provided instance into the provided array.   *   * @param {FrustumOutlineGeometry} value The value to pack.   * @param {Number[]} array The array to pack into.   * @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.   *   * @returns {Number[]} The array that was packed into   */  FrustumOutlineGeometry.pack = function (value, array, startingIndex) {    //>>includeStart('debug', pragmas.debug);    RuntimeError.Check.typeOf.object("value", value);    RuntimeError.Check.defined("array", array);    //>>includeEnd('debug');    startingIndex = defaultValue.defaultValue(startingIndex, 0);    const frustumType = value._frustumType;    const frustum = value._frustum;    array[startingIndex++] = frustumType;    if (frustumType === PERSPECTIVE) {      FrustumGeometry.PerspectiveFrustum.pack(frustum, array, startingIndex);      startingIndex += FrustumGeometry.PerspectiveFrustum.packedLength;    } else {      FrustumGeometry.OrthographicFrustum.pack(frustum, array, startingIndex);      startingIndex += FrustumGeometry.OrthographicFrustum.packedLength;    }    Matrix2.Cartesian3.pack(value._origin, array, startingIndex);    startingIndex += Matrix2.Cartesian3.packedLength;    Transforms.Quaternion.pack(value._orientation, array, startingIndex);    startingIndex += Transforms.Quaternion.packedLength;    array[startingIndex] = value._drawNearPlane ? 1.0 : 0.0;    return array;  };  const scratchPackPerspective = new FrustumGeometry.PerspectiveFrustum();  const scratchPackOrthographic = new FrustumGeometry.OrthographicFrustum();  const scratchPackQuaternion = new Transforms.Quaternion();  const scratchPackorigin = new Matrix2.Cartesian3();  /**   * Retrieves an instance from a packed array.   *   * @param {Number[]} array The packed array.   * @param {Number} [startingIndex=0] The starting index of the element to be unpacked.   * @param {FrustumOutlineGeometry} [result] The object into which to store the result.   */  FrustumOutlineGeometry.unpack = function (array, startingIndex, result) {    //>>includeStart('debug', pragmas.debug);    RuntimeError.Check.defined("array", array);    //>>includeEnd('debug');    startingIndex = defaultValue.defaultValue(startingIndex, 0);    const frustumType = array[startingIndex++];    let frustum;    if (frustumType === PERSPECTIVE) {      frustum = FrustumGeometry.PerspectiveFrustum.unpack(        array,        startingIndex,        scratchPackPerspective      );      startingIndex += FrustumGeometry.PerspectiveFrustum.packedLength;    } else {      frustum = FrustumGeometry.OrthographicFrustum.unpack(        array,        startingIndex,        scratchPackOrthographic      );      startingIndex += FrustumGeometry.OrthographicFrustum.packedLength;    }    const origin = Matrix2.Cartesian3.unpack(array, startingIndex, scratchPackorigin);    startingIndex += Matrix2.Cartesian3.packedLength;    const orientation = Transforms.Quaternion.unpack(      array,      startingIndex,      scratchPackQuaternion    );    startingIndex += Transforms.Quaternion.packedLength;    const drawNearPlane = array[startingIndex] === 1.0;    if (!defaultValue.defined(result)) {      return new FrustumOutlineGeometry({        frustum: frustum,        origin: origin,        orientation: orientation,        _drawNearPlane: drawNearPlane,      });    }    const frustumResult =      frustumType === result._frustumType ? result._frustum : undefined;    result._frustum = frustum.clone(frustumResult);    result._frustumType = frustumType;    result._origin = Matrix2.Cartesian3.clone(origin, result._origin);    result._orientation = Transforms.Quaternion.clone(orientation, result._orientation);    result._drawNearPlane = drawNearPlane;    return result;  };  /**   * Computes the geometric representation of a frustum outline, including its vertices, indices, and a bounding sphere.   *   * @param {FrustumOutlineGeometry} frustumGeometry A description of the frustum.   * @returns {Geometry|undefined} The computed vertices and indices.   */  FrustumOutlineGeometry.createGeometry = function (frustumGeometry) {    const frustumType = frustumGeometry._frustumType;    const frustum = frustumGeometry._frustum;    const origin = frustumGeometry._origin;    const orientation = frustumGeometry._orientation;    const drawNearPlane = frustumGeometry._drawNearPlane;    const positions = new Float64Array(3 * 4 * 2);    FrustumGeometry.FrustumGeometry._computeNearFarPlanes(      origin,      orientation,      frustumType,      frustum,      positions    );    const attributes = new GeometryAttributes.GeometryAttributes({      position: new GeometryAttribute.GeometryAttribute({        componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,        componentsPerAttribute: 3,        values: positions,      }),    });    let offset;    let index;    const numberOfPlanes = drawNearPlane ? 2 : 1;    const indices = new Uint16Array(8 * (numberOfPlanes + 1));    // Build the near/far planes    let i = drawNearPlane ? 0 : 1;    for (; i < 2; ++i) {      offset = drawNearPlane ? i * 8 : 0;      index = i * 4;      indices[offset] = index;      indices[offset + 1] = index + 1;      indices[offset + 2] = index + 1;      indices[offset + 3] = index + 2;      indices[offset + 4] = index + 2;      indices[offset + 5] = index + 3;      indices[offset + 6] = index + 3;      indices[offset + 7] = index;    }    // Build the sides of the frustums    for (i = 0; i < 2; ++i) {      offset = (numberOfPlanes + i) * 8;      index = i * 4;      indices[offset] = index;      indices[offset + 1] = index + 4;      indices[offset + 2] = index + 1;      indices[offset + 3] = index + 5;      indices[offset + 4] = index + 2;      indices[offset + 5] = index + 6;      indices[offset + 6] = index + 3;      indices[offset + 7] = index + 7;    }    return new GeometryAttribute.Geometry({      attributes: attributes,      indices: indices,      primitiveType: GeometryAttribute.PrimitiveType.LINES,      boundingSphere: Transforms.BoundingSphere.fromVertices(positions),    });  };  function createFrustumOutlineGeometry(frustumGeometry, offset) {    if (defaultValue.defined(offset)) {      frustumGeometry = FrustumOutlineGeometry.unpack(frustumGeometry, offset);    }    return FrustumOutlineGeometry.createGeometry(frustumGeometry);  }  return createFrustumOutlineGeometry;}));
 |