-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Feat sdf loader #31140
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
base: dev
Are you sure you want to change the base?
Feat sdf loader #31140
Conversation
…molecule-rendering Add SDFLoader for Molfile support
- Improved readability and maintainability of the SDFLoader code. - Added error handling for invalid atom and bond data in the parsing process. - Included detailed JSDoc comments for the SDFLoader class. - Updated unit tests to include SDFLoader tests.
…, example update, and export in Addons.js
examples/jsm/loaders/SDFParser.js
Outdated
* @param {string} text - Raw SDF or MOL text content. | ||
* @returns {Object} Parsed molecule data with `atoms` and `bonds` arrays. | ||
*/ | ||
function parseSDF( text ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As suggested at the forum, I vote to move this bit out of the library into a separate repository:
https://discourse.threejs.org/t/why-is-there-a-pdb-loader-and-no-sdf-loader/82861/2
You are ignoring many SDF properties right now that might be relevant for other use cases in the future.
* | ||
* @see examples/webgl_loader_sdf | ||
*/ | ||
class SDFLoader extends Loader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote to remove SDFLoader
and implement the JSON parsing right in the example. The loader contains too much application specific code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SDF parsing library could be imported like in other examples:
three.js/examples/webgl_loader_ifc.html
Lines 26 to 28 in c6e73de
"three-mesh-bvh": "https://cdn.jsdelivr.net/npm/[email protected]/build/index.module.js", | |
"web-ifc": "https://cdn.jsdelivr.net/npm/[email protected]/web-ifc-api.js", | |
"web-ifc-three": "https://cdn.jsdelivr.net/npm/[email protected]/IFCLoader.js" |
New example: https://raw.githack.com/jakekinchen/three.js/feat-sdf-loader/examples/webgl_loader_sdf.html Tip: Metals require an environment map. I'd suggest removing the lights and adding |
… current implementation
What
Adds native support for MDL Molfile / SDF data to three.js via an enhanced
SDFLoader
.THREE.Group
.Why
Many chemistry / materials projects store molecules as SDF.
Until now developers had to:
This PR removes that barrier and lets pure-JS (Next.js, Vite, etc.) apps visualise SDF files out-of-the-box, just like PDB files.
Highlights
SDFLoader.js
; no new export or dependency added to the Addons bundle.SDFLoader.tests.js
updated; all addon tests pass.examples/webgl_loader_sdf.html
demonstrates direct SDF loading with atom labels.Usage
Screenshots
Implementation Notes
parse()
to keep scope local and avoid public API surface increase.setElementData()
.Happy to adjust naming, structure or docs as requested by maintainers — thanks for reviewing!