PolylineVolumeGeometryLibrary-62b3e4fb.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  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/main/LICENSE.md for full licensing details.
  22. */
  23. define(['exports', './Matrix2-d35cf4b5', './EllipsoidTangentPlane-2abe082d', './ComponentDatatype-9e86ac8f', './PolylinePipeline-3b5d6486', './Transforms-f0a54c7b', './defaultValue-81eec7ed', './RuntimeError-8952249c'], (function (exports, Matrix2, EllipsoidTangentPlane, ComponentDatatype, PolylinePipeline, Transforms, defaultValue, RuntimeError) { '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. const 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. const warnings = {};
  60. /**
  61. * Logs a one time message to the console. Use this function instead of
  62. * <code>console.log</code> directly since this does not log duplicate messages
  63. * unless it is called from multiple workers.
  64. *
  65. * @function oneTimeWarning
  66. *
  67. * @param {String} identifier The unique identifier for this warning.
  68. * @param {String} [message=identifier] The message to log to the console.
  69. *
  70. * @example
  71. * for(let i=0;i<foo.length;++i) {
  72. * if (!defined(foo[i].bar)) {
  73. * // Something that can be recovered from but may happen a lot
  74. * oneTimeWarning('foo.bar undefined', 'foo.bar is undefined. Setting to 0.');
  75. * foo[i].bar = 0;
  76. * // ...
  77. * }
  78. * }
  79. *
  80. * @private
  81. */
  82. function oneTimeWarning(identifier, message) {
  83. //>>includeStart('debug', pragmas.debug);
  84. if (!defaultValue.defined(identifier)) {
  85. throw new RuntimeError.DeveloperError("identifier is required.");
  86. }
  87. //>>includeEnd('debug');
  88. if (!defaultValue.defined(warnings[identifier])) {
  89. warnings[identifier] = true;
  90. console.warn(defaultValue.defaultValue(message, identifier));
  91. }
  92. }
  93. oneTimeWarning.geometryOutlines =
  94. "Entity geometry outlines are unsupported on terrain. Outlines will be disabled. To enable outlines, disable geometry terrain clamping by explicitly setting height to 0.";
  95. oneTimeWarning.geometryZIndex =
  96. "Entity geometry with zIndex are unsupported when height or extrudedHeight are defined. zIndex will be ignored";
  97. oneTimeWarning.geometryHeightReference =
  98. "Entity corridor, ellipse, polygon or rectangle with heightReference must also have a defined height. heightReference will be ignored";
  99. oneTimeWarning.geometryExtrudedHeightReference =
  100. "Entity corridor, ellipse, polygon or rectangle with extrudedHeightReference must also have a defined extrudedHeight. extrudedHeightReference will be ignored";
  101. const scratch2Array = [new Matrix2.Cartesian3(), new Matrix2.Cartesian3()];
  102. const scratchCartesian1 = new Matrix2.Cartesian3();
  103. const scratchCartesian2 = new Matrix2.Cartesian3();
  104. const scratchCartesian3 = new Matrix2.Cartesian3();
  105. const scratchCartesian4 = new Matrix2.Cartesian3();
  106. const scratchCartesian5 = new Matrix2.Cartesian3();
  107. const scratchCartesian6 = new Matrix2.Cartesian3();
  108. const scratchCartesian7 = new Matrix2.Cartesian3();
  109. const scratchCartesian8 = new Matrix2.Cartesian3();
  110. const scratchCartesian9 = new Matrix2.Cartesian3();
  111. const scratch1 = new Matrix2.Cartesian3();
  112. const scratch2 = new Matrix2.Cartesian3();
  113. /**
  114. * @private
  115. */
  116. const PolylineVolumeGeometryLibrary = {};
  117. let cartographic = new Matrix2.Cartographic();
  118. function scaleToSurface(positions, ellipsoid) {
  119. const heights = new Array(positions.length);
  120. for (let i = 0; i < positions.length; i++) {
  121. const pos = positions[i];
  122. cartographic = ellipsoid.cartesianToCartographic(pos, cartographic);
  123. heights[i] = cartographic.height;
  124. positions[i] = ellipsoid.scaleToGeodeticSurface(pos, pos);
  125. }
  126. return heights;
  127. }
  128. function subdivideHeights(points, h0, h1, granularity) {
  129. const p0 = points[0];
  130. const p1 = points[1];
  131. const angleBetween = Matrix2.Cartesian3.angleBetween(p0, p1);
  132. const numPoints = Math.ceil(angleBetween / granularity);
  133. const heights = new Array(numPoints);
  134. let i;
  135. if (h0 === h1) {
  136. for (i = 0; i < numPoints; i++) {
  137. heights[i] = h0;
  138. }
  139. heights.push(h1);
  140. return heights;
  141. }
  142. const dHeight = h1 - h0;
  143. const heightPerVertex = dHeight / numPoints;
  144. for (i = 1; i < numPoints; i++) {
  145. const h = h0 + i * heightPerVertex;
  146. heights[i] = h;
  147. }
  148. heights[0] = h0;
  149. heights.push(h1);
  150. return heights;
  151. }
  152. const nextScratch = new Matrix2.Cartesian3();
  153. const prevScratch = new Matrix2.Cartesian3();
  154. function computeRotationAngle(start, end, position, ellipsoid) {
  155. const tangentPlane = new EllipsoidTangentPlane.EllipsoidTangentPlane(position, ellipsoid);
  156. const next = tangentPlane.projectPointOntoPlane(
  157. Matrix2.Cartesian3.add(position, start, nextScratch),
  158. nextScratch
  159. );
  160. const prev = tangentPlane.projectPointOntoPlane(
  161. Matrix2.Cartesian3.add(position, end, prevScratch),
  162. prevScratch
  163. );
  164. const angle = Matrix2.Cartesian2.angleBetween(next, prev);
  165. return prev.x * next.y - prev.y * next.x >= 0.0 ? -angle : angle;
  166. }
  167. const negativeX = new Matrix2.Cartesian3(-1, 0, 0);
  168. let transform = new Matrix2.Matrix4();
  169. const translation = new Matrix2.Matrix4();
  170. let rotationZ = new Matrix2.Matrix3();
  171. const scaleMatrix = Matrix2.Matrix3.IDENTITY.clone();
  172. const westScratch = new Matrix2.Cartesian3();
  173. const finalPosScratch = new Matrix2.Cartesian4();
  174. const heightCartesian = new Matrix2.Cartesian3();
  175. function addPosition(
  176. center,
  177. left,
  178. shape,
  179. finalPositions,
  180. ellipsoid,
  181. height,
  182. xScalar,
  183. repeat
  184. ) {
  185. let west = westScratch;
  186. let finalPosition = finalPosScratch;
  187. transform = Transforms.Transforms.eastNorthUpToFixedFrame(center, ellipsoid, transform);
  188. west = Matrix2.Matrix4.multiplyByPointAsVector(transform, negativeX, west);
  189. west = Matrix2.Cartesian3.normalize(west, west);
  190. const angle = computeRotationAngle(west, left, center, ellipsoid);
  191. rotationZ = Matrix2.Matrix3.fromRotationZ(angle, rotationZ);
  192. heightCartesian.z = height;
  193. transform = Matrix2.Matrix4.multiplyTransformation(
  194. transform,
  195. Matrix2.Matrix4.fromRotationTranslation(rotationZ, heightCartesian, translation),
  196. transform
  197. );
  198. const scale = scaleMatrix;
  199. scale[0] = xScalar;
  200. for (let j = 0; j < repeat; j++) {
  201. for (let i = 0; i < shape.length; i += 3) {
  202. finalPosition = Matrix2.Cartesian3.fromArray(shape, i, finalPosition);
  203. finalPosition = Matrix2.Matrix3.multiplyByVector(
  204. scale,
  205. finalPosition,
  206. finalPosition
  207. );
  208. finalPosition = Matrix2.Matrix4.multiplyByPoint(
  209. transform,
  210. finalPosition,
  211. finalPosition
  212. );
  213. finalPositions.push(finalPosition.x, finalPosition.y, finalPosition.z);
  214. }
  215. }
  216. return finalPositions;
  217. }
  218. const centerScratch = new Matrix2.Cartesian3();
  219. function addPositions(
  220. centers,
  221. left,
  222. shape,
  223. finalPositions,
  224. ellipsoid,
  225. heights,
  226. xScalar
  227. ) {
  228. for (let i = 0; i < centers.length; i += 3) {
  229. const center = Matrix2.Cartesian3.fromArray(centers, i, centerScratch);
  230. finalPositions = addPosition(
  231. center,
  232. left,
  233. shape,
  234. finalPositions,
  235. ellipsoid,
  236. heights[i / 3],
  237. xScalar,
  238. 1
  239. );
  240. }
  241. return finalPositions;
  242. }
  243. function convertShapeTo3DDuplicate(shape2D, boundingRectangle) {
  244. //orientate 2D shape to XZ plane center at (0, 0, 0), duplicate points
  245. const length = shape2D.length;
  246. const shape = new Array(length * 6);
  247. let index = 0;
  248. const xOffset = boundingRectangle.x + boundingRectangle.width / 2;
  249. const yOffset = boundingRectangle.y + boundingRectangle.height / 2;
  250. let point = shape2D[0];
  251. shape[index++] = point.x - xOffset;
  252. shape[index++] = 0.0;
  253. shape[index++] = point.y - yOffset;
  254. for (let i = 1; i < length; i++) {
  255. point = shape2D[i];
  256. const x = point.x - xOffset;
  257. const z = point.y - yOffset;
  258. shape[index++] = x;
  259. shape[index++] = 0.0;
  260. shape[index++] = z;
  261. shape[index++] = x;
  262. shape[index++] = 0.0;
  263. shape[index++] = z;
  264. }
  265. point = shape2D[0];
  266. shape[index++] = point.x - xOffset;
  267. shape[index++] = 0.0;
  268. shape[index++] = point.y - yOffset;
  269. return shape;
  270. }
  271. function convertShapeTo3D(shape2D, boundingRectangle) {
  272. //orientate 2D shape to XZ plane center at (0, 0, 0)
  273. const length = shape2D.length;
  274. const shape = new Array(length * 3);
  275. let index = 0;
  276. const xOffset = boundingRectangle.x + boundingRectangle.width / 2;
  277. const yOffset = boundingRectangle.y + boundingRectangle.height / 2;
  278. for (let i = 0; i < length; i++) {
  279. shape[index++] = shape2D[i].x - xOffset;
  280. shape[index++] = 0;
  281. shape[index++] = shape2D[i].y - yOffset;
  282. }
  283. return shape;
  284. }
  285. const quaterion = new Transforms.Quaternion();
  286. const startPointScratch = new Matrix2.Cartesian3();
  287. const rotMatrix = new Matrix2.Matrix3();
  288. function computeRoundCorner(
  289. pivot,
  290. startPoint,
  291. endPoint,
  292. cornerType,
  293. leftIsOutside,
  294. ellipsoid,
  295. finalPositions,
  296. shape,
  297. height,
  298. duplicatePoints
  299. ) {
  300. const angle = Matrix2.Cartesian3.angleBetween(
  301. Matrix2.Cartesian3.subtract(startPoint, pivot, scratch1),
  302. Matrix2.Cartesian3.subtract(endPoint, pivot, scratch2)
  303. );
  304. const granularity =
  305. cornerType === CornerType$1.BEVELED
  306. ? 0
  307. : Math.ceil(angle / ComponentDatatype.CesiumMath.toRadians(5));
  308. let m;
  309. if (leftIsOutside) {
  310. m = Matrix2.Matrix3.fromQuaternion(
  311. Transforms.Quaternion.fromAxisAngle(
  312. Matrix2.Cartesian3.negate(pivot, scratch1),
  313. angle / (granularity + 1),
  314. quaterion
  315. ),
  316. rotMatrix
  317. );
  318. } else {
  319. m = Matrix2.Matrix3.fromQuaternion(
  320. Transforms.Quaternion.fromAxisAngle(pivot, angle / (granularity + 1), quaterion),
  321. rotMatrix
  322. );
  323. }
  324. let left;
  325. let surfacePoint;
  326. startPoint = Matrix2.Cartesian3.clone(startPoint, startPointScratch);
  327. if (granularity > 0) {
  328. const repeat = duplicatePoints ? 2 : 1;
  329. for (let i = 0; i < granularity; i++) {
  330. startPoint = Matrix2.Matrix3.multiplyByVector(m, startPoint, startPoint);
  331. left = Matrix2.Cartesian3.subtract(startPoint, pivot, scratch1);
  332. left = Matrix2.Cartesian3.normalize(left, left);
  333. if (!leftIsOutside) {
  334. left = Matrix2.Cartesian3.negate(left, left);
  335. }
  336. surfacePoint = ellipsoid.scaleToGeodeticSurface(startPoint, scratch2);
  337. finalPositions = addPosition(
  338. surfacePoint,
  339. left,
  340. shape,
  341. finalPositions,
  342. ellipsoid,
  343. height,
  344. 1,
  345. repeat
  346. );
  347. }
  348. } else {
  349. left = Matrix2.Cartesian3.subtract(startPoint, pivot, scratch1);
  350. left = Matrix2.Cartesian3.normalize(left, left);
  351. if (!leftIsOutside) {
  352. left = Matrix2.Cartesian3.negate(left, left);
  353. }
  354. surfacePoint = ellipsoid.scaleToGeodeticSurface(startPoint, scratch2);
  355. finalPositions = addPosition(
  356. surfacePoint,
  357. left,
  358. shape,
  359. finalPositions,
  360. ellipsoid,
  361. height,
  362. 1,
  363. 1
  364. );
  365. endPoint = Matrix2.Cartesian3.clone(endPoint, startPointScratch);
  366. left = Matrix2.Cartesian3.subtract(endPoint, pivot, scratch1);
  367. left = Matrix2.Cartesian3.normalize(left, left);
  368. if (!leftIsOutside) {
  369. left = Matrix2.Cartesian3.negate(left, left);
  370. }
  371. surfacePoint = ellipsoid.scaleToGeodeticSurface(endPoint, scratch2);
  372. finalPositions = addPosition(
  373. surfacePoint,
  374. left,
  375. shape,
  376. finalPositions,
  377. ellipsoid,
  378. height,
  379. 1,
  380. 1
  381. );
  382. }
  383. return finalPositions;
  384. }
  385. PolylineVolumeGeometryLibrary.removeDuplicatesFromShape = function (
  386. shapePositions
  387. ) {
  388. const length = shapePositions.length;
  389. const cleanedPositions = [];
  390. for (let i0 = length - 1, i1 = 0; i1 < length; i0 = i1++) {
  391. const v0 = shapePositions[i0];
  392. const v1 = shapePositions[i1];
  393. if (!Matrix2.Cartesian2.equals(v0, v1)) {
  394. cleanedPositions.push(v1); // Shallow copy!
  395. }
  396. }
  397. return cleanedPositions;
  398. };
  399. PolylineVolumeGeometryLibrary.angleIsGreaterThanPi = function (
  400. forward,
  401. backward,
  402. position,
  403. ellipsoid
  404. ) {
  405. const tangentPlane = new EllipsoidTangentPlane.EllipsoidTangentPlane(position, ellipsoid);
  406. const next = tangentPlane.projectPointOntoPlane(
  407. Matrix2.Cartesian3.add(position, forward, nextScratch),
  408. nextScratch
  409. );
  410. const prev = tangentPlane.projectPointOntoPlane(
  411. Matrix2.Cartesian3.add(position, backward, prevScratch),
  412. prevScratch
  413. );
  414. return prev.x * next.y - prev.y * next.x >= 0.0;
  415. };
  416. const scratchForwardProjection = new Matrix2.Cartesian3();
  417. const scratchBackwardProjection = new Matrix2.Cartesian3();
  418. PolylineVolumeGeometryLibrary.computePositions = function (
  419. positions,
  420. shape2D,
  421. boundingRectangle,
  422. geometry,
  423. duplicatePoints
  424. ) {
  425. const ellipsoid = geometry._ellipsoid;
  426. const heights = scaleToSurface(positions, ellipsoid);
  427. const granularity = geometry._granularity;
  428. const cornerType = geometry._cornerType;
  429. const shapeForSides = duplicatePoints
  430. ? convertShapeTo3DDuplicate(shape2D, boundingRectangle)
  431. : convertShapeTo3D(shape2D, boundingRectangle);
  432. const shapeForEnds = duplicatePoints
  433. ? convertShapeTo3D(shape2D, boundingRectangle)
  434. : undefined;
  435. const heightOffset = boundingRectangle.height / 2;
  436. const width = boundingRectangle.width / 2;
  437. let length = positions.length;
  438. let finalPositions = [];
  439. let ends = duplicatePoints ? [] : undefined;
  440. let forward = scratchCartesian1;
  441. let backward = scratchCartesian2;
  442. let cornerDirection = scratchCartesian3;
  443. let surfaceNormal = scratchCartesian4;
  444. let pivot = scratchCartesian5;
  445. let start = scratchCartesian6;
  446. let end = scratchCartesian7;
  447. let left = scratchCartesian8;
  448. let previousPosition = scratchCartesian9;
  449. let position = positions[0];
  450. let nextPosition = positions[1];
  451. surfaceNormal = ellipsoid.geodeticSurfaceNormal(position, surfaceNormal);
  452. forward = Matrix2.Cartesian3.subtract(nextPosition, position, forward);
  453. forward = Matrix2.Cartesian3.normalize(forward, forward);
  454. left = Matrix2.Cartesian3.cross(surfaceNormal, forward, left);
  455. left = Matrix2.Cartesian3.normalize(left, left);
  456. let h0 = heights[0];
  457. let h1 = heights[1];
  458. if (duplicatePoints) {
  459. ends = addPosition(
  460. position,
  461. left,
  462. shapeForEnds,
  463. ends,
  464. ellipsoid,
  465. h0 + heightOffset,
  466. 1,
  467. 1
  468. );
  469. }
  470. previousPosition = Matrix2.Cartesian3.clone(position, previousPosition);
  471. position = nextPosition;
  472. backward = Matrix2.Cartesian3.negate(forward, backward);
  473. let subdividedHeights;
  474. let subdividedPositions;
  475. for (let i = 1; i < length - 1; i++) {
  476. const repeat = duplicatePoints ? 2 : 1;
  477. nextPosition = positions[i + 1];
  478. if (position.equals(nextPosition)) {
  479. oneTimeWarning(
  480. "Positions are too close and are considered equivalent with rounding error."
  481. );
  482. continue;
  483. }
  484. forward = Matrix2.Cartesian3.subtract(nextPosition, position, forward);
  485. forward = Matrix2.Cartesian3.normalize(forward, forward);
  486. cornerDirection = Matrix2.Cartesian3.add(forward, backward, cornerDirection);
  487. cornerDirection = Matrix2.Cartesian3.normalize(cornerDirection, cornerDirection);
  488. surfaceNormal = ellipsoid.geodeticSurfaceNormal(position, surfaceNormal);
  489. const forwardProjection = Matrix2.Cartesian3.multiplyByScalar(
  490. surfaceNormal,
  491. Matrix2.Cartesian3.dot(forward, surfaceNormal),
  492. scratchForwardProjection
  493. );
  494. Matrix2.Cartesian3.subtract(forward, forwardProjection, forwardProjection);
  495. Matrix2.Cartesian3.normalize(forwardProjection, forwardProjection);
  496. const backwardProjection = Matrix2.Cartesian3.multiplyByScalar(
  497. surfaceNormal,
  498. Matrix2.Cartesian3.dot(backward, surfaceNormal),
  499. scratchBackwardProjection
  500. );
  501. Matrix2.Cartesian3.subtract(backward, backwardProjection, backwardProjection);
  502. Matrix2.Cartesian3.normalize(backwardProjection, backwardProjection);
  503. const doCorner = !ComponentDatatype.CesiumMath.equalsEpsilon(
  504. Math.abs(Matrix2.Cartesian3.dot(forwardProjection, backwardProjection)),
  505. 1.0,
  506. ComponentDatatype.CesiumMath.EPSILON7
  507. );
  508. if (doCorner) {
  509. cornerDirection = Matrix2.Cartesian3.cross(
  510. cornerDirection,
  511. surfaceNormal,
  512. cornerDirection
  513. );
  514. cornerDirection = Matrix2.Cartesian3.cross(
  515. surfaceNormal,
  516. cornerDirection,
  517. cornerDirection
  518. );
  519. cornerDirection = Matrix2.Cartesian3.normalize(cornerDirection, cornerDirection);
  520. const scalar =
  521. 1 /
  522. Math.max(
  523. 0.25,
  524. Matrix2.Cartesian3.magnitude(
  525. Matrix2.Cartesian3.cross(cornerDirection, backward, scratch1)
  526. )
  527. );
  528. const leftIsOutside = PolylineVolumeGeometryLibrary.angleIsGreaterThanPi(
  529. forward,
  530. backward,
  531. position,
  532. ellipsoid
  533. );
  534. if (leftIsOutside) {
  535. pivot = Matrix2.Cartesian3.add(
  536. position,
  537. Matrix2.Cartesian3.multiplyByScalar(
  538. cornerDirection,
  539. scalar * width,
  540. cornerDirection
  541. ),
  542. pivot
  543. );
  544. start = Matrix2.Cartesian3.add(
  545. pivot,
  546. Matrix2.Cartesian3.multiplyByScalar(left, width, start),
  547. start
  548. );
  549. scratch2Array[0] = Matrix2.Cartesian3.clone(previousPosition, scratch2Array[0]);
  550. scratch2Array[1] = Matrix2.Cartesian3.clone(start, scratch2Array[1]);
  551. subdividedHeights = subdivideHeights(
  552. scratch2Array,
  553. h0 + heightOffset,
  554. h1 + heightOffset,
  555. granularity
  556. );
  557. subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
  558. positions: scratch2Array,
  559. granularity: granularity,
  560. ellipsoid: ellipsoid,
  561. });
  562. finalPositions = addPositions(
  563. subdividedPositions,
  564. left,
  565. shapeForSides,
  566. finalPositions,
  567. ellipsoid,
  568. subdividedHeights,
  569. 1
  570. );
  571. left = Matrix2.Cartesian3.cross(surfaceNormal, forward, left);
  572. left = Matrix2.Cartesian3.normalize(left, left);
  573. end = Matrix2.Cartesian3.add(
  574. pivot,
  575. Matrix2.Cartesian3.multiplyByScalar(left, width, end),
  576. end
  577. );
  578. if (
  579. cornerType === CornerType$1.ROUNDED ||
  580. cornerType === CornerType$1.BEVELED
  581. ) {
  582. computeRoundCorner(
  583. pivot,
  584. start,
  585. end,
  586. cornerType,
  587. leftIsOutside,
  588. ellipsoid,
  589. finalPositions,
  590. shapeForSides,
  591. h1 + heightOffset,
  592. duplicatePoints
  593. );
  594. } else {
  595. cornerDirection = Matrix2.Cartesian3.negate(cornerDirection, cornerDirection);
  596. finalPositions = addPosition(
  597. position,
  598. cornerDirection,
  599. shapeForSides,
  600. finalPositions,
  601. ellipsoid,
  602. h1 + heightOffset,
  603. scalar,
  604. repeat
  605. );
  606. }
  607. previousPosition = Matrix2.Cartesian3.clone(end, previousPosition);
  608. } else {
  609. pivot = Matrix2.Cartesian3.add(
  610. position,
  611. Matrix2.Cartesian3.multiplyByScalar(
  612. cornerDirection,
  613. scalar * width,
  614. cornerDirection
  615. ),
  616. pivot
  617. );
  618. start = Matrix2.Cartesian3.add(
  619. pivot,
  620. Matrix2.Cartesian3.multiplyByScalar(left, -width, start),
  621. start
  622. );
  623. scratch2Array[0] = Matrix2.Cartesian3.clone(previousPosition, scratch2Array[0]);
  624. scratch2Array[1] = Matrix2.Cartesian3.clone(start, scratch2Array[1]);
  625. subdividedHeights = subdivideHeights(
  626. scratch2Array,
  627. h0 + heightOffset,
  628. h1 + heightOffset,
  629. granularity
  630. );
  631. subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
  632. positions: scratch2Array,
  633. granularity: granularity,
  634. ellipsoid: ellipsoid,
  635. });
  636. finalPositions = addPositions(
  637. subdividedPositions,
  638. left,
  639. shapeForSides,
  640. finalPositions,
  641. ellipsoid,
  642. subdividedHeights,
  643. 1
  644. );
  645. left = Matrix2.Cartesian3.cross(surfaceNormal, forward, left);
  646. left = Matrix2.Cartesian3.normalize(left, left);
  647. end = Matrix2.Cartesian3.add(
  648. pivot,
  649. Matrix2.Cartesian3.multiplyByScalar(left, -width, end),
  650. end
  651. );
  652. if (
  653. cornerType === CornerType$1.ROUNDED ||
  654. cornerType === CornerType$1.BEVELED
  655. ) {
  656. computeRoundCorner(
  657. pivot,
  658. start,
  659. end,
  660. cornerType,
  661. leftIsOutside,
  662. ellipsoid,
  663. finalPositions,
  664. shapeForSides,
  665. h1 + heightOffset,
  666. duplicatePoints
  667. );
  668. } else {
  669. finalPositions = addPosition(
  670. position,
  671. cornerDirection,
  672. shapeForSides,
  673. finalPositions,
  674. ellipsoid,
  675. h1 + heightOffset,
  676. scalar,
  677. repeat
  678. );
  679. }
  680. previousPosition = Matrix2.Cartesian3.clone(end, previousPosition);
  681. }
  682. backward = Matrix2.Cartesian3.negate(forward, backward);
  683. } else {
  684. finalPositions = addPosition(
  685. previousPosition,
  686. left,
  687. shapeForSides,
  688. finalPositions,
  689. ellipsoid,
  690. h0 + heightOffset,
  691. 1,
  692. 1
  693. );
  694. previousPosition = position;
  695. }
  696. h0 = h1;
  697. h1 = heights[i + 1];
  698. position = nextPosition;
  699. }
  700. scratch2Array[0] = Matrix2.Cartesian3.clone(previousPosition, scratch2Array[0]);
  701. scratch2Array[1] = Matrix2.Cartesian3.clone(position, scratch2Array[1]);
  702. subdividedHeights = subdivideHeights(
  703. scratch2Array,
  704. h0 + heightOffset,
  705. h1 + heightOffset,
  706. granularity
  707. );
  708. subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
  709. positions: scratch2Array,
  710. granularity: granularity,
  711. ellipsoid: ellipsoid,
  712. });
  713. finalPositions = addPositions(
  714. subdividedPositions,
  715. left,
  716. shapeForSides,
  717. finalPositions,
  718. ellipsoid,
  719. subdividedHeights,
  720. 1
  721. );
  722. if (duplicatePoints) {
  723. ends = addPosition(
  724. position,
  725. left,
  726. shapeForEnds,
  727. ends,
  728. ellipsoid,
  729. h1 + heightOffset,
  730. 1,
  731. 1
  732. );
  733. }
  734. length = finalPositions.length;
  735. const posLength = duplicatePoints ? length + ends.length : length;
  736. const combinedPositions = new Float64Array(posLength);
  737. combinedPositions.set(finalPositions);
  738. if (duplicatePoints) {
  739. combinedPositions.set(ends, length);
  740. }
  741. return combinedPositions;
  742. };
  743. exports.CornerType = CornerType$1;
  744. exports.PolylineVolumeGeometryLibrary = PolylineVolumeGeometryLibrary;
  745. exports.oneTimeWarning = oneTimeWarning;
  746. }));
  747. //# sourceMappingURL=PolylineVolumeGeometryLibrary-62b3e4fb.js.map