createCircleOutlineGeometry.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* This file is automatically rebuilt by the Cesium build process. */
  2. define(['./Matrix2-fc7e9822', './RuntimeError-c581ca93', './defaultValue-94c3e563', './EllipseOutlineGeometry-7ecc2ea8', './ComponentDatatype-4a60b8d6', './WebGLConstants-7dccdc96', './GeometryOffsetAttribute-3e8c299c', './Transforms-a076dbe6', './_commonjsHelpers-3aae1032-f55dc0c4', './combine-761d9c3f', './EllipseGeometryLibrary-4199bc89', './GeometryAttribute-2ecf73f6', './GeometryAttributes-7df9bef6', './IndexDatatype-db156785'], (function (Matrix2, RuntimeError, defaultValue, EllipseOutlineGeometry, ComponentDatatype, WebGLConstants, GeometryOffsetAttribute, Transforms, _commonjsHelpers3aae1032, combine, EllipseGeometryLibrary, GeometryAttribute, GeometryAttributes, IndexDatatype) { 'use strict';
  3. /**
  4. * A description of the outline of a circle on the ellipsoid.
  5. *
  6. * @alias CircleOutlineGeometry
  7. * @constructor
  8. *
  9. * @param {Object} options Object with the following properties:
  10. * @param {Cartesian3} options.center The circle's center point in the fixed frame.
  11. * @param {Number} options.radius The radius in meters.
  12. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid the circle will be on.
  13. * @param {Number} [options.height=0.0] The distance in meters between the circle and the ellipsoid surface.
  14. * @param {Number} [options.granularity=0.02] The angular distance between points on the circle in radians.
  15. * @param {Number} [options.extrudedHeight=0.0] The distance in meters between the circle's extruded face and the ellipsoid surface.
  16. * @param {Number} [options.numberOfVerticalLines=16] Number of lines to draw between the top and bottom of an extruded circle.
  17. *
  18. * @exception {DeveloperError} radius must be greater than zero.
  19. * @exception {DeveloperError} granularity must be greater than zero.
  20. *
  21. * @see CircleOutlineGeometry.createGeometry
  22. * @see Packable
  23. *
  24. * @example
  25. * // Create a circle.
  26. * const circle = new Cesium.CircleOutlineGeometry({
  27. * center : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
  28. * radius : 100000.0
  29. * });
  30. * const geometry = Cesium.CircleOutlineGeometry.createGeometry(circle);
  31. */
  32. function CircleOutlineGeometry(options) {
  33. options = defaultValue.defaultValue(options, defaultValue.defaultValue.EMPTY_OBJECT);
  34. const radius = options.radius;
  35. //>>includeStart('debug', pragmas.debug);
  36. RuntimeError.Check.typeOf.number("radius", radius);
  37. //>>includeEnd('debug');
  38. const ellipseGeometryOptions = {
  39. center: options.center,
  40. semiMajorAxis: radius,
  41. semiMinorAxis: radius,
  42. ellipsoid: options.ellipsoid,
  43. height: options.height,
  44. extrudedHeight: options.extrudedHeight,
  45. granularity: options.granularity,
  46. numberOfVerticalLines: options.numberOfVerticalLines,
  47. };
  48. this._ellipseGeometry = new EllipseOutlineGeometry.EllipseOutlineGeometry(ellipseGeometryOptions);
  49. this._workerName = "createCircleOutlineGeometry";
  50. }
  51. /**
  52. * The number of elements used to pack the object into an array.
  53. * @type {Number}
  54. */
  55. CircleOutlineGeometry.packedLength = EllipseOutlineGeometry.EllipseOutlineGeometry.packedLength;
  56. /**
  57. * Stores the provided instance into the provided array.
  58. *
  59. * @param {CircleOutlineGeometry} value The value to pack.
  60. * @param {Number[]} array The array to pack into.
  61. * @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
  62. *
  63. * @returns {Number[]} The array that was packed into
  64. */
  65. CircleOutlineGeometry.pack = function (value, array, startingIndex) {
  66. //>>includeStart('debug', pragmas.debug);
  67. RuntimeError.Check.typeOf.object("value", value);
  68. //>>includeEnd('debug');
  69. return EllipseOutlineGeometry.EllipseOutlineGeometry.pack(
  70. value._ellipseGeometry,
  71. array,
  72. startingIndex
  73. );
  74. };
  75. const scratchEllipseGeometry = new EllipseOutlineGeometry.EllipseOutlineGeometry({
  76. center: new Matrix2.Cartesian3(),
  77. semiMajorAxis: 1.0,
  78. semiMinorAxis: 1.0,
  79. });
  80. const scratchOptions = {
  81. center: new Matrix2.Cartesian3(),
  82. radius: undefined,
  83. ellipsoid: Matrix2.Ellipsoid.clone(Matrix2.Ellipsoid.UNIT_SPHERE),
  84. height: undefined,
  85. extrudedHeight: undefined,
  86. granularity: undefined,
  87. numberOfVerticalLines: undefined,
  88. semiMajorAxis: undefined,
  89. semiMinorAxis: undefined,
  90. };
  91. /**
  92. * Retrieves an instance from a packed array.
  93. *
  94. * @param {Number[]} array The packed array.
  95. * @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
  96. * @param {CircleOutlineGeometry} [result] The object into which to store the result.
  97. * @returns {CircleOutlineGeometry} The modified result parameter or a new CircleOutlineGeometry instance if one was not provided.
  98. */
  99. CircleOutlineGeometry.unpack = function (array, startingIndex, result) {
  100. const ellipseGeometry = EllipseOutlineGeometry.EllipseOutlineGeometry.unpack(
  101. array,
  102. startingIndex,
  103. scratchEllipseGeometry
  104. );
  105. scratchOptions.center = Matrix2.Cartesian3.clone(
  106. ellipseGeometry._center,
  107. scratchOptions.center
  108. );
  109. scratchOptions.ellipsoid = Matrix2.Ellipsoid.clone(
  110. ellipseGeometry._ellipsoid,
  111. scratchOptions.ellipsoid
  112. );
  113. scratchOptions.height = ellipseGeometry._height;
  114. scratchOptions.extrudedHeight = ellipseGeometry._extrudedHeight;
  115. scratchOptions.granularity = ellipseGeometry._granularity;
  116. scratchOptions.numberOfVerticalLines = ellipseGeometry._numberOfVerticalLines;
  117. if (!defaultValue.defined(result)) {
  118. scratchOptions.radius = ellipseGeometry._semiMajorAxis;
  119. return new CircleOutlineGeometry(scratchOptions);
  120. }
  121. scratchOptions.semiMajorAxis = ellipseGeometry._semiMajorAxis;
  122. scratchOptions.semiMinorAxis = ellipseGeometry._semiMinorAxis;
  123. result._ellipseGeometry = new EllipseOutlineGeometry.EllipseOutlineGeometry(scratchOptions);
  124. return result;
  125. };
  126. /**
  127. * Computes the geometric representation of an outline of a circle on an ellipsoid, including its vertices, indices, and a bounding sphere.
  128. *
  129. * @param {CircleOutlineGeometry} circleGeometry A description of the circle.
  130. * @returns {Geometry|undefined} The computed vertices and indices.
  131. */
  132. CircleOutlineGeometry.createGeometry = function (circleGeometry) {
  133. return EllipseOutlineGeometry.EllipseOutlineGeometry.createGeometry(circleGeometry._ellipseGeometry);
  134. };
  135. function createCircleOutlineGeometry(circleGeometry, offset) {
  136. if (defaultValue.defined(offset)) {
  137. circleGeometry = CircleOutlineGeometry.unpack(circleGeometry, offset);
  138. }
  139. circleGeometry._ellipseGeometry._center = Matrix2.Cartesian3.clone(
  140. circleGeometry._ellipseGeometry._center
  141. );
  142. circleGeometry._ellipseGeometry._ellipsoid = Matrix2.Ellipsoid.clone(
  143. circleGeometry._ellipseGeometry._ellipsoid
  144. );
  145. return CircleOutlineGeometry.createGeometry(circleGeometry);
  146. }
  147. return createCircleOutlineGeometry;
  148. }));