build-dxf 0.1.131 → 0.1.134

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/build.js +19 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-dxf",
3
- "version": "0.1.131",
3
+ "version": "0.1.134",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/build.js CHANGED
@@ -10545,24 +10545,29 @@ class ThreeVJiaPipeline extends Pipeline {
10545
10545
  console.warn(`第${i}个物品轮廓为空`);
10546
10546
  return;
10547
10547
  }
10548
- const itemPoly = new Polygon(
10548
+ let itemPoly = new Polygon(
10549
10549
  contour.map((p2) => Point.from(p2).rotate(json.center, json.angle))
10550
- ), center = itemPoly.getCenter(), index2 = roomPloys.findIndex((poly) => poly.pointWithin(center));
10550
+ );
10551
+ const center = itemPoly.getCenter(), index2 = roomPloys.findIndex((poly) => poly.pointWithin(center));
10551
10552
  if (index2 < 0) return;
10552
10553
  try {
10553
- const rect = itemPoly.getMinimumBoundingRectangle().map((p2) => p2.toJson2D());
10554
- json.placeHolders.push({
10555
- name: placeHoldersMap[item.category],
10556
- polygon: rect,
10557
- direction: Point.from(item.direction).rotate(Point.zero(), json.angle),
10558
- height: item.box.max.z - item.box.min.z,
10559
- sillHeight: item.box.min.z - z,
10560
- roomId: rooms[index2].roomTypeId,
10561
- id: i
10562
- });
10554
+ let newR = itemPoly.getMinimumBoundingRectangle();
10555
+ if (newR) itemPoly = newR;
10563
10556
  } catch (error) {
10564
- console.warn(`第${i}个物品解析异常`);
10565
- }
10557
+ console.warn(`第${i}个物品 转四边形错误`);
10558
+ }
10559
+ const direction = Point.from(item.direction).normalize().rotate(Point.zero(), json.angle);
10560
+ if (itemPoly[1].distanceSquared(itemPoly[0]) < itemPoly[2].distanceSquared(itemPoly[1])) itemPoly.reverse();
10561
+ const rect = itemPoly.map((p2) => p2.toJson2D());
10562
+ json.placeHolders.push({
10563
+ name: placeHoldersMap[item.category],
10564
+ polygon: rect,
10565
+ direction: direction.toJson2D(),
10566
+ height: item.box.max.z - item.box.min.z,
10567
+ sillHeight: item.box.min.z - z,
10568
+ roomId: rooms[index2].roomTypeId,
10569
+ id: i
10570
+ });
10566
10571
  });
10567
10572
  return json;
10568
10573
  }