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

Unable to setobject! in atframe #134

Open
dmillard opened this issue Dec 5, 2019 · 5 comments
Open

Unable to setobject! in atframe #134

dmillard opened this issue Dec 5, 2019 · 5 comments

Comments

@dmillard
Copy link

dmillard commented Dec 5, 2019

MWE:

using MeshCat    
using GeometryTypes    
                                                                                                               
vis = Visualizer()    
open(vis)    
                                                                                                               
function test!(vis)                                                                                                               
  anim = Animation()    
  for i in 1:10                                                                                                                                         
    atframe(anim, i) do    
      marker = Sphere(Point3(0., 0., 0.), i/10)    
      setobject!(vis, marker)    
    end    
  end    
  setanimation!(vis, anim)    
end    
                                                                                                               
test!(vis)

Output:

ERROR: LoadError: type DataType has no field body
Stacktrace:
 [1] getproperty at ./Base.jl:15 [inlined]
 [2] call at /home/drm/.julia/packages/Cassette/YCOeN/src/context.jl:447 [inlined]
 [3] fallback at /home/drm/.julia/packages/Cassette/YCOeN/src/context.jl:445 [inlined]
 [4] overdub at /home/drm/.julia/packages/Cassette/YCOeN/src/context.jl:271 [inlined]
 [5] typename at ./essentials.jl:294 [inlined]
 [6] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(Base.typename), ::Type{ColorTypes.RGB}) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [7] typename at ./essentials.jl:294 [inlined]
 [8] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(Base.typename), ::Type{ColorTypes.RGB}) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [9] basetype at /home/drm/.julia/packages/ColorTypes/TvB32/src/traits.jl:156 [inlined]
 [10] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(ColorTypes.basetype), ::Type{ColorTypes.RGB}) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [11] base_colorant_type at /home/drm/.julia/packages/ColorTypes/TvB32/src/traits.jl:157 [inlined]
 [12] eltypes_supported at /home/drm/.julia/packages/ColorTypes/TvB32/src/traits.jl:97 [inlined]
 [13] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(ColorTypes.eltypes_supported), ::Type{ColorTypes.RGB}) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [14] issupported at /home/drm/.julia/packages/ColorTypes/TvB32/src/traits.jl:102 [inlined]
 [15] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(ColorTypes.issupported), ::Type{ColorTypes.RGB}, ::Type{Float32}) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [16] pick_eltype at /home/drm/.julia/packages/ColorTypes/TvB32/src/traits.jl:296 [inlined]
 [17] ccolor at /home/drm/.julia/packages/ColorTypes/TvB32/src/traits.jl:279 [inlined]
 [18] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(ColorTypes.ccolor), ::Type{ColorTypes.RGB}, ::Type{ColorTypes.RGBA{Float32}}) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [19] convert at /home/drm/.julia/packages/ColorTypes/TvB32/src/conversions.jl:7 [inlined]
 [20] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(convert), ::Type{ColorTypes.RGB}, ::ColorTypes.RGBA{Float32}) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [21] lower at /home/drm/.julia/packages/MeshCat/GMobF/src/lowering.jl:215 [inlined]
 [22] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(MeshCat.lower), ::MeshCat.GenericMaterial) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [23] lower at /home/drm/.julia/packages/MeshCat/GMobF/src/lowering.jl:21 [inlined]
 [24] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(MeshCat.lower), ::Object{HyperSphere{3,Float64},MeshCat.GenericMaterial}) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [25] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(MeshCat.lower), ::MeshCat.SetObject{Object{HyperSphere{3,Float64},MeshCat.GenericMaterial}}) at /home/drm/.julia/packages/MeshCat/GMobF/src/lowering.jl:265
 [26] send at /home/drm/.julia/packages/MeshCat/GMobF/src/visualizer.jl:110 [inlined]
 [27] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::typeof(MeshCat.send), ::MeshCat.CoreVisualizer, ::MeshCat.SetObject{Object{HyperSphere{3,Float64},MeshCat.GenericMaterial}}) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [28] setobject! at /home/drm/.julia/packages/MeshCat/GMobF/src/visualizer.jl:164 [inlined]
 [29] setobject! at /home/drm/.julia/packages/MeshCat/GMobF/src/abstract_visualizer.jl:12 [inlined]
 [30] #3 at /tmp/MWE.jl:12 [inlined]
 [31] overdub(::Cassette.Context{nametype(AnimationCtx),Tuple{Animation,Int64},Nothing,getfield(Cassette, Symbol("##PassType#373")),Nothing,Nothing}, ::getfield(Main, Symbol("##3#4")){Visualizer,Int64}) at /home/drm/.julia/packages/Cassette/YCOeN/src/overdub.jl:0
 [32] atframe at /home/drm/.julia/packages/MeshCat/GMobF/src/atframe.jl:58 [inlined]
 [33] test!(::Visualizer) at /tmp/MWE.jl:10
 [34] top-level scope at /tmp/MWE.jl:18
 [35] include at ./boot.jl:328 [inlined]
 [36] include_relative(::Module, ::String) at ./loading.jl:1094
 [37] include(::Module, ::String) at ./Base.jl:31
 [38] exec_options(::Base.JLOptions) at ./client.jl:295
 [39] _start() at ./client.jl:464
in expression starting at /tmp/MWE.jl:18
@dmillard
Copy link
Author

dmillard commented Dec 5, 2019

Really, I'm not sure that this is even a supported use-case, but I'm trying to update a LineSegment object once per frame, and can't think of a better way to do it than setobject! inside the atframe.

Thanks for meshcat, it's a pleasure to use.

@rdeits
Copy link
Owner

rdeits commented Jan 8, 2020

Hey, sorry for the late reply. Yes, you're right this doesn't work, but we should give a more helpful error message.

The problem is that, as far as I know, there's no way to cause Three.js to spawn an object as part of an animation. Instead, I think you should be able to get this to work by adding the object ahead of time and then setting the visible property at the relevant frame.

@dmillard
Copy link
Author

Thanks for the feedback! For my use case, that seems like quite a lot of hidden objects sitting around, but I'll keep it in mind.

@rdeits
Copy link
Owner

rdeits commented May 24, 2020

The animation demo notebook now more explicitly talks about using setvisible! to create objects that appear to pop in and out of existence in an animation: https://github.com/rdeits/MeshCat.jl/blob/master/notebooks/animation.ipynb#Making-Objects-Appear-and-Disappear

@ga72kud
Copy link

ga72kud commented Jan 10, 2023

@rdeits is this workaround also suitable for large datasets like visualizing huge LIDAR datasets? I come to the same error message with "> type DataType has no field body" and want to test it by changing my code with setvisible!...

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

3 participants