CylinderGeometryLibrary-1a22ba0e.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* This file is automatically rebuilt by the Cesium build process. */
  2. define(['exports', './Math-fa6e45cb'], function (exports, _Math) { 'use strict';
  3. /**
  4. * @private
  5. */
  6. var CylinderGeometryLibrary = {};
  7. /**
  8. * @private
  9. */
  10. CylinderGeometryLibrary.computePositions = function(length, topRadius, bottomRadius, slices, fill){
  11. var topZ = length * 0.5;
  12. var bottomZ = -topZ;
  13. var twoSlice = slices + slices;
  14. var size = (fill) ? 2 * twoSlice : twoSlice;
  15. var positions = new Float64Array(size*3);
  16. var i;
  17. var index = 0;
  18. var tbIndex = 0;
  19. var bottomOffset = (fill) ? twoSlice*3 : 0;
  20. var topOffset = (fill) ? (twoSlice + slices)*3 : slices*3;
  21. for (i = 0; i < slices; i++) {
  22. var angle = i / slices * _Math.CesiumMath.TWO_PI;
  23. var x = Math.cos(angle);
  24. var y = Math.sin(angle);
  25. var bottomX = x * bottomRadius;
  26. var bottomY = y * bottomRadius;
  27. var topX = x * topRadius;
  28. var topY = y * topRadius;
  29. positions[tbIndex + bottomOffset] = bottomX;
  30. positions[tbIndex + bottomOffset + 1] = bottomY;
  31. positions[tbIndex + bottomOffset + 2] = bottomZ;
  32. positions[tbIndex + topOffset] = topX;
  33. positions[tbIndex + topOffset + 1] = topY;
  34. positions[tbIndex + topOffset + 2] = topZ;
  35. tbIndex += 3;
  36. if (fill) {
  37. positions[index++] = bottomX;
  38. positions[index++] = bottomY;
  39. positions[index++] = bottomZ;
  40. positions[index++] = topX;
  41. positions[index++] = topY;
  42. positions[index++] = topZ;
  43. }
  44. }
  45. return positions;
  46. };
  47. exports.CylinderGeometryLibrary = CylinderGeometryLibrary;
  48. });