qd-changjing/public/static/Build/CesiumUnminified/Workers/PolylinePipeline-b9913663.j...

1 line
35 KiB
Plaintext
Raw Normal View History

2022-07-05 16:56:29 +08:00
{"version":3,"file":"PolylinePipeline-b9913663.js","sources":["../../../../Source/Core/PolylinePipeline.js"],"sourcesContent":["import Cartesian3 from \"./Cartesian3.js\";\nimport Cartographic from \"./Cartographic.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport Ellipsoid from \"./Ellipsoid.js\";\nimport EllipsoidGeodesic from \"./EllipsoidGeodesic.js\";\nimport EllipsoidRhumbLine from \"./EllipsoidRhumbLine.js\";\nimport IntersectionTests from \"./IntersectionTests.js\";\nimport CesiumMath from \"./Math.js\";\nimport Matrix4 from \"./Matrix4.js\";\nimport Plane from \"./Plane.js\";\n\n/**\n * @private\n */\nconst PolylinePipeline = {};\n\nPolylinePipeline.numberOfPoints = function (p0, p1, minDistance) {\n const distance = Cartesian3.distance(p0, p1);\n return Math.ceil(distance / minDistance);\n};\n\nPolylinePipeline.numberOfPointsRhumbLine = function (p0, p1, granularity) {\n const radiansDistanceSquared =\n Math.pow(p0.longitude - p1.longitude, 2) +\n Math.pow(p0.latitude - p1.latitude, 2);\n\n return Math.max(\n 1,\n Math.ceil(Math.sqrt(radiansDistanceSquared / (granularity * granularity)))\n );\n};\n\nconst cartoScratch = new Cartographic();\nPolylinePipeline.extractHeights = function (positions, ellipsoid) {\n const length = positions.length;\n const heights = new Array(length);\n for (let i = 0; i < length; i++) {\n const p = positions[i];\n heights[i] = ellipsoid.cartesianToCartographic(p, cartoScratch).height;\n }\n return heights;\n};\n\nconst wrapLongitudeInversMatrix = new Matrix4();\nconst wrapLongitudeOrigin = new Cartesian3();\nconst wrapLongitudeXZNormal = new Cartesian3();\nconst wrapLongitudeXZPlane = new Plane(Cartesian3.UNIT_X, 0.0);\nconst wrapLongitudeYZNormal = new Cartesian3();\nconst wrapLongitudeYZPlane = new Plane(Cartesian3.UNIT_X, 0.0);\nconst wrapLongitudeIntersection = new Cartesian3();\nconst wrapLongitudeOffset = new Cartesian3();\n\nconst subdivideHeightsScratchArray = [];\n\nfunction subdivideHeights(numPoints, h0, h1) {\n const heights = subdivideHeightsScratchArray;\n heights.length = numPoints;\n\n let i;\n if (h0 === h1) {\n for (i = 0; i < numPoints; i++) {\n heights[i] = h0;\n }\n return heights;\n }\n\n const dHeight = h1 - h0;\n const heightPerVertex = dHeight / numPoints;\n\n for (i = 0; i < numPoints; i++) {\n const h = h0 + i * heightPerVertex;\n heights[i] = h;\n }\n\n return heights;\n}\n\nconst carto1 = new Cartographic();\nconst carto2 = new Cartographic();\nconst cartesian = new Cartesian3();\nconst scaleFirst = new Cartesian3();\nconst scaleLast = new Cartesian3();\nconst ellipsoidGeodesic = new EllipsoidGeodesic();\nlet ellipsoidRhumb = new EllipsoidRhumbLine();\n\n//Returns subdivided line scaled to ellipsoid surface starting at p1 and ending at p2.\n//Result includes p1, but not include p2. This function is called for a sequence of line segments,\n//and this prevents duplication of end point.\nfunction generateCartesianArc(\n p0,\n p1,\n minDistance,\n ellipsoid,\n h0,\n h1,\n array,\n offset\n) {\n const first = ellipsoid.scaleToGeodeticSurface(p0, scaleFirst);\n const last = ellipsoid.scaleToGeodeticSurface(p1, scaleLast);\n const numPoints = PolylinePipeline.numberOfPoints(p0, p1, minDistance);\n const start = ellipsoid.cartesianToCartographic(first, carto1);\n const end = ellipsoid.cartesianToCartographic(last, carto2);\n const heights = subdivideHeights(numPoints, h0, h1);\n\n ellipsoidGeodesic.setEndPoints(start, end);\n const surfaceDistanceBetweenPoints =\n ellipsoidGeodesic.surfaceDistance / numPoints;\n\n let index = offset;\n start.height = h0;\n let cart = ellipsoid.cartographicToCartesian(start, cartesian);\n Cartesian3.pack(cart, array, index);\n index += 3;\n\n for (let i = 1; i < numPoints; i++) {\n const carto = ellipsoidGeodesic.interpolateUsingSurfaceDistance(\n i * surfaceDistanceBetweenPoints,\n carto2\n );\n carto.height = heights[i];\n