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

Ability to pass optional WebGLRendererParameters #3

Open
patrick-austin opened this issue Dec 9, 2022 · 2 comments
Open

Ability to pass optional WebGLRendererParameters #3

patrick-austin opened this issue Dec 9, 2022 · 2 comments

Comments

@patrick-austin
Copy link

By default the WebGLRenderer is called with no arguments:

this._r = new THREE.WebGLRenderer();

It would be good to have the option to pass WebGLRendererParameters to this function (via the constructor for Renderer and Crystvis). Specifically, to integrate with the existing screenshot functionality within muon-spectroscopy-computational-project/muon-galaxy#12, preserveDrawingBuffer would need to be set to true, which is not currently possible.

jkshenton added a commit that referenced this issue Mar 15, 2023
@jkshenton
Copy link
Member

I've (finally) added this ability, I think. Could you give it a go and see if it solves your issue?

@patrick-austin
Copy link
Author

Thanks so much for adding this, and the other stuff with file format/lattice vector support. In terms of the ability to pass preserveDrawingBuffer: this works for me and I'm able to generate screenshots inside Galaxy's "infrastructure", which is great.

I did however, run into another issue which I can't quite understand. When loading files using the demo, everything goes fine. But when loading via the Galaxy visualiser, it was throwing an (uncaught) error here (for multiple structures in various formats):

crystvis-js/lib/model.js

Lines 934 to 936 in 4c69eec

if (!(atoms instanceof Atoms)) {
throw new Error('Model must be initialised with a loaded Atoms object');
}

I added logging in both places and got the following for Galaxy:

Object { _arrays: {}, _N: 8, _pbc: (3) [], _inv_cell: (3) [], _cell: (3) [], info: {} }
​
_N: 8
​
_arrays: Object { symbols: (8) [], numbers: (8) [], positions: (8) [] }
​
_cell: Array(3) [ (3) [], (3) [], (3) [] ]
​
_inv_cell: Array(3) [ (3) [], (3) [], (3) [] ]
​
_pbc: Array(3) [ true, true, true ]
​
info: Object {  }<prototype>: Object { length: length(), set_array: set_array(e, t), get_array: get_array(e)
,  }
​​
get_array: function get_array(e)​​
get_atomic_numbers: function get_atomic_numbers()​​
get_cell: function get_cell()​​
get_chemical_symbols: function get_chemical_symbols()​​
get_inv_cell: function get_inv_cell()​​
get_pbc: function get_pbc()​​
get_positions: function get_positions()​​
get_scaled_positions: function get_scaled_positions()​​
length: function length()​​
set_array: function set_array(e, t)​​
<prototype>: Object {  }

And the following for the demo:

Object { _arrays: {}, _N: 8, _pbc: (3) [], _inv_cell: (3) [], _cell: (3) [], info: {} }
​
_N: 8
​
_arrays: Object { symbols: (8) [], numbers: (8) [], positions: (8) [] }
​
_cell: Array(3) [ (3) [], (3) [], (3) [] ]
​
_inv_cell: Array(3) [ (3) [], (3) [], (3) [] ]
​
_pbc: Array(3) [ true, true, true ]
​
info: Object {  }<prototype>: Object { length: length(), set_array: set_array(name280, arr), get_array: get_array(name280)
,  }
​​
get_array: function get_array(name280)​​
get_atomic_numbers: function get_atomic_numbers()​​
get_cell: function get_cell()​​
get_chemical_symbols: function get_chemical_symbols()​​
get_inv_cell: function get_inv_cell()​​
get_pbc: function get_pbc()​​
get_positions: function get_positions()​​
get_scaled_positions: function get_scaled_positions()​​
length: function length()​​
set_array: function set_array(name280, arr)​​
<prototype>: Object {  }

I do not understand why it's failing the instanceof check in Galaxy, as far as I can tell it's loading everything exactly the same as the demo and (other than the variable names in the prototype functions but surely that doesn't matter when determining the type?). Once I commented the check out everything worked great.

Do you have any insight as to what might be going wrong? It's been a while since I've done js in earnest and getting Galaxy set up to use the local crystvis files gave me a lot of grief - it's possible I messed something up (maybe with the crystcif-parse import since that's where the Atoms class comes from?) and this wouldn't be an issue at all when installing a release from npm.

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

2 participants