CylinderGeometryLibrary-365438d7.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * @license
  3. * Cesium - https://github.com/CesiumGS/cesium
  4. * Version 1.95
  5. *
  6. * Copyright 2011-2022 Cesium Contributors
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. * Columbus View (Pat. Pend.)
  21. *
  22. * Portions licensed separately.
  23. * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
  24. */
  25. define(['exports', './ComponentDatatype-4eeb6d9b'], (function (exports, ComponentDatatype) { 'use strict';
  26. /**
  27. * @private
  28. */
  29. const CylinderGeometryLibrary = {};
  30. /**
  31. * @private
  32. */
  33. CylinderGeometryLibrary.computePositions = function (
  34. length,
  35. topRadius,
  36. bottomRadius,
  37. slices,
  38. fill
  39. ) {
  40. const topZ = length * 0.5;
  41. const bottomZ = -topZ;
  42. const twoSlice = slices + slices;
  43. const size = fill ? 2 * twoSlice : twoSlice;
  44. const positions = new Float64Array(size * 3);
  45. let i;
  46. let index = 0;
  47. let tbIndex = 0;
  48. const bottomOffset = fill ? twoSlice * 3 : 0;
  49. const topOffset = fill ? (twoSlice + slices) * 3 : slices * 3;
  50. for (i = 0; i < slices; i++) {
  51. const angle = (i / slices) * ComponentDatatype.CesiumMath.TWO_PI;
  52. const x = Math.cos(angle);
  53. const y = Math.sin(angle);
  54. const bottomX = x * bottomRadius;
  55. const bottomY = y * bottomRadius;
  56. const topX = x * topRadius;
  57. const topY = y * topRadius;
  58. positions[tbIndex + bottomOffset] = bottomX;
  59. positions[tbIndex + bottomOffset + 1] = bottomY;
  60. positions[tbIndex + bottomOffset + 2] = bottomZ;
  61. positions[tbIndex + topOffset] = topX;
  62. positions[tbIndex + topOffset + 1] = topY;
  63. positions[tbIndex + topOffset + 2] = topZ;
  64. tbIndex += 3;
  65. if (fill) {
  66. positions[index++] = bottomX;
  67. positions[index++] = bottomY;
  68. positions[index++] = bottomZ;
  69. positions[index++] = topX;
  70. positions[index++] = topY;
  71. positions[index++] = topZ;
  72. }
  73. }
  74. return positions;
  75. };
  76. exports.CylinderGeometryLibrary = CylinderGeometryLibrary;
  77. }));
  78. //# sourceMappingURL=CylinderGeometryLibrary-365438d7.js.map