Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | 1x 1x 1x 1x 198x 196x 194x 194x 194x 774x 774x 774x 194x 1x 194x 192x 1x 105x 104x 104x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 70x 70x 70x 69x 68x 67x 66x 65x 64x 64x 64x 64x 64x 64x 64x 285x 285x 285x 285x 285x 9x 9x 9x 64x 64x 64x 64x 64x 64x 364063x 364063x 364063x 364063x 364063x 364063x 364063x 7x 7x 7x 364063x 364063x 364063x 364063x 364063x 364063x 364063x 364063x 181946x 2120x 2120x 2120x 1131x 1131x 1131x 1131x 1131x 1131x 1x 1x 1x 2120x 2120x 179826x 89874x 89874x 89874x 66751x 66751x 66751x 66751x 66751x 66751x 89874x 89874x 89952x 89952x 89952x 89952x 24282x 24282x 24282x 24282x 24282x 24282x 89952x 89952x 182117x 182117x 182117x 64x 64x 2x 64x 1x 1x 1x 1x 1x 14x 14x 14x 13x 12x 11x 10x 9x 8x 8x 8x 8x 8x 8x 8x 34x 34x 34x 34x 34x 5x 5x 5x 8x 8x 8x 8x 8x 8x 8x 8x 33010x 33010x 33010x 33010x 33010x 33010x 33010x 5x 5x 5x 33010x 33010x 33010x 33010x 33010x 33010x 33010x 33010x 33010x 33010x 33010x 16495x 5x 5x 5x 4x 4x 4x 4x 4x 4x 4x 1x 1x 1x 5x 5x 16490x 8241x 8241x 8241x 6243x 6243x 6243x 6243x 6243x 6243x 6243x 8241x 8241x 8249x 8249x 8249x 8249x 2148x 2148x 2148x 2148x 2148x 2148x 2148x 8249x 8249x 16515x 16515x 16515x 8x 8x 1x 8x 1x 559x 559x 559x 559x 559x 559x 559x 559x 530258x 530258x 41691x 530258x 25266x 25266x 25266x 530258x 530258x 530258x 559x | import earcut from "earcut";
import Cartesian2 from "./Cartesian2.js";
import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import Check from "./Check.js";
import ComponentDatatype from "./ComponentDatatype.js";
import defined from "./defined.js";
import Ellipsoid from "./Ellipsoid.js";
import EllipsoidRhumbLine from "./EllipsoidRhumbLine.js";
import Geometry from "./Geometry.js";
import GeometryAttribute from "./GeometryAttribute.js";
import CesiumMath from "./Math.js";
import PrimitiveType from "./PrimitiveType.js";
import WindingOrder from "./WindingOrder.js";
const scaleToGeodeticHeightN = new Cartesian3();
const scaleToGeodeticHeightP = new Cartesian3();
/**
* @private
*/
const PolygonPipeline = {};
/**
* @exception {DeveloperError} At least three positions are required.
*/
PolygonPipeline.computeArea2D = function (positions) {
//>>includeStart('debug', pragmas.debug);
Check.defined("positions", positions);
Check.typeOf.number.greaterThanOrEquals(
"positions.length",
positions.length,
3,
);
//>>includeEnd('debug');
const length = positions.length;
let area = 0.0;
for (let i0 = length - 1, i1 = 0; i1 < length; i0 = i1++) {
const v0 = positions[i0];
const v1 = positions[i1];
area += v0.x * v1.y - v1.x * v0.y;
}
return area * 0.5;
};
/**
* @returns {WindingOrder} The winding order.
*
* @exception {DeveloperError} At least three positions are required.
*/
PolygonPipeline.computeWindingOrder2D = function (positions) {
const area = PolygonPipeline.computeArea2D(positions);
return area > 0.0 ? WindingOrder.COUNTER_CLOCKWISE : WindingOrder.CLOCKWISE;
};
/**
* Triangulate a polygon.
*
* @param {Cartesian2[]} positions Cartesian2 array containing the vertices of the polygon
* @param {number[]} [holes] An array of the staring indices of the holes.
* @returns {number[]} Index array representing triangles that fill the polygon
*/
PolygonPipeline.triangulate = function (positions, holes) {
//>>includeStart('debug', pragmas.debug);
Check.defined("positions", positions);
//>>includeEnd('debug');
const flattenedPositions = Cartesian2.packArray(positions);
return earcut(flattenedPositions, holes, 2);
};
const subdivisionV0Scratch = new Cartesian3();
const subdivisionV1Scratch = new Cartesian3();
const subdivisionV2Scratch = new Cartesian3();
const subdivisionS0Scratch = new Cartesian3();
const subdivisionS1Scratch = new Cartesian3();
const subdivisionS2Scratch = new Cartesian3();
const subdivisionMidScratch = new Cartesian3();
const subdivisionT0Scratch = new Cartesian2();
const subdivisionT1Scratch = new Cartesian2();
const subdivisionT2Scratch = new Cartesian2();
const subdivisionTexcoordMidScratch = new Cartesian2();
/**
* Subdivides positions and raises points to the surface of the ellipsoid.
*
* @param {Ellipsoid} ellipsoid The ellipsoid the polygon in on.
* @param {Cartesian3[]} positions An array of {@link Cartesian3} positions of the polygon.
* @param {number[]} indices An array of indices that determines the triangles in the polygon.
* @param {Cartesian2[]} texcoords An optional array of {@link Cartesian2} texture coordinates of the polygon.
* @param {number} [granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
*
* @exception {DeveloperError} At least three indices are required.
* @exception {DeveloperError} The number of indices must be divisable by three.
* @exception {DeveloperError} Granularity must be greater than zero.
*/
PolygonPipeline.computeSubdivision = function (
ellipsoid,
positions,
indices,
texcoords,
granularity,
) {
granularity = granularity ?? CesiumMath.RADIANS_PER_DEGREE;
const hasTexcoords = defined(texcoords);
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("ellipsoid", ellipsoid);
Check.defined("positions", positions);
Check.defined("indices", indices);
Check.typeOf.number.greaterThanOrEquals("indices.length", indices.length, 3);
Check.typeOf.number.equals("indices.length % 3", "0", indices.length % 3, 0);
Check.typeOf.number.greaterThan("granularity", granularity, 0.0);
//>>includeEnd('debug');
// triangles that need (or might need) to be subdivided.
const triangles = indices.slice(0);
// New positions due to edge splits are appended to the positions list.
let i;
const length = positions.length;
const subdividedPositions = new Array(length * 3);
const subdividedTexcoords = new Array(length * 2);
let q = 0;
let p = 0;
for (i = 0; i < length; i++) {
const item = positions[i];
subdividedPositions[q++] = item.x;
subdividedPositions[q++] = item.y;
subdividedPositions[q++] = item.z;
if (hasTexcoords) {
const texcoordItem = texcoords[i];
subdividedTexcoords[p++] = texcoordItem.x;
subdividedTexcoords[p++] = texcoordItem.y;
}
}
const subdividedIndices = [];
// Used to make sure shared edges are not split more than once.
const edges = {};
const radius = ellipsoid.maximumRadius;
const minDistance = CesiumMath.chordLength(granularity, radius);
const minDistanceSqrd = minDistance * minDistance;
while (triangles.length > 0) {
const i2 = triangles.pop();
const i1 = triangles.pop();
const i0 = triangles.pop();
const v0 = Cartesian3.fromArray(
subdividedPositions,
i0 * 3,
subdivisionV0Scratch,
);
const v1 = Cartesian3.fromArray(
subdividedPositions,
i1 * 3,
subdivisionV1Scratch,
);
const v2 = Cartesian3.fromArray(
subdividedPositions,
i2 * 3,
subdivisionV2Scratch,
);
let t0, t1, t2;
if (hasTexcoords) {
t0 = Cartesian2.fromArray(
subdividedTexcoords,
i0 * 2,
subdivisionT0Scratch,
);
t1 = Cartesian2.fromArray(
subdividedTexcoords,
i1 * 2,
subdivisionT1Scratch,
);
t2 = Cartesian2.fromArray(
subdividedTexcoords,
i2 * 2,
subdivisionT2Scratch,
);
}
const s0 = Cartesian3.multiplyByScalar(
Cartesian3.normalize(v0, subdivisionS0Scratch),
radius,
subdivisionS0Scratch,
);
const s1 = Cartesian3.multiplyByScalar(
Cartesian3.normalize(v1, subdivisionS1Scratch),
radius,
subdivisionS1Scratch,
);
const s2 = Cartesian3.multiplyByScalar(
Cartesian3.normalize(v2, subdivisionS2Scratch),
radius,
subdivisionS2Scratch,
);
const g0 = Cartesian3.magnitudeSquared(
Cartesian3.subtract(s0, s1, subdivisionMidScratch),
);
const g1 = Cartesian3.magnitudeSquared(
Cartesian3.subtract(s1, s2, subdivisionMidScratch),
);
const g2 = Cartesian3.magnitudeSquared(
Cartesian3.subtract(s2, s0, subdivisionMidScratch),
);
const max = Math.max(g0, g1, g2);
let edge;
let mid;
let midTexcoord;
// if the max length squared of a triangle edge is greater than the chord length of squared
// of the granularity, subdivide the triangle
if (max > minDistanceSqrd) {
if (g0 === max) {
edge = `${Math.min(i0, i1)} ${Math.max(i0, i1)}`;
i = edges[edge];
if (!defined(i)) {
mid = Cartesian3.add(v0, v1, subdivisionMidScratch);
Cartesian3.multiplyByScalar(mid, 0.5, mid);
subdividedPositions.push(mid.x, mid.y, mid.z);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
if (hasTexcoords) {
midTexcoord = Cartesian2.add(t0, t1, subdivisionTexcoordMidScratch);
Cartesian2.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i0, i, i2);
triangles.push(i, i1, i2);
} else if (g1 === max) {
edge = `${Math.min(i1, i2)} ${Math.max(i1, i2)}`;
i = edges[edge];
if (!defined(i)) {
mid = Cartesian3.add(v1, v2, subdivisionMidScratch);
Cartesian3.multiplyByScalar(mid, 0.5, mid);
subdividedPositions.push(mid.x, mid.y, mid.z);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
Iif (hasTexcoords) {
midTexcoord = Cartesian2.add(t1, t2, subdivisionTexcoordMidScratch);
Cartesian2.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i1, i, i0);
triangles.push(i, i2, i0);
} else Eif (g2 === max) {
edge = `${Math.min(i2, i0)} ${Math.max(i2, i0)}`;
i = edges[edge];
if (!defined(i)) {
mid = Cartesian3.add(v2, v0, subdivisionMidScratch);
Cartesian3.multiplyByScalar(mid, 0.5, mid);
subdividedPositions.push(mid.x, mid.y, mid.z);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
Iif (hasTexcoords) {
midTexcoord = Cartesian2.add(t2, t0, subdivisionTexcoordMidScratch);
Cartesian2.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i2, i, i1);
triangles.push(i, i0, i1);
}
} else {
subdividedIndices.push(i0);
subdividedIndices.push(i1);
subdividedIndices.push(i2);
}
}
const geometryOptions = {
attributes: {
position: new GeometryAttribute({
componentDatatype: ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
values: subdividedPositions,
}),
},
indices: subdividedIndices,
primitiveType: PrimitiveType.TRIANGLES,
};
if (hasTexcoords) {
geometryOptions.attributes.st = new GeometryAttribute({
componentDatatype: ComponentDatatype.FLOAT,
componentsPerAttribute: 2,
values: subdividedTexcoords,
});
}
return new Geometry(geometryOptions);
};
const subdivisionC0Scratch = new Cartographic();
const subdivisionC1Scratch = new Cartographic();
const subdivisionC2Scratch = new Cartographic();
const subdivisionCartographicScratch = new Cartographic();
/**
* Subdivides positions on rhumb lines and raises points to the surface of the ellipsoid.
*
* @param {Ellipsoid} ellipsoid The ellipsoid the polygon in on.
* @param {Cartesian3[]} positions An array of {@link Cartesian3} positions of the polygon.
* @param {number[]} indices An array of indices that determines the triangles in the polygon.
* @param {Cartesian2[]} texcoords An optional array of {@link Cartesian2} texture coordinates of the polygon.
* @param {number} [granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.
*
* @exception {DeveloperError} At least three indices are required.
* @exception {DeveloperError} The number of indices must be divisable by three.
* @exception {DeveloperError} Granularity must be greater than zero.
*/
PolygonPipeline.computeRhumbLineSubdivision = function (
ellipsoid,
positions,
indices,
texcoords,
granularity,
) {
granularity = granularity ?? CesiumMath.RADIANS_PER_DEGREE;
const hasTexcoords = defined(texcoords);
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object("ellipsoid", ellipsoid);
Check.defined("positions", positions);
Check.defined("indices", indices);
Check.typeOf.number.greaterThanOrEquals("indices.length", indices.length, 3);
Check.typeOf.number.equals("indices.length % 3", "0", indices.length % 3, 0);
Check.typeOf.number.greaterThan("granularity", granularity, 0.0);
//>>includeEnd('debug');
// triangles that need (or might need) to be subdivided.
const triangles = indices.slice(0);
// New positions due to edge splits are appended to the positions list.
let i;
const length = positions.length;
const subdividedPositions = new Array(length * 3);
const subdividedTexcoords = new Array(length * 2);
let q = 0;
let p = 0;
for (i = 0; i < length; i++) {
const item = positions[i];
subdividedPositions[q++] = item.x;
subdividedPositions[q++] = item.y;
subdividedPositions[q++] = item.z;
if (hasTexcoords) {
const texcoordItem = texcoords[i];
subdividedTexcoords[p++] = texcoordItem.x;
subdividedTexcoords[p++] = texcoordItem.y;
}
}
const subdividedIndices = [];
// Used to make sure shared edges are not split more than once.
const edges = {};
const radius = ellipsoid.maximumRadius;
const minDistance = CesiumMath.chordLength(granularity, radius);
const rhumb0 = new EllipsoidRhumbLine(undefined, undefined, ellipsoid);
const rhumb1 = new EllipsoidRhumbLine(undefined, undefined, ellipsoid);
const rhumb2 = new EllipsoidRhumbLine(undefined, undefined, ellipsoid);
while (triangles.length > 0) {
const i2 = triangles.pop();
const i1 = triangles.pop();
const i0 = triangles.pop();
const v0 = Cartesian3.fromArray(
subdividedPositions,
i0 * 3,
subdivisionV0Scratch,
);
const v1 = Cartesian3.fromArray(
subdividedPositions,
i1 * 3,
subdivisionV1Scratch,
);
const v2 = Cartesian3.fromArray(
subdividedPositions,
i2 * 3,
subdivisionV2Scratch,
);
let t0, t1, t2;
if (hasTexcoords) {
t0 = Cartesian2.fromArray(
subdividedTexcoords,
i0 * 2,
subdivisionT0Scratch,
);
t1 = Cartesian2.fromArray(
subdividedTexcoords,
i1 * 2,
subdivisionT1Scratch,
);
t2 = Cartesian2.fromArray(
subdividedTexcoords,
i2 * 2,
subdivisionT2Scratch,
);
}
const c0 = ellipsoid.cartesianToCartographic(v0, subdivisionC0Scratch);
const c1 = ellipsoid.cartesianToCartographic(v1, subdivisionC1Scratch);
const c2 = ellipsoid.cartesianToCartographic(v2, subdivisionC2Scratch);
rhumb0.setEndPoints(c0, c1);
const g0 = rhumb0.surfaceDistance;
rhumb1.setEndPoints(c1, c2);
const g1 = rhumb1.surfaceDistance;
rhumb2.setEndPoints(c2, c0);
const g2 = rhumb2.surfaceDistance;
const max = Math.max(g0, g1, g2);
let edge;
let mid;
let midHeight;
let midCartesian3;
let midTexcoord;
// if the max length squared of a triangle edge is greater than granularity, subdivide the triangle
if (max > minDistance) {
if (g0 === max) {
edge = `${Math.min(i0, i1)} ${Math.max(i0, i1)}`;
i = edges[edge];
if (!defined(i)) {
mid = rhumb0.interpolateUsingFraction(
0.5,
subdivisionCartographicScratch,
);
midHeight = (c0.height + c1.height) * 0.5;
midCartesian3 = Cartesian3.fromRadians(
mid.longitude,
mid.latitude,
midHeight,
ellipsoid,
subdivisionMidScratch,
);
subdividedPositions.push(
midCartesian3.x,
midCartesian3.y,
midCartesian3.z,
);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
if (hasTexcoords) {
midTexcoord = Cartesian2.add(t0, t1, subdivisionTexcoordMidScratch);
Cartesian2.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i0, i, i2);
triangles.push(i, i1, i2);
} else if (g1 === max) {
edge = `${Math.min(i1, i2)} ${Math.max(i1, i2)}`;
i = edges[edge];
if (!defined(i)) {
mid = rhumb1.interpolateUsingFraction(
0.5,
subdivisionCartographicScratch,
);
midHeight = (c1.height + c2.height) * 0.5;
midCartesian3 = Cartesian3.fromRadians(
mid.longitude,
mid.latitude,
midHeight,
ellipsoid,
subdivisionMidScratch,
);
subdividedPositions.push(
midCartesian3.x,
midCartesian3.y,
midCartesian3.z,
);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
Iif (hasTexcoords) {
midTexcoord = Cartesian2.add(t1, t2, subdivisionTexcoordMidScratch);
Cartesian2.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i1, i, i0);
triangles.push(i, i2, i0);
} else Eif (g2 === max) {
edge = `${Math.min(i2, i0)} ${Math.max(i2, i0)}`;
i = edges[edge];
if (!defined(i)) {
mid = rhumb2.interpolateUsingFraction(
0.5,
subdivisionCartographicScratch,
);
midHeight = (c2.height + c0.height) * 0.5;
midCartesian3 = Cartesian3.fromRadians(
mid.longitude,
mid.latitude,
midHeight,
ellipsoid,
subdivisionMidScratch,
);
subdividedPositions.push(
midCartesian3.x,
midCartesian3.y,
midCartesian3.z,
);
i = subdividedPositions.length / 3 - 1;
edges[edge] = i;
Iif (hasTexcoords) {
midTexcoord = Cartesian2.add(t2, t0, subdivisionTexcoordMidScratch);
Cartesian2.multiplyByScalar(midTexcoord, 0.5, midTexcoord);
subdividedTexcoords.push(midTexcoord.x, midTexcoord.y);
}
}
triangles.push(i2, i, i1);
triangles.push(i, i0, i1);
}
} else {
subdividedIndices.push(i0);
subdividedIndices.push(i1);
subdividedIndices.push(i2);
}
}
const geometryOptions = {
attributes: {
position: new GeometryAttribute({
componentDatatype: ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
values: subdividedPositions,
}),
},
indices: subdividedIndices,
primitiveType: PrimitiveType.TRIANGLES,
};
if (hasTexcoords) {
geometryOptions.attributes.st = new GeometryAttribute({
componentDatatype: ComponentDatatype.FLOAT,
componentsPerAttribute: 2,
values: subdividedTexcoords,
});
}
return new Geometry(geometryOptions);
};
/**
* Scales each position of a geometry's position attribute to a height, in place.
*
* @param {number[]} positions The array of numbers representing the positions to be scaled
* @param {number} [height=0.0] The desired height to add to the positions
* @param {Ellipsoid} [ellipsoid=Ellipsoid.default] The ellipsoid on which the positions lie.
* @param {boolean} [scaleToSurface=true] <code>true</code> if the positions need to be scaled to the surface before the height is added.
* @returns {number[]} The input array of positions, scaled to height
*/
PolygonPipeline.scaleToGeodeticHeight = function (
positions,
height,
ellipsoid,
scaleToSurface,
) {
ellipsoid = ellipsoid ?? Ellipsoid.default;
let n = scaleToGeodeticHeightN;
let p = scaleToGeodeticHeightP;
height = height ?? 0.0;
scaleToSurface = scaleToSurface ?? true;
Eif (defined(positions)) {
const length = positions.length;
for (let i = 0; i < length; i += 3) {
Cartesian3.fromArray(positions, i, p);
if (scaleToSurface) {
p = ellipsoid.scaleToGeodeticSurface(p, p);
}
if (height !== 0) {
n = ellipsoid.geodeticSurfaceNormal(p, n);
Cartesian3.multiplyByScalar(n, height, n);
Cartesian3.add(p, n, p);
}
positions[i] = p.x;
positions[i + 1] = p.y;
positions[i + 2] = p.z;
}
}
return positions;
};
export default PolygonPipeline;
|