createWallGeometry.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. /* This file is automatically rebuilt by the Cesium build process. */
  2. define(['./defined-26bd4a03', './Check-da037458', './freezeObject-2d83f591', './defaultValue-f2e68450', './Math-fa6e45cb', './Cartesian2-2a723276', './defineProperties-6f7a50f2', './Transforms-65aba0a4', './RuntimeError-ad75c885', './WebGLConstants-497deb20', './ComponentDatatype-69643096', './GeometryAttribute-ed359d71', './when-ee12a2cb', './GeometryAttributes-eecc9f43', './IndexDatatype-3de60176', './IntersectionTests-c2360ffa', './Plane-a1a3fd52', './VertexFormat-fbb91dc7', './EllipsoidTangentPlane-10c6053a', './EllipsoidRhumbLine-c6cdbfd3', './PolygonPipeline-e486c11c', './EllipsoidGeodesic-53e988a6', './PolylinePipeline-b4161aaf', './WallGeometryLibrary-f30761f4'], function (defined, Check, freezeObject, defaultValue, _Math, Cartesian2, defineProperties, Transforms, RuntimeError, WebGLConstants, ComponentDatatype, GeometryAttribute, when, GeometryAttributes, IndexDatatype, IntersectionTests, Plane, VertexFormat, EllipsoidTangentPlane, EllipsoidRhumbLine, PolygonPipeline, EllipsoidGeodesic, PolylinePipeline, WallGeometryLibrary) { 'use strict';
  3. var scratchCartesian3Position1 = new Cartesian2.Cartesian3();
  4. var scratchCartesian3Position2 = new Cartesian2.Cartesian3();
  5. var scratchCartesian3Position3 = new Cartesian2.Cartesian3();
  6. var scratchCartesian3Position4 = new Cartesian2.Cartesian3();
  7. var scratchCartesian3Position5 = new Cartesian2.Cartesian3();
  8. var scratchBitangent = new Cartesian2.Cartesian3();
  9. var scratchTangent = new Cartesian2.Cartesian3();
  10. var scratchNormal = new Cartesian2.Cartesian3();
  11. /**
  12. * A description of a wall, which is similar to a KML line string. A wall is defined by a series of points,
  13. * which extrude down to the ground. Optionally, they can extrude downwards to a specified height.
  14. *
  15. * @alias WallGeometry
  16. * @constructor
  17. *
  18. * @param {Object} options Object with the following properties:
  19. * @param {Cartesian3[]} options.positions An array of Cartesian objects, which are the points of the wall.
  20. * @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.
  21. * @param {Number[]} [options.maximumHeights] An array parallel to <code>positions</code> that give the maximum height of the
  22. * wall at <code>positions</code>. If undefined, the height of each position in used.
  23. * @param {Number[]} [options.minimumHeights] An array parallel to <code>positions</code> that give the minimum height of the
  24. * wall at <code>positions</code>. If undefined, the height at each position is 0.0.
  25. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid for coordinate manipulation
  26. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
  27. *
  28. * @exception {DeveloperError} positions length must be greater than or equal to 2.
  29. * @exception {DeveloperError} positions and maximumHeights must have the same length.
  30. * @exception {DeveloperError} positions and minimumHeights must have the same length.
  31. *
  32. * @see WallGeometry#createGeometry
  33. * @see WallGeometry#fromConstantHeight
  34. *
  35. * @demo {@link https://sandcastle.cesium.com/index.html?src=Wall.html|Cesium Sandcastle Wall Demo}
  36. *
  37. * @example
  38. * // create a wall that spans from ground level to 10000 meters
  39. * var wall = new Cesium.WallGeometry({
  40. * positions : Cesium.Cartesian3.fromDegreesArrayHeights([
  41. * 19.0, 47.0, 10000.0,
  42. * 19.0, 48.0, 10000.0,
  43. * 20.0, 48.0, 10000.0,
  44. * 20.0, 47.0, 10000.0,
  45. * 19.0, 47.0, 10000.0
  46. * ])
  47. * });
  48. * var geometry = Cesium.WallGeometry.createGeometry(wall);
  49. */
  50. function WallGeometry(options) {
  51. options = defaultValue.defaultValue(options, defaultValue.defaultValue.EMPTY_OBJECT);
  52. var wallPositions = options.positions;
  53. var maximumHeights = options.maximumHeights;
  54. var minimumHeights = options.minimumHeights;
  55. //>>includeStart('debug', pragmas.debug);
  56. if (!defined.defined(wallPositions)) {
  57. throw new Check.DeveloperError('options.positions is required.');
  58. }
  59. if (defined.defined(maximumHeights) && maximumHeights.length !== wallPositions.length) {
  60. throw new Check.DeveloperError('options.positions and options.maximumHeights must have the same length.');
  61. }
  62. if (defined.defined(minimumHeights) && minimumHeights.length !== wallPositions.length) {
  63. throw new Check.DeveloperError('options.positions and options.minimumHeights must have the same length.');
  64. }
  65. //>>includeEnd('debug');
  66. var vertexFormat = defaultValue.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
  67. var granularity = defaultValue.defaultValue(options.granularity, _Math.CesiumMath.RADIANS_PER_DEGREE);
  68. var ellipsoid = defaultValue.defaultValue(options.ellipsoid, Cartesian2.Ellipsoid.WGS84);
  69. this._positions = wallPositions;
  70. this._minimumHeights = minimumHeights;
  71. this._maximumHeights = maximumHeights;
  72. this._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat);
  73. this._granularity = granularity;
  74. this._ellipsoid = Cartesian2.Ellipsoid.clone(ellipsoid);
  75. this._workerName = 'createWallGeometry';
  76. var numComponents = 1 + wallPositions.length * Cartesian2.Cartesian3.packedLength + 2;
  77. if (defined.defined(minimumHeights)) {
  78. numComponents += minimumHeights.length;
  79. }
  80. if (defined.defined(maximumHeights)) {
  81. numComponents += maximumHeights.length;
  82. }
  83. /**
  84. * The number of elements used to pack the object into an array.
  85. * @type {Number}
  86. */
  87. this.packedLength = numComponents + Cartesian2.Ellipsoid.packedLength + VertexFormat.VertexFormat.packedLength + 1;
  88. }
  89. /**
  90. * Stores the provided instance into the provided array.
  91. *
  92. * @param {WallGeometry} value The value to pack.
  93. * @param {Number[]} array The array to pack into.
  94. * @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
  95. *
  96. * @returns {Number[]} The array that was packed into
  97. */
  98. WallGeometry.pack = function(value, array, startingIndex) {
  99. //>>includeStart('debug', pragmas.debug);
  100. if (!defined.defined(value)) {
  101. throw new Check.DeveloperError('value is required');
  102. }
  103. if (!defined.defined(array)) {
  104. throw new Check.DeveloperError('array is required');
  105. }
  106. //>>includeEnd('debug');
  107. startingIndex = defaultValue.defaultValue(startingIndex, 0);
  108. var i;
  109. var positions = value._positions;
  110. var length = positions.length;
  111. array[startingIndex++] = length;
  112. for (i = 0; i < length; ++i, startingIndex += Cartesian2.Cartesian3.packedLength) {
  113. Cartesian2.Cartesian3.pack(positions[i], array, startingIndex);
  114. }
  115. var minimumHeights = value._minimumHeights;
  116. length = defined.defined(minimumHeights) ? minimumHeights.length : 0;
  117. array[startingIndex++] = length;
  118. if (defined.defined(minimumHeights)) {
  119. for (i = 0; i < length; ++i) {
  120. array[startingIndex++] = minimumHeights[i];
  121. }
  122. }
  123. var maximumHeights = value._maximumHeights;
  124. length = defined.defined(maximumHeights) ? maximumHeights.length : 0;
  125. array[startingIndex++] = length;
  126. if (defined.defined(maximumHeights)) {
  127. for (i = 0; i < length; ++i) {
  128. array[startingIndex++] = maximumHeights[i];
  129. }
  130. }
  131. Cartesian2.Ellipsoid.pack(value._ellipsoid, array, startingIndex);
  132. startingIndex += Cartesian2.Ellipsoid.packedLength;
  133. VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex);
  134. startingIndex += VertexFormat.VertexFormat.packedLength;
  135. array[startingIndex] = value._granularity;
  136. return array;
  137. };
  138. var scratchEllipsoid = Cartesian2.Ellipsoid.clone(Cartesian2.Ellipsoid.UNIT_SPHERE);
  139. var scratchVertexFormat = new VertexFormat.VertexFormat();
  140. var scratchOptions = {
  141. positions : undefined,
  142. minimumHeights : undefined,
  143. maximumHeights : undefined,
  144. ellipsoid : scratchEllipsoid,
  145. vertexFormat : scratchVertexFormat,
  146. granularity : undefined
  147. };
  148. /**
  149. * Retrieves an instance from a packed array.
  150. *
  151. * @param {Number[]} array The packed array.
  152. * @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
  153. * @param {WallGeometry} [result] The object into which to store the result.
  154. * @returns {WallGeometry} The modified result parameter or a new WallGeometry instance if one was not provided.
  155. */
  156. WallGeometry.unpack = function(array, startingIndex, result) {
  157. //>>includeStart('debug', pragmas.debug);
  158. if (!defined.defined(array)) {
  159. throw new Check.DeveloperError('array is required');
  160. }
  161. //>>includeEnd('debug');
  162. startingIndex = defaultValue.defaultValue(startingIndex, 0);
  163. var i;
  164. var length = array[startingIndex++];
  165. var positions = new Array(length);
  166. for (i = 0; i < length; ++i, startingIndex += Cartesian2.Cartesian3.packedLength) {
  167. positions[i] = Cartesian2.Cartesian3.unpack(array, startingIndex);
  168. }
  169. length = array[startingIndex++];
  170. var minimumHeights;
  171. if (length > 0) {
  172. minimumHeights = new Array(length);
  173. for (i = 0; i < length; ++i) {
  174. minimumHeights[i] = array[startingIndex++];
  175. }
  176. }
  177. length = array[startingIndex++];
  178. var maximumHeights;
  179. if (length > 0) {
  180. maximumHeights = new Array(length);
  181. for (i = 0; i < length; ++i) {
  182. maximumHeights[i] = array[startingIndex++];
  183. }
  184. }
  185. var ellipsoid = Cartesian2.Ellipsoid.unpack(array, startingIndex, scratchEllipsoid);
  186. startingIndex += Cartesian2.Ellipsoid.packedLength;
  187. var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex, scratchVertexFormat);
  188. startingIndex += VertexFormat.VertexFormat.packedLength;
  189. var granularity = array[startingIndex];
  190. if (!defined.defined(result)) {
  191. scratchOptions.positions = positions;
  192. scratchOptions.minimumHeights = minimumHeights;
  193. scratchOptions.maximumHeights = maximumHeights;
  194. scratchOptions.granularity = granularity;
  195. return new WallGeometry(scratchOptions);
  196. }
  197. result._positions = positions;
  198. result._minimumHeights = minimumHeights;
  199. result._maximumHeights = maximumHeights;
  200. result._ellipsoid = Cartesian2.Ellipsoid.clone(ellipsoid, result._ellipsoid);
  201. result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
  202. result._granularity = granularity;
  203. return result;
  204. };
  205. /**
  206. * A description of a wall, which is similar to a KML line string. A wall is defined by a series of points,
  207. * which extrude down to the ground. Optionally, they can extrude downwards to a specified height.
  208. *
  209. * @param {Object} options Object with the following properties:
  210. * @param {Cartesian3[]} options.positions An array of Cartesian objects, which are the points of the wall.
  211. * @param {Number} [options.maximumHeight] A constant that defines the maximum height of the
  212. * wall at <code>positions</code>. If undefined, the height of each position in used.
  213. * @param {Number} [options.minimumHeight] A constant that defines the minimum height of the
  214. * wall at <code>positions</code>. If undefined, the height at each position is 0.0.
  215. * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid for coordinate manipulation
  216. * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
  217. * @returns {WallGeometry}
  218. *
  219. *
  220. * @example
  221. * // create a wall that spans from 10000 meters to 20000 meters
  222. * var wall = Cesium.WallGeometry.fromConstantHeights({
  223. * positions : Cesium.Cartesian3.fromDegreesArray([
  224. * 19.0, 47.0,
  225. * 19.0, 48.0,
  226. * 20.0, 48.0,
  227. * 20.0, 47.0,
  228. * 19.0, 47.0,
  229. * ]),
  230. * minimumHeight : 20000.0,
  231. * maximumHeight : 10000.0
  232. * });
  233. * var geometry = Cesium.WallGeometry.createGeometry(wall);
  234. *
  235. * @see WallGeometry#createGeometry
  236. */
  237. WallGeometry.fromConstantHeights = function(options) {
  238. options = defaultValue.defaultValue(options, defaultValue.defaultValue.EMPTY_OBJECT);
  239. var positions = options.positions;
  240. //>>includeStart('debug', pragmas.debug);
  241. if (!defined.defined(positions)) {
  242. throw new Check.DeveloperError('options.positions is required.');
  243. }
  244. //>>includeEnd('debug');
  245. var minHeights;
  246. var maxHeights;
  247. var min = options.minimumHeight;
  248. var max = options.maximumHeight;
  249. var doMin = defined.defined(min);
  250. var doMax = defined.defined(max);
  251. if (doMin || doMax) {
  252. var length = positions.length;
  253. minHeights = (doMin) ? new Array(length) : undefined;
  254. maxHeights = (doMax) ? new Array(length) : undefined;
  255. for (var i = 0; i < length; ++i) {
  256. if (doMin) {
  257. minHeights[i] = min;
  258. }
  259. if (doMax) {
  260. maxHeights[i] = max;
  261. }
  262. }
  263. }
  264. var newOptions = {
  265. positions : positions,
  266. maximumHeights : maxHeights,
  267. minimumHeights : minHeights,
  268. ellipsoid : options.ellipsoid,
  269. vertexFormat : options.vertexFormat
  270. };
  271. return new WallGeometry(newOptions);
  272. };
  273. /**
  274. * Computes the geometric representation of a wall, including its vertices, indices, and a bounding sphere.
  275. *
  276. * @param {WallGeometry} wallGeometry A description of the wall.
  277. * @returns {Geometry|undefined} The computed vertices and indices.
  278. */
  279. WallGeometry.createGeometry = function(wallGeometry) {
  280. var wallPositions = wallGeometry._positions;
  281. var minimumHeights = wallGeometry._minimumHeights;
  282. var maximumHeights = wallGeometry._maximumHeights;
  283. var vertexFormat = wallGeometry._vertexFormat;
  284. var granularity = wallGeometry._granularity;
  285. var ellipsoid = wallGeometry._ellipsoid;
  286. var pos = WallGeometryLibrary.WallGeometryLibrary.computePositions(ellipsoid, wallPositions, maximumHeights, minimumHeights, granularity, true);
  287. if (!defined.defined(pos)) {
  288. return;
  289. }
  290. var bottomPositions = pos.bottomPositions;
  291. var topPositions = pos.topPositions;
  292. var numCorners = pos.numCorners;
  293. var length = topPositions.length;
  294. var size = length * 2;
  295. var positions = vertexFormat.position ? new Float64Array(size) : undefined;
  296. var normals = vertexFormat.normal ? new Float32Array(size) : undefined;
  297. var tangents = vertexFormat.tangent ? new Float32Array(size) : undefined;
  298. var bitangents = vertexFormat.bitangent ? new Float32Array(size) : undefined;
  299. var textureCoordinates = vertexFormat.st ? new Float32Array(size / 3 * 2) : undefined;
  300. var positionIndex = 0;
  301. var normalIndex = 0;
  302. var bitangentIndex = 0;
  303. var tangentIndex = 0;
  304. var stIndex = 0;
  305. // add lower and upper points one after the other, lower
  306. // points being even and upper points being odd
  307. var normal = scratchNormal;
  308. var tangent = scratchTangent;
  309. var bitangent = scratchBitangent;
  310. var recomputeNormal = true;
  311. length /= 3;
  312. var i;
  313. var s = 0;
  314. var ds = 1/(length - wallPositions.length + 1);
  315. for (i = 0; i < length; ++i) {
  316. var i3 = i * 3;
  317. var topPosition = Cartesian2.Cartesian3.fromArray(topPositions, i3, scratchCartesian3Position1);
  318. var bottomPosition = Cartesian2.Cartesian3.fromArray(bottomPositions, i3, scratchCartesian3Position2);
  319. if (vertexFormat.position) {
  320. // insert the lower point
  321. positions[positionIndex++] = bottomPosition.x;
  322. positions[positionIndex++] = bottomPosition.y;
  323. positions[positionIndex++] = bottomPosition.z;
  324. // insert the upper point
  325. positions[positionIndex++] = topPosition.x;
  326. positions[positionIndex++] = topPosition.y;
  327. positions[positionIndex++] = topPosition.z;
  328. }
  329. if (vertexFormat.st) {
  330. textureCoordinates[stIndex++] = s;
  331. textureCoordinates[stIndex++] = 0.0;
  332. textureCoordinates[stIndex++] = s;
  333. textureCoordinates[stIndex++] = 1.0;
  334. }
  335. if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
  336. var nextPosition;
  337. var nextTop = Cartesian2.Cartesian3.clone(Cartesian2.Cartesian3.ZERO, scratchCartesian3Position5);
  338. var groundPosition = ellipsoid.scaleToGeodeticSurface(Cartesian2.Cartesian3.fromArray(topPositions, i3, scratchCartesian3Position2), scratchCartesian3Position2);
  339. if (i + 1 < length) {
  340. nextPosition = ellipsoid.scaleToGeodeticSurface(Cartesian2.Cartesian3.fromArray(topPositions, i3 + 3, scratchCartesian3Position3), scratchCartesian3Position3);
  341. nextTop = Cartesian2.Cartesian3.fromArray(topPositions, i3 + 3, scratchCartesian3Position5);
  342. }
  343. if (recomputeNormal) {
  344. var scalednextPosition = Cartesian2.Cartesian3.subtract(nextTop, topPosition, scratchCartesian3Position4);
  345. var scaledGroundPosition = Cartesian2.Cartesian3.subtract(groundPosition, topPosition, scratchCartesian3Position1);
  346. normal = Cartesian2.Cartesian3.normalize(Cartesian2.Cartesian3.cross(scaledGroundPosition, scalednextPosition, normal), normal);
  347. recomputeNormal = false;
  348. }
  349. if (Cartesian2.Cartesian3.equalsEpsilon(nextPosition, groundPosition, _Math.CesiumMath.EPSILON10)) {
  350. recomputeNormal = true;
  351. } else {
  352. s += ds;
  353. if (vertexFormat.tangent) {
  354. tangent = Cartesian2.Cartesian3.normalize(Cartesian2.Cartesian3.subtract(nextPosition, groundPosition, tangent), tangent);
  355. }
  356. if (vertexFormat.bitangent) {
  357. bitangent = Cartesian2.Cartesian3.normalize(Cartesian2.Cartesian3.cross(normal, tangent, bitangent), bitangent);
  358. }
  359. }
  360. if (vertexFormat.normal) {
  361. normals[normalIndex++] = normal.x;
  362. normals[normalIndex++] = normal.y;
  363. normals[normalIndex++] = normal.z;
  364. normals[normalIndex++] = normal.x;
  365. normals[normalIndex++] = normal.y;
  366. normals[normalIndex++] = normal.z;
  367. }
  368. if (vertexFormat.tangent) {
  369. tangents[tangentIndex++] = tangent.x;
  370. tangents[tangentIndex++] = tangent.y;
  371. tangents[tangentIndex++] = tangent.z;
  372. tangents[tangentIndex++] = tangent.x;
  373. tangents[tangentIndex++] = tangent.y;
  374. tangents[tangentIndex++] = tangent.z;
  375. }
  376. if (vertexFormat.bitangent) {
  377. bitangents[bitangentIndex++] = bitangent.x;
  378. bitangents[bitangentIndex++] = bitangent.y;
  379. bitangents[bitangentIndex++] = bitangent.z;
  380. bitangents[bitangentIndex++] = bitangent.x;
  381. bitangents[bitangentIndex++] = bitangent.y;
  382. bitangents[bitangentIndex++] = bitangent.z;
  383. }
  384. }
  385. }
  386. var attributes = new GeometryAttributes.GeometryAttributes();
  387. if (vertexFormat.position) {
  388. attributes.position = new GeometryAttribute.GeometryAttribute({
  389. componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
  390. componentsPerAttribute : 3,
  391. values : positions
  392. });
  393. }
  394. if (vertexFormat.normal) {
  395. attributes.normal = new GeometryAttribute.GeometryAttribute({
  396. componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
  397. componentsPerAttribute : 3,
  398. values : normals
  399. });
  400. }
  401. if (vertexFormat.tangent) {
  402. attributes.tangent = new GeometryAttribute.GeometryAttribute({
  403. componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
  404. componentsPerAttribute : 3,
  405. values : tangents
  406. });
  407. }
  408. if (vertexFormat.bitangent) {
  409. attributes.bitangent = new GeometryAttribute.GeometryAttribute({
  410. componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
  411. componentsPerAttribute : 3,
  412. values : bitangents
  413. });
  414. }
  415. if (vertexFormat.st) {
  416. attributes.st = new GeometryAttribute.GeometryAttribute({
  417. componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
  418. componentsPerAttribute : 2,
  419. values : textureCoordinates
  420. });
  421. }
  422. // prepare the side walls, two triangles for each wall
  423. //
  424. // A (i+1) B (i+3) E
  425. // +--------+-------+
  426. // | / | /| triangles: A C B
  427. // | / | / | B C D
  428. // | / | / |
  429. // | / | / |
  430. // | / | / |
  431. // | / | / |
  432. // +--------+-------+
  433. // C (i) D (i+2) F
  434. //
  435. var numVertices = size / 3;
  436. size -= 6 * (numCorners + 1);
  437. var indices = IndexDatatype.IndexDatatype.createTypedArray(numVertices, size);
  438. var edgeIndex = 0;
  439. for (i = 0; i < numVertices - 2; i += 2) {
  440. var LL = i;
  441. var LR = i + 2;
  442. var pl = Cartesian2.Cartesian3.fromArray(positions, LL * 3, scratchCartesian3Position1);
  443. var pr = Cartesian2.Cartesian3.fromArray(positions, LR * 3, scratchCartesian3Position2);
  444. if (Cartesian2.Cartesian3.equalsEpsilon(pl, pr, _Math.CesiumMath.EPSILON10)) {
  445. continue;
  446. }
  447. var UL = i + 1;
  448. var UR = i + 3;
  449. indices[edgeIndex++] = UL;
  450. indices[edgeIndex++] = LL;
  451. indices[edgeIndex++] = UR;
  452. indices[edgeIndex++] = UR;
  453. indices[edgeIndex++] = LL;
  454. indices[edgeIndex++] = LR;
  455. }
  456. return new GeometryAttribute.Geometry({
  457. attributes : attributes,
  458. indices : indices,
  459. primitiveType : GeometryAttribute.PrimitiveType.TRIANGLES,
  460. boundingSphere : new Transforms.BoundingSphere.fromVertices(positions)
  461. });
  462. };
  463. function createWallGeometry(wallGeometry, offset) {
  464. if (defined.defined(offset)) {
  465. wallGeometry = WallGeometry.unpack(wallGeometry, offset);
  466. }
  467. wallGeometry._ellipsoid = Cartesian2.Ellipsoid.clone(wallGeometry._ellipsoid);
  468. return WallGeometry.createGeometry(wallGeometry);
  469. }
  470. return createWallGeometry;
  471. });