Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the getVertices example may be outdated #1

Open
madjestic opened this issue Aug 10, 2023 · 2 comments
Open

the getVertices example may be outdated #1

madjestic opened this issue Aug 10, 2023 · 2 comments

Comments

@madjestic
Copy link

getVertices :: Gltf -> [V3 Float]
getVertices gltf = concatMap getVertices' (gltf ^. _meshes)
  where getVertices' mesh = concatMap (^. _meshPrimitivePositions) (mesh ^. _meshPrimitives)

produces the following error:

    • Couldn't match type: vector-0.12.3.1:Data.Vector.Vector
                             (V3 Float)
                     with: [b]
      Expected: Getting [b] MeshPrimitive [b]
        Actual: (vector-0.12.3.1:Data.Vector.Vector (V3 Float)
                 -> Data.Functor.Const.Const
                      [b] (vector-0.12.3.1:Data.Vector.Vector (V3 Float)))
                -> MeshPrimitive -> Data.Functor.Const.Const [b] MeshPrimitive
    • In the expression: _meshPrimitivePositions
      In the first argument of ‘concatMap’, namely
        ‘(^. _meshPrimitivePositions)’
      In the expression:
        concatMap (^. _meshPrimitivePositions) (mesh ^. _meshPrimitives)
    • Relevant bindings include
        getVertices' :: Mesh -> [b] (bound at app/Mandelbrot_glTF.hs:380:9)
    |
380 |   where getVertices' mesh = concatMap (^. _meshPrimitivePositions) (mesh ^. _meshPrimitives)
@madjestic
Copy link
Author

This seems to work:

import           Text.GLTF.Loader as Gltf
import           Lens.Micro
import           Linear.V3
import qualified Data.Vector as V

getVertices :: Gltf -> V.Vector (V3 Float)
getVertices gltf = V.concatMap getVertices' (gltf ^. _meshes)
  where getVertices' mesh = V.concatMap (^. _meshPrimitivePositions) (mesh ^. _meshPrimitives)

@sgillespie
Copy link
Owner

You're right, I never updated the docs after I switched to Vectors. Feel free to open a PR with the updated example. If not I'll eventually get to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants