Skip to content

Commit

Permalink
Fix constraints parameter parsing out of save files (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
shueja authored Nov 12, 2023
1 parent c32aa0a commit 18ccb09
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/document/ConstraintStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ const defineConstraintStore = (
.actions((self) => {
let x: ModelActions = {};
Object.keys(definition.properties).forEach((key) => {
if (key.length == 0) {
return;
}
let upperCaseName = key[0].toUpperCase() + key.slice(1);
x[`set${upperCaseName}`] = (arg0: number) => {
self[key] = arg0;
Expand Down
16 changes: 15 additions & 1 deletion src/document/HolonomicPathStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,24 @@ export const HolonomicPathStore = types
return { uuid: self.waypoints[savedId].uuid as string };
}
};
self.addConstraint(
let constraint = self.addConstraint(
constraintStore,
saved.scope.map((id) => savedWaypointIdToWaypointId(id))
);

Object.keys(constraint?.definition.properties ?? {}).forEach(
(key) => {
if (
Object.hasOwn(saved, key) &&
typeof saved[key] === "number" &&
key.length >= 1
) {
let upperCaseName = key[0].toUpperCase() + key.slice(1);
//@ts-ignore
constraint[`set${upperCaseName}`](saved[key]);
}
}
);
}
});
self.generated.clear();
Expand Down

0 comments on commit 18ccb09

Please sign in to comment.