createVerticesFromGoogleEarthEnterpriseBuffer.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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(['./when-54c2dc71', './Check-6c0211bc', './Math-1124a290', './Cartesian2-33d2657c', './Transforms-8be64844', './RuntimeError-2109023a', './WebGLConstants-76bb35d1', './ComponentDatatype-a26dd044', './AttributeCompression-75249b5e', './IntersectionTests-afc38163', './Plane-fa30fc46', './WebMercatorProjection-054890ef', './createTaskProcessorWorker', './EllipsoidTangentPlane-ce6e380f', './OrientedBoundingBox-8897f474', './TerrainEncoding-6954276f'], function (when, Check, _Math, Cartesian2, Transforms, RuntimeError, WebGLConstants, ComponentDatatype, AttributeCompression, IntersectionTests, Plane, WebMercatorProjection, createTaskProcessorWorker, EllipsoidTangentPlane, OrientedBoundingBox, TerrainEncoding) { 'use strict';
  24. var sizeOfUint16 = Uint16Array.BYTES_PER_ELEMENT;
  25. var sizeOfInt32 = Int32Array.BYTES_PER_ELEMENT;
  26. var sizeOfUint32 = Uint32Array.BYTES_PER_ELEMENT;
  27. var sizeOfFloat = Float32Array.BYTES_PER_ELEMENT;
  28. var sizeOfDouble = Float64Array.BYTES_PER_ELEMENT;
  29. function indexOfEpsilon(arr, elem, elemType) {
  30. elemType = when.defaultValue(elemType, _Math.CesiumMath);
  31. var count = arr.length;
  32. for (var i = 0; i < count; ++i) {
  33. if (elemType.equalsEpsilon(arr[i], elem, _Math.CesiumMath.EPSILON12)) {
  34. return i;
  35. }
  36. }
  37. return -1;
  38. }
  39. function createVerticesFromGoogleEarthEnterpriseBuffer(
  40. parameters,
  41. transferableObjects
  42. ) {
  43. parameters.ellipsoid = Cartesian2.Ellipsoid.clone(parameters.ellipsoid);
  44. parameters.rectangle = Cartesian2.Rectangle.clone(parameters.rectangle);
  45. var statistics = processBuffer(
  46. parameters.buffer,
  47. parameters.relativeToCenter,
  48. parameters.ellipsoid,
  49. parameters.rectangle,
  50. parameters.nativeRectangle,
  51. parameters.exaggeration,
  52. parameters.skirtHeight,
  53. parameters.includeWebMercatorT,
  54. parameters.negativeAltitudeExponentBias,
  55. parameters.negativeElevationThreshold
  56. );
  57. var vertices = statistics.vertices;
  58. transferableObjects.push(vertices.buffer);
  59. var indices = statistics.indices;
  60. transferableObjects.push(indices.buffer);
  61. return {
  62. vertices: vertices.buffer,
  63. indices: indices.buffer,
  64. numberOfAttributes: statistics.encoding.getStride(),
  65. minimumHeight: statistics.minimumHeight,
  66. maximumHeight: statistics.maximumHeight,
  67. boundingSphere3D: statistics.boundingSphere3D,
  68. orientedBoundingBox: statistics.orientedBoundingBox,
  69. occludeePointInScaledSpace: statistics.occludeePointInScaledSpace,
  70. encoding: statistics.encoding,
  71. vertexCountWithoutSkirts: statistics.vertexCountWithoutSkirts,
  72. indexCountWithoutSkirts: statistics.indexCountWithoutSkirts,
  73. westIndicesSouthToNorth: statistics.westIndicesSouthToNorth,
  74. southIndicesEastToWest: statistics.southIndicesEastToWest,
  75. eastIndicesNorthToSouth: statistics.eastIndicesNorthToSouth,
  76. northIndicesWestToEast: statistics.northIndicesWestToEast,
  77. };
  78. }
  79. var scratchCartographic = new Cartesian2.Cartographic();
  80. var scratchCartesian = new Cartesian2.Cartesian3();
  81. var minimumScratch = new Cartesian2.Cartesian3();
  82. var maximumScratch = new Cartesian2.Cartesian3();
  83. var matrix4Scratch = new Transforms.Matrix4();
  84. function processBuffer(
  85. buffer,
  86. relativeToCenter,
  87. ellipsoid,
  88. rectangle,
  89. nativeRectangle,
  90. exaggeration,
  91. skirtHeight,
  92. includeWebMercatorT,
  93. negativeAltitudeExponentBias,
  94. negativeElevationThreshold
  95. ) {
  96. var geographicWest;
  97. var geographicSouth;
  98. var geographicEast;
  99. var geographicNorth;
  100. var rectangleWidth, rectangleHeight;
  101. if (!when.defined(rectangle)) {
  102. geographicWest = _Math.CesiumMath.toRadians(nativeRectangle.west);
  103. geographicSouth = _Math.CesiumMath.toRadians(nativeRectangle.south);
  104. geographicEast = _Math.CesiumMath.toRadians(nativeRectangle.east);
  105. geographicNorth = _Math.CesiumMath.toRadians(nativeRectangle.north);
  106. rectangleWidth = _Math.CesiumMath.toRadians(rectangle.width);
  107. rectangleHeight = _Math.CesiumMath.toRadians(rectangle.height);
  108. } else {
  109. geographicWest = rectangle.west;
  110. geographicSouth = rectangle.south;
  111. geographicEast = rectangle.east;
  112. geographicNorth = rectangle.north;
  113. rectangleWidth = rectangle.width;
  114. rectangleHeight = rectangle.height;
  115. }
  116. // Keep track of quad borders so we can remove duplicates around the borders
  117. var quadBorderLatitudes = [geographicSouth, geographicNorth];
  118. var quadBorderLongitudes = [geographicWest, geographicEast];
  119. var fromENU = Transforms.Transforms.eastNorthUpToFixedFrame(relativeToCenter, ellipsoid);
  120. var toENU = Transforms.Matrix4.inverseTransformation(fromENU, matrix4Scratch);
  121. var southMercatorY;
  122. var oneOverMercatorHeight;
  123. if (includeWebMercatorT) {
  124. southMercatorY = WebMercatorProjection.WebMercatorProjection.geodeticLatitudeToMercatorAngle(
  125. geographicSouth
  126. );
  127. oneOverMercatorHeight =
  128. 1.0 /
  129. (WebMercatorProjection.WebMercatorProjection.geodeticLatitudeToMercatorAngle(geographicNorth) -
  130. southMercatorY);
  131. }
  132. var dv = new DataView(buffer);
  133. var minHeight = Number.POSITIVE_INFINITY;
  134. var maxHeight = Number.NEGATIVE_INFINITY;
  135. var minimum = minimumScratch;
  136. minimum.x = Number.POSITIVE_INFINITY;
  137. minimum.y = Number.POSITIVE_INFINITY;
  138. minimum.z = Number.POSITIVE_INFINITY;
  139. var maximum = maximumScratch;
  140. maximum.x = Number.NEGATIVE_INFINITY;
  141. maximum.y = Number.NEGATIVE_INFINITY;
  142. maximum.z = Number.NEGATIVE_INFINITY;
  143. // Compute sizes
  144. var offset = 0;
  145. var size = 0;
  146. var indicesSize = 0;
  147. var quadSize;
  148. var quad;
  149. for (quad = 0; quad < 4; ++quad) {
  150. var o = offset;
  151. quadSize = dv.getUint32(o, true);
  152. o += sizeOfUint32;
  153. var x = _Math.CesiumMath.toRadians(dv.getFloat64(o, true) * 180.0);
  154. o += sizeOfDouble;
  155. if (indexOfEpsilon(quadBorderLongitudes, x) === -1) {
  156. quadBorderLongitudes.push(x);
  157. }
  158. var y = _Math.CesiumMath.toRadians(dv.getFloat64(o, true) * 180.0);
  159. o += sizeOfDouble;
  160. if (indexOfEpsilon(quadBorderLatitudes, y) === -1) {
  161. quadBorderLatitudes.push(y);
  162. }
  163. o += 2 * sizeOfDouble; // stepX + stepY
  164. var c = dv.getInt32(o, true); // Read point count
  165. o += sizeOfInt32;
  166. size += c;
  167. c = dv.getInt32(o, true); // Read index count
  168. indicesSize += c * 3;
  169. offset += quadSize + sizeOfUint32; // Jump to next quad
  170. }
  171. // Quad Border points to remove duplicates
  172. var quadBorderPoints = [];
  173. var quadBorderIndices = [];
  174. // Create arrays
  175. var positions = new Array(size);
  176. var uvs = new Array(size);
  177. var heights = new Array(size);
  178. var webMercatorTs = includeWebMercatorT ? new Array(size) : [];
  179. var indices = new Array(indicesSize);
  180. // Points are laid out in rows starting at SW, so storing border points as we
  181. // come across them all points will be adjacent.
  182. var westBorder = [];
  183. var southBorder = [];
  184. var eastBorder = [];
  185. var northBorder = [];
  186. // Each tile is split into 4 parts
  187. var pointOffset = 0;
  188. var indicesOffset = 0;
  189. offset = 0;
  190. for (quad = 0; quad < 4; ++quad) {
  191. quadSize = dv.getUint32(offset, true);
  192. offset += sizeOfUint32;
  193. var startQuad = offset;
  194. var originX = _Math.CesiumMath.toRadians(dv.getFloat64(offset, true) * 180.0);
  195. offset += sizeOfDouble;
  196. var originY = _Math.CesiumMath.toRadians(dv.getFloat64(offset, true) * 180.0);
  197. offset += sizeOfDouble;
  198. var stepX = _Math.CesiumMath.toRadians(dv.getFloat64(offset, true) * 180.0);
  199. var halfStepX = stepX * 0.5;
  200. offset += sizeOfDouble;
  201. var stepY = _Math.CesiumMath.toRadians(dv.getFloat64(offset, true) * 180.0);
  202. var halfStepY = stepY * 0.5;
  203. offset += sizeOfDouble;
  204. var numPoints = dv.getInt32(offset, true);
  205. offset += sizeOfInt32;
  206. var numFaces = dv.getInt32(offset, true);
  207. offset += sizeOfInt32;
  208. //var level = dv.getInt32(offset, true);
  209. offset += sizeOfInt32;
  210. // Keep track of quad indices to overall tile indices
  211. var indicesMapping = new Array(numPoints);
  212. for (var i = 0; i < numPoints; ++i) {
  213. var longitude = originX + dv.getUint8(offset++) * stepX;
  214. scratchCartographic.longitude = longitude;
  215. var latitude = originY + dv.getUint8(offset++) * stepY;
  216. scratchCartographic.latitude = latitude;
  217. var height = dv.getFloat32(offset, true);
  218. offset += sizeOfFloat;
  219. // In order to support old clients, negative altitude values are stored as
  220. // height/-2^32. Old clients see the value as really close to 0 but new clients multiply
  221. // by -2^32 to get the real negative altitude value.
  222. if (height !== 0 && height < negativeElevationThreshold) {
  223. height *= -Math.pow(2, negativeAltitudeExponentBias);
  224. }
  225. // Height is stored in units of (1/EarthRadius) or (1/6371010.0)
  226. height *= 6371010.0 * exaggeration;
  227. scratchCartographic.height = height;
  228. // Is it along a quad border - if so check if already exists and use that index
  229. if (
  230. indexOfEpsilon(quadBorderLongitudes, longitude) !== -1 ||
  231. indexOfEpsilon(quadBorderLatitudes, latitude) !== -1
  232. ) {
  233. var index = indexOfEpsilon(
  234. quadBorderPoints,
  235. scratchCartographic,
  236. Cartesian2.Cartographic
  237. );
  238. if (index === -1) {
  239. quadBorderPoints.push(Cartesian2.Cartographic.clone(scratchCartographic));
  240. quadBorderIndices.push(pointOffset);
  241. } else {
  242. indicesMapping[i] = quadBorderIndices[index];
  243. continue;
  244. }
  245. }
  246. indicesMapping[i] = pointOffset;
  247. if (Math.abs(longitude - geographicWest) < halfStepX) {
  248. westBorder.push({
  249. index: pointOffset,
  250. cartographic: Cartesian2.Cartographic.clone(scratchCartographic),
  251. });
  252. } else if (Math.abs(longitude - geographicEast) < halfStepX) {
  253. eastBorder.push({
  254. index: pointOffset,
  255. cartographic: Cartesian2.Cartographic.clone(scratchCartographic),
  256. });
  257. } else if (Math.abs(latitude - geographicSouth) < halfStepY) {
  258. southBorder.push({
  259. index: pointOffset,
  260. cartographic: Cartesian2.Cartographic.clone(scratchCartographic),
  261. });
  262. } else if (Math.abs(latitude - geographicNorth) < halfStepY) {
  263. northBorder.push({
  264. index: pointOffset,
  265. cartographic: Cartesian2.Cartographic.clone(scratchCartographic),
  266. });
  267. }
  268. minHeight = Math.min(height, minHeight);
  269. maxHeight = Math.max(height, maxHeight);
  270. heights[pointOffset] = height;
  271. var pos = ellipsoid.cartographicToCartesian(scratchCartographic);
  272. positions[pointOffset] = pos;
  273. if (includeWebMercatorT) {
  274. webMercatorTs[pointOffset] =
  275. (WebMercatorProjection.WebMercatorProjection.geodeticLatitudeToMercatorAngle(latitude) -
  276. southMercatorY) *
  277. oneOverMercatorHeight;
  278. }
  279. Transforms.Matrix4.multiplyByPoint(toENU, pos, scratchCartesian);
  280. Cartesian2.Cartesian3.minimumByComponent(scratchCartesian, minimum, minimum);
  281. Cartesian2.Cartesian3.maximumByComponent(scratchCartesian, maximum, maximum);
  282. var u = (longitude - geographicWest) / (geographicEast - geographicWest);
  283. u = _Math.CesiumMath.clamp(u, 0.0, 1.0);
  284. var v =
  285. (latitude - geographicSouth) / (geographicNorth - geographicSouth);
  286. v = _Math.CesiumMath.clamp(v, 0.0, 1.0);
  287. uvs[pointOffset] = new Cartesian2.Cartesian2(u, v);
  288. ++pointOffset;
  289. }
  290. var facesElementCount = numFaces * 3;
  291. for (var j = 0; j < facesElementCount; ++j, ++indicesOffset) {
  292. indices[indicesOffset] = indicesMapping[dv.getUint16(offset, true)];
  293. offset += sizeOfUint16;
  294. }
  295. if (quadSize !== offset - startQuad) {
  296. throw new RuntimeError.RuntimeError("Invalid terrain tile.");
  297. }
  298. }
  299. positions.length = pointOffset;
  300. uvs.length = pointOffset;
  301. heights.length = pointOffset;
  302. if (includeWebMercatorT) {
  303. webMercatorTs.length = pointOffset;
  304. }
  305. var vertexCountWithoutSkirts = pointOffset;
  306. var indexCountWithoutSkirts = indicesOffset;
  307. // Add skirt points
  308. var skirtOptions = {
  309. hMin: minHeight,
  310. lastBorderPoint: undefined,
  311. skirtHeight: skirtHeight,
  312. toENU: toENU,
  313. ellipsoid: ellipsoid,
  314. minimum: minimum,
  315. maximum: maximum,
  316. };
  317. // Sort counter clockwise from NW corner
  318. // Corner points are in the east/west arrays
  319. westBorder.sort(function (a, b) {
  320. return b.cartographic.latitude - a.cartographic.latitude;
  321. });
  322. southBorder.sort(function (a, b) {
  323. return a.cartographic.longitude - b.cartographic.longitude;
  324. });
  325. eastBorder.sort(function (a, b) {
  326. return a.cartographic.latitude - b.cartographic.latitude;
  327. });
  328. northBorder.sort(function (a, b) {
  329. return b.cartographic.longitude - a.cartographic.longitude;
  330. });
  331. var percentage = 0.00001;
  332. addSkirt(
  333. positions,
  334. heights,
  335. uvs,
  336. webMercatorTs,
  337. indices,
  338. skirtOptions,
  339. westBorder,
  340. -percentage * rectangleWidth,
  341. true,
  342. -percentage * rectangleHeight
  343. );
  344. addSkirt(
  345. positions,
  346. heights,
  347. uvs,
  348. webMercatorTs,
  349. indices,
  350. skirtOptions,
  351. southBorder,
  352. -percentage * rectangleHeight,
  353. false
  354. );
  355. addSkirt(
  356. positions,
  357. heights,
  358. uvs,
  359. webMercatorTs,
  360. indices,
  361. skirtOptions,
  362. eastBorder,
  363. percentage * rectangleWidth,
  364. true,
  365. percentage * rectangleHeight
  366. );
  367. addSkirt(
  368. positions,
  369. heights,
  370. uvs,
  371. webMercatorTs,
  372. indices,
  373. skirtOptions,
  374. northBorder,
  375. percentage * rectangleHeight,
  376. false
  377. );
  378. // Since the corner between the north and west sides is in the west array, generate the last
  379. // two triangles between the last north vertex and the first west vertex
  380. if (westBorder.length > 0 && northBorder.length > 0) {
  381. var firstBorderIndex = westBorder[0].index;
  382. var firstSkirtIndex = vertexCountWithoutSkirts;
  383. var lastBorderIndex = northBorder[northBorder.length - 1].index;
  384. var lastSkirtIndex = positions.length - 1;
  385. indices.push(
  386. lastBorderIndex,
  387. lastSkirtIndex,
  388. firstSkirtIndex,
  389. firstSkirtIndex,
  390. firstBorderIndex,
  391. lastBorderIndex
  392. );
  393. }
  394. size = positions.length; // Get new size with skirt vertices
  395. var boundingSphere3D = Transforms.BoundingSphere.fromPoints(positions);
  396. var orientedBoundingBox;
  397. if (when.defined(rectangle)) {
  398. orientedBoundingBox = OrientedBoundingBox.OrientedBoundingBox.fromRectangle(
  399. rectangle,
  400. minHeight,
  401. maxHeight,
  402. ellipsoid
  403. );
  404. }
  405. var occluder = new TerrainEncoding.EllipsoidalOccluder(ellipsoid);
  406. var occludeePointInScaledSpace = occluder.computeHorizonCullingPointPossiblyUnderEllipsoid(
  407. relativeToCenter,
  408. positions,
  409. minHeight
  410. );
  411. var aaBox = new EllipsoidTangentPlane.AxisAlignedBoundingBox(minimum, maximum, relativeToCenter);
  412. var encoding = new TerrainEncoding.TerrainEncoding(
  413. aaBox,
  414. skirtOptions.hMin,
  415. maxHeight,
  416. fromENU,
  417. false,
  418. includeWebMercatorT
  419. );
  420. var vertices = new Float32Array(size * encoding.getStride());
  421. var bufferIndex = 0;
  422. for (var k = 0; k < size; ++k) {
  423. bufferIndex = encoding.encode(
  424. vertices,
  425. bufferIndex,
  426. positions[k],
  427. uvs[k],
  428. heights[k],
  429. undefined,
  430. webMercatorTs[k]
  431. );
  432. }
  433. var westIndicesSouthToNorth = westBorder
  434. .map(function (vertex) {
  435. return vertex.index;
  436. })
  437. .reverse();
  438. var southIndicesEastToWest = southBorder
  439. .map(function (vertex) {
  440. return vertex.index;
  441. })
  442. .reverse();
  443. var eastIndicesNorthToSouth = eastBorder
  444. .map(function (vertex) {
  445. return vertex.index;
  446. })
  447. .reverse();
  448. var northIndicesWestToEast = northBorder
  449. .map(function (vertex) {
  450. return vertex.index;
  451. })
  452. .reverse();
  453. southIndicesEastToWest.unshift(
  454. eastIndicesNorthToSouth[eastIndicesNorthToSouth.length - 1]
  455. );
  456. southIndicesEastToWest.push(westIndicesSouthToNorth[0]);
  457. northIndicesWestToEast.unshift(
  458. westIndicesSouthToNorth[westIndicesSouthToNorth.length - 1]
  459. );
  460. northIndicesWestToEast.push(eastIndicesNorthToSouth[0]);
  461. return {
  462. vertices: vertices,
  463. indices: new Uint16Array(indices),
  464. maximumHeight: maxHeight,
  465. minimumHeight: minHeight,
  466. encoding: encoding,
  467. boundingSphere3D: boundingSphere3D,
  468. orientedBoundingBox: orientedBoundingBox,
  469. occludeePointInScaledSpace: occludeePointInScaledSpace,
  470. vertexCountWithoutSkirts: vertexCountWithoutSkirts,
  471. indexCountWithoutSkirts: indexCountWithoutSkirts,
  472. westIndicesSouthToNorth: westIndicesSouthToNorth,
  473. southIndicesEastToWest: southIndicesEastToWest,
  474. eastIndicesNorthToSouth: eastIndicesNorthToSouth,
  475. northIndicesWestToEast: northIndicesWestToEast,
  476. };
  477. }
  478. function addSkirt(
  479. positions,
  480. heights,
  481. uvs,
  482. webMercatorTs,
  483. indices,
  484. skirtOptions,
  485. borderPoints,
  486. fudgeFactor,
  487. eastOrWest,
  488. cornerFudge
  489. ) {
  490. var count = borderPoints.length;
  491. for (var j = 0; j < count; ++j) {
  492. var borderPoint = borderPoints[j];
  493. var borderCartographic = borderPoint.cartographic;
  494. var borderIndex = borderPoint.index;
  495. var currentIndex = positions.length;
  496. var longitude = borderCartographic.longitude;
  497. var latitude = borderCartographic.latitude;
  498. latitude = _Math.CesiumMath.clamp(
  499. latitude,
  500. -_Math.CesiumMath.PI_OVER_TWO,
  501. _Math.CesiumMath.PI_OVER_TWO
  502. ); // Don't go over the poles
  503. var height = borderCartographic.height - skirtOptions.skirtHeight;
  504. skirtOptions.hMin = Math.min(skirtOptions.hMin, height);
  505. Cartesian2.Cartographic.fromRadians(longitude, latitude, height, scratchCartographic);
  506. // Adjust sides to angle out
  507. if (eastOrWest) {
  508. scratchCartographic.longitude += fudgeFactor;
  509. }
  510. // Adjust top or bottom to angle out
  511. // Since corners are in the east/west arrays angle the first and last points as well
  512. if (!eastOrWest) {
  513. scratchCartographic.latitude += fudgeFactor;
  514. } else if (j === count - 1) {
  515. scratchCartographic.latitude += cornerFudge;
  516. } else if (j === 0) {
  517. scratchCartographic.latitude -= cornerFudge;
  518. }
  519. var pos = skirtOptions.ellipsoid.cartographicToCartesian(
  520. scratchCartographic
  521. );
  522. positions.push(pos);
  523. heights.push(height);
  524. uvs.push(Cartesian2.Cartesian2.clone(uvs[borderIndex])); // Copy UVs from border point
  525. if (webMercatorTs.length > 0) {
  526. webMercatorTs.push(webMercatorTs[borderIndex]);
  527. }
  528. Transforms.Matrix4.multiplyByPoint(skirtOptions.toENU, pos, scratchCartesian);
  529. var minimum = skirtOptions.minimum;
  530. var maximum = skirtOptions.maximum;
  531. Cartesian2.Cartesian3.minimumByComponent(scratchCartesian, minimum, minimum);
  532. Cartesian2.Cartesian3.maximumByComponent(scratchCartesian, maximum, maximum);
  533. var lastBorderPoint = skirtOptions.lastBorderPoint;
  534. if (when.defined(lastBorderPoint)) {
  535. var lastBorderIndex = lastBorderPoint.index;
  536. indices.push(
  537. lastBorderIndex,
  538. currentIndex - 1,
  539. currentIndex,
  540. currentIndex,
  541. borderIndex,
  542. lastBorderIndex
  543. );
  544. }
  545. skirtOptions.lastBorderPoint = borderPoint;
  546. }
  547. }
  548. var createVerticesFromGoogleEarthEnterpriseBuffer$1 = createTaskProcessorWorker(
  549. createVerticesFromGoogleEarthEnterpriseBuffer
  550. );
  551. return createVerticesFromGoogleEarthEnterpriseBuffer$1;
  552. });
  553. //# sourceMappingURL=createVerticesFromGoogleEarthEnterpriseBuffer.js.map