1 line
216 KiB
Plaintext
1 line
216 KiB
Plaintext
|
{"version":3,"file":"GeometryPipeline-e93f6439.js","sources":["../../../../Source/Core/barycentricCoordinates.js","../../../../Source/Core/Tipsify.js","../../../../Source/Core/GeometryPipeline.js"],"sourcesContent":["import Cartesian2 from \"./Cartesian2.js\";\nimport Cartesian3 from \"./Cartesian3.js\";\nimport Check from \"./Check.js\";\nimport defined from \"./defined.js\";\nimport CesiumMath from \"./Math.js\";\n\nconst scratchCartesian1 = new Cartesian3();\nconst scratchCartesian2 = new Cartesian3();\nconst scratchCartesian3 = new Cartesian3();\n\n/**\n * Computes the barycentric coordinates for a point with respect to a triangle.\n *\n * @function\n *\n * @param {Cartesian2|Cartesian3} point The point to test.\n * @param {Cartesian2|Cartesian3} p0 The first point of the triangle, corresponding to the barycentric x-axis.\n * @param {Cartesian2|Cartesian3} p1 The second point of the triangle, corresponding to the barycentric y-axis.\n * @param {Cartesian2|Cartesian3} p2 The third point of the triangle, corresponding to the barycentric z-axis.\n * @param {Cartesian3} [result] The object onto which to store the result.\n * @returns {Cartesian3|undefined} The modified result parameter or a new Cartesian3 instance if one was not provided. If the triangle is degenerate the function will return undefined.\n *\n * @example\n * // Returns Cartesian3.UNIT_X\n * const p = new Cesium.Cartesian3(-1.0, 0.0, 0.0);\n * const b = Cesium.barycentricCoordinates(p,\n * new Cesium.Cartesian3(-1.0, 0.0, 0.0),\n * new Cesium.Cartesian3( 1.0, 0.0, 0.0),\n * new Cesium.Cartesian3( 0.0, 1.0, 1.0));\n */\nfunction barycentricCoordinates(point, p0, p1, p2, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"point\", point);\n Check.defined(\"p0\", p0);\n Check.defined(\"p1\", p1);\n Check.defined(\"p2\", p2);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new Cartesian3();\n }\n\n // Implementation based on http://www.blackpawn.com/texts/pointinpoly/default.html.\n let v0;\n let v1;\n let v2;\n let dot00;\n let dot01;\n let dot02;\n let dot11;\n let dot12;\n\n if (!defined(p0.z)) {\n if (Cartesian2.equalsEpsilon(point, p0, CesiumMath.EPSILON14)) {\n return Cartesian3.clone(Cartesian3.UNIT_X, result);\n }\n if (Cartesian2.equalsEpsilon(point, p1, CesiumMath.EPSILON14)) {\n return Cartesian3.clone(Cartesian3.UNIT_Y, result);\n }\n if (Cartesian2.equalsEpsilon(point, p2, CesiumMath.EPSILON14)) {\n return Cartesian3.clone(Cartesian3.UNIT_Z, result);\n }\n\n v0 = Cartesian2.subtract(p1, p0, scratchCartesian1);\n v1 = Cartesian2.subtract(p2, p0, scratchCartesian2);\n v2 = Cartesian2.subtract(point, p0, scratchCartesian3);\n\n dot00 = Cartesian2.dot(v0, v0);\n dot01 = Cartesian2.dot(v0, v1);\n dot02 = Cartesian2.dot(v0, v2);\n dot11 = Cartesian2.dot(v1, v1);\n dot12 = Cartesian2.dot(v1, v2);\n } else {\n if (Cartesian3.equalsEpsilon(point, p0, CesiumMath.EPSILON14)) {\n return Cartesian3.clone(Cartesian3.UNIT_X, result);\n }\n if (Cartesian3.equalsEpsilon(point, p1, CesiumMath.EPSILON14)) {\n return Cartesian3.clone(Cartesian3.UNIT_Y, result);\n }\n if (Cartesian3.equalsEpsilon(point, p2, CesiumMath.EPSILON14)) {\n return Cartesian3.clone(Cartesian3.UNIT_Z, result);\n }\n\n v0 = Cartesian3.subtract(p1, p0, scratchCartesian1);\n v1 = Cartesian3.subtract(p2, p0, scratchCartesian2);\n v2 = Cartesian3.subtract(point, p0, scratchCartesian3);\n\n dot00 = Cartesian3.dot(v0, v0);\n dot01 = Cartesian3.dot(v0, v1);\n dot02 = Cartesian3.dot(v0, v2);\n dot11 = Cartesian3.dot(v1, v1);\n dot12 = Cartesian3.dot(v1, v2);\n }\n\n result.y = dot11 * dot02 - dot01 * dot12;\n result.z = dot00 * dot12 - dot01 * dot02;\n const q = dot00 * dot11 - dot01 * dot01;\n\n // Triangle is degenerate\n if (q === 0) {\n return undefined;\n }\n\n result.y /= q;\n result.z /= q;\n result.x = 1.0 - result.y - result.z;\n return result;\n}\nexport default barycentricCoordinates;\n","import defa
|