1
votes

I parse obj file and try to substitute vertices in f instead of ordinal numbers.

Example f:

[[{:v 1 :vt 1 :vn 1} {:v 2 :vt 2 :vn 2} {:v 3 :vt 3 :vn 3}]
 ...]

But I have error

java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$map$fn__5583

in line

{:v (nth v-list (dec v)) :vt (get vt-list (dec vt)) :vn (nth vn-list (dec vn))}

How I can fix it? Thanks.

My code:

(defn fill-vertex [{:keys [v vt vn]} v-list vt-list vn-list]
  {:v (nth v-list (dec v)) :vt (get vt-list (dec vt)) :vn (nth vn-list (dec vn))})

(defn fill-triangle [triangle v vt vn]
  (map #(fill-vertex % v vt vn) triangle))

(defn to-f-list [{:keys [f v vt vn matrix]}]
  (let [v-u (->> v (map #(add-perspective % matrix) (map #(viewport %))))
        vn-u (map #(add-perspective % matrix) vn)]
    (map #(fill-triangle % v-u vt vn-u) f)))
1
Could you please include a minimal, complete working example? (i.e. please include the definition of add-perspective and the top-level function call that triggers the error.) That will help people help you. - Ashton Wiersdorf

1 Answers

4
votes
(->> v (map #(add-perspective % matrix) (map #(viewport %))))

is the same as

(map #(add-perspective % matrix) (map #(viewport %)) v)

But

(map #(viewport %))

Is not a sequence, it is a transducer function.

You probably meant it to be:

(->> v (map #(add-perspective % matrix)) (map #(viewport %)))

It's hard to spot debug this kind of mistake when you put multiple operations on one line, so I encourage you to use a line break

(->> v
     (map #(add-perspective % matrix))
     (map #(viewport %)))

It makes it easier to follow the steps, and thus the grouping.