stur86 / crystvis-js

A Three.js based crystallographic visualisation tool
https://stur86.github.io/crystvis-js/
MIT License
15 stars 7 forks source link

Demo errors when loading CIF files #17

Open elichad opened 3 years ago

elichad commented 3 years ago

When loading CHA.cif or org.cif from the test files on the demo page:

Uncaught TypeError: Cannot read property 'find' of null
    at FileReader.reader.onload

Relates to this line.

The H2O.xyz file works fine so I assume this is a CIF issue.

stur86 commented 3 years ago

I can't reproduce this, can you give me more information?

elichad commented 3 years ago
Uncaught TypeError: Cannot read property 'find' of null
    at FileReader.reader.onload (demo.js:319223)
reader.onload @ demo.js:319223
load (async)
window.loadFile @ demo.js:319215
onclick @ (index):35

I dug a bit and it looks like there's an error coming from crystcif-parse on load:

Invalid loop - values must be a multiple of tags

Aaaaand it's a problem with line endings. My copy of CHA.cif got converted to CRLF endings, and crystcif-parse doesn't work with those. I switched to LF and it loads.

Sidenote: the loader should fail loudly if it can't load the file! The rest of the code was trying to work with empty/undefined variables since the loader failed, hence the cryptic original message.