createCircleOutlineGeometry.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /* This file is automatically rebuilt by the Cesium build process. */
  2. define(['./defined-26bd4a03', './Check-da037458', './freezeObject-2d83f591', './defaultValue-f2e68450', './Math-fa6e45cb', './Cartesian2-2a723276', './defineProperties-6f7a50f2', './Transforms-65aba0a4', './RuntimeError-ad75c885', './WebGLConstants-497deb20', './ComponentDatatype-69643096', './GeometryAttribute-ed359d71', './when-ee12a2cb', './GeometryAttributes-eecc9f43', './IndexDatatype-3de60176', './GeometryOffsetAttribute-cb30cd97', './EllipseGeometryLibrary-ff991705', './EllipseOutlineGeometry-e0a3b205'], function (defined, Check, freezeObject, defaultValue, _Math, Cartesian2, defineProperties, Transforms, RuntimeError, WebGLConstants, ComponentDatatype, GeometryAttribute, when, GeometryAttributes, IndexDatatype, GeometryOffsetAttribute, EllipseGeometryLibrary, EllipseOutlineGeometry) { '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. * var circle = new Cesium.CircleOutlineGeometry({
  27. * center : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
  28. * radius : 100000.0
  29. * });
  30. * var geometry = Cesium.CircleOutlineGeometry.createGeometry(circle);
  31. */
  32. function CircleOutlineGeometry(options) {
  33. options = defaultValue.defaultValue(options, defaultValue.defaultValue.EMPTY_OBJECT);
  34. var radius = options.radius;
  35. //>>includeStart('debug', pragmas.debug);
  36. Check.Check.typeOf.number('radius', radius);
  37. //>>includeEnd('debug');
  38. var 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. Check.Check.typeOf.object('value', value);
  68. //>>includeEnd('debug');
  69. return EllipseOutlineGeometry.EllipseOutlineGeometry.pack(value._ellipseGeometry, array, startingIndex);
  70. };
  71. var scratchEllipseGeometry = new EllipseOutlineGeometry.EllipseOutlineGeometry({
  72. center : new Cartesian2.Cartesian3(),
  73. semiMajorAxis : 1.0,
  74. semiMinorAxis : 1.0
  75. });
  76. var scratchOptions = {
  77. center : new Cartesian2.Cartesian3(),
  78. radius : undefined,
  79. ellipsoid : Cartesian2.Ellipsoid.clone(Cartesian2.Ellipsoid.UNIT_SPHERE),
  80. height : undefined,
  81. extrudedHeight : undefined,
  82. granularity : undefined,
  83. numberOfVerticalLines : undefined,
  84. semiMajorAxis : undefined,
  85. semiMinorAxis : undefined
  86. };
  87. /**
  88. * Retrieves an instance from a packed array.
  89. *
  90. * @param {Number[]} array The packed array.
  91. * @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
  92. * @param {CircleOutlineGeometry} [result] The object into which to store the result.
  93. * @returns {CircleOutlineGeometry} The modified result parameter or a new CircleOutlineGeometry instance if one was not provided.
  94. */
  95. CircleOutlineGeometry.unpack = function(array, startingIndex, result) {
  96. var ellipseGeometry = EllipseOutlineGeometry.EllipseOutlineGeometry.unpack(array, startingIndex, scratchEllipseGeometry);
  97. scratchOptions.center = Cartesian2.Cartesian3.clone(ellipseGeometry._center, scratchOptions.center);
  98. scratchOptions.ellipsoid = Cartesian2.Ellipsoid.clone(ellipseGeometry._ellipsoid, scratchOptions.ellipsoid);
  99. scratchOptions.height = ellipseGeometry._height;
  100. scratchOptions.extrudedHeight = ellipseGeometry._extrudedHeight;
  101. scratchOptions.granularity = ellipseGeometry._granularity;
  102. scratchOptions.numberOfVerticalLines = ellipseGeometry._numberOfVerticalLines;
  103. if (!defined.defined(result)) {
  104. scratchOptions.radius = ellipseGeometry._semiMajorAxis;
  105. return new CircleOutlineGeometry(scratchOptions);
  106. }
  107. scratchOptions.semiMajorAxis = ellipseGeometry._semiMajorAxis;
  108. scratchOptions.semiMinorAxis = ellipseGeometry._semiMinorAxis;
  109. result._ellipseGeometry = new EllipseOutlineGeometry.EllipseOutlineGeometry(scratchOptions);
  110. return result;
  111. };
  112. /**
  113. * Computes the geometric representation of an outline of a circle on an ellipsoid, including its vertices, indices, and a bounding sphere.
  114. *
  115. * @param {CircleOutlineGeometry} circleGeometry A description of the circle.
  116. * @returns {Geometry|undefined} The computed vertices and indices.
  117. */
  118. CircleOutlineGeometry.createGeometry = function(circleGeometry) {
  119. return EllipseOutlineGeometry.EllipseOutlineGeometry.createGeometry(circleGeometry._ellipseGeometry);
  120. };
  121. function createCircleOutlineGeometry(circleGeometry, offset) {
  122. if (defined.defined(offset)) {
  123. circleGeometry = CircleOutlineGeometry.unpack(circleGeometry, offset);
  124. }
  125. circleGeometry._ellipseGeometry._center = Cartesian2.Cartesian3.clone(circleGeometry._ellipseGeometry._center);
  126. circleGeometry._ellipseGeometry._ellipsoid = Cartesian2.Ellipsoid.clone(circleGeometry._ellipseGeometry._ellipsoid);
  127. return CircleOutlineGeometry.createGeometry(circleGeometry);
  128. }
  129. return createCircleOutlineGeometry;
  130. });