bwlewis / rthreejs

Three.js widgets for R and shiny
http://bwlewis.github.io/rthreejs
Other
303 stars 64 forks source link

Brain network ideas? #77

Open seantma opened 6 years ago

seantma commented 6 years ago

@bwlewis Thank you for this great package that helps convey ideas on paper onto visual graphs that is approachable.

I'm trying to use rthreejs to render some brain activity networks under a glass brain for interactive purposes. After searching the threejs website and forum, most of the brain related projects are focused on rendering surfaces.

My idea is rather to combine graphjs() with globejs() without the globe but substitute it with a glass brain that has its own 3d coordinates.

Any suggestions or pointers where I can get started? Many thanks!

Sean

bwlewis commented 6 years ago

Hmmm. I think instead of globejs, a rather hacky function, one approach might be to plot points in 3d with scatterplot3js (graphjs actually calls scatterplot3js under the hood).

the thing to add would be the three-d glass brain image. That would require additions to the JavaScript code. One possibility is to add the ability to import a 3d texture from a file or url, for example x3d (https://en.wikipedia.org/wiki/X3D). See this example:

https://threejs.org/examples/#webgl_loader_x

For example, maybe add an option to the R scatterpot3js function like x3d="file.x" or whatever. Then just display that 3d texture in the scatterplot, probably as a new THREE.Object3d(). You could then layer whatever points/lines you want over that.

Just a thought...

Note that the globejs() function is much dumber. It maps a 2-d image onto a sphere only, and is not capable of displaying generic 3d textures.

bwlewis commented 6 years ago

Check this experimental function out render:

devtools::install_github("bwlewis/rthreejs")
threejs::render(gzfile(system.file("extdata/pump.json.gz", package="threejs")), bg="black")

Also see ?threejs::render.

Right now, this is a super-basic implementation that just displays a JSON-encoded threejs scene. The plan is to add a few basic functions to help build threejs scenes up easily from R. Then we can visualize and animate just about anything. This is similar to R's rgl package, but with a threejs focus.

What do you think of this approach?

Would anyone like to help add some functions to help build up threejs scenes from R?