PolylineVolumeGeometryLibrary-d573ce10.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  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', './Cartesian2-33d2657c', './Transforms-8be64844', './EllipsoidTangentPlane-ce6e380f', './PolylinePipeline-25d1e129'], function (exports, _Math, Cartesian2, Transforms, EllipsoidTangentPlane, PolylinePipeline) { 'use strict';
  24. /**
  25. * Style options for corners.
  26. *
  27. * @demo The {@link https://sandcastle.cesium.com/index.html?src=Corridor.html&label=Geometries|Corridor Demo}
  28. * demonstrates the three corner types, as used by {@link CorridorGraphics}.
  29. *
  30. * @enum {Number}
  31. */
  32. var CornerType = {
  33. /**
  34. * <img src="Images/CornerTypeRounded.png" style="vertical-align: middle;" width="186" height="189" />
  35. *
  36. * Corner has a smooth edge.
  37. * @type {Number}
  38. * @constant
  39. */
  40. ROUNDED: 0,
  41. /**
  42. * <img src="Images/CornerTypeMitered.png" style="vertical-align: middle;" width="186" height="189" />
  43. *
  44. * Corner point is the intersection of adjacent edges.
  45. * @type {Number}
  46. * @constant
  47. */
  48. MITERED: 1,
  49. /**
  50. * <img src="Images/CornerTypeBeveled.png" style="vertical-align: middle;" width="186" height="189" />
  51. *
  52. * Corner is clipped.
  53. * @type {Number}
  54. * @constant
  55. */
  56. BEVELED: 2,
  57. };
  58. var CornerType$1 = Object.freeze(CornerType);
  59. var scratch2Array = [new Cartesian2.Cartesian3(), new Cartesian2.Cartesian3()];
  60. var scratchCartesian1 = new Cartesian2.Cartesian3();
  61. var scratchCartesian2 = new Cartesian2.Cartesian3();
  62. var scratchCartesian3 = new Cartesian2.Cartesian3();
  63. var scratchCartesian4 = new Cartesian2.Cartesian3();
  64. var scratchCartesian5 = new Cartesian2.Cartesian3();
  65. var scratchCartesian6 = new Cartesian2.Cartesian3();
  66. var scratchCartesian7 = new Cartesian2.Cartesian3();
  67. var scratchCartesian8 = new Cartesian2.Cartesian3();
  68. var scratchCartesian9 = new Cartesian2.Cartesian3();
  69. var scratch1 = new Cartesian2.Cartesian3();
  70. var scratch2 = new Cartesian2.Cartesian3();
  71. /**
  72. * @private
  73. */
  74. var PolylineVolumeGeometryLibrary = {};
  75. var cartographic = new Cartesian2.Cartographic();
  76. function scaleToSurface(positions, ellipsoid) {
  77. var heights = new Array(positions.length);
  78. for (var i = 0; i < positions.length; i++) {
  79. var pos = positions[i];
  80. cartographic = ellipsoid.cartesianToCartographic(pos, cartographic);
  81. heights[i] = cartographic.height;
  82. positions[i] = ellipsoid.scaleToGeodeticSurface(pos, pos);
  83. }
  84. return heights;
  85. }
  86. function subdivideHeights(points, h0, h1, granularity) {
  87. var p0 = points[0];
  88. var p1 = points[1];
  89. var angleBetween = Cartesian2.Cartesian3.angleBetween(p0, p1);
  90. var numPoints = Math.ceil(angleBetween / granularity);
  91. var heights = new Array(numPoints);
  92. var i;
  93. if (h0 === h1) {
  94. for (i = 0; i < numPoints; i++) {
  95. heights[i] = h0;
  96. }
  97. heights.push(h1);
  98. return heights;
  99. }
  100. var dHeight = h1 - h0;
  101. var heightPerVertex = dHeight / numPoints;
  102. for (i = 1; i < numPoints; i++) {
  103. var h = h0 + i * heightPerVertex;
  104. heights[i] = h;
  105. }
  106. heights[0] = h0;
  107. heights.push(h1);
  108. return heights;
  109. }
  110. var nextScratch = new Cartesian2.Cartesian3();
  111. var prevScratch = new Cartesian2.Cartesian3();
  112. function computeRotationAngle(start, end, position, ellipsoid) {
  113. var tangentPlane = new EllipsoidTangentPlane.EllipsoidTangentPlane(position, ellipsoid);
  114. var next = tangentPlane.projectPointOntoPlane(
  115. Cartesian2.Cartesian3.add(position, start, nextScratch),
  116. nextScratch
  117. );
  118. var prev = tangentPlane.projectPointOntoPlane(
  119. Cartesian2.Cartesian3.add(position, end, prevScratch),
  120. prevScratch
  121. );
  122. var angle = Cartesian2.Cartesian2.angleBetween(next, prev);
  123. return prev.x * next.y - prev.y * next.x >= 0.0 ? -angle : angle;
  124. }
  125. var negativeX = new Cartesian2.Cartesian3(-1, 0, 0);
  126. var transform = new Transforms.Matrix4();
  127. var translation = new Transforms.Matrix4();
  128. var rotationZ = new Transforms.Matrix3();
  129. var scaleMatrix = Transforms.Matrix3.IDENTITY.clone();
  130. var westScratch = new Cartesian2.Cartesian3();
  131. var finalPosScratch = new Transforms.Cartesian4();
  132. var heightCartesian = new Cartesian2.Cartesian3();
  133. function addPosition(
  134. center,
  135. left,
  136. shape,
  137. finalPositions,
  138. ellipsoid,
  139. height,
  140. xScalar,
  141. repeat
  142. ) {
  143. var west = westScratch;
  144. var finalPosition = finalPosScratch;
  145. transform = Transforms.Transforms.eastNorthUpToFixedFrame(center, ellipsoid, transform);
  146. west = Transforms.Matrix4.multiplyByPointAsVector(transform, negativeX, west);
  147. west = Cartesian2.Cartesian3.normalize(west, west);
  148. var angle = computeRotationAngle(west, left, center, ellipsoid);
  149. rotationZ = Transforms.Matrix3.fromRotationZ(angle, rotationZ);
  150. heightCartesian.z = height;
  151. transform = Transforms.Matrix4.multiplyTransformation(
  152. transform,
  153. Transforms.Matrix4.fromRotationTranslation(rotationZ, heightCartesian, translation),
  154. transform
  155. );
  156. var scale = scaleMatrix;
  157. scale[0] = xScalar;
  158. for (var j = 0; j < repeat; j++) {
  159. for (var i = 0; i < shape.length; i += 3) {
  160. finalPosition = Cartesian2.Cartesian3.fromArray(shape, i, finalPosition);
  161. finalPosition = Transforms.Matrix3.multiplyByVector(
  162. scale,
  163. finalPosition,
  164. finalPosition
  165. );
  166. finalPosition = Transforms.Matrix4.multiplyByPoint(
  167. transform,
  168. finalPosition,
  169. finalPosition
  170. );
  171. finalPositions.push(finalPosition.x, finalPosition.y, finalPosition.z);
  172. }
  173. }
  174. return finalPositions;
  175. }
  176. var centerScratch = new Cartesian2.Cartesian3();
  177. function addPositions(
  178. centers,
  179. left,
  180. shape,
  181. finalPositions,
  182. ellipsoid,
  183. heights,
  184. xScalar
  185. ) {
  186. for (var i = 0; i < centers.length; i += 3) {
  187. var center = Cartesian2.Cartesian3.fromArray(centers, i, centerScratch);
  188. finalPositions = addPosition(
  189. center,
  190. left,
  191. shape,
  192. finalPositions,
  193. ellipsoid,
  194. heights[i / 3],
  195. xScalar,
  196. 1
  197. );
  198. }
  199. return finalPositions;
  200. }
  201. function convertShapeTo3DDuplicate(shape2D, boundingRectangle) {
  202. //orientate 2D shape to XZ plane center at (0, 0, 0), duplicate points
  203. var length = shape2D.length;
  204. var shape = new Array(length * 6);
  205. var index = 0;
  206. var xOffset = boundingRectangle.x + boundingRectangle.width / 2;
  207. var yOffset = boundingRectangle.y + boundingRectangle.height / 2;
  208. var point = shape2D[0];
  209. shape[index++] = point.x - xOffset;
  210. shape[index++] = 0.0;
  211. shape[index++] = point.y - yOffset;
  212. for (var i = 1; i < length; i++) {
  213. point = shape2D[i];
  214. var x = point.x - xOffset;
  215. var z = point.y - yOffset;
  216. shape[index++] = x;
  217. shape[index++] = 0.0;
  218. shape[index++] = z;
  219. shape[index++] = x;
  220. shape[index++] = 0.0;
  221. shape[index++] = z;
  222. }
  223. point = shape2D[0];
  224. shape[index++] = point.x - xOffset;
  225. shape[index++] = 0.0;
  226. shape[index++] = point.y - yOffset;
  227. return shape;
  228. }
  229. function convertShapeTo3D(shape2D, boundingRectangle) {
  230. //orientate 2D shape to XZ plane center at (0, 0, 0)
  231. var length = shape2D.length;
  232. var shape = new Array(length * 3);
  233. var index = 0;
  234. var xOffset = boundingRectangle.x + boundingRectangle.width / 2;
  235. var yOffset = boundingRectangle.y + boundingRectangle.height / 2;
  236. for (var i = 0; i < length; i++) {
  237. shape[index++] = shape2D[i].x - xOffset;
  238. shape[index++] = 0;
  239. shape[index++] = shape2D[i].y - yOffset;
  240. }
  241. return shape;
  242. }
  243. var quaterion = new Transforms.Quaternion();
  244. var startPointScratch = new Cartesian2.Cartesian3();
  245. var rotMatrix = new Transforms.Matrix3();
  246. function computeRoundCorner(
  247. pivot,
  248. startPoint,
  249. endPoint,
  250. cornerType,
  251. leftIsOutside,
  252. ellipsoid,
  253. finalPositions,
  254. shape,
  255. height,
  256. duplicatePoints
  257. ) {
  258. var angle = Cartesian2.Cartesian3.angleBetween(
  259. Cartesian2.Cartesian3.subtract(startPoint, pivot, scratch1),
  260. Cartesian2.Cartesian3.subtract(endPoint, pivot, scratch2)
  261. );
  262. var granularity =
  263. cornerType === CornerType$1.BEVELED
  264. ? 0
  265. : Math.ceil(angle / _Math.CesiumMath.toRadians(5));
  266. var m;
  267. if (leftIsOutside) {
  268. m = Transforms.Matrix3.fromQuaternion(
  269. Transforms.Quaternion.fromAxisAngle(
  270. Cartesian2.Cartesian3.negate(pivot, scratch1),
  271. angle / (granularity + 1),
  272. quaterion
  273. ),
  274. rotMatrix
  275. );
  276. } else {
  277. m = Transforms.Matrix3.fromQuaternion(
  278. Transforms.Quaternion.fromAxisAngle(pivot, angle / (granularity + 1), quaterion),
  279. rotMatrix
  280. );
  281. }
  282. var left;
  283. var surfacePoint;
  284. startPoint = Cartesian2.Cartesian3.clone(startPoint, startPointScratch);
  285. if (granularity > 0) {
  286. var repeat = duplicatePoints ? 2 : 1;
  287. for (var i = 0; i < granularity; i++) {
  288. startPoint = Transforms.Matrix3.multiplyByVector(m, startPoint, startPoint);
  289. left = Cartesian2.Cartesian3.subtract(startPoint, pivot, scratch1);
  290. left = Cartesian2.Cartesian3.normalize(left, left);
  291. if (!leftIsOutside) {
  292. left = Cartesian2.Cartesian3.negate(left, left);
  293. }
  294. surfacePoint = ellipsoid.scaleToGeodeticSurface(startPoint, scratch2);
  295. finalPositions = addPosition(
  296. surfacePoint,
  297. left,
  298. shape,
  299. finalPositions,
  300. ellipsoid,
  301. height,
  302. 1,
  303. repeat
  304. );
  305. }
  306. } else {
  307. left = Cartesian2.Cartesian3.subtract(startPoint, pivot, scratch1);
  308. left = Cartesian2.Cartesian3.normalize(left, left);
  309. if (!leftIsOutside) {
  310. left = Cartesian2.Cartesian3.negate(left, left);
  311. }
  312. surfacePoint = ellipsoid.scaleToGeodeticSurface(startPoint, scratch2);
  313. finalPositions = addPosition(
  314. surfacePoint,
  315. left,
  316. shape,
  317. finalPositions,
  318. ellipsoid,
  319. height,
  320. 1,
  321. 1
  322. );
  323. endPoint = Cartesian2.Cartesian3.clone(endPoint, startPointScratch);
  324. left = Cartesian2.Cartesian3.subtract(endPoint, pivot, scratch1);
  325. left = Cartesian2.Cartesian3.normalize(left, left);
  326. if (!leftIsOutside) {
  327. left = Cartesian2.Cartesian3.negate(left, left);
  328. }
  329. surfacePoint = ellipsoid.scaleToGeodeticSurface(endPoint, scratch2);
  330. finalPositions = addPosition(
  331. surfacePoint,
  332. left,
  333. shape,
  334. finalPositions,
  335. ellipsoid,
  336. height,
  337. 1,
  338. 1
  339. );
  340. }
  341. return finalPositions;
  342. }
  343. PolylineVolumeGeometryLibrary.removeDuplicatesFromShape = function (
  344. shapePositions
  345. ) {
  346. var length = shapePositions.length;
  347. var cleanedPositions = [];
  348. for (var i0 = length - 1, i1 = 0; i1 < length; i0 = i1++) {
  349. var v0 = shapePositions[i0];
  350. var v1 = shapePositions[i1];
  351. if (!Cartesian2.Cartesian2.equals(v0, v1)) {
  352. cleanedPositions.push(v1); // Shallow copy!
  353. }
  354. }
  355. return cleanedPositions;
  356. };
  357. PolylineVolumeGeometryLibrary.angleIsGreaterThanPi = function (
  358. forward,
  359. backward,
  360. position,
  361. ellipsoid
  362. ) {
  363. var tangentPlane = new EllipsoidTangentPlane.EllipsoidTangentPlane(position, ellipsoid);
  364. var next = tangentPlane.projectPointOntoPlane(
  365. Cartesian2.Cartesian3.add(position, forward, nextScratch),
  366. nextScratch
  367. );
  368. var prev = tangentPlane.projectPointOntoPlane(
  369. Cartesian2.Cartesian3.add(position, backward, prevScratch),
  370. prevScratch
  371. );
  372. return prev.x * next.y - prev.y * next.x >= 0.0;
  373. };
  374. var scratchForwardProjection = new Cartesian2.Cartesian3();
  375. var scratchBackwardProjection = new Cartesian2.Cartesian3();
  376. PolylineVolumeGeometryLibrary.computePositions = function (
  377. positions,
  378. shape2D,
  379. boundingRectangle,
  380. geometry,
  381. duplicatePoints
  382. ) {
  383. var ellipsoid = geometry._ellipsoid;
  384. var heights = scaleToSurface(positions, ellipsoid);
  385. var granularity = geometry._granularity;
  386. var cornerType = geometry._cornerType;
  387. var shapeForSides = duplicatePoints
  388. ? convertShapeTo3DDuplicate(shape2D, boundingRectangle)
  389. : convertShapeTo3D(shape2D, boundingRectangle);
  390. var shapeForEnds = duplicatePoints
  391. ? convertShapeTo3D(shape2D, boundingRectangle)
  392. : undefined;
  393. var heightOffset = boundingRectangle.height / 2;
  394. var width = boundingRectangle.width / 2;
  395. var length = positions.length;
  396. var finalPositions = [];
  397. var ends = duplicatePoints ? [] : undefined;
  398. var forward = scratchCartesian1;
  399. var backward = scratchCartesian2;
  400. var cornerDirection = scratchCartesian3;
  401. var surfaceNormal = scratchCartesian4;
  402. var pivot = scratchCartesian5;
  403. var start = scratchCartesian6;
  404. var end = scratchCartesian7;
  405. var left = scratchCartesian8;
  406. var previousPosition = scratchCartesian9;
  407. var position = positions[0];
  408. var nextPosition = positions[1];
  409. surfaceNormal = ellipsoid.geodeticSurfaceNormal(position, surfaceNormal);
  410. forward = Cartesian2.Cartesian3.subtract(nextPosition, position, forward);
  411. forward = Cartesian2.Cartesian3.normalize(forward, forward);
  412. left = Cartesian2.Cartesian3.cross(surfaceNormal, forward, left);
  413. left = Cartesian2.Cartesian3.normalize(left, left);
  414. var h0 = heights[0];
  415. var h1 = heights[1];
  416. if (duplicatePoints) {
  417. ends = addPosition(
  418. position,
  419. left,
  420. shapeForEnds,
  421. ends,
  422. ellipsoid,
  423. h0 + heightOffset,
  424. 1,
  425. 1
  426. );
  427. }
  428. previousPosition = Cartesian2.Cartesian3.clone(position, previousPosition);
  429. position = nextPosition;
  430. backward = Cartesian2.Cartesian3.negate(forward, backward);
  431. var subdividedHeights;
  432. var subdividedPositions;
  433. for (var i = 1; i < length - 1; i++) {
  434. var repeat = duplicatePoints ? 2 : 1;
  435. nextPosition = positions[i + 1];
  436. forward = Cartesian2.Cartesian3.subtract(nextPosition, position, forward);
  437. forward = Cartesian2.Cartesian3.normalize(forward, forward);
  438. cornerDirection = Cartesian2.Cartesian3.add(forward, backward, cornerDirection);
  439. cornerDirection = Cartesian2.Cartesian3.normalize(cornerDirection, cornerDirection);
  440. surfaceNormal = ellipsoid.geodeticSurfaceNormal(position, surfaceNormal);
  441. var forwardProjection = Cartesian2.Cartesian3.multiplyByScalar(
  442. surfaceNormal,
  443. Cartesian2.Cartesian3.dot(forward, surfaceNormal),
  444. scratchForwardProjection
  445. );
  446. Cartesian2.Cartesian3.subtract(forward, forwardProjection, forwardProjection);
  447. Cartesian2.Cartesian3.normalize(forwardProjection, forwardProjection);
  448. var backwardProjection = Cartesian2.Cartesian3.multiplyByScalar(
  449. surfaceNormal,
  450. Cartesian2.Cartesian3.dot(backward, surfaceNormal),
  451. scratchBackwardProjection
  452. );
  453. Cartesian2.Cartesian3.subtract(backward, backwardProjection, backwardProjection);
  454. Cartesian2.Cartesian3.normalize(backwardProjection, backwardProjection);
  455. var doCorner = !_Math.CesiumMath.equalsEpsilon(
  456. Math.abs(Cartesian2.Cartesian3.dot(forwardProjection, backwardProjection)),
  457. 1.0,
  458. _Math.CesiumMath.EPSILON7
  459. );
  460. if (doCorner) {
  461. cornerDirection = Cartesian2.Cartesian3.cross(
  462. cornerDirection,
  463. surfaceNormal,
  464. cornerDirection
  465. );
  466. cornerDirection = Cartesian2.Cartesian3.cross(
  467. surfaceNormal,
  468. cornerDirection,
  469. cornerDirection
  470. );
  471. cornerDirection = Cartesian2.Cartesian3.normalize(cornerDirection, cornerDirection);
  472. var scalar =
  473. 1 /
  474. Math.max(
  475. 0.25,
  476. Cartesian2.Cartesian3.magnitude(
  477. Cartesian2.Cartesian3.cross(cornerDirection, backward, scratch1)
  478. )
  479. );
  480. var leftIsOutside = PolylineVolumeGeometryLibrary.angleIsGreaterThanPi(
  481. forward,
  482. backward,
  483. position,
  484. ellipsoid
  485. );
  486. if (leftIsOutside) {
  487. pivot = Cartesian2.Cartesian3.add(
  488. position,
  489. Cartesian2.Cartesian3.multiplyByScalar(
  490. cornerDirection,
  491. scalar * width,
  492. cornerDirection
  493. ),
  494. pivot
  495. );
  496. start = Cartesian2.Cartesian3.add(
  497. pivot,
  498. Cartesian2.Cartesian3.multiplyByScalar(left, width, start),
  499. start
  500. );
  501. scratch2Array[0] = Cartesian2.Cartesian3.clone(previousPosition, scratch2Array[0]);
  502. scratch2Array[1] = Cartesian2.Cartesian3.clone(start, scratch2Array[1]);
  503. subdividedHeights = subdivideHeights(
  504. scratch2Array,
  505. h0 + heightOffset,
  506. h1 + heightOffset,
  507. granularity
  508. );
  509. subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
  510. positions: scratch2Array,
  511. granularity: granularity,
  512. ellipsoid: ellipsoid,
  513. });
  514. finalPositions = addPositions(
  515. subdividedPositions,
  516. left,
  517. shapeForSides,
  518. finalPositions,
  519. ellipsoid,
  520. subdividedHeights,
  521. 1
  522. );
  523. left = Cartesian2.Cartesian3.cross(surfaceNormal, forward, left);
  524. left = Cartesian2.Cartesian3.normalize(left, left);
  525. end = Cartesian2.Cartesian3.add(
  526. pivot,
  527. Cartesian2.Cartesian3.multiplyByScalar(left, width, end),
  528. end
  529. );
  530. if (
  531. cornerType === CornerType$1.ROUNDED ||
  532. cornerType === CornerType$1.BEVELED
  533. ) {
  534. computeRoundCorner(
  535. pivot,
  536. start,
  537. end,
  538. cornerType,
  539. leftIsOutside,
  540. ellipsoid,
  541. finalPositions,
  542. shapeForSides,
  543. h1 + heightOffset,
  544. duplicatePoints
  545. );
  546. } else {
  547. cornerDirection = Cartesian2.Cartesian3.negate(cornerDirection, cornerDirection);
  548. finalPositions = addPosition(
  549. position,
  550. cornerDirection,
  551. shapeForSides,
  552. finalPositions,
  553. ellipsoid,
  554. h1 + heightOffset,
  555. scalar,
  556. repeat
  557. );
  558. }
  559. previousPosition = Cartesian2.Cartesian3.clone(end, previousPosition);
  560. } else {
  561. pivot = Cartesian2.Cartesian3.add(
  562. position,
  563. Cartesian2.Cartesian3.multiplyByScalar(
  564. cornerDirection,
  565. scalar * width,
  566. cornerDirection
  567. ),
  568. pivot
  569. );
  570. start = Cartesian2.Cartesian3.add(
  571. pivot,
  572. Cartesian2.Cartesian3.multiplyByScalar(left, -width, start),
  573. start
  574. );
  575. scratch2Array[0] = Cartesian2.Cartesian3.clone(previousPosition, scratch2Array[0]);
  576. scratch2Array[1] = Cartesian2.Cartesian3.clone(start, scratch2Array[1]);
  577. subdividedHeights = subdivideHeights(
  578. scratch2Array,
  579. h0 + heightOffset,
  580. h1 + heightOffset,
  581. granularity
  582. );
  583. subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
  584. positions: scratch2Array,
  585. granularity: granularity,
  586. ellipsoid: ellipsoid,
  587. });
  588. finalPositions = addPositions(
  589. subdividedPositions,
  590. left,
  591. shapeForSides,
  592. finalPositions,
  593. ellipsoid,
  594. subdividedHeights,
  595. 1
  596. );
  597. left = Cartesian2.Cartesian3.cross(surfaceNormal, forward, left);
  598. left = Cartesian2.Cartesian3.normalize(left, left);
  599. end = Cartesian2.Cartesian3.add(
  600. pivot,
  601. Cartesian2.Cartesian3.multiplyByScalar(left, -width, end),
  602. end
  603. );
  604. if (
  605. cornerType === CornerType$1.ROUNDED ||
  606. cornerType === CornerType$1.BEVELED
  607. ) {
  608. computeRoundCorner(
  609. pivot,
  610. start,
  611. end,
  612. cornerType,
  613. leftIsOutside,
  614. ellipsoid,
  615. finalPositions,
  616. shapeForSides,
  617. h1 + heightOffset,
  618. duplicatePoints
  619. );
  620. } else {
  621. finalPositions = addPosition(
  622. position,
  623. cornerDirection,
  624. shapeForSides,
  625. finalPositions,
  626. ellipsoid,
  627. h1 + heightOffset,
  628. scalar,
  629. repeat
  630. );
  631. }
  632. previousPosition = Cartesian2.Cartesian3.clone(end, previousPosition);
  633. }
  634. backward = Cartesian2.Cartesian3.negate(forward, backward);
  635. } else {
  636. finalPositions = addPosition(
  637. previousPosition,
  638. left,
  639. shapeForSides,
  640. finalPositions,
  641. ellipsoid,
  642. h0 + heightOffset,
  643. 1,
  644. 1
  645. );
  646. previousPosition = position;
  647. }
  648. h0 = h1;
  649. h1 = heights[i + 1];
  650. position = nextPosition;
  651. }
  652. scratch2Array[0] = Cartesian2.Cartesian3.clone(previousPosition, scratch2Array[0]);
  653. scratch2Array[1] = Cartesian2.Cartesian3.clone(position, scratch2Array[1]);
  654. subdividedHeights = subdivideHeights(
  655. scratch2Array,
  656. h0 + heightOffset,
  657. h1 + heightOffset,
  658. granularity
  659. );
  660. subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
  661. positions: scratch2Array,
  662. granularity: granularity,
  663. ellipsoid: ellipsoid,
  664. });
  665. finalPositions = addPositions(
  666. subdividedPositions,
  667. left,
  668. shapeForSides,
  669. finalPositions,
  670. ellipsoid,
  671. subdividedHeights,
  672. 1
  673. );
  674. if (duplicatePoints) {
  675. ends = addPosition(
  676. position,
  677. left,
  678. shapeForEnds,
  679. ends,
  680. ellipsoid,
  681. h1 + heightOffset,
  682. 1,
  683. 1
  684. );
  685. }
  686. length = finalPositions.length;
  687. var posLength = duplicatePoints ? length + ends.length : length;
  688. var combinedPositions = new Float64Array(posLength);
  689. combinedPositions.set(finalPositions);
  690. if (duplicatePoints) {
  691. combinedPositions.set(ends, length);
  692. }
  693. return combinedPositions;
  694. };
  695. exports.CornerType = CornerType$1;
  696. exports.PolylineVolumeGeometryLibrary = PolylineVolumeGeometryLibrary;
  697. });
  698. //# sourceMappingURL=PolylineVolumeGeometryLibrary-d573ce10.js.map