Skip to content
Snippets Groups Projects
Select Git revision
  • 66b9f6104c1104255a527f6af92e8c80b319f1ac
  • master default protected
  • rednatco-v2
  • 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
  • servers
  • 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

element-point.ts

Blame
  • element-point.ts 2.16 KiB
    /**
     * Copyright (c) 2018 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 { UnitsPointsParams, UnitsVisual, UnitsPointsVisual } from '../units-visual';
    import { VisualContext } from '../../visual';
    import { Unit, Structure } from '../../../mol-model/structure';
    import { Theme } from '../../../mol-theme/theme';
    import { Points } from '../../../mol-geo/geometry/points/points';
    import { PointsBuilder } from '../../../mol-geo/geometry/points/points-builder';
    import { Vec3 } from '../../../mol-math/linear-algebra';
    import { StructureElementIterator, getElementLoci, eachElement } from './util/element';
    import { VisualUpdateState } from '../../util';
    
    export const ElementPointParams = {
        ...UnitsPointsParams,
        // sizeFactor: PD.Numeric(1.0, { min: 0, max: 10, step: 0.01 }),
        pointSizeAttenuation: PD.Boolean(false),
        showHydrogens: PD.Boolean(true),
    }
    export type ElementPointParams = typeof ElementPointParams
    
    // TODO size
    
    export function createElementPoint(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PD.Values<ElementPointParams>, points: Points) {
        // const { sizeFactor } = props
    
        const elements = unit.elements
        const n = elements.length
        const builder = PointsBuilder.create(n, n / 10, points)
    
        const pos = unit.conformation.invariantPosition
        const p = Vec3.zero()
    
        for (let i = 0; i < n; ++i) {
            pos(elements[i], p)
            builder.add(p[0], p[1], p[2], i)
        }
        return builder.getPoints()
    }
    
    export function ElementPointVisual(materialId: number): UnitsVisual<ElementPointParams> {
        return UnitsPointsVisual<ElementPointParams>({
            defaultProps: PD.getDefaultValues(ElementPointParams),
            createGeometry: createElementPoint,
            createLocationIterator: StructureElementIterator.fromGroup,
            getLoci: getElementLoci,
            eachLocation: eachElement,
            setUpdateState: (state: VisualUpdateState, newProps: PD.Values<ElementPointParams>, currentProps: PD.Values<ElementPointParams>) => {
    
            }
        }, materialId)
    }