rm-graphical-computing-node 1.0.36 → 1.0.37

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/dist/index.mjs +22 -15
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -8271,21 +8271,26 @@ var OBB = class _OBB extends OBB_ {
8271
8271
  * @returns
8272
8272
  */
8273
8273
  static fromByPath2D(path3, origin, height, obb_ = new _OBB()) {
8274
- const result = smallestSurroundingRectangleByArea({
8275
- type: "Polygon",
8276
- coordinates: [path3.map((p) => [p.x, p.y])]
8277
- });
8278
- if (!result) throw new Error("2d obb \u83B7\u53D6\u5931\u8D25");
8279
- const rectangle = result.geometry.coordinates[0];
8280
- const width1 = distance(rectangle[0], rectangle[1]);
8281
- const width2 = distance(rectangle[1], rectangle[2]);
8282
- const angle = Math.atan2(rectangle[1][1] - rectangle[0][1], rectangle[1][0] - rectangle[0][0]);
8283
- vec3.set(width1, width2, height);
8284
- euler.set(0, 0, angle);
8285
- const [x, y] = getCenter(rectangle);
8286
- origin.x = x;
8287
- origin.y = y;
8288
- const obb = this.from(vec3, origin, euler, obb_);
8274
+ let obb = null;
8275
+ try {
8276
+ const result = smallestSurroundingRectangleByArea({
8277
+ type: "Polygon",
8278
+ coordinates: [path3.map((p) => [p.x, p.y])]
8279
+ });
8280
+ if (!result) throw new Error("2d obb \u83B7\u53D6\u5931\u8D25");
8281
+ const rectangle = result.geometry.coordinates[0];
8282
+ const width1 = distance(rectangle[0], rectangle[1]);
8283
+ const width2 = distance(rectangle[1], rectangle[2]);
8284
+ const angle = Math.atan2(rectangle[1][1] - rectangle[0][1], rectangle[1][0] - rectangle[0][0]);
8285
+ vec3.set(width1, width2, height);
8286
+ euler.set(0, 0, angle);
8287
+ const [x, y] = getCenter(rectangle);
8288
+ origin.x = x;
8289
+ origin.y = y;
8290
+ obb = this.from(vec3, origin, euler, obb_);
8291
+ } catch (error) {
8292
+ return null;
8293
+ }
8289
8294
  return obb;
8290
8295
  }
8291
8296
  };
@@ -8441,6 +8446,8 @@ function getObb(path3, center, h, z) {
8441
8446
  if (pathPoints.length == 0)
8442
8447
  return null;
8443
8448
  const obb = OBB.fromByPath2D(pathPoints, center, h);
8449
+ if (obb == null)
8450
+ return null;
8444
8451
  obb.center.z = z;
8445
8452
  return obb;
8446
8453
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rm-graphical-computing-node",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "description": "墙体/梁线/点云语义计算库(依赖 Python 与 three.js)",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",