Compare commits

...

289 Commits

Author SHA1 Message Date
Alexander Rose
2d09df55a9 3.0.0-dev.8 2021-12-31 11:42:09 -08:00
Alexander Rose
ec2554537e changelog 2021-12-31 11:37:40 -08:00
Alexander Rose
f266dfadc6 emulate round function for webgl1 compatibility 2021-12-31 11:37:02 -08:00
Alexander Rose
99048eed61 Merge pull request #323 from molstar/dv-refactor
Direct-volume refactor
2021-12-31 10:43:26 -08:00
Alexander Rose
fe63718b0c Merge branch 'master' into dv-refactor 2021-12-31 10:34:50 -08:00
Alexander Rose
2c1200433c Merge pull request #333 from molstar/surface-size-theme
Use size theme in molecular/gaussian surface & label representations
2021-12-31 10:33:46 -08:00
Alexander Rose
4a3252c929 use size theme in label repr 2021-12-30 18:17:40 -08:00
Alexander Rose
5e052174ee use size theme in molecular/gaussian surface repr 2021-12-30 18:12:53 -08:00
Alexander Rose
cda0966105 filter repr size themes to applicable types 2021-12-30 18:01:02 -08:00
Alexander Rose
c0a9716846 Merge branch 'master' of https://github.com/molstar/molstar into dv-refactor 2021-12-30 17:30:44 -08:00
Alexander Rose
18c7395f9d Merge pull request #326 from molstar/marker-fixes
Marker improvements
2021-12-30 17:29:07 -08:00
Alexander Rose
d3da79f3dd better use of StateSelection API 2021-12-30 17:18:21 -08:00
Alexander Rose
5a215daca4 remove superfluous arg from canvas3d.requestDraw 2021-12-30 17:14:07 -08:00
Alexander Rose
8527a3b3ef change canvas3d draw to use options argument 2021-12-30 17:08:28 -08:00
Alexander Rose
492dc1ba32 Merge branch 'master' of https://github.com/molstar/molstar into marker-fixes 2021-12-30 17:04:17 -08:00
Alexander Rose
305a8ca802 Merge pull request #332 from molstar/fix-331
fix gpu isosurface group id
2021-12-30 17:02:54 -08:00
Alexander Rose
6d2a35494f rename float-packing to number-packing
- more telling name
2021-12-30 17:01:23 -08:00
Alexander Rose
e76a08c73a remove unused en/decodeFloatLog 2021-12-30 16:59:39 -08:00
Alexander Rose
a0fef0c20f rename en/decodeFloatRGB
- since they only work for positive integers
- encodeFloatRGB -> packIntToRGB
- decodeFloatRGB -> unpackRGBToInt
2021-12-30 16:57:50 -08:00
Alexander Rose
605432ddd1 fix glsl decodeFloatRGB 2021-12-30 16:39:06 -08:00
Alexander Rose
0c895071d8 support axis order in direct-volume shader 2021-12-30 15:36:12 -08:00
Alexander Rose
79cd833ae6 cleanup 2021-12-30 14:37:34 -08:00
Alexander Rose
0fee928e37 fix gpu isosurface group id
- was wrong for axis order other than 012
- fixes #331
2021-12-30 13:49:08 -08:00
Alexander Rose
7f698336d7 fix webgl error in volume-streaming behavior
- don't use gpu mc for small volumes
- return empty texture-mesh for volumes of size 1 or 0
2021-12-29 18:51:55 -08:00
Alexander Rose
cef04f192a no picking during camera spinning 2021-12-29 16:54:26 -08:00
Alexander Rose
4087c4c226 changelog 2021-12-29 16:27:43 -08:00
Alexander Rose
87bdcd2372 add prefer-webgl1 & disable-wboit Viewer GET params 2021-12-29 16:03:45 -08:00
Alexander Rose
1dbcc0d7c8 Merge branch 'master' of https://github.com/molstar/molstar into dv-refactor 2021-12-29 15:42:41 -08:00
Alexander Rose
4c93f01c64 improve temporal multi-smaple handling
- add forceOn arg
- instead of letting temporal converge do full sampling
- saves one geometry pass
2021-12-28 20:39:03 -08:00
Alexander Rose
0a18412da0 refactor draw/multiSample .render args 2021-12-28 20:24:16 -08:00
Alexander Rose
b67d16bdc4 enable marking pass by default 2021-12-28 19:47:54 -08:00
Alexander Rose
976542d355 ensure mark changes are rendered (even w/ noDraw)
- schedule using forceNextRender to avoid rendering twice
2021-12-28 19:30:45 -08:00
Alexander Rose
a2e5fda646 improve temporal multi-sample rendering
- don't render all when spinning
- only render all when explicitely requested (new allowMulti arg)
2021-12-28 19:28:36 -08:00
Alexander Rose
41b1b65d5f improve SelectLoci behavior
- only handle direct children of updated objects (no update of same repr multiple times)
2021-12-28 19:25:40 -08:00
Alexander Rose
2ec2d1997f improve StructureSelectionManager.onUpdate
- only process for root structure (processing childs is superfluous)
2021-12-28 19:20:54 -08:00
Alexander Rose
0bc65f3b72 improve visual marking performance
- treat structure-loci as every-loci
2021-12-28 19:17:46 -08:00
Alexander Rose
9ed96b3599 fix getMarkersAverage edge case with small arrays 2021-12-28 19:16:08 -08:00
David Sehnal
b1cf9566f6 Merge pull request #324 from molstar/safari15-wboit
PluginFeatureDetection and disable WBOIT in Safari
2021-12-28 20:46:46 +01:00
dsehnal
983ae4f8c2 PluginFeatureDetection and disable WBOIT in Safari 2021-12-24 11:21:15 +01:00
Alexander Rose
7ce3531cc7 direct-volume define cleanup 2021-12-23 15:35:14 -08:00
Alexander Rose
11f1a7fd1c add general dGeometryType
- remove dRenderMode & dGeoTexture
2021-12-23 15:16:14 -08:00
Alexander Rose
47d7dd4d22 move direct-volume coloring into theme
- add 'direct' color type
- remove color from transfer-function (now only alpha)
- add direct-volume color theme support
- add volume-value color theme
2021-12-23 14:47:17 -08:00
Alexander Rose
0d4f6bb5d9 3.0.0-dev.7 2021-12-20 22:42:23 -08:00
Alexander Rose
b3a4e1976d changelog 2021-12-20 22:36:56 -08:00
Alexander Rose
8b3c0fd94e Merge branch 'master' of https://github.com/molstar/molstar into dv-refactor 2021-12-20 17:51:38 -08:00
Alexander Rose
ab4a24d8ab Merge pull request #310 from molstar/clipping
Per Object Clip Objects
2021-12-20 17:38:41 -08:00
Alexander Rose
7c93e9f834 changelog & fix clipping exclude group filtering 2021-12-20 17:22:15 -08:00
Alexander Rose
90ea8cfebd Merge branch 'master' of https://github.com/molstar/molstar into clipping 2021-12-20 16:49:58 -08:00
Alexander Rose
7fc1866dac Merge pull request #320 from molstar/shader-compilation
Shader compilation
2021-12-20 16:46:56 -08:00
Alexander Rose
bb520ff424 fix spec 2021-12-20 16:38:24 -08:00
Alexander Rose
f9d2e20cb9 webgl1 compat 2021-12-20 16:16:22 -08:00
Alexander Rose
6f13b67bf1 combine markingDepth/markingMask shader variants 2021-12-20 16:14:37 -08:00
Alexander Rose
f37026a980 Merge branch 'master' of https://github.com/molstar/molstar into shader-compilation 2021-12-20 14:15:06 -08:00
Alexander Rose
ddc4d8e867 3.0.0-dev.6 2021-12-19 13:15:50 -08:00
Alexander Rose
7cded03598 changelog 2021-12-19 13:11:41 -08:00
Alexander Rose
744b04edc6 add demos to deploy script
- include analytics in deployed demos
2021-12-19 13:06:41 -08:00
Alexander Rose
f2119b1d0b tweak alpha-orbitals example
- remove direct-volume option
- enable tryUseGpu for isosurface repr
2021-12-19 13:05:34 -08:00
Alexander Rose
b4783909d7 fix lighting example
- adjust to new light & material handling
2021-12-19 13:04:05 -08:00
Alexander Rose
fe5f841ab8 improve docking-viewer example
- add example pdbqt & mol2
2021-12-19 13:03:10 -08:00
Alexander Rose
2c3f0dbc97 fix missing uniform in direct-volume shader 2021-12-19 13:02:23 -08:00
Alexander Rose
224fd1733f improve aromatic bonds
- Don't detect aromatic bonds for rings < 5 atoms based on planarity
- Prefer atoms in aromatic rings as bond reference positions
2021-12-19 13:02:02 -08:00
Alexander Rose
1f262ee422 Merge pull request #321 from molstar/update-create-plugin
mol-plugin-ui/createPluginUI
2021-12-19 11:51:44 -08:00
Alexander Rose
df3bcdd05a fix embedded 2021-12-19 11:41:53 -08:00
dsehnal
d5d08542ed tweak 2021-12-19 17:36:32 +01:00
dsehnal
564a360c8f Added createPluginUI, removed createPlugin and createPluginAsync 2021-12-19 17:32:58 +01:00
Alexander Rose
74f123265b correctly set shader define flags
- overpaint, transparency, substance, clipping
2021-12-18 19:53:35 -08:00
Alexander Rose
ccfae65b01 fix tests 2021-12-18 19:29:02 -08:00
Alexander Rose
bcfaef77c9 combined pick shader variant 2021-12-18 18:11:31 -08:00
Alexander Rose
0b6243c0d1 remove log statement 2021-12-18 16:53:48 -08:00
Alexander Rose
472866d8ec support ignoring defines for shader variants 2021-12-18 16:48:56 -08:00
Alexander Rose
471163f3d8 better defaults for postprocessing pass 2021-12-18 16:44:08 -08:00
Alexander Rose
ab6106896d only include vPaletteV for color shaders 2021-12-18 16:43:48 -08:00
Alexander Rose
7ca624d04b remove dMarkerType shader define 2021-12-18 16:42:43 -08:00
Alexander Rose
bd3d18f43f use uniform for double-sided shader param 2021-12-18 16:39:15 -08:00
Alexander Rose
21eb21b6dd support variants for graphics render-itms 2021-12-18 16:32:20 -08:00
Alexander Rose
fe0d4dc11e warn (not throw) about erroneous symmetry matrix
- #303
2021-12-18 15:24:52 -08:00
Alexander Rose
812eb0efa9 Merge pull request #309 from molstar/ma-support
ModelArchive / AlphaFold support
2021-12-18 14:52:55 -08:00
Alexander Rose
10d0bf293a fix wrong method name loadAfdb 2021-12-18 14:41:38 -08:00
Alexander Rose
ce2544b9f3 add model-archive viewer helpers 2021-12-18 14:40:45 -08:00
Alexander Rose
1964de1e44 Merge branch 'master' of https://github.com/molstar/molstar into ma-support 2021-12-18 14:26:00 -08:00
Alexander Rose
20c9d2cc41 enable aromaticBonds by default 2021-12-18 14:22:21 -08:00
Alexander Rose
3b1513adc0 fix eslint warnings 2021-12-18 14:12:58 -08:00
Alexander Rose
eaa60fc5cd fix linting errors and vscode settings 2021-12-18 12:47:41 -08:00
Alexander Rose
ce1e3960a2 avoid standard polymers misqualified as ligands
- overrule erroneous chem comp type in some files
2021-12-18 12:13:36 -08:00
Alexander Rose
176f80ea9b ensure trace element for polymer residues 2021-12-18 12:09:17 -08:00
Alexander Rose
28c9dc8286 refactor Model.isFromPdbArchive
- split into isFromPdbArchive and hasPdbId
- improve when secondary structure is calculated
2021-12-18 10:45:59 -08:00
Alexander Rose
2135f76441 fix temporal multi-sample flicker, enable by default 2021-12-18 10:29:42 -08:00
Alexander Rose
5637a23153 fix unnecessary cartoon geometry recreation 2021-12-18 10:14:55 -08:00
dsehnal
2818389741 update label 2021-12-17 23:33:50 +01:00
dsehnal
805f772696 3.0.0-dev.5 2021-12-16 12:21:45 +01:00
dsehnal
308bbc1ea0 lint 2021-12-16 12:19:32 +01:00
dsehnal
4a248b5591 shouldResetCamera reset fix 2021-12-16 12:17:46 +01:00
David Sehnal
704a9a111d Merge pull request #316 from JonStargaryen/master
update State Snapshots canApply when snapshots are added
2021-12-16 11:48:15 +01:00
JonStargaryen
a6befc5509 update State Snapshots canApply when snapshots are added 2021-12-16 11:31:53 +01:00
dsehnal
9e7aa4226d CI task 2021-12-14 21:55:23 +01:00
David Sehnal
7a25699c23 Merge pull request #312 from molstar/dependabot/npm_and_yarn/swagger-ui-dist-4.1.3
Bump swagger-ui-dist from 4.1.1 to 4.1.3
2021-12-14 14:29:01 +01:00
dependabot[bot]
901ae7f6d6 Bump swagger-ui-dist from 4.1.1 to 4.1.3
Bumps [swagger-ui-dist](https://github.com/swagger-api/swagger-ui) from 4.1.1 to 4.1.3.
- [Release notes](https://github.com/swagger-api/swagger-ui/releases)
- [Commits](https://github.com/swagger-api/swagger-ui/compare/v4.1.1...v4.1.3)

---
updated-dependencies:
- dependency-name: swagger-ui-dist
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-14 13:26:49 +00:00
dsehnal
c57a4cdf6e 3.0.0-dev.4 2021-12-14 14:25:51 +01:00
dsehnal
18573e17f0 package.lock 2021-12-14 14:23:37 +01:00
dsehnal
5bc7ffa8a7 react and react-dom as peerDependencies 2021-12-14 14:17:25 +01:00
David Sehnal
430cc83259 Merge pull request #311 from molstar/upload-overlay
Drag and Drop Overlay
2021-12-14 14:11:15 +01:00
dsehnal
3cd3afb775 drag and drop overlay 2021-12-14 14:10:05 +01:00
dsehnal
93215b6beb prefer webgl 1 in Safari 15.1-15.3 2021-12-14 13:19:27 +01:00
Alexander Rose
694261c19c add ModelArchive to DownloadStructure action 2021-12-13 19:57:19 -08:00
Alexander Rose
24ad38e260 add clip support to components & focus repr 2021-12-12 18:09:26 -08:00
Alexander Rose
53bac83dff remove renderable.noClip 2021-12-12 17:59:09 -08:00
Alexander Rose
ab1578f667 move clip props to base geometry 2021-12-12 17:56:14 -08:00
Alexander Rose
4e70301b62 cleanup after merge 2021-12-12 17:27:47 -08:00
Alexander Rose
76ed2e9e11 Merge branch 'master' of https://github.com/molstar/molstar into clipping 2021-12-12 17:11:59 -08:00
Alexander Rose
58ce1f6498 Viewer.loadAfdb -> Viewer.loadAlphaFoldDb 2021-12-12 14:56:04 -08:00
Alexander Rose
47c4353eb9 use web api to get alphafold model for uniprot ac 2021-12-12 14:55:09 -08:00
Alexander Rose
d82cd3a8fe fix: do plugin ui render after context init 2021-12-12 14:45:57 -08:00
Alexander Rose
8f06b603e6 add bond location support to qmean & pLDDT color themes 2021-12-11 21:35:56 -08:00
Alexander Rose
0865c1b7fb changelog 2021-12-11 18:04:40 -08:00
Alexander Rose
c8c32b89c1 improve loading of ModelArchive schema structures
- includes AlphaFold mmcif structures
- add Viewer.loadAfdb
- add afdb GET param to Viewer html
- add Viewer default presets showing quality assessment (qmean & pLDDT)
- add alphafolddb option to download structure action
2021-12-11 17:56:26 -08:00
Alexander Rose
658c789906 tweak: use PD.arrayToOptions 2021-12-11 17:47:29 -08:00
Alexander Rose
c9ad7fce5b add PluginConfig.Structure.DefaultRepresentationPreset 2021-12-11 17:46:21 -08:00
Alexander Rose
720a8a440f tweak param comparision
- avoid unneccesary update
2021-12-11 17:42:41 -08:00
Alexander Rose
84fe2d2502 add ModelArchive extension
- QualityAssessment prop (from ma_qa_metric_local mmcif category)
- pLDDT & qmean coloring
- pLDDT & qmean repr presets
- pLDDT & qmean molql symbol
- pLDDT & qmean loci labels (including avg for mutli residue selections)
- pLDDT selection query
2021-12-11 17:40:04 -08:00
Alexander Rose
6f159c592f cleanup mmcif schema generation
- remove BRANCH and CARB extension (nwo included in mmCIF)
2021-12-11 16:57:09 -08:00
Alexander Rose
beff1ecb3e add model-archive cif schema 2021-12-11 16:40:29 -08:00
Alexander Rose
e4f630dbef improve drag and drop support
- any file type
- multiple files
- if session, only first is loaded
2021-12-11 16:37:20 -08:00
Alexander Rose
ccaf18af04 add analytics to viewer on deployment
- only for molstar.org (done in ./scripts/deploy.js)
2021-12-11 12:25:05 -08:00
Alexander Rose
2b72098f95 fix: false positives in Model.isFromPdbArchive
- wrong for, e.g., AlphaFold DB entries
2021-12-11 11:42:15 -08:00
Alexander Rose
b32546bea7 add outline color option to renderer 2021-12-11 11:30:00 -08:00
Alexander Rose
b9b0413e9f improve label repr defaults 2021-12-11 11:25:35 -08:00
David Sehnal
1d29b4627f Merge pull request #305 from MadCatX/cleanup-old-nodejs
Make cleanup script work with older vesions of Node.js
2021-12-10 12:43:08 +01:00
Michal Malý
bd44c76709 Make cleanup script work with older versions of Node.js 2021-12-10 09:36:58 +01:00
Alexander Rose
06b4761f2b add `carbonLightness` to illustrative color theme 2021-12-06 20:02:25 -08:00
Alexander Rose
daa3d1dbaa handle zero light count 2021-12-06 20:01:46 -08:00
Alexander Rose
5490d5ceb5 fixes for material bumpiness 2021-12-06 20:01:18 -08:00
dsehnal
cf3c1cfcce update Group Presets UI 2021-12-06 10:44:20 +01:00
Alexander Rose
be2607ae84 add bumpAmplitude render parameter 2021-12-05 21:29:07 -08:00
Alexander Rose
aa1f081664 remove direct-volume isosurface render-mode 2021-12-05 14:24:18 -08:00
Alexander Rose
e2966241e8 Merge pull request #299 from molstar/bump
procedural bump mapping
2021-12-05 12:42:27 -08:00
Alexander Rose
447792b1ef changelog 2021-12-05 12:30:28 -08:00
Alexander Rose
1cbcb5c530 remove duplicated line 2021-12-05 12:10:26 -08:00
Alexander Rose
f8d32d1d8d fix temp texture usage for color smoothing 2021-12-05 12:07:32 -08:00
Alexander Rose
8c556c2849 Merge branch 'master' of https://github.com/molstar/molstar into bump 2021-12-05 12:02:21 -08:00
Alexander Rose
4d0f0ceebf 3.0.0-dev.3 2021-12-04 22:23:51 -08:00
Alexander Rose
14abcddfcf changelog 2021-12-04 22:17:24 -08:00
Alexander Rose
704cc96a9f Merge pull request #300 from sukolsak/fix-export
Fix USDZ and OBJ export
2021-12-04 22:13:41 -08:00
Sukolsak Sakshuwong
b51f610173 fix USDZ and OBJ export 2021-12-04 20:08:15 -08:00
Alexander Rose
98050875c7 add bumpiness to material 2021-12-04 16:54:23 -08:00
dsehnal
470280ea1a changelog and update eslint 2021-12-01 13:29:02 +01:00
dsehnal
dafb5a8299 3.0.0-dev.2 2021-12-01 13:26:08 +01:00
dsehnal
4a1af03744 package.json fix 2021-12-01 13:23:50 +01:00
dsehnal
bb176f1efb 3.0.0-dev.1 2021-12-01 13:17:15 +01:00
dsehnal
a53bcde973 npmignore tweaks 2021-12-01 13:14:28 +01:00
David Sehnal
1a8dc2c637 Merge pull request #295 from molstar/material-object
Refactor Material Representation
2021-11-29 18:04:52 +01:00
dsehnal
f96211ff91 comment 2021-11-29 18:04:23 +01:00
dsehnal
77f9c02785 udpate presets 2021-11-29 18:01:41 +01:00
dsehnal
7910b65fdc Merge branch 'master' of https://github.com/molstar/molstar 2021-11-29 14:49:53 +01:00
dsehnal
eb4fc4588d remove console.log 2021-11-29 14:49:51 +01:00
David Sehnal
5430674071 Merge pull request #294 from MadCatX/fixtypo
Fix typo in README
2021-11-29 14:10:20 +01:00
dsehnal
17e67e3b79 Refactor Material representation 2021-11-29 14:09:56 +01:00
dsehnal
e87a0d72e4 Fix docking viewer material usage 2021-11-29 12:48:26 +01:00
dsehnal
67d3c65907 ParamDefinition.Group.presets support 2021-11-29 12:35:57 +01:00
dsehnal
564a5486c9 StructureComponentManager.Options state saving support 2021-11-29 11:57:37 +01:00
Michal Malý
9ce11c4c32 Fix typo in README 2021-11-29 11:41:57 +01:00
dsehnal
5e97b551a5 changelog 2021-11-29 11:10:30 +01:00
David Sehnal
77536e75af Merge pull request #292 from MadCatX/provide-rebuild-cmd
Add packaging command to force a full rebuild
2021-11-29 11:05:44 +01:00
Alexander Rose
6f12f714d2 3.0.0-dev.0 2021-11-28 14:02:46 -08:00
Alexander Rose
1f67077400 changelog 2021-11-28 13:56:07 -08:00
Alexander Rose
d1c4cf69cb Merge pull request #291 from molstar/lighting
Lighting
2021-11-28 13:53:42 -08:00
Alexander Rose
803c5eaa15 changelog 2021-11-28 13:39:53 -08:00
Alexander Rose
970fd5d9c3 Merge branch 'master' of https://github.com/molstar/molstar into lighting 2021-11-28 13:32:56 -08:00
Alexander Rose
7ccd4a1e0d 2.4.1 2021-11-28 13:31:12 -08:00
Michal Malý
3a6ab55266 Add a cleanup packaging script 2021-11-28 22:29:50 +01:00
Alexander Rose
eb41882c56 Merge branch 'master' of https://github.com/molstar/molstar 2021-11-28 13:25:42 -08:00
Alexander Rose
734851a810 changelog 2021-11-28 12:46:12 -08:00
Alexander Rose
6318717a15 tweak material param 2021-11-28 12:42:33 -08:00
dsehnal
d8498feaef updade npmignore 2021-11-28 14:36:54 +01:00
Michal Malý
aaec452bc2 Add packaging command to force a full rebuild 2021-11-28 13:28:06 +01:00
Alexander Rose
bce959195a fix renderer spec baseline 2021-11-27 17:31:42 -08:00
Alexander Rose
4287e09a9a fix material param number formating 2021-11-27 17:25:51 -08:00
Alexander Rose
fdc006f833 Merge branch 'master' of https://github.com/molstar/molstar into lighting 2021-11-27 17:08:56 -08:00
Alexander Rose
c704b7505c add Substance theming (per-group material) 2021-11-27 17:06:55 -08:00
Alexander Rose
ceaf238322 material improvements
- material helpers
- material in structure component manager
2021-11-27 17:02:48 -08:00
Alexander Rose
b7224ce5c7 lighting tweaks 2021-11-26 18:04:33 -08:00
Alexander Rose
95654175fe improve 'rounded' tube geometry
- correct normals
- circle offset
2021-11-26 15:34:16 -08:00
Alexander Rose
de96244706 allow atoms in aromatic rings to do hydrogen bonds 2021-11-26 14:37:50 -08:00
Alexander Rose
3104ee5742 Merge branch 'master' of https://github.com/molstar/molstar into lighting 2021-11-25 15:00:19 -08:00
Alexander Rose
73ac445a44 2.4.0 2021-11-25 14:46:10 -08:00
Alexander Rose
1a1d1d9d30 changelog 2021-11-25 14:41:19 -08:00
Alexander Rose
062aff76da update schemas 2021-11-25 14:40:35 -08:00
Alexander Rose
7d0d24b66d update packages 2021-11-25 14:40:26 -08:00
Alexander Rose
6655672d11 Merge pull request #290 from molstar/smoothing2
Smooth Overpaint and Transparency
2021-11-25 14:13:10 -08:00
Alexander Rose
6e573ae410 reduce args counts in geo exporters 2021-11-25 14:04:58 -08:00
Alexander Rose
1c48c02473 basic overpaint for direct-volume isosurface 2021-11-24 19:49:42 -08:00
Alexander Rose
78be3320ce geo export support smoothed overpaint/transparency 2021-11-24 19:49:05 -08:00
Alexander Rose
c8018800cc grid-based smoothing of Overpaint and Transparency 2021-11-24 19:47:07 -08:00
Alexander Rose
bb795aca98 refactor grid-based color smoothing
- support rgba and alpha values
- CPU and GPU versions
- for Mesh and TextureMesh
2021-11-24 19:43:15 -08:00
Alexander Rose
2cb1279f4c gl compute utils improvements
- CopyRenderable
- readTexture and readAlphaTexture helpers
2021-11-24 19:10:15 -08:00
Alexander Rose
b876c6f618 avoid unnecessary representation state updates 2021-11-24 18:51:16 -08:00
Alexander Rose
3a7dfc055e add Representation.geometryVersion
- increments whenever the geometry of any visual changes
2021-11-24 18:49:10 -08:00
Alexander Rose
928e521ac7 improve handling of .meta in Mesh & TextureMesh 2021-11-24 18:36:04 -08:00
Alexander Rose
e5e9598e4b changelog 2021-11-24 18:31:08 -08:00
Alexander Rose
e6e1809592 Fix secondary-structure property handling
- StructureElement.Property was incorrectly resolving type & key
- StructureSelectionQuery helpers 'helix' & 'beta' were not ensuring property availability
2021-11-24 18:30:53 -08:00
Alexander Rose
812f97ddb7 skip picking/depth pass for volume rendering
- not supported in shader anyway
- was printing 'no output' warning in Chrome console
2021-11-24 18:20:42 -08:00
Alexander Rose
c6b814b31b re-enable VAO with better workaround 2021-11-24 18:17:48 -08:00
Alexander Rose
98566fa389 improve error handling
- console.error if not re-thrown
- better messages for users
2021-11-24 18:15:47 -08:00
David Sehnal
4318c89bdb Merge pull request #288 from jpattle/allow-v3-sdf
Added the ability to handle v3000 sd files
2021-11-23 15:49:42 +01:00
Jason Pattle
b41a97ce6a Added a separate function to handle v2 counts and refactored the existing code that distinguishes v2 and v3 atom and bond counts 2021-11-23 10:30:09 +00:00
Jason Pattle
862c384dc0 Added the ability to handle v3000 sd files. Added a set of utility functions for parsing atoms and bonds from v3000 sd files. Updated the existing sdf parser to determine the version and run the v3000 sd file parser functions instead of the default v2000 ones. Added tests to verify parsing functionality for example v3000 ctab 2021-11-22 16:00:35 +00:00
Alexander Rose
26cc7e94c2 2.3.9 2021-11-20 16:58:28 -08:00
Alexander Rose
c6fe6ddcba switch off VAO support for now 2021-11-20 16:54:38 -08:00
Alexander Rose
154984e74d 2.3.8 2021-11-20 16:30:22 -08:00
Alexander Rose
72fcaf8321 changelog 2021-11-20 16:24:54 -08:00
Alexander Rose
0c14ca5888 workaround for VAO issue in Chrome 96 2021-11-20 16:14:30 -08:00
Alexander Rose
a85ede5058 fix unused vertex attribute handling 2021-11-20 16:13:18 -08:00
Alexander Rose
db49a16184 fix double canvas context creation 2021-11-20 12:52:47 -08:00
dsehnal
0704db2343 replace webpack-version-file-plugin 2021-11-20 13:45:28 +01:00
dsehnal
425dca4665 fix sass division 2021-11-20 12:55:46 +01:00
dsehnal
8d65ccabd2 update packages
- use sass instead of node sass
2021-11-20 12:49:26 +01:00
Alexander Rose
cbd417ca13 2.3.7 2021-11-15 19:31:07 -08:00
Alexander Rose
1e4d1e45f9 Merge branch 'master' of https://github.com/molstar/molstar into lighting 2021-11-13 13:36:03 -08:00
Alexander Rose
1578211157 add helix profile option to cartoon repr 2021-11-13 13:16:11 -08:00
Alexander Rose
15932dc5df handle parent in Structure.remapModel 2021-11-13 09:23:57 -08:00
dsehnal
7db2205956 changelog 2021-11-09 21:18:55 +01:00
dsehnal
d87f0d236a ViewerOptions.collapseRightPanel 2021-11-09 21:17:01 +01:00
dsehnal
16daca6008 undo test code 2021-11-09 21:13:28 +01:00
dsehnal
a0d919c8db Viewer.loadTrajectory 2021-11-09 21:12:24 +01:00
David Sehnal
ffee2bf1c4 Merge pull request #285 from MadCatX/tweak-measurement-order-labels
Tweak measurement order labels
2021-11-09 10:28:13 +01:00
Michal Malý
de77f6ac59 Fix a visual glitch where the label border was initially rendered with
half of the intended size.
2021-11-09 09:59:25 +01:00
Michal Malý
c8c2ebcd65 Reduce Z-offset of measurement order labels to avoid too early clipping 2021-11-09 09:59:25 +01:00
Michal Malý
42796b984f Reduce border width of measurement order labels 2021-11-09 09:58:58 +01:00
David Sehnal
746557bf52 Merge pull request #284 from russellp17/master
Move jest types to devDependencies
2021-11-08 22:48:15 +01:00
Russell Parker
a5020a9e96 Move jest types to devDependencies 2021-11-08 15:58:14 -05:00
dsehnal
2ebb0a35fd 2.3.6 2021-11-08 18:57:06 +01:00
dsehnal
64aaa92d45 changelog 2021-11-08 18:54:52 +01:00
dsehnal
4baf391efe prefer webgl1 in safari 15.1
- WebGL2 is broken there for Mol* shaders
- It works again in Safari 15.4 tech preview
2021-11-08 18:50:16 +01:00
David Sehnal
5afdcff6a5 Merge pull request #273 from molstar/shader-tests
add basic unit tests for graphics shaders
2021-11-08 18:40:51 +01:00
dsehnal
339c397860 package lock 2021-11-08 18:30:52 +01:00
dsehnal
a58cbd31ef Merge branch 'master' of https://github.com/molstar/molstar into shader-tests 2021-11-08 18:30:30 +01:00
David Sehnal
d232b01cf9 Merge pull request #283 from MadCatX/improve-measurements-ux
Improve measurements user experience
2021-11-08 17:12:37 +01:00
Michal Malý
ec95270854 Use the entire element to trigger highlighting of loci from additionsHistory 2021-11-08 15:46:07 +01:00
Michal Malý
78cc0d960f Show the order of locis to be used for measurements in 3D view 2021-11-08 15:46:02 +01:00
Alexander Rose
b5ccdfdd53 multiple lights, per object materials
- multiple directional lights
- per-object materials (roughness & metalness)
- fixed reflectivity to 0.5
- update PhysicalMaterial from three.js to r134
2021-11-06 21:14:14 -07:00
Alexander Rose
d0c0d8e703 require standardDerivatives glsl extension 2021-11-06 20:57:22 -07:00
Alexander Rose
ebf64404be add loop unrolling glsl support 2021-11-06 15:02:14 -07:00
Alexander Rose
7f39cf0f37 add missing updateFocusRepr to atomicDetail preset
- fixes #280
2021-11-02 22:10:35 -07:00
Alexander Rose
e5dcc8e54f wip, lighting improvements
- set light direction
- set light color
- set ambient color
2021-10-31 14:59:19 -07:00
Alexander Rose
4592510a95 linting fix 2021-10-30 21:50:15 -07:00
Alexander Rose
46d5442dc5 Merge pull request #252 from corredD/forkdev
binary model loading support and latest mycoplasma model.
2021-10-30 17:11:27 -07:00
Alexander Rose
271cff4aba changelog 2021-10-30 17:09:35 -07:00
Alexander Rose
94fd5a97d6 Merge branch 'master' of https://github.com/molstar/molstar into pr/corredD/252 2021-10-30 16:53:35 -07:00
Alexander Rose
28678e2f80 Merge pull request #270 from molstar/measurements
Additional measurement controls
2021-10-30 16:52:32 -07:00
Alexander Rose
406307a432 add radiusScale param to orientation measurement 2021-10-30 16:48:47 -07:00
Alexander Rose
56345b5096 Merge branch 'master' of https://github.com/molstar/molstar into measurements 2021-10-30 16:31:12 -07:00
Alexander Rose
3fcc42ee0e fix, proper EmptyRepresentationProvider 2021-10-30 16:26:37 -07:00
Alexander Rose
b903677f8a gh action, add npm run build 2021-10-30 16:12:42 -07:00
Alexander Rose
ef4b632a07 update package-lock 2021-10-30 16:05:24 -07:00
Alexander Rose
e9d485ca85 gh action, use npm ci 2021-10-30 16:01:09 -07:00
Alexander Rose
a149fa5929 gh action 2021-10-30 15:53:58 -07:00
Alexander Rose
bb3dde585b gh action 2021-10-30 15:46:23 -07:00
Alexander Rose
cd6bbeaa86 gh action 2021-10-30 15:44:06 -07:00
Alexander Rose
e3d24dae4b gh action 2021-10-30 15:43:05 -07:00
Alexander Rose
687a814a62 gh action
- update eslint
- add jest
2021-10-30 15:02:25 -07:00
Alexander Rose
8f2e99dc51 improve shader tests
- made gl package optional
- skip test if gl package not available
2021-10-30 14:52:11 -07:00
Alexander Rose
568be030c3 Merge branch 'master' of https://github.com/molstar/molstar into shader-tests 2021-10-30 14:45:19 -07:00
Alexander Rose
97c3ab8b5a changelog 2021-10-30 14:44:27 -07:00
Alexander Rose
5db646d139 fix marker highlight color overriding select color 2021-10-30 14:43:57 -07:00
Alexander Rose
340f8f1af3 add additional aromatic bond visual params 2021-10-30 14:42:17 -07:00
Alexander Rose
b371f8c11c Merge branch 'master' of https://github.com/molstar/molstar into shader-tests 2021-10-03 15:24:02 -07:00
Alexander Rose
895a13fc0d Merge branch 'master' into shader-tests 2021-10-03 14:36:23 -07:00
Alexander Rose
2f9ac711d1 add basic unit tests for graphics shaders
- compile using `gl` package
2021-10-03 10:52:58 -07:00
Alexander Rose
b06c134b61 add additional measurement controls
- orientation (box, axes, ellipsoid)
- plane (best fit)
2021-09-18 22:39:40 -07:00
Alexander Rose
3436d03468 add helpers to work with many locis
- StructureElement.Loci.getPrincipalAxesMany
- structureElementLociLabelMany
2021-09-18 22:13:22 -07:00
Alexander Rose
58df6f3b85 formating 2021-09-18 22:12:08 -07:00
Alexander Rose
ffaf008dce limit max display counts in sequence panel
- MaxSelectOptionsCount
- MaxSequenceWrappersCount
- workaround for cellpack models
2021-09-18 16:30:14 -07:00
ludovic autin
eb196a41b5 change variables names to avoid confusion with other types. Added the xrayshading for the compartment geometry 2021-09-14 11:25:15 -07:00
ludovic autin
35baaaf594 support for compartment PLY file. 2021-09-13 11:46:27 -07:00
Alexander Rose
0fc305aaea fix linting issues 2021-09-12 23:32:55 -07:00
Alexander Rose
bf67546a61 Merge branch 'master' of https://github.com/molstar/molstar into pr/corredD/252 2021-09-12 23:30:26 -07:00
Alexander Rose
80d54afdd0 Merge branch 'master' into forkdev 2021-09-12 20:16:00 -07:00
Alexander Rose
2a74dfcf46 factor out membrane sphere handling 2021-09-12 10:26:10 -07:00
Alexander Rose
b0f447adde fix cellpack results file asset handling 2021-09-12 10:17:37 -07:00
ludovic autin
b8628ccff1 Merge branch 'master' of https://github.com/molstar/molstar into forkdev 2021-09-01 09:55:13 -07:00
ludovic autin
4c30057edf I am trying to get the binary asset to get cached. But still can't save a working session. 2021-08-27 16:14:43 -07:00
ludovic autin
53a4826274 Merge branch 'master' of https://github.com/molstar/molstar into forkdev 2021-08-27 14:55:22 -07:00
ludovic autin
393fc99ed2 moved the model loading in model.ts and get the info from the recipe dictionary ( result file and lipids file ) if available. Fix the dates and some const / let variable defintion 2021-08-16 12:35:51 -07:00
ludovic autin
7c5dff1c8b Merge remote-tracking branch 'upstream/master' into forkdev 2021-08-16 11:55:09 -07:00
ludovic autin
ce3f13431d endianess test with IsNativeEndianLittle 2021-08-13 10:58:25 -07:00
ludovic autin
df54766ab2 lower-case icosahedron 2021-08-12 10:48:27 -07:00
ludovic autin
94233fbcd9 eslint error fix 2021-08-11 11:07:34 -07:00
ludovic autin
d044496eaa fix eslint errors 2021-08-11 11:04:08 -07:00
ludovic autin
ca825d720e binary model loading support, latest mycoplasma model. 2021-08-11 10:44:44 -07:00
Alexander Rose
504406eb22 move clip variant and objects to repr state 2021-08-01 21:16:44 -07:00
358 changed files with 31369 additions and 6196 deletions

View File

@@ -1,18 +0,0 @@
on:
push:
pull_request:
jobs:
eslint:
name: eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install node v14
uses: actions/setup-node@v1
with:
node-version: 14
- name: yarn install
run: yarn install
- name: eslint
uses: icrawl/action-eslint@v1

20
.github/workflows/node.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 17
- run: npm ci
- run: sudo apt-get install xvfb
- name: Lint
run: npm run lint
- name: Test
run: xvfb-run --auto-servernum npm run jest
- name: Build
run: npm run build

View File

@@ -1 +1,5 @@
tsconfig.commonjs.tsbuildinfo
tests
perf-tests
_spec
*.tsbuildinfo
*.js.map

View File

@@ -7,6 +7,8 @@
"*.gql.ts": "graphql"
},
"eslint.options": {
"ignorePattern": ["webpack.config.js", "scripts/*"],
"overrideConfig": {
"ignorePatterns": ["webpack.config.js", "scripts/*"],
},
}
}

View File

@@ -6,6 +6,137 @@ Note that since we don't clearly distinguish between a public and private interf
## [Unreleased]
## [v3.0.0-dev.8] - 2021-12-31
- Add ``PluginFeatureDetection`` and disable WBOIT in Safari 15.
- Add ``disable-wboit`` Viewer GET param
- Add ``prefer-webgl1`` Viewer GET param
- [Breaking] Refactor direct-volume rendering
- Remove isosurface render-mode (use GPU MC instead)
- Move coloring into theme (like for other geometries/renderables)
- Add ``direct`` color type
- Remove color from transfer-function (now only alpha)
- Add direct-volume color theme support
- Add volume-value color theme
- [Breaking] Use size theme in molecular/gaussian surface & label representations
- This is breaking because it was hardcoded to ``physical`` internally but the repr size theme default was ``uniform`` (now ``physical``)
## [v3.0.0-dev.7] - 2021-12-20
- Reduce number of created programs/shaders
- Support specifying variants when creating graphics render-items
- Change double-side shader param from define to uniform
- Remove dMarkerType shader define (use uMarker as needed)
- Support to ignore defines depending on the shader variant
- Combine pickObject/pickInstance/pickGroup shader variants into one
- Combine markingDepth/markingMask shader variants into one
- Correctly set shader define flags for overpaint, transparency, substance, clipping
- [Breaking] Add per-object clip rendering properties (variant/objects)
- ``SimpleSettingsParams.clipping.variant/objects`` and ``RendererParams.clip`` were removed
## [v3.0.0-dev.6] - 2021-12-19
- Enable temporal multi-sampling by default
- Fix flickering during marking with camera at rest
- Enable ``aromaticBonds`` in structure representations by default
- Add ``PluginConfig.Structure.DefaultRepresentationPreset``
- Add ModelArchive support
- schema extensions (e.g., AlphaFold uses it for the pLDDT score)
- ModelArchive option in DownloadStructure action
- ``model-archive`` GET parameter for Viewer app
- ``Viewer.loadModelArchive`` method
- Improve support for loading AlphaFold structures
- Automatic coloring by pLDDT
- AlphaFold DB option in DownloadStructure action
- ``afdb`` GET parameter for Viewer app
- ``Viewer.loadAlphaFoldDb`` method
- Add QualityAssessment extension (using data from ma_qa_metric_local mmcif category)
- pLDDT & qmean score: coloring, repr presets, molql symbol, loci labels (including avg for mutli-residue selections)
- pLDDT: selection query
- Warn about erroneous symmetry operator matrix (instead of throwing an error)
- Added ``createPluginUI`` to ``mol-plugin-ui``
- Support ``onBeforeUIRender`` to make sure initial UI works with custom presets and similar features.
- [Breaking] Removed ``createPlugin`` and ``createPluginAsync`` from ``mol-plugin-ui``
- Please use ``createPluginUI`` instead
- Improve aromatic bonds handling
- Don't detect aromatic bonds for rings < 5 atoms based on planarity
- Prefer atoms in aromatic rings as bond reference positions
## [v3.0.0-dev.5] - 2021-12-16
- Fix initial camera reset not triggering for some entries.
## [v3.0.0-dev.4] - 2021-12-14
- Add ``bumpiness`` (per-object and per-group), ``bumpFrequency`` & ``bumpAmplitude`` (per-object) render parameters (#299)
- Change ``label`` representation defaults: Use text border instead of rectangle background
- Add outline color option to renderer
- Fix false positives in Model.isFromPdbArchive
- Add drag and drop support for loading any file, including multiple at once
- If there are session files (.molx or .molj) among the dropped files, only the first session will be loaded
- Add drag and drop overlay
- Safari 15.1 - 15.3 WebGL 2 support workaround
- [Breaking] Move ``react`` and ``react-dom`` to ``peerDependencies``. This might break some builds.
## [v3.0.0-dev.3] - 2021-12-4
- Fix OBJ and USDZ export
## [v3.0.0-dev.2] - 2021-12-1
- Do not include tests and source maps in NPM package
## [v3.0.0-dev.0] - 2021-11-28
- Add multiple lights support (with color, intensity, and direction parameters)
- [Breaking] Add per-object material rendering properties
- ``SimpleSettingsParams.lighting.renderStyle`` and ``RendererParams.style`` were removed
- Add substance theme with per-group material rendering properties
- ``StructureComponentManager.Options`` state saving support
- ``ParamDefinition.Group.presets`` support
## [v2.4.1] - 2021-11-28
- Fix: allow atoms in aromatic rings to do hydrogen bonds
## [v2.4.0] - 2021-11-25
- Fix secondary-structure property handling
- StructureElement.Property was incorrectly resolving type & key
- StructureSelectionQuery helpers 'helix' & 'beta' were not ensuring property availability
- Re-enable VAO with better workaround (bind null elements buffer before deleting)
- Add ``Representation.geometryVersion`` (increments whenever the geometry of any of its visuals changes)
- Add support for grid-based smoothing of Overpaint and Transparency visual state for surfaces
## [v2.3.9] - 2021-11-20
- Workaround: switch off VAO support for now
## [v2.3.8] - 2021-11-20
- Fix double canvas context creation (in plugin context)
- Fix unused vertex attribute handling (track which are used, disable the rest)
- Workaround for VAO issue in Chrome 96 (can cause WebGL to crash on geometry updates)
## [v2.3.7] - 2021-11-15
- Added ``ViewerOptions.collapseRightPanel``
- Added ``Viewer.loadTrajectory`` to support loading "composed" trajectories (e.g. from gro + xtc)
- Fix: handle parent in Structure.remapModel
- Add ``rounded`` and ``square`` helix profile options to Cartoon representation (in addition to the default ``elliptical``)
## [v2.3.6] - 2021-11-8
- Add additional measurement controls: orientation (box, axes, ellipsoid) & plane (best fit)
- Improve aromatic bond visuals (add ``aromaticScale``, ``aromaticSpacing``, ``aromaticDashCount`` params)
- [Breaking] Change ``adjustCylinderLength`` default to ``false`` (set to true for focus representation)
- Fix marker highlight color overriding select color
- CellPack extension update
- add binary model support
- add compartment (including membrane) geometry support
- add latest mycoplasma model example
- Prefer WebGL1 in Safari 15.1.
## [v2.3.5] - 2021-10-19
- Fix sequence viewer for PDB files with COMPND record and multichain entities.
@@ -153,29 +284,22 @@ Note that since we don't clearly distinguish between a public and private interf
- Fixed Measurements UI labels (#166)
## [v2.0.3] - 2021-04-09
### Added
- Support for ``ColorTheme.palette`` designed for providing gradient-like coloring.
### Changed
- Add support for ``ColorTheme.palette`` designed for providing gradient-like coloring.
- [Breaking] The ``zip`` function is now asynchronous and expects a ``RuntimeContext``. Also added ``Zip()`` returning a ``Task``.
- [Breaking] Add ``CubeGridFormat`` in ``alpha-orbitals`` extension.
## [v2.0.2] - 2021-03-29
### Added
- ``Canvas3D.getRenderObjects``.
- Add ``Canvas3D.getRenderObjects``.
- [WIP] Animate state interpolating, including model trajectories
### Changed
- Recognise MSE, SEP, TPO, PTR and PCA as non-standard amino-acids.
### Fixed
- VolumeFromDensityServerCif transform label
- Fix VolumeFromDensityServerCif transform label
## [v2.0.1] - 2021-03-23
### Fixed
- Exclude tsconfig.commonjs.tsbuildinfo from npm bundle
## [v2.0.0] - 2021-03-23
Too many changes to list as this is the start of the changelog... Notably, default exports are now forbidden.

View File

@@ -68,6 +68,17 @@ If working on just the viewer, ``npm run watch-viewer`` will provide shorter com
Debug/production mode in browsers can be turned on/off during runtime by calling ``setMolStarDebugMode(true/false, true/false)`` from the dev console.
### Cleaning and forcing a full rebuild
npm run clean
Wipes the `build` and `lib` directories and `.tsbuildinfo` files.
npm run rebuild
Runs the cleanup script prior to building the project, forcing a full rebuild of the project.
Use these commands to resolve occassional build failures which may arise after some dependency updates. Once done, `npm run build` should work again. Note that full rebuilds take more time to complete.
### Build for production:
NODE_ENV=production npm run build
@@ -122,9 +133,9 @@ and navigate to `build/viewer`
**Convert any CIF to BinaryCIF**
node lib/servers/model/preprocess -i file.cif -ob file.bcif
node lib/commonjs/servers/model/preprocess -i file.cif -ob file.bcif
To see all available commands, use ``node lib/servers/model/preprocess -h``.
To see all available commands, use ``node lib/commonjs/servers/model/preprocess -h``.
Or

View File

@@ -246,6 +246,14 @@ citation_author.ordinal
exptl.entry_id
exptl.method
software.classification
software.date
software.description
software.name
software.pdbx_ordinal
software.type
software.version
struct.entry_id
struct.title
struct.pdbx_descriptor
@@ -802,4 +810,58 @@ ihm_multi_state_modeling.population_fraction_sd
ihm_multi_state_modeling.state_type
ihm_multi_state_modeling.state_name
ihm_multi_state_modeling.experiment_type
ihm_multi_state_modeling.details
ihm_multi_state_modeling.details
ma_data.content_type
ma_data.content_type_other_details
ma_data.id
ma_data.name
ma_model_list.data_id
ma_model_list.model_group_id
ma_model_list.model_group_name
ma_model_list.model_id
ma_model_list.model_name
ma_model_list.model_type
ma_model_list.ordinal_id
ma_qa_metric.id
ma_qa_metric.mode
ma_qa_metric.name
ma_qa_metric.software_group_id
ma_qa_metric.type
ma_qa_metric_global.metric_id
ma_qa_metric_global.metric_value
ma_qa_metric_global.model_id
ma_qa_metric_global.ordinal_id
ma_qa_metric_local.label_asym_id
ma_qa_metric_local.label_comp_id
ma_qa_metric_local.label_seq_id
ma_qa_metric_local.metric_id
ma_qa_metric_local.metric_value
ma_qa_metric_local.model_id
ma_qa_metric_local.ordinal_id
ma_software_group.group_id
ma_software_group.ordinal_id
ma_software_group.software_id
ma_target_entity.data_id
ma_target_entity.entity_id
ma_target_entity.origin
ma_target_entity_instance.asym_id
ma_target_entity_instance.details
ma_target_entity_instance.entity_id
ma_target_ref_db_details.db_accession
ma_target_ref_db_details.db_code
ma_target_ref_db_details.db_name
ma_target_ref_db_details.ncbi_taxonomy_id
ma_target_ref_db_details.organism_scientific
ma_target_ref_db_details.seq_db_align_begin
ma_target_ref_db_details.seq_db_align_end
ma_target_ref_db_details.seq_db_isoform
ma_target_ref_db_details.target_entity_id
1 atom_sites.entry_id
246 struct_conn.conn_type_id struct_conf.end_auth_comp_id
247 struct_conn.pdbx_PDB_id struct_conf.end_auth_asym_id
248 struct_conn.ptnr1_label_asym_id struct_conf.end_auth_seq_id
249 struct_conf.pdbx_PDB_helix_class
250 struct_conf.details
251 struct_conf.pdbx_PDB_helix_length
252 struct_conn.id
253 struct_conn.conn_type_id
254 struct_conn.pdbx_PDB_id
255 struct_conn.ptnr1_label_asym_id
256 struct_conn.ptnr1_label_comp_id
257 struct_conn.ptnr1_label_comp_id struct_conn.ptnr1_label_seq_id
258 struct_conn.ptnr1_label_seq_id struct_conn.ptnr1_label_atom_id
259 struct_conn.ptnr1_label_atom_id struct_conn.pdbx_ptnr1_label_alt_id
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867

View File

@@ -29,6 +29,11 @@
* Long linear sugar chain (4HG6)
* Anisotropic B-factors/Ellipsoids (1EJG)
* NOS bridges (LYS-CSO in 7B0L, 6ZWJ, 6ZWH)
* Non-polymer components in polymer entities
* PN2 in 1F80
* ACE (many, e.g. 5AGU, 1E1X)
* ACY in 7ABY
* NH2 (many, e.g. 6Y13)
Assembly symmetries
* 5M30 (Assembly 1, C3 local and pseudo)

86
examples/ace2-hit.mol2 Normal file
View File

@@ -0,0 +1,86 @@
@<TRIPOS>MOLECULE
ace2_r_r2.top2000.poses.plain/3_Z1137565832_1_T2.pdb
37 41 0 0 0
SMALL
GASTEIGER
@<TRIPOS>ATOM
1 C 64.7720 85.9180 38.1090 C.3 1 LIG1 0.0799
2 C 64.6440 84.6900 37.1570 C.3 1 LIG1 0.0306
3 C 65.2660 83.4260 37.8080 C.3 1 LIG1 0.0927
4 N 66.6560 83.6710 38.1790 N.pl3 1 LIG1 -0.2919
5 C 67.7080 82.9280 37.6260 C.ar 1 LIG1 0.1520
6 C 69.0970 83.1860 37.8250 C.ar 1 LIG1 0.0393
7 C 70.0830 82.4100 37.1810 C.ar 1 LIG1 0.0436
8 C 69.6450 81.3740 36.3510 C.ar 1 LIG1 0.1867
9 N 70.3370 80.5030 35.6050 N.ar 1 LIG1 -0.1270
10 N 69.4700 79.7480 35.0040 N.ar 1 LIG1 -0.1228
11 C 68.2200 80.1120 35.3570 C.ar 1 LIG1 0.2583
12 N 68.3350 81.1470 36.2040 N.ar 1 LIG1 -0.1866
13 N 67.4230 81.8700 36.8030 N.ar 1 LIG1 -0.1473
14 C 66.8190 84.7600 39.1350 C.3 1 LIG1 0.0927
15 C 66.2560 86.0870 38.5570 C.3 1 LIG1 0.0306
16 N 64.4520 87.4670 36.2150 N.am 1 LIG1 -0.2979
17 H 64.9740 86.7650 35.7110 H 1 LIG1 0.1498
18 C 64.2290 87.1720 37.5220 C.2 1 LIG1 0.2224
19 O 63.5690 87.9550 38.2480 O.2 1 LIG1 -0.2751
20 C 64.0160 88.6470 35.5420 C.3 1 LIG1 0.1559
21 C 65.9650 88.2170 32.5700 C.ar 1 LIG1 0.1629
22 N 65.8040 88.0390 33.8860 N.ar 1 LIG1 -0.3232
23 H 66.4190 87.5270 34.5040 H 1 LIG1 0.1686
24 C 64.6770 88.6690 34.2330 C.ar 1 LIG1 0.1601
25 N 64.1890 89.2810 33.1430 N.ar 1 LIG1 -0.1318
26 N 64.9640 89.0070 32.1450 N.ar 1 LIG1 -0.1293
27 F 69.9260 86.0280 29.3520 F 1 LIG1 -0.2042
28 C 68.9880 86.5420 30.0990 C.ar 1 LIG1 0.1401
29 C 67.6590 86.0900 29.9830 C.ar 1 LIG1 0.0297
30 C 66.6500 86.6450 30.7950 C.ar 1 LIG1 0.0053
31 C 66.9590 87.6470 31.7450 C.ar 1 LIG1 0.0359
32 C 68.2970 88.0990 31.8400 C.ar 1 LIG1 0.0053
33 C 69.3030 87.5560 31.0230 C.ar 1 LIG1 0.0297
34 C 66.9850 79.4910 34.8440 C.3 1 LIG1 0.4541
35 F 67.3150 78.4110 34.0640 F 1 LIG1 -0.1631
36 F 66.2460 80.3690 34.0910 F 1 LIG1 -0.1631
37 F 66.1920 79.0650 35.8800 F 1 LIG1 -0.1631
@<TRIPOS>BOND
1 1 2 1
2 1 18 1
3 1 15 1
4 2 3 1
5 3 4 1
6 4 5 1
7 4 14 1
8 5 13 ar
9 5 6 ar
10 6 7 ar
11 7 8 ar
12 8 9 ar
13 8 12 ar
14 9 10 ar
15 10 11 ar
16 11 34 1
17 11 12 ar
18 12 13 ar
19 14 15 1
20 16 20 1
21 16 17 1
22 16 18 am
23 18 19 2
24 20 24 1
25 21 31 1
26 21 26 ar
27 21 22 ar
28 22 24 ar
29 22 23 1
30 24 25 ar
31 25 26 ar
32 27 28 1
33 28 29 ar
34 28 33 ar
35 29 30 ar
36 30 31 ar
37 31 32 ar
38 32 33 ar
39 34 35 1
40 34 36 1
41 34 37 1

7628
examples/ace2.pdbqt Normal file

File diff suppressed because it is too large Load Diff

19194
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "molstar",
"version": "2.3.5",
"version": "3.0.0-dev.8",
"description": "A comprehensive macromolecular library.",
"homepage": "https://github.com/molstar/molstar#readme",
"repository": {
@@ -16,6 +16,8 @@
"test": "npm run lint && jest",
"jest": "jest",
"build": "npm run build-tsc && npm run build-extra && npm run build-webpack",
"clean": "node ./scripts/clean.js",
"rebuild": "npm run clean && npm run build",
"build-viewer": "npm run build-tsc && npm run build-extra && npm run build-webpack-viewer",
"build-tsc": "concurrently \"tsc --incremental\" \"tsc --build tsconfig.commonjs.json --incremental\"",
"build-extra": "cpx \"src/**/*.{scss,html,ico}\" lib/",
@@ -36,7 +38,7 @@
"volume-server-test": "node lib/commonjs/servers/volume/server.js --idMap em 'test/${id}.mdb' --defaultPort 1336",
"plugin-state": "node lib/commonjs/servers/plugin-state/index.js --working-folder ./build/state --port 1339",
"preversion": "npm run test",
"version": "npm run build",
"version": "npm run rebuild && cpx .npmignore lib/",
"postversion": "git push && git push --tags"
},
"files": [
@@ -89,51 +91,51 @@
"license": "MIT",
"devDependencies": {
"@graphql-codegen/add": "^3.1.0",
"@graphql-codegen/cli": "^2.2.0",
"@graphql-codegen/cli": "^2.3.0",
"@graphql-codegen/time": "^3.1.0",
"@graphql-codegen/typescript": "^2.2.2",
"@graphql-codegen/typescript": "^2.4.1",
"@graphql-codegen/typescript-graphql-files-modules": "^2.1.0",
"@graphql-codegen/typescript-graphql-request": "^4.1.4",
"@graphql-codegen/typescript-operations": "^2.1.6",
"@graphql-codegen/typescript-graphql-request": "^4.3.1",
"@graphql-codegen/typescript-operations": "^2.2.1",
"@types/cors": "^2.8.12",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"@types/gl": "^4.1.0",
"@types/jest": "^27.0.3",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"benchmark": "^2.1.4",
"concurrently": "^6.3.0",
"concurrently": "^6.4.0",
"cpx2": "^4.0.0",
"crypto-browserify": "^3.12.0",
"css-loader": "^6.3.0",
"eslint": "^7.32.0",
"css-loader": "^6.5.1",
"eslint": "^8.3.0",
"extra-watch-webpack-plugin": "^1.0.3",
"file-loader": "^6.2.0",
"fs-extra": "^10.0.0",
"graphql": "^15.6.0",
"http-server": "^13.0.2",
"jest": "^27.2.4",
"mini-css-extract-plugin": "^2.3.0",
"node-sass": "^6.0.1",
"graphql": "^15.7.2",
"http-server": "^14.0.0",
"jest": "^27.3.1",
"mini-css-extract-plugin": "^2.4.5",
"path-browserify": "^1.0.1",
"raw-loader": "^4.0.2",
"sass-loader": "^12.1.0",
"simple-git": "^2.46.0",
"sass": "^1.43.5",
"sass-loader": "^12.3.0",
"simple-git": "^2.47.0",
"stream-browserify": "^3.0.0",
"style-loader": "^3.3.0",
"ts-jest": "^27.0.5",
"typescript": "^4.4.3",
"webpack": "^5.56.0",
"webpack-cli": "^4.8.0",
"webpack-version-file-plugin": "^0.4.0"
"style-loader": "^3.3.1",
"ts-jest": "^27.0.7",
"typescript": "^4.5.2",
"webpack": "^5.64.4",
"webpack-cli": "^4.9.1"
},
"dependencies": {
"@types/argparse": "^2.0.10",
"@types/benchmark": "^2.1.1",
"@types/compression": "1.7.2",
"@types/express": "^4.17.13",
"@types/jest": "^27.0.2",
"@types/node": "^16.10.2",
"@types/node": "^16.11.10",
"@types/node-fetch": "^2.5.12",
"@types/react": "^17.0.27",
"@types/react-dom": "^17.0.9",
"@types/react": "^17.0.37",
"@types/react-dom": "^17.0.11",
"@types/swagger-ui-dist": "3.30.1",
"argparse": "^2.0.1",
"body-parser": "^1.19.0",
@@ -141,15 +143,20 @@
"cors": "^2.8.5",
"express": "^4.17.1",
"h264-mp4-encoder": "^1.0.12",
"immer": "^9.0.6",
"immer": "^9.0.7",
"immutable": "^3.8.2",
"node-fetch": "^2.6.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rxjs": "^7.3.1",
"swagger-ui-dist": "^3.52.3",
"rxjs": "^7.4.0",
"swagger-ui-dist": "^4.1.1",
"tslib": "^2.3.1",
"util.promisify": "^1.1.1",
"xhr2": "^0.2.1"
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"optionalDependencies": {
"gl": "^4.9.2"
}
}

41
scripts/clean.js Normal file
View File

@@ -0,0 +1,41 @@
/**
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Michal Malý <malym@ibt.cas.cz>
*/
const fs = require('fs');
const path = require('path');
function removeDir(dirPath) {
for (const ent of fs.readdirSync(dirPath)) {
const entryPath = path.join(dirPath, ent);
remove(entryPath);
}
fs.rmdirSync(dirPath);
}
function remove(entryPath) {
const st = fs.statSync(entryPath);
if (st.isDirectory())
removeDir(entryPath);
else
fs.unlinkSync(entryPath);
}
const toClean = [
path.resolve(__dirname, '../build'),
path.resolve(__dirname, '../lib'),
path.resolve(__dirname, '../tsconfig.tsbuildinfo'),
];
toClean.forEach(ph => {
if (fs.existsSync(ph)) {
try {
remove(ph);
} catch (err) {
console.warn(`Cleanup failed: ${err}`);
}
}
});

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -14,6 +14,9 @@ const buildDir = path.resolve(__dirname, '../build/');
const deployDir = path.resolve(buildDir, 'deploy/');
const localPath = path.resolve(deployDir, 'molstar.github.io/');
const analyticsTag = /<!-- __MOLSTAR_ANALYTICS__ -->/g;
const analyticsCode = `<!-- Cloudflare Web Analytics --><script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "c414cbae2d284ea995171a81e4a3e721"}'></script><!-- End Cloudflare Web Analytics -->`;
function log(command, stdout, stderr) {
if (command) {
console.log('\n###', command);
@@ -22,11 +25,36 @@ function log(command, stdout, stderr) {
}
}
function addAnalytics(path) {
const data = fs.readFileSync(path, 'utf8');
const result = data.replace(analyticsTag, analyticsCode);
fs.writeFileSync(path, result, 'utf8');
}
function copyViewer() {
console.log('\n###', 'copy viewer files');
const viewerBuildPath = path.resolve(buildDir, '../build/viewer/');
const viewerDeployPath = path.resolve(localPath, 'viewer/');
fse.copySync(viewerBuildPath, viewerDeployPath, { overwrite: true });
addAnalytics(path.resolve(viewerDeployPath, 'index.html'));
}
function copyDemos() {
console.log('\n###', 'copy demos files');
const lightingBuildPath = path.resolve(buildDir, '../build/examples/lighting/');
const lightingDeployPath = path.resolve(localPath, 'demos/lighting/');
fse.copySync(lightingBuildPath, lightingDeployPath, { overwrite: true });
addAnalytics(path.resolve(lightingDeployPath, 'index.html'));
const orbitalsBuildPath = path.resolve(buildDir, '../build/examples/alpha-orbitals/');
const orbitalsDeployPath = path.resolve(localPath, 'demos/alpha-orbitals/');
fse.copySync(orbitalsBuildPath, orbitalsDeployPath, { overwrite: true });
addAnalytics(path.resolve(orbitalsDeployPath, 'index.html'));
}
function copyFiles() {
copyViewer();
copyDemos();
}
if (!fs.existsSync(localPath)) {
@@ -42,9 +70,9 @@ if (!fs.existsSync(path.resolve(localPath, '.git/'))) {
.outputHandler(log)
.clone(remoteUrl, localPath)
.fetch(['--all'])
.exec(copyViewer)
.exec(copyFiles)
.add(['-A'])
.commit('updated viewer')
.commit('updated viewer & demos')
.push();
} else {
console.log('\n###', 'update repository');
@@ -52,8 +80,8 @@ if (!fs.existsSync(path.resolve(localPath, '.git/'))) {
.outputHandler(log)
.fetch(['--all'])
.reset(['--hard', 'origin/master'])
.exec(copyViewer)
.exec(copyFiles)
.add(['-A'])
.commit('updated viewer')
.commit('updated viewer & demos')
.push();
}

View File

@@ -19,19 +19,19 @@
<div id="app"></div>
<script type="text/javascript" src="./molstar.js"></script>
<script type="text/javascript">
var viewer = new DockingViewer('app', [0x33DD22, 0x1133EE], true);
function getParam(name, regex) {
var r = new RegExp(name + '=' + '(' + regex + ')[&]?', 'i');
return decodeURIComponent(((window.location.search || '').match(r) || [])[1] || '');
}
var pdbqt = getParam('pdbqt', '[^&]+').trim();
var mol2 = getParam('mol2', '[^&]+').trim();
var pdbqt = getParam('pdbqt', '[^&]+').trim() || '../../examples/ace2.pdbqt';
var mol2 = getParam('mol2', '[^&]+').trim() || '../../examples/ace2-hit.mol2';
viewer.loadStructuresFromUrlsAndMerge([
{ url: pdbqt, format: 'pdbqt' },
{ url: mol2, format: 'mol2' }
]);
DockingViewer.create('app', [0x33DD22, 0x1133EE], true).then(viewer => {
viewer.loadStructuresFromUrlsAndMerge([
{ url: pdbqt, format: 'pdbqt' },
{ url: mol2, format: 'mol2' }
]);
});
</script>
</body>
</html>

View File

@@ -8,7 +8,7 @@
import { Structure } from '../../mol-model/structure';
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
import { PluginStateObject as PSO, PluginStateTransform } from '../../mol-plugin-state/objects';
import { createPlugin } from '../../mol-plugin-ui';
import { createPluginUI } from '../../mol-plugin-ui';
import { PluginUIContext } from '../../mol-plugin-ui/context';
import { PluginLayoutControlsDisplay } from '../../mol-plugin/layout';
import { DefaultPluginUISpec, PluginUISpec } from '../../mol-plugin-ui/spec';
@@ -54,9 +54,10 @@ const DefaultViewerOptions = {
};
class Viewer {
plugin: PluginUIContext
constructor(public plugin: PluginUIContext) {
}
constructor(elementOrId: string | HTMLElement, colors = [Color(0x992211), Color(0xDDDDDD)], showButtons = true) {
static async create(elementOrId: string | HTMLElement, colors = [Color(0x992211), Color(0xDDDDDD)], showButtons = true) {
const o = { ...DefaultViewerOptions, ...{
layoutIsExpanded: false,
layoutShowControls: false,
@@ -125,29 +126,31 @@ class Viewer {
? document.getElementById(elementOrId)
: elementOrId;
if (!element) throw new Error(`Could not get element with id '${elementOrId}'`);
this.plugin = createPlugin(element, spec);
const plugin = await createPluginUI(element, spec);
(this.plugin.customState as any) = {
(plugin.customState as any) = {
colorPalette: {
name: 'colors',
params: { list: { colors } }
}
};
this.plugin.behaviors.canvas3d.initialized.subscribe(v => {
plugin.behaviors.canvas3d.initialized.subscribe(v => {
if (v) {
PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: {
PluginCommands.Canvas3D.SetSettings(plugin, { settings: {
renderer: {
...this.plugin.canvas3d!.props.renderer,
...plugin.canvas3d!.props.renderer,
backgroundColor: ColorNames.white,
},
camera: {
...this.plugin.canvas3d!.props.camera,
...plugin.canvas3d!.props.camera,
helper: { axes: { name: 'off', params: {} } }
}
} });
}
});
return new Viewer(plugin);
}
async loadStructuresFromUrlsAndMerge(sources: { url: string, format: BuiltInTrajectoryFormat, isBinary?: boolean }[]) {

View File

@@ -21,12 +21,12 @@ import { PluginContext } from '../../mol-plugin/context';
import { MolScriptBuilder as MS } from '../../mol-script/language/builder';
import { StateObjectRef } from '../../mol-state';
import { Color } from '../../mol-util/color';
import { Material } from '../../mol-util/material';
function shinyStyle(plugin: PluginContext) {
return PluginCommands.Canvas3D.SetSettings(plugin, { settings: {
renderer: {
...plugin.canvas3d!.props.renderer,
style: { name: 'plastic', params: {} },
},
postprocessing: {
...plugin.canvas3d!.props.postprocessing,
@@ -40,7 +40,6 @@ function occlusionStyle(plugin: PluginContext) {
return PluginCommands.Canvas3D.SetSettings(plugin, { settings: {
renderer: {
...plugin.canvas3d!.props.renderer,
style: { name: 'flat', params: {} }
},
postprocessing: {
...plugin.canvas3d!.props.postprocessing,
@@ -52,7 +51,8 @@ function occlusionStyle(plugin: PluginContext) {
} },
outline: { name: 'on', params: {
scale: 1.0,
threshold: 0.33
threshold: 0.33,
color: Color(0x0000),
} }
}
} });
@@ -77,7 +77,7 @@ const PresetParams = {
...StructureRepresentationPresetProvider.CommonParams,
};
const CustomMaterial = Material({ roughness: 0.2, metalness: 0 });
export const StructurePreset = StructureRepresentationPresetProvider({
id: 'preset-structure',
@@ -94,8 +94,8 @@ export const StructurePreset = StructureRepresentationPresetProvider({
const { update, builder, typeParams } = StructureRepresentationPresetProvider.reprBuilder(plugin, params);
const representations = {
ligand: builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams: { ...typeParams, sizeFactor: 0.35 }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ligand' }),
polymer: builder.buildRepresentation(update, components.polymer, { type: 'cartoon', typeParams: { ...typeParams }, color: 'chain-id', colorParams: { palette: (plugin.customState as any).colorPalette } }, { tag: 'polymer' }),
ligand: builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams: { ...typeParams, material: CustomMaterial, sizeFactor: 0.35 }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ligand' }),
polymer: builder.buildRepresentation(update, components.polymer, { type: 'cartoon', typeParams: { ...typeParams, material: CustomMaterial }, color: 'chain-id', colorParams: { palette: (plugin.customState as any).colorPalette } }, { tag: 'polymer' }),
};
await update.commit({ revertOnError: true });
@@ -121,8 +121,8 @@ export const IllustrativePreset = StructureRepresentationPresetProvider({
const { update, builder, typeParams } = StructureRepresentationPresetProvider.reprBuilder(plugin, params);
const representations = {
ligand: builder.buildRepresentation(update, components.ligand, { type: 'spacefill', typeParams: { ...typeParams }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ligand' }),
polymer: builder.buildRepresentation(update, components.polymer, { type: 'spacefill', typeParams: { ...typeParams }, color: 'illustrative', colorParams: { palette: (plugin.customState as any).colorPalette } }, { tag: 'polymer' }),
ligand: builder.buildRepresentation(update, components.ligand, { type: 'spacefill', typeParams: { ...typeParams, ignoreLight: true }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ligand' }),
polymer: builder.buildRepresentation(update, components.polymer, { type: 'spacefill', typeParams: { ...typeParams, ignoreLight: true }, color: 'illustrative', colorParams: { palette: (plugin.customState as any).colorPalette } }, { tag: 'polymer' }),
};
await update.commit({ revertOnError: true });
@@ -149,8 +149,8 @@ const SurfacePreset = StructureRepresentationPresetProvider({
const { update, builder, typeParams } = StructureRepresentationPresetProvider.reprBuilder(plugin, params);
const representations = {
ligand: builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams: { ...typeParams, sizeFactor: 0.26 }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ligand' }),
polymer: builder.buildRepresentation(update, components.polymer, { type: 'molecular-surface', typeParams: { ...typeParams, quality: 'custom', resolution: 0.5, doubleSided: true }, color: 'partial-charge' }, { tag: 'polymer' }),
ligand: builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams: { ...typeParams, material: CustomMaterial, sizeFactor: 0.26 }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ligand' }),
polymer: builder.buildRepresentation(update, components.polymer, { type: 'molecular-surface', typeParams: { ...typeParams, material: CustomMaterial, quality: 'custom', resolution: 0.5, doubleSided: true }, color: 'partial-charge' }, { tag: 'polymer' }),
};
await update.commit({ revertOnError: true });
@@ -177,8 +177,8 @@ const PocketPreset = StructureRepresentationPresetProvider({
const { update, builder, typeParams } = StructureRepresentationPresetProvider.reprBuilder(plugin, params);
const representations = {
ligand: builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams: { ...typeParams, sizeFactor: 0.26 }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ligand' }),
surroundings: builder.buildRepresentation(update, components.surroundings, { type: 'molecular-surface', typeParams: { ...typeParams, includeParent: true, quality: 'custom', resolution: 0.2, doubleSided: true }, color: 'partial-charge' }, { tag: 'surroundings' }),
ligand: builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams: { ...typeParams, material: CustomMaterial, sizeFactor: 0.26 }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ligand' }),
surroundings: builder.buildRepresentation(update, components.surroundings, { type: 'molecular-surface', typeParams: { ...typeParams, material: CustomMaterial, includeParent: true, quality: 'custom', resolution: 0.2, doubleSided: true }, color: 'partial-charge' }, { tag: 'surroundings' }),
};
await update.commit({ revertOnError: true });
@@ -206,10 +206,10 @@ const InteractionsPreset = StructureRepresentationPresetProvider({
const { update, builder, typeParams } = StructureRepresentationPresetProvider.reprBuilder(plugin, params);
const representations = {
ligand: builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams: { ...typeParams, sizeFactor: 0.3 }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ligand' }),
ballAndStick: builder.buildRepresentation(update, components.surroundings, { type: 'ball-and-stick', typeParams: { ...typeParams, sizeFactor: 0.1, sizeAspectRatio: 1 }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ball-and-stick' }),
interactions: builder.buildRepresentation(update, components.interactions, { type: InteractionsRepresentationProvider, typeParams: { ...typeParams }, color: InteractionTypeColorThemeProvider }, { tag: 'interactions' }),
label: builder.buildRepresentation(update, components.surroundings, { type: 'label', typeParams: { ...typeParams, background: false, borderWidth: 0.1 }, color: 'uniform', colorParams: { value: Color(0x000000) } }, { tag: 'label' }),
ligand: builder.buildRepresentation(update, components.ligand, { type: 'ball-and-stick', typeParams: { ...typeParams, material: CustomMaterial, sizeFactor: 0.3 }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ligand' }),
ballAndStick: builder.buildRepresentation(update, components.surroundings, { type: 'ball-and-stick', typeParams: { ...typeParams, material: CustomMaterial, sizeFactor: 0.1, sizeAspectRatio: 1 }, color: 'element-symbol', colorParams: { carbonColor: { name: 'element-symbol', params: {} } } }, { tag: 'ball-and-stick' }),
interactions: builder.buildRepresentation(update, components.interactions, { type: InteractionsRepresentationProvider, typeParams: { ...typeParams, material: CustomMaterial }, color: InteractionTypeColorThemeProvider }, { tag: 'interactions' }),
label: builder.buildRepresentation(update, components.surroundings, { type: 'label', typeParams: { ...typeParams, material: CustomMaterial, background: false, borderWidth: 0.1 }, color: 'uniform', colorParams: { value: Color(0x000000) } }, { tag: 'label' }),
};
await update.commit({ revertOnError: true });
@@ -230,7 +230,7 @@ export class ViewportComponent extends PluginUIComponent {
set = async (preset: StructureRepresentationPresetProvider) => {
await this._set(this.plugin.managers.structure.hierarchy.selection.structures, preset);
}
};
structurePreset = () => this.set(StructurePreset);
illustrativePreset = () => this.set(IllustrativePreset);

View File

@@ -20,7 +20,7 @@
<div id="app"></div>
<script type="text/javascript" src="./molstar.js"></script>
<script type="text/javascript">
var viewer = new molstar.Viewer('app', {
molstar.Viewer.create('app', {
layoutIsExpanded: true,
layoutShowControls: false,
layoutShowRemoteState: false,
@@ -34,11 +34,11 @@
pdbProvider: 'rcsb',
emdbProvider: 'rcsb',
}).then(viewer => {
viewer.loadPdb('7bv2');
viewer.loadEmdb('EMD-30210', { detail: 6 });
// viewer.loadAllModelsOrAssemblyFromUrl('https://cs.litemol.org/5ire/full', 'mmcif', false, { representationParams: { theme: { globalName: 'operator-name' } } })
});
viewer.loadPdb('7bv2');
viewer.loadEmdb('EMD-30210', { detail: 6 });
// viewer.loadAllModelsOrAssemblyFromUrl('https://cs.litemol.org/5ire/full', 'mmcif', false, { representationParams: { theme: { globalName: 'operator-name' } } })
</script>
</body>
</html>

View File

@@ -56,7 +56,10 @@
var pixelScale = getParam('pixel-scale', '[^&]+').trim();
var pickScale = getParam('pick-scale', '[^&]+').trim();
var pickPadding = getParam('pick-padding', '[^&]+').trim();
var viewer = new molstar.Viewer('app', {
var disableWboit = getParam('disable-wboit', '[^&]+').trim() === '1';
var preferWebgl1 = getParam('prefer-webgl1', '[^&]+').trim() === '1';
molstar.Viewer.create('app', {
layoutShowControls: !hideControls,
viewportShowExpand: false,
collapseLeftPanel: collapseLeftPanel,
@@ -68,28 +71,37 @@
pixelScale: parseFloat(pixelScale) || 1,
pickScale: parseFloat(pickScale) || 0.25,
pickPadding: isNaN(parseFloat(pickPadding)) ? 1 : parseFloat(pickPadding),
enableWboit: !disableWboit,
preferWebgl1: preferWebgl1,
}).then(viewer => {
var snapshotId = getParam('snapshot-id', '[^&]+').trim();
if (snapshotId) viewer.setRemoteSnapshot(snapshotId);
var snapshotUrl = getParam('snapshot-url', '[^&]+').trim();
var snapshotUrlType = getParam('snapshot-url-type', '[^&]+').toLowerCase().trim() || 'molj';
if (snapshotUrl && snapshotUrlType) viewer.loadSnapshotFromUrl(snapshotUrl, snapshotUrlType);
var structureUrl = getParam('structure-url', '[^&]+').trim();
var structureUrlFormat = getParam('structure-url-format', '[a-z]+').toLowerCase().trim();
var structureUrlIsBinary = getParam('structure-url-is-binary', '[^&]+').trim() === '1';
if (structureUrl) viewer.loadStructureFromUrl(structureUrl, structureUrlFormat, structureUrlIsBinary);
var pdb = getParam('pdb', '[^&]+').trim();
if (pdb) viewer.loadPdb(pdb);
var pdbDev = getParam('pdb-dev', '[^&]+').trim();
if (pdbDev) viewer.loadPdbDev(pdbDev);
var emdb = getParam('emdb', '[^&]+').trim();
if (emdb) viewer.loadEmdb(emdb);
var afdb = getParam('afdb', '[^&]+').trim();
if (afdb) viewer.loadAlphaFoldDb(afdb);
var modelArchive = getParam('model-archive', '[^&]+').trim();
if (modelArchive) viewer.loadModelArchive(modelArchive);
});
var snapshotId = getParam('snapshot-id', '[^&]+').trim();
if (snapshotId) viewer.setRemoteSnapshot(snapshotId);
var snapshotUrl = getParam('snapshot-url', '[^&]+').trim();
var snapshotUrlType = getParam('snapshot-url-type', '[^&]+').toLowerCase().trim() || 'molj';
if (snapshotUrl && snapshotUrlType) viewer.loadSnapshotFromUrl(snapshotUrl, snapshotUrlType);
var structureUrl = getParam('structure-url', '[^&]+').trim();
var structureUrlFormat = getParam('structure-url-format', '[a-z]+').toLowerCase().trim();
var structureUrlIsBinary = getParam('structure-url-is-binary', '[^&]+').trim() === '1';
if (structureUrl) viewer.loadStructureFromUrl(structureUrl, structureUrlFormat, structureUrlIsBinary);
var pdb = getParam('pdb', '[^&]+').trim();
if (pdb) viewer.loadPdb(pdb);
var pdbDev = getParam('pdb-dev', '[^&]+').trim();
if (pdbDev) viewer.loadPdbDev(pdbDev);
var emdb = getParam('emdb', '[^&]+').trim();
if (emdb) viewer.loadEmdb(emdb);
</script>
<!-- __MOLSTAR_ANALYTICS__ -->
</body>
</html>

View File

@@ -9,28 +9,34 @@ import { ANVILMembraneOrientation } from '../../extensions/anvil/behavior';
import { CellPack } from '../../extensions/cellpack';
import { DnatcoConfalPyramids } from '../../extensions/dnatco';
import { G3DFormat, G3dProvider } from '../../extensions/g3d/format';
import { Mp4Export } from '../../extensions/mp4-export';
import { GeometryExport } from '../../extensions/geo-export';
import { MAQualityAssessment } from '../../extensions/model-archive/quality-assessment/behavior';
import { QualityAssessmentPLDDTPreset, QualityAssessmentQmeanPreset } from '../../extensions/model-archive/quality-assessment/behavior';
import { QualityAssessment } from '../../extensions/model-archive/quality-assessment/prop';
import { Mp4Export } from '../../extensions/mp4-export';
import { PDBeStructureQualityReport } from '../../extensions/pdbe';
import { RCSBAssemblySymmetry, RCSBValidationReport } from '../../extensions/rcsb';
import { DownloadStructure, PdbDownloadProvider } from '../../mol-plugin-state/actions/structure';
import { DownloadDensity } from '../../mol-plugin-state/actions/volume';
import { StructureRepresentationPresetProvider } from '../../mol-plugin-state/builder/structure/representation-preset';
import { PresetTrajectoryHierarchy } from '../../mol-plugin-state/builder/structure/hierarchy-preset';
import { PresetStructureRepresentations, StructureRepresentationPresetProvider } from '../../mol-plugin-state/builder/structure/representation-preset';
import { DataFormatProvider } from '../../mol-plugin-state/formats/provider';
import { BuildInStructureFormat } from '../../mol-plugin-state/formats/structure';
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
import { BuildInVolumeFormat } from '../../mol-plugin-state/formats/volume';
import { createVolumeRepresentationParams } from '../../mol-plugin-state/helpers/volume-representation-params';
import { PluginStateObject } from '../../mol-plugin-state/objects';
import { StateTransforms } from '../../mol-plugin-state/transforms';
import { createPlugin } from '../../mol-plugin-ui';
import { TrajectoryFromModelAndCoordinates } from '../../mol-plugin-state/transforms/model';
import { createPluginUI } from '../../mol-plugin-ui';
import { PluginUIContext } from '../../mol-plugin-ui/context';
import { PluginLayoutControlsDisplay } from '../../mol-plugin/layout';
import { DefaultPluginUISpec, PluginUISpec } from '../../mol-plugin-ui/spec';
import { PluginCommands } from '../../mol-plugin/commands';
import { PluginConfig } from '../../mol-plugin/config';
import { PluginLayoutControlsDisplay } from '../../mol-plugin/layout';
import { PluginSpec } from '../../mol-plugin/spec';
import { PluginState } from '../../mol-plugin/state';
import { StateObjectSelector } from '../../mol-state';
import { StateObjectRef, StateObjectSelector } from '../../mol-state';
import { Asset } from '../../mol-util/assets';
import { Color } from '../../mol-util/color';
import '../../mol-util/polyfill';
@@ -57,7 +63,8 @@ const Extensions = {
'anvil-membrane-orientation': PluginSpec.Behavior(ANVILMembraneOrientation),
'g3d': PluginSpec.Behavior(G3DFormat),
'mp4-export': PluginSpec.Behavior(Mp4Export),
'geo-export': PluginSpec.Behavior(GeometryExport)
'geo-export': PluginSpec.Behavior(GeometryExport),
'ma-quality-assessment': PluginSpec.Behavior(MAQualityAssessment),
};
const DefaultViewerOptions = {
@@ -71,11 +78,13 @@ const DefaultViewerOptions = {
layoutShowLog: true,
layoutShowLeftPanel: true,
collapseLeftPanel: false,
collapseRightPanel: false,
disableAntialiasing: PluginConfig.General.DisableAntialiasing.defaultValue,
pixelScale: PluginConfig.General.PixelScale.defaultValue,
pickScale: PluginConfig.General.PickScale.defaultValue,
pickPadding: PluginConfig.General.PickPadding.defaultValue,
enableWboit: PluginConfig.General.EnableWboit.defaultValue,
preferWebgl1: PluginConfig.General.PreferWebGl1.defaultValue,
viewportShowExpand: PluginConfig.Viewport.ShowExpand.defaultValue,
viewportShowControls: PluginConfig.Viewport.ShowControls.defaultValue,
@@ -91,9 +100,10 @@ const DefaultViewerOptions = {
type ViewerOptions = typeof DefaultViewerOptions;
export class Viewer {
plugin: PluginUIContext
constructor(public plugin: PluginUIContext) {
}
constructor(elementOrId: string | HTMLElement, options: Partial<ViewerOptions> = {}) {
static async create(elementOrId: string | HTMLElement, options: Partial<ViewerOptions> = {}) {
const o = { ...DefaultViewerOptions, ...options };
const defaultSpec = DefaultPluginUISpec();
@@ -114,7 +124,7 @@ export class Viewer {
regionState: {
bottom: 'full',
left: o.collapseLeftPanel ? 'collapsed' : 'full',
right: 'full',
right: o.collapseRightPanel ? 'hidden' : 'full',
top: 'full',
}
},
@@ -135,6 +145,7 @@ export class Viewer {
[PluginConfig.General.PickScale, o.pickScale],
[PluginConfig.General.PickPadding, o.pickPadding],
[PluginConfig.General.EnableWboit, o.enableWboit],
[PluginConfig.General.PreferWebGl1, o.preferWebgl1],
[PluginConfig.Viewport.ShowExpand, o.viewportShowExpand],
[PluginConfig.Viewport.ShowControls, o.viewportShowControls],
[PluginConfig.Viewport.ShowSettings, o.viewportShowSettings],
@@ -145,7 +156,8 @@ export class Viewer {
[PluginConfig.VolumeStreaming.DefaultServer, o.volumeStreamingServer],
[PluginConfig.VolumeStreaming.Enabled, !o.volumeStreamingDisabled],
[PluginConfig.Download.DefaultPdbProvider, o.pdbProvider],
[PluginConfig.Download.DefaultEmdbProvider, o.emdbProvider]
[PluginConfig.Download.DefaultEmdbProvider, o.emdbProvider],
[PluginConfig.Structure.DefaultRepresentationPreset, ViewerAutoPreset.id],
]
};
@@ -153,7 +165,14 @@ export class Viewer {
? document.getElementById(elementOrId)
: elementOrId;
if (!element) throw new Error(`Could not get element with id '${elementOrId}'`);
this.plugin = createPlugin(element, spec);
const plugin = await createPluginUI(element, spec, {
onBeforeUIRender: plugin => {
// the preset needs to be added before the UI renders otherwise
// "Download Structure" wont be able to pick it up
plugin.builders.structure.representation.registerPreset(ViewerAutoPreset);
}
});
return new Viewer(plugin);
}
setRemoteSnapshot(id: string) {
@@ -247,6 +266,35 @@ export class Viewer {
}));
}
loadAlphaFoldDb(afdb: string) {
const params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj!, this.plugin);
return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
source: {
name: 'alphafolddb' as const,
params: {
id: afdb,
options: {
...params.source.params.options,
representation: 'preset-structure-representation-ma-quality-assessment-plddt'
},
}
}
}));
}
loadModelArchive(id: string) {
const params = DownloadStructure.createDefaultParams(this.plugin.state.data.root.obj!, this.plugin);
return this.plugin.runTask(this.plugin.state.data.applyAction(DownloadStructure, {
source: {
name: 'modelarchive' as const,
params: {
id,
options: params.source.params.options,
}
}
}));
}
/**
* @example Load X-ray density from volume server
viewer.loadVolumeFromUrl({
@@ -328,6 +376,56 @@ export class Viewer {
});
}
/**
* @example
* viewer.loadTrajectory({
* model: { kind: 'model-url', url: 'villin.gro', format: 'gro' },
* coordinates: { kind: 'coordinates-url', url: 'villin.xtc', format: 'xtc', isBinary: true },
* preset: 'all-models' // or 'default'
* });
*/
async loadTrajectory(params: LoadTrajectoryParams) {
const plugin = this.plugin;
let model: StateObjectSelector, coords: StateObjectSelector;
if (params.model.kind === 'model-data' || params.model.kind === 'model-url') {
const data = params.model.kind === 'model-data'
? await plugin.builders.data.rawData({ data: params.model.data, label: params.modelLabel })
: await plugin.builders.data.download({ url: params.model.url, isBinary: params.model.isBinary, label: params.modelLabel });
const trajectory = await plugin.builders.structure.parseTrajectory(data, params.model.format ?? 'mmcif');
model = await plugin.builders.structure.createModel(trajectory);
} else {
const data = params.model.kind === 'topology-data'
? await plugin.builders.data.rawData({ data: params.model.data, label: params.modelLabel })
: await plugin.builders.data.download({ url: params.model.url, isBinary: params.model.isBinary, label: params.modelLabel });
const provider = plugin.dataFormats.get(params.model.format);
model = await provider!.parse(plugin, data);
}
{
const data = params.coordinates.kind === 'coordinates-data'
? await plugin.builders.data.rawData({ data: params.coordinates.data, label: params.coordinatesLabel })
: await plugin.builders.data.download({ url: params.coordinates.url, isBinary: params.coordinates.isBinary, label: params.coordinatesLabel });
const provider = plugin.dataFormats.get(params.coordinates.format);
coords = await provider!.parse(plugin, data);
}
const trajectory = await plugin.build().toRoot()
.apply(TrajectoryFromModelAndCoordinates, {
modelRef: model.ref,
coordinatesRef: coords.ref
}, { dependsOn: [model.ref, coords.ref] })
.commit();
const preset = await plugin.builders.structure.hierarchy.applyPreset(trajectory, params.preset ?? 'default');
return { model, coords, preset };
}
handleResize() {
this.plugin.layout.events.updated.next(void 0);
}
@@ -343,4 +441,44 @@ export interface VolumeIsovalueInfo {
color: Color,
alpha?: number,
volumeIndex?: number
}
}
export interface LoadTrajectoryParams {
model: { kind: 'model-url', url: string, format?: BuiltInTrajectoryFormat /* mmcif */, isBinary?: boolean }
| { kind: 'model-data', data: string | number[] | ArrayBuffer | Uint8Array, format?: BuiltInTrajectoryFormat /* mmcif */ }
| { kind: 'topology-url', url: string, format: BuildInStructureFormat, isBinary?: boolean }
| { kind: 'topology-data', data: string | number[] | ArrayBuffer | Uint8Array, format: BuildInStructureFormat },
modelLabel?: string,
coordinates: { kind: 'coordinates-url', url: string, format: BuildInStructureFormat, isBinary?: boolean }
| { kind: 'coordinates-data', data: string | number[] | ArrayBuffer | Uint8Array, format: BuildInStructureFormat },
coordinatesLabel?: string,
preset?: keyof PresetTrajectoryHierarchy
}
export const ViewerAutoPreset = StructureRepresentationPresetProvider({
id: 'preset-structure-representation-viewer-auto',
display: {
name: 'Automatic (w/ Annotation)', group: 'Annotation',
description: 'Show standard automatic representation but colored by quality assessment (if available in the model).'
},
isApplicable(a) {
return (
!!a.data.models.some(m => QualityAssessment.isApplicable(m, 'pLDDT')) ||
!!a.data.models.some(m => QualityAssessment.isApplicable(m, 'qmean'))
);
},
params: () => StructureRepresentationPresetProvider.CommonParams,
async apply(ref, params, plugin) {
const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref);
const structure = structureCell?.obj?.data;
if (!structureCell || !structure) return {};
if (!!structure.models.some(m => QualityAssessment.isApplicable(m, 'pLDDT'))) {
return await QualityAssessmentPLDDTPreset.apply(ref, params, plugin);
} else if (!!structure.models.some(m => QualityAssessment.isApplicable(m, 'qmean'))) {
return await QualityAssessmentQmeanPreset.apply(ref, params, plugin);
} else {
return await PresetStructureRepresentations.auto.apply(ref, params, plugin);
}
}
});

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env node
/**
* Copyright (c) 2017-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2017-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -35,20 +35,16 @@ async function runGenerateSchemaMmcif(name: string, fieldNamesPath: string, type
const ihmDic = await parseCifText(fs.readFileSync(IHM_DIC_PATH, 'utf8')).run();
if (ihmDic.isError) throw ihmDic;
await ensureCarbBranchDicAvailable();
const carbBranchDic = await parseCifText(fs.readFileSync(CARB_BRANCH_DIC_PATH, 'utf8')).run();
if (carbBranchDic.isError) throw carbBranchDic;
await ensureCarbCompDicAvailable();
const carbCompDic = await parseCifText(fs.readFileSync(CARB_COMP_DIC_PATH, 'utf8')).run();
if (carbCompDic.isError) throw carbCompDic;
await ensureMaDicAvailable();
const maDic = await parseCifText(fs.readFileSync(MA_DIC_PATH, 'utf8')).run();
if (maDic.isError) throw maDic;
const mmcifDicVersion = getDicVersion(mmcifDic.result.blocks[0]);
const ihmDicVersion = getDicVersion(ihmDic.result.blocks[0]);
const carbDicVersion = 'draft';
const version = `Dictionary versions: mmCIF ${mmcifDicVersion}, IHM ${ihmDicVersion}, CARB ${carbDicVersion}.`;
const maDicVersion = getDicVersion(maDic.result.blocks[0]);
const version = `Dictionary versions: mmCIF ${mmcifDicVersion}, IHM ${ihmDicVersion}, MA ${maDicVersion}.`;
const frames: CifFrame[] = [...mmcifDic.result.blocks[0].saveFrames, ...ihmDic.result.blocks[0].saveFrames, ...carbBranchDic.result.blocks[0].saveFrames, ...carbCompDic.result.blocks[0].saveFrames];
const frames: CifFrame[] = [...mmcifDic.result.blocks[0].saveFrames, ...ihmDic.result.blocks[0].saveFrames, ...maDic.result.blocks[0].saveFrames];
const schema = generateSchema(frames);
await runGenerateSchema(name, version, schema, fieldNamesPath, typescript, out, moldbImportPath, addAliases);
@@ -139,8 +135,7 @@ async function getFieldNamesFilter(fieldNamesPath: string): Promise<Filter> {
async function ensureMmcifDicAvailable() { await ensureDicAvailable(MMCIF_DIC_PATH, MMCIF_DIC_URL); }
async function ensureIhmDicAvailable() { await ensureDicAvailable(IHM_DIC_PATH, IHM_DIC_URL); }
async function ensureCarbBranchDicAvailable() { await ensureDicAvailable(CARB_BRANCH_DIC_PATH, CARB_BRANCH_DIC_URL); }
async function ensureCarbCompDicAvailable() { await ensureDicAvailable(CARB_COMP_DIC_PATH, CARB_COMP_DIC_URL); }
async function ensureMaDicAvailable() { await ensureDicAvailable(MA_DIC_PATH, MA_DIC_URL); }
async function ensureCifCoreDicAvailable() {
await ensureDicAvailable(CIF_CORE_DIC_PATH, CIF_CORE_DIC_URL);
await ensureDicAvailable(CIF_CORE_ENUM_PATH, CIF_CORE_ENUM_URL);
@@ -165,10 +160,8 @@ const MMCIF_DIC_PATH = `${DIC_DIR}/mmcif_pdbx_v50.dic`;
const MMCIF_DIC_URL = 'http://mmcif.wwpdb.org/dictionaries/ascii/mmcif_pdbx_v50.dic';
const IHM_DIC_PATH = `${DIC_DIR}/ihm-extension.dic`;
const IHM_DIC_URL = 'https://raw.githubusercontent.com/ihmwg/IHM-dictionary/master/ihm-extension.dic';
const CARB_BRANCH_DIC_PATH = `${DIC_DIR}/entity_branch-extension.dic`;
const CARB_BRANCH_DIC_URL = 'https://raw.githubusercontent.com/pdbxmmcifwg/carbohydrate-extension/master/dict/entity_branch-extension.dic';
const CARB_COMP_DIC_PATH = `${DIC_DIR}/chem_comp-extension.dic`;
const CARB_COMP_DIC_URL = 'https://raw.githubusercontent.com/pdbxmmcifwg/carbohydrate-extension/master/dict/chem_comp-extension.dic';
const MA_DIC_PATH = `${DIC_DIR}/ma-extension.dic`;
const MA_DIC_URL = 'https://raw.githubusercontent.com/ihmwg/MA-dictionary/master/mmcif_ma.dic';
const CIF_CORE_DIC_PATH = `${DIC_DIR}/cif_core.dic`;
const CIF_CORE_DIC_URL = 'https://raw.githubusercontent.com/COMCIFS/cif_core/master/cif_core.dic';

View File

@@ -84,6 +84,7 @@ export function getFieldType(type: string, description: string, values?: string[
case 'DateTime':
case 'Tag':
case 'Implied':
case 'Word':
return wrapContainer('str', ',', description, container);
case 'Real':
return wrapContainer('float', ',', description, container);

View File

@@ -57,5 +57,6 @@
<script>
AlphaOrbitalsExample.init('app')
</script>
<!-- __MOLSTAR_ANALYTICS__ -->
</body>
</html>

View File

@@ -11,7 +11,7 @@ import { SphericalBasisOrder } from '../../extensions/alpha-orbitals/spherical-f
import { BasisAndOrbitals, CreateOrbitalDensityVolume, CreateOrbitalRepresentation3D, CreateOrbitalVolume, StaticBasisAndOrbitals } from '../../extensions/alpha-orbitals/transforms';
import { canComputeGrid3dOnGPU } from '../../mol-gl/compute/grid3d';
import { PluginStateObject } from '../../mol-plugin-state/objects';
import { createPluginAsync } from '../../mol-plugin-ui';
import { createPluginUI } from '../../mol-plugin-ui';
import { PluginUIContext } from '../../mol-plugin-ui/context';
import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec';
import { PluginCommands } from '../../mol-plugin/commands';
@@ -54,7 +54,7 @@ export class AlphaOrbitalsExample {
async init(target: string | HTMLElement) {
const defaultSpec = DefaultPluginUISpec();
this.plugin = await createPluginAsync(typeof target === 'string' ? document.getElementById(target)! : target, {
this.plugin = await createPluginUI(typeof target === 'string' ? document.getElementById(target)! : target, {
...defaultSpec,
layout: {
initial: {
@@ -67,7 +67,7 @@ export class AlphaOrbitalsExample {
},
canvas3d: {
camera: {
helper: { axes: { name: 'off', params: { } } }
helper: { axes: { name: 'off', params: {} } }
}
},
config: [
@@ -97,7 +97,7 @@ export class AlphaOrbitalsExample {
}
readonly params = new BehaviorSubject<ParamDefinition.For<Params>>({} as any);
readonly state = new BehaviorSubject<Params>({ show: { name: 'orbital', params: { index: 32 } }, isoValue: 1, gpuSurface: false });
readonly state = new BehaviorSubject<Params>({ show: { name: 'orbital', params: { index: 32 } }, isoValue: 1, gpuSurface: true });
private selectors?: Selectors = void 0;
private basis?: StateObjectSelector<BasisAndOrbitals> = void 0;
@@ -170,12 +170,11 @@ export class AlphaOrbitalsExample {
return {
alpha: 0.85,
color,
directVolume: this.state.value.gpuSurface,
kind,
relativeIsovalue: this.state.value.isoValue,
pickable: false,
xrayShaded: true,
tryUseGpu: false
tryUseGpu: true
};
}

View File

@@ -69,8 +69,9 @@
$('format').value = format;
$('format').onchange = function (e) { format = e.target.value; }
BasicMolStarWrapper.init('app' /** or document.getElementById('app') */);
BasicMolStarWrapper.setBackground(0xffffff);
BasicMolStarWrapper.init('app' /** or document.getElementById('app') */).then(() => {
BasicMolStarWrapper.setBackground(0xffffff);
});
addControl('Load Asym Unit', () => BasicMolStarWrapper.load({ url: url, format: format }));
addControl('Load Assembly', () => BasicMolStarWrapper.load({ url: url, format: format, assemblyId: assemblyId }));

View File

@@ -9,7 +9,7 @@ import { EmptyLoci } from '../../mol-model/loci';
import { StructureSelection } from '../../mol-model/structure';
import { AnimateModelIndex } from '../../mol-plugin-state/animation/built-in/model-index';
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
import { createPlugin } from '../../mol-plugin-ui';
import { createPluginUI } from '../../mol-plugin-ui';
import { PluginUIContext } from '../../mol-plugin-ui/context';
import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec';
import { PluginCommands } from '../../mol-plugin/commands';
@@ -28,8 +28,8 @@ type LoadParams = { url: string, format?: BuiltInTrajectoryFormat, isBinary?: bo
class BasicWrapper {
plugin: PluginUIContext;
init(target: string | HTMLElement) {
this.plugin = createPlugin(typeof target === 'string' ? document.getElementById(target)! : target, {
async init(target: string | HTMLElement) {
this.plugin = await createPluginUI(typeof target === 'string' ? document.getElementById(target)! : target, {
...DefaultPluginUISpec(),
layout: {
initial: {
@@ -60,7 +60,7 @@ class BasicWrapper {
params: { id: assemblyId }
} : {
name: 'model',
params: { }
params: {}
},
showUnitcell: false,
representationPreset: 'auto'
@@ -95,7 +95,7 @@ class BasicWrapper {
loop: () => { this.plugin.managers.animation.play(AnimateModelIndex, { duration: { name: 'computed', params: { targetFps: this.animateModelIndexTargetFps() } }, mode: { name: 'loop', params: { direction: 'forward' } } }); },
stop: () => this.plugin.managers.animation.stop()
}
}
};
coloring = {
applyStripes: async () => {
@@ -119,7 +119,7 @@ class BasicWrapper {
}
});
}
}
};
interactivity = {
highlightOn: () => {
@@ -137,7 +137,7 @@ class BasicWrapper {
clearHighlight: () => {
this.plugin.managers.interactivity.lociHighlights.highlightOnly({ loci: EmptyLoci });
}
}
};
tests = {
staticSuperposition: async () => {
@@ -168,7 +168,7 @@ class BasicWrapper {
PluginCommands.Toast.Hide(this.plugin, { key: 'toast-1' });
PluginCommands.Toast.Hide(this.plugin, { key: 'toast-2' });
}
}
};
}
(window as any).BasicMolStarWrapper = new BasicWrapper();

View File

@@ -45,8 +45,9 @@
<div id='controls'></div>
<div id="app"></div>
<script>
LightingDemo.init('app')
LightingDemo.load({ url: 'https://models.rcsb.org/4KTC.bcif', assemblyId: '1' }, 5, 1.3)
LightingDemo.init('app').then(() => {
LightingDemo.load({ url: 'https://models.rcsb.org/4KTC.bcif', assemblyId: '1' }, 5, 1.3);
});
addHeader('Example PDB IDs');
addControl('4KTC', () => LightingDemo.load({ url: 'https://models.rcsb.org/4KTC.bcif', assemblyId: '1' }, 5, 1.3));
@@ -83,5 +84,6 @@
$('controls').appendChild(h);
}
</script>
<!-- __MOLSTAR_ANALYTICS__ -->
</body>
</html>

View File

@@ -1,59 +1,62 @@
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { Canvas3DProps } from '../../mol-canvas3d/canvas3d';
import { BuiltInTrajectoryFormat } from '../../mol-plugin-state/formats/trajectory';
import { createPlugin } from '../../mol-plugin-ui';
import { createPluginUI } from '../../mol-plugin-ui';
import { PluginUIContext } from '../../mol-plugin-ui/context';
import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec';
import { PluginCommands } from '../../mol-plugin/commands';
import { Asset } from '../../mol-util/assets';
import { Color } from '../../mol-util/color';
import './index.html';
require('mol-plugin-ui/skin/light.scss');
type LoadParams = { url: string, format?: BuiltInTrajectoryFormat, isBinary?: boolean, assemblyId?: string }
type _Preset = Pick<Canvas3DProps, 'multiSample' | 'postprocessing' | 'renderer'>
type _Preset = Pick<Canvas3DProps, 'postprocessing' | 'renderer'>
type Preset = { [K in keyof _Preset]: Partial<_Preset[K]> }
const Canvas3DPresets = {
illustrative: <Preset> {
multiSample: {
mode: 'temporal' as Canvas3DProps['multiSample']['mode']
},
postprocessing: {
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
outline: { name: 'on', params: { scale: 1, threshold: 0.1 } }
},
renderer: {
style: { name: 'flat', params: {} }
illustrative: {
canvas3d: <Preset>{
postprocessing: {
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
outline: { name: 'on', params: { scale: 1, threshold: 0.33, color: Color(0x000000) } }
},
renderer: {
ambientIntensity: 1.0,
light: []
}
}
},
occlusion: <Preset> {
multiSample: {
mode: 'temporal' as Canvas3DProps['multiSample']['mode']
},
postprocessing: {
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
outline: { name: 'off', params: { } }
},
renderer: {
style: { name: 'matte', params: {} }
occlusion: {
canvas3d: <Preset>{
postprocessing: {
occlusion: { name: 'on', params: { samples: 32, radius: 6, bias: 1.4, blurKernelSize: 15 } },
outline: { name: 'off', params: {} }
},
renderer: {
ambientIntensity: 0.4,
light: [{ inclination: 180, azimuth: 0, color: Color.fromNormalizedRgb(1.0, 1.0, 1.0),
intensity: 0.6 }]
}
}
},
standard: <Preset> {
multiSample: {
mode: 'off' as Canvas3DProps['multiSample']['mode']
},
postprocessing: {
occlusion: { name: 'off', params: { } },
outline: { name: 'off', params: { } }
},
renderer: {
style: { name: 'matte', params: {} }
standard: {
canvas3d: <Preset>{
postprocessing: {
occlusion: { name: 'off', params: {} },
outline: { name: 'off', params: {} }
},
renderer: {
ambientIntensity: 0.4,
light: [{ inclination: 180, azimuth: 0, color: Color.fromNormalizedRgb(1.0, 1.0, 1.0),
intensity: 0.6 }]
}
}
}
};
@@ -68,8 +71,8 @@ class LightingDemo {
private bias = 1.1;
private preset: Canvas3DPreset = 'illustrative';
init(target: string | HTMLElement) {
this.plugin = createPlugin(typeof target === 'string' ? document.getElementById(target)! : target, {
async init(target: string | HTMLElement) {
this.plugin = await createPluginUI(typeof target === 'string' ? document.getElementById(target)! : target, {
...DefaultPluginUISpec(),
layout: {
initial: {
@@ -87,25 +90,23 @@ class LightingDemo {
setPreset(preset: Canvas3DPreset) {
const props = Canvas3DPresets[preset];
if (props.postprocessing.occlusion?.name === 'on') {
props.postprocessing.occlusion.params.radius = this.radius;
props.postprocessing.occlusion.params.bias = this.bias;
if (props.canvas3d.postprocessing.occlusion?.name === 'on') {
props.canvas3d.postprocessing.occlusion.params.radius = this.radius;
props.canvas3d.postprocessing.occlusion.params.bias = this.bias;
}
PluginCommands.Canvas3D.SetSettings(this.plugin, { settings: {
...props,
multiSample: {
...this.plugin.canvas3d!.props.multiSample,
...props.multiSample
},
renderer: {
...this.plugin.canvas3d!.props.renderer,
...props.renderer
},
postprocessing: {
...this.plugin.canvas3d!.props.postprocessing,
...props.postprocessing
},
} });
PluginCommands.Canvas3D.SetSettings(this.plugin, {
settings: {
...props,
renderer: {
...this.plugin.canvas3d!.props.renderer,
...props.canvas3d.renderer
},
postprocessing: {
...this.plugin.canvas3d!.props.postprocessing,
...props.canvas3d.postprocessing
},
}
});
}
async load({ url, format = 'mmcif', isBinary = true, assemblyId = '' }: LoadParams, radius: number, bias: number) {
@@ -114,7 +115,7 @@ class LightingDemo {
const data = await this.plugin.builders.data.download({ url: Asset.Url(url), isBinary }, { state: { isGhost: true } });
const trajectory = await this.plugin.builders.structure.parseTrajectory(data, format);
const model = await this.plugin.builders.structure.createModel(trajectory);
const structure = await this.plugin.builders.structure.createStructure(model, assemblyId ? { name: 'assembly', params: { id: assemblyId } } : { name: 'model', params: { } });
const structure = await this.plugin.builders.structure.createStructure(model, assemblyId ? { name: 'assembly', params: { id: assemblyId } } : { name: 'model', params: {} });
const polymer = await this.plugin.builders.structure.tryCreateComponentStatic(structure, 'polymer');
if (polymer) await this.plugin.builders.structure.representation.addRepresentation(polymer, { type: 'spacefill', color: 'illustrative' });

View File

@@ -103,10 +103,11 @@
PluginWrapper.init('app' /** or document.getElementById('app') */, {
customColorList: CustomColors
}).then(() => {
PluginWrapper.setBackground(0xffffff);
loadAndSnapshot({ url: url, format: format, isBinary: isBinary, assemblyId: assemblyId, representationStyle: representationStyle });
PluginWrapper.toggleSpin();
});
PluginWrapper.setBackground(0xffffff);
loadAndSnapshot({ url: url, format: format, isBinary: isBinary, assemblyId: assemblyId, representationStyle: representationStyle });
PluginWrapper.toggleSpin();
PluginWrapper.events.modelInfo.subscribe(function (info) {
console.log('Model Info', info);

View File

@@ -10,7 +10,7 @@ import { AnimateModelIndex } from '../../mol-plugin-state/animation/built-in/mod
import { createStructureRepresentationParams } from '../../mol-plugin-state/helpers/structure-representation-params';
import { PluginStateObject, PluginStateObject as PSO } from '../../mol-plugin-state/objects';
import { StateTransforms } from '../../mol-plugin-state/transforms';
import { createPlugin } from '../../mol-plugin-ui';
import { createPluginUI } from '../../mol-plugin-ui';
import { PluginUIContext } from '../../mol-plugin-ui/context';
import { DefaultPluginUISpec } from '../../mol-plugin-ui/spec';
import { CreateVolumeStreamingInfo, InitVolumeStreaming } from '../../mol-plugin/behavior/dynamic/volume-streaming/transformers';
@@ -43,10 +43,10 @@ class MolStarProteopediaWrapper {
plugin: PluginUIContext;
init(target: string | HTMLElement, options?: {
async init(target: string | HTMLElement, options?: {
customColorList?: number[]
}) {
this.plugin = createPlugin(typeof target === 'string' ? document.getElementById(target)! : target, {
this.plugin = await createPluginUI(typeof target === 'string' ? document.getElementById(target)! : target, {
...DefaultPluginUISpec(),
animations: [
AnimateModelIndex
@@ -95,7 +95,7 @@ class MolStarProteopediaWrapper {
params: { id: assemblyId }
} : {
name: 'model' as const,
params: { }
params: {}
}
};
@@ -113,7 +113,7 @@ class MolStarProteopediaWrapper {
const structure = this.getObj<PluginStateObject.Molecule.Structure>(StateElements.Assembly);
if (!structure) return;
const style = _style || { };
const style = _style || {};
const update = this.state.build();
@@ -229,7 +229,7 @@ class MolStarProteopediaWrapper {
params: { id: asmId }
} : {
name: 'model' as const,
params: { }
params: {}
}
};
tree.to(StateElements.Assembly).update(StateTransforms.Model.StructureFromModel, p => ({ ...p, ...props }));
@@ -269,8 +269,8 @@ class MolStarProteopediaWrapper {
camera = {
toggleSpin: () => this.toggleSpin(),
resetPosition: () => PluginCommands.Camera.Reset(this.plugin, { })
}
resetPosition: () => PluginCommands.Camera.Reset(this.plugin, {})
};
private animateModelIndexTargetFps() {
return Math.max(1, this.animate.modelIndex.targetFps | 0);
@@ -285,7 +285,7 @@ class MolStarProteopediaWrapper {
loop: () => { this.plugin.managers.animation.play(AnimateModelIndex, { duration: { name: 'computed', params: { targetFps: this.animateModelIndexTargetFps() } }, mode: { name: 'loop', params: { direction: 'forward' } } }); },
stop: () => this.plugin.managers.animation.stop()
}
}
};
coloring = {
evolutionaryConservation: async (params?: { sequence?: boolean, het?: boolean, keepStyle?: boolean }) => {
@@ -306,7 +306,7 @@ class MolStarProteopediaWrapper {
await PluginCommands.State.Update(this.plugin, { state, tree });
}
}
};
private experimentalDataElement?: Element = void 0;
experimentalData = {
@@ -330,17 +330,17 @@ class MolStarProteopediaWrapper {
this.experimentalDataElement = void 0;
}
}
}
};
hetGroups = {
reset: () => {
const update = this.state.build().delete(StateElements.HetGroupFocusGroup);
PluginCommands.State.Update(this.plugin, { state: this.state, tree: update });
PluginCommands.Camera.Reset(this.plugin, { });
PluginCommands.Camera.Reset(this.plugin, {});
},
focusFirst: async (compId: string, options?: { hideLabels: boolean, doNotLabelWaters: boolean }) => {
if (!this.state.transforms.has(StateElements.Assembly)) return;
await PluginCommands.Camera.Reset(this.plugin, { });
await PluginCommands.Camera.Reset(this.plugin, {});
const update = this.state.build();
@@ -397,7 +397,7 @@ class MolStarProteopediaWrapper {
const snapshot = this.plugin.canvas3d!.camera.getFocus(sphere.center, radius);
PluginCommands.Camera.SetSnapshot(this.plugin, { snapshot, durationMs: 250 });
}
}
};
snapshot = {
get: (params?: PluginState.SnapshotParams) => {
@@ -420,7 +420,7 @@ class MolStarProteopediaWrapper {
}
}
}
};
}
(window as any).MolStarProteopediaWrapper = MolStarProteopediaWrapper;

View File

@@ -166,7 +166,6 @@ export const CreateOrbitalRepresentation3D = PluginStateTransform.BuiltIn({
from: PluginStateObject.Volume.Data,
to: PluginStateObject.Volume.Representation3D,
params: {
directVolume: PD.Boolean(false),
relativeIsovalue: PD.Numeric(1, { min: 0.01, max: 5, step: 0.01 }),
kind: PD.Select<'positive' | 'negative'>('positive', [['positive', 'Positive'], ['negative', 'Negative']]),
color: PD.Color(ColorNames.blue),
@@ -217,19 +216,7 @@ function volumeParams(plugin: PluginContext, volume: PluginStateObject.Volume.Da
const value = isovalues[params.kind];
return createVolumeRepresentationParams(plugin, volume.data, params.directVolume ? {
type: 'direct-volume',
typeParams: {
alpha: params.alpha,
renderMode: {
name: 'isosurface',
params: { isoValue: { kind: 'absolute', absoluteValue: (value ?? 1000) * params.relativeIsovalue }, singleLayer: false }
},
xrayShaded: params.xrayShaded
},
color: 'uniform',
colorParams: { value: params.color }
} : {
return createVolumeRepresentationParams(plugin, volume.data, {
type: 'isosurface',
typeParams: { isoValue: { kind: 'absolute', absoluteValue: (value ?? 1000) * params.relativeIsovalue }, alpha: params.alpha, xrayShaded: params.xrayShaded, tryUseGpu: params.tryUseGpu },
color: 'uniform',

View File

@@ -30,7 +30,7 @@ export const ANVILMembraneOrientation = PluginBehavior.create<{ autoAttach: bool
description: 'Data calculated with ANVIL algorithm.'
},
ctor: class extends PluginBehavior.Handler<{ autoAttach: boolean }> {
private provider = MembraneOrientationProvider
private provider = MembraneOrientationProvider;
register(): void {
DefaultQueryRuntimeTable.addCustomProp(this.provider.descriptor);

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/

View File

@@ -1,7 +1,7 @@
/**
* Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Ludovic Autin <autin@scripps.edu>
* @author Ludovic Autin <ludovic.autin@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/

View File

@@ -13,16 +13,27 @@ export interface CellPack {
export interface CellPacking {
name: string,
location: 'surface' | 'interior' | 'cytoplasme',
location: 'surface' | 'interior' | 'cytoplasme'
ingredients: Packing['ingredients']
compartment?: CellCompartment
}
//
export interface CellCompartment {
filename?: string
geom_type?: 'raw' | 'file' | 'sphere' | 'mb' | 'None'
compartment_primitives?: CompartmentPrimitives
}
export interface Cell {
recipe: Recipe
options?: RecipeOptions
cytoplasme?: Packing
compartments?: { [key: string]: Compartment }
mapping_ids?: { [key: number]: [number, string] }
}
export interface RecipeOptions {
resultfile?: string
}
export interface Recipe {
@@ -35,8 +46,29 @@ export interface Recipe {
export interface Compartment {
surface?: Packing
interior?: Packing
geom?: unknown
geom_type?: 'raw' | 'file' | 'sphere' | 'mb' | 'None'
mb?: CompartmentPrimitives
}
// Primitives discribing a compartment
export const enum CompartmentPrimitiveType {
MetaBall = 0,
Sphere = 1,
Cube = 2,
Cylinder = 3,
Cone = 4,
Plane = 5,
None = 6
}
export interface CompartmentPrimitives{
positions?: number[];
radii?: number[];
types?: CompartmentPrimitiveType[];
}
export interface Packing {
ingredients: { [key: string]: Ingredient }
}
@@ -64,11 +96,13 @@ export interface Ingredient {
[curveX: string]: unknown;
/** the orientation in the membrane */
principalAxis?: Vec3;
principalVector?: Vec3;
/** offset along membrane */
offset?: Vec3;
ingtype?: string;
color?: Vec3;
confidence?: number;
Type?: string;
}
export interface IngredientSource {

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/

View File

@@ -2,13 +2,14 @@
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Ludovic Autin <ludovic.autin@gmail.com>
*/
import { StateAction, StateBuilder, StateTransformer, State } from '../../mol-state';
import { PluginContext } from '../../mol-plugin/context';
import { PluginStateObject as PSO } from '../../mol-plugin-state/objects';
import { ParamDefinition as PD } from '../../mol-util/param-definition';
import { Ingredient, IngredientSource, CellPacking } from './data';
import { Ingredient, CellPacking, CompartmentPrimitives } from './data';
import { getFromPdb, getFromCellPackDB, IngredientFiles, parseCif, parsePDBfile, getStructureMean, getFromOPM } from './util';
import { Model, Structure, StructureSymmetry, StructureSelection, QueryContext, Unit, Trajectory } from '../../mol-model/structure';
import { trajectoryFromMmCIF, MmcifFormat } from '../../mol-model-formats/structure/mmcif';
@@ -17,7 +18,7 @@ import { Mat4, Vec3, Quat } from '../../mol-math/linear-algebra';
import { SymmetryOperator } from '../../mol-math/geometry';
import { Task, RuntimeContext } from '../../mol-task';
import { StateTransforms } from '../../mol-plugin-state/transforms';
import { ParseCellPack, StructureFromCellpack, DefaultCellPackBaseUrl, StructureFromAssemblies } from './state';
import { ParseCellPack, StructureFromCellpack, DefaultCellPackBaseUrl, StructureFromAssemblies, CreateCompartmentSphere } from './state';
import { MolScriptBuilder as MS } from '../../mol-script/language/builder';
import { getMatFromResamplePoints } from './curve';
import { compile } from '../../mol-script/runtime/query/compiler';
@@ -28,8 +29,9 @@ import { createModels } from '../../mol-model-formats/structure/basic/parser';
import { CellpackPackingPreset, CellpackMembranePreset } from './preset';
import { Asset } from '../../mol-util/assets';
import { Color } from '../../mol-util/color';
import { readFromFile } from '../../mol-util/data-source';
import { objectForEach } from '../../mol-util/object';
import { readFromFile } from '../../mol-util/data-source';
import { ColorNames } from '../../mol-util/color/names';
function getCellPackModelUrl(fileName: string, baseUrl: string) {
return `${baseUrl}/results/${fileName}`;
@@ -41,10 +43,14 @@ class TrajectoryCache {
get(id: string) { return this.map.get(id); }
}
async function getModel(plugin: PluginContext, id: string, ingredient: Ingredient, baseUrl: string, trajCache: TrajectoryCache, file?: Asset.File) {
async function getModel(plugin: PluginContext, id: string, ingredient: Ingredient,
baseUrl: string, trajCache: TrajectoryCache, location: string,
file?: Asset.File
) {
const assetManager = plugin.managers.asset;
const modelIndex = (ingredient.source.model) ? parseInt(ingredient.source.model) : 0;
const surface = (ingredient.ingtype) ? (ingredient.ingtype === 'transmembrane') : false;
let surface = (ingredient.ingtype) ? (ingredient.ingtype === 'transmembrane') : false;
if (location === 'surface') surface = true;
let trajectory = trajCache.get(id);
const assets: Asset.Wrapper[] = [];
if (!trajectory) {
@@ -72,6 +78,7 @@ async function getModel(plugin: PluginContext, id: string, ingredient: Ingredien
try {
const data = await getFromOPM(plugin, id, assetManager);
assets.push(data.asset);
data.pdb.id! = id.toUpperCase();
trajectory = await plugin.runTask(trajectoryFromPDB(data.pdb));
} catch (e) {
// fallback to getFromPdb
@@ -100,7 +107,7 @@ async function getModel(plugin: PluginContext, id: string, ingredient: Ingredien
return { model, assets };
}
async function getStructure(plugin: PluginContext, model: Model, source: IngredientSource, props: { assembly?: string } = {}) {
async function getStructure(plugin: PluginContext, model: Model, source: Ingredient, props: { assembly?: string } = {}) {
let structure = Structure.ofModel(model);
const { assembly } = props;
@@ -108,11 +115,12 @@ async function getStructure(plugin: PluginContext, model: Model, source: Ingredi
structure = await plugin.runTask(StructureSymmetry.buildAssembly(structure, assembly));
}
let query;
if (source.selection) {
const asymIds: string[] = source.selection.replace(' ', '').replace(':', '').split('or');
if (source.source.selection) {
const sel = source.source.selection;
// selection can have the model ID as well. remove it
const asymIds: string[] = sel.replace(/ /g, '').replace(/:/g, '').split('or').slice(1);
query = MS.struct.modifier.union([
MS.struct.generator.atomGroups({
'entity-test': MS.core.rel.eq([MS.ammp('entityType'), 'polymer']),
'chain-test': MS.core.set.has([MS.set(...asymIds), MS.ammp('auth_asym_id')])
})
]);
@@ -123,11 +131,11 @@ async function getStructure(plugin: PluginContext, model: Model, source: Ingredi
})
]);
}
const compiled = compile<StructureSelection>(query);
const result = compiled(new QueryContext(structure));
structure = StructureSelection.unionStructure(result);
// change here if possible the label ?
// structure.label = source.name;
return structure;
}
@@ -141,9 +149,9 @@ function getTransformLegacy(trans: Vec3, rot: Quat) {
}
function getTransform(trans: Vec3, rot: Quat) {
const q: Quat = Quat.create(rot[0], rot[1], rot[2], rot[3]);
const q: Quat = Quat.create(-rot[0], rot[1], rot[2], -rot[3]);
const m: Mat4 = Mat4.fromQuat(Mat4.zero(), q);
const p: Vec3 = Vec3.create(trans[0], trans[1], trans[2]);
const p: Vec3 = Vec3.create(-trans[0], trans[1], trans[2]);
Mat4.setTranslation(m, p);
return m;
}
@@ -168,7 +176,7 @@ function getCurveTransforms(ingredient: Ingredient) {
for (let i = 0; i < n; ++i) {
const cname = `curve${i}`;
if (!(cname in ingredient)) {
// console.warn(`Expected '${cname}' in ingredient`)
console.warn(`Expected '${cname}' in ingredient`);
continue;
}
const _points = ingredient[cname] as Vec3[];
@@ -179,7 +187,7 @@ function getCurveTransforms(ingredient: Ingredient) {
// test for resampling
const distance: number = Vec3.distance(_points[0], _points[1]);
if (distance >= segmentLength + 2.0) {
console.info(distance);
// console.info(distance);
resampling = true;
}
const points = new Float32Array(_points.length * 3);
@@ -190,8 +198,8 @@ function getCurveTransforms(ingredient: Ingredient) {
return instances;
}
function getAssembly(transforms: Mat4[], structure: Structure) {
const builder = Structure.Builder();
function getAssembly(name: string, transforms: Mat4[], structure: Structure) {
const builder = Structure.Builder({ label: name });
const { units } = structure;
for (let i = 0, il = transforms.length; i < il; ++i) {
@@ -307,13 +315,13 @@ async function getCurve(plugin: PluginContext, name: string, ingredient: Ingredi
});
const curveModel = await plugin.runTask(curveModelTask);
return getStructure(plugin, curveModel, ingredient.source);
// ingredient.source.selection = undefined;
return getStructure(plugin, curveModel, ingredient);
}
async function getIngredientStructure(plugin: PluginContext, ingredient: Ingredient, baseUrl: string, ingredientFiles: IngredientFiles, trajCache: TrajectoryCache) {
async function getIngredientStructure(plugin: PluginContext, ingredient: Ingredient, baseUrl: string, ingredientFiles: IngredientFiles, trajCache: TrajectoryCache, location: 'surface' | 'interior' | 'cytoplasme') {
const { name, source, results, nbCurve } = ingredient;
if (source.pdb === 'None') return;
const file = ingredientFiles[source.pdb];
if (!file) {
// TODO can these be added to the library?
@@ -325,13 +333,13 @@ async function getIngredientStructure(plugin: PluginContext, ingredient: Ingredi
}
// model id in case structure is NMR
const { model, assets } = await getModel(plugin, source.pdb || name, ingredient, baseUrl, trajCache, file);
const { model, assets } = await getModel(plugin, source.pdb || name, ingredient, baseUrl, trajCache, location, file);
if (!model) return;
let structure: Structure;
if (nbCurve) {
structure = await getCurve(plugin, name, ingredient, getCurveTransforms(ingredient), model);
} else {
if ((!results || results.length === 0)) return;
let bu: string|undefined = source.bu ? source.bu : undefined;
if (bu) {
if (bu === 'AU') {
@@ -340,10 +348,11 @@ async function getIngredientStructure(plugin: PluginContext, ingredient: Ingredi
bu = bu.slice(2);
}
}
structure = await getStructure(plugin, model, source, { assembly: bu });
structure = await getStructure(plugin, model, ingredient, { assembly: bu });
// transform with offset and pcp
let legacy: boolean = true;
if (ingredient.offset || ingredient.principalAxis) {
const pcp = ingredient.principalVector ? ingredient.principalVector : ingredient.principalAxis;
if (pcp) {
legacy = false;
const structureMean = getStructureMean(structure);
Vec3.negate(structureMean, structureMean);
@@ -351,38 +360,44 @@ async function getIngredientStructure(plugin: PluginContext, ingredient: Ingredi
Mat4.setTranslation(m1, structureMean);
structure = Structure.transform(structure, m1);
if (ingredient.offset) {
if (!Vec3.exactEquals(ingredient.offset, Vec3.zero())) {
const o: Vec3 = Vec3.create(ingredient.offset[0], ingredient.offset[1], ingredient.offset[2]);
if (!Vec3.exactEquals(o, Vec3.zero())) { // -1, 1, 4e-16 ??
if (location !== 'surface') {
Vec3.negate(o, o);
}
const m: Mat4 = Mat4.identity();
Mat4.setTranslation(m, ingredient.offset);
Mat4.setTranslation(m, o);
structure = Structure.transform(structure, m);
}
}
if (ingredient.principalAxis) {
if (!Vec3.exactEquals(ingredient.principalAxis, Vec3.unitZ)) {
if (pcp) {
const p: Vec3 = Vec3.create(pcp[0], pcp[1], pcp[2]);
if (!Vec3.exactEquals(p, Vec3.unitZ)) {
const q: Quat = Quat.identity();
Quat.rotationTo(q, ingredient.principalAxis, Vec3.unitZ);
Quat.rotationTo(q, p, Vec3.unitZ);
const m: Mat4 = Mat4.fromQuat(Mat4.zero(), q);
structure = Structure.transform(structure, m);
}
}
}
structure = getAssembly(getResultTransforms(results, legacy), structure);
structure = getAssembly(name, getResultTransforms(results, legacy), structure);
}
return { structure, assets };
}
export function createStructureFromCellPack(plugin: PluginContext, packing: CellPacking, baseUrl: string, ingredientFiles: IngredientFiles) {
return Task.create('Create Packing Structure', async ctx => {
const { ingredients, name } = packing;
const { ingredients, location, name } = packing;
const assets: Asset.Wrapper[] = [];
const trajCache = new TrajectoryCache();
const structures: Structure[] = [];
const colors: Color[] = [];
let skipColors: boolean = false;
for (const iName in ingredients) {
if (ctx.shouldUpdate) await ctx.update(iName);
const ingredientStructure = await getIngredientStructure(plugin, ingredients[iName], baseUrl, ingredientFiles, trajCache);
const ingredientStructure = await getIngredientStructure(plugin, ingredients[iName], baseUrl, ingredientFiles, trajCache, location);
if (ingredientStructure) {
structures.push(ingredientStructure.structure);
assets.push(...ingredientStructure.assets);
@@ -390,7 +405,7 @@ export function createStructureFromCellPack(plugin: PluginContext, packing: Cell
if (c) {
colors.push(Color.fromNormalizedRgb(c[0], c[1], c[2]));
} else {
skipColors = true;
colors.push(Color.fromNormalizedRgb(1, 0, 0));
}
}
}
@@ -414,21 +429,20 @@ export function createStructureFromCellPack(plugin: PluginContext, packing: Cell
}
if (ctx.shouldUpdate) await ctx.update(`${name} - structure`);
const structure = Structure.create(units);
const structure = Structure.create(units, { label: name + '.' + location });
for (let i = 0, il = structure.models.length; i < il; ++i) {
Model.TrajectoryInfo.set(structure.models[i], { size: il, index: i });
}
return { structure, assets, colors: skipColors ? undefined : colors };
return { structure, assets, colors: colors };
});
}
async function handleHivRna(plugin: PluginContext, packings: CellPacking[], baseUrl: string) {
for (let i = 0, il = packings.length; i < il; ++i) {
if (packings[i].name === 'HIV1_capsid_3j3q_PackInner_0_1_0') {
if (packings[i].name === 'HIV1_capsid_3j3q_PackInner_0_1_0' || packings[i].name === 'HIV_capsid') {
const url = Asset.getUrlAsset(plugin.managers.asset, `${baseUrl}/extras/rna_allpoints.json`);
const json = await plugin.runTask(plugin.managers.asset.resolve(url, 'json', false));
const points = json.data.points as number[];
const curve0: Vec3[] = [];
for (let j = 0, jl = points.length; j < jl; j += 3) {
curve0.push(Vec3.fromArray(Vec3(), points, j));
@@ -465,7 +479,8 @@ async function loadMembrane(plugin: PluginContext, name: string, state: State, p
}
}
}
let legacy_membrane: boolean = false; // temporary variable until all membrane are converted to the new correct cif format
let geometry_membrane: boolean = false; // membrane can be a mesh geometry
let b = state.build().toRoot();
if (file) {
if (file.name.endsWith('.cif')) {
@@ -474,27 +489,82 @@ async function loadMembrane(plugin: PluginContext, name: string, state: State, p
b = b.apply(StateTransforms.Data.ReadFile, { file, isBinary: true, label: file.name }, { state: { isGhost: true } });
}
} else {
const url = Asset.getUrlAsset(plugin.managers.asset, `${params.baseUrl}/membranes/${name}.bcif`);
b = b.apply(StateTransforms.Data.Download, { url, isBinary: true, label: name }, { state: { isGhost: true } });
if (name.toLowerCase().endsWith('.bcif')) {
const url = Asset.getUrlAsset(plugin.managers.asset, `${params.baseUrl}/membranes/${name}`);
b = b.apply(StateTransforms.Data.Download, { url, isBinary: true, label: name }, { state: { isGhost: true } });
} else if (name.toLowerCase().endsWith('.cif')) {
const url = Asset.getUrlAsset(plugin.managers.asset, `${params.baseUrl}/membranes/${name}`);
b = b.apply(StateTransforms.Data.Download, { url, isBinary: false, label: name }, { state: { isGhost: true } });
} else if (name.toLowerCase().endsWith('.ply')) {
const url = Asset.getUrlAsset(plugin.managers.asset, `${params.baseUrl}/geometries/${name}`);
b = b.apply(StateTransforms.Data.Download, { url, isBinary: false, label: name }, { state: { isGhost: true } });
geometry_membrane = true;
} else {
const url = Asset.getUrlAsset(plugin.managers.asset, `${params.baseUrl}/membranes/${name}.bcif`);
b = b.apply(StateTransforms.Data.Download, { url, isBinary: true, label: name }, { state: { isGhost: true } });
legacy_membrane = true;
}
}
const membrane = await b.apply(StateTransforms.Data.ParseCif, undefined, { state: { isGhost: true } })
.apply(StateTransforms.Model.TrajectoryFromMmCif, undefined, { state: { isGhost: true } })
.apply(StateTransforms.Model.ModelFromTrajectory, undefined, { state: { isGhost: true } })
.apply(StructureFromAssemblies, undefined, { state: { isGhost: true } })
.commit({ revertOnError: true });
const membraneParams = {
representation: params.preset.representation,
const props = {
type: {
name: 'assembly' as const,
params: { id: '1' }
}
};
if (legacy_membrane) {
// old membrane
const membrane = await b.apply(StateTransforms.Data.ParseCif, undefined, { state: { isGhost: true } })
.apply(StateTransforms.Model.TrajectoryFromMmCif, undefined, { state: { isGhost: true } })
.apply(StateTransforms.Model.ModelFromTrajectory, undefined, { state: { isGhost: true } })
.apply(StructureFromAssemblies, undefined, { state: { isGhost: true } })
.commit({ revertOnError: true });
const membraneParams = {
representation: params.preset.representation,
};
await CellpackMembranePreset.apply(membrane, membraneParams, plugin);
} else if (geometry_membrane) {
await b.apply(StateTransforms.Data.ParsePly, undefined, { state: { isGhost: true } })
.apply(StateTransforms.Model.ShapeFromPly)
.apply(StateTransforms.Representation.ShapeRepresentation3D, { xrayShaded: true,
doubleSided: true, coloring: { name: 'uniform', params: { color: ColorNames.orange } } })
.commit({ revertOnError: true });
} else {
const membrane = await b.apply(StateTransforms.Data.ParseCif, undefined, { state: { isGhost: true } })
.apply(StateTransforms.Model.TrajectoryFromMmCif, undefined, { state: { isGhost: true } })
.apply(StateTransforms.Model.ModelFromTrajectory, undefined, { state: { isGhost: true } })
.apply(StateTransforms.Model.StructureFromModel, props, { state: { isGhost: true } })
.commit({ revertOnError: true });
const membraneParams = {
representation: params.preset.representation,
};
await CellpackMembranePreset.apply(membrane, membraneParams, plugin);
}
}
await CellpackMembranePreset.apply(membrane, membraneParams, plugin);
async function handleMembraneSpheres(state: State, primitives: CompartmentPrimitives) {
const nSpheres = primitives.positions!.length / 3;
// console.log('ok mb ', nSpheres);
// TODO : take in account the type of the primitives.
for (let j = 0; j < nSpheres; j++) {
await state.build()
.toRoot()
.apply(CreateCompartmentSphere, {
center: Vec3.create(
primitives.positions![j * 3 + 0],
primitives.positions![j * 3 + 1],
primitives.positions![j * 3 + 2]
),
radius: primitives!.radii![j]
})
.commit();
}
}
async function loadPackings(plugin: PluginContext, runtime: RuntimeContext, state: State, params: LoadCellPackModelParams) {
const ingredientFiles = params.ingredients || [];
let cellPackJson: StateBuilder.To<PSO.Format.Json, StateTransformer<PSO.Data.String, PSO.Format.Json>>;
let resultsFile: Asset.File | null = params.results;
if (params.source.name === 'id') {
const url = Asset.getUrlAsset(plugin.managers.asset, getCellPackModelUrl(params.source.params, params.baseUrl));
cellPackJson = state.build().toRoot()
@@ -506,29 +576,36 @@ async function loadPackings(plugin: PluginContext, runtime: RuntimeContext, stat
return;
}
let jsonFile: Asset.File;
let modelFile: Asset.File;
if (file.name.toLowerCase().endsWith('.zip')) {
const data = await readFromFile(file.file, 'zip').runInContext(runtime);
jsonFile = Asset.File(new File([data['model.json']], 'model.json'));
if (data['model.json']) {
modelFile = Asset.File(new File([data['model.json']], 'model.json'));
} else {
throw new Error('model.json missing from zip file');
}
if (data['results.bin']) {
resultsFile = Asset.File(new File([data['results.bin']], 'results.bin'));
}
objectForEach(data, (v, k) => {
if (k === 'model.json') return;
if (k === 'results.bin') return;
ingredientFiles.push(Asset.File(new File([v], k)));
});
} else {
jsonFile = file;
modelFile = file;
}
cellPackJson = state.build().toRoot()
.apply(StateTransforms.Data.ReadFile, { file: jsonFile, isBinary: false, label: jsonFile.name }, { state: { isGhost: true } });
.apply(StateTransforms.Data.ReadFile, { file: modelFile, isBinary: false, label: modelFile.name }, { state: { isGhost: true } });
}
const cellPackBuilder = cellPackJson
.apply(StateTransforms.Data.ParseJson, undefined, { state: { isGhost: true } })
.apply(ParseCellPack);
.apply(ParseCellPack, { resultsFile, baseUrl: params.baseUrl });
const cellPackObject = await state.updateTree(cellPackBuilder).runInContext(runtime);
const { packings } = cellPackObject.obj!.data;
const { packings } = cellPackObject.obj!.data;
await handleHivRna(plugin, packings, params.baseUrl);
for (let i = 0, il = packings.length; i < il; ++i) {
@@ -544,8 +621,30 @@ async function loadPackings(plugin: PluginContext, runtime: RuntimeContext, stat
representation: params.preset.representation,
};
await CellpackPackingPreset.apply(packing, packingParams, plugin);
if (packings[i].location === 'surface' && params.membrane) {
await loadMembrane(plugin, packings[i].name, state, params);
if (packings[i].compartment) {
if (params.membrane === 'lipids') {
if (packings[i].compartment!.geom_type) {
if (packings[i].compartment!.geom_type === 'file') {
// TODO: load mesh files or vertex,faces data
await loadMembrane(plugin, packings[i].compartment!.filename!, state, params);
} else if (packings[i].compartment!.compartment_primitives) {
await handleMembraneSpheres(state, packings[i].compartment!.compartment_primitives!);
}
} else {
// try loading membrane from repo as a bcif file or from the given list of files.
if (params.membrane === 'lipids') {
await loadMembrane(plugin, packings[i].name, state, params);
}
}
} else if (params.membrane === 'geometry') {
if (packings[i].compartment!.compartment_primitives) {
await handleMembraneSpheres(state, packings[i].compartment!.compartment_primitives!);
} else if (packings[i].compartment!.geom_type === 'file') {
if (packings[i].compartment!.filename!.toLowerCase().endsWith('.ply')) {
await loadMembrane(plugin, packings[i].compartment!.filename!, state, params);
}
}
}
}
}
}
@@ -555,19 +654,19 @@ const LoadCellPackModelParams = {
'id': PD.Select('InfluenzaModel2.json', [
['blood_hiv_immature_inside.json', 'Blood HIV immature'],
['HIV_immature_model.json', 'HIV immature'],
['BloodHIV1.0_mixed_fixed_nc1.cpr', 'Blood HIV'],
['HIV-1_0.1.6-8_mixed_radii_pdb.cpr', 'HIV'],
['Blood_HIV.json', 'Blood HIV'],
['HIV-1_0.1.6-8_mixed_radii_pdb.json', 'HIV'],
['influenza_model1.json', 'Influenza envelope'],
['InfluenzaModel2.json', 'Influenza Complete'],
['InfluenzaModel2.json', 'Influenza complete'],
['ExosomeModel.json', 'Exosome Model'],
['Mycoplasma1.5_mixed_pdb_fixed.cpr', 'Mycoplasma simple'],
['MycoplasmaModel.json', 'Mycoplasma WholeCell model'],
['MycoplasmaGenitalium.json', 'Mycoplasma Genitalium curated model'],
] as const, { description: 'Download the model definition with `id` from the server at `baseUrl.`' }),
'file': PD.File({ accept: '.json,.cpr,.zip', description: 'Open model definition from .json/.cpr file or open .zip file containing model definition plus ingredients.' }),
'file': PD.File({ accept: '.json,.cpr,.zip', description: 'Open model definition from .json/.cpr file or open .zip file containing model definition plus ingredients.', label: 'Recipe file' }),
}, { options: [['id', 'Id'], ['file', 'File']] }),
baseUrl: PD.Text(DefaultCellPackBaseUrl),
membrane: PD.Boolean(true),
ingredients: PD.FileList({ accept: '.cif,.bcif,.pdb', label: 'Ingredients' }),
results: PD.File({ accept: '.bin', description: 'open results file in binary format from cellpackgpu for the specified recipe', label: 'Results file' }),
membrane: PD.Select('lipids', PD.arrayToOptions(['lipids', 'geometry', 'none'])),
ingredients: PD.FileList({ accept: '.cif,.bcif,.pdb', label: 'Ingredient files' }),
preset: PD.Group({
traceOnly: PD.Boolean(false),
representation: PD.Select('gaussian-surface', PD.arrayToOptions(['spacefill', 'gaussian-surface', 'point', 'orientation']))
@@ -581,4 +680,4 @@ export const LoadCellPackModel = StateAction.build({
from: PSO.Root
})(({ state, params }, ctx: PluginContext) => Task.create('CellPack Loader', async taskCtx => {
await loadPackings(ctx, taskCtx, state, params);
}));
}));

View File

@@ -1,7 +1,8 @@
/**
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Ludovic Autin <ludovic.autin@gmail.com>
*/
import { StateObjectRef } from '../../mol-state';
@@ -9,8 +10,6 @@ import { StructureRepresentationPresetProvider, presetStaticComponent } from '..
import { ParamDefinition as PD } from '../../mol-util/param-definition';
import { ColorNames } from '../../mol-util/color/names';
import { CellPackGenerateColorThemeProvider } from './color/generate';
import { CellPackInfoProvider } from './property';
import { CellPackProvidedColorThemeProvider } from './color/provided';
export const CellpackPackingPresetParams = {
traceOnly: PD.Boolean(true),
@@ -42,8 +41,8 @@ export const CellpackPackingPreset = StructureRepresentationPresetProvider({
Object.assign(reprProps, { sizeFactor: 2 });
}
const info = structureCell.obj?.data && CellPackInfoProvider.get(structureCell.obj?.data).value;
const color = info?.colors ? CellPackProvidedColorThemeProvider.name : CellPackGenerateColorThemeProvider.name;
// default is generated
const color = CellPackGenerateColorThemeProvider.name;
const { update, builder, typeParams } = StructureRepresentationPresetProvider.reprBuilder(plugin, {});
const representations = {
@@ -92,4 +91,4 @@ export const CellpackMembranePreset = StructureRepresentationPresetProvider({
return { components, representations };
}
});
});

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -34,4 +34,4 @@ export const CellPackInfoProvider: CustomStructureProperty.Provider<typeof CellP
value: { ...CellPackInfoParams.info.defaultValue, ...props.info }
};
}
});
});

View File

@@ -0,0 +1,70 @@
/**
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Ludovic Autin <ludovic.autin@gmail.com>
*/
import { ShapeRepresentation } from '../../mol-repr/shape/representation';
import { Shape } from '../../mol-model/shape';
import { ColorNames } from '../../mol-util/color/names';
import { RuntimeContext } from '../../mol-task';
import { ParamDefinition as PD } from '../../mol-util/param-definition';
import { Mesh } from '../../mol-geo/geometry/mesh/mesh';
import { MeshBuilder } from '../../mol-geo/geometry/mesh/mesh-builder';
// import { Polyhedron, DefaultPolyhedronProps } from '../../mol-geo/primitive/polyhedron';
// import { Icosahedron } from '../../mol-geo/primitive/icosahedron';
import { Sphere } from '../../mol-geo/primitive/sphere';
import { Mat4, Vec3 } from '../../mol-math/linear-algebra';
import { RepresentationParamsGetter, Representation, RepresentationContext } from '../../mol-repr/representation';
interface MembraneSphereData {
radius: number
center: Vec3
}
const MembraneSphereParams = {
...Mesh.Params,
cellColor: PD.Color(ColorNames.orange),
cellScale: PD.Numeric(2, { min: 0.1, max: 5, step: 0.1 }),
radius: PD.Numeric(2, { min: 0.1, max: 5, step: 0.1 }),
center: PD.Vec3(Vec3.create(0, 0, 0)),
quality: { ...Mesh.Params.quality, isEssential: false },
};
type MeshParams = typeof MembraneSphereParams
const MembraneSphereVisuals = {
'mesh': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<MembraneSphereData, MeshParams>) => ShapeRepresentation(getMBShape, Mesh.Utils),
};
export const MBParams = {
...MembraneSphereParams
};
export type MBParams = typeof MBParams
export type UnitcellProps = PD.Values<MBParams>
function getMBMesh(data: MembraneSphereData, props: UnitcellProps, mesh?: Mesh) {
const state = MeshBuilder.createState(256, 128, mesh);
const radius = props.radius;
const asphere = Sphere(3);
const trans: Mat4 = Mat4.identity();
Mat4.fromScaling(trans, Vec3.create(radius, radius, radius));
state.currentGroup = 1;
MeshBuilder.addPrimitive(state, trans, asphere);
const m = MeshBuilder.getMesh(state);
return m;
}
function getMBShape(ctx: RuntimeContext, data: MembraneSphereData, props: UnitcellProps, shape?: Shape<Mesh>) {
const geo = getMBMesh(data, props, shape && shape.geometry);
const label = 'mb';
return Shape.create(label, data, geo, () => props.cellColor, () => 1, () => label);
}
export type MBRepresentation = Representation<MembraneSphereData, MBParams>
export function MBRepresentation(ctx: RepresentationContext, getParams: RepresentationParamsGetter<MembraneSphereData, MBParams>): MBRepresentation {
return Representation.createMulti('MB', ctx, getParams, Representation.StateBuilder, MembraneSphereVisuals as unknown as Representation.Def<MembraneSphereData, MBParams>);
}

View File

@@ -1,7 +1,8 @@
/**
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Ludovic Autin <ludovic.autin@gmail.com>
*/
import { PluginStateObject as PSO, PluginStateTransform } from '../../mol-plugin-state/objects';
@@ -15,9 +16,13 @@ import { PluginContext } from '../../mol-plugin/context';
import { CellPackInfoProvider } from './property';
import { Structure, StructureSymmetry, Unit, Model } from '../../mol-model/structure';
import { ModelSymmetry } from '../../mol-model-formats/structure/property/symmetry';
import { Vec3, Quat } from '../../mol-math/linear-algebra';
import { StateTransformer } from '../../mol-state';
import { MBRepresentation, MBParams } from './representation';
import { IsNativeEndianLittle, flipByteOrder } from '../../mol-io/common/binary';
import { getFloatValue } from './util';
export const DefaultCellPackBaseUrl = 'https://mesoscope.scripps.edu/data/cellPACK_data/cellPACK_database_1.1.0/';
export const DefaultCellPackBaseUrl = 'https://raw.githubusercontent.com/mesoscope/cellPACK_data/master/cellPACK_database_1.1.0';
export class CellPack extends PSO.Create<_CellPack>({ name: 'CellPack', typeClass: 'Object' }) { }
export { ParseCellPack };
@@ -26,26 +31,173 @@ const ParseCellPack = PluginStateTransform.BuiltIn({
name: 'parse-cellpack',
display: { name: 'Parse CellPack', description: 'Parse CellPack from JSON data' },
from: PSO.Format.Json,
to: CellPack
to: CellPack,
params: a => {
return {
resultsFile: PD.File({ accept: '.bin' }),
baseUrl: PD.Text(DefaultCellPackBaseUrl)
};
}
})({
apply({ a }) {
apply({ a, params, cache }, plugin: PluginContext) {
return Task.create('Parse CellPack', async ctx => {
const cell = a.data as Cell;
let counter_id = 0;
let fiber_counter_id = 0;
let comp_counter = 0;
const packings: CellPacking[] = [];
const { compartments, cytoplasme } = cell;
if (!cell.mapping_ids) cell.mapping_ids = {};
if (cytoplasme) {
packings.push({ name: 'Cytoplasme', location: 'cytoplasme', ingredients: cytoplasme.ingredients });
for (const iName in cytoplasme.ingredients) {
if (cytoplasme.ingredients[iName].ingtype === 'fiber') {
cell.mapping_ids[-(fiber_counter_id + 1)] = [comp_counter, iName];
if (!cytoplasme.ingredients[iName].nbCurve) cytoplasme.ingredients[iName].nbCurve = 0;
fiber_counter_id++;
} else {
cell.mapping_ids[counter_id] = [comp_counter, iName];
if (!cytoplasme.ingredients[iName].results) { cytoplasme.ingredients[iName].results = []; }
counter_id++;
}
}
comp_counter++;
}
if (compartments) {
for (const name in compartments) {
const { surface, interior } = compartments[name];
if (surface) packings.push({ name, location: 'surface', ingredients: surface.ingredients });
if (interior) packings.push({ name, location: 'interior', ingredients: interior.ingredients });
let filename = '';
if (compartments[name].geom_type === 'file') {
filename = (compartments[name].geom) ? compartments[name].geom as string : '';
}
const compartment = { filename: filename, geom_type: compartments[name].geom_type, compartment_primitives: compartments[name].mb };
if (surface) {
packings.push({ name, location: 'surface', ingredients: surface.ingredients, compartment: compartment });
for (const iName in surface.ingredients) {
if (surface.ingredients[iName].ingtype === 'fiber') {
cell.mapping_ids[-(fiber_counter_id + 1)] = [comp_counter, iName];
if (!surface.ingredients[iName].nbCurve) surface.ingredients[iName].nbCurve = 0;
fiber_counter_id++;
} else {
cell.mapping_ids[counter_id] = [comp_counter, iName];
if (!surface.ingredients[iName].results) { surface.ingredients[iName].results = []; }
counter_id++;
}
}
comp_counter++;
}
if (interior) {
if (!surface) packings.push({ name, location: 'interior', ingredients: interior.ingredients, compartment: compartment });
else packings.push({ name, location: 'interior', ingredients: interior.ingredients });
for (const iName in interior.ingredients) {
if (interior.ingredients[iName].ingtype === 'fiber') {
cell.mapping_ids[-(fiber_counter_id + 1)] = [comp_counter, iName];
if (!interior.ingredients[iName].nbCurve) interior.ingredients[iName].nbCurve = 0;
fiber_counter_id++;
} else {
cell.mapping_ids[counter_id] = [comp_counter, iName];
if (!interior.ingredients[iName].results) { interior.ingredients[iName].results = []; }
counter_id++;
}
}
comp_counter++;
}
}
}
if (cytoplasme) packings.push({ name: 'Cytoplasme', location: 'cytoplasme', ingredients: cytoplasme.ingredients });
const { options } = cell;
let resultsAsset: Asset.Wrapper<'binary'> | undefined;
if (params.resultsFile) {
resultsAsset = await plugin.runTask(plugin.managers.asset.resolve(params.resultsFile, 'binary', true));
} else if (options?.resultfile) {
const url = `${params.baseUrl}/results/${options.resultfile}`;
resultsAsset = await plugin.runTask(plugin.managers.asset.resolve(Asset.getUrlAsset(plugin.managers.asset, url), 'binary', true));
}
if (resultsAsset) {
(cache as any).asset = resultsAsset;
const results = resultsAsset.data;
// flip the byte order if needed
const buffer = IsNativeEndianLittle ? results.buffer : flipByteOrder(results, 4);
const numbers = new DataView(buffer);
const ninst = getFloatValue(numbers, 0);
const npoints = getFloatValue(numbers, 4);
const ncurve = getFloatValue(numbers, 8);
let offset = 12;
if (ninst !== 0) {
const pos = new Float32Array(buffer, offset, ninst * 4);
offset += ninst * 4 * 4;
const quat = new Float32Array(buffer, offset, ninst * 4);
offset += ninst * 4 * 4;
for (let i = 0; i < ninst; i++) {
const x: number = pos[i * 4 + 0];
const y: number = pos[i * 4 + 1];
const z: number = pos[i * 4 + 2];
const ingr_id = pos[i * 4 + 3] as number;
const pid = cell.mapping_ids![ingr_id];
if (!packings[pid[0]].ingredients[pid[1]].results) {
packings[pid[0]].ingredients[pid[1]].results = [];
}
packings[pid[0]].ingredients[pid[1]].results.push([Vec3.create(x, y, z),
Quat.create(quat[i * 4 + 0], quat[i * 4 + 1], quat[i * 4 + 2], quat[i * 4 + 3])]);
}
}
if (npoints !== 0) {
const ctr_pos = new Float32Array(buffer, offset, npoints * 4);
offset += npoints * 4 * 4;
offset += npoints * 4 * 4;
const ctr_info = new Float32Array(buffer, offset, npoints * 4);
offset += npoints * 4 * 4;
const curve_ids = new Float32Array(buffer, offset, ncurve * 4);
offset += ncurve * 4 * 4;
let counter = 0;
let ctr_points: Vec3[] = [];
let prev_ctype = 0;
let prev_cid = 0;
for (let i = 0; i < npoints; i++) {
const x: number = -ctr_pos[i * 4 + 0];
const y: number = ctr_pos[i * 4 + 1];
const z: number = ctr_pos[i * 4 + 2];
const cid: number = ctr_info[i * 4 + 0]; // curve id
const ctype: number = curve_ids[cid * 4 + 0]; // curve type
// cid 148 165 -1 0
// console.log("cid ",cid,ctype,prev_cid,prev_ctype);//165,148
if (prev_ctype !== ctype) {
const pid = cell.mapping_ids![-prev_ctype - 1];
const cname = `curve${counter}`;
packings[pid[0]].ingredients[pid[1]].nbCurve = counter + 1;
packings[pid[0]].ingredients[pid[1]][cname] = ctr_points;
ctr_points = [];
counter = 0;
} else if (prev_cid !== cid) {
ctr_points = [];
const pid = cell.mapping_ids![-prev_ctype - 1];
const cname = `curve${counter}`;
packings[pid[0]].ingredients[pid[1]][cname] = ctr_points;
counter += 1;
}
ctr_points.push(Vec3.create(x, y, z));
prev_ctype = ctype;
prev_cid = cid;
}
// do the last one
const pid = cell.mapping_ids![-prev_ctype - 1];
const cname = `curve${counter}`;
packings[pid[0]].ingredients[pid[1]].nbCurve = counter + 1;
packings[pid[0]].ingredients[pid[1]][cname] = ctr_points;
}
}
return new CellPack({ cell, packings });
});
}
},
dispose({ cache }) {
((cache as any)?.asset as Asset.Wrapper | undefined)?.dispose();
},
});
export { StructureFromCellpack };
@@ -77,9 +229,8 @@ const StructureFromCellpack = PluginStateTransform.BuiltIn({
await CellPackInfoProvider.attach({ runtime: ctx, assetManager: plugin.managers.asset }, structure, {
info: { packingsCount: a.data.packings.length, packingIndex: params.packing, colors }
});
(cache as any).assets = assets;
return new PSO.Molecule.Structure(structure, { label: packing.name });
return new PSO.Molecule.Structure(structure, { label: packing.name + '.' + packing.location });
});
},
dispose({ b, cache }) {
@@ -125,7 +276,7 @@ const StructureFromAssemblies = PluginStateTransform.BuiltIn({
const s = await StructureSymmetry.buildAssembly(initial_structure, a.id).runInContext(ctx);
structures.push(s);
}
const builder = Structure.Builder();
const builder = Structure.Builder({ label: 'Membrane' });
let offsetInvariantId = 0;
for (const s of structures) {
let maxInvariantId = 0;
@@ -148,3 +299,28 @@ const StructureFromAssemblies = PluginStateTransform.BuiltIn({
b?.data.customPropertyDescriptors.dispose();
}
});
const CreateTransformer = StateTransformer.builderFactory('cellPACK');
export const CreateCompartmentSphere = CreateTransformer({
name: 'create-compartment-sphere',
display: 'CompartmentSphere',
from: PSO.Root, // or whatever data source
to: PSO.Shape.Representation3D,
params: {
center: PD.Vec3(Vec3()),
radius: PD.Numeric(1),
label: PD.Text(`Compartment Sphere`)
}
})({
canAutoUpdate({ oldParams, newParams }) {
return true;
},
apply({ a, params }, plugin: PluginContext) {
return Task.create('Compartment Sphere', async ctx => {
const data = params;
const repr = MBRepresentation({ webgl: plugin.canvas3d?.webgl, ...plugin.representation.structure.themes }, () => (MBParams));
await repr.createOrUpdate({ ...params, quality: 'custom', xrayShaded: true, doubleSided: true }, data).runInContext(ctx);
return new PSO.Shape.Representation3D({ repr, sourceData: a }, { label: data.label });
});
}
});

View File

@@ -1,7 +1,8 @@
/**
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author Ludovic Autin <ludovic.autin@gmail.com>
*/
import { CIF } from '../../mol-io/reader/cif';
@@ -37,7 +38,7 @@ async function downloadPDB(plugin: PluginContext, url: string, id: string, asset
}
export async function getFromPdb(plugin: PluginContext, pdbId: string, assetManager: AssetManager) {
const { cif, asset } = await downloadCif(plugin, `https://models.rcsb.org/${pdbId.toUpperCase()}.bcif`, true, assetManager);
const { cif, asset } = await downloadCif(plugin, `https://models.rcsb.org/${pdbId}.bcif`, true, assetManager);
return { mmcif: cif.blocks[0], asset };
}
@@ -74,4 +75,35 @@ export function getStructureMean(structure: Structure) {
}
const { elementCount } = structure;
return Vec3.create(xSum / elementCount, ySum / elementCount, zSum / elementCount);
}
export function getFloatValue(value: DataView, offset: number) {
// if the last byte is a negative value (MSB is 1), the final
// float should be too
const negative = value.getInt8(offset + 2) >>> 31;
// this is how the bytes are arranged in the byte array/DataView
// buffer
const [b0, b1, b2, exponent] = [
// get first three bytes as unsigned since we only care
// about the last 8 bits of 32-bit js number returned by
// getUint8().
// Should be the same as: getInt8(offset) & -1 >>> 24
value.getUint8(offset),
value.getUint8(offset + 1),
value.getUint8(offset + 2),
// get the last byte, which is the exponent, as a signed int
// since it's already correct
value.getInt8(offset + 3)
];
let mantissa = b0 | (b1 << 8) | (b2 << 16);
if (negative) {
// need to set the most significant 8 bits to 1's since a js
// number is 32 bits but our mantissa is only 24.
mantissa |= 255 << 24;
}
return mantissa * Math.pow(10, exponent);
}

View File

@@ -66,7 +66,7 @@ export const DnatcoConfalPyramids = PluginBehavior.create<{ autoAttach: boolean,
/* TODO: Implement this */
return void 0;
}
}
};
register(): void {
this.ctx.customModelProperties.register(this.provider, this.params.autoAttach);

View File

@@ -114,7 +114,7 @@ export namespace ConfalPyramidsUtil {
this.modelNum = unit.model.modelNum;
}
protected readonly data: CPT.PyramidsData
protected readonly data: CPT.PyramidsData;
protected readonly hasMultipleModels: boolean;
protected readonly entryId: string;
protected readonly modelNum: number;

View File

@@ -4,7 +4,6 @@
* @author Sukolsak Sakshuwong <sukolsak@stanford.edu>
*/
import { getStyle } from '../../mol-gl/renderer';
import { Box3D } from '../../mol-math/geometry';
import { PluginComponent } from '../../mol-plugin-state/component';
import { PluginContext } from '../../mol-plugin/context';
@@ -30,7 +29,7 @@ export const GeometryParams = {
export class GeometryControls extends PluginComponent {
readonly behaviors = {
params: this.ev.behavior<PD.Values<typeof GeometryParams>>(PD.getDefaultValues(GeometryParams))
}
};
private getFilename() {
const models = this.plugin.state.data.select(StateSelection.Generators.rootsOfType(PluginStateObject.Molecule.Model)).map(s => s.obj!.data);
@@ -46,13 +45,12 @@ export class GeometryControls extends PluginComponent {
const renderObjects = this.plugin.canvas3d?.getRenderObjects()!;
const filename = this.getFilename();
const style = getStyle(this.plugin.canvas3d?.props.renderer.style!);
const boundingSphere = this.plugin.canvas3d?.boundingSphereVisible!;
const boundingBox = Box3D.fromSphere3D(Box3D(), boundingSphere);
let renderObjectExporter: GlbExporter | ObjExporter | StlExporter | UsdzExporter;
switch (this.behaviors.params.value.format) {
case 'glb':
renderObjectExporter = new GlbExporter(style, boundingBox);
renderObjectExporter = new GlbExporter(boundingBox);
break;
case 'obj':
renderObjectExporter = new ObjExporter(filename, boundingBox);
@@ -61,7 +59,7 @@ export class GeometryControls extends PluginComponent {
renderObjectExporter = new StlExporter(boundingBox);
break;
case 'usdz':
renderObjectExporter = new UsdzExporter(style, boundingBox, boundingSphere.radius);
renderObjectExporter = new UsdzExporter(boundingBox, boundingSphere.radius);
break;
default: throw new Error('Unsupported format.');
}
@@ -77,7 +75,7 @@ export class GeometryControls extends PluginComponent {
filename: filename + '.' + renderObjectExporter.fileExtension
};
} catch (e) {
this.plugin.log.error('' + e);
this.plugin.log.error('Error during geometry export');
throw e;
}
});

View File

@@ -2,10 +2,9 @@
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Sukolsak Sakshuwong <sukolsak@stanford.edu>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { BaseValues } from '../../mol-gl/renderable/schema';
import { Style } from '../../mol-gl/renderer';
import { asciiWrite } from '../../mol-io/common/ascii';
import { IsNativeEndianLittle, flipByteOrder } from '../../mol-io/common/binary';
import { Box3D } from '../../mol-math/geometry';
@@ -15,7 +14,7 @@ import { RuntimeContext } from '../../mol-task';
import { Color } from '../../mol-util/color/color';
import { fillSerial } from '../../mol-util/array';
import { NumberArray } from '../../mol-util/type-helpers';
import { MeshExporter, AddMeshInput } from './mesh-exporter';
import { MeshExporter, AddMeshInput, MeshGeoData } from './mesh-exporter';
// avoiding namespace lookup improved performance in Chrome (Aug 2020)
const v3fromArray = Vec3.fromArray;
@@ -30,6 +29,12 @@ const FLOAT = 5126;
const ARRAY_BUFFER = 34962;
const ELEMENT_ARRAY_BUFFER = 34963;
const GLTF_MAGIC_BYTE = 0x46546C67;
const JSON_CHUNK_TYPE = 0x4E4F534A;
const BIN_CHUNK_TYPE = 0x004E4942;
const JSON_PAD_CHAR = 0x20;
const BIN_PAD_CHAR = 0x00;
export type GlbData = {
glb: Uint8Array
}
@@ -38,6 +43,8 @@ export class GlbExporter extends MeshExporter<GlbData> {
readonly fileExtension = 'glb';
private nodes: Record<string, any>[] = [];
private meshes: Record<string, any>[] = [];
private materials: Record<string, any>[] = [];
private materialMap = new Map<string, number>();
private accessors: Record<string, any>[] = [];
private bufferViews: Record<string, any>[] = [];
private binaryBuffer: ArrayBuffer[] = [];
@@ -126,23 +133,17 @@ export class GlbExporter extends MeshExporter<GlbData> {
};
}
private addColorBuffer(values: BaseValues, groups: Float32Array | Uint8Array, vertexCount: number, instanceIndex: number, isGeoTexture: boolean, interpolatedColors: Uint8Array | undefined) {
const groupCount = values.uGroupCount.ref.value;
private addColorBuffer(geoData: MeshGeoData, interpolatedColors: Uint8Array | undefined, interpolatedOverpaint: Uint8Array | undefined, interpolatedTransparency: Uint8Array | undefined) {
const { values, vertexCount } = geoData;
const uAlpha = values.uAlpha.ref.value;
const dTransparency = values.dTransparency.ref.value;
const tTransparency = values.tTransparency.ref.value;
const colorArray = new Uint8Array(vertexCount * 4);
for (let i = 0; i < vertexCount; ++i) {
let color = GlbExporter.getColor(values, groups, vertexCount, instanceIndex, isGeoTexture, interpolatedColors, i);
let color = GlbExporter.getColor(i, geoData, interpolatedColors, interpolatedOverpaint);
let alpha = uAlpha;
if (dTransparency) {
const group = isGeoTexture ? GlbExporter.getGroup(groups, i) : groups[i];
const transparency = tTransparency.array[instanceIndex * groupCount + group] / 255;
alpha *= 1 - transparency;
}
const transparency = GlbExporter.getTransparency(i, geoData, interpolatedTransparency);
const alpha = uAlpha * (1 - transparency);
color = Color.sRGBToLinear(color);
Color.toArray(color, colorArray, i * 4);
@@ -157,20 +158,53 @@ export class GlbExporter extends MeshExporter<GlbData> {
return this.addBuffer(colorBuffer, UNSIGNED_BYTE, 'VEC4', vertexCount, ARRAY_BUFFER, undefined, undefined, true);
}
private addMaterial(metalness: number, roughness: number) {
const hash = `${metalness}|${roughness}`;
if (!this.materialMap.has(hash)) {
this.materialMap.set(hash, this.materials.length);
this.materials.push({
pbrMetallicRoughness: {
baseColorFactor: [1, 1, 1, 1],
metallicFactor: metalness,
roughnessFactor: roughness
}
});
}
return this.materialMap.get(hash)!;
}
protected async addMeshWithColors(input: AddMeshInput) {
const { mesh, values, isGeoTexture, webgl, ctx } = input;
const t = Mat4();
const colorType = values.dColorType.ref.value;
const overpaintType = values.dOverpaintType.ref.value;
const transparencyType = values.dTransparencyType.ref.value;
const dTransparency = values.dTransparency.ref.value;
const aTransform = values.aTransform.ref.value;
const instanceCount = values.uInstanceCount.ref.value;
const metalness = values.uMetalness.ref.value;
const roughness = values.uRoughness.ref.value;
const material = this.addMaterial(metalness, roughness);
let interpolatedColors: Uint8Array | undefined;
if (colorType === 'volume' || colorType === 'volumeInstance') {
const stride = isGeoTexture ? 4 : 3;
interpolatedColors = GlbExporter.getInterpolatedColors(mesh!.vertices, mesh!.vertexCount, values, stride, colorType, webgl!);
interpolatedColors = GlbExporter.getInterpolatedColors(webgl!, { vertices: mesh!.vertices, vertexCount: mesh!.vertexCount, values, stride, colorType });
}
let interpolatedOverpaint: Uint8Array | undefined;
if (overpaintType === 'volumeInstance') {
const stride = isGeoTexture ? 4 : 3;
interpolatedOverpaint = GlbExporter.getInterpolatedOverpaint(webgl!, { vertices: mesh!.vertices, vertexCount: mesh!.vertexCount, values, stride, colorType: overpaintType });
}
let interpolatedTransparency: Uint8Array | undefined;
if (transparencyType === 'volumeInstance') {
const stride = isGeoTexture ? 4 : 3;
interpolatedTransparency = GlbExporter.getInterpolatedTransparency(webgl!, { vertices: mesh!.vertices, vertexCount: mesh!.vertexCount, values, stride, colorType: transparencyType });
}
// instancing
@@ -201,7 +235,7 @@ export class GlbExporter extends MeshExporter<GlbData> {
// create a color buffer if needed
if (instanceIndex === 0 || !sameColorBuffer) {
colorAccessorIndex = this.addColorBuffer(values, groups, vertexCount, instanceIndex, isGeoTexture, interpolatedColors);
colorAccessorIndex = this.addColorBuffer({ values, groups, vertexCount, instanceIndex, isGeoTexture }, interpolatedColors, interpolatedOverpaint, interpolatedTransparency);
}
// glTF mesh
@@ -214,7 +248,7 @@ export class GlbExporter extends MeshExporter<GlbData> {
COLOR_0: colorAccessorIndex!
},
indices: indexAccessorIndex,
material: 0
material
}]
});
}
@@ -248,13 +282,7 @@ export class GlbExporter extends MeshExporter<GlbData> {
}],
bufferViews: this.bufferViews,
accessors: this.accessors,
materials: [{
pbrMetallicRoughness: {
baseColorFactor: [1, 1, 1, 1],
metallicFactor: this.style.metalness,
roughnessFactor: this.style.roughness
}
}]
materials: this.materials
};
const createChunk = (chunkType: number, data: ArrayBuffer[], byteLength: number, padChar: number): [ArrayBuffer[], number] => {
@@ -279,13 +307,13 @@ export class GlbExporter extends MeshExporter<GlbData> {
const jsonBuffer = new Uint8Array(jsonString.length);
asciiWrite(jsonBuffer, jsonString);
const [jsonChunk, jsonChunkLength] = createChunk(0x4E4F534A, [jsonBuffer.buffer], jsonBuffer.length, 0x20);
const [binaryChunk, binaryChunkLength] = createChunk(0x004E4942, this.binaryBuffer, binaryBufferLength, 0x00);
const [jsonChunk, jsonChunkLength] = createChunk(JSON_CHUNK_TYPE, [jsonBuffer.buffer], jsonBuffer.length, JSON_PAD_CHAR);
const [binaryChunk, binaryChunkLength] = createChunk(BIN_CHUNK_TYPE, this.binaryBuffer, binaryBufferLength, BIN_PAD_CHAR);
const glbBufferLength = 12 + jsonChunkLength + binaryChunkLength;
const header = new ArrayBuffer(12);
const headerDataView = new DataView(header);
headerDataView.setUint32(0, 0x46546C67, true); // magic number "glTF"
headerDataView.setUint32(0, GLTF_MAGIC_BYTE, true); // magic number "glTF"
headerDataView.setUint32(4, 2, true); // version
headerDataView.setUint32(8, glbBufferLength, true); // length
const glbBuffer = [header, ...jsonChunk, ...binaryChunk];
@@ -303,7 +331,7 @@ export class GlbExporter extends MeshExporter<GlbData> {
return new Blob([(await this.getData()).glb], { type: 'model/gltf-binary' });
}
constructor(private style: Style, boundingBox: Box3D) {
constructor(boundingBox: Box3D) {
super();
const tmpV = Vec3();
Vec3.add(tmpV, boundingBox.min, boundingBox.max);

View File

@@ -2,6 +2,7 @@
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Sukolsak Sakshuwong <sukolsak@stanford.edu>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { sort, arraySwap } from '../../mol-data/util';
@@ -24,8 +25,9 @@ import { sizeDataFactor } from '../../mol-geo/geometry/size-data';
import { Vec3 } from '../../mol-math/linear-algebra';
import { RuntimeContext } from '../../mol-task';
import { Color } from '../../mol-util/color/color';
import { decodeFloatRGB } from '../../mol-util/float-packing';
import { unpackRGBToInt } from '../../mol-util/number-packing';
import { RenderObjectExporter, RenderObjectExportData } from './render-object-exporter';
import { readAlphaTexture, readTexture } from '../../mol-gl/compute/util';
const GeoExportName = 'geo-export';
@@ -48,6 +50,14 @@ export interface AddMeshInput {
ctx: RuntimeContext
}
export type MeshGeoData = {
values: BaseValues,
groups: Float32Array | Uint8Array,
vertexCount: number,
instanceIndex: number,
isGeoTexture: boolean
}
export abstract class MeshExporter<D extends RenderObjectExportData> implements RenderObjectExporter<D> {
abstract readonly fileExtension: string;
@@ -55,7 +65,7 @@ export abstract class MeshExporter<D extends RenderObjectExportData> implements
const r = tSize.array[i * 3];
const g = tSize.array[i * 3 + 1];
const b = tSize.array[i * 3 + 2];
return decodeFloatRGB(r, g, b) / sizeDataFactor;
return unpackRGBToInt(r, g, b) / sizeDataFactor;
}
private static getSize(values: BaseValues & SizeValues, instanceIndex: number, group: number): number {
@@ -85,31 +95,48 @@ export abstract class MeshExporter<D extends RenderObjectExportData> implements
const g = groups[i4 + 1];
const b = groups[i4 + 2];
if (groups instanceof Float32Array) {
return decodeFloatRGB(r * 255 + 0.5, g * 255 + 0.5, b * 255 + 0.5);
return unpackRGBToInt(r * 255 + 0.5, g * 255 + 0.5, b * 255 + 0.5);
}
return decodeFloatRGB(r, g, b);
return unpackRGBToInt(r, g, b);
}
protected static getInterpolatedColors(vertices: Float32Array, vertexCount: number, values: BaseValues, stride: number, colorType: 'volume' | 'volumeInstance', webgl: WebGLContext) {
protected static getInterpolatedColors(webgl: WebGLContext, input: { vertices: Float32Array, vertexCount: number, values: BaseValues, stride: 3 | 4, colorType: 'volume' | 'volumeInstance' }) {
const { values, vertexCount, vertices, colorType, stride } = input;
const colorGridTransform = values.uColorGridTransform.ref.value;
const colorGridDim = values.uColorGridDim.ref.value;
const colorTexDim = values.uColorTexDim.ref.value;
const aTransform = values.aTransform.ref.value;
const instanceCount = values.uInstanceCount.ref.value;
if (!webgl.namedFramebuffers[GeoExportName]) {
webgl.namedFramebuffers[GeoExportName] = webgl.resources.framebuffer();
}
const framebuffer = webgl.namedFramebuffers[GeoExportName];
const colorGrid = readTexture(webgl, values.tColorGrid.ref.value).array;
const interpolated = getTrilinearlyInterpolated({ vertexCount, instanceCount, transformBuffer: aTransform, positionBuffer: vertices, colorType, grid: colorGrid, gridDim: colorGridDim, gridTexDim: colorTexDim, gridTransform: colorGridTransform, vertexStride: stride, colorStride: 4, outputStride: 3 });
return interpolated.array;
}
const [width, height] = colorTexDim;
const colorGrid = new Uint8Array(width * height * 4);
protected static getInterpolatedOverpaint(webgl: WebGLContext, input: { vertices: Float32Array, vertexCount: number, values: BaseValues, stride: 3 | 4, colorType: 'volumeInstance' }) {
const { values, vertexCount, vertices, colorType, stride } = input;
const overpaintGridTransform = values.uOverpaintGridTransform.ref.value;
const overpaintGridDim = values.uOverpaintGridDim.ref.value;
const overpaintTexDim = values.uOverpaintTexDim.ref.value;
const aTransform = values.aTransform.ref.value;
const instanceCount = values.uInstanceCount.ref.value;
framebuffer.bind();
values.tColorGrid.ref.value.attachFramebuffer(framebuffer, 0);
webgl.readPixels(0, 0, width, height, colorGrid);
const overpaintGrid = readTexture(webgl, values.tOverpaintGrid.ref.value).array;
const interpolated = getTrilinearlyInterpolated({ vertexCount, instanceCount, transformBuffer: aTransform, positionBuffer: vertices, colorType, grid: overpaintGrid, gridDim: overpaintGridDim, gridTexDim: overpaintTexDim, gridTransform: overpaintGridTransform, vertexStride: stride, colorStride: 4, outputStride: 4 });
return interpolated.array;
}
protected static getInterpolatedTransparency(webgl: WebGLContext, input: { vertices: Float32Array, vertexCount: number, values: BaseValues, stride: 3 | 4, colorType: 'volumeInstance' }) {
const { values, vertexCount, vertices, colorType, stride } = input;
const transparencyGridTransform = values.uTransparencyGridTransform.ref.value;
const transparencyGridDim = values.uTransparencyGridDim.ref.value;
const transparencyTexDim = values.uTransparencyTexDim.ref.value;
const aTransform = values.aTransform.ref.value;
const instanceCount = values.uInstanceCount.ref.value;
const transparencyGrid = readAlphaTexture(webgl, values.tTransparencyGrid.ref.value).array;
const interpolated = getTrilinearlyInterpolated({ vertexCount, instanceCount, transformBuffer: aTransform, positionBuffer: vertices, colorType, grid: transparencyGrid, gridDim: transparencyGridDim, gridTexDim: transparencyTexDim, gridTransform: transparencyGridTransform, vertexStride: stride, colorStride: 4, outputStride: 1, itemOffset: 3 });
const interpolated = getTrilinearlyInterpolated({ vertexCount, instanceCount, transformBuffer: aTransform, positionBuffer: vertices, colorType, grid: colorGrid, gridDim: colorGridDim, gridTexDim: colorTexDim, gridTransform: colorGridTransform, vertexStride: stride, colorStride: 4 });
return interpolated.array;
}
@@ -194,11 +221,13 @@ export abstract class MeshExporter<D extends RenderObjectExportData> implements
}
}
protected static getColor(values: BaseValues, groups: Float32Array | Uint8Array, vertexCount: number, instanceIndex: number, isGeoTexture: boolean, interpolatedColors: Uint8Array | undefined, vertexIndex: number): Color {
protected static getColor(vertexIndex: number, geoData: MeshGeoData, interpolatedColors?: Uint8Array, interpolatedOverpaint?: Uint8Array): Color {
const { values, instanceIndex, isGeoTexture, groups, vertexCount } = geoData;
const groupCount = values.uGroupCount.ref.value;
const colorType = values.dColorType.ref.value;
const uColor = values.uColor.ref.value;
const tColor = values.tColor.ref.value.array;
const overpaintType = values.dOverpaintType.ref.value;
const dOverpaint = values.dOverpaint.ref.value;
const tOverpaint = values.tOverpaint.ref.value.array;
@@ -236,15 +265,70 @@ export abstract class MeshExporter<D extends RenderObjectExportData> implements
}
if (dOverpaint) {
const group = isGeoTexture ? MeshExporter.getGroup(groups, vertexIndex) : groups[vertexIndex];
const overpaintColor = Color.fromArray(tOverpaint, (instanceIndex * groupCount + group) * 4);
const overpaintAlpha = tOverpaint[(instanceIndex * groupCount + group) * 4 + 3] / 255;
let overpaintColor: Color;
let overpaintAlpha: number;
switch (overpaintType) {
case 'groupInstance': {
const group = isGeoTexture ? MeshExporter.getGroup(groups, vertexIndex) : groups[vertexIndex];
const idx = (instanceIndex * groupCount + group) * 4;
overpaintColor = Color.fromArray(tOverpaint, idx);
overpaintAlpha = tOverpaint[idx + 3] / 255;
break;
}
case 'vertexInstance': {
const idx = (instanceIndex * vertexCount + vertexIndex) * 4;
overpaintColor = Color.fromArray(tOverpaint, idx);
overpaintAlpha = tOverpaint[idx + 3] / 255;
break;
}
case 'volumeInstance': {
const idx = (instanceIndex * vertexCount + vertexIndex) * 4;
overpaintColor = Color.fromArray(interpolatedOverpaint!, idx);
overpaintAlpha = interpolatedOverpaint![idx + 3] / 255;
break;
}
default: throw new Error('Unsupported overpaint type.');
}
// interpolate twice to avoid darkening due to empty overpaint
overpaintColor = Color.interpolate(color, overpaintColor, overpaintAlpha);
color = Color.interpolate(color, overpaintColor, overpaintAlpha);
}
return color;
}
protected static getTransparency(vertexIndex: number, geoData: MeshGeoData, interpolatedTransparency?: Uint8Array): number {
const { values, instanceIndex, isGeoTexture, groups, vertexCount } = geoData;
const groupCount = values.uGroupCount.ref.value;
const dTransparency = values.dTransparency.ref.value;
const tTransparency = values.tTransparency.ref.value.array;
const transparencyType = values.dTransparencyType.ref.value;
let transparency: number = 0;
if (dTransparency) {
switch (transparencyType) {
case 'groupInstance': {
const group = isGeoTexture ? MeshExporter.getGroup(groups, vertexIndex) : groups[vertexIndex];
const idx = (instanceIndex * groupCount + group);
transparency = tTransparency[idx] / 255;
break;
}
case 'vertexInstance': {
const idx = (instanceIndex * vertexCount + vertexIndex);
transparency = tTransparency[idx] / 255;
break;
}
case 'volumeInstance': {
const idx = (instanceIndex * vertexCount + vertexIndex);
transparency = interpolatedTransparency![idx] / 255;
break;
}
default: throw new Error('Unsupported transparency type.');
}
}
return transparency;
}
protected abstract addMeshWithColors(input: AddMeshInput): void;
private async addMesh(values: MeshValues, webgl: WebGLContext, ctx: RuntimeContext) {

View File

@@ -2,6 +2,7 @@
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Sukolsak Sakshuwong <sukolsak@stanford.edu>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { asciiWrite } from '../../mol-io/common/ascii';
@@ -47,7 +48,7 @@ export class ObjExporter extends MeshExporter<ObjData> {
StringBuilder.newline(this.obj);
if (!this.materialSet.has(material)) {
this.materialSet.add(material);
const [r, g, b] = Color.toRgbNormalized(color);
const [r, g, b] = Color.toRgbNormalized(color).map(v => Math.round(v * 1000) / 1000);
const mtl = this.mtl;
StringBuilder.writeSafe(mtl, `newmtl ${material}\n`);
StringBuilder.writeSafe(mtl, 'illum 2\n'); // illumination model
@@ -77,18 +78,27 @@ export class ObjExporter extends MeshExporter<ObjData> {
const tmpV = Vec3();
const stride = isGeoTexture ? 4 : 3;
const groupCount = values.uGroupCount.ref.value;
const colorType = values.dColorType.ref.value;
const overpaintType = values.dOverpaintType.ref.value;
const transparencyType = values.dTransparencyType.ref.value;
const uAlpha = values.uAlpha.ref.value;
const dTransparency = values.dTransparency.ref.value;
const tTransparency = values.tTransparency.ref.value;
const aTransform = values.aTransform.ref.value;
const instanceCount = values.uInstanceCount.ref.value;
let interpolatedColors: Uint8Array | undefined;
if (colorType === 'volume' || colorType === 'volumeInstance') {
interpolatedColors = ObjExporter.getInterpolatedColors(mesh!.vertices, mesh!.vertexCount, values, stride, colorType, webgl!);
ObjExporter.quantizeColors(interpolatedColors, mesh!.vertexCount);
interpolatedColors = ObjExporter.getInterpolatedColors(webgl!, { vertices: mesh!.vertices, vertexCount: mesh!.vertexCount, values, stride, colorType });
}
let interpolatedOverpaint: Uint8Array | undefined;
if (overpaintType === 'volumeInstance') {
interpolatedOverpaint = ObjExporter.getInterpolatedOverpaint(webgl!, { vertices: mesh!.vertices, vertexCount: mesh!.vertexCount, values, stride, colorType: overpaintType });
}
let interpolatedTransparency: Uint8Array | undefined;
if (transparencyType === 'volumeInstance') {
const stride = isGeoTexture ? 4 : 3;
interpolatedTransparency = ObjExporter.getInterpolatedTransparency(webgl!, { vertices: mesh!.vertices, vertexCount: mesh!.vertexCount, values, stride, colorType: transparencyType });
}
await ctx.update({ isIndeterminate: false, current: 0, max: instanceCount });
@@ -126,17 +136,23 @@ export class ObjExporter extends MeshExporter<ObjData> {
StringBuilder.newline(obj);
}
// face
const geoData = { values, groups, vertexCount, instanceIndex, isGeoTexture };
// color
const quantizedColors = new Uint8Array(drawCount * 3);
for (let i = 0; i < drawCount; i += 3) {
const v = isGeoTexture ? i : indices![i];
const color = ObjExporter.getColor(values, groups, vertexCount, instanceIndex, isGeoTexture, interpolatedColors, v);
const color = ObjExporter.getColor(v, geoData, interpolatedColors, interpolatedOverpaint);
Color.toArray(color, quantizedColors, i);
}
ObjExporter.quantizeColors(quantizedColors, vertexCount);
let alpha = uAlpha;
if (dTransparency) {
const group = isGeoTexture ? ObjExporter.getGroup(groups, i) : groups[indices![i]];
const transparency = tTransparency.array[instanceIndex * groupCount + group] / 255;
alpha *= 1 - transparency;
}
// face
for (let i = 0; i < drawCount; i += 3) {
const color = Color.fromArray(quantizedColors, i);
const transparency = ObjExporter.getTransparency(i, geoData, interpolatedTransparency);
const alpha = Math.round(uAlpha * (1 - transparency) * 10) / 10; // quantized
this.updateMaterial(color, alpha);

View File

@@ -79,19 +79,18 @@ export class GeometryExporterUI extends CollapsableControls<{}, State> {
try {
this.setState({ busy: true });
const data = await this.controls.exportGeometry();
this.setState({ busy: false });
download(data.blob, data.filename);
} catch {
} catch (e) {
console.error(e);
} finally {
this.setState({ busy: false });
}
}
};
viewInAR = async () => {
try {
this.setState({ busy: true });
const data = await this.controls.exportGeometry();
this.setState({ busy: false });
const a = document.createElement('a');
a.rel = 'ar';
a.href = URL.createObjectURL(data.blob);
@@ -100,8 +99,10 @@ export class GeometryExporterUI extends CollapsableControls<{}, State> {
a.appendChild(document.createElement('img'));
setTimeout(() => URL.revokeObjectURL(a.href), 4E4); // 40s
setTimeout(() => a.dispatchEvent(new MouseEvent('click')));
} catch {
} catch (e) {
console.error(e);
} finally {
this.setState({ busy: false });
}
}
};
}

View File

@@ -2,9 +2,9 @@
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Sukolsak Sakshuwong <sukolsak@stanford.edu>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { Style } from '../../mol-gl/renderer';
import { asciiWrite } from '../../mol-io/common/ascii';
import { Box3D } from '../../mol-math/geometry';
import { Vec3, Mat3, Mat4 } from '../../mol-math/linear-algebra';
@@ -31,18 +31,17 @@ export class UsdzExporter extends MeshExporter<UsdzData> {
readonly fileExtension = 'usdz';
private meshes: string[] = [];
private materials: string[] = [];
private materialSet = new Set<number>();
private materialMap = new Map<string, number>();
private centerTransform: Mat4;
private static getMaterialKey(color: Color, alpha: number) {
return color * 256 + Math.round(alpha * 255);
}
private addMaterial(color: Color, alpha: number, metalness: number, roughness: number): number {
const hash = `${color}|${alpha}|${metalness}|${roughness}`;
if (this.materialMap.has(hash)) return this.materialMap.get(hash)!;
private addMaterial(color: Color, alpha: number) {
const materialKey = UsdzExporter.getMaterialKey(color, alpha);
if (this.materialSet.has(materialKey)) return;
this.materialSet.add(materialKey);
const [r, g, b] = Color.toRgbNormalized(color);
const materialKey = this.materialMap.size;
this.materialMap.set(hash, materialKey);
const [r, g, b] = Color.toRgbNormalized(color).map(v => Math.round(v * 1000) / 1000);
this.materials.push(`
def Material "material${materialKey}"
{
@@ -52,12 +51,13 @@ def Material "material${materialKey}"
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor = (${r},${g},${b})
float inputs:opacity = ${alpha}
float inputs:metallic = ${this.style.metalness}
float inputs:roughness = ${this.style.roughness}
float inputs:metallic = ${metalness}
float inputs:roughness = ${roughness}
token outputs:surface
}
}
`);
return materialKey;
}
protected async addMeshWithColors(input: AddMeshInput) {
@@ -68,18 +68,30 @@ def Material "material${materialKey}"
const tmpV = Vec3();
const stride = isGeoTexture ? 4 : 3;
const groupCount = values.uGroupCount.ref.value;
const colorType = values.dColorType.ref.value;
const overpaintType = values.dOverpaintType.ref.value;
const transparencyType = values.dTransparencyType.ref.value;
const uAlpha = values.uAlpha.ref.value;
const dTransparency = values.dTransparency.ref.value;
const tTransparency = values.tTransparency.ref.value;
const aTransform = values.aTransform.ref.value;
const instanceCount = values.uInstanceCount.ref.value;
const metalness = values.uMetalness.ref.value;
const roughness = values.uRoughness.ref.value;
let interpolatedColors: Uint8Array | undefined;
if (colorType === 'volume' || colorType === 'volumeInstance') {
interpolatedColors = UsdzExporter.getInterpolatedColors(mesh!.vertices, mesh!.vertexCount, values, stride, colorType, webgl!);
UsdzExporter.quantizeColors(interpolatedColors, mesh!.vertexCount);
interpolatedColors = UsdzExporter.getInterpolatedColors(webgl!, { vertices: mesh!.vertices, vertexCount: mesh!.vertexCount, values, stride, colorType });
}
let interpolatedOverpaint: Uint8Array | undefined;
if (overpaintType === 'volumeInstance') {
const stride = isGeoTexture ? 4 : 3;
interpolatedOverpaint = UsdzExporter.getInterpolatedOverpaint(webgl!, { vertices: mesh!.vertices, vertexCount: mesh!.vertexCount, values, stride, colorType: overpaintType });
}
let interpolatedTransparency: Uint8Array | undefined;
if (transparencyType === 'volumeInstance') {
const stride = isGeoTexture ? 4 : 3;
interpolatedTransparency = UsdzExporter.getInterpolatedTransparency(webgl!, { vertices: mesh!.vertices, vertexCount: mesh!.vertexCount, values, stride, colorType: transparencyType });
}
await ctx.update({ isIndeterminate: false, current: 0, max: instanceCount });
@@ -121,6 +133,8 @@ def Material "material${materialKey}"
StringBuilder.writeSafe(normalBuilder, ')');
}
const geoData = { values, groups, vertexCount, instanceIndex, isGeoTexture };
// face
for (let i = 0; i < drawCount; ++i) {
const v = isGeoTexture ? i : indices![i];
@@ -129,21 +143,23 @@ def Material "material${materialKey}"
}
// color
const faceIndicesByMaterial = new Map<number, number[]>();
const quantizedColors = new Uint8Array(drawCount * 3);
for (let i = 0; i < drawCount; i += 3) {
const v = isGeoTexture ? i : indices![i];
const color = UsdzExporter.getColor(values, groups, vertexCount, instanceIndex, isGeoTexture, interpolatedColors, v);
const color = UsdzExporter.getColor(v, geoData, interpolatedColors, interpolatedOverpaint);
Color.toArray(color, quantizedColors, i);
}
UsdzExporter.quantizeColors(quantizedColors, vertexCount);
let alpha = uAlpha;
if (dTransparency) {
const group = isGeoTexture ? UsdzExporter.getGroup(groups, i) : groups[indices![i]];
const transparency = tTransparency.array[instanceIndex * groupCount + group] / 255;
alpha *= 1 - transparency;
}
// material
const faceIndicesByMaterial = new Map<number, number[]>();
for (let i = 0; i < drawCount; i += 3) {
const color = Color.fromArray(quantizedColors, i);
this.addMaterial(color, alpha);
const transparency = UsdzExporter.getTransparency(i, geoData, interpolatedTransparency);
const alpha = Math.round(uAlpha * (1 - transparency) * 10) / 10; // quantized
const materialKey = UsdzExporter.getMaterialKey(color, alpha);
const materialKey = this.addMaterial(color, alpha, metalness, roughness);
let faceIndices = faceIndicesByMaterial.get(materialKey);
if (faceIndices === undefined) {
faceIndices = [];
@@ -215,7 +231,7 @@ def Mesh "mesh${this.meshes.length}"
return new Blob([usdz], { type: 'model/vnd.usdz+zip' });
}
constructor(private style: Style, boundingBox: Box3D, radius: number) {
constructor(boundingBox: Box3D, radius: number) {
super();
const t = Mat4();
// scale the model so that it fits within 1 meter

View File

@@ -0,0 +1,212 @@
/**
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { ParamDefinition as PD } from '../../../mol-util/param-definition';
import { PluginBehavior } from '../../../mol-plugin/behavior/behavior';
import { Loci } from '../../../mol-model/loci';
import { DefaultQueryRuntimeTable } from '../../../mol-script/runtime/query/compiler';
import { PLDDTConfidenceColorThemeProvider } from './color/plddt';
import { QualityAssessment, QualityAssessmentProvider } from './prop';
import { StructureSelectionCategory, StructureSelectionQuery } from '../../../mol-plugin-state/helpers/structure-selection-query';
import { MolScriptBuilder as MS } from '../../../mol-script/language/builder';
import { OrderedSet } from '../../../mol-data/int';
import { cantorPairing } from '../../../mol-data/util';
import { QmeanScoreColorThemeProvider } from './color/qmean';
import { PresetStructureRepresentations, StructureRepresentationPresetProvider } from '../../../mol-plugin-state/builder/structure/representation-preset';
import { StateObjectRef } from '../../../mol-state';
export const MAQualityAssessment = PluginBehavior.create<{ autoAttach: boolean, showTooltip: boolean }>({
name: 'ma-quality-assessment-prop',
category: 'custom-props',
display: {
name: 'Quality Assessment',
description: 'Data included in Model Archive files.'
},
ctor: class extends PluginBehavior.Handler<{ autoAttach: boolean, showTooltip: boolean }> {
private provider = QualityAssessmentProvider;
private labelProvider = {
label: (loci: Loci): string | undefined => {
if (!this.params.showTooltip) return;
return [
plddtLabel(loci),
qmeanLabel(loci),
].filter(l => !!l).join('</br>');
}
};
register(): void {
DefaultQueryRuntimeTable.addCustomProp(this.provider.descriptor);
this.ctx.customModelProperties.register(this.provider, this.params.autoAttach);
this.ctx.managers.lociLabels.addProvider(this.labelProvider);
this.ctx.representation.structure.themes.colorThemeRegistry.add(PLDDTConfidenceColorThemeProvider);
this.ctx.representation.structure.themes.colorThemeRegistry.add(QmeanScoreColorThemeProvider);
this.ctx.query.structure.registry.add(confidentPLDDT);
this.ctx.builders.structure.representation.registerPreset(QualityAssessmentPLDDTPreset);
this.ctx.builders.structure.representation.registerPreset(QualityAssessmentQmeanPreset);
}
update(p: { autoAttach: boolean, showTooltip: boolean }) {
const updated = this.params.autoAttach !== p.autoAttach;
this.params.autoAttach = p.autoAttach;
this.params.showTooltip = p.showTooltip;
this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name, this.params.autoAttach);
return updated;
}
unregister() {
DefaultQueryRuntimeTable.removeCustomProp(this.provider.descriptor);
this.ctx.customStructureProperties.unregister(this.provider.descriptor.name);
this.ctx.managers.lociLabels.removeProvider(this.labelProvider);
this.ctx.representation.structure.themes.colorThemeRegistry.remove(PLDDTConfidenceColorThemeProvider);
this.ctx.representation.structure.themes.colorThemeRegistry.remove(QmeanScoreColorThemeProvider);
this.ctx.query.structure.registry.remove(confidentPLDDT);
this.ctx.builders.structure.representation.unregisterPreset(QualityAssessmentPLDDTPreset);
this.ctx.builders.structure.representation.unregisterPreset(QualityAssessmentQmeanPreset);
}
},
params: () => ({
autoAttach: PD.Boolean(false),
showTooltip: PD.Boolean(true),
})
});
//
function plddtCategory(score: number) {
if (score > 50 && score <= 70) return 'Low';
if (score > 70 && score <= 90) return 'Confident';
if (score > 90) return 'Very high';
return 'Very low';
}
function plddtLabel(loci: Loci): string | undefined {
return metricLabel(loci, 'pLDDT', (scoreAvg: number, countInfo: string) => `pLDDT Score ${countInfo}: ${scoreAvg.toFixed(2)} <small>(${plddtCategory(scoreAvg)})</small>`);
}
function qmeanLabel(loci: Loci): string | undefined {
return metricLabel(loci, 'qmean', (scoreAvg: number, countInfo: string) => `QMEAN Score ${countInfo}: ${scoreAvg.toFixed(2)}`);
}
function metricLabel(loci: Loci, name: 'qmean' | 'pLDDT', label: (scoreAvg: number, countInfo: string) => string): string | undefined {
if (loci.kind === 'element-loci') {
if (loci.elements.length === 0) return;
const seen = new Set<number>();
const scoreSeen = new Set<number>();
let scoreSum = 0;
for (const { indices, unit } of loci.elements) {
const metric = QualityAssessmentProvider.get(unit.model).value?.[name];
if (!metric) continue;
const residueIndex = unit.model.atomicHierarchy.residueAtomSegments.index;
const { elements } = unit;
OrderedSet.forEach(indices, idx => {
const eI = elements[idx];
const rI = residueIndex[eI];
const residueKey = cantorPairing(rI, unit.id);
if (!seen.has(residueKey)) {
const score = metric.get(residueIndex[eI]) ?? -1;
if (score !== -1) {
scoreSum += score;
scoreSeen.add(residueKey);
}
seen.add(residueKey);
}
});
}
if (seen.size === 0) return;
const summary: string[] = [];
if (scoreSeen.size) {
const countInfo = `<small>(${scoreSeen.size} ${scoreSeen.size > 1 ? 'Residues avg.' : 'Residue'})</small>`;
const scoreAvg = scoreSum / scoreSeen.size;
summary.push(label(scoreAvg, countInfo));
}
if (summary.length) {
return summary.join('</br>');
}
}
}
//
const confidentPLDDT = StructureSelectionQuery('Confident pLDDT (> 70)', MS.struct.modifier.union([
MS.struct.modifier.wholeResidues([
MS.struct.modifier.union([
MS.struct.generator.atomGroups({
'chain-test': MS.core.rel.eq([MS.ammp('objectPrimitive'), 'atomistic']),
'residue-test': MS.core.rel.gr([QualityAssessment.symbols.pLDDT.symbol(), 70]),
})
])
])
]), {
description: 'Select residues with a pLDDT > 70 (confident).',
category: StructureSelectionCategory.Validation,
ensureCustomProperties: async (ctx, structure) => {
for (const m of structure.models) {
await QualityAssessmentProvider.attach(ctx, m, void 0, true);
}
}
});
//
export const QualityAssessmentPLDDTPreset = StructureRepresentationPresetProvider({
id: 'preset-structure-representation-ma-quality-assessment-plddt',
display: {
name: 'Quality Assessment (pLDDT)', group: 'Annotation',
description: 'Color structure based on pLDDT Confidence.'
},
isApplicable(a) {
return !!a.data.models.some(m => QualityAssessment.isApplicable(m, 'pLDDT'));
},
params: () => StructureRepresentationPresetProvider.CommonParams,
async apply(ref, params, plugin) {
const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref);
const structure = structureCell?.obj?.data;
if (!structureCell || !structure) return {};
const colorTheme = PLDDTConfidenceColorThemeProvider.name as any;
return await PresetStructureRepresentations.auto.apply(ref, { ...params, theme: { globalName: colorTheme, focus: { name: colorTheme } } }, plugin);
}
});
export const QualityAssessmentQmeanPreset = StructureRepresentationPresetProvider({
id: 'preset-structure-representation-ma-quality-assessment-qmean',
display: {
name: 'Quality Assessment (QMEAN)', group: 'Annotation',
description: 'Color structure based on QMEAN Score.'
},
isApplicable(a) {
return !!a.data.models.some(m => QualityAssessment.isApplicable(m, 'qmean'));
},
params: () => StructureRepresentationPresetProvider.CommonParams,
async apply(ref, params, plugin) {
const structureCell = StateObjectRef.resolveAndCheck(plugin.state.data, ref);
const structure = structureCell?.obj?.data;
if (!structureCell || !structure) return {};
const colorTheme = QmeanScoreColorThemeProvider.name as any;
return await PresetStructureRepresentations.auto.apply(ref, { ...params, theme: { globalName: colorTheme, focus: { name: colorTheme } } }, plugin);
}
});

View File

@@ -0,0 +1,106 @@
/**
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Mandar Deshpande <mandar@ebi.ac.uk>
* @author Sebastian Bittrich <sebastian.bittrich@rcsb.org>
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { QualityAssessment, QualityAssessmentProvider } from '../prop';
import { Location } from '../../../../mol-model/location';
import { Bond, StructureElement, Unit } from '../../../../mol-model/structure';
import { ColorTheme, LocationColor } from '../../../../mol-theme/color';
import { ThemeDataContext } from '../../../../mol-theme/theme';
import { Color } from '../../../../mol-util/color';
import { ParamDefinition as PD } from '../../../../mol-util/param-definition';
import { CustomProperty } from '../../../../mol-model-props/common/custom-property';
import { TableLegend } from '../../../../mol-util/legend';
const DefaultColor = Color(0xaaaaaa);
const ConfidenceColors = {
'No Score': DefaultColor,
'Very Low': Color(0xff7d45),
'Low': Color(0xffdb13),
'Confident': Color(0x65cbf3),
'Very High': Color(0x0053d6)
};
const ConfidenceColorLegend = TableLegend(Object.entries(ConfidenceColors));
export function getPLDDTConfidenceColorThemeParams(ctx: ThemeDataContext) {
return {};
}
export type PLDDTConfidenceColorThemeParams = ReturnType<typeof getPLDDTConfidenceColorThemeParams>
export function PLDDTConfidenceColorTheme(ctx: ThemeDataContext, props: PD.Values<PLDDTConfidenceColorThemeParams>): ColorTheme<PLDDTConfidenceColorThemeParams> {
let color: LocationColor = () => DefaultColor;
if (ctx.structure) {
const l = StructureElement.Location.create(ctx.structure.root);
const getColor = (location: StructureElement.Location): Color => {
const { unit, element } = location;
if (!Unit.isAtomic(unit)) return DefaultColor;
const qualityAssessment = QualityAssessmentProvider.get(unit.model).value;
const score = qualityAssessment?.pLDDT?.get(unit.model.atomicHierarchy.residueAtomSegments.index[element]) ?? -1;
if (score < 0) {
return DefaultColor;
} else if (score <= 50) {
return Color(0xff7d45);
} else if (score <= 70) {
return Color(0xffdb13);
} else if (score <= 90) {
return Color(0x65cbf3);
} else {
return Color(0x0053d6);
}
};
color = (location: Location) => {
if (StructureElement.Location.is(location)) {
return getColor(location);
} else if (Bond.isLocation(location)) {
l.unit = location.aUnit;
l.element = location.aUnit.elements[location.aIndex];
return getColor(l);
}
return DefaultColor;
};
}
return {
factory: PLDDTConfidenceColorTheme,
granularity: 'group',
preferSmoothing: true,
color,
props,
description: 'Assigns residue colors according to the pLDDT Confidence score.',
legend: ConfidenceColorLegend
};
}
export const PLDDTConfidenceColorThemeProvider: ColorTheme.Provider<PLDDTConfidenceColorThemeParams, 'plddt-confidence'> = {
name: 'plddt-confidence',
label: 'pLDDT Confidence',
category: ColorTheme.Category.Validation,
factory: PLDDTConfidenceColorTheme,
getParams: getPLDDTConfidenceColorThemeParams,
defaultValues: PD.getDefaultValues(getPLDDTConfidenceColorThemeParams({})),
isApplicable: (ctx: ThemeDataContext) => !!ctx.structure?.models.some(m => QualityAssessment.isApplicable(m, 'pLDDT')),
ensureCustomProperties: {
attach: async (ctx: CustomProperty.Context, data: ThemeDataContext) => {
if (data.structure) {
for (const m of data.structure.models) {
await QualityAssessmentProvider.attach(ctx, m, void 0, true);
}
}
},
detach: async (data: ThemeDataContext) => {
if (data.structure) {
for (const m of data.structure.models) {
QualityAssessmentProvider.ref(m, false);
}
}
}
}
};

View File

@@ -0,0 +1,95 @@
/**
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { QualityAssessment, QualityAssessmentProvider } from '../prop';
import { Location } from '../../../../mol-model/location';
import { Bond, StructureElement, Unit } from '../../../../mol-model/structure';
import { ColorTheme, LocationColor } from '../../../../mol-theme/color';
import { ThemeDataContext } from '../../../../mol-theme/theme';
import { Color, ColorScale } from '../../../../mol-util/color';
import { ParamDefinition as PD } from '../../../../mol-util/param-definition';
import { CustomProperty } from '../../../../mol-model-props/common/custom-property';
const DefaultColor = Color(0xaaaaaa);
export function getQmeanScoreColorThemeParams(ctx: ThemeDataContext) {
return {};
}
export type QmeanScoreColorThemeParams = ReturnType<typeof getQmeanScoreColorThemeParams>
export function QmeanScoreColorTheme(ctx: ThemeDataContext, props: PD.Values<QmeanScoreColorThemeParams>): ColorTheme<QmeanScoreColorThemeParams> {
let color: LocationColor = () => DefaultColor;
const scale = ColorScale.create({
domain: [0, 1],
listOrName: [
[Color(0xFF5000), 0.5], [Color(0x025AFD), 1.0]
]
});
if (ctx.structure) {
const l = StructureElement.Location.create(ctx.structure.root);
const getColor = (location: StructureElement.Location): Color => {
const { unit, element } = location;
if (!Unit.isAtomic(unit)) return DefaultColor;
const qualityAssessment = QualityAssessmentProvider.get(unit.model).value;
const score = qualityAssessment?.qmean?.get(unit.model.atomicHierarchy.residueAtomSegments.index[element]) ?? -1;
if (score < 0) {
return DefaultColor;
} else {
return scale.color(score);
}
};
color = (location: Location) => {
if (StructureElement.Location.is(location)) {
return getColor(location);
} else if (Bond.isLocation(location)) {
l.unit = location.aUnit;
l.element = location.aUnit.elements[location.aIndex];
return getColor(l);
}
return DefaultColor;
};
}
return {
factory: QmeanScoreColorTheme,
granularity: 'group',
preferSmoothing: true,
color,
props,
description: 'Assigns residue colors according to the QMEAN score.',
legend: scale.legend
};
}
export const QmeanScoreColorThemeProvider: ColorTheme.Provider<QmeanScoreColorThemeParams, 'qmean-score'> = {
name: 'qmean-score',
label: 'QMEAN Score',
category: ColorTheme.Category.Validation,
factory: QmeanScoreColorTheme,
getParams: getQmeanScoreColorThemeParams,
defaultValues: PD.getDefaultValues(getQmeanScoreColorThemeParams({})),
isApplicable: (ctx: ThemeDataContext) => !!ctx.structure?.models.some(m => QualityAssessment.isApplicable(m, 'qmean')),
ensureCustomProperties: {
attach: async (ctx: CustomProperty.Context, data: ThemeDataContext) => {
if (data.structure) {
for (const m of data.structure.models) {
await QualityAssessmentProvider.attach(ctx, m, void 0, true);
}
}
},
detach: async (data: ThemeDataContext) => {
if (data.structure) {
for (const m of data.structure.models) {
QualityAssessmentProvider.ref(m, false);
}
}
}
}
};

View File

@@ -0,0 +1,131 @@
/**
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { ParamDefinition as PD } from '../../../mol-util/param-definition';
import { Unit } from '../../../mol-model/structure';
import { CustomProperty } from '../../../mol-model-props/common/custom-property';
import { CustomModelProperty } from '../../../mol-model-props/common/custom-model-property';
import { Model, ResidueIndex } from '../../../mol-model/structure/model';
import { QuerySymbolRuntime } from '../../../mol-script/runtime/query/compiler';
import { CustomPropSymbol } from '../../../mol-script/language/symbol';
import { Type } from '../../../mol-script/language/type';
import { CustomPropertyDescriptor } from '../../../mol-model/custom-property';
import { MmcifFormat } from '../../../mol-model-formats/structure/mmcif';
export { QualityAssessment };
interface QualityAssessment {
localMetrics: Map<string, Map<ResidueIndex, number>>
pLDDT?: Map<ResidueIndex, number>
qmean?: Map<ResidueIndex, number>
}
namespace QualityAssessment {
const Empty = {
value: {
localMetrics: new Map()
}
};
export function isApplicable(model?: Model, localMetricName?: 'pLDDT' | 'qmean'): boolean {
if (!model || !MmcifFormat.is(model.sourceData)) return false;
const { db } = model.sourceData.data;
const hasLocalMetric = (
db.ma_qa_metric.id.isDefined &&
db.ma_qa_metric_local.ordinal_id.isDefined
);
if (localMetricName && hasLocalMetric) {
for (let i = 0, il = db.ma_qa_metric._rowCount; i < il; i++) {
if (db.ma_qa_metric.mode.value(i) !== 'local') continue;
if (localMetricName === db.ma_qa_metric.name.value(i)) return true;
}
return false;
} else {
return hasLocalMetric;
}
}
export async function obtain(ctx: CustomProperty.Context, model: Model, props: QualityAssessmentProps): Promise<CustomProperty.Data<QualityAssessment>> {
if (!model || !MmcifFormat.is(model.sourceData)) return Empty;
const { ma_qa_metric, ma_qa_metric_local } = model.sourceData.data.db;
const { model_id, label_asym_id, label_seq_id, metric_id, metric_value } = ma_qa_metric_local;
const { index } = model.atomicHierarchy;
// for simplicity we assume names in ma_qa_metric for mode 'local' are unique
const localMetrics = new Map<string, Map<ResidueIndex, number>>();
const localNames = new Map<number, string>();
for (let i = 0, il = ma_qa_metric._rowCount; i < il; i++) {
if (ma_qa_metric.mode.value(i) !== 'local') continue;
const name = ma_qa_metric.name.value(i);
if (localMetrics.has(name)) {
console.warn(`local ma_qa_metric with name '${name}' already added`);
continue;
}
localMetrics.set(name, new Map());
localNames.set(ma_qa_metric.id.value(i), name);
}
for (let i = 0, il = ma_qa_metric_local._rowCount; i < il; i++) {
if (model_id.value(i) !== model.modelNum) continue;
const labelAsymId = label_asym_id.value(i);
const entityIndex = index.findEntity(labelAsymId);
const rI = index.findResidue(model.entities.data.id.value(entityIndex), labelAsymId, label_seq_id.value(i));
const name = localNames.get(metric_id.value(i))!;
localMetrics.get(name)!.set(rI, metric_value.value(i));
}
return {
value: {
localMetrics,
pLDDT: localMetrics.get('pLDDT'),
qmean: localMetrics.get('qmean'),
}
};
}
export const symbols = {
pLDDT: QuerySymbolRuntime.Dynamic(CustomPropSymbol('ma', 'quality-assessment.pLDDT', Type.Num),
ctx => {
const { unit, element } = ctx.element;
if (!Unit.isAtomic(unit)) return -1;
const qualityAssessment = QualityAssessmentProvider.get(unit.model).value;
return qualityAssessment?.pLDDT?.get(unit.model.atomicHierarchy.residueAtomSegments.index[element]) ?? -1;
}
),
qmean: QuerySymbolRuntime.Dynamic(CustomPropSymbol('ma', 'quality-assessment.qmean', Type.Num),
ctx => {
const { unit, element } = ctx.element;
if (!Unit.isAtomic(unit)) return -1;
const qualityAssessment = QualityAssessmentProvider.get(unit.model).value;
return qualityAssessment?.qmean?.get(unit.model.atomicHierarchy.residueAtomSegments.index[element]) ?? -1;
}
),
};
}
export const QualityAssessmentParams = { };
export type QualityAssessmentParams = typeof QualityAssessmentParams
export type QualityAssessmentProps = PD.Values<QualityAssessmentParams>
export const QualityAssessmentProvider: CustomModelProperty.Provider<QualityAssessmentParams, QualityAssessment> = CustomModelProperty.createProvider({
label: 'QualityAssessment',
descriptor: CustomPropertyDescriptor({
name: 'ma_quality_assessment',
symbols: QualityAssessment.symbols
}),
type: 'static',
defaultParams: QualityAssessmentParams,
getParams: (data: Model) => QualityAssessmentParams,
isApplicable: (data: Model) => QualityAssessment.isApplicable(data),
obtain: async (ctx: CustomProperty.Context, data: Model, props: Partial<QualityAssessmentProps>) => {
const p = { ...PD.getDefaultValues(QualityAssessmentParams), ...props };
return await QualityAssessment.obtain(ctx, data, p);
}
});

View File

@@ -31,7 +31,7 @@ export class Mp4Controls extends PluginComponent {
canApply: this.ev.behavior<PluginStateAnimation.CanApply>({ canApply: false }),
info: this.ev.behavior<Mp4AnimationInfo>({ width: 0, height: 0 }),
params: this.ev.behavior<PD.Values<typeof Mp4AnimationParams>>(PD.getDefaultValues(Mp4AnimationParams))
}
};
setCurrent(name?: string) {
const anim = this.animations.find(a => a.name === name);
@@ -73,7 +73,7 @@ export class Mp4Controls extends PluginComponent {
const filename = anim.anim.display.name.toLowerCase().replace(/\s/g, '-').replace(/[^a-z0-9_\-]/g, '');
return { movie, filename: `${this.plugin.helpers.viewportScreenshot?.getFilename('')}_${filename}.mp4` };
} catch (e) {
this.plugin.log.error('' + e);
this.plugin.log.error('Error during animation export');
throw e;
}
});
@@ -125,17 +125,20 @@ export class Mp4Controls extends PluginComponent {
this.subscribe(this.plugin.canvas3d?.resized!, () => this.syncInfo());
this.subscribe(this.plugin.helpers.viewportScreenshot?.events.previewed!, () => this.syncInfo());
this.subscribe(this.plugin.behaviors.state.isBusy, b => {
const anim = this.current;
if (!b && anim) {
this.behaviors.canApply.next(anim.anim.canApply?.(this.plugin) ?? { canApply: true });
}
});
this.subscribe(this.plugin.behaviors.state.isBusy, b => this.updateCanApply(b));
this.subscribe(this.plugin.managers.snapshot.events.changed, b => this.updateCanApply(b));
this.sync();
this.syncInfo();
}
private updateCanApply(b?: any) {
const anim = this.current;
if (!b && anim) {
this.behaviors.canApply.next(anim.anim.canApply?.(this.plugin) ?? { canApply: true });
}
}
constructor(private plugin: PluginContext) {
super();

View File

@@ -108,15 +108,16 @@ export class Mp4EncoderUI extends CollapsableControls<{}, State> {
save = () => {
download(new Blob([this.state.data!.movie]), this.state.data!.filename);
}
};
generate = async () => {
try {
this.setState({ busy: true });
const data = await this.controls.render();
this.setState({ busy: false, data });
} catch {
} catch (e) {
console.error(e);
this.setState({ busy: false });
}
}
};
}

View File

@@ -21,7 +21,7 @@ export const PDBeStructureQualityReport = PluginBehavior.create<{ autoAttach: bo
},
ctor: class extends PluginBehavior.Handler<{ autoAttach: boolean, showTooltip: boolean }> {
private provider = StructureQualityReportProvider
private provider = StructureQualityReportProvider;
private labelPDBeValidation = {
label: (loci: Loci): string | undefined => {
@@ -42,7 +42,7 @@ export const PDBeStructureQualityReport = PluginBehavior.create<{ autoAttach: bo
default: return void 0;
}
}
}
};
register(): void {
this.ctx.customModelProperties.register(this.provider, this.params.autoAttach);

View File

@@ -38,7 +38,7 @@ namespace StructureQualityReport {
}
export function isApplicable(model?: Model): boolean {
return !!model && Model.isFromPdbArchive(model);
return !!model && Model.hasPdbId(model);
}
export const Schema = {

View File

@@ -27,7 +27,7 @@ export const RCSBAssemblySymmetry = PluginBehavior.create<{ autoAttach: boolean
description: 'Assembly Symmetry data calculated with BioJava, obtained via RCSB PDB.'
},
ctor: class extends PluginBehavior.Handler<{ autoAttach: boolean }> {
private provider = AssemblySymmetryProvider
private provider = AssemblySymmetryProvider;
register(): void {
this.ctx.state.data.actions.add(InitAssemblySymmetry3D);

View File

@@ -53,7 +53,7 @@ export namespace AssemblySymmetry {
export function isApplicable(structure?: Structure): boolean {
return (
!!structure && structure.models.length === 1 &&
Model.isFromPdbArchive(structure.models[0]) &&
Model.hasPdbId(structure.models[0]) &&
isBiologicalAssembly(structure)
);
}

View File

@@ -118,7 +118,7 @@ export class AssemblySymmetryControls extends CollapsableControls<{}, AssemblySy
paramsOnChange = (options: AssemblySymmetryProps) => {
this.updateAssemblySymmetry(options);
}
};
get hasAssemblySymmetry3D() {
return !this.pivot.cell.parent || !!StateSelection.findTagInSubtree(this.pivot.cell.parent.tree, this.pivot.cell.transform.ref, AssemblySymmetry.Tag.Representation);

View File

@@ -1,9 +1,10 @@
/* eslint-disable */
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
// Generated on 2021-09-12T13:31:40-07:00
// Generated on 2021-11-25T14:34:23-08:00
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
@@ -6769,7 +6770,7 @@ export type Query = {
/** Query root */
export type QueryAssembliesArgs = {
assembly_ids: ReadonlyArray<Maybe<Scalars['String']>>;
assembly_ids: ReadonlyArray<InputMaybe<Scalars['String']>>;
};
@@ -6802,7 +6803,7 @@ export type QueryBranched_Entity_InstanceArgs = {
/** Query root */
export type QueryBranched_Entity_InstancesArgs = {
instance_ids: ReadonlyArray<Maybe<Scalars['String']>>;
instance_ids: ReadonlyArray<InputMaybe<Scalars['String']>>;
};
@@ -6814,7 +6815,7 @@ export type QueryChem_CompArgs = {
/** Query root */
export type QueryChem_CompsArgs = {
comp_ids: ReadonlyArray<Maybe<Scalars['String']>>;
comp_ids: ReadonlyArray<InputMaybe<Scalars['String']>>;
};
@@ -6852,7 +6853,7 @@ export type QueryNonpolymer_Entity_InstanceArgs = {
/** Query root */
export type QueryNonpolymer_Entity_InstancesArgs = {
instance_ids: ReadonlyArray<Maybe<Scalars['String']>>;
instance_ids: ReadonlyArray<InputMaybe<Scalars['String']>>;
};
@@ -6878,7 +6879,7 @@ export type QueryPolymer_Entity_InstanceArgs = {
/** Query root */
export type QueryPolymer_Entity_InstancesArgs = {
instance_ids: ReadonlyArray<Maybe<Scalars['String']>>;
instance_ids: ReadonlyArray<InputMaybe<Scalars['String']>>;
};
@@ -13144,4 +13145,4 @@ export type AssemblySymmetryQueryVariables = Exact<{
}>;
export type AssemblySymmetryQuery = { readonly assembly?: Maybe<{ readonly rcsb_struct_symmetry?: Maybe<ReadonlyArray<Maybe<{ readonly kind: string, readonly oligomeric_state: string, readonly stoichiometry: ReadonlyArray<Maybe<string>>, readonly symbol: string, readonly type: string, readonly clusters: ReadonlyArray<Maybe<{ readonly avg_rmsd?: Maybe<number>, readonly members: ReadonlyArray<Maybe<{ readonly asym_id: string, readonly pdbx_struct_oper_list_ids?: Maybe<ReadonlyArray<Maybe<string>>> }>> }>>, readonly rotation_axes?: Maybe<ReadonlyArray<Maybe<{ readonly order?: Maybe<number>, readonly start: ReadonlyArray<Maybe<number>>, readonly end: ReadonlyArray<Maybe<number>> }>>> }>>> }> };
export type AssemblySymmetryQuery = { readonly assembly?: { readonly rcsb_struct_symmetry?: ReadonlyArray<{ readonly kind: string, readonly oligomeric_state: string, readonly stoichiometry: ReadonlyArray<string | null | undefined>, readonly symbol: string, readonly type: string, readonly clusters: ReadonlyArray<{ readonly avg_rmsd?: number | null | undefined, readonly members: ReadonlyArray<{ readonly asym_id: string, readonly pdbx_struct_oper_list_ids?: ReadonlyArray<string | null | undefined> | null | undefined } | null | undefined> } | null | undefined>, readonly rotation_axes?: ReadonlyArray<{ readonly order?: number | null | undefined, readonly start: ReadonlyArray<number | null | undefined>, readonly end: ReadonlyArray<number | null | undefined> } | null | undefined> | null | undefined } | null | undefined> | null | undefined } | null | undefined };

View File

@@ -30,7 +30,7 @@ export const RCSBValidationReport = PluginBehavior.create<{ autoAttach: boolean,
description: 'Data from wwPDB Validation Report, obtained via RCSB PDB.'
},
ctor: class extends PluginBehavior.Handler<{ autoAttach: boolean, showTooltip: boolean }> {
private provider = ValidationReportProvider
private provider = ValidationReportProvider;
private labelProvider = {
label: (loci: Loci): string | undefined => {
@@ -41,7 +41,7 @@ export const RCSBValidationReport = PluginBehavior.create<{ autoAttach: boolean,
randomCoilIndexLabel(loci)
].filter(l => !!l).join('</br>');
}
}
};
register(): void {
DefaultQueryRuntimeTable.addCustomProp(this.provider.descriptor);

View File

@@ -92,7 +92,7 @@ namespace ValidationReport {
}
export function isApplicable(model?: Model): boolean {
return !!model && Model.isFromPdbArchive(model);
return !!model && Model.hasPdbId(model);
}
export function fromXml(xml: XMLDocument, model: Model): ValidationReport {

View File

@@ -37,7 +37,7 @@ class Camera implements ICamera {
readonly projectionView: Mat4 = Mat4.identity();
readonly inverseProjectionView: Mat4 = Mat4.identity();
private pixelScale: number
private pixelScale: number;
get pixelRatio() {
const dpr = (typeof window !== 'undefined') ? window.devicePixelRatio : 1;
return dpr * this.pixelScale;
@@ -47,11 +47,11 @@ class Camera implements ICamera {
readonly state: Readonly<Camera.Snapshot> = Camera.createDefaultSnapshot();
readonly viewOffset = Camera.ViewOffset();
near = 1
far = 10000
fogNear = 5000
fogFar = 10000
zoom = 1
near = 1;
far = 10000;
fogNear = 5000;
fogFar = 10000;
zoom = 1;
readonly transition: CameraTransitionManager = new CameraTransitionManager(this);
readonly stateChanged = new BehaviorSubject<Partial<Camera.Snapshot>>(this.state);

View File

@@ -33,7 +33,7 @@ class StereoCamera {
return this.parent.viewOffset;
}
private props: StereoCameraProps
private props: StereoCameraProps;
constructor(private parent: Camera, props: Partial<StereoCameraProps> = {}) {
this.props = { ...DefaultStereoCameraProps, ...props };

View File

@@ -39,6 +39,7 @@ import { Helper } from './helper/helper';
import { Passes } from './passes/passes';
import { shallowEqual } from '../mol-util';
import { MarkingParams } from './passes/marking';
import { GraphicsRenderVariantsBlended, GraphicsRenderVariantsWboit } from '../mol-gl/webgl/render-item';
export const Canvas3DParams = {
camera: PD.Group({
@@ -222,7 +223,7 @@ interface Canvas3D {
clear(): void
syncVisibility(): void
requestDraw(force?: boolean): void
requestDraw(): void
/** Reset the timers, used by "animate" */
resetTime(t: number): void
@@ -296,7 +297,7 @@ namespace Canvas3D {
let height = 128;
updateViewport();
const scene = Scene.create(webgl);
const scene = Scene.create(webgl, passes.draw.wboitEnabled ? GraphicsRenderVariantsWboit : GraphicsRenderVariantsBlended);
const camera = new Camera({
position: Vec3.create(0, 0, 100),
@@ -354,17 +355,24 @@ namespace Canvas3D {
changed = helper.camera.mark(loci, action) || changed;
reprRenderObjects.forEach((_, _repr) => { changed = _repr.mark(loci, action) || changed; });
}
if (changed && !noDraw) {
scene.update(void 0, true);
helper.handle.scene.update(void 0, true);
helper.camera.scene.update(void 0, true);
const prevPickDirty = pickHelper.dirty;
draw(true);
pickHelper.dirty = prevPickDirty; // marking does not change picking buffers
if (changed) {
if (noDraw) {
// Even with `noDraw` make sure changes will be rendered.
// Note that with this calling mark (with or without `noDraw`) multiple times
// during a JS event loop iteration will only result in a single render call.
forceNextRender = true;
} else {
scene.update(void 0, true);
helper.handle.scene.update(void 0, true);
helper.camera.scene.update(void 0, true);
const prevPickDirty = pickHelper.dirty;
draw({ force: true, allowMulti: true });
pickHelper.dirty = prevPickDirty; // marking does not change picking buffers
}
}
}
function render(force: boolean) {
function render(force: boolean, allowMulti: boolean) {
if (webgl.isContextLost) return false;
let resized = false;
@@ -394,10 +402,12 @@ namespace Canvas3D {
cam = stereoCamera;
}
const ctx = { renderer, camera: cam, scene, helper };
if (MultiSamplePass.isEnabled(p.multiSample)) {
multiSampleHelper.render(renderer, cam, scene, helper, true, p.transparentBackground, p);
const forceOn = !cameraChanged && allowMulti && !controls.props.spin;
multiSampleHelper.render(ctx, p, true, forceOn);
} else {
passes.draw.render(renderer, cam, scene, helper, true, p.transparentBackground, p.postprocessing, p.marking);
passes.draw.render(ctx, p, true);
}
pickHelper.dirty = true;
didRender = true;
@@ -411,15 +421,15 @@ namespace Canvas3D {
let currentTime = 0;
let drawPaused = false;
function draw(force?: boolean) {
function draw(options?: { force?: boolean, allowMulti?: boolean }) {
if (drawPaused) return;
if (render(!!force) && notifyDidDraw) {
if (render(!!options?.force, !!options?.allowMulti) && notifyDidDraw) {
didDraw.next(now() - startTime as now.Timestamp);
}
}
function requestDraw(force?: boolean) {
forceNextRender = forceNextRender || !!force;
function requestDraw() {
forceNextRender = true;
}
let animationFrameHandle = 0;
@@ -433,8 +443,8 @@ namespace Canvas3D {
return;
}
draw(false);
if (!camera.transition.inTransition && !webgl.isContextLost) {
draw();
if (!camera.transition.inTransition && !controls.props.spin && !webgl.isContextLost) {
interactionHelper.tick(currentTime);
}
}
@@ -473,7 +483,7 @@ namespace Canvas3D {
resolveCameraReset();
if (forceDrawAfterAllCommited) {
if (helper.debug.isEnabled) helper.debug.update();
draw(true);
draw({ force: true });
forceDrawAfterAllCommited = false;
}
commited.next(now());
@@ -514,7 +524,7 @@ namespace Canvas3D {
if (camera.transition.inTransition || nextCameraResetSnapshot) return false;
let cameraSphereOverlapsNone = true;
let cameraSphereOverlapsNone = true, isEmpty = true;
Sphere3D.set(cameraSphere, camera.state.target, camera.state.radius);
// check if any renderable has moved outside of the old bounding sphere
@@ -525,12 +535,13 @@ namespace Canvas3D {
const b = r.values.boundingSphere.ref.value;
if (!b.radius) continue;
isEmpty = false;
const cameraDist = Vec3.distance(cameraSphere.center, b.center);
if ((cameraDist > cameraSphere.radius || cameraDist > b.radius || b.radius > camera.state.radiusMax) && !Sphere3D.includes(oldBoundingSphereVisible, b)) return true;
if (Sphere3D.overlaps(cameraSphere, b)) cameraSphereOverlapsNone = false;
}
return cameraSphereOverlapsNone;
return cameraSphereOverlapsNone || (!isEmpty && cameraSphere.radius <= 0.1);
}
const sceneCommitTimeoutMs = 250;
@@ -655,11 +666,11 @@ namespace Canvas3D {
const contextRestoredSub = contextRestored.subscribe(() => {
pickHelper.dirty = true;
draw(true);
draw({ force: true });
// Unclear why, but in Chrome with wboit enabled the first `draw` only clears
// the drawingBuffer. Note that in Firefox the drawingBuffer is preserved after
// context loss so it is unclear if it behaves the same.
draw(true);
draw({ force: true });
});
const resized = new BehaviorSubject<any>(0);
@@ -668,7 +679,7 @@ namespace Canvas3D {
passes.updateSize();
updateViewport();
syncViewport();
if (draw) requestDraw(true);
if (draw) requestDraw();
resized.next(+new Date());
}
@@ -693,7 +704,7 @@ namespace Canvas3D {
reprRenderObjects.clear();
scene.clear();
helper.debug.clear();
requestDraw(true);
requestDraw();
reprCount.next(reprRenderObjects.size);
},
syncVisibility: () => {
@@ -705,7 +716,7 @@ namespace Canvas3D {
if (scene.syncVisibility()) {
if (helper.debug.isEnabled) helper.debug.update();
}
requestDraw(true);
requestDraw();
},
requestDraw,
@@ -793,7 +804,7 @@ namespace Canvas3D {
}
if (!doNotRequestDraw) {
requestDraw(true);
requestDraw();
}
},
getImagePass: (props: Partial<ImageProps> = {}) => {

View File

@@ -18,6 +18,7 @@ import { TransformData } from '../../mol-geo/geometry/transform-data';
import { sphereVertexCount } from '../../mol-geo/primitive/sphere';
import { ValueCell } from '../../mol-util';
import { Geometry } from '../../mol-geo/geometry/geometry';
import { GraphicsRenderVariantsBlended } from '../../mol-gl/webgl/render-item';
export const DebugHelperParams = {
sceneBoundingSpheres: PD.Boolean(false, { description: 'Show full scene bounding spheres.' }),
@@ -31,17 +32,17 @@ export type DebugHelperProps = PD.Values<DebugHelperParams>
type BoundingSphereData = { boundingSphere: Sphere3D, renderObject: GraphicsRenderObject, mesh: Mesh }
export class BoundingSphereHelper {
readonly scene: Scene
readonly scene: Scene;
private readonly parent: Scene
private _props: DebugHelperProps
private objectsData = new Map<GraphicsRenderObject, BoundingSphereData>()
private instancesData = new Map<GraphicsRenderObject, BoundingSphereData>()
private sceneData: BoundingSphereData | undefined
private visibleSceneData: BoundingSphereData | undefined
private readonly parent: Scene;
private _props: DebugHelperProps;
private objectsData = new Map<GraphicsRenderObject, BoundingSphereData>();
private instancesData = new Map<GraphicsRenderObject, BoundingSphereData>();
private sceneData: BoundingSphereData | undefined;
private visibleSceneData: BoundingSphereData | undefined;
constructor(ctx: WebGLContext, parent: Scene, props: Partial<DebugHelperProps>) {
this.scene = Scene.create(ctx);
this.scene = Scene.create(ctx, GraphicsRenderVariantsBlended);
this.parent = parent;
this._props = { ...PD.getDefaultValues(DebugHelperParams), ...props };
}
@@ -160,5 +161,5 @@ const instanceMaterialId = getNextMaterialId();
function createBoundingSphereRenderObject(mesh: Mesh, color: Color, materialId: number, transform?: TransformData) {
const values = Mesh.Utils.createValuesSimple(mesh, { alpha: 0.1, doubleSided: false }, color, 1, transform);
return createRenderObject('mesh', values, { disposed: false, visible: true, alphaFactor: 1, pickable: false, colorOnly: false, opaque: false, writeDepth: false, noClip: false }, materialId);
return createRenderObject('mesh', values, { disposed: false, visible: true, alphaFactor: 1, pickable: false, colorOnly: false, opaque: false, writeDepth: false }, materialId);
}

View File

@@ -14,6 +14,7 @@ import { PickingId } from '../../mol-geo/geometry/picking';
import { GraphicsRenderObject } from '../../mol-gl/render-object';
import { Scene } from '../../mol-gl/scene';
import { WebGLContext } from '../../mol-gl/webgl/context';
import { GraphicsRenderVariantsBlended } from '../../mol-gl/webgl/render-item';
import { Sphere3D } from '../../mol-math/geometry';
import { Mat4, Vec3 } from '../../mol-math/linear-algebra';
import { DataLoci, EmptyLoci, Loci } from '../../mol-model/loci';
@@ -49,16 +50,16 @@ export type CameraHelperParams = typeof CameraHelperParams
export type CameraHelperProps = PD.Values<CameraHelperParams>
export class CameraHelper {
scene: Scene
camera: Camera
scene: Scene;
camera: Camera;
props: CameraHelperProps = {
axes: { name: 'off', params: {} }
}
};
private renderObject: GraphicsRenderObject | undefined
private renderObject: GraphicsRenderObject | undefined;
constructor(private webgl: WebGLContext, props: Partial<CameraHelperProps> = {}) {
this.scene = Scene.create(webgl);
this.scene = Scene.create(webgl, GraphicsRenderVariantsBlended);
this.camera = new Camera();
Vec3.set(this.camera.up, 0, 1, 0);
@@ -75,7 +76,6 @@ export class CameraHelper {
this.scene.clear();
const params = { ...props.axes.params, scale: props.axes.params.scale * this.webgl.pixelRatio };
this.renderObject = createAxesRenderObject(params);
this.renderObject.state.noClip = true;
this.scene.add(this.renderObject);
this.scene.commit();
@@ -109,7 +109,7 @@ export class CameraHelper {
if (apply(Interval.ofSingleton(idx))) changed = true;
}
return changed;
}
};
mark(loci: Loci, action: MarkerAction) {
if (!MarkerActions.is(MarkerActions.Highlighting, action)) return false;
@@ -201,7 +201,7 @@ function createAxesMesh(scale: number, mesh?: Mesh) {
const x = Vec3.scale(Vec3(), Vec3.unitX, scale);
const y = Vec3.scale(Vec3(), Vec3.unitY, scale);
const z = Vec3.scale(Vec3(), Vec3.unitZ, scale);
const cylinderProps = { radiusTop: radius, radiusBottom: radius, radialSegments: 32 };
const cylinderProps = { radiusTop: radius, radiusBottom: radius, radialSegments: 32 };
state.currentGroup = CameraHelperAxis.None;
addSphere(state, Vec3.origin, radius, 2);

View File

@@ -24,6 +24,7 @@ import { DataLoci, EmptyLoci, Loci } from '../../mol-model/loci';
import { MarkerAction, MarkerActions } from '../../mol-util/marker-action';
import { Visual } from '../../mol-repr/visual';
import { Interval } from '../../mol-data/int';
import { GraphicsRenderVariantsBlended } from '../../mol-gl/webgl/render-item';
const HandleParams = {
...Mesh.Params,
@@ -47,12 +48,12 @@ export type HandleHelperParams = typeof HandleHelperParams
export type HandleHelperProps = PD.Values<HandleHelperParams>
export class HandleHelper {
scene: Scene
scene: Scene;
props: HandleHelperProps = {
handle: { name: 'off', params: {} }
}
};
private renderObject: GraphicsRenderObject | undefined
private renderObject: GraphicsRenderObject | undefined;
private _transform = Mat4();
getBoundingSphere(out: Sphere3D, instanceId: number) {
@@ -72,7 +73,6 @@ export class HandleHelper {
this.scene.clear();
const params = { ...props.handle.params, scale: props.handle.params.scale * this.webgl.pixelRatio };
this.renderObject = createHandleRenderObject(params);
this.renderObject.state.noClip = true;
this.scene.add(this.renderObject);
this.scene.commit();
@@ -117,7 +117,7 @@ export class HandleHelper {
if (apply(Interval.ofSingleton(idx))) changed = true;
}
return changed;
}
};
mark(loci: Loci, action: MarkerAction) {
if (!MarkerActions.is(MarkerActions.Highlighting, action)) return false;
@@ -127,7 +127,7 @@ export class HandleHelper {
}
constructor(private webgl: WebGLContext, props: Partial<HandleHelperProps> = {}) {
this.scene = Scene.create(webgl);
this.scene = Scene.create(webgl, GraphicsRenderVariantsBlended);
this.setProps(props);
}
}

View File

@@ -23,9 +23,9 @@ export type HelperProps = PD.Values<typeof HelperParams>
export class Helper {
readonly debug: BoundingSphereHelper
readonly camera: CameraHelper
readonly handle: HandleHelper
readonly debug: BoundingSphereHelper;
readonly camera: CameraHelper;
readonly handle: HandleHelper;
constructor(webgl: WebGLContext, scene: Scene, props: Partial<HelperProps> = {}) {
const p = { ...DefaultHelperProps, ...props };

View File

@@ -22,11 +22,11 @@ import { Helper } from '../helper/helper';
import { quad_vert } from '../../mol-gl/shader/quad.vert';
import { depthMerge_frag } from '../../mol-gl/shader/depth-merge.frag';
import { copy_frag } from '../../mol-gl/shader/copy.frag';
import { StereoCamera } from '../camera/stereo';
import { WboitPass } from './wboit';
import { AntialiasingPass, PostprocessingPass, PostprocessingProps } from './postprocessing';
import { MarkingPass, MarkingProps } from './marking';
import { CopyRenderable, createCopyRenderable } from '../../mol-gl/compute/util';
const DepthMergeSchema = {
...QuadSchema,
@@ -53,49 +53,41 @@ function getDepthMergeRenderable(ctx: WebGLContext, depthTexturePrimitives: Text
return createComputeRenderable(renderItem, values);
}
const CopySchema = {
...QuadSchema,
tColor: TextureSpec('texture', 'rgba', 'ubyte', 'nearest'),
uTexSize: UniformSpec('v2'),
};
const CopyShaderCode = ShaderCode('copy', quad_vert, copy_frag);
type CopyRenderable = ComputeRenderable<Values<typeof CopySchema>>
type Props = {
postprocessing: PostprocessingProps
marking: MarkingProps
transparentBackground: boolean;
}
function getCopyRenderable(ctx: WebGLContext, colorTexture: Texture): CopyRenderable {
const values: Values<typeof CopySchema> = {
...QuadValues,
tColor: ValueCell.create(colorTexture),
uTexSize: ValueCell.create(Vec2.create(colorTexture.getWidth(), colorTexture.getHeight())),
};
const schema = { ...CopySchema };
const renderItem = createComputeRenderItem(ctx, 'triangles', CopyShaderCode, schema, values);
return createComputeRenderable(renderItem, values);
type RenderContext = {
renderer: Renderer;
camera: Camera | StereoCamera;
scene: Scene;
helper: Helper;
}
export class DrawPass {
private readonly drawTarget: RenderTarget
private readonly drawTarget: RenderTarget;
readonly colorTarget: RenderTarget
readonly depthTexture: Texture
readonly depthTexturePrimitives: Texture
readonly colorTarget: RenderTarget;
readonly depthTexture: Texture;
readonly depthTexturePrimitives: Texture;
readonly packedDepth: boolean
readonly packedDepth: boolean;
private depthTarget: RenderTarget
private depthTargetPrimitives: RenderTarget | null
private depthTargetVolumes: RenderTarget | null
private depthTextureVolumes: Texture
private depthMerge: DepthMergeRenderable
private depthTarget: RenderTarget;
private depthTargetPrimitives: RenderTarget | null;
private depthTargetVolumes: RenderTarget | null;
private depthTextureVolumes: Texture;
private depthMerge: DepthMergeRenderable;
private copyFboTarget: CopyRenderable
private copyFboPostprocessing: CopyRenderable
private copyFboTarget: CopyRenderable;
private copyFboPostprocessing: CopyRenderable;
private wboit: WboitPass | undefined
private readonly marking: MarkingPass
readonly postprocessing: PostprocessingPass
private readonly antialiasing: AntialiasingPass
private wboit: WboitPass | undefined;
private readonly marking: MarkingPass;
readonly postprocessing: PostprocessingPass;
private readonly antialiasing: AntialiasingPass;
get wboitEnabled() {
return !!this.wboit?.supported;
@@ -128,8 +120,8 @@ export class DrawPass {
this.postprocessing = new PostprocessingPass(webgl, this);
this.antialiasing = new AntialiasingPass(webgl, this);
this.copyFboTarget = getCopyRenderable(webgl, this.colorTarget.texture);
this.copyFboPostprocessing = getCopyRenderable(webgl, this.postprocessing.target.texture);
this.copyFboTarget = createCopyRenderable(webgl, this.colorTarget.texture);
this.copyFboPostprocessing = createCopyRenderable(webgl, this.postprocessing.target.texture);
}
reset() {
@@ -285,25 +277,25 @@ export class DrawPass {
renderer.renderBlendedTransparent(scene.primitives, camera, null);
}
private _render(renderer: Renderer, camera: ICamera, scene: Scene, helper: Helper, toDrawingBuffer: boolean, transparentBackground: boolean, postprocessingProps: PostprocessingProps, markingProps: MarkingProps) {
private _render(renderer: Renderer, camera: ICamera, scene: Scene, helper: Helper, toDrawingBuffer: boolean, props: Props) {
const volumeRendering = scene.volumes.renderables.length > 0;
const postprocessingEnabled = PostprocessingPass.isEnabled(postprocessingProps);
const antialiasingEnabled = AntialiasingPass.isEnabled(postprocessingProps);
const markingEnabled = MarkingPass.isEnabled(markingProps);
const postprocessingEnabled = PostprocessingPass.isEnabled(props.postprocessing);
const antialiasingEnabled = AntialiasingPass.isEnabled(props.postprocessing);
const markingEnabled = MarkingPass.isEnabled(props.marking);
const { x, y, width, height } = camera.viewport;
renderer.setViewport(x, y, width, height);
renderer.update(camera);
if (transparentBackground && !antialiasingEnabled && toDrawingBuffer) {
if (props.transparentBackground && !antialiasingEnabled && toDrawingBuffer) {
this.drawTarget.bind();
renderer.clear(false);
}
if (this.wboitEnabled) {
this._renderWboit(renderer, camera, scene, transparentBackground, postprocessingProps);
this._renderWboit(renderer, camera, scene, props.transparentBackground, props.postprocessing);
} else {
this._renderBlended(renderer, camera, scene, !volumeRendering && !postprocessingEnabled && !antialiasingEnabled && toDrawingBuffer, transparentBackground, postprocessingProps);
this._renderBlended(renderer, camera, scene, !volumeRendering && !postprocessingEnabled && !antialiasingEnabled && toDrawingBuffer, props.transparentBackground, props.postprocessing);
}
if (postprocessingEnabled) {
@@ -315,7 +307,7 @@ export class DrawPass {
}
if (markingEnabled) {
const markingDepthTest = markingProps.ghostEdgeStrength < 1;
const markingDepthTest = props.marking.ghostEdgeStrength < 1;
if (markingDepthTest) {
this.marking.depthTarget.bind();
renderer.clear(false);
@@ -326,7 +318,7 @@ export class DrawPass {
renderer.clear(false);
renderer.renderMarkingMask(scene.primitives, camera, markingDepthTest ? this.marking.depthTarget.texture : null);
this.marking.update(markingProps);
this.marking.update(props.marking);
this.marking.render(camera.viewport, postprocessingEnabled ? this.postprocessing.target : this.colorTarget);
}
@@ -344,7 +336,7 @@ export class DrawPass {
}
if (antialiasingEnabled) {
this.antialiasing.render(camera, toDrawingBuffer, postprocessingProps);
this.antialiasing.render(camera, toDrawingBuffer, props.postprocessing);
} else if (toDrawingBuffer) {
this.drawTarget.bind();
@@ -359,16 +351,17 @@ export class DrawPass {
this.webgl.gl.flush();
}
render(renderer: Renderer, camera: Camera | StereoCamera, scene: Scene, helper: Helper, toDrawingBuffer: boolean, transparentBackground: boolean, postprocessingProps: PostprocessingProps, markingProps: MarkingProps) {
renderer.setTransparentBackground(transparentBackground);
render(ctx: RenderContext, props: Props, toDrawingBuffer: boolean) {
const { renderer, camera, scene, helper } = ctx;
renderer.setTransparentBackground(props.transparentBackground);
renderer.setDrawingBufferSize(this.colorTarget.getWidth(), this.colorTarget.getHeight());
renderer.setPixelRatio(this.webgl.pixelRatio);
if (StereoCamera.is(camera)) {
this._render(renderer, camera.left, scene, helper, toDrawingBuffer, transparentBackground, postprocessingProps, markingProps);
this._render(renderer, camera.right, scene, helper, toDrawingBuffer, transparentBackground, postprocessingProps, markingProps);
this._render(renderer, camera.left, scene, helper, toDrawingBuffer, props);
this._render(renderer, camera.right, scene, helper, toDrawingBuffer, props);
} else {
this._render(renderer, camera, scene, helper, toDrawingBuffer, transparentBackground, postprocessingProps, markingProps);
this._render(renderer, camera, scene, helper, toDrawingBuffer, props);
}
}

View File

@@ -28,7 +28,7 @@ export const FxaaParams = {
export type FxaaProps = PD.Values<typeof FxaaParams>
export class FxaaPass {
private readonly renderable: FxaaRenderable
private readonly renderable: FxaaRenderable;
constructor(private webgl: WebGLContext, input: Texture) {
this.renderable = getFxaaRenderable(webgl, input);

View File

@@ -30,19 +30,19 @@ export const ImageParams = {
export type ImageProps = PD.Values<typeof ImageParams>
export class ImagePass {
private _width = 0
private _height = 0
private _camera = new Camera()
private _width = 0;
private _height = 0;
private _camera = new Camera();
readonly props: ImageProps
readonly props: ImageProps;
private _colorTarget: RenderTarget
private _colorTarget: RenderTarget;
get colorTarget() { return this._colorTarget; }
private readonly drawPass: DrawPass
private readonly multiSamplePass: MultiSamplePass
private readonly multiSampleHelper: MultiSampleHelper
private readonly helper: Helper
private readonly drawPass: DrawPass;
private readonly multiSamplePass: MultiSamplePass;
private readonly multiSampleHelper: MultiSampleHelper;
private readonly helper: Helper;
get width() { return this._width; }
get height() { return this._height; }
@@ -83,11 +83,12 @@ export class ImagePass {
Viewport.set(this._camera.viewport, 0, 0, this._width, this._height);
this._camera.update();
const ctx = { renderer: this.renderer, camera: this._camera, scene: this.scene, helper: this.helper };
if (MultiSamplePass.isEnabled(this.props.multiSample)) {
this.multiSampleHelper.render(this.renderer, this._camera, this.scene, this.helper, false, this.props.transparentBackground, this.props);
this.multiSampleHelper.render(ctx, this.props, false);
this._colorTarget = this.multiSamplePass.colorTarget;
} else {
this.drawPass.render(this.renderer, this._camera, this.scene, this.helper, false, this.props.transparentBackground, this.props.postprocessing, this.props.marking);
this.drawPass.render(ctx, this.props, false);
this._colorTarget = this.drawPass.getColorTarget(this.props.postprocessing);
}
}

View File

@@ -22,7 +22,7 @@ import { Color } from '../../mol-util/color';
import { edge_frag } from '../../mol-gl/shader/marking/edge.frag';
export const MarkingParams = {
enabled: PD.Boolean(false),
enabled: PD.Boolean(true),
highlightEdgeColor: PD.Color(Color.darken(Color.fromNormalizedRgb(1.0, 0.4, 0.6), 1.0)),
selectEdgeColor: PD.Color(Color.darken(Color.fromNormalizedRgb(0.2, 1.0, 0.1), 1.0)),
edgeScale: PD.Numeric(1, { min: 1, max: 3, step: 1 }, { description: 'Thickness of the edge.' }),
@@ -36,12 +36,12 @@ export class MarkingPass {
return props.enabled;
}
readonly depthTarget: RenderTarget
readonly maskTarget: RenderTarget
private readonly edgesTarget: RenderTarget
readonly depthTarget: RenderTarget;
readonly maskTarget: RenderTarget;
private readonly edgesTarget: RenderTarget;
private readonly edge: EdgeRenderable
private readonly overlay: OverlayRenderable
private readonly edge: EdgeRenderable;
private readonly overlay: OverlayRenderable;
constructor(private webgl: WebGLContext, width: number, height: number) {
this.depthTarget = webgl.createRenderTarget(width, height);

View File

@@ -50,8 +50,8 @@ function getComposeRenderable(ctx: WebGLContext, colorTexture: Texture): Compose
}
export const MultiSampleParams = {
mode: PD.Select('off', [['off', 'Off'], ['on', 'On'], ['temporal', 'Temporal']]),
sampleLevel: PD.Numeric(2, { min: 0, max: 5, step: 1 }),
mode: PD.Select('temporal', [['off', 'Off'], ['on', 'On'], ['temporal', 'Temporal']]),
sampleLevel: PD.Numeric(2, { min: 0, max: 5, step: 1 }, { description: 'Take level^2 samples.' }),
};
export type MultiSampleProps = PD.Values<typeof MultiSampleParams>
@@ -59,6 +59,14 @@ type Props = {
multiSample: MultiSampleProps
postprocessing: PostprocessingProps
marking: MarkingProps
transparentBackground: boolean;
}
type RenderContext = {
renderer: Renderer;
camera: Camera | StereoCamera;
scene: Scene;
helper: Helper;
}
export class MultiSamplePass {
@@ -66,11 +74,11 @@ export class MultiSamplePass {
return props.mode !== 'off';
}
colorTarget: RenderTarget
colorTarget: RenderTarget;
private composeTarget: RenderTarget
private holdTarget: RenderTarget
private compose: ComposeRenderable
private composeTarget: RenderTarget;
private holdTarget: RenderTarget;
private compose: ComposeRenderable;
constructor(private webgl: WebGLContext, private drawPass: DrawPass) {
const { colorBufferFloat, textureFloat, colorBufferHalfFloat, textureHalfFloat } = webgl.extensions;
@@ -97,12 +105,12 @@ export class MultiSamplePass {
}
}
render(sampleIndex: number, renderer: Renderer, camera: Camera | StereoCamera, scene: Scene, helper: Helper, toDrawingBuffer: boolean, transparentBackground: boolean, props: Props) {
if (props.multiSample.mode === 'temporal') {
return this.renderTemporalMultiSample(sampleIndex, renderer, camera, scene, helper, toDrawingBuffer, transparentBackground, props);
render(sampleIndex: number, ctx: RenderContext, props: Props, toDrawingBuffer: boolean, forceOn: boolean) {
if (props.multiSample.mode === 'temporal' && !forceOn) {
return this.renderTemporalMultiSample(sampleIndex, ctx, props, toDrawingBuffer);
} else {
this.renderMultiSample(renderer, camera, scene, helper, toDrawingBuffer, transparentBackground, props);
return sampleIndex;
this.renderMultiSample(ctx, toDrawingBuffer, props);
return -2;
}
}
@@ -114,7 +122,8 @@ export class MultiSamplePass {
}
}
private renderMultiSample(renderer: Renderer, camera: Camera | StereoCamera, scene: Scene, helper: Helper, toDrawingBuffer: boolean, transparentBackground: boolean, props: Props) {
private renderMultiSample(ctx: RenderContext, toDrawingBuffer: boolean, props: Props) {
const { camera } = ctx;
const { compose, composeTarget, drawPass, webgl } = this;
const { gl, state } = webgl;
@@ -148,7 +157,7 @@ export class MultiSamplePass {
ValueCell.update(compose.values.uWeight, sampleWeight);
// render scene
drawPass.render(renderer, camera, scene, helper, false, transparentBackground, props.postprocessing, props.marking);
drawPass.render(ctx, props, false);
// compose rendered scene with compose target
composeTarget.bind();
@@ -181,7 +190,8 @@ export class MultiSamplePass {
camera.update();
}
private renderTemporalMultiSample(sampleIndex: number, renderer: Renderer, camera: Camera | StereoCamera, scene: Scene, helper: Helper, toDrawingBuffer: boolean, transparentBackground: boolean, props: Props) {
private renderTemporalMultiSample(sampleIndex: number, ctx: RenderContext, props: Props, toDrawingBuffer: boolean) {
const { camera } = ctx;
const { compose, composeTarget, holdTarget, drawPass, webgl } = this;
const { gl, state } = webgl;
@@ -198,7 +208,7 @@ export class MultiSamplePass {
const sampleWeight = 1.0 / offsetList.length;
if (sampleIndex === -1) {
drawPass.render(renderer, camera, scene, helper, false, transparentBackground, props.postprocessing, props.marking);
drawPass.render(ctx, props, false);
ValueCell.update(compose.values.uWeight, 1.0);
ValueCell.update(compose.values.tColor, drawPass.getColorTarget(props.postprocessing).texture);
compose.update();
@@ -226,7 +236,7 @@ export class MultiSamplePass {
camera.update();
// render scene
drawPass.render(renderer, camera, scene, helper, false, transparentBackground, props.postprocessing, props.marking);
drawPass.render(ctx, props, false);
// compose rendered scene with compose target
composeTarget.bind();
@@ -317,15 +327,17 @@ JitterVectors.forEach(offsetList => {
});
export class MultiSampleHelper {
private sampleIndex = -2
private sampleIndex = -2;
update(changed: boolean, props: MultiSampleProps) {
if (changed) this.sampleIndex = -1;
return props.mode === 'temporal' ? this.sampleIndex !== -2 : false;
}
render(renderer: Renderer, camera: Camera | StereoCamera, scene: Scene, helper: Helper, toDrawingBuffer: boolean, transparentBackground: boolean, props: Props) {
this.sampleIndex = this.multiSamplePass.render(this.sampleIndex, renderer, camera, scene, helper, toDrawingBuffer, transparentBackground, props);
/** Return `true` while more samples are needed */
render(ctx: RenderContext, props: Props, toDrawingBuffer: boolean, forceOn?: boolean) {
this.sampleIndex = this.multiSamplePass.render(this.sampleIndex, ctx, props, toDrawingBuffer, !!forceOn);
return this.sampleIndex < 0;
}
constructor(private multiSamplePass: MultiSamplePass) {

View File

@@ -10,9 +10,9 @@ import { MultiSamplePass } from './multi-sample';
import { WebGLContext } from '../../mol-gl/webgl/context';
export class Passes {
readonly draw: DrawPass
readonly pick: PickPass
readonly multiSample: MultiSamplePass
readonly draw: DrawPass;
readonly pick: PickPass;
readonly multiSample: MultiSamplePass;
constructor(private webgl: WebGLContext, attribs: Partial<{ pickScale: number, enableWboit: boolean }> = {}) {
const { gl } = webgl;

View File

@@ -5,14 +5,14 @@
*/
import { PickingId } from '../../mol-geo/geometry/picking';
import { Renderer } from '../../mol-gl/renderer';
import { PickType, Renderer } from '../../mol-gl/renderer';
import { Scene } from '../../mol-gl/scene';
import { WebGLContext } from '../../mol-gl/webgl/context';
import { GraphicsRenderVariant } from '../../mol-gl/webgl/render-item';
import { RenderTarget } from '../../mol-gl/webgl/render-target';
import { Vec3 } from '../../mol-math/linear-algebra';
import { spiral2d } from '../../mol-math/misc';
import { decodeFloatRGB, unpackRGBAToDepth } from '../../mol-util/float-packing';
import { unpackRGBToInt, unpackRGBAToDepth } from '../../mol-util/number-packing';
import { Camera, ICamera } from '../camera';
import { StereoCamera } from '../camera/stereo';
import { cameraUnproject } from '../camera/util';
@@ -25,13 +25,13 @@ const NullId = Math.pow(2, 24) - 2;
export type PickData = { id: PickingId, position: Vec3 }
export class PickPass {
readonly objectPickTarget: RenderTarget
readonly instancePickTarget: RenderTarget
readonly groupPickTarget: RenderTarget
readonly depthPickTarget: RenderTarget
readonly objectPickTarget: RenderTarget;
readonly instancePickTarget: RenderTarget;
readonly groupPickTarget: RenderTarget;
readonly depthPickTarget: RenderTarget;
private pickWidth: number
private pickHeight: number
private pickWidth: number;
private pickHeight: number;
constructor(private webgl: WebGLContext, private drawPass: DrawPass, readonly pickBaseScale: number) {
const pickScale = pickBaseScale / webgl.pixelRatio;
@@ -64,56 +64,56 @@ export class PickPass {
}
}
private renderVariant(renderer: Renderer, camera: ICamera, scene: Scene, helper: Helper, variant: GraphicsRenderVariant) {
private renderVariant(renderer: Renderer, camera: ICamera, scene: Scene, helper: Helper, variant: GraphicsRenderVariant, pickType: number) {
const depth = this.drawPass.depthTexturePrimitives;
renderer.clear(false);
renderer.update(camera);
renderer.renderPick(scene.primitives, camera, variant, null);
renderer.renderPick(scene.volumes, camera, variant, depth);
renderer.renderPick(helper.handle.scene, camera, variant, null);
renderer.renderPick(scene.primitives, camera, variant, null, pickType);
renderer.renderPick(scene.volumes, camera, variant, depth, pickType);
renderer.renderPick(helper.handle.scene, camera, variant, null, pickType);
if (helper.camera.isEnabled) {
helper.camera.update(camera);
renderer.update(helper.camera.camera);
renderer.renderPick(helper.camera.scene, helper.camera.camera, variant, null);
renderer.renderPick(helper.camera.scene, helper.camera.camera, variant, null, pickType);
}
}
render(renderer: Renderer, camera: ICamera, scene: Scene, helper: Helper) {
this.objectPickTarget.bind();
this.renderVariant(renderer, camera, scene, helper, 'pickObject');
this.renderVariant(renderer, camera, scene, helper, 'pick', PickType.Object);
this.instancePickTarget.bind();
this.renderVariant(renderer, camera, scene, helper, 'pickInstance');
this.renderVariant(renderer, camera, scene, helper, 'pick', PickType.Instance);
this.groupPickTarget.bind();
this.renderVariant(renderer, camera, scene, helper, 'pickGroup');
this.renderVariant(renderer, camera, scene, helper, 'pick', PickType.Group);
// printTexture(this.webgl, this.groupPickTarget.texture, { id: 'group' })
this.depthPickTarget.bind();
this.renderVariant(renderer, camera, scene, helper, 'depth');
this.renderVariant(renderer, camera, scene, helper, 'depth', PickType.None);
}
}
export class PickHelper {
dirty = true
dirty = true;
private objectBuffer: Uint8Array
private instanceBuffer: Uint8Array
private groupBuffer: Uint8Array
private depthBuffer: Uint8Array
private objectBuffer: Uint8Array;
private instanceBuffer: Uint8Array;
private groupBuffer: Uint8Array;
private depthBuffer: Uint8Array;
private viewport = Viewport()
private viewport = Viewport();
private pickScale: number
private pickX: number
private pickY: number
private pickWidth: number
private pickHeight: number
private halfPickWidth: number
private pickScale: number;
private pickX: number;
private pickY: number;
private pickWidth: number;
private pickHeight: number;
private halfPickWidth: number;
private spiral: [number, number][]
private spiral: [number, number][];
private setupBuffers() {
const bufferSize = this.pickWidth * this.pickHeight * 4;
@@ -174,7 +174,7 @@ export class PickHelper {
private getId(x: number, y: number, buffer: Uint8Array) {
const idx = this.getBufferIdx(x, y);
return decodeFloatRGB(buffer[idx], buffer[idx + 1], buffer[idx + 2]);
return unpackRGBToInt(buffer[idx], buffer[idx + 1], buffer[idx + 2]);
}
private render(camera: Camera | StereoCamera) {

View File

@@ -86,7 +86,7 @@ function getSsaoRenderable(ctx: WebGLContext, depthTexture: Texture): SsaoRender
tDepth: ValueCell.create(depthTexture),
uSamples: ValueCell.create([0.0, 0.0, 1.0]),
dNSamples: ValueCell.create(1),
dNSamples: ValueCell.create(32),
uProjection: ValueCell.create(Mat4.identity()),
uInvProjection: ValueCell.create(Mat4.identity()),
@@ -133,7 +133,7 @@ function getSsaoBlurRenderable(ctx: WebGLContext, ssaoDepthTexture: Texture, dir
uTexSize: ValueCell.create(Vec2.create(ssaoDepthTexture.getWidth(), ssaoDepthTexture.getHeight())),
uKernel: ValueCell.create([0.0]),
dOcclusionKernelSize: ValueCell.create(1),
dOcclusionKernelSize: ValueCell.create(15),
uBlurDirectionX: ValueCell.create(direction === 'horizontal' ? 1 : 0),
uBlurDirectionY: ValueCell.create(direction === 'vertical' ? 1 : 0),
@@ -193,6 +193,7 @@ const PostprocessingSchema = {
uFogNear: UniformSpec('f'),
uFogFar: UniformSpec('f'),
uFogColor: UniformSpec('v3'),
uOutlineColor: UniformSpec('v3'),
uTransparentBackground: UniformSpec('b'),
uMaxPossibleViewZDiff: UniformSpec('f'),
@@ -220,11 +221,12 @@ function getPostprocessingRenderable(ctx: WebGLContext, colorTexture: Texture, d
uFogNear: ValueCell.create(10000),
uFogFar: ValueCell.create(10000),
uFogColor: ValueCell.create(Vec3.create(1, 1, 1)),
uOutlineColor: ValueCell.create(Vec3.create(0, 0, 0)),
uTransparentBackground: ValueCell.create(false),
uMaxPossibleViewZDiff: ValueCell.create(0.5),
dOcclusionEnable: ValueCell.create(false),
dOcclusionEnable: ValueCell.create(true),
dOutlineEnable: ValueCell.create(false),
dOutlineScale: ValueCell.create(1),
@@ -252,6 +254,7 @@ export const PostprocessingParams = {
on: PD.Group({
scale: PD.Numeric(1, { min: 1, max: 5, step: 1 }),
threshold: PD.Numeric(0.33, { min: 0.01, max: 1, step: 0.01 }),
color: PD.Color(Color(0x000000)),
}),
off: PD.Group({})
}, { cycle: true, description: 'Draw outline around 3D objects' }),
@@ -268,29 +271,29 @@ export class PostprocessingPass {
return props.occlusion.name === 'on' || props.outline.name === 'on';
}
readonly target: RenderTarget
readonly target: RenderTarget;
private readonly outlinesTarget: RenderTarget
private readonly outlinesRenderable: OutlinesRenderable
private readonly outlinesTarget: RenderTarget;
private readonly outlinesRenderable: OutlinesRenderable;
private readonly randomHemisphereVector: Vec3[]
private readonly ssaoFramebuffer: Framebuffer
private readonly ssaoBlurFirstPassFramebuffer: Framebuffer
private readonly ssaoBlurSecondPassFramebuffer: Framebuffer
private readonly randomHemisphereVector: Vec3[];
private readonly ssaoFramebuffer: Framebuffer;
private readonly ssaoBlurFirstPassFramebuffer: Framebuffer;
private readonly ssaoBlurSecondPassFramebuffer: Framebuffer;
private readonly ssaoDepthTexture: Texture
private readonly ssaoDepthBlurProxyTexture: Texture
private readonly ssaoDepthTexture: Texture;
private readonly ssaoDepthBlurProxyTexture: Texture;
private readonly ssaoRenderable: SsaoRenderable
private readonly ssaoBlurFirstPassRenderable: SsaoBlurRenderable
private readonly ssaoBlurSecondPassRenderable: SsaoBlurRenderable
private readonly ssaoRenderable: SsaoRenderable;
private readonly ssaoBlurFirstPassRenderable: SsaoBlurRenderable;
private readonly ssaoBlurSecondPassRenderable: SsaoBlurRenderable;
private nSamples: number
private blurKernelSize: number
private nSamples: number;
private blurKernelSize: number;
private readonly renderable: PostprocessingRenderable
private readonly renderable: PostprocessingRenderable;
private ssaoScale: number
private ssaoScale: number;
private calcSsaoScale() {
// downscale ssao for high pixel-ratios
return Math.min(1, 1 / this.webgl.pixelRatio);
@@ -446,6 +449,8 @@ export class PostprocessingPass {
ValueCell.updateIfChanged(this.outlinesRenderable.values.uFar, camera.far);
ValueCell.updateIfChanged(this.outlinesRenderable.values.uMaxPossibleViewZDiff, maxPossibleViewZDiff);
ValueCell.update(this.renderable.values.uOutlineColor, Color.toVec3Normalized(this.renderable.values.uOutlineColor.ref.value, props.outline.params.color));
ValueCell.updateIfChanged(this.renderable.values.uMaxPossibleViewZDiff, maxPossibleViewZDiff);
if (this.renderable.values.dOutlineScale.ref.value !== outlineScale) { needsUpdateMain = true; }
ValueCell.updateIfChanged(this.renderable.values.dOutlineScale, outlineScale);
@@ -538,9 +543,9 @@ export class AntialiasingPass {
return props.antialiasing.name !== 'off';
}
readonly target: RenderTarget
private readonly fxaa: FxaaPass
private readonly smaa: SmaaPass
readonly target: RenderTarget;
private readonly fxaa: FxaaPass;
private readonly smaa: SmaaPass;
constructor(webgl: WebGLContext, private drawPass: DrawPass) {
const { colorTarget } = drawPass;

View File

@@ -31,12 +31,12 @@ export const SmaaParams = {
export type SmaaProps = PD.Values<typeof SmaaParams>
export class SmaaPass {
private readonly edgesTarget: RenderTarget
private readonly weightsTarget: RenderTarget
private readonly edgesTarget: RenderTarget;
private readonly weightsTarget: RenderTarget;
private readonly edgesRenderable: EdgesRenderable
private readonly weightsRenderable: WeightsRenderable
private readonly blendRenderable: BlendRenderable
private readonly edgesRenderable: EdgesRenderable;
private readonly weightsRenderable: WeightsRenderable;
private readonly blendRenderable: BlendRenderable;
private _supported = false;
get supported() {
@@ -201,7 +201,7 @@ function getWeightsRenderable(ctx: WebGLContext, edgesTexture: Texture): Weights
uTexSizeInv: ValueCell.create(Vec2.create(1 / width, 1 / height)),
uViewport: ValueCell.create(Vec4()),
dMaxSearchSteps: ValueCell.create(8),
dMaxSearchSteps: ValueCell.create(16),
};
// Note: loading image textures requires `HTMLImageElement` to be available

View File

@@ -45,11 +45,11 @@ function getEvaluateWboitRenderable(ctx: WebGLContext, wboitATexture: Texture, w
//
export class WboitPass {
private readonly renderable: EvaluateWboitRenderable
private readonly renderable: EvaluateWboitRenderable;
private readonly framebuffer: Framebuffer
private readonly textureA: Texture
private readonly textureB: Texture
private readonly framebuffer: Framebuffer;
private readonly textureA: Texture;
private readonly textureB: Texture;
private _supported = false;
get supported() {

View File

@@ -87,9 +87,9 @@ namespace SortedRanges {
}
export class Iterator<T extends number = number, I extends number = number> implements _Iterator<Segmentation.Segment<I>> {
private value: Segmentation.Segment<I> = { index: 0 as I, start: 0 as T, end: 0 as T }
private value: Segmentation.Segment<I> = { index: 0 as I, start: 0 as T, end: 0 as T };
private curIndex = 0
private curIndex = 0;
hasNext: boolean = false;

View File

@@ -28,11 +28,11 @@ function nextIndex(n: number) {
};
export class CombinationIterator<T> implements Iterator<ReadonlyArray<T>> {
private value: T[]
private index: number
private maxIndex: number
private value: T[];
private index: number;
private maxIndex: number;
size: number
size: number;
hasNext: boolean = false;
move() {

View File

@@ -9,10 +9,10 @@ import { OrderedSet, Interval, Segmentation } from '../int';
/** Emits a segment of length one for each element in the interval that is also in the set */
export class IntervalIterator<I extends number = number> implements Iterator<Segmentation.Segment<I>> {
private value: Segmentation.Segment<I> = { index: 0 as I, start: 0, end: 0 }
private value: Segmentation.Segment<I> = { index: 0 as I, start: 0, end: 0 };
private curIndex = 0
private maxIndex = 0
private curIndex = 0;
private maxIndex = 0;
hasNext: boolean = false;

View File

@@ -0,0 +1,16 @@
/**
* Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { getMarkersAverage } from '../marker-data';
describe('marker-data', () => {
it('getMarkersAverage', () => {
expect(getMarkersAverage(new Uint8Array([0, 0, 0, 0]), 3)).toBe(0);
expect(getMarkersAverage(new Uint8Array([0, 0, 1, 0]), 3)).toBe(1 / 3);
expect(getMarkersAverage(new Uint8Array([0, 0, 0, 0]), 4)).toBe(0);
expect(getMarkersAverage(new Uint8Array([0, 0, 1, 0]), 4)).toBe(1 / 4);
});
});

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -15,6 +15,9 @@ import { ColorNames } from '../../mol-util/color/names';
import { NullLocation } from '../../mol-model/location';
import { UniformColorTheme } from '../../mol-theme/color/uniform';
import { UniformSizeTheme } from '../../mol-theme/size/uniform';
import { smoothstep } from '../../mol-math/interpolate';
import { Material } from '../../mol-util/material';
import { Clip } from '../../mol-util/clip';
export const VisualQualityInfo = {
'custom': {},
@@ -33,19 +36,56 @@ export const VisualQualityOptions = PD.arrayToOptions(VisualQualityNames);
//
export namespace BaseGeometry {
export const Params = {
alpha: PD.Numeric(1, { min: 0, max: 1, step: 0.01 }, { label: 'Opacity', isEssential: true, description: 'How opaque/transparent the representation is rendered.' }),
quality: PD.Select<VisualQuality>('auto', VisualQualityOptions, { isEssential: true, description: 'Visual/rendering quality of the representation.' }),
};
export type Params = typeof Params
export const ColorSmoothingParams = {
smoothColors: PD.MappedStatic('auto', {
auto: PD.Group({}),
on: PD.Group({
resolutionFactor: PD.Numeric(2, { min: 0.5, max: 6, step: 0.1 }),
sampleStride: PD.Numeric(3, { min: 1, max: 12, step: 1 }),
}),
off: PD.Group({})
}),
};
export type ColorSmoothingParams = typeof ColorSmoothingParams
export function hasColorSmoothingProp(props: PD.Values<any>): props is PD.Values<ColorSmoothingParams> {
return !!props.smoothColors;
}
export function getColorSmoothingProps(smoothColors: PD.Values<ColorSmoothingParams>['smoothColors'], preferSmoothing?: boolean, resolution?: number) {
if ((smoothColors.name === 'on' || (smoothColors.name === 'auto' && preferSmoothing)) && resolution && resolution < 3) {
let stride = 3;
if (smoothColors.name === 'on') {
resolution *= smoothColors.params.resolutionFactor;
stride = smoothColors.params.sampleStride;
} else {
// https://graphtoy.com/?f1(x,t)=(2-smoothstep(0,1.1,x))*x&coords=0.7,0.6,1.8
resolution *= 2 - smoothstep(0, 1.1, resolution);
resolution = Math.max(0.5, resolution);
if (resolution > 1.2) stride = 2;
}
return { resolution, stride };
};
}
//
export namespace BaseGeometry {
export const MaterialCategory: PD.Info = { category: 'Material' };
export const ShadingCategory: PD.Info = { category: 'Shading' };
export const CustomQualityParamInfo: PD.Info = {
category: 'Custom Quality',
hideIf: (params: PD.Values<Params>) => typeof params.quality !== 'undefined' && params.quality !== 'custom'
};
export const Params = {
alpha: PD.Numeric(1, { min: 0, max: 1, step: 0.01 }, { label: 'Opacity', isEssential: true, description: 'How opaque/transparent the representation is rendered.' }),
quality: PD.Select<VisualQuality>('auto', VisualQualityOptions, { isEssential: true, description: 'Visual/rendering quality of the representation.' }),
material: Material.getParam(),
clip: PD.Group(Clip.Params),
};
export type Params = typeof Params
export type Counts = { drawCount: number, vertexCount: number, groupCount: number, instanceCount: number }
export function createSimple(colorValue = ColorNames.grey, sizeValue = 1, transform?: TransformData) {
@@ -59,17 +99,42 @@ export namespace BaseGeometry {
}
export function createValues(props: PD.Values<Params>, counts: Counts) {
const clip = Clip.getClip(props.clip);
return {
alpha: ValueCell.create(props.alpha),
uAlpha: ValueCell.create(props.alpha),
uVertexCount: ValueCell.create(counts.vertexCount),
uGroupCount: ValueCell.create(counts.groupCount),
drawCount: ValueCell.create(counts.drawCount),
uMetalness: ValueCell.create(props.material.metalness),
uRoughness: ValueCell.create(props.material.roughness),
uBumpiness: ValueCell.create(props.material.bumpiness),
dLightCount: ValueCell.create(1),
dClipObjectCount: ValueCell.create(clip.objects.count),
dClipVariant: ValueCell.create(clip.variant),
uClipObjectType: ValueCell.create(clip.objects.type),
uClipObjectInvert: ValueCell.create(clip.objects.invert),
uClipObjectPosition: ValueCell.create(clip.objects.position),
uClipObjectRotation: ValueCell.create(clip.objects.rotation),
uClipObjectScale: ValueCell.create(clip.objects.scale),
};
}
export function updateValues(values: BaseValues, props: PD.Values<Params>) {
ValueCell.updateIfChanged(values.alpha, props.alpha); // `uAlpha` is set in renderable.render
ValueCell.updateIfChanged(values.uMetalness, props.material.metalness);
ValueCell.updateIfChanged(values.uRoughness, props.material.roughness);
ValueCell.updateIfChanged(values.uBumpiness, props.material.bumpiness);
const clip = Clip.getClip(props.clip);
ValueCell.update(values.dClipObjectCount, clip.objects.count);
ValueCell.update(values.dClipVariant, clip.variant);
ValueCell.update(values.uClipObjectType, clip.objects.type);
ValueCell.update(values.uClipObjectInvert, clip.objects.invert);
ValueCell.update(values.uClipObjectPosition, clip.objects.position);
ValueCell.update(values.uClipObjectRotation, clip.objects.rotation);
ValueCell.update(values.uClipObjectScale, clip.objects.scale);
}
export function createRenderableState(props: Partial<PD.Values<Params>> = {}): RenderableState {
@@ -82,7 +147,6 @@ export namespace BaseGeometry {
colorOnly: false,
opaque,
writeDepth: opaque,
noClip: false,
};
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2020-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -10,18 +10,13 @@ import { TextureImage, createTextureImage } from '../../mol-gl/renderable/util';
import { Clipping } from '../../mol-theme/clipping';
export type ClippingData = {
dClipObjectCount: ValueCell<number>,
dClipVariant: ValueCell<string>,
tClipping: ValueCell<TextureImage<Uint8Array>>
uClippingTexDim: ValueCell<Vec2>
dClipping: ValueCell<boolean>,
}
export function applyClippingGroups(array: Uint8Array, start: number, end: number, groups: Clipping.Groups) {
for (let i = start; i < end; ++i) {
array[i] = groups;
}
array.fill(groups, start, end);
return true;
}
@@ -38,9 +33,6 @@ export function createClipping(count: number, clippingData?: ClippingData): Clip
return clippingData;
} else {
return {
dClipObjectCount: ValueCell.create(0),
dClipVariant: ValueCell.create('instance'),
tClipping: ValueCell.create(clipping),
uClippingTexDim: ValueCell.create(Vec2.create(clipping.width, clipping.height)),
dClipping: ValueCell.create(count > 0),
@@ -53,12 +45,10 @@ export function createEmptyClipping(clippingData?: ClippingData): ClippingData {
if (clippingData) {
ValueCell.update(clippingData.tClipping, emptyClippingTexture);
ValueCell.update(clippingData.uClippingTexDim, Vec2.create(1, 1));
ValueCell.updateIfChanged(clippingData.dClipping, false);
return clippingData;
} else {
return {
dClipObjectCount: ValueCell.create(0),
dClipVariant: ValueCell.create('instance'),
tClipping: ValueCell.create(emptyClippingTexture),
uClippingTexDim: ValueCell.create(Vec2.create(1, 1)),
dClipping: ValueCell.create(false),

View File

@@ -15,7 +15,7 @@ import { LocationColor, ColorTheme } from '../../mol-theme/color';
import { Geometry } from './geometry';
import { createNullTexture, Texture } from '../../mol-gl/webgl/texture';
export type ColorType = 'uniform' | 'instance' | 'group' | 'groupInstance' | 'vertex' | 'vertexInstance' | 'volume' | 'volumeInstance'
export type ColorType = 'uniform' | 'instance' | 'group' | 'groupInstance' | 'vertex' | 'vertexInstance' | 'volume' | 'volumeInstance' | 'direct'
export type ColorData = {
uColor: ValueCell<Vec3>,
@@ -50,6 +50,7 @@ function _createColors(locationIt: LocationIterator, positionIt: LocationIterato
case 'vertexInstance': return createVertexInstanceColor(positionIt, colorTheme.color, colorData);
case 'volume': return createGridColor((colorTheme as any).grid, 'volume', colorData);
case 'volumeInstance': return createGridColor((colorTheme as any).grid, 'volumeInstance', colorData);
case 'direct': return createDirectColor(colorData);
}
}
@@ -237,3 +238,25 @@ export function createGridColor(grid: ColorVolume, type: ColorType, colorData?:
};
}
}
//
/** Creates direct color */
function createDirectColor(colorData?: ColorData): ColorData {
if (colorData) {
ValueCell.updateIfChanged(colorData.dColorType, 'direct');
return colorData;
} else {
return {
uColor: ValueCell.create(Vec3()),
tColor: ValueCell.create({ array: new Uint8Array(3), width: 1, height: 1 }),
tColorGrid: ValueCell.create(createNullTexture()),
tPalette: ValueCell.create({ array: new Uint8Array(3), width: 1, height: 1 }),
uColorTexDim: ValueCell.create(Vec2.create(1, 1)),
uColorGridDim: ValueCell.create(Vec3.create(1, 1, 1)),
uColorGridTransform: ValueCell.create(Vec4.create(0, 0, 0, 1)),
dColorType: ValueCell.create('direct'),
dUsePalette: ValueCell.create(false),
};
}
}

View File

@@ -25,6 +25,7 @@ import { hashFnv32a } from '../../../mol-data/util';
import { createEmptyClipping } from '../clipping-data';
import { CylindersValues } from '../../../mol-gl/renderable/cylinders';
import { RenderableState } from '../../../mol-gl/renderable';
import { createEmptySubstance } from '../substance-data';
export interface Cylinders {
readonly kind: 'cylinders',
@@ -156,6 +157,8 @@ export namespace Cylinders {
doubleSided: PD.Boolean(false, BaseGeometry.CustomQualityParamInfo),
ignoreLight: PD.Boolean(false, BaseGeometry.ShadingCategory),
xrayShaded: PD.Boolean(false, BaseGeometry.ShadingCategory),
bumpFrequency: PD.Numeric(0, { min: 0, max: 10, step: 0.1 }, BaseGeometry.ShadingCategory),
bumpAmplitude: PD.Numeric(1, { min: 0, max: 5, step: 0.1 }, BaseGeometry.ShadingCategory),
};
export type Params = typeof Params
@@ -200,6 +203,7 @@ export namespace Cylinders {
const marker = createMarkers(instanceCount * groupCount);
const overpaint = createEmptyOverpaint();
const transparency = createEmptyTransparency();
const material = createEmptySubstance();
const clipping = createEmptyClipping();
const counts = { drawCount: cylinders.cylinderCount * 4 * 3, vertexCount: cylinders.cylinderCount * 6, groupCount, instanceCount };
@@ -209,6 +213,8 @@ export namespace Cylinders {
const boundingSphere = calculateTransformBoundingSphere(invariantBoundingSphere, transform.aTransform.ref.value, instanceCount);
return {
dGeometryType: ValueCell.create('cylinders'),
aMapping: cylinders.mappingBuffer,
aGroup: cylinders.groupBuffer,
aStart: cylinders.startBuffer,
@@ -224,6 +230,7 @@ export namespace Cylinders {
...marker,
...overpaint,
...transparency,
...material,
...clipping,
...transform,
@@ -231,9 +238,11 @@ export namespace Cylinders {
...BaseGeometry.createValues(props, counts),
uSizeFactor: ValueCell.create(props.sizeFactor * props.sizeAspectRatio),
dDoubleSided: ValueCell.create(props.doubleSided),
uDoubleSided: ValueCell.create(props.doubleSided),
dIgnoreLight: ValueCell.create(props.ignoreLight),
dXrayShaded: ValueCell.create(props.xrayShaded),
uBumpFrequency: ValueCell.create(props.bumpFrequency),
uBumpAmplitude: ValueCell.create(props.bumpAmplitude),
};
}
@@ -246,9 +255,11 @@ export namespace Cylinders {
function updateValues(values: CylindersValues, props: PD.Values<Params>) {
BaseGeometry.updateValues(values, props);
ValueCell.updateIfChanged(values.uSizeFactor, props.sizeFactor * props.sizeAspectRatio);
ValueCell.updateIfChanged(values.dDoubleSided, props.doubleSided);
ValueCell.updateIfChanged(values.uDoubleSided, props.doubleSided);
ValueCell.updateIfChanged(values.dIgnoreLight, props.ignoreLight);
ValueCell.updateIfChanged(values.dXrayShaded, props.xrayShaded);
ValueCell.updateIfChanged(values.uBumpFrequency, props.bumpFrequency);
ValueCell.updateIfChanged(values.uBumpAmplitude, props.bumpAmplitude);
}
function updateBoundingSphere(values: CylindersValues, cylinders: Cylinders) {

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
@@ -26,8 +26,8 @@ import { TransformData } from '../transform-data';
import { createEmptyTransparency } from '../transparency-data';
import { createTransferFunctionTexture, getControlPointsFromVec2Array } from './transfer-function';
import { createEmptyClipping } from '../clipping-data';
import { Grid, Volume } from '../../../mol-model/volume';
import { ColorNames } from '../../../mol-util/color/names';
import { Grid } from '../../../mol-model/volume';
import { createEmptySubstance } from '../substance-data';
const VolumeBox = Box();
@@ -47,6 +47,7 @@ export interface DirectVolume {
readonly unitToCartn: ValueCell<Mat4>
readonly cartnToUnit: ValueCell<Mat4>
readonly packedGroup: ValueCell<boolean>
readonly axisOrder: ValueCell<Vec3>
/** Bounding sphere of the volume */
readonly boundingSphere: Sphere3D
@@ -55,10 +56,10 @@ export interface DirectVolume {
}
export namespace DirectVolume {
export function create(bbox: Box3D, gridDimension: Vec3, transform: Mat4, unitToCartn: Mat4, cellDim: Vec3, texture: Texture, stats: Grid['stats'], packedGroup: boolean, directVolume?: DirectVolume): DirectVolume {
export function create(bbox: Box3D, gridDimension: Vec3, transform: Mat4, unitToCartn: Mat4, cellDim: Vec3, texture: Texture, stats: Grid['stats'], packedGroup: boolean, axisOrder: Vec3, directVolume?: DirectVolume): DirectVolume {
return directVolume ?
update(bbox, gridDimension, transform, unitToCartn, cellDim, texture, stats, packedGroup, directVolume) :
fromData(bbox, gridDimension, transform, unitToCartn, cellDim, texture, stats, packedGroup);
update(bbox, gridDimension, transform, unitToCartn, cellDim, texture, stats, packedGroup, axisOrder, directVolume) :
fromData(bbox, gridDimension, transform, unitToCartn, cellDim, texture, stats, packedGroup, axisOrder);
}
function hashCode(directVolume: DirectVolume) {
@@ -69,7 +70,7 @@ export namespace DirectVolume {
]);
}
function fromData(bbox: Box3D, gridDimension: Vec3, transform: Mat4, unitToCartn: Mat4, cellDim: Vec3, texture: Texture, stats: Grid['stats'], packedGroup: boolean): DirectVolume {
function fromData(bbox: Box3D, gridDimension: Vec3, transform: Mat4, unitToCartn: Mat4, cellDim: Vec3, texture: Texture, stats: Grid['stats'], packedGroup: boolean, axisOrder: Vec3): DirectVolume {
const boundingSphere = Sphere3D();
let currentHash = -1;
@@ -100,6 +101,7 @@ export namespace DirectVolume {
return boundingSphere;
},
packedGroup: ValueCell.create(packedGroup),
axisOrder: ValueCell.create(axisOrder),
setBoundingSphere(sphere: Sphere3D) {
Sphere3D.copy(boundingSphere, sphere);
currentHash = hashCode(directVolume);
@@ -108,7 +110,7 @@ export namespace DirectVolume {
return directVolume;
}
function update(bbox: Box3D, gridDimension: Vec3, transform: Mat4, unitToCartn: Mat4, cellDim: Vec3, texture: Texture, stats: Grid['stats'], packedGroup: boolean, directVolume: DirectVolume): DirectVolume {
function update(bbox: Box3D, gridDimension: Vec3, transform: Mat4, unitToCartn: Mat4, cellDim: Vec3, texture: Texture, stats: Grid['stats'], packedGroup: boolean, axisOrder: Vec3, directVolume: DirectVolume): DirectVolume {
const width = texture.getWidth();
const height = texture.getHeight();
const depth = texture.getDepth();
@@ -125,6 +127,7 @@ export namespace DirectVolume {
ValueCell.update(directVolume.unitToCartn, unitToCartn);
ValueCell.update(directVolume.cartnToUnit, Mat4.invert(Mat4(), unitToCartn));
ValueCell.updateIfChanged(directVolume.packedGroup, packedGroup);
ValueCell.updateIfChanged(directVolume.axisOrder, Vec3.fromArray(directVolume.axisOrder.ref.value, axisOrder, 0));
return directVolume;
}
@@ -137,47 +140,19 @@ export namespace DirectVolume {
const texture = createNullTexture();
const stats = Grid.One.stats;
const packedGroup = false;
return create(bbox, gridDimension, transform, unitToCartn, cellDim, texture, stats, packedGroup, directVolume);
}
export function createRenderModeParam(stats?: Grid['stats']) {
const isoValueParam = stats
? Volume.createIsoValueParam(Volume.IsoValue.relative(2), stats)
: Volume.IsoValueParam;
return PD.MappedStatic('volume', {
isosurface: PD.Group({
isoValue: isoValueParam,
singleLayer: PD.Boolean(false, { isEssential: true }),
}, { isFlat: true }),
volume: PD.Group({
controlPoints: PD.LineGraph([
Vec2.create(0.19, 0.0), Vec2.create(0.2, 0.05), Vec2.create(0.25, 0.05), Vec2.create(0.26, 0.0),
Vec2.create(0.79, 0.0), Vec2.create(0.8, 0.05), Vec2.create(0.85, 0.05), Vec2.create(0.86, 0.0),
]),
list: PD.ColorList({
kind: 'interpolate',
colors: [
[ColorNames.white, 0],
[ColorNames.red, 0.25],
[ColorNames.white, 0.5],
[ColorNames.blue, 0.75],
[ColorNames.white, 1]
]
}, { offsets: true }),
}, { isFlat: true })
}, { isEssential: true });
const axisOrder = Vec3.create(0, 1, 2);
return create(bbox, gridDimension, transform, unitToCartn, cellDim, texture, stats, packedGroup, axisOrder, directVolume);
}
export const Params = {
...BaseGeometry.Params,
doubleSided: PD.Boolean(false, BaseGeometry.CustomQualityParamInfo),
flipSided: PD.Boolean(false, BaseGeometry.ShadingCategory),
flatShaded: PD.Boolean(false, BaseGeometry.ShadingCategory),
ignoreLight: PD.Boolean(false, BaseGeometry.ShadingCategory),
xrayShaded: PD.Boolean(false, BaseGeometry.ShadingCategory),
renderMode: createRenderModeParam(),
stepsPerCell: PD.Numeric(5, { min: 1, max: 20, step: 1 }),
controlPoints: PD.LineGraph([
Vec2.create(0.19, 0.0), Vec2.create(0.2, 0.05), Vec2.create(0.25, 0.05), Vec2.create(0.26, 0.0),
Vec2.create(0.79, 0.0), Vec2.create(0.8, 0.05), Vec2.create(0.85, 0.05), Vec2.create(0.86, 0.0),
], { isEssential: true }),
stepsPerCell: PD.Numeric(3, { min: 1, max: 10, step: 1 }),
jumpLength: PD.Numeric(0, { min: 0, max: 20, step: 0.1 }),
};
export type Params = typeof Params
@@ -216,13 +191,6 @@ export namespace DirectVolume {
return LocationIterator(groupCount, instanceCount, 1, getLocation);
}
function getNormalizedIsoValue(out: Vec2, isoValue: Volume.IsoValue, stats: Vec4) {
const [min, max, mean, sigma] = stats;
const value = Volume.IsoValue.toAbsolute(isoValue, { min, max, mean, sigma }).absoluteValue;
Vec2.set(out, (value - min) / (max - min), (0 - min) / (max - min));
return out;
}
function getMaxSteps(gridDim: Vec3, stepsPerCell: number) {
return Math.ceil(Vec3.magnitude(gridDim) * stepsPerCell);
}
@@ -246,6 +214,7 @@ export namespace DirectVolume {
const marker = createMarkers(instanceCount * groupCount);
const overpaint = createEmptyOverpaint();
const transparency = createEmptyTransparency();
const material = createEmptySubstance();
const clipping = createEmptyClipping();
const [x, y, z] = gridDimension.ref.value;
@@ -254,22 +223,17 @@ export namespace DirectVolume {
const invariantBoundingSphere = Sphere3D.clone(directVolume.boundingSphere);
const boundingSphere = calculateTransformBoundingSphere(invariantBoundingSphere, transform.aTransform.ref.value, instanceCount);
const controlPoints = props.renderMode.name === 'volume' ? getControlPointsFromVec2Array(props.renderMode.params.controlPoints) : [];
const transferTex = createTransferFunctionTexture(controlPoints, props.renderMode.name === 'volume' ? props.renderMode.params.list.colors : []);
const isoValue = props.renderMode.name === 'isosurface'
? props.renderMode.params.isoValue
: Volume.IsoValue.relative(2);
const singleLayer = props.renderMode.name === 'isosurface'
? props.renderMode.params.singleLayer
: false;
const controlPoints = getControlPointsFromVec2Array(props.controlPoints);
const transferTex = createTransferFunctionTexture(controlPoints);
return {
dGeometryType: ValueCell.create('directVolume'),
...color,
...marker,
...overpaint,
...transparency,
...material,
...clipping,
...transform,
...BaseGeometry.createValues(props, counts),
@@ -280,7 +244,6 @@ export namespace DirectVolume {
invariantBoundingSphere: ValueCell.create(invariantBoundingSphere),
uInvariantBoundingSphere: ValueCell.create(Vec4.ofSphere(invariantBoundingSphere)),
uIsoValue: ValueCell.create(getNormalizedIsoValue(Vec2(), isoValue, directVolume.gridStats.ref.value)),
uBboxMin: bboxMin,
uBboxMax: bboxMax,
uBboxSize: bboxSize,
@@ -289,7 +252,6 @@ export namespace DirectVolume {
uJumpLength: ValueCell.create(props.jumpLength),
uTransform: gridTransform,
uGridDim: gridDimension,
dRenderMode: ValueCell.create(props.renderMode.name),
tTransferTex: transferTex,
uTransferScale: ValueCell.create(getTransferScale(props.stepsPerCell)),
@@ -302,11 +264,8 @@ export namespace DirectVolume {
uCartnToUnit: directVolume.cartnToUnit,
uUnitToCartn: directVolume.unitToCartn,
dPackedGroup: directVolume.packedGroup,
dSingleLayer: ValueCell.create(singleLayer),
dAxisOrder: ValueCell.create(directVolume.axisOrder.ref.value.join('')),
dDoubleSided: ValueCell.create(props.doubleSided),
dFlatShaded: ValueCell.create(props.flatShaded),
dFlipSided: ValueCell.create(props.flipSided),
dIgnoreLight: ValueCell.create(props.ignoreLight),
dXrayShaded: ValueCell.create(props.xrayShaded),
};
@@ -319,22 +278,12 @@ export namespace DirectVolume {
}
function updateValues(values: DirectVolumeValues, props: PD.Values<Params>) {
ValueCell.updateIfChanged(values.alpha, props.alpha);
ValueCell.updateIfChanged(values.uAlpha, props.alpha);
ValueCell.updateIfChanged(values.dDoubleSided, props.doubleSided);
ValueCell.updateIfChanged(values.dFlatShaded, props.flatShaded);
ValueCell.updateIfChanged(values.dFlipSided, props.flipSided);
BaseGeometry.updateValues(values, props);
ValueCell.updateIfChanged(values.dIgnoreLight, props.ignoreLight);
ValueCell.updateIfChanged(values.dXrayShaded, props.xrayShaded);
ValueCell.updateIfChanged(values.dRenderMode, props.renderMode.name);
if (props.renderMode.name === 'isosurface') {
ValueCell.updateIfChanged(values.uIsoValue, getNormalizedIsoValue(values.uIsoValue.ref.value, props.renderMode.params.isoValue, values.uGridStats.ref.value));
ValueCell.updateIfChanged(values.dSingleLayer, props.renderMode.params.singleLayer);
} else if (props.renderMode.name === 'volume') {
const controlPoints = getControlPointsFromVec2Array(props.renderMode.params.controlPoints);
createTransferFunctionTexture(controlPoints, props.renderMode.params.list.colors, values.tTransferTex);
}
const controlPoints = getControlPointsFromVec2Array(props.controlPoints);
createTransferFunctionTexture(controlPoints, values.tTransferTex);
ValueCell.updateIfChanged(values.uMaxSteps, getMaxSteps(values.uGridDim.ref.value, props.stepsPerCell));
ValueCell.updateIfChanged(values.uStepScale, getStepScale(values.uCellDim.ref.value, props.stepsPerCell));
@@ -358,14 +307,14 @@ export namespace DirectVolume {
function createRenderableState(props: PD.Values<Params>): RenderableState {
const state = BaseGeometry.createRenderableState(props);
state.opaque = false;
state.writeDepth = props.renderMode.name === 'isosurface';
state.writeDepth = false;
return state;
}
function updateRenderableState(state: RenderableState, props: PD.Values<Params>) {
BaseGeometry.updateRenderableState(state, props);
state.opaque = false;
state.writeDepth = props.renderMode.name === 'isosurface';
state.writeDepth = false;
}
}

View File

@@ -1,16 +1,13 @@
/**
* Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { TextureImage } from '../../../mol-gl/renderable/util';
import { spline } from '../../../mol-math/interpolate';
import { ColorScale } from '../../../mol-util/color';
import { ValueCell } from '../../../mol-util';
import { Vec2 } from '../../../mol-math/linear-algebra';
import { ColorListName } from '../../../mol-util/color/lists';
import { ColorListEntry } from '../../../mol-util/color/color';
export interface ControlPoint { x: number, alpha: number }
@@ -25,7 +22,7 @@ export function getControlPointsFromVec2Array(array: Vec2[]): ControlPoint[] {
return array.map(v => ({ x: v[0], alpha: v[1] }));
}
export function createTransferFunctionTexture(controlPoints: ControlPoint[], listOrName: ColorListEntry[] | ColorListName, texture?: ValueCell<TextureImage<Uint8Array>>): ValueCell<TextureImage<Uint8Array>> {
export function createTransferFunctionTexture(controlPoints: ControlPoint[], texture?: ValueCell<TextureImage<Uint8Array>>): ValueCell<TextureImage<Uint8Array>> {
const cp = [
{ x: 0, alpha: 0 },
{ x: 0, alpha: 0 },
@@ -33,10 +30,9 @@ export function createTransferFunctionTexture(controlPoints: ControlPoint[], lis
{ x: 1, alpha: 0 },
{ x: 1, alpha: 0 },
];
const scale = ColorScale.create({ domain: [0, 1], listOrName });
const n = 256;
const array = texture ? texture.ref.value.array : new Uint8Array(n * 4);
const array = texture ? texture.ref.value.array : new Uint8Array(n);
let k = 0;
let x1: number, x2: number;
@@ -55,8 +51,7 @@ export function createTransferFunctionTexture(controlPoints: ControlPoint[], lis
const jl = Math.round((x2 - x1) * n);
for (let j = 0; j < jl; ++j) {
const t = j / jl;
array[k * 4 + 3] = Math.max(0, spline(a0, a1, a2, a3, t, 0.5) * 255);
scale.colorToArray(k / 255, array, k * 4);
array[k] = Math.max(0, spline(a0, a1, a2, a3, t, 0.5) * 255);
++k;
}
}

View File

@@ -26,6 +26,7 @@ import { fillSerial } from '../../../mol-util/array';
import { createEmptyClipping } from '../clipping-data';
import { NullLocation } from '../../../mol-model/location';
import { QuadPositions } from '../../../mol-gl/compute/util';
import { createEmptySubstance } from '../substance-data';
const QuadIndices = new Uint32Array([
0, 1, 2,
@@ -145,6 +146,7 @@ namespace Image {
const marker = createMarkers(instanceCount * groupCount);
const overpaint = createEmptyOverpaint();
const transparency = createEmptyTransparency();
const material = createEmptySubstance();
const clipping = createEmptyClipping();
const counts = { drawCount: QuadIndices.length, vertexCount: QuadPositions.length / 3, groupCount, instanceCount };
@@ -153,10 +155,13 @@ namespace Image {
const boundingSphere = calculateTransformBoundingSphere(invariantBoundingSphere, transform.aTransform.ref.value, instanceCount);
return {
dGeometryType: ValueCell.create('image'),
...color,
...marker,
...overpaint,
...transparency,
...material,
...clipping,
...transform,
...BaseGeometry.createValues(props, counts),

View File

@@ -26,6 +26,7 @@ import { createEmptyOverpaint } from '../overpaint-data';
import { createEmptyTransparency } from '../transparency-data';
import { hashFnv32a } from '../../../mol-data/util';
import { createEmptyClipping } from '../clipping-data';
import { createEmptySubstance } from '../substance-data';
/** Wide line */
export interface Lines {
@@ -210,6 +211,7 @@ export namespace Lines {
const marker = createMarkers(instanceCount * groupCount);
const overpaint = createEmptyOverpaint();
const transparency = createEmptyTransparency();
const material = createEmptySubstance();
const clipping = createEmptyClipping();
const counts = { drawCount: lines.lineCount * 2 * 3, vertexCount: lines.lineCount * 4, groupCount, instanceCount };
@@ -218,6 +220,8 @@ export namespace Lines {
const boundingSphere = calculateTransformBoundingSphere(invariantBoundingSphere, transform.aTransform.ref.value, instanceCount);
return {
dGeometryType: ValueCell.create('lines'),
aMapping: lines.mappingBuffer,
aGroup: lines.groupBuffer,
aStart: lines.startBuffer,
@@ -231,13 +235,14 @@ export namespace Lines {
...marker,
...overpaint,
...transparency,
...material,
...clipping,
...transform,
...BaseGeometry.createValues(props, counts),
uSizeFactor: ValueCell.create(props.sizeFactor),
dLineSizeAttenuation: ValueCell.create(props.lineSizeAttenuation),
dDoubleSided: ValueCell.create(true),
uDoubleSided: ValueCell.create(true),
dFlipSided: ValueCell.create(false),
};
}

View File

@@ -12,7 +12,6 @@ export type MarkerData = {
uMarker: ValueCell<number>,
tMarker: ValueCell<TextureImage<Uint8Array>>
uMarkerTexDim: ValueCell<Vec2>
dMarkerType: ValueCell<string>,
markerAverage: ValueCell<number>
markerStatus: ValueCell<number>
}
@@ -48,12 +47,19 @@ export function getMarkersAverage(array: Uint8Array, count: number): number {
const backStart = 4 * viewEnd;
let sum = 0;
for (let i = 0; i < viewEnd; ++i) {
const v = view[i];
sum += MarkerCountLut[v & 0xFFFF] + MarkerCountLut[v >> 16];
}
for (let i = backStart; i < count; ++i) {
sum += array[i] && 1;
if (viewEnd < 0) {
// avoid edge cases with small arrays
for (let i = 0; i < count; ++i) {
sum += array[i] && 1;
}
} else {
for (let i = 0; i < viewEnd; ++i) {
const v = view[i];
sum += MarkerCountLut[v & 0xFFFF] + MarkerCountLut[v >> 16];
}
for (let i = backStart; i < count; ++i) {
sum += array[i] && 1;
}
}
return sum / count;
}
@@ -66,7 +72,6 @@ export function createMarkers(count: number, markerData?: MarkerData): MarkerDat
ValueCell.updateIfChanged(markerData.uMarker, 0);
ValueCell.update(markerData.tMarker, markers);
ValueCell.update(markerData.uMarkerTexDim, Vec2.create(markers.width, markers.height));
ValueCell.updateIfChanged(markerData.dMarkerType, status === -1 ? 'groupInstance' : 'uniform');
ValueCell.updateIfChanged(markerData.markerAverage, average);
ValueCell.updateIfChanged(markerData.markerStatus, status);
return markerData;
@@ -77,7 +82,6 @@ export function createMarkers(count: number, markerData?: MarkerData): MarkerDat
uMarkerTexDim: ValueCell.create(Vec2.create(markers.width, markers.height)),
markerAverage: ValueCell.create(average),
markerStatus: ValueCell.create(status),
dMarkerType: ValueCell.create('uniform'),
};
}
}
@@ -88,7 +92,6 @@ export function createEmptyMarkers(markerData?: MarkerData): MarkerData {
ValueCell.updateIfChanged(markerData.uMarker, 0);
ValueCell.update(markerData.tMarker, emptyMarkerTexture);
ValueCell.update(markerData.uMarkerTexDim, Vec2.create(1, 1));
ValueCell.updateIfChanged(markerData.dMarkerType, 'uniform');
ValueCell.updateIfChanged(markerData.markerAverage, 0);
ValueCell.updateIfChanged(markerData.markerStatus, 0);
return markerData;
@@ -99,7 +102,6 @@ export function createEmptyMarkers(markerData?: MarkerData): MarkerData {
uMarkerTexDim: ValueCell.create(Vec2.create(1, 1)),
markerAverage: ValueCell.create(0),
markerStatus: ValueCell.create(0),
dMarkerType: ValueCell.create('uniform'),
};
}
}

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author David Sehnal <david.sehnal@gmail.com>
@@ -40,7 +40,7 @@ const v3set = Vec3.set;
const caAdd3 = ChunkedArray.add3;
const caAdd = ChunkedArray.add;
function addCap(offset: number, state: MeshBuilder.State, controlPoints: ArrayLike<number>, normalVectors: ArrayLike<number>, binormalVectors: ArrayLike<number>, width: number, leftHeight: number, rightHeight: number) {
function addCap(offset: number, state: MeshBuilder.State, controlPoints: ArrayLike<number>, normalVectors: ArrayLike<number>, binormalVectors: ArrayLike<number>, width: number, leftHeight: number, rightHeight: number, flip: boolean) {
const { vertices, normals, indices } = state;
const vertexCount = vertices.elementCount;
@@ -74,11 +74,19 @@ function addCap(offset: number, state: MeshBuilder.State, controlPoints: ArrayLi
v3copy(verticalVector, verticalLeftVector);
}
for (let i = 0; i < 4; ++i) {
caAdd3(normals, normalVector[0], normalVector[1], normalVector[2]);
if (flip) {
for (let i = 0; i < 4; ++i) {
caAdd3(normals, -normalVector[0], -normalVector[1], -normalVector[2]);
}
caAdd3(indices, vertexCount, vertexCount + 1, vertexCount + 2);
caAdd3(indices, vertexCount + 2, vertexCount + 3, vertexCount);
} else {
for (let i = 0; i < 4; ++i) {
caAdd3(normals, normalVector[0], normalVector[1], normalVector[2]);
}
caAdd3(indices, vertexCount + 2, vertexCount + 1, vertexCount);
caAdd3(indices, vertexCount, vertexCount + 3, vertexCount + 2);
}
caAdd3(indices, vertexCount + 2, vertexCount + 1, vertexCount);
caAdd3(indices, vertexCount, vertexCount + 3, vertexCount + 2);
}
/** set arrowHeight = 0 for no arrow */
@@ -193,19 +201,18 @@ export function addSheet(state: MeshBuilder.State, controlPoints: ArrayLike<numb
const width = widthValues[0];
const height = heightValues[0];
const h = arrowHeight === 0 ? height : arrowHeight;
addCap(0, state, controlPoints, normalVectors, binormalVectors, width, h, h);
addCap(0, state, controlPoints, normalVectors, binormalVectors, width, h, h, false);
} else if (arrowHeight > 0) {
const width = widthValues[0];
const height = heightValues[0];
addCap(0, state, controlPoints, normalVectors, binormalVectors, width, arrowHeight, -height);
addCap(0, state, controlPoints, normalVectors, binormalVectors, width, -arrowHeight, height);
addCap(0, state, controlPoints, normalVectors, binormalVectors, width, arrowHeight, -height, false);
addCap(0, state, controlPoints, normalVectors, binormalVectors, width, -arrowHeight, height, false);
}
if (endCap && arrowHeight === 0) {
const width = widthValues[linearSegments];
const height = heightValues[linearSegments];
// use negative height to flip the direction the cap's triangles are facing
addCap(linearSegments * 3, state, controlPoints, normalVectors, binormalVectors, width, -height, -height);
addCap(linearSegments * 3, state, controlPoints, normalVectors, binormalVectors, width, height, height, true);
}
const addedVertexCount = (linearSegments + 1) * 8 +

View File

@@ -1,12 +1,12 @@
/**
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
* @author David Sehnal <david.sehnal@gmail.com>
*/
import { Vec3 } from '../../../../mol-math/linear-algebra';
import { ChunkedArray } from '../../../../mol-data/util';
import { cantorPairing, ChunkedArray } from '../../../../mol-data/util';
import { MeshBuilder } from '../mesh-builder';
const normalVector = Vec3();
@@ -30,32 +30,38 @@ function add3AndScale2(out: Vec3, a: Vec3, b: Vec3, c: Vec3, sa: number, sb: num
// avoiding namespace lookup improved performance in Chrome (Aug 2020)
const v3fromArray = Vec3.fromArray;
const v3normalize = Vec3.normalize;
const v3negate = Vec3.negate;
const v3copy = Vec3.copy;
const v3scaleAndAdd = Vec3.scaleAndAdd;
const v3cross = Vec3.cross;
const v3dot = Vec3.dot;
const v3unitX = Vec3.unitX;
const caAdd3 = ChunkedArray.add3;
const CosSinCache = new Map<number, { cos: number[], sin: number[] }>();
function getCosSin(radialSegments: number) {
if (!CosSinCache.has(radialSegments)) {
function getCosSin(radialSegments: number, shift: boolean) {
const offset = shift ? 1 : 0;
const hash = cantorPairing(radialSegments, offset);
if (!CosSinCache.has(hash)) {
const cos: number[] = [];
const sin: number[] = [];
for (let j = 0; j < radialSegments; ++j) {
const t = 2 * Math.PI * j / radialSegments;
const t = (j * 2 + offset) / radialSegments * Math.PI;
cos[j] = Math.cos(t);
sin[j] = Math.sin(t);
}
CosSinCache.set(radialSegments, { cos, sin });
CosSinCache.set(hash, { cos, sin });
}
return CosSinCache.get(radialSegments)!;
return CosSinCache.get(hash)!;
}
export function addTube(state: MeshBuilder.State, controlPoints: ArrayLike<number>, normalVectors: ArrayLike<number>, binormalVectors: ArrayLike<number>, linearSegments: number, radialSegments: number, widthValues: ArrayLike<number>, heightValues: ArrayLike<number>, startCap: boolean, endCap: boolean) {
export function addTube(state: MeshBuilder.State, controlPoints: ArrayLike<number>, normalVectors: ArrayLike<number>, binormalVectors: ArrayLike<number>, linearSegments: number, radialSegments: number, widthValues: ArrayLike<number>, heightValues: ArrayLike<number>, startCap: boolean, endCap: boolean, crossSection: 'elliptical' | 'rounded') {
const { currentGroup, vertices, normals, indices, groups } = state;
let vertexCount = vertices.elementCount;
const { cos, sin } = getCosSin(radialSegments);
const { cos, sin } = getCosSin(radialSegments, crossSection === 'rounded');
const q1 = Math.round(radialSegments / 4);
const q3 = q1 * 3;
for (let i = 0; i <= linearSegments; ++i) {
const i3 = i * 3;
@@ -65,14 +71,24 @@ export function addTube(state: MeshBuilder.State, controlPoints: ArrayLike<numbe
const width = widthValues[i];
const height = heightValues[i];
const rounded = crossSection === 'rounded' && height > width;
for (let j = 0; j < radialSegments; ++j) {
add3AndScale2(surfacePoint, u, v, controlPoint, height * cos[j], width * sin[j]);
if (radialSegments === 2) {
v3copy(normalVector, v);
v3normalize(normalVector, normalVector);
if (j !== 0 || i % 2 === 0) v3negate(normalVector, normalVector);
if (rounded) {
add3AndScale2(surfacePoint, u, v, controlPoint, width * cos[j], width * sin[j]);
const h = v3dot(v, v3unitX) < 0
? (j < q1 || j >= q3) ? height - width : -height + width
: (j >= q1 && j < q3) ? -height + width : height - width;
v3scaleAndAdd(surfacePoint, surfacePoint, u, h);
if (j === q1 || j === q1 - 1) {
add2AndScale2(normalVector, u, v, 0, 1);
} else if (j === q3 || j === q3 - 1) {
add2AndScale2(normalVector, u, v, 0, -1);
} else {
add2AndScale2(normalVector, u, v, cos[j], sin[j]);
}
} else {
add3AndScale2(surfacePoint, u, v, controlPoint, height * cos[j], width * sin[j]);
add2AndScale2(normalVector, u, v, width * cos[j], height * sin[j]);
}
v3normalize(normalVector, normalVector);
@@ -82,19 +98,37 @@ export function addTube(state: MeshBuilder.State, controlPoints: ArrayLike<numbe
}
}
const radialSegmentsHalf = Math.round(radialSegments / 2);
for (let i = 0; i < linearSegments; ++i) {
for (let j = 0; j < radialSegments; ++j) {
// the triangles are arranged such that opposing triangles of the sheet align
// which prevents triangle intersection within tight curves
for (let j = 0; j < radialSegmentsHalf; ++j) {
caAdd3(
indices,
vertexCount + i * radialSegments + (j + 1) % radialSegments,
vertexCount + (i + 1) * radialSegments + (j + 1) % radialSegments,
vertexCount + i * radialSegments + j
vertexCount + i * radialSegments + (j + 1) % radialSegments, // a
vertexCount + (i + 1) * radialSegments + (j + 1) % radialSegments, // c
vertexCount + i * radialSegments + j // b
);
caAdd3(
indices,
vertexCount + (i + 1) * radialSegments + (j + 1) % radialSegments,
vertexCount + (i + 1) * radialSegments + j,
vertexCount + i * radialSegments + j
vertexCount + (i + 1) * radialSegments + (j + 1) % radialSegments, // c
vertexCount + (i + 1) * radialSegments + j, // d
vertexCount + i * radialSegments + j // b
);
}
for (let j = radialSegmentsHalf; j < radialSegments; ++j) {
caAdd3(
indices,
vertexCount + i * radialSegments + (j + 1) % radialSegments, // a
vertexCount + (i + 1) * radialSegments + j, // d
vertexCount + i * radialSegments + j // b
);
caAdd3(
indices,
vertexCount + (i + 1) * radialSegments + (j + 1) % radialSegments, // c
vertexCount + (i + 1) * radialSegments + j, // d
vertexCount + i * radialSegments + (j + 1) % radialSegments, // a
);
}
}
@@ -111,11 +145,18 @@ export function addTube(state: MeshBuilder.State, controlPoints: ArrayLike<numbe
caAdd3(normals, normalVector[0], normalVector[1], normalVector[2]);
const width = widthValues[0];
const height = heightValues[0];
let height = heightValues[0];
const rounded = crossSection === 'rounded' && height > width;
if (rounded) height -= width;
vertexCount = vertices.elementCount;
for (let i = 0; i < radialSegments; ++i) {
add3AndScale2(surfacePoint, u, v, controlPoint, height * cos[i], width * sin[i]);
if (rounded) {
add3AndScale2(surfacePoint, u, v, controlPoint, width * cos[i], width * sin[i]);
v3scaleAndAdd(surfacePoint, surfacePoint, u, (i < q1 || i >= q3) ? height : -height);
} else {
add3AndScale2(surfacePoint, u, v, controlPoint, height * cos[i], width * sin[i]);
}
caAdd3(vertices, surfacePoint[0], surfacePoint[1], surfacePoint[2]);
caAdd3(normals, normalVector[0], normalVector[1], normalVector[2]);
@@ -141,11 +182,18 @@ export function addTube(state: MeshBuilder.State, controlPoints: ArrayLike<numbe
caAdd3(normals, normalVector[0], normalVector[1], normalVector[2]);
const width = widthValues[linearSegments];
const height = heightValues[linearSegments];
let height = heightValues[linearSegments];
const rounded = crossSection === 'rounded' && height > width;
if (rounded) height -= width;
vertexCount = vertices.elementCount;
for (let i = 0; i < radialSegments; ++i) {
add3AndScale2(surfacePoint, u, v, controlPoint, height * cos[i], width * sin[i]);
if (rounded) {
add3AndScale2(surfacePoint, u, v, controlPoint, width * cos[i], width * sin[i]);
v3scaleAndAdd(surfacePoint, surfacePoint, u, (i < q1 || i >= q3) ? height : -height);
} else {
add3AndScale2(surfacePoint, u, v, controlPoint, height * cos[i], width * sin[i]);
}
caAdd3(vertices, surfacePoint[0], surfacePoint[1], surfacePoint[2]);
caAdd3(normals, normalVector[0], normalVector[1], normalVector[2]);

View File

@@ -4,13 +4,15 @@
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { MeshValues } from '../../../mol-gl/renderable/mesh';
import { createTextureImage, TextureImage } from '../../../mol-gl/renderable/util';
import { WebGLContext } from '../../../mol-gl/webgl/context';
import { Texture } from '../../../mol-gl/webgl/texture';
import { Box3D, Sphere3D } from '../../../mol-math/geometry';
import { lerp } from '../../../mol-math/interpolate';
import { Vec2, Vec3, Vec4 } from '../../../mol-math/linear-algebra';
import { getVolumeTexture2dLayout } from '../../../mol-repr/volume/util';
import { Color } from '../../../mol-util/color';
import { ValueCell } from '../../../mol-util';
interface ColorSmoothingInput {
vertexCount: number
@@ -24,10 +26,11 @@ interface ColorSmoothingInput {
colorType: 'group' | 'groupInstance'
boundingSphere: Sphere3D
invariantBoundingSphere: Sphere3D
itemSize: 4 | 3 | 1
}
export function calcMeshColorSmoothing(input: ColorSmoothingInput, resolution: number, stride: number, webgl?: WebGLContext, texture?: Texture) {
const { colorType, vertexCount, groupCount, positionBuffer, transformBuffer, groupBuffer } = input;
const { colorType, vertexCount, groupCount, positionBuffer, transformBuffer, groupBuffer, itemSize } = input;
const isInstanceType = colorType.endsWith('Instance');
const box = Box3D.fromSphere3D(Box3D(), isInstanceType ? input.boundingSphere : input.invariantBoundingSphere);
@@ -43,7 +46,6 @@ export function calcMeshColorSmoothing(input: ColorSmoothingInput, resolution: n
const { width, height } = getVolumeTexture2dLayout(gridDim);
// console.log({ width, height, dim });
const itemSize = 3;
const data = new Float32Array(width * height * itemSize);
const count = new Float32Array(width * height);
@@ -78,10 +80,7 @@ export function calcMeshColorSmoothing(input: ColorSmoothingInput, resolution: n
const z = Math.floor(vz);
// group colors
const ci = i * groupCount + groupBuffer[j];
const r = colors[ci * 3];
const g = colors[ci * 3 + 1];
const b = colors[ci * 3 + 2];
const ci = (i * groupCount + groupBuffer[j]) * itemSize;
// Extents of grid to consider for this atom
const begX = Math.max(0, x - p);
@@ -106,10 +105,10 @@ export function calcMeshColorSmoothing(input: ColorSmoothingInput, resolution: n
const s = p - d;
const index = getIndex(xi, yi, zi);
data[index] += r * s;
data[index + 1] += g * s;
data[index + 2] += b * s;
count[index / 3] += s;
for (let k = 0; k < itemSize; ++k) {
data[index + k] += colors[ci + k] * s;
}
count[index / itemSize] += s;
}
}
}
@@ -117,11 +116,11 @@ export function calcMeshColorSmoothing(input: ColorSmoothingInput, resolution: n
}
for (let i = 0, il = count.length; i < il; ++i) {
const i3 = i * 3;
const is = i * itemSize;
const c = count[i];
grid[i3] = Math.round(data[i3] / c);
grid[i3 + 1] = Math.round(data[i3 + 1] / c);
grid[i3 + 2] = Math.round(data[i3 + 2] / c);
for (let k = 0; k < itemSize; ++k) {
grid[is + k] = Math.round(data[is + k] / c);
}
}
const gridTexDim = Vec2.create(width, height);
@@ -129,12 +128,16 @@ export function calcMeshColorSmoothing(input: ColorSmoothingInput, resolution: n
const type = isInstanceType ? 'volumeInstance' as const : 'volume' as const;
if (webgl) {
if (!texture) texture = webgl.resources.texture('image-uint8', 'rgb', 'ubyte', 'linear');
if (!texture) {
const format = itemSize === 4 ? 'rgba' :
itemSize === 3 ? 'rgb' : 'alpha';
texture = webgl.resources.texture('image-uint8', format, 'ubyte', 'linear');
}
texture.load(textureImage);
return { kind: 'volume' as const, texture, gridTexDim, gridDim, gridTransform, type };
} else {
const interpolated = getTrilinearlyInterpolated({ vertexCount, instanceCount, transformBuffer, positionBuffer, colorType: type, grid, gridDim, gridTexDim, gridTransform, vertexStride: 3, colorStride: 3 });
const interpolated = getTrilinearlyInterpolated({ vertexCount, instanceCount, transformBuffer, positionBuffer, colorType: type, grid, gridDim, gridTexDim, gridTransform, vertexStride: 3, colorStride: itemSize, outputStride: itemSize });
return {
kind: 'vertex' as const,
@@ -157,16 +160,24 @@ interface ColorInterpolationInput {
gridTexDim: Vec2
gridDim: Vec3
gridTransform: Vec4
vertexStride: number
colorStride: number
vertexStride: 3 | 4
colorStride: 1 | 3 | 4
outputStride: 1 | 3 | 4
itemOffset?: 0 | 1 | 2 | 3
}
export function getTrilinearlyInterpolated(input: ColorInterpolationInput): TextureImage<Uint8Array> {
const { vertexCount, positionBuffer, transformBuffer, grid, gridDim, gridTexDim, gridTransform, vertexStride, colorStride } = input;
const itemOffset = input.itemOffset || 0;
const outputStride = input.outputStride;
if (outputStride + itemOffset > colorStride) {
throw new Error('outputStride + itemOffset must NOT be larger than colorStride');
}
const isInstanceType = input.colorType.endsWith('Instance');
const instanceCount = isInstanceType ? input.instanceCount : 1;
const image = createTextureImage(Math.max(1, instanceCount * vertexCount), 3, Uint8Array);
const image = createTextureImage(Math.max(1, instanceCount * vertexCount), outputStride, Uint8Array);
const { array } = image;
const [xn, yn] = gridDim;
@@ -204,26 +215,178 @@ export function getTrilinearlyInterpolated(input: ColorInterpolationInput): Text
const [x1, y1, z1] = v1;
const [xd, yd, zd] = vd;
const s000 = Color.fromArray(grid, getIndex(x0, y0, z0));
const s100 = Color.fromArray(grid, getIndex(x1, y0, z0));
const s001 = Color.fromArray(grid, getIndex(x0, y0, z1));
const s101 = Color.fromArray(grid, getIndex(x1, y0, z1));
const s010 = Color.fromArray(grid, getIndex(x0, y1, z0));
const s110 = Color.fromArray(grid, getIndex(x1, y1, z0));
const s011 = Color.fromArray(grid, getIndex(x0, y1, z1));
const s111 = Color.fromArray(grid, getIndex(x1, y1, z1));
const i000 = getIndex(x0, y0, z0) + itemOffset;
const i100 = getIndex(x1, y0, z0) + itemOffset;
const i001 = getIndex(x0, y0, z1) + itemOffset;
const i101 = getIndex(x1, y0, z1) + itemOffset;
const i010 = getIndex(x0, y1, z0) + itemOffset;
const i110 = getIndex(x1, y1, z0) + itemOffset;
const i011 = getIndex(x0, y1, z1) + itemOffset;
const i111 = getIndex(x1, y1, z1) + itemOffset;
const s00 = Color.interpolate(s000, s100, xd);
const s01 = Color.interpolate(s001, s101, xd);
const s10 = Color.interpolate(s010, s110, xd);
const s11 = Color.interpolate(s011, s111, xd);
const o = (i * vertexCount + j) * outputStride;
const s0 = Color.interpolate(s00, s10, yd);
const s1 = Color.interpolate(s01, s11, yd);
for (let k = 0; k < outputStride; ++k) {
const s000 = grid[i000 + k];
const s100 = grid[i100 + k];
const s001 = grid[i001 + k];
const s101 = grid[i101 + k];
const s010 = grid[i010 + k];
const s110 = grid[i110 + k];
const s011 = grid[i011 + k];
const s111 = grid[i111 + k];
Color.toArray(Color.interpolate(s0, s1, zd), array, (i * vertexCount + j) * 3);
const s00 = lerp(s000, s100, xd);
const s01 = lerp(s001, s101, xd);
const s10 = lerp(s010, s110, xd);
const s11 = lerp(s011, s111, xd);
const s0 = lerp(s00, s10, yd);
const s1 = lerp(s01, s11, yd);
array[o + k] = lerp(s0, s1, zd);
}
}
}
return image;
}
//
function isSupportedColorType(x: string): x is 'group' | 'groupInstance' {
return x === 'group' || x === 'groupInstance';
}
export function applyMeshColorSmoothing(values: MeshValues, resolution: number, stride: number, webgl?: WebGLContext, colorTexture?: Texture) {
if (!isSupportedColorType(values.dColorType.ref.value)) return;
const smoothingData = calcMeshColorSmoothing({
vertexCount: values.uVertexCount.ref.value,
instanceCount: values.uInstanceCount.ref.value,
groupCount: values.uGroupCount.ref.value,
transformBuffer: values.aTransform.ref.value,
instanceBuffer: values.aInstance.ref.value,
positionBuffer: values.aPosition.ref.value,
groupBuffer: values.aGroup.ref.value,
colorData: values.tColor.ref.value,
colorType: values.dColorType.ref.value,
boundingSphere: values.boundingSphere.ref.value,
invariantBoundingSphere: values.invariantBoundingSphere.ref.value,
itemSize: 3
}, resolution, stride, webgl, colorTexture);
if (smoothingData.kind === 'volume') {
ValueCell.updateIfChanged(values.dColorType, smoothingData.type);
ValueCell.update(values.tColorGrid, smoothingData.texture);
ValueCell.update(values.uColorTexDim, smoothingData.gridTexDim);
ValueCell.update(values.uColorGridDim, smoothingData.gridDim);
ValueCell.update(values.uColorGridTransform, smoothingData.gridTransform);
} else if (smoothingData.kind === 'vertex') {
ValueCell.updateIfChanged(values.dColorType, smoothingData.type);
ValueCell.update(values.tColor, smoothingData.texture);
ValueCell.update(values.uColorTexDim, smoothingData.texDim);
}
}
function isSupportedOverpaintType(x: string): x is 'groupInstance' {
return x === 'groupInstance';
}
export function applyMeshOverpaintSmoothing(values: MeshValues, resolution: number, stride: number, webgl?: WebGLContext, colorTexture?: Texture) {
if (!isSupportedOverpaintType(values.dOverpaintType.ref.value)) return;
const smoothingData = calcMeshColorSmoothing({
vertexCount: values.uVertexCount.ref.value,
instanceCount: values.uInstanceCount.ref.value,
groupCount: values.uGroupCount.ref.value,
transformBuffer: values.aTransform.ref.value,
instanceBuffer: values.aInstance.ref.value,
positionBuffer: values.aPosition.ref.value,
groupBuffer: values.aGroup.ref.value,
colorData: values.tOverpaint.ref.value,
colorType: values.dOverpaintType.ref.value,
boundingSphere: values.boundingSphere.ref.value,
invariantBoundingSphere: values.invariantBoundingSphere.ref.value,
itemSize: 4
}, resolution, stride, webgl, colorTexture);
if (smoothingData.kind === 'volume') {
ValueCell.updateIfChanged(values.dOverpaintType, smoothingData.type);
ValueCell.update(values.tOverpaintGrid, smoothingData.texture);
ValueCell.update(values.uOverpaintTexDim, smoothingData.gridTexDim);
ValueCell.update(values.uOverpaintGridDim, smoothingData.gridDim);
ValueCell.update(values.uOverpaintGridTransform, smoothingData.gridTransform);
} else if (smoothingData.kind === 'vertex') {
ValueCell.updateIfChanged(values.dOverpaintType, smoothingData.type);
ValueCell.update(values.tOverpaint, smoothingData.texture);
ValueCell.update(values.uOverpaintTexDim, smoothingData.texDim);
}
}
function isSupportedTransparencyType(x: string): x is 'groupInstance' {
return x === 'groupInstance';
}
export function applyMeshTransparencySmoothing(values: MeshValues, resolution: number, stride: number, webgl?: WebGLContext, colorTexture?: Texture) {
if (!isSupportedTransparencyType(values.dTransparencyType.ref.value)) return;
const smoothingData = calcMeshColorSmoothing({
vertexCount: values.uVertexCount.ref.value,
instanceCount: values.uInstanceCount.ref.value,
groupCount: values.uGroupCount.ref.value,
transformBuffer: values.aTransform.ref.value,
instanceBuffer: values.aInstance.ref.value,
positionBuffer: values.aPosition.ref.value,
groupBuffer: values.aGroup.ref.value,
colorData: values.tTransparency.ref.value,
colorType: values.dTransparencyType.ref.value,
boundingSphere: values.boundingSphere.ref.value,
invariantBoundingSphere: values.invariantBoundingSphere.ref.value,
itemSize: 1
}, resolution, stride, webgl, colorTexture);
if (smoothingData.kind === 'volume') {
ValueCell.updateIfChanged(values.dTransparencyType, smoothingData.type);
ValueCell.update(values.tTransparencyGrid, smoothingData.texture);
ValueCell.update(values.uTransparencyTexDim, smoothingData.gridTexDim);
ValueCell.update(values.uTransparencyGridDim, smoothingData.gridDim);
ValueCell.update(values.uTransparencyGridTransform, smoothingData.gridTransform);
} else if (smoothingData.kind === 'vertex') {
ValueCell.updateIfChanged(values.dTransparencyType, smoothingData.type);
ValueCell.update(values.tTransparency, smoothingData.texture);
ValueCell.update(values.uTransparencyTexDim, smoothingData.texDim);
}
}
function isSupportedSubstanceType(x: string): x is 'groupInstance' {
return x === 'groupInstance';
}
export function applyMeshSubstanceSmoothing(values: MeshValues, resolution: number, stride: number, webgl?: WebGLContext, colorTexture?: Texture) {
if (!isSupportedSubstanceType(values.dSubstanceType.ref.value)) return;
const smoothingData = calcMeshColorSmoothing({
vertexCount: values.uVertexCount.ref.value,
instanceCount: values.uInstanceCount.ref.value,
groupCount: values.uGroupCount.ref.value,
transformBuffer: values.aTransform.ref.value,
instanceBuffer: values.aInstance.ref.value,
positionBuffer: values.aPosition.ref.value,
groupBuffer: values.aGroup.ref.value,
colorData: values.tSubstance.ref.value,
colorType: values.dSubstanceType.ref.value,
boundingSphere: values.boundingSphere.ref.value,
invariantBoundingSphere: values.invariantBoundingSphere.ref.value,
itemSize: 4
}, resolution, stride, webgl, colorTexture);
if (smoothingData.kind === 'volume') {
ValueCell.updateIfChanged(values.dSubstanceType, smoothingData.type);
ValueCell.update(values.tSubstanceGrid, smoothingData.texture);
ValueCell.update(values.uSubstanceTexDim, smoothingData.gridTexDim);
ValueCell.update(values.uSubstanceGridDim, smoothingData.gridDim);
ValueCell.update(values.uSubstanceGridTransform, smoothingData.gridTransform);
} else if (smoothingData.kind === 'vertex') {
ValueCell.updateIfChanged(values.dSubstanceType, smoothingData.type);
ValueCell.update(values.tSubstance, smoothingData.texture);
ValueCell.update(values.uSubstanceTexDim, smoothingData.texDim);
}
}

View File

@@ -27,6 +27,7 @@ import { createEmptyClipping } from '../clipping-data';
import { RenderableState } from '../../../mol-gl/renderable';
import { arraySetAdd } from '../../../mol-util/array';
import { degToRad } from '../../../mol-math/misc';
import { createEmptySubstance } from '../substance-data';
export interface Mesh {
readonly kind: 'mesh',
@@ -624,6 +625,8 @@ export namespace Mesh {
flatShaded: PD.Boolean(false, BaseGeometry.ShadingCategory),
ignoreLight: PD.Boolean(false, BaseGeometry.ShadingCategory),
xrayShaded: PD.Boolean(false, BaseGeometry.ShadingCategory),
bumpFrequency: PD.Numeric(0, { min: 0, max: 10, step: 0.1 }, BaseGeometry.ShadingCategory),
bumpAmplitude: PD.Numeric(1, { min: 0, max: 5, step: 0.1 }, BaseGeometry.ShadingCategory),
};
export type Params = typeof Params
@@ -665,6 +668,7 @@ export namespace Mesh {
const marker = createMarkers(instanceCount * groupCount);
const overpaint = createEmptyOverpaint();
const transparency = createEmptyTransparency();
const material = createEmptySubstance();
const clipping = createEmptyClipping();
const counts = { drawCount: mesh.triangleCount * 3, vertexCount: mesh.vertexCount, groupCount, instanceCount };
@@ -673,6 +677,8 @@ export namespace Mesh {
const boundingSphere = calculateTransformBoundingSphere(invariantBoundingSphere, transform.aTransform.ref.value, instanceCount);
return {
dGeometryType: ValueCell.create('mesh'),
aPosition: mesh.vertexBuffer,
aNormal: mesh.normalBuffer,
aGroup: mesh.groupBuffer,
@@ -684,15 +690,18 @@ export namespace Mesh {
...marker,
...overpaint,
...transparency,
...material,
...clipping,
...transform,
...BaseGeometry.createValues(props, counts),
dDoubleSided: ValueCell.create(props.doubleSided),
uDoubleSided: ValueCell.create(props.doubleSided),
dFlatShaded: ValueCell.create(props.flatShaded),
dFlipSided: ValueCell.create(props.flipSided),
dIgnoreLight: ValueCell.create(props.ignoreLight),
dXrayShaded: ValueCell.create(props.xrayShaded),
uBumpFrequency: ValueCell.create(props.bumpFrequency),
uBumpAmplitude: ValueCell.create(props.bumpAmplitude),
meta: ValueCell.create(mesh.meta),
};
@@ -706,11 +715,13 @@ export namespace Mesh {
function updateValues(values: MeshValues, props: PD.Values<Params>) {
BaseGeometry.updateValues(values, props);
ValueCell.updateIfChanged(values.dDoubleSided, props.doubleSided);
ValueCell.updateIfChanged(values.uDoubleSided, props.doubleSided);
ValueCell.updateIfChanged(values.dFlatShaded, props.flatShaded);
ValueCell.updateIfChanged(values.dFlipSided, props.flipSided);
ValueCell.updateIfChanged(values.dIgnoreLight, props.ignoreLight);
ValueCell.updateIfChanged(values.dXrayShaded, props.xrayShaded);
ValueCell.updateIfChanged(values.uBumpFrequency, props.bumpFrequency);
ValueCell.updateIfChanged(values.uBumpAmplitude, props.bumpAmplitude);
}
function updateBoundingSphere(values: MeshValues, mesh: Mesh) {

View File

@@ -1,18 +1,24 @@
/**
* Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
* Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { ValueCell } from '../../mol-util/value-cell';
import { Vec2 } from '../../mol-math/linear-algebra';
import { Vec2, Vec3, Vec4 } from '../../mol-math/linear-algebra';
import { TextureImage, createTextureImage } from '../../mol-gl/renderable/util';
import { Color } from '../../mol-util/color';
import { createNullTexture, Texture } from '../../mol-gl/webgl/texture';
export type OverpaintData = {
tOverpaint: ValueCell<TextureImage<Uint8Array>>
uOverpaintTexDim: ValueCell<Vec2>
dOverpaint: ValueCell<boolean>,
tOverpaintGrid: ValueCell<Texture>,
uOverpaintGridDim: ValueCell<Vec3>,
uOverpaintGridTransform: ValueCell<Vec4>,
dOverpaintType: ValueCell<string>,
}
export function applyOverpaintColor(array: Uint8Array, start: number, end: number, color: Color) {
@@ -40,6 +46,11 @@ export function createOverpaint(count: number, overpaintData?: OverpaintData): O
tOverpaint: ValueCell.create(overpaint),
uOverpaintTexDim: ValueCell.create(Vec2.create(overpaint.width, overpaint.height)),
dOverpaint: ValueCell.create(count > 0),
tOverpaintGrid: ValueCell.create(createNullTexture()),
uOverpaintGridDim: ValueCell.create(Vec3.create(1, 1, 1)),
uOverpaintGridTransform: ValueCell.create(Vec4.create(0, 0, 0, 1)),
dOverpaintType: ValueCell.create('groupInstance'),
};
}
}
@@ -55,6 +66,11 @@ export function createEmptyOverpaint(overpaintData?: OverpaintData): OverpaintDa
tOverpaint: ValueCell.create(emptyOverpaintTexture),
uOverpaintTexDim: ValueCell.create(Vec2.create(1, 1)),
dOverpaint: ValueCell.create(false),
tOverpaintGrid: ValueCell.create(createNullTexture()),
uOverpaintGridDim: ValueCell.create(Vec3.create(1, 1, 1)),
uOverpaintGridTransform: ValueCell.create(Vec4.create(0, 0, 0, 1)),
dOverpaintType: ValueCell.create('groupInstance'),
};
}
}

Some files were not shown because too many files have changed in this diff Show More