diff --git a/src/main/plexus/core.clj b/src/main/plexus/core.clj index bf407af..4faf49c 100644 --- a/src/main/plexus/core.clj +++ b/src/main/plexus/core.clj @@ -69,8 +69,9 @@ along the x axis by negative `:curve-radians`. opts - `:angle` - number of radians to cufve. - `:curve-radius` - radius of the curve." + `:angle` - number of radians to curve. + `:curve-radius` - radius of the curve. + `:arc-length` - Arc length of the curve (exclusive with `:angle`)." schema/curve-schema) (defop right @@ -194,13 +195,7 @@ opts `:name` (required) A keyword or string naming the frame. `:cross-section` (optional) Cross-section to associate with the - current frame. - - Options that specify default values to for future extrusion segments applied to this frame: - - `:cs` (optional) specifies the default number of circular segments to each - curved extrusion. - `:curve-radius` (optional) Default curve-radius of future segments applied to this frame." + current frame." schema/frame-schema) (defop save-transform diff --git a/src/main/plexus/impl.clj b/src/main/plexus/impl.clj index 38de686..a75ed0a 100644 --- a/src/main/plexus/impl.clj +++ b/src/main/plexus/impl.clj @@ -223,7 +223,6 @@ (assoc form :cross-section (:cross-section (get frames replace))) form) default-frame-id (:default-frame state) - _ default-frame-id default-frame (get frames default-frame-id) default-frame-transform (m/compose-frames (:frame-transform default-frame) @@ -233,13 +232,13 @@ (assoc frame :segment-transform (m/compose-frames - (m/invert-frame (:frame-transform frame)) - default-frame-transform)) + (m/invert-frame (:frame-transform frame)) + default-frame-transform)) (assoc default-frame :segments [] :segment-transform (m/frame 1) :frame-transform default-frame-transform)) - (select-keys form [:name :cross-section :curve-radius]))) + (select-keys form [:name :cross-section :curve-radius]))) (or (:meta form) {}))] (recur (cond-> (-> state (assoc :default-frame frame-id) @@ -384,10 +383,13 @@ (into result-forms (:result-forms form)))) (:plexus.impl/left :plexus.impl/right :plexus.impl/up :plexus.impl/down) - (let [{:keys [curve-radius angle to op transform-step-fn props gap cs] + (let [{:keys [curve-radius angle to op transform-step-fn props gap cs arc-length] :or {transform-step-fn (fn [tf angle] tf) cs 20}} form - apply-to (if to (set to) current-frame-ids)] + apply-to (if to (set to) current-frame-ids) + angle (if angle + angle + (/ arc-length curve-radius))] (recur state forms (reduce @@ -405,6 +407,9 @@ (f (sign r)) (tf/go-forward d) (f (sign (- angle r)))) + is-gap (or (true? gap) + (and (sequential? gap) (contains? (set gap) frame-id))) + cross-section (and (not is-gap) (:cross-section frame)) all-tfs (if gap [] (all-transforms start-transform @@ -417,9 +422,6 @@ angle cs transform-step-fn)) - is-gap (or (true? gap) - (and (sequential? gap) (contains? (set gap) frame-id))) - cross-section (and (not is-gap) (:cross-section frame)) manifold (when cross-section (-> cross-section (m/rotate 180) @@ -452,7 +454,9 @@ :plexus.impl/translate (let [{:keys [x y z to global?]} form - apply-to (if to (set to) current-frame-ids)] + apply-to (if to + (set to) + (conj current-frame-ids (:default-frame state)))] (recur state forms (reduce @@ -466,13 +470,15 @@ (DoubleVec3. (or x 0) (or y 0) (or z 0)))) (update frame :segment-transform m/translate [(or x 0) (or y 0) (or z 0)]))))) frames - (conj apply-to (:default-frame state))) + apply-to) result-forms)) :plexus.impl/rotate (let [{:keys [x y z to]} form - apply-to (if to (set to) current-frame-ids)] + apply-to (if to + (set to) + (conj current-frame-ids (:default-frame state)))] (recur state forms (reduce @@ -484,7 +490,7 @@ (* 1 (or y 0)) (* 1 (or z 0))])))) frames - (conj apply-to (:default-frame state))) + apply-to) result-forms)) :plexus.impl/segment diff --git a/src/main/plexus/schema.clj b/src/main/plexus/schema.clj index 55ecc81..13746ec 100644 --- a/src/main/plexus/schema.clj +++ b/src/main/plexus/schema.clj @@ -7,6 +7,7 @@ (def curve-schema [:map [:angle {:optional true} number?] + [:arc-length {:optional true} number?] [:curve-radius {:optional true} number?] [:transform-step-fn {:optional true} fn?]])