Skip to content
Snippets Groups Projects
Select Git revision
  • 0aa2fa114e61af9a78ccd4b3a8a194b675ee9308
  • master default protected
  • rednatco-v2
  • base-pairs-ladder
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

gaussian-density.ts

Blame
  • element-sphere.ts 2.39 KiB
    /**
     * Copyright (c) 2018 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 { UnitsVisual } from '../representation';
    import { VisualUpdateState } from '../../util';
    import { createElementSphereMesh, eachElement, getElementLoci, StructureElementIterator, createElementSphereImpostor } from './util/element';
    import { UnitsMeshVisual, UnitsMeshParams, UnitsSpheresVisual, UnitsSpheresParams } from '../units-visual';
    import { ParamDefinition as PD } from 'mol-util/param-definition';
    import { WebGLContext } from 'mol-gl/webgl/context';
    
    export const ElementSphereParams = {
        ...UnitsMeshParams,
        ...UnitsSpheresParams,
        sizeFactor: PD.Numeric(1, { min: 0, max: 10, step: 0.1 }),
        detail: PD.Numeric(0, { min: 0, max: 3, step: 1 }),
    }
    export type ElementSphereParams = typeof ElementSphereParams
    
    export function getElementSphereVisual(webgl?: WebGLContext) {
        return webgl && webgl.extensions.fragDepth ? ElementSphereImpostorVisual : ElementSphereMeshVisual
    }
    
    export function ElementSphereImpostorVisual(materialId: number): UnitsVisual<ElementSphereParams> {
        return UnitsSpheresVisual<ElementSphereParams>({
            defaultProps: PD.getDefaultValues(ElementSphereParams),
            createGeometry: createElementSphereImpostor,
            createLocationIterator: StructureElementIterator.fromGroup,
            getLoci: getElementLoci,
            eachLocation: eachElement,
            setUpdateState: (state: VisualUpdateState, newProps: PD.Values<ElementSphereParams>, currentProps: PD.Values<ElementSphereParams>) => {
    
            }
        }, materialId)
    }
    
    export function ElementSphereMeshVisual(materialId: number): UnitsVisual<ElementSphereParams> {
        return UnitsMeshVisual<ElementSphereParams>({
            defaultProps: PD.getDefaultValues(ElementSphereParams),
            createGeometry: createElementSphereMesh,
            createLocationIterator: StructureElementIterator.fromGroup,
            getLoci: getElementLoci,
            eachLocation: eachElement,
            setUpdateState: (state: VisualUpdateState, newProps: PD.Values<ElementSphereParams>, currentProps: PD.Values<ElementSphereParams>) => {
                state.createGeometry = (
                    newProps.sizeFactor !== currentProps.sizeFactor ||
                    newProps.detail !== currentProps.detail
                )
            }
        }, materialId)
    }