gltf-parser-plugin 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2021,7 +2021,7 @@ class GLTFParserPlugin {
2021
2021
  }
2022
2022
  /**
2023
2023
  * 选择多边形(平面投影)范围内的构件(包含相交和包含两种情况)
2024
- * @param polygon 多边形顶点数组(Vector2),按顺序连接构成闭合多边形
2024
+ * @param polygon 多边形顶点数组(Vector3),按顺序连接构成闭合多边形
2025
2025
  * @param axis 投影平面,决定使用 bbox 的哪两个轴做 2D 判定
2026
2026
  * - 'xz'(默认):俯视图,取 bbox 的 x/z 坐标
2027
2027
  * - 'xy':正视图,取 bbox 的 x/y 坐标
@@ -2031,6 +2031,17 @@ class GLTFParserPlugin {
2031
2031
  async selectByPolygon(polygon, axis = "xz") {
2032
2032
  await this._ensureStructureLoaded();
2033
2033
  const result = [];
2034
+ const polygon2D = polygon.map((p) => {
2035
+ switch (axis) {
2036
+ case "xy":
2037
+ return new Vector2(p.x, p.y);
2038
+ case "yz":
2039
+ return new Vector2(p.y, p.z);
2040
+ case "xz":
2041
+ default:
2042
+ return new Vector2(p.x, p.z);
2043
+ }
2044
+ });
2034
2045
  for (const [oid, node] of this._oidNodeMap) {
2035
2046
  if (!node.bbox || node.bbox.length < 6) continue;
2036
2047
  let minU, minV, maxU, maxV;
@@ -2054,7 +2065,7 @@ class GLTFParserPlugin {
2054
2065
  maxV = node.bbox[5];
2055
2066
  break;
2056
2067
  }
2057
- if (this._polygonIntersectsRect(polygon, minU, minV, maxU, maxV)) {
2068
+ if (this._polygonIntersectsRect(polygon2D, minU, minV, maxU, maxV)) {
2058
2069
  result.push(oid);
2059
2070
  }
2060
2071
  }