Skip to content

Commit 41b0616

Browse files
committed
Fix pointToJSObject to cast coordinates to long and add rotation/translation functions for Item
1 parent 83a504a commit 41b0616

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libnest2d_js/libnest2d_js.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ EMSCRIPTEN_DECLARE_VAL_TYPE(DoubleList);
3535
// Helper function to convert a Point to a JavaScript object
3636
emscripten::val pointToJSObject(const Point& point) {
3737
emscripten::val obj = emscripten::val::object();
38-
obj.set("x", getX(point));
39-
obj.set("y", getY(point));
38+
obj.set("x", long{ static_cast<long>(getX(point)) } );
39+
obj.set("y", long{ static_cast<long>(getY(point)) } );
4040
return obj;
4141
}
4242

@@ -167,6 +167,8 @@ EMSCRIPTEN_BINDINGS(libnest2d_js) {
167167
.function("boundingBox", &Item::boundingBox)
168168
.function("translate", &Item::translate)
169169
.function("rotate", &Item::rotate)
170+
.function("rotation", optional_override([](const Item& self) { return self.rotation(); }))
171+
.function("translation", optional_override([](const Item& self) { return self.translation(); }))
170172
.function("isFixed", &Item::isFixed)
171173
.function("isDisallowedArea", &Item::isDisallowedArea)
172174
.function("markAsFixedInBin", &Item::markAsFixedInBin)

0 commit comments

Comments
 (0)