commit e4c3c85d601b06ee227dd779d60bc555d3edb5bc
parent 9e73702858fdbbc3ca0e4ef8d66ca526d9a48b44
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Tue, 15 Oct 2024 17:38:35 -0700
Use range for furniture rotation
In the end I want to have rotation done by a handle on the furniture,
but this is an easy change to make for the time being so that I can
focus on other priorities.
Diffstat:
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/files/floorplans/floorplan/main.js b/files/floorplans/floorplan/main.js
@@ -1058,7 +1058,7 @@ function furnitureMenuX(editor, pointOrID) {
menuItem("variety", "Variety"),
menuItem("width", "Width", { attributes: { value: userLength(editor, params.width), required: true } }),
menuItem("depth", "Depth", { attributes: { value: userLength(editor, params.depth), required: true } }),
- menuItem("angle", "Angle", { attributes: { value: params.angle ?? 0, min: 0, max: 359, step: 1, type: "number", required: true } })
+ menuItem("angle", "Angle", { attributes: { value: params.angle ?? 0, min: 0, max: 359, step: 1, type: "range", required: true } })
]
let keys = {}
for (let i in items) {
@@ -1186,9 +1186,25 @@ function furnitureMenuX(editor, pointOrID) {
params[ev.target.name] = null
} else {
if (ev.target.name === "angle") {
- ev.target.value %= 360
+ let a
+ if (ev.target.value.length === 0) {
+ a = 0
+ } else {
+ const snapOn = 45
+ const snapAt = 12
+ a = ev.target.value
+ let d = (a % snapOn)
+ if (d < snapAt) {
+ a -= d
+ } else if (d > (snapOn - snapAt)) {
+ a -= d - snapOn
+ }
+ a %= 360
+ }
+ params[ev.target.name] = a
+ } else {
+ params[ev.target.name] = ev.target.value.length === 0 ? null : ev.target.value
}
- params[ev.target.name] = ev.target.value.length === 0 ? null : ev.target.value
}
if (ev.target.name === "type") {
newVariety()