rplotrgl.obj

Can't covisualise objects in same plot using plot3d()


Normally, this is fairly straight forward to acheive, however it is not working for .obj files I have read into R. One plot simply overwrites the preceding plot. Here is the code:

#read .obj files into R
fillskel_dnp=read.neuron("C:\\Users\\usr\\Dropbox\\WRITE.NEURON\\FILL TRACE\\DNP.obj")
fillskel=read.neuron("C:\\Users\\usr\\Dropbox\\WRITE.NEURON\\FILL TRACE\\fillobjnew.obj")

#process .obj files
fillskel.hbum=xform_brain(fillskel, reference = 'JRCFIB2018F', sample=T1, via=JFRC2)
fillskel.hbum_dnp=xform_brain(fillskel_dnp, reference = 'JRCFIB2018F', sample=JRC2018U, via=JFRC2)

#plot
open3d()
plot3d(fillskel.hbum, type='wire', col='black', lwd=3)
plot3d(fillskel.hbum_dnp,type='wire', col='Red', lwd=3)

Any help would be greatly appreciated!


Solution

  • Generally speaking plot3d clears the window (or moves to the next frame) before plotting. If you don't want that to happen, use the add = TRUE argument, i.e. your last commands should be

    #plot
    open3d()
    plot3d(fillskel.hbum, type='wire', col='black', lwd=3)
    plot3d(fillskel.hbum_dnp,type='wire', col='Red', lwd=3, add = TRUE)