1 |
- {"version":3,"file":"CoplanarPolygonGeometryLibrary-f703c864.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 */\nvar CoplanarPolygonGeometryLibrary = {};\n\nvar scratchIntersectionPoint = new Cartesian3();\nvar scratchXAxis = new Cartesian3();\nvar scratchYAxis = new Cartesian3();\nvar scratchZAxis = new Cartesian3();\nvar obbScratch = new OrientedBoundingBox();\n\nCoplanarPolygonGeometryLibrary.validOutline = function (positions) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"positions\", positions);\n //>>includeEnd('debug');\n\n var orientedBoundingBox = OrientedBoundingBox.fromPoints(\n positions,\n obbScratch\n );\n var halfAxes = orientedBoundingBox.halfAxes;\n var xAxis = Matrix3.getColumn(halfAxes, 0, scratchXAxis);\n var yAxis = Matrix3.getColumn(halfAxes, 1, scratchYAxis);\n var zAxis = Matrix3.getColumn(halfAxes, 2, scratchZAxis);\n\n var xMag = Cartesian3.magnitude(xAxis);\n var yMag = Cartesian3.magnitude(yAxis);\n var 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 var orientedBoundingBox = OrientedBoundingBox.fromPoints(\n positions,\n obbScratch\n );\n var halfAxes = orientedBoundingBox.halfAxes;\n var xAxis = Matrix3.getColumn(halfAxes, 0, scratchXAxis);\n var yAxis = Matrix3.getColumn(halfAxes, 1, scratchYAxis);\n var zAxis = Matrix3.getColumn(halfAxes, 2, scratchZAxis);\n\n var xMag = Cartesian3.magnitude(xAxis);\n var yMag = Cartesian3.magnitude(yAxis);\n var zMag = Cartesian3.magnitude(zAxis);\n var 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 var planeAxis1;\n var 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 var v = Cartesian3.subtract(position, center, scratchIntersectionPoint);\n var x = Cartesian3.dot(axis1, v);\n var 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 var positionResults = new Array(positions.length);\n for (var 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"],"names":["Cartesian3","OrientedBoundingBox","Check","Matrix3","C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