1 line
59 KiB
Plaintext
1 line
59 KiB
Plaintext
|
{"version":3,"file":"upsampleQuantizedTerrainMesh.js","sources":["../../../../Source/Core/Intersections2D.js","../../../../Source/WorkersES6/upsampleQuantizedTerrainMesh.js"],"sourcesContent":["import Cartesian2 from \"./Cartesian2.js\";\nimport Cartesian3 from \"./Cartesian3.js\";\nimport Check from \"./Check.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\n\n/**\n * Contains functions for operating on 2D triangles.\n *\n * @namespace Intersections2D\n */\nconst Intersections2D = {};\n\n/**\n * Splits a 2D triangle at given axis-aligned threshold value and returns the resulting\n * polygon on a given side of the threshold. The resulting polygon may have 0, 1, 2,\n * 3, or 4 vertices.\n *\n * @param {Number} threshold The threshold coordinate value at which to clip the triangle.\n * @param {Boolean} keepAbove true to keep the portion of the triangle above the threshold, or false\n * to keep the portion below.\n * @param {Number} u0 The coordinate of the first vertex in the triangle, in counter-clockwise order.\n * @param {Number} u1 The coordinate of the second vertex in the triangle, in counter-clockwise order.\n * @param {Number} u2 The coordinate of the third vertex in the triangle, in counter-clockwise order.\n * @param {Number[]} [result] The array into which to copy the result. If this parameter is not supplied,\n * a new array is constructed and returned.\n * @returns {Number[]} The polygon that results after the clip, specified as a list of\n * vertices. The vertices are specified in counter-clockwise order.\n * Each vertex is either an index from the existing list (identified as\n * a 0, 1, or 2) or -1 indicating a new vertex not in the original triangle.\n * For new vertices, the -1 is followed by three additional numbers: the\n * index of each of the two original vertices forming the line segment that\n * the new vertex lies on, and the fraction of the distance from the first\n * vertex to the second one.\n *\n * @example\n * const result = Cesium.Intersections2D.clipTriangleAtAxisAlignedThreshold(0.5, false, 0.2, 0.6, 0.4);\n * // result === [2, 0, -1, 1, 0, 0.25, -1, 1, 2, 0.5]\n */\nIntersections2D.clipTriangleAtAxisAlignedThreshold = function (\n threshold,\n keepAbove,\n u0,\n u1,\n u2,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n if (!defined(threshold)) {\n throw new DeveloperError(\"threshold is required.\");\n }\n if (!defined(keepAbove)) {\n throw new DeveloperError(\"keepAbove is required.\");\n }\n if (!defined(u0)) {\n throw new DeveloperError(\"u0 is required.\");\n }\n if (!defined(u1)) {\n throw new DeveloperError(\"u1 is required.\");\n }\n if (!defined(u2)) {\n throw new DeveloperError(\"u2 is required.\");\n }\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = [];\n } else {\n result.length = 0;\n }\n\n let u0Behind;\n let u1Behind;\n let u2Behind;\n if (keepAbove) {\n u0Behind = u0 < threshold;\n u1Behind = u1 < threshold;\n u2Behind = u2 < threshold;\n } else {\n u0Behind = u0 > threshold;\n u1Behind = u1 > threshold;\n u2Behind = u2 > threshold;\n }\n\n const numBehind = u0Behind + u1Behind + u2Behind;\n\n let u01Ratio;\n let u02Ratio;\n let u12Ratio;\n let u10Ratio;\n let u20Ratio;\n let u21Ratio;\n\n if (numBehind === 1) {\n if (u0Behind) {\n u01Ratio = (threshold - u0) / (u1 - u0);\n u02Ratio = (threshold - u0) / (u2 - u0);\n\n result.push(1);\n\n result.push(2);\n\n if (u02Ratio !== 1.0) {\n result.push(-1);\n result.push(0);\n result.push(2);\n result.push(u02Ratio);\n }\n\n if (u01Ratio !== 1.0) {\n result.push(-1);\n result.push(0);\n result.push(1);\n result.push(u01Ratio);\n }\n } else if (u1Behind) {\n u12Ratio = (threshold - u1
|