Files
Foundry-VTT-Docker/resources/app/node_modules/@pixi/graphics/lib/utils/buildPoly.mjs.map
2025-01-04 00:34:03 +01:00

1 line
4.4 KiB
Plaintext

{"version":3,"file":"buildPoly.mjs","sources":["../../src/utils/buildPoly.ts"],"sourcesContent":["import { utils } from '@pixi/core';\n\nimport type { Polygon } from '@pixi/core';\nimport type { IShapeBuildCommand } from './IShapeBuildCommand';\n\nfunction fixOrientation(points: number[], hole = false)\n{\n const m = points.length;\n\n if (m < 6)\n {\n return;\n }\n\n let area = 0;\n\n for (let i = 0, x1 = points[m - 2], y1 = points[m - 1]; i < m; i += 2)\n {\n const x2 = points[i];\n const y2 = points[i + 1];\n\n area += (x2 - x1) * (y2 + y1);\n\n x1 = x2;\n y1 = y2;\n }\n\n if ((!hole && area > 0) || (hole && area <= 0))\n {\n const n = m / 2;\n\n for (let i = n + (n % 2); i < m; i += 2)\n {\n const i1 = m - i - 2;\n const i2 = m - i - 1;\n const i3 = i;\n const i4 = i + 1;\n\n [points[i1], points[i3]] = [points[i3], points[i1]];\n [points[i2], points[i4]] = [points[i4], points[i2]];\n }\n }\n}\n/**\n * Builds a polygon to draw\n *\n * Ignored from docs since it is not directly exposed.\n * @ignore\n * @private\n * @param {PIXI.WebGLGraphicsData} graphicsData - The graphics object containing all the necessary properties\n * @param {object} webGLData - an object containing all the WebGL-specific information to create this shape\n * @param {object} webGLDataNativeLines - an object containing all the WebGL-specific information to create nativeLines\n */\nexport const buildPoly: IShapeBuildCommand = {\n\n build(graphicsData)\n {\n graphicsData.points = (graphicsData.shape as Polygon).points.slice();\n },\n\n triangulate(graphicsData, graphicsGeometry)\n {\n let points = graphicsData.points;\n const holes = graphicsData.holes;\n const verts = graphicsGeometry.points;\n const indices = graphicsGeometry.indices;\n\n if (points.length >= 6)\n {\n fixOrientation(points, false);\n\n const holeArray = [];\n // Process holes..\n\n for (let i = 0; i < holes.length; i++)\n {\n const hole = holes[i];\n\n fixOrientation(hole.points, true);\n\n holeArray.push(points.length / 2);\n points = points.concat(hole.points);\n }\n\n // sort color\n const triangles = utils.earcut(points, holeArray, 2);\n\n if (!triangles)\n {\n return;\n }\n\n const vertPos = verts.length / 2;\n\n for (let i = 0; i < triangles.length; i += 3)\n {\n indices.push(triangles[i] + vertPos);\n indices.push(triangles[i + 1] + vertPos);\n indices.push(triangles[i + 2] + vertPos);\n }\n\n for (let i = 0; i < points.length; i++)\n {\n verts.push(points[i]);\n }\n }\n },\n};\n"],"names":[],"mappings":";AAKA,SAAS,eAAe,QAAkB,OAAO,IACjD;AACI,QAAM,IAAI,OAAO;AAEjB,MAAI,IAAI;AAEJ;AAGJ,MAAI,OAAO;AAEX,WAAS,IAAI,GAAG,KAAK,OAAO,IAAI,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,GACpE;AACI,UAAM,KAAK,OAAO,CAAC,GACb,KAAK,OAAO,IAAI,CAAC;AAEvB,aAAS,KAAK,OAAO,KAAK,KAE1B,KAAK,IACL,KAAK;AAAA,EACT;AAEA,MAAK,CAAC,QAAQ,OAAO,KAAO,QAAQ,QAAQ,GAC5C;AACI,UAAM,IAAI,IAAI;AAEd,aAAS,IAAI,IAAK,IAAI,GAAI,IAAI,GAAG,KAAK,GACtC;AACU,YAAA,KAAK,IAAI,IAAI,GACb,KAAK,IAAI,IAAI,GACb,KAAK,GACL,KAAK,IAAI;AAEf,OAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,GAClD,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;AAAA,IACtD;AAAA,EACJ;AACJ;AAWO,MAAM,YAAgC;AAAA,EAEzC,MAAM,cACN;AACI,iBAAa,SAAU,aAAa,MAAkB,OAAO,MAAM;AAAA,EACvE;AAAA,EAEA,YAAY,cAAc,kBAC1B;AACI,QAAI,SAAS,aAAa;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