molstar 3.26.0 → 3.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +202 -202
- package/build/viewer/embedded.html +52 -52
- package/build/viewer/index.html +115 -115
- package/build/viewer/molstar.css +1 -1
- package/build/viewer/molstar.js +1 -1
- package/lib/apps/docking-viewer/index.html +36 -36
- package/lib/apps/docking-viewer/viewport.d.ts +2 -0
- package/lib/apps/docking-viewer/viewport.js +1 -0
- package/lib/apps/viewer/app.d.ts +3 -1
- package/lib/apps/viewer/app.js +4 -0
- package/lib/apps/viewer/embedded.html +52 -52
- package/lib/apps/viewer/index.html +115 -115
- package/lib/cli/structure-info/volume.js +1 -1
- package/lib/commonjs/apps/docking-viewer/viewport.d.ts +2 -0
- package/lib/commonjs/apps/docking-viewer/viewport.js +1 -0
- package/lib/commonjs/apps/viewer/app.d.ts +3 -1
- package/lib/commonjs/apps/viewer/app.js +4 -0
- package/lib/commonjs/cli/structure-info/volume.js +1 -1
- package/lib/commonjs/examples/lighting/index.js +1 -1
- package/lib/commonjs/extensions/anvil/behavior.d.ts +1 -0
- package/lib/commonjs/extensions/cellpack/model.js +2 -1
- package/lib/commonjs/extensions/dnatco/confal-pyramids/behavior.d.ts +1 -0
- package/lib/commonjs/extensions/meshes/choice.d.ts +26 -0
- package/lib/commonjs/extensions/meshes/choice.js +31 -0
- package/lib/commonjs/extensions/meshes/examples.d.ts +26 -0
- package/lib/commonjs/extensions/meshes/examples.js +337 -0
- package/lib/commonjs/extensions/meshes/mesh-cif-schema.d.ts +29 -0
- package/lib/commonjs/extensions/meshes/mesh-cif-schema.js +34 -0
- package/lib/commonjs/extensions/meshes/mesh-extension.d.ts +66 -0
- package/lib/commonjs/extensions/meshes/mesh-extension.js +221 -0
- package/lib/commonjs/extensions/meshes/mesh-streaming/behavior.d.ts +105 -0
- package/lib/commonjs/extensions/meshes/mesh-streaming/behavior.js +379 -0
- package/lib/commonjs/extensions/meshes/mesh-streaming/server-info.d.ts +54 -0
- package/lib/commonjs/extensions/meshes/mesh-streaming/server-info.js +30 -0
- package/lib/commonjs/extensions/meshes/mesh-streaming/transformers.d.ts +42 -0
- package/lib/commonjs/extensions/meshes/mesh-streaming/transformers.js +273 -0
- package/lib/commonjs/extensions/meshes/mesh-utils.d.ts +41 -0
- package/lib/commonjs/extensions/meshes/mesh-utils.js +357 -0
- package/lib/commonjs/extensions/meshes/metadata.d.ts +108 -0
- package/lib/commonjs/extensions/meshes/metadata.js +72 -0
- package/lib/commonjs/extensions/model-archive/quality-assessment/behavior.d.ts +2 -0
- package/lib/commonjs/extensions/model-archive/quality-assessment/prop.d.ts +1 -0
- package/lib/commonjs/extensions/model-archive/quality-assessment/prop.js +16 -4
- package/lib/commonjs/extensions/rcsb/assembly-symmetry/behavior.d.ts +4 -2
- package/lib/commonjs/extensions/rcsb/validation-report/behavior.d.ts +3 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-meshes.d.ts +17 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-meshes.js +156 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-models.d.ts +12 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-models.js +96 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-root.d.ts +122 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-root.js +576 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-segmentation.d.ts +20 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-segmentation.js +200 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-state.d.ts +88 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-state.js +32 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-volume.d.ts +35 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/entry-volume.js +234 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/external-api.d.ts +11 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/external-api.js +85 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/global-state.d.ts +51 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/global-state.js +83 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/helpers.d.ts +56 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/helpers.js +171 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/index.d.ts +20 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/index.js +130 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/transformers.d.ts +33 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/transformers.js +85 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/ui.d.ts +29 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/ui.js +232 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/api.d.ts +22 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/api.js +83 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/data.d.ts +92 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/data.js +7 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/utils.d.ts +23 -0
- package/lib/commonjs/extensions/volumes-and-segmentations/volseg-api/utils.js +78 -0
- package/lib/commonjs/mol-canvas3d/canvas3d.d.ts +2 -0
- package/lib/commonjs/mol-canvas3d/passes/draw.js +3 -3
- package/lib/commonjs/mol-canvas3d/passes/image.d.ts +1 -0
- package/lib/commonjs/mol-canvas3d/passes/postprocessing.d.ts +2 -1
- package/lib/commonjs/mol-canvas3d/passes/postprocessing.js +27 -13
- package/lib/commonjs/mol-geo/geometry/cylinders/cylinders.d.ts +2 -1
- package/lib/commonjs/mol-geo/geometry/cylinders/cylinders.js +3 -2
- package/lib/commonjs/mol-geo/geometry/lines/lines.d.ts +0 -1
- package/lib/commonjs/mol-geo/geometry/points/points.d.ts +1 -1
- package/lib/commonjs/mol-geo/geometry/spheres/spheres.d.ts +1 -0
- package/lib/commonjs/mol-geo/geometry/spheres/spheres.js +3 -2
- package/lib/commonjs/mol-gl/compute/histogram-pyramid/reduction.js +1 -2
- package/lib/commonjs/mol-gl/compute/marching-cubes/isosurface.js +4 -6
- package/lib/commonjs/mol-gl/renderable/cylinders.d.ts +1 -0
- package/lib/commonjs/mol-gl/renderable/cylinders.js +1 -1
- package/lib/commonjs/mol-gl/renderable/spheres.d.ts +1 -0
- package/lib/commonjs/mol-gl/renderable/spheres.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/apply-light-color.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/apply-light-color.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/clip-instance.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/clip-instance.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/clip-pixel.glsl.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/clip-pixel.glsl.js +1 -1
- package/lib/commonjs/mol-gl/shader/chunks/common-clip.glsl.d.ts +2 -2
- package/lib/commonjs/mol-gl/shader/chunks/common-clip.glsl.js +2 -2
- package/lib/commonjs/mol-gl/shader/cylinders.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/cylinders.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/cylinders.vert.d.ts +2 -2
- package/lib/commonjs/mol-gl/shader/cylinders.vert.js +2 -2
- package/lib/commonjs/mol-gl/shader/direct-volume.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/direct-volume.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/outlines.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/outlines.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/postprocessing.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/postprocessing.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/spheres.frag.d.ts +1 -1
- package/lib/commonjs/mol-gl/shader/spheres.frag.js +1 -1
- package/lib/commonjs/mol-gl/shader/spheres.vert.d.ts +2 -2
- package/lib/commonjs/mol-gl/shader/spheres.vert.js +2 -2
- package/lib/commonjs/mol-gl/webgl/renderbuffer.d.ts +1 -1
- package/lib/commonjs/mol-gl/webgl/renderbuffer.js +15 -0
- package/lib/commonjs/mol-gl/webgl/state.d.ts +12 -0
- package/lib/commonjs/mol-gl/webgl/state.js +136 -0
- package/lib/commonjs/mol-io/reader/cif/schema/segmentation.d.ts +38 -0
- package/lib/commonjs/mol-io/reader/cif/schema/segmentation.js +22 -0
- package/lib/commonjs/mol-io/reader/cif.d.ts +3 -1
- package/lib/commonjs/mol-io/reader/cif.js +3 -1
- package/lib/commonjs/mol-model/location.d.ts +2 -1
- package/lib/commonjs/mol-model/loci.d.ts +11 -11
- package/lib/commonjs/mol-model/loci.js +13 -1
- package/lib/commonjs/mol-model/sequence/alignment/sequence.d.ts +4 -1
- package/lib/commonjs/mol-model/sequence/alignment/sequence.js +4 -1
- package/lib/commonjs/mol-model/structure/model/properties/atomic/hierarchy.d.ts +6 -0
- package/lib/commonjs/mol-model/structure/model/properties/utils/atomic-index.js +8 -0
- package/lib/commonjs/mol-model/structure/structure/unit/bonds/inter-compute.js +21 -5
- package/lib/commonjs/mol-model/structure/structure/util/superposition.d.ts +1 -0
- package/lib/commonjs/mol-model/structure/structure/util/superposition.js +2 -1
- package/lib/commonjs/mol-model/volume/volume.d.ts +35 -2
- package/lib/commonjs/mol-model/volume/volume.js +77 -2
- package/lib/commonjs/mol-model-formats/volume/segmentation.d.ts +23 -0
- package/lib/commonjs/mol-model-formats/volume/segmentation.js +138 -0
- package/lib/commonjs/mol-plugin/behavior/dynamic/representation.d.ts +2 -2
- package/lib/commonjs/mol-plugin/behavior/dynamic/selection/structure-focus-representation.d.ts +1 -0
- package/lib/commonjs/mol-plugin/behavior/dynamic/selection/structure-focus-representation.js +2 -1
- package/lib/commonjs/mol-plugin/behavior/dynamic/volume-streaming/model.d.ts +2 -3
- package/lib/commonjs/mol-plugin/commands.d.ts +1 -0
- package/lib/commonjs/mol-plugin-state/animation/built-in/model-index.js +4 -1
- package/lib/commonjs/mol-plugin-state/builder/structure/hierarchy-preset.d.ts +2 -0
- package/lib/commonjs/mol-plugin-state/builder/structure/hierarchy.d.ts +1 -0
- package/lib/commonjs/mol-plugin-state/builder/structure/representation-preset.d.ts +13 -4
- package/lib/commonjs/mol-plugin-state/builder/structure/representation-preset.js +6 -1
- package/lib/commonjs/mol-plugin-state/builder/structure/representation.d.ts +1 -0
- package/lib/commonjs/mol-plugin-state/formats/provider.d.ts +2 -2
- package/lib/commonjs/mol-plugin-state/formats/provider.js +11 -3
- package/lib/commonjs/mol-plugin-state/formats/registry.js +6 -5
- package/lib/commonjs/mol-plugin-state/formats/volume.d.ts +27 -0
- package/lib/commonjs/mol-plugin-state/formats/volume.js +65 -1
- package/lib/commonjs/mol-plugin-state/manager/structure/component.d.ts +1 -1
- package/lib/commonjs/mol-plugin-state/manager/structure/component.js +18 -13
- package/lib/commonjs/mol-plugin-state/transforms/representation.d.ts +1 -2
- package/lib/commonjs/mol-plugin-state/transforms/representation.js +5 -6
- package/lib/commonjs/mol-plugin-state/transforms/volume.d.ts +11 -1
- package/lib/commonjs/mol-plugin-state/transforms/volume.js +55 -2
- package/lib/commonjs/mol-plugin-ui/controls/line-graph/line-graph-component.d.ts +1 -0
- package/lib/commonjs/mol-plugin-ui/controls/line-graph/line-graph-component.js +33 -13
- package/lib/commonjs/mol-plugin-ui/controls/parameters.d.ts +1 -0
- package/lib/commonjs/mol-plugin-ui/controls/parameters.js +22 -5
- package/lib/commonjs/mol-plugin-ui/sequence/sequence.d.ts +25 -17
- package/lib/commonjs/mol-plugin-ui/sequence.d.ts +19 -1
- package/lib/commonjs/mol-plugin-ui/sequence.js +8 -1
- package/lib/commonjs/mol-plugin-ui/state/apply-action.d.ts +2 -10
- package/lib/commonjs/mol-plugin-ui/state/apply-action.js +2 -2
- package/lib/commonjs/mol-plugin-ui/structure/quick-styles.js +2 -2
- package/lib/commonjs/mol-plugin-ui/structure/superposition.d.ts +1 -1
- package/lib/commonjs/mol-plugin-ui/structure/volume.d.ts +1 -1
- package/lib/commonjs/mol-plugin-ui/structure/volume.js +3 -2
- package/lib/commonjs/mol-repr/structure/complex-visual.d.ts +1 -0
- package/lib/commonjs/mol-repr/structure/params.d.ts +2 -0
- package/lib/commonjs/mol-repr/structure/registry.d.ts +12 -0
- package/lib/commonjs/mol-repr/structure/representation/backbone.d.ts +3 -0
- package/lib/commonjs/mol-repr/structure/representation/ball-and-stick.d.ts +6 -0
- package/lib/commonjs/mol-repr/structure/representation/ellipsoid.d.ts +6 -0
- package/lib/commonjs/mol-repr/structure/representation/gaussian-surface.d.ts +3 -0
- package/lib/commonjs/mol-repr/structure/representation/gaussian-volume.d.ts +3 -0
- package/lib/commonjs/mol-repr/structure/representation/line.d.ts +3 -0
- package/lib/commonjs/mol-repr/structure/representation/molecular-surface.d.ts +3 -0
- package/lib/commonjs/mol-repr/structure/representation/point.d.ts +3 -0
- package/lib/commonjs/mol-repr/structure/representation/spacefill.d.ts +6 -0
- package/lib/commonjs/mol-repr/structure/units-visual.d.ts +2 -0
- package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-cylinder.d.ts +4 -0
- package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-cylinder.js +2 -0
- package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-line.d.ts +1 -0
- package/lib/commonjs/mol-repr/structure/visual/bond-inter-unit-line.js +1 -0
- package/lib/commonjs/mol-repr/structure/visual/bond-intra-unit-cylinder.d.ts +4 -0
- package/lib/commonjs/mol-repr/structure/visual/bond-intra-unit-cylinder.js +2 -0
- package/lib/commonjs/mol-repr/structure/visual/bond-intra-unit-line.d.ts +1 -0
- package/lib/commonjs/mol-repr/structure/visual/bond-intra-unit-line.js +1 -0
- package/lib/commonjs/mol-repr/structure/visual/element-cross.d.ts +1 -0
- package/lib/commonjs/mol-repr/structure/visual/element-cross.js +2 -1
- package/lib/commonjs/mol-repr/structure/visual/element-point.d.ts +1 -0
- package/lib/commonjs/mol-repr/structure/visual/element-point.js +2 -1
- package/lib/commonjs/mol-repr/structure/visual/element-sphere.d.ts +4 -0
- package/lib/commonjs/mol-repr/structure/visual/element-sphere.js +3 -1
- package/lib/commonjs/mol-repr/structure/visual/gaussian-density-volume.d.ts +2 -0
- package/lib/commonjs/mol-repr/structure/visual/gaussian-density-volume.js +6 -2
- package/lib/commonjs/mol-repr/structure/visual/gaussian-surface-mesh.d.ts +4 -0
- package/lib/commonjs/mol-repr/structure/visual/gaussian-surface-mesh.js +9 -1
- package/lib/commonjs/mol-repr/structure/visual/gaussian-surface-wireframe.d.ts +1 -0
- package/lib/commonjs/mol-repr/structure/visual/gaussian-surface-wireframe.js +3 -1
- package/lib/commonjs/mol-repr/structure/visual/molecular-surface-mesh.d.ts +1 -0
- package/lib/commonjs/mol-repr/structure/visual/molecular-surface-mesh.js +4 -0
- package/lib/commonjs/mol-repr/structure/visual/molecular-surface-wireframe.d.ts +1 -0
- package/lib/commonjs/mol-repr/structure/visual/molecular-surface-wireframe.js +2 -0
- package/lib/commonjs/mol-repr/structure/visual/polymer-backbone-cylinder.d.ts +2 -0
- package/lib/commonjs/mol-repr/structure/visual/polymer-backbone-sphere.d.ts +2 -0
- package/lib/commonjs/mol-repr/structure/visual/util/bond.d.ts +7 -0
- package/lib/commonjs/mol-repr/structure/visual/util/bond.js +18 -7
- package/lib/commonjs/mol-repr/structure/visual/util/common.d.ts +4 -1
- package/lib/commonjs/mol-repr/structure/visual/util/common.js +10 -6
- package/lib/commonjs/mol-repr/structure/visual/util/element.d.ts +1 -0
- package/lib/commonjs/mol-repr/structure/visual/util/element.js +2 -3
- package/lib/commonjs/mol-repr/structure/visual/util/gaussian.d.ts +2 -0
- package/lib/commonjs/mol-repr/volume/direct-volume.d.ts +4 -4
- package/lib/commonjs/mol-repr/volume/direct-volume.js +8 -6
- package/lib/commonjs/mol-repr/volume/isosurface.d.ts +4 -4
- package/lib/commonjs/mol-repr/volume/isosurface.js +17 -16
- package/lib/commonjs/mol-repr/volume/registry.d.ts +54 -1
- package/lib/commonjs/mol-repr/volume/registry.js +3 -1
- package/lib/commonjs/mol-repr/volume/representation.d.ts +11 -7
- package/lib/commonjs/mol-repr/volume/representation.js +142 -47
- package/lib/commonjs/mol-repr/volume/segment.d.ts +291 -0
- package/lib/commonjs/mol-repr/volume/segment.js +289 -0
- package/lib/commonjs/mol-repr/volume/slice.d.ts +2 -2
- package/lib/commonjs/mol-repr/volume/slice.js +5 -5
- package/lib/commonjs/mol-repr/volume/util.d.ts +12 -3
- package/lib/commonjs/mol-repr/volume/util.js +72 -6
- package/lib/commonjs/mol-script/language/builder.d.ts +1 -0
- package/lib/commonjs/mol-theme/color/volume-segment.d.ts +41 -0
- package/lib/commonjs/mol-theme/color/volume-segment.js +58 -0
- package/lib/commonjs/mol-theme/color/volume-value.js +2 -1
- package/lib/commonjs/mol-theme/color.d.ts +15 -0
- package/lib/commonjs/mol-theme/color.js +2 -0
- package/lib/commonjs/mol-theme/label.d.ts +1 -1
- package/lib/commonjs/mol-theme/label.js +13 -1
- package/lib/commonjs/mol-util/param-definition.d.ts +4 -1
- package/lib/commonjs/mol-util/param-definition.js +5 -2
- package/lib/examples/alpha-orbitals/index.html +72 -72
- package/lib/examples/basic-wrapper/index.html +137 -137
- package/lib/examples/lighting/index.html +88 -88
- package/lib/examples/lighting/index.js +1 -1
- package/lib/examples/proteopedia-wrapper/index.html +236 -236
- package/lib/extensions/anvil/behavior.d.ts +1 -0
- package/lib/extensions/cellpack/model.js +2 -1
- package/lib/extensions/dnatco/confal-pyramids/behavior.d.ts +1 -0
- package/lib/extensions/meshes/choice.d.ts +26 -0
- package/lib/extensions/meshes/choice.js +28 -0
- package/lib/extensions/meshes/examples.d.ts +26 -0
- package/lib/extensions/meshes/examples.js +325 -0
- package/lib/extensions/meshes/mesh-cif-schema.d.ts +29 -0
- package/lib/extensions/meshes/mesh-cif-schema.js +30 -0
- package/lib/extensions/meshes/mesh-extension.d.ts +66 -0
- package/lib/extensions/meshes/mesh-extension.js +218 -0
- package/lib/extensions/meshes/mesh-streaming/behavior.d.ts +105 -0
- package/lib/extensions/meshes/mesh-streaming/behavior.js +375 -0
- package/lib/extensions/meshes/mesh-streaming/server-info.d.ts +54 -0
- package/lib/extensions/meshes/mesh-streaming/server-info.js +26 -0
- package/lib/extensions/meshes/mesh-streaming/transformers.d.ts +42 -0
- package/lib/extensions/meshes/mesh-streaming/transformers.js +270 -0
- package/lib/extensions/meshes/mesh-utils.d.ts +41 -0
- package/lib/extensions/meshes/mesh-utils.js +346 -0
- package/lib/extensions/meshes/metadata.d.ts +108 -0
- package/lib/extensions/meshes/metadata.js +69 -0
- package/lib/extensions/model-archive/quality-assessment/behavior.d.ts +2 -0
- package/lib/extensions/model-archive/quality-assessment/prop.d.ts +1 -0
- package/lib/extensions/model-archive/quality-assessment/prop.js +16 -4
- package/lib/extensions/rcsb/assembly-symmetry/behavior.d.ts +4 -2
- package/lib/extensions/rcsb/validation-report/behavior.d.ts +3 -0
- package/lib/extensions/volumes-and-segmentations/entry-meshes.d.ts +17 -0
- package/lib/extensions/volumes-and-segmentations/entry-meshes.js +153 -0
- package/lib/extensions/volumes-and-segmentations/entry-models.d.ts +12 -0
- package/lib/extensions/volumes-and-segmentations/entry-models.js +93 -0
- package/lib/extensions/volumes-and-segmentations/entry-root.d.ts +122 -0
- package/lib/extensions/volumes-and-segmentations/entry-root.js +571 -0
- package/lib/extensions/volumes-and-segmentations/entry-segmentation.d.ts +20 -0
- package/lib/extensions/volumes-and-segmentations/entry-segmentation.js +197 -0
- package/lib/extensions/volumes-and-segmentations/entry-state.d.ts +88 -0
- package/lib/extensions/volumes-and-segmentations/entry-state.js +29 -0
- package/lib/extensions/volumes-and-segmentations/entry-volume.d.ts +35 -0
- package/lib/extensions/volumes-and-segmentations/entry-volume.js +231 -0
- package/lib/extensions/volumes-and-segmentations/external-api.d.ts +11 -0
- package/lib/extensions/volumes-and-segmentations/external-api.js +80 -0
- package/lib/extensions/volumes-and-segmentations/global-state.d.ts +51 -0
- package/lib/extensions/volumes-and-segmentations/global-state.js +80 -0
- package/lib/extensions/volumes-and-segmentations/helpers.d.ts +56 -0
- package/lib/extensions/volumes-and-segmentations/helpers.js +163 -0
- package/lib/extensions/volumes-and-segmentations/index.d.ts +20 -0
- package/lib/extensions/volumes-and-segmentations/index.js +127 -0
- package/lib/extensions/volumes-and-segmentations/transformers.d.ts +33 -0
- package/lib/extensions/volumes-and-segmentations/transformers.js +82 -0
- package/lib/extensions/volumes-and-segmentations/ui.d.ts +29 -0
- package/lib/extensions/volumes-and-segmentations/ui.js +229 -0
- package/lib/extensions/volumes-and-segmentations/volseg-api/api.d.ts +22 -0
- package/lib/extensions/volumes-and-segmentations/volseg-api/api.js +80 -0
- package/lib/extensions/volumes-and-segmentations/volseg-api/data.d.ts +92 -0
- package/lib/extensions/volumes-and-segmentations/volseg-api/data.js +6 -0
- package/lib/extensions/volumes-and-segmentations/volseg-api/utils.d.ts +23 -0
- package/lib/extensions/volumes-and-segmentations/volseg-api/utils.js +75 -0
- package/lib/mol-canvas3d/canvas3d.d.ts +2 -0
- package/lib/mol-canvas3d/passes/draw.js +3 -3
- package/lib/mol-canvas3d/passes/image.d.ts +1 -0
- package/lib/mol-canvas3d/passes/postprocessing.d.ts +2 -1
- package/lib/mol-canvas3d/passes/postprocessing.js +27 -13
- package/lib/mol-geo/geometry/cylinders/cylinders.d.ts +2 -1
- package/lib/mol-geo/geometry/cylinders/cylinders.js +3 -2
- package/lib/mol-geo/geometry/lines/lines.d.ts +0 -1
- package/lib/mol-geo/geometry/points/points.d.ts +1 -1
- package/lib/mol-geo/geometry/spheres/spheres.d.ts +1 -0
- package/lib/mol-geo/geometry/spheres/spheres.js +3 -2
- package/lib/mol-gl/compute/histogram-pyramid/reduction.js +1 -2
- package/lib/mol-gl/compute/marching-cubes/isosurface.js +4 -6
- package/lib/mol-gl/renderable/cylinders.d.ts +1 -0
- package/lib/mol-gl/renderable/cylinders.js +1 -1
- package/lib/mol-gl/renderable/spheres.d.ts +1 -0
- package/lib/mol-gl/renderable/spheres.js +1 -1
- package/lib/mol-gl/shader/chunks/apply-light-color.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/apply-light-color.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/clip-instance.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/clip-instance.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/clip-pixel.glsl.d.ts +1 -1
- package/lib/mol-gl/shader/chunks/clip-pixel.glsl.js +1 -1
- package/lib/mol-gl/shader/chunks/common-clip.glsl.d.ts +2 -2
- package/lib/mol-gl/shader/chunks/common-clip.glsl.js +2 -2
- package/lib/mol-gl/shader/cylinders.frag.d.ts +1 -1
- package/lib/mol-gl/shader/cylinders.frag.js +1 -1
- package/lib/mol-gl/shader/cylinders.vert.d.ts +2 -2
- package/lib/mol-gl/shader/cylinders.vert.js +2 -2
- package/lib/mol-gl/shader/direct-volume.frag.d.ts +1 -1
- package/lib/mol-gl/shader/direct-volume.frag.js +1 -1
- package/lib/mol-gl/shader/outlines.frag.d.ts +1 -1
- package/lib/mol-gl/shader/outlines.frag.js +1 -1
- package/lib/mol-gl/shader/postprocessing.frag.d.ts +1 -1
- package/lib/mol-gl/shader/postprocessing.frag.js +1 -1
- package/lib/mol-gl/shader/spheres.frag.d.ts +1 -1
- package/lib/mol-gl/shader/spheres.frag.js +1 -1
- package/lib/mol-gl/shader/spheres.vert.d.ts +2 -2
- package/lib/mol-gl/shader/spheres.vert.js +2 -2
- package/lib/mol-gl/webgl/renderbuffer.d.ts +1 -1
- package/lib/mol-gl/webgl/renderbuffer.js +15 -0
- package/lib/mol-gl/webgl/state.d.ts +12 -0
- package/lib/mol-gl/webgl/state.js +136 -0
- package/lib/mol-io/reader/cif/schema/segmentation.d.ts +38 -0
- package/lib/mol-io/reader/cif/schema/segmentation.js +19 -0
- package/lib/mol-io/reader/cif.d.ts +3 -1
- package/lib/mol-io/reader/cif.js +3 -1
- package/lib/mol-model/location.d.ts +2 -1
- package/lib/mol-model/loci.d.ts +11 -11
- package/lib/mol-model/loci.js +13 -1
- package/lib/mol-model/sequence/alignment/sequence.d.ts +4 -1
- package/lib/mol-model/sequence/alignment/sequence.js +3 -2
- package/lib/mol-model/structure/model/properties/atomic/hierarchy.d.ts +6 -0
- package/lib/mol-model/structure/model/properties/utils/atomic-index.js +8 -0
- package/lib/mol-model/structure/structure/unit/bonds/inter-compute.js +21 -5
- package/lib/mol-model/structure/structure/util/superposition.d.ts +1 -0
- package/lib/mol-model/structure/structure/util/superposition.js +1 -1
- package/lib/mol-model/volume/volume.d.ts +35 -2
- package/lib/mol-model/volume/volume.js +79 -4
- package/lib/mol-model-formats/volume/segmentation.d.ts +23 -0
- package/lib/mol-model-formats/volume/segmentation.js +135 -0
- package/lib/mol-plugin/behavior/dynamic/representation.d.ts +2 -2
- package/lib/mol-plugin/behavior/dynamic/selection/structure-focus-representation.d.ts +1 -0
- package/lib/mol-plugin/behavior/dynamic/selection/structure-focus-representation.js +2 -1
- package/lib/mol-plugin/behavior/dynamic/volume-streaming/model.d.ts +2 -3
- package/lib/mol-plugin/commands.d.ts +1 -0
- package/lib/mol-plugin/version.js +2 -2
- package/lib/mol-plugin-state/animation/built-in/model-index.js +4 -1
- package/lib/mol-plugin-state/builder/structure/hierarchy-preset.d.ts +2 -0
- package/lib/mol-plugin-state/builder/structure/hierarchy.d.ts +1 -0
- package/lib/mol-plugin-state/builder/structure/representation-preset.d.ts +13 -4
- package/lib/mol-plugin-state/builder/structure/representation-preset.js +6 -1
- package/lib/mol-plugin-state/builder/structure/representation.d.ts +1 -0
- package/lib/mol-plugin-state/formats/provider.d.ts +2 -2
- package/lib/mol-plugin-state/formats/provider.js +11 -3
- package/lib/mol-plugin-state/formats/registry.js +6 -5
- package/lib/mol-plugin-state/formats/volume.d.ts +27 -0
- package/lib/mol-plugin-state/formats/volume.js +64 -0
- package/lib/mol-plugin-state/manager/structure/component.d.ts +1 -1
- package/lib/mol-plugin-state/manager/structure/component.js +18 -13
- package/lib/mol-plugin-state/transforms/representation.d.ts +1 -2
- package/lib/mol-plugin-state/transforms/representation.js +5 -6
- package/lib/mol-plugin-state/transforms/volume.d.ts +11 -1
- package/lib/mol-plugin-state/transforms/volume.js +54 -1
- package/lib/mol-plugin-ui/controls/line-graph/line-graph-component.d.ts +1 -0
- package/lib/mol-plugin-ui/controls/line-graph/line-graph-component.js +33 -13
- package/lib/mol-plugin-ui/controls/parameters.d.ts +1 -0
- package/lib/mol-plugin-ui/controls/parameters.js +22 -5
- package/lib/mol-plugin-ui/sequence/sequence.d.ts +25 -17
- package/lib/mol-plugin-ui/sequence.d.ts +19 -1
- package/lib/mol-plugin-ui/sequence.js +7 -7
- package/lib/mol-plugin-ui/skin/base/base.scss +32 -32
- package/lib/mol-plugin-ui/skin/base/components/controls-base.scss +333 -333
- package/lib/mol-plugin-ui/skin/base/components/controls.scss +418 -418
- package/lib/mol-plugin-ui/skin/base/components/help.scss +27 -27
- package/lib/mol-plugin-ui/skin/base/components/line-graph.scss +67 -67
- package/lib/mol-plugin-ui/skin/base/components/log.scss +100 -100
- package/lib/mol-plugin-ui/skin/base/components/misc.scss +643 -643
- package/lib/mol-plugin-ui/skin/base/components/sequence.scss +125 -125
- package/lib/mol-plugin-ui/skin/base/components/slider.scss +165 -165
- package/lib/mol-plugin-ui/skin/base/components/tasks.scss +99 -99
- package/lib/mol-plugin-ui/skin/base/components/toast.scss +83 -83
- package/lib/mol-plugin-ui/skin/base/components/transformer.scss +163 -163
- package/lib/mol-plugin-ui/skin/base/components/viewport.scss +137 -128
- package/lib/mol-plugin-ui/skin/base/layout/common.scss +71 -71
- package/lib/mol-plugin-ui/skin/base/layout/controls-landscape.scss +89 -89
- package/lib/mol-plugin-ui/skin/base/layout/controls-outside.scss +98 -98
- package/lib/mol-plugin-ui/skin/base/layout/controls-portrait.scss +108 -108
- package/lib/mol-plugin-ui/skin/base/layout.scss +40 -40
- package/lib/mol-plugin-ui/skin/base/logo.scss +12 -12
- package/lib/mol-plugin-ui/skin/base/normalize.scss +209 -209
- package/lib/mol-plugin-ui/skin/base/ui.scss +40 -40
- package/lib/mol-plugin-ui/skin/base/variables.scss +85 -85
- package/lib/mol-plugin-ui/skin/blue.scss +1 -1
- package/lib/mol-plugin-ui/skin/colors/blue.scss +23 -23
- package/lib/mol-plugin-ui/skin/colors/dark.scss +23 -23
- package/lib/mol-plugin-ui/skin/colors/light.scss +29 -29
- package/lib/mol-plugin-ui/skin/dark.scss +1 -1
- package/lib/mol-plugin-ui/skin/light.scss +1 -1
- package/lib/mol-plugin-ui/state/apply-action.d.ts +2 -10
- package/lib/mol-plugin-ui/state/apply-action.js +2 -2
- package/lib/mol-plugin-ui/structure/quick-styles.js +2 -2
- package/lib/mol-plugin-ui/structure/superposition.d.ts +1 -1
- package/lib/mol-plugin-ui/structure/volume.d.ts +1 -1
- package/lib/mol-plugin-ui/structure/volume.js +3 -2
- package/lib/mol-repr/structure/complex-visual.d.ts +1 -0
- package/lib/mol-repr/structure/params.d.ts +2 -0
- package/lib/mol-repr/structure/registry.d.ts +12 -0
- package/lib/mol-repr/structure/representation/backbone.d.ts +3 -0
- package/lib/mol-repr/structure/representation/ball-and-stick.d.ts +6 -0
- package/lib/mol-repr/structure/representation/ellipsoid.d.ts +6 -0
- package/lib/mol-repr/structure/representation/gaussian-surface.d.ts +3 -0
- package/lib/mol-repr/structure/representation/gaussian-volume.d.ts +3 -0
- package/lib/mol-repr/structure/representation/line.d.ts +3 -0
- package/lib/mol-repr/structure/representation/molecular-surface.d.ts +3 -0
- package/lib/mol-repr/structure/representation/point.d.ts +3 -0
- package/lib/mol-repr/structure/representation/spacefill.d.ts +6 -0
- package/lib/mol-repr/structure/units-visual.d.ts +2 -0
- package/lib/mol-repr/structure/visual/bond-inter-unit-cylinder.d.ts +4 -0
- package/lib/mol-repr/structure/visual/bond-inter-unit-cylinder.js +2 -0
- package/lib/mol-repr/structure/visual/bond-inter-unit-line.d.ts +1 -0
- package/lib/mol-repr/structure/visual/bond-inter-unit-line.js +1 -0
- package/lib/mol-repr/structure/visual/bond-intra-unit-cylinder.d.ts +4 -0
- package/lib/mol-repr/structure/visual/bond-intra-unit-cylinder.js +2 -0
- package/lib/mol-repr/structure/visual/bond-intra-unit-line.d.ts +1 -0
- package/lib/mol-repr/structure/visual/bond-intra-unit-line.js +1 -0
- package/lib/mol-repr/structure/visual/element-cross.d.ts +1 -0
- package/lib/mol-repr/structure/visual/element-cross.js +2 -1
- package/lib/mol-repr/structure/visual/element-point.d.ts +1 -0
- package/lib/mol-repr/structure/visual/element-point.js +2 -1
- package/lib/mol-repr/structure/visual/element-sphere.d.ts +4 -0
- package/lib/mol-repr/structure/visual/element-sphere.js +3 -1
- package/lib/mol-repr/structure/visual/gaussian-density-volume.d.ts +2 -0
- package/lib/mol-repr/structure/visual/gaussian-density-volume.js +6 -2
- package/lib/mol-repr/structure/visual/gaussian-surface-mesh.d.ts +4 -0
- package/lib/mol-repr/structure/visual/gaussian-surface-mesh.js +9 -1
- package/lib/mol-repr/structure/visual/gaussian-surface-wireframe.d.ts +1 -0
- package/lib/mol-repr/structure/visual/gaussian-surface-wireframe.js +3 -1
- package/lib/mol-repr/structure/visual/molecular-surface-mesh.d.ts +1 -0
- package/lib/mol-repr/structure/visual/molecular-surface-mesh.js +4 -0
- package/lib/mol-repr/structure/visual/molecular-surface-wireframe.d.ts +1 -0
- package/lib/mol-repr/structure/visual/molecular-surface-wireframe.js +2 -0
- package/lib/mol-repr/structure/visual/polymer-backbone-cylinder.d.ts +2 -0
- package/lib/mol-repr/structure/visual/polymer-backbone-sphere.d.ts +2 -0
- package/lib/mol-repr/structure/visual/util/bond.d.ts +7 -0
- package/lib/mol-repr/structure/visual/util/bond.js +19 -8
- package/lib/mol-repr/structure/visual/util/common.d.ts +4 -1
- package/lib/mol-repr/structure/visual/util/common.js +10 -6
- package/lib/mol-repr/structure/visual/util/element.d.ts +1 -0
- package/lib/mol-repr/structure/visual/util/element.js +3 -4
- package/lib/mol-repr/structure/visual/util/gaussian.d.ts +2 -0
- package/lib/mol-repr/volume/direct-volume.d.ts +4 -4
- package/lib/mol-repr/volume/direct-volume.js +8 -6
- package/lib/mol-repr/volume/isosurface.d.ts +4 -4
- package/lib/mol-repr/volume/isosurface.js +17 -16
- package/lib/mol-repr/volume/registry.d.ts +54 -1
- package/lib/mol-repr/volume/registry.js +3 -1
- package/lib/mol-repr/volume/representation.d.ts +11 -7
- package/lib/mol-repr/volume/representation.js +144 -49
- package/lib/mol-repr/volume/segment.d.ts +291 -0
- package/lib/mol-repr/volume/segment.js +279 -0
- package/lib/mol-repr/volume/slice.d.ts +2 -2
- package/lib/mol-repr/volume/slice.js +5 -5
- package/lib/mol-repr/volume/util.d.ts +12 -3
- package/lib/mol-repr/volume/util.js +71 -6
- package/lib/mol-script/language/builder.d.ts +1 -0
- package/lib/mol-theme/color/volume-segment.d.ts +41 -0
- package/lib/mol-theme/color/volume-segment.js +53 -0
- package/lib/mol-theme/color/volume-value.js +2 -1
- package/lib/mol-theme/color.d.ts +15 -0
- package/lib/mol-theme/color.js +2 -0
- package/lib/mol-theme/label.d.ts +1 -1
- package/lib/mol-theme/label.js +13 -1
- package/lib/mol-util/param-definition.d.ts +4 -1
- package/lib/mol-util/param-definition.js +5 -2
- package/package.json +169 -168
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
4
|
+
*
|
|
5
|
+
* @author Adam Midlik <midlik@gmail.com>
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.InitMeshStreaming = exports.MeshVisualTransformer = exports.MeshVisualGroupTransformer = exports.MeshStreamingTransformer = exports.MeshServerTransformer = exports.FOREROUND_OPACITY = exports.BACKGROUND_OPACITY = void 0;
|
|
9
|
+
var tslib_1 = require("tslib");
|
|
10
|
+
var mesh_1 = require("../../../mol-geo/geometry/mesh/mesh");
|
|
11
|
+
var objects_1 = require("../../../mol-plugin-state/objects");
|
|
12
|
+
var representation_1 = require("../../../mol-repr/shape/representation");
|
|
13
|
+
var mol_state_1 = require("../../../mol-state");
|
|
14
|
+
var mol_task_1 = require("../../../mol-task");
|
|
15
|
+
var mol_util_1 = require("../../../mol-util");
|
|
16
|
+
var param_definition_1 = require("../../../mol-util/param-definition");
|
|
17
|
+
var mesh_extension_1 = require("../mesh-extension");
|
|
18
|
+
var behavior_1 = require("./behavior");
|
|
19
|
+
var server_info_1 = require("./server-info");
|
|
20
|
+
exports.BACKGROUND_OPACITY = 0.2;
|
|
21
|
+
exports.FOREROUND_OPACITY = 1;
|
|
22
|
+
// // // // // // // // // // // // // // // // // // // // // // // //
|
|
23
|
+
exports.MeshServerTransformer = (0, mesh_extension_1.VolsegTransform)({
|
|
24
|
+
name: 'mesh-server-info',
|
|
25
|
+
from: objects_1.PluginStateObject.Root,
|
|
26
|
+
to: server_info_1.MeshServerInfo,
|
|
27
|
+
params: server_info_1.MeshServerInfo.Params,
|
|
28
|
+
})({
|
|
29
|
+
apply: function (_a, plugin) {
|
|
30
|
+
var a = _a.a, params = _a.params;
|
|
31
|
+
params.serverUrl = params.serverUrl.replace(/\/*$/, ''); // trim trailing slash
|
|
32
|
+
var description = params.entryId;
|
|
33
|
+
return new server_info_1.MeshServerInfo(tslib_1.__assign({}, params), { label: 'Mesh Server', description: description });
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
// // // // // // // // // // // // // // // // // // // // // // // //
|
|
37
|
+
exports.MeshStreamingTransformer = (0, mesh_extension_1.VolsegTransform)({
|
|
38
|
+
name: 'mesh-streaming-from-server-info',
|
|
39
|
+
display: { name: 'Mesh Streaming' },
|
|
40
|
+
from: server_info_1.MeshServerInfo,
|
|
41
|
+
to: behavior_1.MeshStreaming,
|
|
42
|
+
params: function (a) { return behavior_1.MeshStreaming.Params.create(a.data); },
|
|
43
|
+
})({
|
|
44
|
+
canAutoUpdate: function () { return true; },
|
|
45
|
+
apply: function (_a, plugin) {
|
|
46
|
+
var _this = this;
|
|
47
|
+
var a = _a.a, params = _a.params;
|
|
48
|
+
return mol_task_1.Task.create('Mesh Streaming', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
49
|
+
var behavior;
|
|
50
|
+
return tslib_1.__generator(this, function (_a) {
|
|
51
|
+
switch (_a.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
behavior = new behavior_1.MeshStreaming.Behavior(plugin, a.data, params);
|
|
54
|
+
return [4 /*yield*/, behavior.update(params)];
|
|
55
|
+
case 1:
|
|
56
|
+
_a.sent();
|
|
57
|
+
return [2 /*return*/, new behavior_1.MeshStreaming(behavior, { label: 'Mesh Streaming', description: behavior.getDescription() })];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}); });
|
|
61
|
+
},
|
|
62
|
+
update: function (_a) {
|
|
63
|
+
var _this = this;
|
|
64
|
+
var a = _a.a, b = _a.b, oldParams = _a.oldParams, newParams = _a.newParams;
|
|
65
|
+
return mol_task_1.Task.create('Update Mesh Streaming', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
66
|
+
return tslib_1.__generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
if (a.data.source !== b.data.parentData.source || a.data.entryId !== b.data.parentData.entryId) {
|
|
70
|
+
return [2 /*return*/, mol_state_1.StateTransformer.UpdateResult.Recreate];
|
|
71
|
+
}
|
|
72
|
+
b.data.parentData = a.data;
|
|
73
|
+
return [4 /*yield*/, b.data.update(newParams)];
|
|
74
|
+
case 1:
|
|
75
|
+
_a.sent();
|
|
76
|
+
b.description = b.data.getDescription();
|
|
77
|
+
return [2 /*return*/, mol_state_1.StateTransformer.UpdateResult.Updated];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}); });
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
// export type MeshVisualGroupTransformer = typeof MeshVisualGroupTransformer;
|
|
84
|
+
exports.MeshVisualGroupTransformer = (0, mesh_extension_1.VolsegTransform)({
|
|
85
|
+
name: 'mesh-visual-group-from-streaming',
|
|
86
|
+
display: { name: 'Mesh Visuals for a Segment' },
|
|
87
|
+
from: behavior_1.MeshStreaming,
|
|
88
|
+
to: objects_1.PluginStateObject.Group,
|
|
89
|
+
params: {
|
|
90
|
+
/** Shown on the node in GUI */
|
|
91
|
+
label: param_definition_1.ParamDefinition.Text('', { isHidden: true }),
|
|
92
|
+
/** Shown on the node in GUI (gray letters) */
|
|
93
|
+
description: param_definition_1.ParamDefinition.Text(''),
|
|
94
|
+
segmentId: param_definition_1.ParamDefinition.Numeric(behavior_1.NO_SEGMENT, {}, { isHidden: true }),
|
|
95
|
+
opacity: param_definition_1.ParamDefinition.Numeric(-1, { min: 0, max: 1, step: 0.01 }),
|
|
96
|
+
}
|
|
97
|
+
})({
|
|
98
|
+
apply: function (_a, plugin) {
|
|
99
|
+
var a = _a.a, params = _a.params;
|
|
100
|
+
trySetAutoOpacity(params, a);
|
|
101
|
+
return new objects_1.PluginStateObject.Group({ opacity: params.opacity }, params);
|
|
102
|
+
},
|
|
103
|
+
update: function (_a, plugin) {
|
|
104
|
+
var a = _a.a, b = _a.b, oldParams = _a.oldParams, newParams = _a.newParams;
|
|
105
|
+
if ((0, mol_util_1.shallowEqualObjects)(oldParams, newParams)) {
|
|
106
|
+
return mol_state_1.StateTransformer.UpdateResult.Unchanged;
|
|
107
|
+
}
|
|
108
|
+
newParams.label || (newParams.label = oldParams.label); // Protect against resetting params to invalid defaults
|
|
109
|
+
if (newParams.segmentId === behavior_1.NO_SEGMENT)
|
|
110
|
+
newParams.segmentId = oldParams.segmentId; // Protect against resetting params to invalid defaults
|
|
111
|
+
trySetAutoOpacity(newParams, a);
|
|
112
|
+
b.label = newParams.label;
|
|
113
|
+
b.description = newParams.description;
|
|
114
|
+
b.data.opacity = newParams.opacity;
|
|
115
|
+
return mol_state_1.StateTransformer.UpdateResult.Updated;
|
|
116
|
+
},
|
|
117
|
+
canAutoUpdate: function (_a, plugin) {
|
|
118
|
+
var oldParams = _a.oldParams, newParams = _a.newParams;
|
|
119
|
+
return newParams.description === oldParams.description;
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
function trySetAutoOpacity(params, parent) {
|
|
123
|
+
if (params.opacity === -1) {
|
|
124
|
+
var isBgSegment = parent.data.backgroundSegments[params.segmentId];
|
|
125
|
+
if (isBgSegment !== undefined) {
|
|
126
|
+
params.opacity = isBgSegment ? exports.BACKGROUND_OPACITY : exports.FOREROUND_OPACITY;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// // // // // // // // // // // // // // // // // // // // // // // //
|
|
131
|
+
exports.MeshVisualTransformer = (0, mesh_extension_1.VolsegTransform)({
|
|
132
|
+
name: 'mesh-visual-from-streaming',
|
|
133
|
+
display: { name: 'Mesh Visual from Streaming' },
|
|
134
|
+
from: behavior_1.MeshStreaming,
|
|
135
|
+
to: objects_1.PluginStateObject.Shape.Representation3D,
|
|
136
|
+
params: {
|
|
137
|
+
/** Must be set to PluginStateObject reference to self */
|
|
138
|
+
ref: param_definition_1.ParamDefinition.Text('', { isHidden: true, isEssential: true }),
|
|
139
|
+
/** Identification of the mesh visual, e.g. 'low-2' */
|
|
140
|
+
tag: param_definition_1.ParamDefinition.Text('', { isHidden: true, isEssential: true }),
|
|
141
|
+
/** Opacity of the visual (not to be set directly, but controlled by the opacity of the parent Group, and by VisualInfo.visible) */
|
|
142
|
+
opacity: param_definition_1.ParamDefinition.Numeric(-1, { min: 0, max: 1, step: 0.01 }, { isHidden: true }),
|
|
143
|
+
}
|
|
144
|
+
})({
|
|
145
|
+
apply: function (_a, plugin) {
|
|
146
|
+
var _this = this;
|
|
147
|
+
var a = _a.a, params = _a.params, spine = _a.spine;
|
|
148
|
+
return mol_task_1.Task.create('Mesh Visual', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
149
|
+
var visualInfo, groupData, props, repr;
|
|
150
|
+
var _a, _b, _c;
|
|
151
|
+
return tslib_1.__generator(this, function (_d) {
|
|
152
|
+
switch (_d.label) {
|
|
153
|
+
case 0:
|
|
154
|
+
visualInfo = a.data.visuals[params.tag];
|
|
155
|
+
if (!visualInfo)
|
|
156
|
+
throw new Error("VisualInfo with tag '".concat(params.tag, "' is missing."));
|
|
157
|
+
groupData = (_a = spine.getAncestorOfType(objects_1.PluginStateObject.Group)) === null || _a === void 0 ? void 0 : _a.data;
|
|
158
|
+
params.opacity = visualInfo.visible ? ((_b = groupData === null || groupData === void 0 ? void 0 : groupData.opacity) !== null && _b !== void 0 ? _b : exports.FOREROUND_OPACITY) : 0.0;
|
|
159
|
+
props = param_definition_1.ParamDefinition.getDefaultValues(mesh_1.Mesh.Params);
|
|
160
|
+
props.flatShaded = true; // `flatShaded: true` is to see the real mesh vertices and triangles (default: false)
|
|
161
|
+
props.alpha = params.opacity;
|
|
162
|
+
repr = (0, representation_1.ShapeRepresentation)(function (ctx, meshlist) { return mesh_extension_1.MeshlistData.getShape(meshlist, visualInfo.color); }, mesh_1.Mesh.Utils);
|
|
163
|
+
return [4 /*yield*/, repr.createOrUpdate(props, (_c = visualInfo.data) !== null && _c !== void 0 ? _c : mesh_extension_1.MeshlistData.empty()).runInContext(ctx)];
|
|
164
|
+
case 1:
|
|
165
|
+
_d.sent();
|
|
166
|
+
return [2 /*return*/, new objects_1.PluginStateObject.Shape.Representation3D({ repr: repr, sourceData: visualInfo.data }, { label: 'Mesh Visual', description: params.tag })];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}); });
|
|
170
|
+
},
|
|
171
|
+
update: function (_a, plugin) {
|
|
172
|
+
var _this = this;
|
|
173
|
+
var a = _a.a, b = _a.b, oldParams = _a.oldParams, newParams = _a.newParams, spine = _a.spine;
|
|
174
|
+
return mol_task_1.Task.create('Update Mesh Visual', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
175
|
+
var visualInfo, oldData, groupData, newOpacity;
|
|
176
|
+
var _a, _b, _c;
|
|
177
|
+
return tslib_1.__generator(this, function (_d) {
|
|
178
|
+
switch (_d.label) {
|
|
179
|
+
case 0:
|
|
180
|
+
newParams.ref || (newParams.ref = oldParams.ref); // Protect against resetting params to invalid defaults
|
|
181
|
+
newParams.tag || (newParams.tag = oldParams.tag); // Protect against resetting params to invalid defaults
|
|
182
|
+
visualInfo = a.data.visuals[newParams.tag];
|
|
183
|
+
if (!visualInfo)
|
|
184
|
+
throw new Error("VisualInfo with tag '".concat(newParams.tag, "' is missing."));
|
|
185
|
+
oldData = b.data.sourceData;
|
|
186
|
+
if (((_a = visualInfo.data) === null || _a === void 0 ? void 0 : _a.detail) !== (oldData === null || oldData === void 0 ? void 0 : oldData.detail)) {
|
|
187
|
+
return [2 /*return*/, mol_state_1.StateTransformer.UpdateResult.Recreate];
|
|
188
|
+
}
|
|
189
|
+
groupData = (_b = spine.getAncestorOfType(objects_1.PluginStateObject.Group)) === null || _b === void 0 ? void 0 : _b.data;
|
|
190
|
+
newOpacity = visualInfo.visible ? ((_c = groupData === null || groupData === void 0 ? void 0 : groupData.opacity) !== null && _c !== void 0 ? _c : exports.FOREROUND_OPACITY) : 0.0;
|
|
191
|
+
if (!(newOpacity !== oldParams.opacity)) return [3 /*break*/, 2];
|
|
192
|
+
newParams.opacity = newOpacity;
|
|
193
|
+
return [4 /*yield*/, b.data.repr.createOrUpdate({ alpha: newParams.opacity }).runInContext(ctx)];
|
|
194
|
+
case 1:
|
|
195
|
+
_d.sent();
|
|
196
|
+
return [2 /*return*/, mol_state_1.StateTransformer.UpdateResult.Updated];
|
|
197
|
+
case 2: return [2 /*return*/, mol_state_1.StateTransformer.UpdateResult.Unchanged];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}); });
|
|
201
|
+
},
|
|
202
|
+
canAutoUpdate: function (params, globalCtx) {
|
|
203
|
+
return true;
|
|
204
|
+
},
|
|
205
|
+
dispose: function (_a, plugin) {
|
|
206
|
+
var b = _a.b, params = _a.params;
|
|
207
|
+
b === null || b === void 0 ? void 0 : b.data.repr.destroy(); // QUESTION is this correct?
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
// // // // // // // // // // // // // // // // // // // // // // // //
|
|
211
|
+
exports.InitMeshStreaming = mol_state_1.StateAction.build({
|
|
212
|
+
display: { name: 'Mesh Streaming' },
|
|
213
|
+
from: objects_1.PluginStateObject.Root,
|
|
214
|
+
params: server_info_1.MeshServerInfo.Params,
|
|
215
|
+
isApplicable: function (a, _, plugin) { return true; }
|
|
216
|
+
})(function (p, plugin) {
|
|
217
|
+
var _this = this;
|
|
218
|
+
return mol_task_1.Task.create('Mesh Streaming', function (ctx) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
219
|
+
var params, serverNode, streamingNode, visuals, bgSegments, segmentGroups, _a, _b, _c, _i, tag, segid, description, group, visualsUpdate, tag, ref, segid;
|
|
220
|
+
var _d, _e, _f, _g;
|
|
221
|
+
return tslib_1.__generator(this, function (_h) {
|
|
222
|
+
switch (_h.label) {
|
|
223
|
+
case 0:
|
|
224
|
+
params = p.params;
|
|
225
|
+
return [4 /*yield*/, plugin.build().to(p.ref).apply(exports.MeshServerTransformer, params).commit()];
|
|
226
|
+
case 1:
|
|
227
|
+
serverNode = _h.sent();
|
|
228
|
+
return [4 /*yield*/, plugin.build().to(serverNode).apply(exports.MeshStreamingTransformer, {}).commit()];
|
|
229
|
+
case 2:
|
|
230
|
+
streamingNode = _h.sent();
|
|
231
|
+
visuals = (_e = (_d = streamingNode.data) === null || _d === void 0 ? void 0 : _d.visuals) !== null && _e !== void 0 ? _e : {};
|
|
232
|
+
bgSegments = (_g = (_f = streamingNode.data) === null || _f === void 0 ? void 0 : _f.backgroundSegments) !== null && _g !== void 0 ? _g : {};
|
|
233
|
+
segmentGroups = {};
|
|
234
|
+
_a = visuals;
|
|
235
|
+
_b = [];
|
|
236
|
+
for (_c in _a)
|
|
237
|
+
_b.push(_c);
|
|
238
|
+
_i = 0;
|
|
239
|
+
_h.label = 3;
|
|
240
|
+
case 3:
|
|
241
|
+
if (!(_i < _b.length)) return [3 /*break*/, 6];
|
|
242
|
+
_c = _b[_i];
|
|
243
|
+
if (!(_c in _a)) return [3 /*break*/, 5];
|
|
244
|
+
tag = _c;
|
|
245
|
+
segid = visuals[tag].segmentId;
|
|
246
|
+
if (!!segmentGroups[segid]) return [3 /*break*/, 5];
|
|
247
|
+
description = visuals[tag].segmentName;
|
|
248
|
+
if (bgSegments[segid])
|
|
249
|
+
description += ' (background)';
|
|
250
|
+
return [4 /*yield*/, plugin.build().to(streamingNode).apply(exports.MeshVisualGroupTransformer, { label: "Segment ".concat(segid), description: description, segmentId: segid }, { state: { isCollapsed: true } }).commit()];
|
|
251
|
+
case 4:
|
|
252
|
+
group = _h.sent();
|
|
253
|
+
segmentGroups[segid] = group.ref;
|
|
254
|
+
_h.label = 5;
|
|
255
|
+
case 5:
|
|
256
|
+
_i++;
|
|
257
|
+
return [3 /*break*/, 3];
|
|
258
|
+
case 6:
|
|
259
|
+
visualsUpdate = plugin.build();
|
|
260
|
+
for (tag in visuals) {
|
|
261
|
+
ref = "".concat(streamingNode.ref, "-").concat(tag);
|
|
262
|
+
segid = visuals[tag].segmentId;
|
|
263
|
+
visualsUpdate.to(segmentGroups[segid]).apply(exports.MeshVisualTransformer, { ref: ref, tag: tag }, { ref: ref }); // ref - hack to allow the node make itself invisible
|
|
264
|
+
}
|
|
265
|
+
return [4 /*yield*/, plugin.state.data.updateTree(visualsUpdate).runInContext(ctx)];
|
|
266
|
+
case 7:
|
|
267
|
+
_h.sent(); // QUESTION what is really the difference between this and `visualsUpdate.commit()`?
|
|
268
|
+
return [2 /*return*/];
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}); });
|
|
272
|
+
});
|
|
273
|
+
// TODO make available in GUI, in left panel or in right panel like Volume Streaming in src/mol-plugin-ui/structure/volume.tsx?
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
3
|
+
*
|
|
4
|
+
* @author Adam Midlik <midlik@gmail.com>
|
|
5
|
+
*/
|
|
6
|
+
/** Helper functions for manipulation with mesh data. */
|
|
7
|
+
import { Mesh } from '../../mol-geo/geometry/mesh/mesh';
|
|
8
|
+
import { CifFile } from '../../mol-io/reader/cif';
|
|
9
|
+
import { Box3D } from '../../mol-math/geometry';
|
|
10
|
+
import { Mat4 } from '../../mol-math/linear-algebra';
|
|
11
|
+
type MeshModificationParams = {
|
|
12
|
+
scale?: [number, number, number];
|
|
13
|
+
shift?: [number, number, number];
|
|
14
|
+
matrix?: Mat4;
|
|
15
|
+
group?: number;
|
|
16
|
+
invertSides?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** Modify mesh in-place */
|
|
19
|
+
export declare function modify(m: Mesh, params: MeshModificationParams): void;
|
|
20
|
+
/** Create a copy a mesh, possibly modified */
|
|
21
|
+
export declare function copy(m: Mesh, modification?: MeshModificationParams): Mesh;
|
|
22
|
+
/** Join more meshes into one */
|
|
23
|
+
export declare function concat(...meshes: Mesh[]): Mesh;
|
|
24
|
+
/** Return Mesh from CIF data and mesh IDs (group IDs).
|
|
25
|
+
* Assume the CIF contains coords in grid space,
|
|
26
|
+
* transform the output mesh to `space` */
|
|
27
|
+
export declare function meshFromCif(data: CifFile, invertSides?: boolean | undefined, outSpace?: 'grid' | 'fractional' | 'cartesian'): Promise<{
|
|
28
|
+
mesh: Mesh;
|
|
29
|
+
meshIds: number[];
|
|
30
|
+
}>;
|
|
31
|
+
/** Return bounding box */
|
|
32
|
+
export declare function bbox(mesh: Mesh): Box3D | null;
|
|
33
|
+
/** Example mesh - 1 triangle */
|
|
34
|
+
export declare function fakeFakeMesh1(): Mesh;
|
|
35
|
+
/** Example mesh - irregular tetrahedron */
|
|
36
|
+
export declare function fakeMesh4(): Mesh;
|
|
37
|
+
/** Return a box-shaped mesh */
|
|
38
|
+
export declare function meshFromBox(box: [[number, number, number], [number, number, number]], group?: number): Mesh;
|
|
39
|
+
/** Generate random colors (in a cycle) */
|
|
40
|
+
export declare const ColorGenerator: Generator<import("../../mol-util/color").Color, never, unknown>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
|
|
4
|
+
*
|
|
5
|
+
* @author Adam Midlik <midlik@gmail.com>
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ColorGenerator = exports.meshFromBox = exports.fakeMesh4 = exports.fakeFakeMesh1 = exports.bbox = exports.meshFromCif = exports.concat = exports.copy = exports.modify = void 0;
|
|
9
|
+
var tslib_1 = require("tslib");
|
|
10
|
+
/** Helper functions for manipulation with mesh data. */
|
|
11
|
+
var mesh_1 = require("../../mol-geo/geometry/mesh/mesh");
|
|
12
|
+
var cif_1 = require("../../mol-io/reader/cif");
|
|
13
|
+
var geometry_1 = require("../../mol-math/geometry");
|
|
14
|
+
var linear_algebra_1 = require("../../mol-math/linear-algebra");
|
|
15
|
+
var density_server_1 = require("../../mol-model-formats/volume/density-server");
|
|
16
|
+
var volume_1 = require("../../mol-model/volume");
|
|
17
|
+
var names_1 = require("../../mol-util/color/names");
|
|
18
|
+
var mesh_cif_schema_1 = require("./mesh-cif-schema");
|
|
19
|
+
/** Modify mesh in-place */
|
|
20
|
+
function modify(m, params) {
|
|
21
|
+
if (params.scale !== undefined) {
|
|
22
|
+
var _a = params.scale, qx = _a[0], qy = _a[1], qz = _a[2];
|
|
23
|
+
var vertices = m.vertexBuffer.ref.value;
|
|
24
|
+
for (var i = 0; i < vertices.length; i += 3) {
|
|
25
|
+
vertices[i] *= qx;
|
|
26
|
+
vertices[i + 1] *= qy;
|
|
27
|
+
vertices[i + 2] *= qz;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (params.shift !== undefined) {
|
|
31
|
+
var _b = params.shift, dx = _b[0], dy = _b[1], dz = _b[2];
|
|
32
|
+
var vertices = m.vertexBuffer.ref.value;
|
|
33
|
+
for (var i = 0; i < vertices.length; i += 3) {
|
|
34
|
+
vertices[i] += dx;
|
|
35
|
+
vertices[i + 1] += dy;
|
|
36
|
+
vertices[i + 2] += dz;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (params.matrix !== undefined) {
|
|
40
|
+
var r = m.vertexBuffer.ref.value;
|
|
41
|
+
var matrix = params.matrix;
|
|
42
|
+
var size = 3 * m.vertexCount;
|
|
43
|
+
for (var i = 0; i < size; i += 3) {
|
|
44
|
+
linear_algebra_1.Vec3.transformMat4Offset(r, r, matrix, i, i, 0);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (params.group !== undefined) {
|
|
48
|
+
var groups = m.groupBuffer.ref.value;
|
|
49
|
+
for (var i = 0; i < groups.length; i++) {
|
|
50
|
+
groups[i] = params.group;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (params.invertSides) {
|
|
54
|
+
var indices = m.indexBuffer.ref.value;
|
|
55
|
+
var tmp = void 0;
|
|
56
|
+
for (var i = 0; i < indices.length; i += 3) {
|
|
57
|
+
tmp = indices[i];
|
|
58
|
+
indices[i] = indices[i + 1];
|
|
59
|
+
indices[i + 1] = tmp;
|
|
60
|
+
}
|
|
61
|
+
var normals = m.normalBuffer.ref.value;
|
|
62
|
+
for (var i = 0; i < normals.length; i++) {
|
|
63
|
+
normals[i] *= -1;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.modify = modify;
|
|
68
|
+
/** Create a copy a mesh, possibly modified */
|
|
69
|
+
function copy(m, modification) {
|
|
70
|
+
var nVertices = m.vertexCount;
|
|
71
|
+
var nTriangles = m.triangleCount;
|
|
72
|
+
var vertices = new Float32Array(m.vertexBuffer.ref.value);
|
|
73
|
+
var indices = new Uint32Array(m.indexBuffer.ref.value);
|
|
74
|
+
var normals = new Float32Array(m.normalBuffer.ref.value);
|
|
75
|
+
var groups = new Float32Array(m.groupBuffer.ref.value);
|
|
76
|
+
var result = mesh_1.Mesh.create(vertices, indices, normals, groups, nVertices, nTriangles);
|
|
77
|
+
if (modification) {
|
|
78
|
+
modify(result, modification);
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
exports.copy = copy;
|
|
83
|
+
/** Join more meshes into one */
|
|
84
|
+
function concat() {
|
|
85
|
+
var meshes = [];
|
|
86
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
87
|
+
meshes[_i] = arguments[_i];
|
|
88
|
+
}
|
|
89
|
+
var nVertices = sum(meshes.map(function (m) { return m.vertexCount; }));
|
|
90
|
+
var nTriangles = sum(meshes.map(function (m) { return m.triangleCount; }));
|
|
91
|
+
var vertices = concatArrays(Float32Array, meshes.map(function (m) { return m.vertexBuffer.ref.value; }));
|
|
92
|
+
var normals = concatArrays(Float32Array, meshes.map(function (m) { return m.normalBuffer.ref.value; }));
|
|
93
|
+
var groups = concatArrays(Float32Array, meshes.map(function (m) { return m.groupBuffer.ref.value; }));
|
|
94
|
+
var newIndices = [];
|
|
95
|
+
var offset = 0;
|
|
96
|
+
for (var _a = 0, meshes_1 = meshes; _a < meshes_1.length; _a++) {
|
|
97
|
+
var m = meshes_1[_a];
|
|
98
|
+
newIndices.push(m.indexBuffer.ref.value.map(function (i) { return i + offset; }));
|
|
99
|
+
offset += m.vertexCount;
|
|
100
|
+
}
|
|
101
|
+
var indices = concatArrays(Uint32Array, newIndices);
|
|
102
|
+
return mesh_1.Mesh.create(vertices, indices, normals, groups, nVertices, nTriangles);
|
|
103
|
+
}
|
|
104
|
+
exports.concat = concat;
|
|
105
|
+
/** Return Mesh from CIF data and mesh IDs (group IDs).
|
|
106
|
+
* Assume the CIF contains coords in grid space,
|
|
107
|
+
* transform the output mesh to `space` */
|
|
108
|
+
function meshFromCif(data, invertSides, outSpace) {
|
|
109
|
+
if (invertSides === void 0) { invertSides = undefined; }
|
|
110
|
+
if (outSpace === void 0) { outSpace = 'cartesian'; }
|
|
111
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
112
|
+
var volumeInfoBlock, meshesBlock, volumeInfoCif, meshCif, nVertices, nTriangles, mesh_id, vertex_meshId, x, y, z, triangle_meshId, triangle_vertexId, indices, offsets, i, offset, vertices, normals, groups, mesh, volume, gridToCartesian, gridSize, originFract, dimensionFract, scale;
|
|
113
|
+
return tslib_1.__generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
volumeInfoBlock = data.blocks.find(function (b) { return b.header === 'VOLUME_INFO'; });
|
|
117
|
+
meshesBlock = data.blocks.find(function (b) { return b.header === 'MESHES'; });
|
|
118
|
+
if (!volumeInfoBlock || !meshesBlock)
|
|
119
|
+
throw new Error('Missing VOLUME_INFO or MESHES block in mesh CIF file');
|
|
120
|
+
volumeInfoCif = cif_1.CIF.schema.densityServer(volumeInfoBlock);
|
|
121
|
+
meshCif = (0, mesh_cif_schema_1.CIF_schema_mesh)(meshesBlock);
|
|
122
|
+
nVertices = meshCif.mesh_vertex._rowCount;
|
|
123
|
+
nTriangles = Math.floor(meshCif.mesh_triangle._rowCount / 3);
|
|
124
|
+
mesh_id = meshCif.mesh.id.toArray();
|
|
125
|
+
vertex_meshId = meshCif.mesh_vertex.mesh_id.toArray();
|
|
126
|
+
x = meshCif.mesh_vertex.x.toArray();
|
|
127
|
+
y = meshCif.mesh_vertex.y.toArray();
|
|
128
|
+
z = meshCif.mesh_vertex.z.toArray();
|
|
129
|
+
triangle_meshId = meshCif.mesh_triangle.mesh_id.toArray();
|
|
130
|
+
triangle_vertexId = meshCif.mesh_triangle.vertex_id.toArray();
|
|
131
|
+
indices = new Uint32Array(3 * nTriangles);
|
|
132
|
+
offsets = offsetMap(vertex_meshId);
|
|
133
|
+
for (i = 0; i < 3 * nTriangles; i++) {
|
|
134
|
+
offset = offsets.get(triangle_meshId[i]);
|
|
135
|
+
indices[i] = offset + triangle_vertexId[i];
|
|
136
|
+
}
|
|
137
|
+
vertices = flattenCoords(x, y, z);
|
|
138
|
+
normals = new Float32Array(3 * nVertices);
|
|
139
|
+
groups = new Float32Array(vertex_meshId);
|
|
140
|
+
mesh = mesh_1.Mesh.create(vertices, indices, normals, groups, nVertices, nTriangles);
|
|
141
|
+
invertSides !== null && invertSides !== void 0 ? invertSides : (invertSides = isInverted(mesh));
|
|
142
|
+
if (invertSides) {
|
|
143
|
+
modify(mesh, { invertSides: true }); // Vertex orientation convention is opposite in Volseg API and in MolStar
|
|
144
|
+
}
|
|
145
|
+
if (!(outSpace === 'cartesian')) return [3 /*break*/, 2];
|
|
146
|
+
return [4 /*yield*/, (0, density_server_1.volumeFromDensityServerData)(volumeInfoCif).run()];
|
|
147
|
+
case 1:
|
|
148
|
+
volume = _a.sent();
|
|
149
|
+
gridToCartesian = volume_1.Grid.getGridToCartesianTransform(volume.grid);
|
|
150
|
+
modify(mesh, { matrix: gridToCartesian });
|
|
151
|
+
return [3 /*break*/, 3];
|
|
152
|
+
case 2:
|
|
153
|
+
if (outSpace === 'fractional') {
|
|
154
|
+
gridSize = volumeInfoCif.volume_data_3d_info.sample_count.value(0);
|
|
155
|
+
originFract = volumeInfoCif.volume_data_3d_info.origin.value(0);
|
|
156
|
+
dimensionFract = volumeInfoCif.volume_data_3d_info.dimensions.value(0);
|
|
157
|
+
if (dimensionFract[0] !== 1 || dimensionFract[1] !== 1 || dimensionFract[2] !== 1)
|
|
158
|
+
throw new Error("Asserted the fractional dimensions are [1,1,1], but are actually [".concat(dimensionFract, "]"));
|
|
159
|
+
scale = [1 / gridSize[0], 1 / gridSize[1], 1 / gridSize[2]];
|
|
160
|
+
modify(mesh, { scale: scale, shift: Array.from(originFract) });
|
|
161
|
+
}
|
|
162
|
+
_a.label = 3;
|
|
163
|
+
case 3:
|
|
164
|
+
mesh_1.Mesh.computeNormals(mesh); // normals only necessary if flatShaded==false
|
|
165
|
+
// const boxMesh = makeMeshFromBox([[0,0,0], [1,1,1]], 1);
|
|
166
|
+
// const gridSize = volumeInfoCif.volume_data_3d_info.sample_count.value(0); const boxMesh = makeMeshFromBox([[0,0,0], Array.from(gridSize)] as any, 1);
|
|
167
|
+
// const cellSize = volumeInfoCif.volume_data_3d_info.spacegroup_cell_size.value(0); const boxMesh = makeMeshFromBox([[0, 0, 0], Array.from(cellSize)] as any, 1);
|
|
168
|
+
// mesh = concat(mesh, boxMesh); // debug
|
|
169
|
+
return [2 /*return*/, { mesh: mesh, meshIds: Array.from(mesh_id) }];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
exports.meshFromCif = meshFromCif;
|
|
175
|
+
function isInverted(mesh) {
|
|
176
|
+
var vertices = mesh.vertexBuffer.ref.value;
|
|
177
|
+
var indices = mesh.indexBuffer.ref.value;
|
|
178
|
+
var center = meshCenter(mesh);
|
|
179
|
+
var center3 = linear_algebra_1.Vec3.create(3 * center[0], 3 * center[1], 3 * center[2]);
|
|
180
|
+
var dirMetric = 0.0;
|
|
181
|
+
var _a = [(0, linear_algebra_1.Vec3)(), (0, linear_algebra_1.Vec3)(), (0, linear_algebra_1.Vec3)(), (0, linear_algebra_1.Vec3)(), (0, linear_algebra_1.Vec3)(), (0, linear_algebra_1.Vec3)(), (0, linear_algebra_1.Vec3)()], a = _a[0], b = _a[1], c = _a[2], u = _a[3], v = _a[4], normal = _a[5], radius = _a[6];
|
|
182
|
+
for (var i = 0; i < indices.length; i += 3) {
|
|
183
|
+
linear_algebra_1.Vec3.fromArray(a, vertices, 3 * indices[i]);
|
|
184
|
+
linear_algebra_1.Vec3.fromArray(b, vertices, 3 * indices[i + 1]);
|
|
185
|
+
linear_algebra_1.Vec3.fromArray(c, vertices, 3 * indices[i + 2]);
|
|
186
|
+
linear_algebra_1.Vec3.sub(u, b, a);
|
|
187
|
+
linear_algebra_1.Vec3.sub(v, c, b);
|
|
188
|
+
linear_algebra_1.Vec3.cross(normal, u, v); // direction of the surface
|
|
189
|
+
linear_algebra_1.Vec3.add(radius, a, b);
|
|
190
|
+
linear_algebra_1.Vec3.add(radius, radius, c);
|
|
191
|
+
linear_algebra_1.Vec3.sub(radius, radius, center3); // direction center -> this triangle
|
|
192
|
+
dirMetric += linear_algebra_1.Vec3.dot(radius, normal);
|
|
193
|
+
}
|
|
194
|
+
return dirMetric < 0;
|
|
195
|
+
}
|
|
196
|
+
function meshCenter(mesh) {
|
|
197
|
+
var vertices = mesh.vertexBuffer.ref.value;
|
|
198
|
+
var n = vertices.length;
|
|
199
|
+
var x = 0.0;
|
|
200
|
+
var y = 0.0;
|
|
201
|
+
var z = 0.0;
|
|
202
|
+
for (var i = 0; i < vertices.length; i += 3) {
|
|
203
|
+
x += vertices[i];
|
|
204
|
+
y += vertices[i + 1];
|
|
205
|
+
z += vertices[i + 2];
|
|
206
|
+
}
|
|
207
|
+
return linear_algebra_1.Vec3.create(x / n, y / n, z / n);
|
|
208
|
+
}
|
|
209
|
+
function flattenCoords(x, y, z) {
|
|
210
|
+
var n = x.length;
|
|
211
|
+
var out = new Float32Array(3 * n);
|
|
212
|
+
for (var i = 0; i < n; i++) {
|
|
213
|
+
out[3 * i] = x[i];
|
|
214
|
+
out[3 * i + 1] = y[i];
|
|
215
|
+
out[3 * i + 2] = z[i];
|
|
216
|
+
}
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
219
|
+
/** Get mapping of unique values to the position of their first occurrence */
|
|
220
|
+
function offsetMap(values) {
|
|
221
|
+
var result = new Map();
|
|
222
|
+
for (var i = 0; i < values.length; i++) {
|
|
223
|
+
if (!result.has(values[i])) {
|
|
224
|
+
result.set(values[i], i);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
/** Return bounding box */
|
|
230
|
+
function bbox(mesh) {
|
|
231
|
+
var nVertices = mesh.vertexCount;
|
|
232
|
+
var coords = mesh.vertexBuffer.ref.value;
|
|
233
|
+
if (nVertices === 0) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
var minX = coords[0], minY = coords[1], minZ = coords[2];
|
|
237
|
+
var maxX = minX, maxY = minY, maxZ = minZ;
|
|
238
|
+
for (var i = 0; i < 3 * nVertices; i += 3) {
|
|
239
|
+
var x = coords[i], y = coords[i + 1], z = coords[i + 2];
|
|
240
|
+
if (x < minX)
|
|
241
|
+
minX = x;
|
|
242
|
+
if (y < minY)
|
|
243
|
+
minY = y;
|
|
244
|
+
if (z < minZ)
|
|
245
|
+
minZ = z;
|
|
246
|
+
if (x > maxX)
|
|
247
|
+
maxX = x;
|
|
248
|
+
if (y > maxY)
|
|
249
|
+
maxY = y;
|
|
250
|
+
if (z > maxZ)
|
|
251
|
+
maxZ = z;
|
|
252
|
+
}
|
|
253
|
+
return geometry_1.Box3D.create(linear_algebra_1.Vec3.create(minX, minY, minZ), linear_algebra_1.Vec3.create(maxX, maxY, maxZ));
|
|
254
|
+
}
|
|
255
|
+
exports.bbox = bbox;
|
|
256
|
+
/** Example mesh - 1 triangle */
|
|
257
|
+
function fakeFakeMesh1() {
|
|
258
|
+
var nVertices = 3;
|
|
259
|
+
var nTriangles = 1;
|
|
260
|
+
var vertices = new Float32Array([0, 0, 0, 1, 0, 0, 0, 1, 0]);
|
|
261
|
+
var indices = new Uint32Array([0, 1, 2]);
|
|
262
|
+
var normals = new Float32Array([0, 0, 1]);
|
|
263
|
+
var groups = new Float32Array([0]);
|
|
264
|
+
return mesh_1.Mesh.create(vertices, indices, normals, groups, nVertices, nTriangles);
|
|
265
|
+
}
|
|
266
|
+
exports.fakeFakeMesh1 = fakeFakeMesh1;
|
|
267
|
+
/** Example mesh - irregular tetrahedron */
|
|
268
|
+
function fakeMesh4() {
|
|
269
|
+
var nVertices = 4;
|
|
270
|
+
var nTriangles = 4;
|
|
271
|
+
var vertices = new Float32Array([0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
|
272
|
+
var indices = new Uint32Array([0, 2, 1, 0, 1, 3, 1, 2, 3, 2, 0, 3]);
|
|
273
|
+
var normals = new Float32Array([-1, -1, -1, 1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
|
274
|
+
var groups = new Float32Array([0, 1, 2, 3]);
|
|
275
|
+
return mesh_1.Mesh.create(vertices, indices, normals, groups, nVertices, nTriangles);
|
|
276
|
+
}
|
|
277
|
+
exports.fakeMesh4 = fakeMesh4;
|
|
278
|
+
/** Return a box-shaped mesh */
|
|
279
|
+
function meshFromBox(box, group) {
|
|
280
|
+
if (group === void 0) { group = 0; }
|
|
281
|
+
var _a = box[0], x0 = _a[0], y0 = _a[1], z0 = _a[2], _b = box[1], x1 = _b[0], y1 = _b[1], z1 = _b[2];
|
|
282
|
+
var vertices = new Float32Array([
|
|
283
|
+
x0, y0, z0,
|
|
284
|
+
x1, y0, z0,
|
|
285
|
+
x0, y1, z0,
|
|
286
|
+
x1, y1, z0,
|
|
287
|
+
x0, y0, z1,
|
|
288
|
+
x1, y0, z1,
|
|
289
|
+
x0, y1, z1,
|
|
290
|
+
x1, y1, z1,
|
|
291
|
+
]);
|
|
292
|
+
var indices = new Uint32Array([
|
|
293
|
+
2, 1, 0, 1, 2, 3,
|
|
294
|
+
1, 4, 0, 4, 1, 5,
|
|
295
|
+
3, 5, 1, 5, 3, 7,
|
|
296
|
+
2, 7, 3, 7, 2, 6,
|
|
297
|
+
0, 6, 2, 6, 0, 4,
|
|
298
|
+
4, 7, 6, 7, 4, 5,
|
|
299
|
+
]);
|
|
300
|
+
var groups = new Float32Array([group, group, group, group, group, group, group, group]);
|
|
301
|
+
var normals = new Float32Array(8);
|
|
302
|
+
var mesh = mesh_1.Mesh.create(vertices, indices, normals, groups, 8, 12);
|
|
303
|
+
mesh_1.Mesh.computeNormals(mesh); // normals only necessary if flatShaded==false
|
|
304
|
+
return mesh;
|
|
305
|
+
}
|
|
306
|
+
exports.meshFromBox = meshFromBox;
|
|
307
|
+
function sum(array) {
|
|
308
|
+
return array.reduce(function (a, b) { return a + b; }, 0);
|
|
309
|
+
}
|
|
310
|
+
function concatArrays(t, arrays) {
|
|
311
|
+
var totalLength = arrays.map(function (a) { return a.length; }).reduce(function (a, b) { return a + b; }, 0);
|
|
312
|
+
var result = new t(totalLength);
|
|
313
|
+
var offset = 0;
|
|
314
|
+
for (var _i = 0, arrays_1 = arrays; _i < arrays_1.length; _i++) {
|
|
315
|
+
var array = arrays_1[_i];
|
|
316
|
+
result.set(array, offset);
|
|
317
|
+
offset += array.length;
|
|
318
|
+
}
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
/** Generate random colors (in a cycle) */
|
|
322
|
+
exports.ColorGenerator = function () {
|
|
323
|
+
var colors, i;
|
|
324
|
+
return tslib_1.__generator(this, function (_a) {
|
|
325
|
+
switch (_a.label) {
|
|
326
|
+
case 0:
|
|
327
|
+
colors = shuffleArray(Object.values(names_1.ColorNames));
|
|
328
|
+
i = 0;
|
|
329
|
+
_a.label = 1;
|
|
330
|
+
case 1:
|
|
331
|
+
if (!true) return [3 /*break*/, 3];
|
|
332
|
+
return [4 /*yield*/, colors[i]];
|
|
333
|
+
case 2:
|
|
334
|
+
_a.sent();
|
|
335
|
+
i++;
|
|
336
|
+
if (i >= colors.length)
|
|
337
|
+
i = 0;
|
|
338
|
+
return [3 /*break*/, 1];
|
|
339
|
+
case 3: return [2 /*return*/];
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}();
|
|
343
|
+
function shuffleArray(array) {
|
|
344
|
+
// Stealed from https://www.w3docs.com/snippets/javascript/how-to-randomize-shuffle-a-javascript-array.html
|
|
345
|
+
var curId = array.length;
|
|
346
|
+
// There remain elements to shuffle
|
|
347
|
+
while (0 !== curId) {
|
|
348
|
+
// Pick a remaining element
|
|
349
|
+
var randId = Math.floor(Math.random() * curId);
|
|
350
|
+
curId -= 1;
|
|
351
|
+
// Swap it with the current element.
|
|
352
|
+
var tmp = array[curId];
|
|
353
|
+
array[curId] = array[randId];
|
|
354
|
+
array[randId] = tmp;
|
|
355
|
+
}
|
|
356
|
+
return array;
|
|
357
|
+
}
|