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.
- package/dist/index.mjs +22 -15
- 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
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
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
|
}
|