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;\n generateArcOptions.ellipsoid = ellipsoid;\n\n if (duplicateCorners) {\n let count = 0;\n let i;\n\n for (i = 0; i < length - 1; i++) {\n count +=\n PolylinePipeline.numberOfPoints(\n wallPositions[i],\n wallPositions[i + 1],\n minDistance\n ) + 1;\n }\n\n topPositions = new Float64Array(count * 3);\n bottomPositions = new Float64Array(count * 3);\n\n const generateArcPositions = positionsArrayScratch;\n const generateArcHeights = heightsArrayScratch;\n generateArcOptions.positions = generateArcPositions;\n generateArcOptions.height = generateArcHeights;\n\n let offset = 0;\n for (i = 0; i < length - 1; i++) {\n generateArcPositions[0] = wallPositions[i];\n generateArcPositions[1] = wallPositions[i + 1];\n\n generateArcHeights[0] = maximumHeights[i];\n generateArcHeights[1] = maximumHeights[i + 1];\n\n const pos = PolylinePipeline.generateArc(generateArcOptions);\n topPositions.set(pos, offset);\n\n generateArcHeights[0] = minimumHeights[i];\n generateArcHeights[1] = minimumHeights[i + 1];\n\n bottomPositions.set(\n PolylinePipeline.generateArc(generateArcOptions),\n offset\n );\n\n offset += pos.length;\n }\n } else {\n generateArcOptions.positions = wallPositions;\n generateArcOptions.height = maximumHeights;\n topPositions = new Float64Array(\n PolylinePipeline.generateArc(generateArcOptions)\n );\n\n generateArcOptions.height = minimumHeights;\n bottomPositions = new Float64Array(\n PolylinePipeline.generateArc(generateArcOptions)\n );\n }\n\n return {\n bottomPositions: bottomPositions,\n topPositions: topPositions,\n numCorners: numCorners,\n };\n};\nexport default WallGeometryLibrary;\n"],"names":["CesiumMath","Cartographic","arrayRemoveDuplicates","Cartesian3","defined","PolylinePipeline"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAOA;EACA;EACA;AACK,QAAC,mBAAmB,GAAG,GAAG;AAC/B;EACA,SAAS,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;EAC9B,EAAE;EACF,IAAIA,4BAAU,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAEA,4BAAU,CAAC,SAAS,CAAC;EAC5E,IAAIA,4BAAU,CAAC,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAEA,4BAAU,CAAC,SAAS,CAAC;EAC9E,IAAI;EACJ,CAAC;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