1 line
8.2 KiB
Plaintext
1 line
8.2 KiB
Plaintext
{"version":3,"file":"CoplanarPolygonGeometryLibrary-b973f66f.js","sources":["../../../../Source/Core/CoplanarPolygonGeometryLibrary.js"],"sourcesContent":["import Cartesian2 from \"./Cartesian2.js\";\nimport Cartesian3 from \"./Cartesian3.js\";\nimport Check from \"./Check.js\";\nimport Matrix3 from \"./Matrix3.js\";\nimport OrientedBoundingBox from \"./OrientedBoundingBox.js\";\n\n/**\n * @private\n */\nconst CoplanarPolygonGeometryLibrary = {};\n\nconst scratchIntersectionPoint = new Cartesian3();\nconst scratchXAxis = new Cartesian3();\nconst scratchYAxis = new Cartesian3();\nconst scratchZAxis = new Cartesian3();\nconst obbScratch = new OrientedBoundingBox();\n\nCoplanarPolygonGeometryLibrary.validOutline = function (positions) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"positions\", positions);\n //>>includeEnd('debug');\n\n const orientedBoundingBox = OrientedBoundingBox.fromPoints(\n positions,\n obbScratch\n );\n const halfAxes = orientedBoundingBox.halfAxes;\n const xAxis = Matrix3.getColumn(halfAxes, 0, scratchXAxis);\n const yAxis = Matrix3.getColumn(halfAxes, 1, scratchYAxis);\n const zAxis = Matrix3.getColumn(halfAxes, 2, scratchZAxis);\n\n const xMag = Cartesian3.magnitude(xAxis);\n const yMag = Cartesian3.magnitude(yAxis);\n const zMag = Cartesian3.magnitude(zAxis);\n\n // If all the points are on a line return undefined because we can't draw a polygon\n return !(\n (xMag === 0 && (yMag === 0 || zMag === 0)) ||\n (yMag === 0 && zMag === 0)\n );\n};\n\n// call after removeDuplicates\nCoplanarPolygonGeometryLibrary.computeProjectTo2DArguments = function (\n positions,\n centerResult,\n planeAxis1Result,\n planeAxis2Result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"positions\", positions);\n Check.defined(\"centerResult\", centerResult);\n Check.defined(\"planeAxis1Result\", planeAxis1Result);\n Check.defined(\"planeAxis2Result\", planeAxis2Result);\n //>>includeEnd('debug');\n\n const orientedBoundingBox = OrientedBoundingBox.fromPoints(\n positions,\n obbScratch\n );\n const halfAxes = orientedBoundingBox.halfAxes;\n const xAxis = Matrix3.getColumn(halfAxes, 0, scratchXAxis);\n const yAxis = Matrix3.getColumn(halfAxes, 1, scratchYAxis);\n const zAxis = Matrix3.getColumn(halfAxes, 2, scratchZAxis);\n\n const xMag = Cartesian3.magnitude(xAxis);\n const yMag = Cartesian3.magnitude(yAxis);\n const zMag = Cartesian3.magnitude(zAxis);\n const min = Math.min(xMag, yMag, zMag);\n\n // If all the points are on a line return undefined because we can't draw a polygon\n if (\n (xMag === 0 && (yMag === 0 || zMag === 0)) ||\n (yMag === 0 && zMag === 0)\n ) {\n return false;\n }\n\n let planeAxis1;\n let planeAxis2;\n\n if (min === yMag || min === zMag) {\n planeAxis1 = xAxis;\n }\n if (min === xMag) {\n planeAxis1 = yAxis;\n } else if (min === zMag) {\n planeAxis2 = yAxis;\n }\n if (min === xMag || min === yMag) {\n planeAxis2 = zAxis;\n }\n\n Cartesian3.normalize(planeAxis1, planeAxis1Result);\n Cartesian3.normalize(planeAxis2, planeAxis2Result);\n Cartesian3.clone(orientedBoundingBox.center, centerResult);\n return true;\n};\n\nfunction projectTo2D(position, center, axis1, axis2, result) {\n const v = Cartesian3.subtract(position, center, scratchIntersectionPoint);\n const x = Cartesian3.dot(axis1, v);\n const y = Cartesian3.dot(axis2, v);\n\n return Cartesian2.fromElements(x, y, result);\n}\n\nCoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction = function (\n center,\n axis1,\n axis2\n) {\n return function (positions) {\n const positionResults = new Array(positions.length);\n for (let i = 0; i < positions.length; i++) {\n positionResults[i] = projectTo2D(positions[i], center, axis1, axis2);\n }\n\n return positionResults;\n };\n};\n\nCoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction = function (\n center,\n axis1,\n axis2\n) {\n return function (position, result) {\n return projectTo2D(position, center, axis1, axis2, result);\n };\n};\nexport default CoplanarPolygonGeometryLibrary;\n"],"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