createPolylineGeometry.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. define(['./defaultValue-fe22d8c0', './Matrix3-41c58dde', './ArcType-2d9abbbc', './arrayRemoveDuplicates-d2061e85', './Transforms-bc45e707', './Color-2dc49658', './ComponentDatatype-cf1fa08e', './Check-6ede7e26', './GeometryAttribute-a466e9c7', './GeometryAttributes-ad136444', './IndexDatatype-2643aa47', './Math-0a2ac845', './PolylinePipeline-896735cc', './VertexFormat-030f11ff', './Matrix2-e1298525', './RuntimeError-ef395448', './combine-d9581036', './WebGLConstants-0b1ce7ba', './EllipsoidGeodesic-5b3623dc', './EllipsoidRhumbLine-ef872433', './IntersectionTests-88c49b2e', './Plane-4c3d403b'], (function (defaultValue, Matrix3, ArcType, arrayRemoveDuplicates, Transforms, Color, ComponentDatatype, Check, GeometryAttribute, GeometryAttributes, IndexDatatype, Math$1, PolylinePipeline, VertexFormat, Matrix2, RuntimeError, combine, WebGLConstants, EllipsoidGeodesic, EllipsoidRhumbLine, IntersectionTests, Plane) { 'use strict';
  2. const scratchInterpolateColorsArray = [];
  3. function interpolateColors(p0, p1, color0, color1, numPoints) {
  4. const colors = scratchInterpolateColorsArray;
  5. colors.length = numPoints;
  6. let i;
  7. const r0 = color0.red;
  8. const g0 = color0.green;
  9. const b0 = color0.blue;
  10. const a0 = color0.alpha;
  11. const r1 = color1.red;
  12. const g1 = color1.green;
  13. const b1 = color1.blue;
  14. const a1 = color1.alpha;
  15. if (Color.Color.equals(color0, color1)) {
  16. for (i = 0; i < numPoints; i++) {
  17. colors[i] = Color.Color.clone(color0);
  18. }
  19. return colors;
  20. }
  21. const redPerVertex = (r1 - r0) / numPoints;
  22. const greenPerVertex = (g1 - g0) / numPoints;
  23. const bluePerVertex = (b1 - b0) / numPoints;
  24. const alphaPerVertex = (a1 - a0) / numPoints;
  25. for (i = 0; i < numPoints; i++) {
  26. colors[i] = new Color.Color(
  27. r0 + i * redPerVertex,
  28. g0 + i * greenPerVertex,
  29. b0 + i * bluePerVertex,
  30. a0 + i * alphaPerVertex
  31. );
  32. }
  33. return colors;
  34. }
  35. /**
  36. * A description of a polyline modeled as a line strip; the first two positions define a line segment,
  37. * and each additional position defines a line segment from the previous position. The polyline is capable of
  38. * displaying with a material.
  39. *
  40. * @alias PolylineGeometry
  41. * @constructor
  42. *
  43. * @param {object} options Object with the following properties:
  44. * @param {Cartesian3[]} options.positions An array of {@link Cartesian3} defining the positions in the polyline as a line strip.
  45. * @param {number} [options.width=1.0] The width in pixels.
  46. * @param {Color[]} [options.colors] An Array of {@link Color} defining the per vertex or per segment colors.
  47. * @param {boolean} [options.colorsPerVertex=false] A boolean that determines whether the colors will be flat across each segment of the line or interpolated across the vertices.
  48. * @param {ArcType} [options.arcType=ArcType.GEODESIC] The type of line the polyline segments must follow.
  49. * @param {number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude if options.arcType is not ArcType.NONE. Determines the number of positions in the buffer.
  50. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
  51. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference.
  52. *
  53. * @exception {DeveloperError} At least two positions are required.
  54. * @exception {DeveloperError} width must be greater than or equal to one.
  55. * @exception {DeveloperError} colors has an invalid length.
  56. *
  57. * @see PolylineGeometry#createGeometry
  58. *
  59. * @demo {@link https://sandcastle.cesium.com/index.html?src=Polyline.html|Cesium Sandcastle Polyline Demo}
  60. *
  61. * @example
  62. * // A polyline with two connected line segments
  63. * const polyline = new Cesium.PolylineGeometry({
  64. * positions : Cesium.Cartesian3.fromDegreesArray([
  65. * 0.0, 0.0,
  66. * 5.0, 0.0,
  67. * 5.0, 5.0
  68. * ]),
  69. * width : 10.0
  70. * });
  71. * const geometry = Cesium.PolylineGeometry.createGeometry(polyline);
  72. */
  73. function PolylineGeometry(options) {
  74. options = defaultValue.defaultValue(options, defaultValue.defaultValue.EMPTY_OBJECT);
  75. const positions = options.positions;
  76. const colors = options.colors;
  77. const width = defaultValue.defaultValue(options.width, 1.0);
  78. const colorsPerVertex = defaultValue.defaultValue(options.colorsPerVertex, false);
  79. //>>includeStart('debug', pragmas.debug);
  80. if (!defaultValue.defined(positions) || positions.length < 2) {
  81. throw new Check.DeveloperError("At least two positions are required.");
  82. }
  83. if (typeof width !== "number") {
  84. throw new Check.DeveloperError("width must be a number");
  85. }
  86. if (
  87. defaultValue.defined(colors) &&
  88. ((colorsPerVertex && colors.length < positions.length) ||
  89. (!colorsPerVertex && colors.length < positions.length - 1))
  90. ) {
  91. throw new Check.DeveloperError("colors has an invalid length.");
  92. }
  93. //>>includeEnd('debug');
  94. this._positions = positions;
  95. this._colors = colors;
  96. this._width = width;
  97. this._colorsPerVertex = colorsPerVertex;
  98. this._vertexFormat = VertexFormat.VertexFormat.clone(
  99. defaultValue.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT)
  100. );
  101. this._arcType = defaultValue.defaultValue(options.arcType, ArcType.ArcType.GEODESIC);
  102. this._granularity = defaultValue.defaultValue(
  103. options.granularity,
  104. Math$1.CesiumMath.RADIANS_PER_DEGREE
  105. );
  106. this._ellipsoid = Matrix3.Ellipsoid.clone(
  107. defaultValue.defaultValue(options.ellipsoid, Matrix3.Ellipsoid.WGS84)
  108. );
  109. this._workerName = "createPolylineGeometry";
  110. let numComponents = 1 + positions.length * Matrix3.Cartesian3.packedLength;
  111. numComponents += defaultValue.defined(colors) ? 1 + colors.length * Color.Color.packedLength : 1;
  112. /**
  113. * The number of elements used to pack the object into an array.
  114. * @type {number}
  115. */
  116. this.packedLength =
  117. numComponents + Matrix3.Ellipsoid.packedLength + VertexFormat.VertexFormat.packedLength + 4;
  118. }
  119. /**
  120. * Stores the provided instance into the provided array.
  121. *
  122. * @param {PolylineGeometry} value The value to pack.
  123. * @param {number[]} array The array to pack into.
  124. * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
  125. *
  126. * @returns {number[]} The array that was packed into
  127. */
  128. PolylineGeometry.pack = function (value, array, startingIndex) {
  129. //>>includeStart('debug', pragmas.debug);
  130. if (!defaultValue.defined(value)) {
  131. throw new Check.DeveloperError("value is required");
  132. }
  133. if (!defaultValue.defined(array)) {
  134. throw new Check.DeveloperError("array is required");
  135. }
  136. //>>includeEnd('debug');
  137. startingIndex = defaultValue.defaultValue(startingIndex, 0);
  138. let i;
  139. const positions = value._positions;
  140. let length = positions.length;
  141. array[startingIndex++] = length;
  142. for (i = 0; i < length; ++i, startingIndex += Matrix3.Cartesian3.packedLength) {
  143. Matrix3.Cartesian3.pack(positions[i], array, startingIndex);
  144. }
  145. const colors = value._colors;
  146. length = defaultValue.defined(colors) ? colors.length : 0.0;
  147. array[startingIndex++] = length;
  148. for (i = 0; i < length; ++i, startingIndex += Color.Color.packedLength) {
  149. Color.Color.pack(colors[i], array, startingIndex);
  150. }
  151. Matrix3.Ellipsoid.pack(value._ellipsoid, array, startingIndex);
  152. startingIndex += Matrix3.Ellipsoid.packedLength;
  153. VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex);
  154. startingIndex += VertexFormat.VertexFormat.packedLength;
  155. array[startingIndex++] = value._width;
  156. array[startingIndex++] = value._colorsPerVertex ? 1.0 : 0.0;
  157. array[startingIndex++] = value._arcType;
  158. array[startingIndex] = value._granularity;
  159. return array;
  160. };
  161. const scratchEllipsoid = Matrix3.Ellipsoid.clone(Matrix3.Ellipsoid.UNIT_SPHERE);
  162. const scratchVertexFormat = new VertexFormat.VertexFormat();
  163. const scratchOptions = {
  164. positions: undefined,
  165. colors: undefined,
  166. ellipsoid: scratchEllipsoid,
  167. vertexFormat: scratchVertexFormat,
  168. width: undefined,
  169. colorsPerVertex: undefined,
  170. arcType: undefined,
  171. granularity: undefined,
  172. };
  173. /**
  174. * Retrieves an instance from a packed array.
  175. *
  176. * @param {number[]} array The packed array.
  177. * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
  178. * @param {PolylineGeometry} [result] The object into which to store the result.
  179. * @returns {PolylineGeometry} The modified result parameter or a new PolylineGeometry instance if one was not provided.
  180. */
  181. PolylineGeometry.unpack = function (array, startingIndex, result) {
  182. //>>includeStart('debug', pragmas.debug);
  183. if (!defaultValue.defined(array)) {
  184. throw new Check.DeveloperError("array is required");
  185. }
  186. //>>includeEnd('debug');
  187. startingIndex = defaultValue.defaultValue(startingIndex, 0);
  188. let i;
  189. let length = array[startingIndex++];
  190. const positions = new Array(length);
  191. for (i = 0; i < length; ++i, startingIndex += Matrix3.Cartesian3.packedLength) {
  192. positions[i] = Matrix3.Cartesian3.unpack(array, startingIndex);
  193. }
  194. length = array[startingIndex++];
  195. const colors = length > 0 ? new Array(length) : undefined;
  196. for (i = 0; i < length; ++i, startingIndex += Color.Color.packedLength) {
  197. colors[i] = Color.Color.unpack(array, startingIndex);
  198. }
  199. const ellipsoid = Matrix3.Ellipsoid.unpack(array, startingIndex, scratchEllipsoid);
  200. startingIndex += Matrix3.Ellipsoid.packedLength;
  201. const vertexFormat = VertexFormat.VertexFormat.unpack(
  202. array,
  203. startingIndex,
  204. scratchVertexFormat
  205. );
  206. startingIndex += VertexFormat.VertexFormat.packedLength;
  207. const width = array[startingIndex++];
  208. const colorsPerVertex = array[startingIndex++] === 1.0;
  209. const arcType = array[startingIndex++];
  210. const granularity = array[startingIndex];
  211. if (!defaultValue.defined(result)) {
  212. scratchOptions.positions = positions;
  213. scratchOptions.colors = colors;
  214. scratchOptions.width = width;
  215. scratchOptions.colorsPerVertex = colorsPerVertex;
  216. scratchOptions.arcType = arcType;
  217. scratchOptions.granularity = granularity;
  218. return new PolylineGeometry(scratchOptions);
  219. }
  220. result._positions = positions;
  221. result._colors = colors;
  222. result._ellipsoid = Matrix3.Ellipsoid.clone(ellipsoid, result._ellipsoid);
  223. result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
  224. result._width = width;
  225. result._colorsPerVertex = colorsPerVertex;
  226. result._arcType = arcType;
  227. result._granularity = granularity;
  228. return result;
  229. };
  230. const scratchCartesian3 = new Matrix3.Cartesian3();
  231. const scratchPosition = new Matrix3.Cartesian3();
  232. const scratchPrevPosition = new Matrix3.Cartesian3();
  233. const scratchNextPosition = new Matrix3.Cartesian3();
  234. /**
  235. * Computes the geometric representation of a polyline, including its vertices, indices, and a bounding sphere.
  236. *
  237. * @param {PolylineGeometry} polylineGeometry A description of the polyline.
  238. * @returns {Geometry|undefined} The computed vertices and indices.
  239. */
  240. PolylineGeometry.createGeometry = function (polylineGeometry) {
  241. const width = polylineGeometry._width;
  242. const vertexFormat = polylineGeometry._vertexFormat;
  243. let colors = polylineGeometry._colors;
  244. const colorsPerVertex = polylineGeometry._colorsPerVertex;
  245. const arcType = polylineGeometry._arcType;
  246. const granularity = polylineGeometry._granularity;
  247. const ellipsoid = polylineGeometry._ellipsoid;
  248. let i;
  249. let j;
  250. let k;
  251. const removedIndices = [];
  252. let positions = arrayRemoveDuplicates.arrayRemoveDuplicates(
  253. polylineGeometry._positions,
  254. Matrix3.Cartesian3.equalsEpsilon,
  255. false,
  256. removedIndices
  257. );
  258. if (defaultValue.defined(colors) && removedIndices.length > 0) {
  259. let removedArrayIndex = 0;
  260. let nextRemovedIndex = removedIndices[0];
  261. colors = colors.filter(function (color, index) {
  262. let remove = false;
  263. if (colorsPerVertex) {
  264. remove =
  265. index === nextRemovedIndex || (index === 0 && nextRemovedIndex === 1);
  266. } else {
  267. remove = index + 1 === nextRemovedIndex;
  268. }
  269. if (remove) {
  270. removedArrayIndex++;
  271. nextRemovedIndex = removedIndices[removedArrayIndex];
  272. return false;
  273. }
  274. return true;
  275. });
  276. }
  277. let positionsLength = positions.length;
  278. // A width of a pixel or less is not a valid geometry, but in order to support external data
  279. // that may have errors we treat this as an empty geometry.
  280. if (positionsLength < 2 || width <= 0.0) {
  281. return undefined;
  282. }
  283. if (arcType === ArcType.ArcType.GEODESIC || arcType === ArcType.ArcType.RHUMB) {
  284. let subdivisionSize;
  285. let numberOfPointsFunction;
  286. if (arcType === ArcType.ArcType.GEODESIC) {
  287. subdivisionSize = Math$1.CesiumMath.chordLength(
  288. granularity,
  289. ellipsoid.maximumRadius
  290. );
  291. numberOfPointsFunction = PolylinePipeline.PolylinePipeline.numberOfPoints;
  292. } else {
  293. subdivisionSize = granularity;
  294. numberOfPointsFunction = PolylinePipeline.PolylinePipeline.numberOfPointsRhumbLine;
  295. }
  296. const heights = PolylinePipeline.PolylinePipeline.extractHeights(positions, ellipsoid);
  297. if (defaultValue.defined(colors)) {
  298. let colorLength = 1;
  299. for (i = 0; i < positionsLength - 1; ++i) {
  300. colorLength += numberOfPointsFunction(
  301. positions[i],
  302. positions[i + 1],
  303. subdivisionSize
  304. );
  305. }
  306. const newColors = new Array(colorLength);
  307. let newColorIndex = 0;
  308. for (i = 0; i < positionsLength - 1; ++i) {
  309. const p0 = positions[i];
  310. const p1 = positions[i + 1];
  311. const c0 = colors[i];
  312. const numColors = numberOfPointsFunction(p0, p1, subdivisionSize);
  313. if (colorsPerVertex && i < colorLength) {
  314. const c1 = colors[i + 1];
  315. const interpolatedColors = interpolateColors(
  316. p0,
  317. p1,
  318. c0,
  319. c1,
  320. numColors
  321. );
  322. const interpolatedColorsLength = interpolatedColors.length;
  323. for (j = 0; j < interpolatedColorsLength; ++j) {
  324. newColors[newColorIndex++] = interpolatedColors[j];
  325. }
  326. } else {
  327. for (j = 0; j < numColors; ++j) {
  328. newColors[newColorIndex++] = Color.Color.clone(c0);
  329. }
  330. }
  331. }
  332. newColors[newColorIndex] = Color.Color.clone(colors[colors.length - 1]);
  333. colors = newColors;
  334. scratchInterpolateColorsArray.length = 0;
  335. }
  336. if (arcType === ArcType.ArcType.GEODESIC) {
  337. positions = PolylinePipeline.PolylinePipeline.generateCartesianArc({
  338. positions: positions,
  339. minDistance: subdivisionSize,
  340. ellipsoid: ellipsoid,
  341. height: heights,
  342. });
  343. } else {
  344. positions = PolylinePipeline.PolylinePipeline.generateCartesianRhumbArc({
  345. positions: positions,
  346. granularity: subdivisionSize,
  347. ellipsoid: ellipsoid,
  348. height: heights,
  349. });
  350. }
  351. }
  352. positionsLength = positions.length;
  353. const size = positionsLength * 4.0 - 4.0;
  354. const finalPositions = new Float64Array(size * 3);
  355. const prevPositions = new Float64Array(size * 3);
  356. const nextPositions = new Float64Array(size * 3);
  357. const expandAndWidth = new Float32Array(size * 2);
  358. const st = vertexFormat.st ? new Float32Array(size * 2) : undefined;
  359. const finalColors = defaultValue.defined(colors) ? new Uint8Array(size * 4) : undefined;
  360. let positionIndex = 0;
  361. let expandAndWidthIndex = 0;
  362. let stIndex = 0;
  363. let colorIndex = 0;
  364. let position;
  365. for (j = 0; j < positionsLength; ++j) {
  366. if (j === 0) {
  367. position = scratchCartesian3;
  368. Matrix3.Cartesian3.subtract(positions[0], positions[1], position);
  369. Matrix3.Cartesian3.add(positions[0], position, position);
  370. } else {
  371. position = positions[j - 1];
  372. }
  373. Matrix3.Cartesian3.clone(position, scratchPrevPosition);
  374. Matrix3.Cartesian3.clone(positions[j], scratchPosition);
  375. if (j === positionsLength - 1) {
  376. position = scratchCartesian3;
  377. Matrix3.Cartesian3.subtract(
  378. positions[positionsLength - 1],
  379. positions[positionsLength - 2],
  380. position
  381. );
  382. Matrix3.Cartesian3.add(positions[positionsLength - 1], position, position);
  383. } else {
  384. position = positions[j + 1];
  385. }
  386. Matrix3.Cartesian3.clone(position, scratchNextPosition);
  387. let color0, color1;
  388. if (defaultValue.defined(finalColors)) {
  389. if (j !== 0 && !colorsPerVertex) {
  390. color0 = colors[j - 1];
  391. } else {
  392. color0 = colors[j];
  393. }
  394. if (j !== positionsLength - 1) {
  395. color1 = colors[j];
  396. }
  397. }
  398. const startK = j === 0 ? 2 : 0;
  399. const endK = j === positionsLength - 1 ? 2 : 4;
  400. for (k = startK; k < endK; ++k) {
  401. Matrix3.Cartesian3.pack(scratchPosition, finalPositions, positionIndex);
  402. Matrix3.Cartesian3.pack(scratchPrevPosition, prevPositions, positionIndex);
  403. Matrix3.Cartesian3.pack(scratchNextPosition, nextPositions, positionIndex);
  404. positionIndex += 3;
  405. const direction = k - 2 < 0 ? -1.0 : 1.0;
  406. expandAndWidth[expandAndWidthIndex++] = 2 * (k % 2) - 1; // expand direction
  407. expandAndWidth[expandAndWidthIndex++] = direction * width;
  408. if (vertexFormat.st) {
  409. st[stIndex++] = j / (positionsLength - 1);
  410. st[stIndex++] = Math.max(expandAndWidth[expandAndWidthIndex - 2], 0.0);
  411. }
  412. if (defaultValue.defined(finalColors)) {
  413. const color = k < 2 ? color0 : color1;
  414. finalColors[colorIndex++] = Color.Color.floatToByte(color.red);
  415. finalColors[colorIndex++] = Color.Color.floatToByte(color.green);
  416. finalColors[colorIndex++] = Color.Color.floatToByte(color.blue);
  417. finalColors[colorIndex++] = Color.Color.floatToByte(color.alpha);
  418. }
  419. }
  420. }
  421. const attributes = new GeometryAttributes.GeometryAttributes();
  422. attributes.position = new GeometryAttribute.GeometryAttribute({
  423. componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,
  424. componentsPerAttribute: 3,
  425. values: finalPositions,
  426. });
  427. attributes.prevPosition = new GeometryAttribute.GeometryAttribute({
  428. componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,
  429. componentsPerAttribute: 3,
  430. values: prevPositions,
  431. });
  432. attributes.nextPosition = new GeometryAttribute.GeometryAttribute({
  433. componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,
  434. componentsPerAttribute: 3,
  435. values: nextPositions,
  436. });
  437. attributes.expandAndWidth = new GeometryAttribute.GeometryAttribute({
  438. componentDatatype: ComponentDatatype.ComponentDatatype.FLOAT,
  439. componentsPerAttribute: 2,
  440. values: expandAndWidth,
  441. });
  442. if (vertexFormat.st) {
  443. attributes.st = new GeometryAttribute.GeometryAttribute({
  444. componentDatatype: ComponentDatatype.ComponentDatatype.FLOAT,
  445. componentsPerAttribute: 2,
  446. values: st,
  447. });
  448. }
  449. if (defaultValue.defined(finalColors)) {
  450. attributes.color = new GeometryAttribute.GeometryAttribute({
  451. componentDatatype: ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
  452. componentsPerAttribute: 4,
  453. values: finalColors,
  454. normalize: true,
  455. });
  456. }
  457. const indices = IndexDatatype.IndexDatatype.createTypedArray(size, positionsLength * 6 - 6);
  458. let index = 0;
  459. let indicesIndex = 0;
  460. const length = positionsLength - 1.0;
  461. for (j = 0; j < length; ++j) {
  462. indices[indicesIndex++] = index;
  463. indices[indicesIndex++] = index + 2;
  464. indices[indicesIndex++] = index + 1;
  465. indices[indicesIndex++] = index + 1;
  466. indices[indicesIndex++] = index + 2;
  467. indices[indicesIndex++] = index + 3;
  468. index += 4;
  469. }
  470. return new GeometryAttribute.Geometry({
  471. attributes: attributes,
  472. indices: indices,
  473. primitiveType: GeometryAttribute.PrimitiveType.TRIANGLES,
  474. boundingSphere: Transforms.BoundingSphere.fromPoints(positions),
  475. geometryType: GeometryAttribute.GeometryType.POLYLINES,
  476. });
  477. };
  478. function createPolylineGeometry(polylineGeometry, offset) {
  479. if (defaultValue.defined(offset)) {
  480. polylineGeometry = PolylineGeometry.unpack(polylineGeometry, offset);
  481. }
  482. polylineGeometry._ellipsoid = Matrix3.Ellipsoid.clone(polylineGeometry._ellipsoid);
  483. return PolylineGeometry.createGeometry(polylineGeometry);
  484. }
  485. return createPolylineGeometry;
  486. }));