createCorridorOutlineGeometry.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /* This file is automatically rebuilt by the Cesium build process. */
  2. define(['./GeometryOffsetAttribute-3e8c299c', './arrayRemoveDuplicates-06991c15', './Transforms-a076dbe6', './Matrix2-fc7e9822', './RuntimeError-c581ca93', './ComponentDatatype-4a60b8d6', './PolylineVolumeGeometryLibrary-759a8d46', './CorridorGeometryLibrary-3d47380e', './defaultValue-94c3e563', './GeometryAttribute-2ecf73f6', './GeometryAttributes-7df9bef6', './IndexDatatype-db156785', './PolygonPipeline-cc031b9f', './_commonjsHelpers-3aae1032-f55dc0c4', './combine-761d9c3f', './WebGLConstants-7dccdc96', './EllipsoidTangentPlane-d2c0c530', './AxisAlignedBoundingBox-8103739f', './IntersectionTests-5deed78b', './Plane-e20fba8c', './PolylinePipeline-7608e667', './EllipsoidGeodesic-dc94f381', './EllipsoidRhumbLine-daebc75b'], (function (GeometryOffsetAttribute, arrayRemoveDuplicates, Transforms, Matrix2, RuntimeError, ComponentDatatype, PolylineVolumeGeometryLibrary, CorridorGeometryLibrary, defaultValue, GeometryAttribute, GeometryAttributes, IndexDatatype, PolygonPipeline, _commonjsHelpers3aae1032, combine$1, WebGLConstants, EllipsoidTangentPlane, AxisAlignedBoundingBox, IntersectionTests, Plane, PolylinePipeline, EllipsoidGeodesic, EllipsoidRhumbLine) { 'use strict';
  3. const cartesian1 = new Matrix2.Cartesian3();
  4. const cartesian2 = new Matrix2.Cartesian3();
  5. const cartesian3 = new Matrix2.Cartesian3();
  6. function scaleToSurface(positions, ellipsoid) {
  7. for (let i = 0; i < positions.length; i++) {
  8. positions[i] = ellipsoid.scaleToGeodeticSurface(positions[i], positions[i]);
  9. }
  10. return positions;
  11. }
  12. function combine(computedPositions, cornerType) {
  13. const wallIndices = [];
  14. const positions = computedPositions.positions;
  15. const corners = computedPositions.corners;
  16. const endPositions = computedPositions.endPositions;
  17. const attributes = new GeometryAttributes.GeometryAttributes();
  18. let corner;
  19. let leftCount = 0;
  20. let rightCount = 0;
  21. let i;
  22. let indicesLength = 0;
  23. let length;
  24. for (i = 0; i < positions.length; i += 2) {
  25. length = positions[i].length - 3;
  26. leftCount += length; //subtracting 3 to account for duplicate points at corners
  27. indicesLength += (length / 3) * 4;
  28. rightCount += positions[i + 1].length - 3;
  29. }
  30. leftCount += 3; //add back count for end positions
  31. rightCount += 3;
  32. for (i = 0; i < corners.length; i++) {
  33. corner = corners[i];
  34. const leftSide = corners[i].leftPositions;
  35. if (defaultValue.defined(leftSide)) {
  36. length = leftSide.length;
  37. leftCount += length;
  38. indicesLength += (length / 3) * 2;
  39. } else {
  40. length = corners[i].rightPositions.length;
  41. rightCount += length;
  42. indicesLength += (length / 3) * 2;
  43. }
  44. }
  45. const addEndPositions = defaultValue.defined(endPositions);
  46. let endPositionLength;
  47. if (addEndPositions) {
  48. endPositionLength = endPositions[0].length - 3;
  49. leftCount += endPositionLength;
  50. rightCount += endPositionLength;
  51. endPositionLength /= 3;
  52. indicesLength += endPositionLength * 4;
  53. }
  54. const size = leftCount + rightCount;
  55. const finalPositions = new Float64Array(size);
  56. let front = 0;
  57. let back = size - 1;
  58. let UL, LL, UR, LR;
  59. let rightPos, leftPos;
  60. const halfLength = endPositionLength / 2;
  61. const indices = IndexDatatype.IndexDatatype.createTypedArray(size / 3, indicesLength + 4);
  62. let index = 0;
  63. indices[index++] = front / 3;
  64. indices[index++] = (back - 2) / 3;
  65. if (addEndPositions) {
  66. // add rounded end
  67. wallIndices.push(front / 3);
  68. leftPos = cartesian1;
  69. rightPos = cartesian2;
  70. const firstEndPositions = endPositions[0];
  71. for (i = 0; i < halfLength; i++) {
  72. leftPos = Matrix2.Cartesian3.fromArray(
  73. firstEndPositions,
  74. (halfLength - 1 - i) * 3,
  75. leftPos
  76. );
  77. rightPos = Matrix2.Cartesian3.fromArray(
  78. firstEndPositions,
  79. (halfLength + i) * 3,
  80. rightPos
  81. );
  82. CorridorGeometryLibrary.CorridorGeometryLibrary.addAttribute(finalPositions, rightPos, front);
  83. CorridorGeometryLibrary.CorridorGeometryLibrary.addAttribute(
  84. finalPositions,
  85. leftPos,
  86. undefined,
  87. back
  88. );
  89. LL = front / 3;
  90. LR = LL + 1;
  91. UL = (back - 2) / 3;
  92. UR = UL - 1;
  93. indices[index++] = UL;
  94. indices[index++] = UR;
  95. indices[index++] = LL;
  96. indices[index++] = LR;
  97. front += 3;
  98. back -= 3;
  99. }
  100. }
  101. let posIndex = 0;
  102. let rightEdge = positions[posIndex++]; //add first two edges
  103. let leftEdge = positions[posIndex++];
  104. finalPositions.set(rightEdge, front);
  105. finalPositions.set(leftEdge, back - leftEdge.length + 1);
  106. length = leftEdge.length - 3;
  107. wallIndices.push(front / 3, (back - 2) / 3);
  108. for (i = 0; i < length; i += 3) {
  109. LL = front / 3;
  110. LR = LL + 1;
  111. UL = (back - 2) / 3;
  112. UR = UL - 1;
  113. indices[index++] = UL;
  114. indices[index++] = UR;
  115. indices[index++] = LL;
  116. indices[index++] = LR;
  117. front += 3;
  118. back -= 3;
  119. }
  120. for (i = 0; i < corners.length; i++) {
  121. let j;
  122. corner = corners[i];
  123. const l = corner.leftPositions;
  124. const r = corner.rightPositions;
  125. let start;
  126. let outsidePoint = cartesian3;
  127. if (defaultValue.defined(l)) {
  128. back -= 3;
  129. start = UR;
  130. wallIndices.push(LR);
  131. for (j = 0; j < l.length / 3; j++) {
  132. outsidePoint = Matrix2.Cartesian3.fromArray(l, j * 3, outsidePoint);
  133. indices[index++] = start - j - 1;
  134. indices[index++] = start - j;
  135. CorridorGeometryLibrary.CorridorGeometryLibrary.addAttribute(
  136. finalPositions,
  137. outsidePoint,
  138. undefined,
  139. back
  140. );
  141. back -= 3;
  142. }
  143. wallIndices.push(start - Math.floor(l.length / 6));
  144. if (cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) {
  145. wallIndices.push((back - 2) / 3 + 1);
  146. }
  147. front += 3;
  148. } else {
  149. front += 3;
  150. start = LR;
  151. wallIndices.push(UR);
  152. for (j = 0; j < r.length / 3; j++) {
  153. outsidePoint = Matrix2.Cartesian3.fromArray(r, j * 3, outsidePoint);
  154. indices[index++] = start + j;
  155. indices[index++] = start + j + 1;
  156. CorridorGeometryLibrary.CorridorGeometryLibrary.addAttribute(
  157. finalPositions,
  158. outsidePoint,
  159. front
  160. );
  161. front += 3;
  162. }
  163. wallIndices.push(start + Math.floor(r.length / 6));
  164. if (cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) {
  165. wallIndices.push(front / 3 - 1);
  166. }
  167. back -= 3;
  168. }
  169. rightEdge = positions[posIndex++];
  170. leftEdge = positions[posIndex++];
  171. rightEdge.splice(0, 3); //remove duplicate points added by corner
  172. leftEdge.splice(leftEdge.length - 3, 3);
  173. finalPositions.set(rightEdge, front);
  174. finalPositions.set(leftEdge, back - leftEdge.length + 1);
  175. length = leftEdge.length - 3;
  176. for (j = 0; j < leftEdge.length; j += 3) {
  177. LR = front / 3;
  178. LL = LR - 1;
  179. UR = (back - 2) / 3;
  180. UL = UR + 1;
  181. indices[index++] = UL;
  182. indices[index++] = UR;
  183. indices[index++] = LL;
  184. indices[index++] = LR;
  185. front += 3;
  186. back -= 3;
  187. }
  188. front -= 3;
  189. back += 3;
  190. wallIndices.push(front / 3, (back - 2) / 3);
  191. }
  192. if (addEndPositions) {
  193. // add rounded end
  194. front += 3;
  195. back -= 3;
  196. leftPos = cartesian1;
  197. rightPos = cartesian2;
  198. const lastEndPositions = endPositions[1];
  199. for (i = 0; i < halfLength; i++) {
  200. leftPos = Matrix2.Cartesian3.fromArray(
  201. lastEndPositions,
  202. (endPositionLength - i - 1) * 3,
  203. leftPos
  204. );
  205. rightPos = Matrix2.Cartesian3.fromArray(lastEndPositions, i * 3, rightPos);
  206. CorridorGeometryLibrary.CorridorGeometryLibrary.addAttribute(
  207. finalPositions,
  208. leftPos,
  209. undefined,
  210. back
  211. );
  212. CorridorGeometryLibrary.CorridorGeometryLibrary.addAttribute(finalPositions, rightPos, front);
  213. LR = front / 3;
  214. LL = LR - 1;
  215. UR = (back - 2) / 3;
  216. UL = UR + 1;
  217. indices[index++] = UL;
  218. indices[index++] = UR;
  219. indices[index++] = LL;
  220. indices[index++] = LR;
  221. front += 3;
  222. back -= 3;
  223. }
  224. wallIndices.push(front / 3);
  225. } else {
  226. wallIndices.push(front / 3, (back - 2) / 3);
  227. }
  228. indices[index++] = front / 3;
  229. indices[index++] = (back - 2) / 3;
  230. attributes.position = new GeometryAttribute.GeometryAttribute({
  231. componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,
  232. componentsPerAttribute: 3,
  233. values: finalPositions,
  234. });
  235. return {
  236. attributes: attributes,
  237. indices: indices,
  238. wallIndices: wallIndices,
  239. };
  240. }
  241. function computePositionsExtruded(params) {
  242. const ellipsoid = params.ellipsoid;
  243. const computedPositions = CorridorGeometryLibrary.CorridorGeometryLibrary.computePositions(params);
  244. const attr = combine(computedPositions, params.cornerType);
  245. const wallIndices = attr.wallIndices;
  246. const height = params.height;
  247. const extrudedHeight = params.extrudedHeight;
  248. const attributes = attr.attributes;
  249. const indices = attr.indices;
  250. let positions = attributes.position.values;
  251. let length = positions.length;
  252. let extrudedPositions = new Float64Array(length);
  253. extrudedPositions.set(positions);
  254. const newPositions = new Float64Array(length * 2);
  255. positions = PolygonPipeline.PolygonPipeline.scaleToGeodeticHeight(
  256. positions,
  257. height,
  258. ellipsoid
  259. );
  260. extrudedPositions = PolygonPipeline.PolygonPipeline.scaleToGeodeticHeight(
  261. extrudedPositions,
  262. extrudedHeight,
  263. ellipsoid
  264. );
  265. newPositions.set(positions);
  266. newPositions.set(extrudedPositions, length);
  267. attributes.position.values = newPositions;
  268. length /= 3;
  269. if (defaultValue.defined(params.offsetAttribute)) {
  270. let applyOffset = new Uint8Array(length * 2);
  271. if (params.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
  272. applyOffset = GeometryOffsetAttribute.arrayFill(applyOffset, 1, 0, length);
  273. } else {
  274. const applyOffsetValue =
  275. params.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
  276. applyOffset = GeometryOffsetAttribute.arrayFill(applyOffset, applyOffsetValue);
  277. }
  278. attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
  279. componentDatatype: ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
  280. componentsPerAttribute: 1,
  281. values: applyOffset,
  282. });
  283. }
  284. let i;
  285. const iLength = indices.length;
  286. const newIndices = IndexDatatype.IndexDatatype.createTypedArray(
  287. newPositions.length / 3,
  288. (iLength + wallIndices.length) * 2
  289. );
  290. newIndices.set(indices);
  291. let index = iLength;
  292. for (i = 0; i < iLength; i += 2) {
  293. // bottom indices
  294. const v0 = indices[i];
  295. const v1 = indices[i + 1];
  296. newIndices[index++] = v0 + length;
  297. newIndices[index++] = v1 + length;
  298. }
  299. let UL, LL;
  300. for (i = 0; i < wallIndices.length; i++) {
  301. //wall indices
  302. UL = wallIndices[i];
  303. LL = UL + length;
  304. newIndices[index++] = UL;
  305. newIndices[index++] = LL;
  306. }
  307. return {
  308. attributes: attributes,
  309. indices: newIndices,
  310. };
  311. }
  312. /**
  313. * A description of a corridor outline.
  314. *
  315. * @alias CorridorOutlineGeometry
  316. * @constructor
  317. *
  318. * @param {Object} options Object with the following properties:
  319. * @param {Cartesian3[]} options.positions An array of positions that define the center of the corridor outline.
  320. * @param {Number} options.width The distance between the edges of the corridor outline.
  321. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference.
  322. * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
  323. * @param {Number} [options.height=0] The distance in meters between the positions and the ellipsoid surface.
  324. * @param {Number} [options.extrudedHeight] The distance in meters between the extruded face and the ellipsoid surface.
  325. * @param {CornerType} [options.cornerType=CornerType.ROUNDED] Determines the style of the corners.
  326. *
  327. * @see CorridorOutlineGeometry.createGeometry
  328. *
  329. * @example
  330. * const corridor = new Cesium.CorridorOutlineGeometry({
  331. * positions : Cesium.Cartesian3.fromDegreesArray([-72.0, 40.0, -70.0, 35.0]),
  332. * width : 100000
  333. * });
  334. */
  335. function CorridorOutlineGeometry(options) {
  336. options = defaultValue.defaultValue(options, defaultValue.defaultValue.EMPTY_OBJECT);
  337. const positions = options.positions;
  338. const width = options.width;
  339. //>>includeStart('debug', pragmas.debug);
  340. RuntimeError.Check.typeOf.object("options.positions", positions);
  341. RuntimeError.Check.typeOf.number("options.width", width);
  342. //>>includeEnd('debug');
  343. const height = defaultValue.defaultValue(options.height, 0.0);
  344. const extrudedHeight = defaultValue.defaultValue(options.extrudedHeight, height);
  345. this._positions = positions;
  346. this._ellipsoid = Matrix2.Ellipsoid.clone(
  347. defaultValue.defaultValue(options.ellipsoid, Matrix2.Ellipsoid.WGS84)
  348. );
  349. this._width = width;
  350. this._height = Math.max(height, extrudedHeight);
  351. this._extrudedHeight = Math.min(height, extrudedHeight);
  352. this._cornerType = defaultValue.defaultValue(options.cornerType, PolylineVolumeGeometryLibrary.CornerType.ROUNDED);
  353. this._granularity = defaultValue.defaultValue(
  354. options.granularity,
  355. ComponentDatatype.CesiumMath.RADIANS_PER_DEGREE
  356. );
  357. this._offsetAttribute = options.offsetAttribute;
  358. this._workerName = "createCorridorOutlineGeometry";
  359. /**
  360. * The number of elements used to pack the object into an array.
  361. * @type {Number}
  362. */
  363. this.packedLength =
  364. 1 + positions.length * Matrix2.Cartesian3.packedLength + Matrix2.Ellipsoid.packedLength + 6;
  365. }
  366. /**
  367. * Stores the provided instance into the provided array.
  368. *
  369. * @param {CorridorOutlineGeometry} value The value to pack.
  370. * @param {Number[]} array The array to pack into.
  371. * @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
  372. *
  373. * @returns {Number[]} The array that was packed into
  374. */
  375. CorridorOutlineGeometry.pack = function (value, array, startingIndex) {
  376. //>>includeStart('debug', pragmas.debug);
  377. RuntimeError.Check.typeOf.object("value", value);
  378. RuntimeError.Check.typeOf.object("array", array);
  379. //>>includeEnd('debug');
  380. startingIndex = defaultValue.defaultValue(startingIndex, 0);
  381. const positions = value._positions;
  382. const length = positions.length;
  383. array[startingIndex++] = length;
  384. for (let i = 0; i < length; ++i, startingIndex += Matrix2.Cartesian3.packedLength) {
  385. Matrix2.Cartesian3.pack(positions[i], array, startingIndex);
  386. }
  387. Matrix2.Ellipsoid.pack(value._ellipsoid, array, startingIndex);
  388. startingIndex += Matrix2.Ellipsoid.packedLength;
  389. array[startingIndex++] = value._width;
  390. array[startingIndex++] = value._height;
  391. array[startingIndex++] = value._extrudedHeight;
  392. array[startingIndex++] = value._cornerType;
  393. array[startingIndex++] = value._granularity;
  394. array[startingIndex] = defaultValue.defaultValue(value._offsetAttribute, -1);
  395. return array;
  396. };
  397. const scratchEllipsoid = Matrix2.Ellipsoid.clone(Matrix2.Ellipsoid.UNIT_SPHERE);
  398. const scratchOptions = {
  399. positions: undefined,
  400. ellipsoid: scratchEllipsoid,
  401. width: undefined,
  402. height: undefined,
  403. extrudedHeight: undefined,
  404. cornerType: undefined,
  405. granularity: undefined,
  406. offsetAttribute: undefined,
  407. };
  408. /**
  409. * Retrieves an instance from a packed array.
  410. *
  411. * @param {Number[]} array The packed array.
  412. * @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
  413. * @param {CorridorOutlineGeometry} [result] The object into which to store the result.
  414. * @returns {CorridorOutlineGeometry} The modified result parameter or a new CorridorOutlineGeometry instance if one was not provided.
  415. */
  416. CorridorOutlineGeometry.unpack = function (array, startingIndex, result) {
  417. //>>includeStart('debug', pragmas.debug);
  418. RuntimeError.Check.typeOf.object("array", array);
  419. //>>includeEnd('debug');
  420. startingIndex = defaultValue.defaultValue(startingIndex, 0);
  421. const length = array[startingIndex++];
  422. const positions = new Array(length);
  423. for (let i = 0; i < length; ++i, startingIndex += Matrix2.Cartesian3.packedLength) {
  424. positions[i] = Matrix2.Cartesian3.unpack(array, startingIndex);
  425. }
  426. const ellipsoid = Matrix2.Ellipsoid.unpack(array, startingIndex, scratchEllipsoid);
  427. startingIndex += Matrix2.Ellipsoid.packedLength;
  428. const width = array[startingIndex++];
  429. const height = array[startingIndex++];
  430. const extrudedHeight = array[startingIndex++];
  431. const cornerType = array[startingIndex++];
  432. const granularity = array[startingIndex++];
  433. const offsetAttribute = array[startingIndex];
  434. if (!defaultValue.defined(result)) {
  435. scratchOptions.positions = positions;
  436. scratchOptions.width = width;
  437. scratchOptions.height = height;
  438. scratchOptions.extrudedHeight = extrudedHeight;
  439. scratchOptions.cornerType = cornerType;
  440. scratchOptions.granularity = granularity;
  441. scratchOptions.offsetAttribute =
  442. offsetAttribute === -1 ? undefined : offsetAttribute;
  443. return new CorridorOutlineGeometry(scratchOptions);
  444. }
  445. result._positions = positions;
  446. result._ellipsoid = Matrix2.Ellipsoid.clone(ellipsoid, result._ellipsoid);
  447. result._width = width;
  448. result._height = height;
  449. result._extrudedHeight = extrudedHeight;
  450. result._cornerType = cornerType;
  451. result._granularity = granularity;
  452. result._offsetAttribute =
  453. offsetAttribute === -1 ? undefined : offsetAttribute;
  454. return result;
  455. };
  456. /**
  457. * Computes the geometric representation of a corridor, including its vertices, indices, and a bounding sphere.
  458. *
  459. * @param {CorridorOutlineGeometry} corridorOutlineGeometry A description of the corridor.
  460. * @returns {Geometry|undefined} The computed vertices and indices.
  461. */
  462. CorridorOutlineGeometry.createGeometry = function (corridorOutlineGeometry) {
  463. let positions = corridorOutlineGeometry._positions;
  464. const width = corridorOutlineGeometry._width;
  465. const ellipsoid = corridorOutlineGeometry._ellipsoid;
  466. positions = scaleToSurface(positions, ellipsoid);
  467. const cleanPositions = arrayRemoveDuplicates.arrayRemoveDuplicates(
  468. positions,
  469. Matrix2.Cartesian3.equalsEpsilon
  470. );
  471. if (cleanPositions.length < 2 || width <= 0) {
  472. return;
  473. }
  474. const height = corridorOutlineGeometry._height;
  475. const extrudedHeight = corridorOutlineGeometry._extrudedHeight;
  476. const extrude = !ComponentDatatype.CesiumMath.equalsEpsilon(
  477. height,
  478. extrudedHeight,
  479. 0,
  480. ComponentDatatype.CesiumMath.EPSILON2
  481. );
  482. const params = {
  483. ellipsoid: ellipsoid,
  484. positions: cleanPositions,
  485. width: width,
  486. cornerType: corridorOutlineGeometry._cornerType,
  487. granularity: corridorOutlineGeometry._granularity,
  488. saveAttributes: false,
  489. };
  490. let attr;
  491. if (extrude) {
  492. params.height = height;
  493. params.extrudedHeight = extrudedHeight;
  494. params.offsetAttribute = corridorOutlineGeometry._offsetAttribute;
  495. attr = computePositionsExtruded(params);
  496. } else {
  497. const computedPositions = CorridorGeometryLibrary.CorridorGeometryLibrary.computePositions(params);
  498. attr = combine(computedPositions, params.cornerType);
  499. attr.attributes.position.values = PolygonPipeline.PolygonPipeline.scaleToGeodeticHeight(
  500. attr.attributes.position.values,
  501. height,
  502. ellipsoid
  503. );
  504. if (defaultValue.defined(corridorOutlineGeometry._offsetAttribute)) {
  505. const length = attr.attributes.position.values.length;
  506. const applyOffset = new Uint8Array(length / 3);
  507. const offsetValue =
  508. corridorOutlineGeometry._offsetAttribute ===
  509. GeometryOffsetAttribute.GeometryOffsetAttribute.NONE
  510. ? 0
  511. : 1;
  512. GeometryOffsetAttribute.arrayFill(applyOffset, offsetValue);
  513. attr.attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
  514. componentDatatype: ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
  515. componentsPerAttribute: 1,
  516. values: applyOffset,
  517. });
  518. }
  519. }
  520. const attributes = attr.attributes;
  521. const boundingSphere = Transforms.BoundingSphere.fromVertices(
  522. attributes.position.values,
  523. undefined,
  524. 3
  525. );
  526. return new GeometryAttribute.Geometry({
  527. attributes: attributes,
  528. indices: attr.indices,
  529. primitiveType: GeometryAttribute.PrimitiveType.LINES,
  530. boundingSphere: boundingSphere,
  531. offsetAttribute: corridorOutlineGeometry._offsetAttribute,
  532. });
  533. };
  534. function createCorridorOutlineGeometry(corridorOutlineGeometry, offset) {
  535. if (defaultValue.defined(offset)) {
  536. corridorOutlineGeometry = CorridorOutlineGeometry.unpack(
  537. corridorOutlineGeometry,
  538. offset
  539. );
  540. }
  541. corridorOutlineGeometry._ellipsoid = Matrix2.Ellipsoid.clone(
  542. corridorOutlineGeometry._ellipsoid
  543. );
  544. return CorridorOutlineGeometry.createGeometry(corridorOutlineGeometry);
  545. }
  546. return createCorridorOutlineGeometry;
  547. }));