rdeits / MeshCat.jl

WebGL-based 3D visualizer in Julia
MIT License
233 stars 43 forks source link

Unable to load cat mesh in demo notebook #154

Closed lhcubillos closed 4 years ago

lhcubillos commented 4 years ago

Hi! I'm trying this amazing project, but one cell of the demo notebook doesn't work as expected. When trying to load the cat mesh, the cell states:

using MeshIO
using FileIO
cat_mesh = load(joinpath(dirname(pathof(GeometryTypes)), "..", "test", "data", "cat.obj"))
setobject!(vis, cat_mesh)
settransform!(vis, LinearMap(AngleAxis(pi/2, 1, 0, 0)))

On the setobject!(vis, cat_mesh), the REPL throws the following error:

ERROR: MethodError: no method matching setobject!(::Visualizer, ::GeometryBasics.Mesh{3,Float32,GeometryBasics.Ngon{3,Float32,3,GeometryBasics.PointMeta{3,Float32,GeometryBasics.Point{3,Float32},(:uv, :normals),Tuple{GeometryBasics.Vec{2,Float32},GeometryBasics.Vec{3,Float32}}}},FaceView{GeometryBasics.Ngon{3,Float32,3,GeometryBasics.PointMeta{3,Float32,GeometryBasics.Point{3,Float32},(:uv, :normals),Tuple{GeometryBasics.Vec{2,Float32},GeometryBasics.Vec{3,Float32}}}}}})
Closest candidates are:
  setobject!(::AbstractVisualizer, ::Union{AbstractGeometry, AbstractMesh, MeshFileGeometry}) at /home/lhcubillos/.julia/packages/MeshCat/nXUuG/src/abstract_visualizer.jl:12
  setobject!(::AbstractVisualizer, ::Union{AbstractGeometry, AbstractMesh, MeshFileGeometry}, ::AbstractMaterial) at /home/lhcubillos/.julia/packages/MeshCat/nXUuG/src/abstract_visualizer.jl:13
  setobject!(::Visualizer, ::AbstractObject) at /home/lhcubillos/.julia/packages/MeshCat/nXUuG/src/visualizer.jl:187
Stacktrace:
 [1] top-level scope at REPL[52]:1

I was able, though, to load the cat mesh using the following command:

setobject!(vis,MeshFileGeometry(joinpath(dirname(pathof(GeometryTypes)), "..", "test", "data", "cat.obj")));

Is it a problem with my configurations and/or packages, or with the notebook? I just started developing with Julia, so it's very likely it will be just a noob mistake.

Thank you!

rdeits commented 4 years ago

No, it's not you--something recently broke in one of our dependencies. I should be able to fix it tonight...

lhcubillos commented 4 years ago

Thank you!

rdeits commented 4 years ago

Can you verify that pinning MeshIO to v0.3.2 fixes the problem? You can do that by running:

]pin MeshIO@0.3.2

in the Julia REPL or in a notebook cell (note the leading ] character). You'll need to restart Julia or restart your jupyter kernel for the change to take effect.

lhcubillos commented 4 years ago

Yep, that solves it. Should I use that version from now on?

rdeits commented 4 years ago

Yeah, that's a good idea for now. MeshIO recently switched from using GeometryTypes to using GeometryBasics, which represents the same data with a new set of types. I'll have to decide how to make MeshCat work well with the newer versions, but for now using an old version of MeshIO (any version prior to v0.4.0) should be fine.

rdeits commented 4 years ago

Closing this now: MeshCat.jl now explicitly declares compatibility with MeshIO 0.3.x, so you should get a compatible version of MeshIO automatically.