1 line
12 KiB
Plaintext
1 line
12 KiB
Plaintext
|
{"version":3,"file":"WallGeometryLibrary-a5c492d8.js","sources":["../../../../Source/Core/WallGeometryLibrary.js"],"sourcesContent":["import arrayRemoveDuplicates from \"./arrayRemoveDuplicates.js\";\nimport Cartesian3 from \"./Cartesian3.js\";\nimport Cartographic from \"./Cartographic.js\";\nimport defined from \"./defined.js\";\nimport CesiumMath from \"./Math.js\";\nimport PolylinePipeline from \"./PolylinePipeline.js\";\n\n/**\n * @private\n */\nconst WallGeometryLibrary = {};\n\nfunction latLonEquals(c0, c1) {\n return (\n CesiumMath.equalsEpsilon(c0.latitude, c1.latitude, CesiumMath.EPSILON10) &&\n CesiumMath.equalsEpsilon(c0.longitude, c1.longitude, CesiumMath.EPSILON10)\n );\n}\n\nconst scratchCartographic1 = new Cartographic();\nconst scratchCartographic2 = new Cartographic();\nfunction removeDuplicates(ellipsoid, positions, topHeights, bottomHeights) {\n positions = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon);\n\n const length = positions.length;\n if (length < 2) {\n return;\n }\n\n const hasBottomHeights = defined(bottomHeights);\n const hasTopHeights = defined(topHeights);\n\n const cleanedPositions = new Array(length);\n const cleanedTopHeights = new Array(length);\n const cleanedBottomHeights = new Array(length);\n\n const v0 = positions[0];\n cleanedPositions[0] = v0;\n\n const c0 = ellipsoid.cartesianToCartographic(v0, scratchCartographic1);\n if (hasTopHeights) {\n c0.height = topHeights[0];\n }\n\n cleanedTopHeights[0] = c0.height;\n\n if (hasBottomHeights) {\n cleanedBottomHeights[0] = bottomHeights[0];\n } else {\n cleanedBottomHeights[0] = 0.0;\n }\n\n const startTopHeight = cleanedTopHeights[0];\n const startBottomHeight = cleanedBottomHeights[0];\n let hasAllSameHeights = startTopHeight === startBottomHeight;\n\n let index = 1;\n for (let i = 1; i < length; ++i) {\n const v1 = positions[i];\n const c1 = ellipsoid.cartesianToCartographic(v1, scratchCartographic2);\n if (hasTopHeights) {\n c1.height = topHeights[i];\n }\n hasAllSameHeights = hasAllSameHeights && c1.height === 0;\n\n if (!latLonEquals(c0, c1)) {\n cleanedPositions[index] = v1; // Shallow copy!\n cleanedTopHeights[index] = c1.height;\n\n if (hasBottomHeights) {\n cleanedBottomHeights[index] = bottomHeights[i];\n } else {\n cleanedBottomHeights[index] = 0.0;\n }\n hasAllSameHeights =\n hasAllSameHeights &&\n cleanedTopHeights[index] === cleanedBottomHeights[index];\n\n Cartographic.clone(c1, c0);\n ++index;\n } else if (c0.height < c1.height) {\n // two adjacent positions are the same, so use whichever has the greater height\n cleanedTopHeights[index - 1] = c1.height;\n }\n }\n\n if (hasAllSameHeights || index < 2) {\n return;\n }\n\n cleanedPositions.length = index;\n cleanedTopHeights.length = index;\n cleanedBottomHeights.length = index;\n\n return {\n positions: cleanedPositions,\n topHeights: cleanedTopHeights,\n bottomHeights: cleanedBottomHeights,\n };\n}\n\nconst positionsArrayScratch = new Array(2);\nconst heightsArrayScratch = new Array(2);\nconst generateArcOptionsScratch = {\n positions: undefined,\n height: undefined,\n granularity: undefined,\n ellipsoid: undefined,\n};\n\n/**\n * @private\n */\nWallGeometryLibrary.computePositions = function (\n ellipsoid,\n wallPositions,\n maximumHeights,\n minimumHeights,\n granularity,\n duplicateCorners\n) {\n const o = removeDuplicates(\n ellipsoid,\n wallPositions,\n maximumHeights,\n minimumHeights\n );\n\n if (!defined(o)) {\n return;\n }\n\n wallPositions = o.positions;\n maximumHeights = o.topHeights;\n minimumHeights = o.bottomHeights;\n\n const length = wallPositions.length;\n const numCorners = length - 2;\n let topPositions;\n let bottomPositions;\n\n const minDistance = CesiumMath.chordLength(\n granularity,\n ellipsoid.maximumRadius\n );\n\n const generateArcOptions = generateArcOptionsScratch;\n generateArcOptions.minDistance = minDistance;\
|