CylinderGeometryLibrary-8580810e.js 2.4 KB

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