nglviewer / ngl

WebGL protein viewer
http://nglviewer.org/ngl/
MIT License
669 stars 170 forks source link

Feature Request: stereoscopic 3D mode. #303

Open daniel-adriano opened 7 years ago

daniel-adriano commented 7 years ago

A way to enable stereoscopic mode for jupyter notebooks? For example: two parallel (side by side) views for left and right eye; cyan/red; interleaved; etc.

arose commented 7 years ago

Can be based on https://github.com/mrdoob/three.js/blob/dev/examples/js/effects/AnaglyphEffect.js. Would suggest to implement in the NGL viewer class by adding the necessary texture targets and shader.

ppillot commented 7 years ago

Not sure if it's relevant, but here is molmil's anaglyph shader code

arose commented 7 years ago

I suggest to go with the three.js one, whose math is based on https://github.com/tschw/angler.js/

cccsander commented 6 years ago

We'd love to have simple cross-eyed stereo view - for both cBioPortal.org (showing cancer relevant mutations in 3D protein) as well as EVfold.org (protein 3D structure prediction using evolutionary couplings from multiple sequence alignments)

arose commented 6 years ago

Hi, I just added a first version for a stereo view to NGL. You can try it on http://nglviewer.org/ts2/. Accessible as a new camera option 'stereo'. Note that the stereo camera currently does not support picking and super sample anti aliasing.

felimoles commented 6 years ago

hi, stereo divide the camera in two, its possible add the three.js and use the propiety "anaglyph"?

arose commented 6 years ago

@newzhongdan not directly but you could use the three.js implementation as a starting point to add it to NGL

KJStrand commented 6 years ago

I created a proof of concept component for A-Frame to allow more complex view setups and VR/AR headsets: https://github.com/KJStrand/ngl/blob/AFRAME-NGL/AFRAME_COMPONENT.md As an A-Frame component, NGL could much more easily extended for custom use cases: https://blog.bluepengu.in/a-new-scratchpad-for-science-e9901955db96

fredludlow commented 6 years ago

Like it! As most of the changes are to stage and viewer classes I wonder if an AFrameStage could avoid breaking the normal behaviour, or make sufficient changes in NGL that a small shim package could implement the A-frame behaviour? (I've not thought this through much, just thinking aloud...).

KJStrand commented 6 years ago

Yes I think the changes could be kept to a minimum. My code changes are pretty hacked together; I don't have a good enough understanding yet of the NGL render pipeline so I commented out camera render code to suppress errors, and some of the shaders (such as the impostor shader) aren't correctly set up with the A-Frame camera. A-Frame maintains its own Three scene, so it would be best for an NGL A-Frame component to link geometry directly to the existing scene and not create a viewport div, cameras, lights, or interactions. Trajectory animations should also be changed to connect directly to A-Frame's tick handler: https://aframe.io/docs/0.8.0/core/component.html#tick-time-timedelta. I think text is also causing some issues and not displaying correctly in A-Frame.

Custom mouse behaviors and camera setups could still be applied, maybe even as A-Frame components themselves.

thomashopf commented 4 years ago

@arose For the stereoscopic mode, is there a setting that would allow to change the angle between the two individual structure views?

Thanks!