qd-changjing/public/static/Build/CesiumUnminified/Workers/EllipseGeometryLibrary-4ab5...

1 line
22 KiB
Plaintext
Raw Normal View History

2022-07-05 16:56:29 +08:00
{"version":3,"file":"EllipseGeometryLibrary-4ab591fa.js","sources":["../../../../Source/Core/EllipseGeometryLibrary.js"],"sourcesContent":["import Cartesian3 from \"./Cartesian3.js\";\nimport CesiumMath from \"./Math.js\";\nimport Matrix3 from \"./Matrix3.js\";\nimport Quaternion from \"./Quaternion.js\";\n\nconst EllipseGeometryLibrary = {};\n\nconst rotAxis = new Cartesian3();\nconst tempVec = new Cartesian3();\nconst unitQuat = new Quaternion();\nconst rotMtx = new Matrix3();\n\nfunction pointOnEllipsoid(\n theta,\n rotation,\n northVec,\n eastVec,\n aSqr,\n ab,\n bSqr,\n mag,\n unitPos,\n result\n) {\n const azimuth = theta + rotation;\n\n Cartesian3.multiplyByScalar(eastVec, Math.cos(azimuth), rotAxis);\n Cartesian3.multiplyByScalar(northVec, Math.sin(azimuth), tempVec);\n Cartesian3.add(rotAxis, tempVec, rotAxis);\n\n let cosThetaSquared = Math.cos(theta);\n cosThetaSquared = cosThetaSquared * cosThetaSquared;\n\n let sinThetaSquared = Math.sin(theta);\n sinThetaSquared = sinThetaSquared * sinThetaSquared;\n\n const radius =\n ab / Math.sqrt(bSqr * cosThetaSquared + aSqr * sinThetaSquared);\n const angle = radius / mag;\n\n // Create the quaternion to rotate the position vector to the boundary of the ellipse.\n Quaternion.fromAxisAngle(rotAxis, angle, unitQuat);\n Matrix3.fromQuaternion(unitQuat, rotMtx);\n\n Matrix3.multiplyByVector(rotMtx, unitPos, result);\n Cartesian3.normalize(result, result);\n Cartesian3.multiplyByScalar(result, mag, result);\n return result;\n}\n\nconst scratchCartesian1 = new Cartesian3();\nconst scratchCartesian2 = new Cartesian3();\nconst scratchCartesian3 = new Cartesian3();\nconst scratchNormal = new Cartesian3();\n/**\n * Returns the positions raised to the given heights\n * @private\n */\nEllipseGeometryLibrary.raisePositionsToHeight = function (\n positions,\n options,\n extrude\n) {\n const ellipsoid = options.ellipsoid;\n const height = options.height;\n const extrudedHeight = options.extrudedHeight;\n const size = extrude ? (positions.length / 3) * 2 : positions.length / 3;\n\n const finalPositions = new Float64Array(size * 3);\n\n const length = positions.length;\n const bottomOffset = extrude ? length : 0;\n for (let i = 0; i < length; i += 3) {\n const i1 = i + 1;\n const i2 = i + 2;\n\n const position = Cartesian3.fromArray(positions, i, scratchCartesian1);\n ellipsoid.scaleToGeodeticSurface(position, position);\n\n const extrudedPosition = Cartesian3.clone(position, scratchCartesian2);\n const normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);\n const scaledNormal = Cartesian3.multiplyByScalar(\n normal,\n height,\n scratchCartesian3\n );\n Cartesian3.add(position, scaledNormal, position);\n\n if (extrude) {\n Cartesian3.multiplyByScalar(normal, extrudedHeight, scaledNormal);\n Cartesian3.add(extrudedPosition, scaledNormal, extrudedPosition);\n\n finalPositions[i + bottomOffset] = extrudedPosition.x;\n finalPositions[i1 + bottomOffset] = extrudedPosition.y;\n finalPositions[i2 + bottomOffset] = extrudedPosition.z;\n }\n\n finalPositions[i] = position.x;\n finalPositions[i1] = position.y;\n finalPositions[i2] = position.z;\n }\n\n return finalPositions;\n};\n\nconst unitPosScratch = new Cartesian3();\nconst eastVecScratch = new Cartesian3();\nconst northVecScratch = new Cartesian3();\n/**\n * Returns an array of positions that make up the ellipse.\n * @private\n */\nEllipseGeometryLibrary.computeEllipsePositions = function (\n options,\n addFillPositions,\n addEdgePositions\n) {\n const semiMinorAxis = options.semiMinorAxis;\n const semiMajorAxis = options.semiMajorAxis;\n const rotation = options.rotation;\n const center = options.center;\n\n // Computing the arc-length of the ellipse is too expensive to be practical. Estimating it using the\n // arc length of the sphere is too inaccurate and creates sharp edges when either the semi-major or\n // semi-minor axis is much bigger than the other. Instead, scale the angle delta to