From be7d6cfbe1cf8323f0c9c2b21e4a0380d84e0b90 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Sat, 24 Nov 2018 19:31:15 -0800 Subject: [PATCH] wip --- src/mol-repr/representation.ts | 2 +- .../structure/complex-representation.ts | 2 +- src/mol-repr/structure/complex-visual.ts | 18 +-- src/mol-repr/structure/registry.ts | 4 +- .../representation/molecular-surface.ts | 84 +++++------ .../structure/units-representation.ts | 15 +- src/mol-repr/structure/units-visual.ts | 18 +-- .../visual/carbohydrate-link-cylinder.ts | 2 +- .../visual/carbohydrate-symbol-mesh.ts | 6 +- .../carbohydrate-terminal-link-cylinder.ts | 2 +- .../visual/cross-link-restraint-cylinder.ts | 2 +- .../structure/visual/element-point.ts | 6 +- .../visual/gaussian-density-point.ts | 130 +++++++++--------- .../visual/gaussian-density-volume.ts | 96 ++++++------- .../structure/visual/gaussian-surface-mesh.ts | 102 +++++++------- .../visual/gaussian-surface-wireframe.ts | 100 +++++++------- .../visual/inter-unit-link-cylinder.ts | 2 +- .../visual/intra-unit-link-cylinder.ts | 2 +- .../structure/visual/nucleotide-block-mesh.ts | 5 +- .../visual/polymer-backbone-cylinder.ts | 9 +- .../visual/polymer-direction-wedge.ts | 5 +- .../structure/visual/polymer-gap-cylinder.ts | 5 +- .../structure/visual/polymer-trace-mesh.ts | 5 +- src/mol-repr/structure/visual/util/element.ts | 6 +- src/mol-repr/structure/visual/util/link.ts | 6 +- 25 files changed, 303 insertions(+), 331 deletions(-) diff --git a/src/mol-repr/representation.ts b/src/mol-repr/representation.ts index b990ba87a..139019a52 100644 --- a/src/mol-repr/representation.ts +++ b/src/mol-repr/representation.ts @@ -243,7 +243,7 @@ export interface Visual<D, P extends PD.Params> { /** Number of addressable groups in all instances of the visual */ readonly groupCount: number readonly renderObject: RenderObject | undefined - createOrUpdate: (ctx: VisualContext, theme: Theme, props?: Partial<PD.Values<P>>, data?: D) => Promise<void> + createOrUpdate: (ctx: VisualContext, theme: Theme, props?: Partial<PD.Values<P>>, data?: D) => void getLoci: (pickingId: PickingId) => Loci mark: (loci: Loci, action: MarkerAction) => boolean setVisibility: (value: boolean) => void diff --git a/src/mol-repr/structure/complex-representation.ts b/src/mol-repr/structure/complex-representation.ts index 2bbfa2955..40e528521 100644 --- a/src/mol-repr/structure/complex-representation.ts +++ b/src/mol-repr/structure/complex-representation.ts @@ -38,7 +38,7 @@ export function ComplexRepresentation<P extends StructureParams>(label: string, return Task.create('Creating or updating ComplexRepresentation', async runtime => { if (!visual) visual = visualCtor() - await visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props, structure) + visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props, structure) updated.next(version++) }); } diff --git a/src/mol-repr/structure/complex-visual.ts b/src/mol-repr/structure/complex-visual.ts index 65086af89..5d028dd7a 100644 --- a/src/mol-repr/structure/complex-visual.ts +++ b/src/mol-repr/structure/complex-visual.ts @@ -38,7 +38,7 @@ type ComplexRenderObject = MeshRenderObject | LinesRenderObject | PointsRenderOb interface ComplexVisualBuilder<P extends ComplexParams, G extends Geometry> { defaultProps: PD.Values<P> - createGeometry(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<P>, geometry?: G): Promise<G> + createGeometry(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<P>, geometry?: G): G createLocationIterator(structure: Structure): LocationIterator getLoci(pickingId: PickingId, structure: Structure, id: number): Loci mark(loci: Loci, structure: Structure, apply: (interval: Interval) => boolean): boolean, @@ -65,19 +65,19 @@ export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeo let locationIt: LocationIterator let conformationHash: number - async function create(ctx: VisualContext, structure: Structure, theme: Theme, props: Partial<PD.Values<P>> = {}) { + function create(ctx: VisualContext, structure: Structure, theme: Theme, props: Partial<PD.Values<P>> = {}) { currentProps = Object.assign({}, defaultProps, props) currentTheme = theme currentStructure = structure conformationHash = Structure.conformationHash(currentStructure) - geometry = await createGeometry(ctx, currentStructure, theme, currentProps, geometry) + geometry = createGeometry(ctx, currentStructure, theme, currentProps, geometry) locationIt = createLocationIterator(structure) renderObject = createRenderObject(structure, geometry, locationIt, theme, currentProps) } - async function update(ctx: VisualContext, theme: Theme, props: Partial<PD.Values<P>>) { + function update(ctx: VisualContext, theme: Theme, props: Partial<PD.Values<P>>) { const newProps = Object.assign({}, currentProps, props, { structure: currentStructure }) if (!renderObject) return false @@ -98,7 +98,7 @@ export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeo // if (updateState.createGeometry) { - geometry = await createGeometry(ctx, currentStructure, theme, newProps, geometry) + geometry = createGeometry(ctx, currentStructure, theme, newProps, geometry) ValueCell.update(renderObject.values.drawCount, Geometry.getDrawCount(geometry)) updateBoundingSphere(renderObject.values, geometry) updateState.updateColor = true @@ -126,18 +126,18 @@ export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeo return { get groupCount() { return locationIt ? locationIt.count : 0 }, get renderObject () { return renderObject }, - async createOrUpdate(ctx: VisualContext, theme: Theme, props: Partial<PD.Values<P>> = {}, structure?: Structure) { + createOrUpdate(ctx: VisualContext, theme: Theme, props: Partial<PD.Values<P>> = {}, structure?: Structure) { if (!structure && !currentStructure) { throw new Error('missing structure') } else if (structure && (!currentStructure || !renderObject)) { - await create(ctx, structure, theme, props) + create(ctx, structure, theme, props) } else if (structure && !Structure.areEquivalent(structure, currentStructure)) { - await create(ctx, structure, theme, props) + create(ctx, structure, theme, props) } else { if (structure && Structure.conformationHash(structure) !== Structure.conformationHash(currentStructure)) { currentStructure = structure } - await update(ctx, theme, props) + update(ctx, theme, props) } }, getLoci(pickingId: PickingId) { diff --git a/src/mol-repr/structure/registry.ts b/src/mol-repr/structure/registry.ts index 058a9c178..16d90e630 100644 --- a/src/mol-repr/structure/registry.ts +++ b/src/mol-repr/structure/registry.ts @@ -8,7 +8,7 @@ import { Structure } from 'mol-model/structure'; import { RepresentationProvider, RepresentationRegistry } from '../representation'; import { CartoonRepresentationProvider } from './representation/cartoon'; import { BallAndStickRepresentationProvider } from './representation/ball-and-stick'; -import { MolecularSurfaceRepresentationProvider } from './representation/molecular-surface'; +// import { MolecularSurfaceRepresentationProvider } from './representation/molecular-surface'; import { CarbohydrateRepresentationProvider } from './representation/carbohydrate'; export class StructureRepresentationRegistry extends RepresentationRegistry<Structure> { @@ -24,7 +24,7 @@ export class StructureRepresentationRegistry extends RepresentationRegistry<Stru export const BuiltInStructureRepresentations = { 'cartoon': CartoonRepresentationProvider, 'ball-and-stick': BallAndStickRepresentationProvider, - 'molecular-surface': MolecularSurfaceRepresentationProvider, + // 'molecular-surface': MolecularSurfaceRepresentationProvider, 'carbohydrate': CarbohydrateRepresentationProvider, } export type BuiltInStructureRepresentationsName = keyof typeof BuiltInStructureRepresentations diff --git a/src/mol-repr/structure/representation/molecular-surface.ts b/src/mol-repr/structure/representation/molecular-surface.ts index 4181217d3..02182081e 100644 --- a/src/mol-repr/structure/representation/molecular-surface.ts +++ b/src/mol-repr/structure/representation/molecular-surface.ts @@ -1,47 +1,47 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - */ +// /** +// * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. +// * +// * @author Alexander Rose <alexander.rose@weirdbyte.de> +// */ -import { GaussianSurfaceVisual, GaussianSurfaceParams } from '../visual/gaussian-surface-mesh'; -import { UnitsRepresentation } from '../units-representation'; -import { GaussianWireframeVisual, GaussianWireframeParams } from '../visual/gaussian-surface-wireframe'; -import { ParamDefinition as PD } from 'mol-util/param-definition'; -import { GaussianDensityVolumeParams, GaussianDensityVolumeVisual } from '../visual/gaussian-density-volume'; -import { StructureRepresentation, StructureRepresentationProvider } from '../representation'; -import { Representation, RepresentationParamsGetter, RepresentationContext } from 'mol-repr/representation'; -import { ThemeRegistryContext } from 'mol-theme/theme'; -import { Structure } from 'mol-model/structure'; +// import { GaussianSurfaceVisual, GaussianSurfaceParams } from '../visual/gaussian-surface-mesh'; +// import { UnitsRepresentation } from '../units-representation'; +// import { GaussianWireframeVisual, GaussianWireframeParams } from '../visual/gaussian-surface-wireframe'; +// import { ParamDefinition as PD } from 'mol-util/param-definition'; +// import { GaussianDensityVolumeParams, GaussianDensityVolumeVisual } from '../visual/gaussian-density-volume'; +// import { StructureRepresentation, StructureRepresentationProvider } from '../representation'; +// import { Representation, RepresentationParamsGetter, RepresentationContext } from 'mol-repr/representation'; +// import { ThemeRegistryContext } from 'mol-theme/theme'; +// import { Structure } from 'mol-model/structure'; -const MolecularSurfaceVisuals = { - 'gaussian-surface': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, GaussianSurfaceParams>) => UnitsRepresentation('Gaussian surface', ctx, getParams, GaussianSurfaceVisual), - 'gaussian-wireframe': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, GaussianWireframeParams>) => UnitsRepresentation('Gaussian wireframe', ctx, getParams, GaussianWireframeVisual), - 'gaussian-volume': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, GaussianDensityVolumeParams>) => UnitsRepresentation('Gaussian volume', ctx, getParams, GaussianDensityVolumeVisual) -} -type MolecularSurfaceVisualName = keyof typeof MolecularSurfaceVisuals -const MolecularSurfaceVisualOptions = Object.keys(MolecularSurfaceVisuals).map(name => [name, name] as [MolecularSurfaceVisualName, string]) +// const MolecularSurfaceVisuals = { +// 'gaussian-surface': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, GaussianSurfaceParams>) => UnitsRepresentation('Gaussian surface', ctx, getParams, GaussianSurfaceVisual), +// 'gaussian-wireframe': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, GaussianWireframeParams>) => UnitsRepresentation('Gaussian wireframe', ctx, getParams, GaussianWireframeVisual), +// 'gaussian-volume': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, GaussianDensityVolumeParams>) => UnitsRepresentation('Gaussian volume', ctx, getParams, GaussianDensityVolumeVisual) +// } +// type MolecularSurfaceVisualName = keyof typeof MolecularSurfaceVisuals +// const MolecularSurfaceVisualOptions = Object.keys(MolecularSurfaceVisuals).map(name => [name, name] as [MolecularSurfaceVisualName, string]) -export const MolecularSurfaceParams = { - ...GaussianSurfaceParams, - ...GaussianWireframeParams, - ...GaussianDensityVolumeParams, - visuals: PD.MultiSelect<MolecularSurfaceVisualName>(['gaussian-surface'], MolecularSurfaceVisualOptions), -} -export type MolecularSurfaceParams = typeof MolecularSurfaceParams -export function getMolecularSurfaceParams(ctx: ThemeRegistryContext, structure: Structure) { - return PD.clone(MolecularSurfaceParams) -} +// export const MolecularSurfaceParams = { +// ...GaussianSurfaceParams, +// ...GaussianWireframeParams, +// ...GaussianDensityVolumeParams, +// visuals: PD.MultiSelect<MolecularSurfaceVisualName>(['gaussian-surface'], MolecularSurfaceVisualOptions), +// } +// export type MolecularSurfaceParams = typeof MolecularSurfaceParams +// export function getMolecularSurfaceParams(ctx: ThemeRegistryContext, structure: Structure) { +// return PD.clone(MolecularSurfaceParams) +// } -export type MolecularSurfaceRepresentation = StructureRepresentation<MolecularSurfaceParams> -export function MolecularSurfaceRepresentation(ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, MolecularSurfaceParams>): MolecularSurfaceRepresentation { - return Representation.createMulti('Molecular Surface', ctx, getParams, MolecularSurfaceVisuals as unknown as Representation.Def<Structure, MolecularSurfaceParams>) -} +// export type MolecularSurfaceRepresentation = StructureRepresentation<MolecularSurfaceParams> +// export function MolecularSurfaceRepresentation(ctx: RepresentationContext, getParams: RepresentationParamsGetter<Structure, MolecularSurfaceParams>): MolecularSurfaceRepresentation { +// return Representation.createMulti('Molecular Surface', ctx, getParams, MolecularSurfaceVisuals as unknown as Representation.Def<Structure, MolecularSurfaceParams>) +// } -export const MolecularSurfaceRepresentationProvider: StructureRepresentationProvider<MolecularSurfaceParams> = { - label: 'Molecular Surface', - description: 'Displays a gaussian molecular surface.', - factory: MolecularSurfaceRepresentation, - getParams: getMolecularSurfaceParams, - defaultValues: PD.getDefaultValues(MolecularSurfaceParams) -} \ No newline at end of file +// export const MolecularSurfaceRepresentationProvider: StructureRepresentationProvider<MolecularSurfaceParams> = { +// label: 'Molecular Surface', +// description: 'Displays a gaussian molecular surface.', +// factory: MolecularSurfaceRepresentation, +// getParams: getMolecularSurfaceParams, +// defaultValues: PD.getDefaultValues(MolecularSurfaceParams) +// } \ No newline at end of file diff --git a/src/mol-repr/structure/units-representation.ts b/src/mol-repr/structure/units-representation.ts index 01b381c9e..59ba0b2fa 100644 --- a/src/mol-repr/structure/units-representation.ts +++ b/src/mol-repr/structure/units-representation.ts @@ -56,8 +56,9 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, ctx: R for (let i = 0; i < _groups.length; i++) { const group = _groups[i]; const visual = visualCtor() - await visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props, { group, structure }) + visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props, { group, structure }) visuals.set(group.hashCode, { visual, group }) + if (runtime.shouldUpdate) await runtime.update({ message: 'Creating or updating UnitsVisual', current: i, max: _groups.length }) } } else if (structure && !Structure.areEquivalent(structure, _structure)) { // console.log(label, 'structure not equivalent') @@ -75,16 +76,17 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, ctx: R // console.log('old', visualGroup.group) // console.log('new', group) const { visual } = visualGroup - await visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props, { group, structure }) + visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props, { group, structure }) visuals.set(group.hashCode, { visual, group }) oldVisuals.delete(group.hashCode) } else { // console.log(label, 'not found visualGroup to reuse, creating new') // newGroups.push(group) const visual = visualCtor() - await visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props, { group, structure }) + visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props, { group, structure }) visuals.set(group.hashCode, { visual, group }) } + if (runtime.shouldUpdate) await runtime.update({ message: 'Creating or updating UnitsVisual', current: i, max: _groups.length }) } oldVisuals.forEach(({ visual }) => { // console.log(label, 'removed unused visual') @@ -113,11 +115,13 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, ctx: R const group = _groups[i]; const visualGroup = visuals.get(group.hashCode) if (visualGroup) { - await visualGroup.visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props, { group, structure }) + visualGroup.visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props, { group, structure }) visualGroup.group = group + } else { throw new Error(`expected to find visual for hashCode ${group.hashCode}`) } + if (runtime.shouldUpdate) await runtime.update({ message: 'Creating or updating UnitsVisual', current: i, max: _groups.length }) } } else { // console.log(label, 'no new structure') @@ -126,7 +130,8 @@ export function UnitsRepresentation<P extends UnitsParams>(label: string, ctx: R visuals.forEach(({ visual, group }) => visualsList.push([ visual, group ])) for (let i = 0, il = visualsList.length; i < il; ++i) { const [ visual ] = visualsList[i] - await visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props) + visual.createOrUpdate({ webgl: ctx.webgl, runtime }, _theme, _props) + if (runtime.shouldUpdate) await runtime.update({ message: 'Creating or updating UnitsVisual', current: i, max: il }) } } if (structure) _structure = structure diff --git a/src/mol-repr/structure/units-visual.ts b/src/mol-repr/structure/units-visual.ts index 6fde0097d..cc6409d48 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/src/mol-repr/structure/units-visual.ts @@ -38,7 +38,7 @@ type UnitsRenderObject = MeshRenderObject | LinesRenderObject | PointsRenderObje interface UnitsVisualBuilder<P extends UnitsParams, G extends Geometry> { defaultProps: PD.Values<P> - createGeometry(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PD.Values<P>, geometry?: G): Promise<G> + createGeometry(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PD.Values<P>, geometry?: G): G createLocationIterator(group: Unit.SymmetryGroup): LocationIterator getLoci(pickingId: PickingId, structureGroup: StructureGroup, id: number): Loci mark(loci: Loci, structureGroup: StructureGroup, apply: (interval: Interval) => boolean): boolean @@ -66,7 +66,7 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB let locationIt: LocationIterator let currentConformationId: UUID - async function create(ctx: VisualContext, group: Unit.SymmetryGroup, theme: Theme, props: Partial<PD.Values<P>> = {}) { + function create(ctx: VisualContext, group: Unit.SymmetryGroup, theme: Theme, props: Partial<PD.Values<P>> = {}) { currentProps = Object.assign({}, defaultProps, props, { structure: currentStructure }) currentTheme = theme currentGroup = group @@ -74,7 +74,7 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB const unit = group.units[0] currentConformationId = Unit.conformationId(unit) geometry = includesUnitKind(currentProps.unitKinds, unit) - ? await createGeometry(ctx, unit, currentStructure, theme, currentProps, geometry) + ? createGeometry(ctx, unit, currentStructure, theme, currentProps, geometry) : createEmptyGeometry(geometry) // TODO create empty location iterator when not in unitKinds @@ -82,7 +82,7 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB renderObject = createRenderObject(group, geometry, locationIt, theme, currentProps) } - async function update(ctx: VisualContext, group: Unit.SymmetryGroup, theme: Theme, props: Partial<PD.Values<P>> = {}) { + function update(ctx: VisualContext, group: Unit.SymmetryGroup, theme: Theme, props: Partial<PD.Values<P>> = {}) { if (!renderObject) return const newProps = Object.assign({}, currentProps, props, { structure: currentStructure }) @@ -137,7 +137,7 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB if (updateState.createGeometry) { // console.log('update geometry') geometry = includesUnitKind(newProps.unitKinds, unit) - ? await createGeometry(ctx, unit, currentStructure, theme, newProps, geometry) + ? createGeometry(ctx, unit, currentStructure, theme, newProps, geometry) : createEmptyGeometry(geometry) ValueCell.update(renderObject.values.drawCount, Geometry.getDrawCount(geometry)) updateBoundingSphere(renderObject.values, geometry) @@ -168,20 +168,20 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB return { get groupCount() { return locationIt ? locationIt.count : 0 }, get renderObject () { return renderObject }, - async createOrUpdate(ctx: VisualContext, theme: Theme, props: Partial<PD.Values<P>> = {}, structureGroup?: StructureGroup) { + createOrUpdate(ctx: VisualContext, theme: Theme, props: Partial<PD.Values<P>> = {}, structureGroup?: StructureGroup) { if (structureGroup) currentStructure = structureGroup.structure const group = structureGroup ? structureGroup.group : undefined if (!group && !currentGroup) { throw new Error('missing group') } else if (group && (!currentGroup || !renderObject)) { // console.log('unit-visual first create') - await create(ctx, group, theme, props) + create(ctx, group, theme, props) } else if (group && group.hashCode !== currentGroup.hashCode) { // console.log('unit-visual group.hashCode !== currentGroup.hashCode') - await create(ctx, group, theme, props) + create(ctx, group, theme, props) } else { // console.log('unit-visual update') - await update(ctx, group || currentGroup, theme, props) + update(ctx, group || currentGroup, theme, props) } }, getLoci(pickingId: PickingId) { diff --git a/src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts b/src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts index f4365b289..0eebe27e7 100644 --- a/src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts +++ b/src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts @@ -21,7 +21,7 @@ import { VisualUpdateState } from '../../util'; import { VisualContext } from 'mol-repr/representation'; import { Theme } from 'mol-theme/theme'; -async function createCarbohydrateLinkCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CarbohydrateLinkParams>, mesh?: Mesh) { +function createCarbohydrateLinkCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CarbohydrateLinkParams>, mesh?: Mesh) { const { links, elements } = structure.carbohydrates const { linkSizeFactor } = props diff --git a/src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts b/src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts index dbdf3ada0..cf9162b15 100644 --- a/src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts +++ b/src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts @@ -44,7 +44,7 @@ const diamondPrism = DiamondPrism() const pentagonalPrism = PentagonalPrism() const hexagonalPrism = HexagonalPrism() -async function createCarbohydrateSymbolMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CarbohydrateSymbolParams>, mesh?: Mesh) { +function createCarbohydrateSymbolMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CarbohydrateSymbolParams>, mesh?: Mesh) { const builder = MeshBuilder.create(256, 128, mesh) const { detail, sizeFactor } = props @@ -136,10 +136,6 @@ async function createCarbohydrateSymbolMesh(ctx: VisualContext, structure: Struc builder.add(t, hexagonalPrism) break } - - if (i % 10000 === 0 && ctx.runtime.shouldUpdate) { - await ctx.runtime.update({ message: 'Carbohydrate symbols', current: i, max: n }); - } } return builder.getMesh() diff --git a/src/mol-repr/structure/visual/carbohydrate-terminal-link-cylinder.ts b/src/mol-repr/structure/visual/carbohydrate-terminal-link-cylinder.ts index fe9d2414e..44231be6d 100644 --- a/src/mol-repr/structure/visual/carbohydrate-terminal-link-cylinder.ts +++ b/src/mol-repr/structure/visual/carbohydrate-terminal-link-cylinder.ts @@ -21,7 +21,7 @@ import { VisualUpdateState } from '../../util'; import { VisualContext } from 'mol-repr/representation'; import { Theme } from 'mol-theme/theme'; -async function createCarbohydrateTerminalLinkCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CarbohydrateTerminalLinkParams>, mesh?: Mesh) { +function createCarbohydrateTerminalLinkCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CarbohydrateTerminalLinkParams>, mesh?: Mesh) { const { terminalLinks, elements } = structure.carbohydrates const { linkSizeFactor } = props diff --git a/src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts b/src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts index 25303be9e..9412dd09c 100644 --- a/src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts +++ b/src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts @@ -21,7 +21,7 @@ import { PickingId } from 'mol-geo/geometry/picking'; import { VisualContext } from 'mol-repr/representation'; import { Theme } from 'mol-theme/theme'; -async function createCrossLinkRestraintCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CrossLinkRestraintParams>, mesh?: Mesh) { +function createCrossLinkRestraintCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CrossLinkRestraintParams>, mesh?: Mesh) { const crossLinks = structure.crossLinkRestraints if (!crossLinks.count) return Mesh.createEmpty(mesh) diff --git a/src/mol-repr/structure/visual/element-point.ts b/src/mol-repr/structure/visual/element-point.ts index 2b146bde3..71f5d4b1f 100644 --- a/src/mol-repr/structure/visual/element-point.ts +++ b/src/mol-repr/structure/visual/element-point.ts @@ -24,7 +24,7 @@ export type ElementPointParams = typeof ElementPointParams // TODO size -export async function createElementPoint(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PD.Values<ElementPointParams>, points: Points) { +export function createElementPoint(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PD.Values<ElementPointParams>, points: Points) { const elements = unit.elements const n = elements.length const builder = PointsBuilder.create(n, n / 10, points) @@ -35,10 +35,6 @@ export async function createElementPoint(ctx: VisualContext, unit: Unit, structu for (let i = 0; i < n; ++i) { pos(elements[i], p) builder.add(p[0], p[1], p[2], i) - - if (i % 10000 === 0 && ctx.runtime.shouldUpdate) { - await ctx.runtime.update({ message: 'Creating points', current: i, max: n }); - } } return builder.getPoints() } diff --git a/src/mol-repr/structure/visual/gaussian-density-point.ts b/src/mol-repr/structure/visual/gaussian-density-point.ts index 6a7e20353..612bc5f01 100644 --- a/src/mol-repr/structure/visual/gaussian-density-point.ts +++ b/src/mol-repr/structure/visual/gaussian-density-point.ts @@ -1,73 +1,73 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - */ +// /** +// * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. +// * +// * @author Alexander Rose <alexander.rose@weirdbyte.de> +// */ -import { Unit, Structure } from 'mol-model/structure'; -import { UnitsVisual } from '../representation'; -import { VisualUpdateState } from '../../util'; -import { StructureElementIterator } from './util/element'; -import { EmptyLoci } from 'mol-model/loci'; -import { Vec3 } from 'mol-math/linear-algebra'; -import { UnitsPointsVisual, UnitsPointsParams } from '../units-visual'; -import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; -import { ParamDefinition as PD } from 'mol-util/param-definition'; -import { Points } from 'mol-geo/geometry/points/points'; -import { PointsBuilder } from 'mol-geo/geometry/points/points-builder'; -import { VisualContext } from 'mol-repr/representation'; -import { Theme } from 'mol-theme/theme'; +// import { Unit, Structure } from 'mol-model/structure'; +// import { UnitsVisual } from '../representation'; +// import { VisualUpdateState } from '../../util'; +// import { StructureElementIterator } from './util/element'; +// import { EmptyLoci } from 'mol-model/loci'; +// import { Vec3 } from 'mol-math/linear-algebra'; +// import { UnitsPointsVisual, UnitsPointsParams } from '../units-visual'; +// import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; +// import { ParamDefinition as PD } from 'mol-util/param-definition'; +// import { Points } from 'mol-geo/geometry/points/points'; +// import { PointsBuilder } from 'mol-geo/geometry/points/points-builder'; +// import { VisualContext } from 'mol-repr/representation'; +// import { Theme } from 'mol-theme/theme'; -export const GaussianDensityPointParams = { - ...UnitsPointsParams, - ...GaussianDensityParams, - pointSizeAttenuation: PD.Boolean(false), -} -export type GaussianDensityPointParams = typeof GaussianDensityPointParams +// export const GaussianDensityPointParams = { +// ...UnitsPointsParams, +// ...GaussianDensityParams, +// pointSizeAttenuation: PD.Boolean(false), +// } +// export type GaussianDensityPointParams = typeof GaussianDensityPointParams -export async function createGaussianDensityPoint(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, points?: Points) { - const { transform, field: { space, data } } = await unit.computeGaussianDensity(props, ctx.runtime, ctx.webgl) +// export async function createGaussianDensityPoint(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, points?: Points) { +// const { transform, field: { space, data } } = await unit.computeGaussianDensity(props, ctx.runtime, ctx.webgl) - const { dimensions, get } = space - const [ xn, yn, zn ] = dimensions +// const { dimensions, get } = space +// const [ xn, yn, zn ] = dimensions - const n = xn * yn * zn * 3 - const builder = PointsBuilder.create(n, n / 10, points) +// const n = xn * yn * zn * 3 +// const builder = PointsBuilder.create(n, n / 10, points) - const p = Vec3.zero() - let i = 0 +// const p = Vec3.zero() +// let i = 0 - for (let x = 0; x < xn; ++x) { - for (let y = 0; y < yn; ++y) { - for (let z = 0; z < zn; ++z) { - if (get(data, x, y, z) > 0.001) { - Vec3.set(p, x, y, z) - Vec3.transformMat4(p, p, transform) - builder.add(p[0], p[1], p[2], i) - } - if (i % 100000 === 0 && ctx.runtime.shouldUpdate) { - await ctx.runtime.update({ message: 'Creating density points', current: i, max: n }); - } - ++i - } - } - } - return builder.getPoints() -} +// for (let x = 0; x < xn; ++x) { +// for (let y = 0; y < yn; ++y) { +// for (let z = 0; z < zn; ++z) { +// if (get(data, x, y, z) > 0.001) { +// Vec3.set(p, x, y, z) +// Vec3.transformMat4(p, p, transform) +// builder.add(p[0], p[1], p[2], i) +// } +// if (i % 100000 === 0 && ctx.runtime.shouldUpdate) { +// await ctx.runtime.update({ message: 'Creating density points', current: i, max: n }); +// } +// ++i +// } +// } +// } +// return builder.getPoints() +// } -export function GaussianDensityPointVisual(): UnitsVisual<GaussianDensityPointParams> { - return UnitsPointsVisual<GaussianDensityPointParams>({ - defaultProps: PD.getDefaultValues(GaussianDensityPointParams), - createGeometry: createGaussianDensityPoint, - createLocationIterator: StructureElementIterator.fromGroup, - getLoci: () => EmptyLoci, - mark: () => false, - setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianDensityPointParams>, currentProps: PD.Values<GaussianDensityPointParams>) => { - if (newProps.resolution !== currentProps.resolution) state.createGeometry = true - if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true - if (newProps.smoothness !== currentProps.smoothness) state.createGeometry = true - if (newProps.useGpu !== currentProps.useGpu) state.createGeometry = true - if (newProps.ignoreCache !== currentProps.ignoreCache) state.createGeometry = true - } - }) -} \ No newline at end of file +// export function GaussianDensityPointVisual(): UnitsVisual<GaussianDensityPointParams> { +// return UnitsPointsVisual<GaussianDensityPointParams>({ +// defaultProps: PD.getDefaultValues(GaussianDensityPointParams), +// createGeometry: createGaussianDensityPoint, +// createLocationIterator: StructureElementIterator.fromGroup, +// getLoci: () => EmptyLoci, +// mark: () => false, +// setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianDensityPointParams>, currentProps: PD.Values<GaussianDensityPointParams>) => { +// if (newProps.resolution !== currentProps.resolution) state.createGeometry = true +// if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true +// if (newProps.smoothness !== currentProps.smoothness) state.createGeometry = true +// if (newProps.useGpu !== currentProps.useGpu) state.createGeometry = true +// if (newProps.ignoreCache !== currentProps.ignoreCache) state.createGeometry = true +// } +// }) +// } \ No newline at end of file diff --git a/src/mol-repr/structure/visual/gaussian-density-volume.ts b/src/mol-repr/structure/visual/gaussian-density-volume.ts index 6e94b12ee..1f5c32fa1 100644 --- a/src/mol-repr/structure/visual/gaussian-density-volume.ts +++ b/src/mol-repr/structure/visual/gaussian-density-volume.ts @@ -1,54 +1,54 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - */ +// /** +// * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. +// * +// * @author Alexander Rose <alexander.rose@weirdbyte.de> +// */ -import { Unit, Structure } from 'mol-model/structure'; -import { UnitsVisual } from '../representation'; -import { VisualUpdateState } from '../../util'; -import { UnitsDirectVolumeVisual, UnitsDirectVolumeParams } from '../units-visual'; -import { StructureElementIterator, getElementLoci, markElement } from './util/element'; -import { GaussianDensityProps, GaussianDensityParams, computeUnitGaussianDensityTexture } from 'mol-model/structure/structure/unit/gaussian-density'; -import { ParamDefinition as PD } from 'mol-util/param-definition'; -import { DirectVolume } from 'mol-geo/geometry/direct-volume/direct-volume'; -import { VisualContext } from 'mol-repr/representation'; -import { Theme } from 'mol-theme/theme'; +// import { Unit, Structure } from 'mol-model/structure'; +// import { UnitsVisual } from '../representation'; +// import { VisualUpdateState } from '../../util'; +// import { UnitsDirectVolumeVisual, UnitsDirectVolumeParams } from '../units-visual'; +// import { StructureElementIterator, getElementLoci, markElement } from './util/element'; +// import { GaussianDensityProps, GaussianDensityParams, computeUnitGaussianDensityTexture } from 'mol-model/structure/structure/unit/gaussian-density'; +// import { ParamDefinition as PD } from 'mol-util/param-definition'; +// import { DirectVolume } from 'mol-geo/geometry/direct-volume/direct-volume'; +// import { VisualContext } from 'mol-repr/representation'; +// import { Theme } from 'mol-theme/theme'; -async function createGaussianDensityVolume(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, directVolume?: DirectVolume): Promise<DirectVolume> { - const { runtime, webgl } = ctx - if (webgl === undefined) throw new Error('createGaussianDensityVolume requires `webgl` object in VisualContext') +// async function createGaussianDensityVolume(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, directVolume?: DirectVolume): Promise<DirectVolume> { +// const { runtime, webgl } = ctx +// if (webgl === undefined) throw new Error('createGaussianDensityVolume requires `webgl` object in VisualContext') - const p = { ...props, useGpu: true } - const oldTexture = directVolume ? directVolume.gridTexture.ref.value : undefined - const densityTextureData = await computeUnitGaussianDensityTexture(unit, p, webgl, oldTexture).runInContext(runtime) - const { transform, texture, bbox, gridDimension } = densityTextureData +// const p = { ...props, useGpu: true } +// const oldTexture = directVolume ? directVolume.gridTexture.ref.value : undefined +// const densityTextureData = await computeUnitGaussianDensityTexture(unit, p, webgl, oldTexture).runInContext(runtime) +// const { transform, texture, bbox, gridDimension } = densityTextureData - return DirectVolume.create(bbox, gridDimension, transform, texture, directVolume) -} +// return DirectVolume.create(bbox, gridDimension, transform, texture, directVolume) +// } -export const GaussianDensityVolumeParams = { - ...UnitsDirectVolumeParams, - ...GaussianDensityParams, -} -export type GaussianDensityVolumeParams = typeof GaussianDensityVolumeParams +// export const GaussianDensityVolumeParams = { +// ...UnitsDirectVolumeParams, +// ...GaussianDensityParams, +// } +// export type GaussianDensityVolumeParams = typeof GaussianDensityVolumeParams -export function GaussianDensityVolumeVisual(): UnitsVisual<GaussianDensityVolumeParams> { - return UnitsDirectVolumeVisual<GaussianDensityVolumeParams>({ - defaultProps: PD.getDefaultValues(GaussianDensityVolumeParams), - createGeometry: createGaussianDensityVolume, - createLocationIterator: StructureElementIterator.fromGroup, - getLoci: getElementLoci, - mark: markElement, - setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianDensityVolumeParams>, currentProps: PD.Values<GaussianDensityVolumeParams>) => { - if (newProps.resolution !== currentProps.resolution) state.createGeometry = true - if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true - if (newProps.smoothness !== currentProps.smoothness) { - state.createGeometry = true - newProps.isoValue = Math.exp(-newProps.smoothness) - } - if (newProps.useGpu !== currentProps.useGpu) state.createGeometry = true - if (newProps.ignoreCache !== currentProps.ignoreCache) state.createGeometry = true - } - }) -} \ No newline at end of file +// export function GaussianDensityVolumeVisual(): UnitsVisual<GaussianDensityVolumeParams> { +// return UnitsDirectVolumeVisual<GaussianDensityVolumeParams>({ +// defaultProps: PD.getDefaultValues(GaussianDensityVolumeParams), +// createGeometry: createGaussianDensityVolume, +// createLocationIterator: StructureElementIterator.fromGroup, +// getLoci: getElementLoci, +// mark: markElement, +// setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianDensityVolumeParams>, currentProps: PD.Values<GaussianDensityVolumeParams>) => { +// if (newProps.resolution !== currentProps.resolution) state.createGeometry = true +// if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true +// if (newProps.smoothness !== currentProps.smoothness) { +// state.createGeometry = true +// newProps.isoValue = Math.exp(-newProps.smoothness) +// } +// if (newProps.useGpu !== currentProps.useGpu) state.createGeometry = true +// if (newProps.ignoreCache !== currentProps.ignoreCache) state.createGeometry = true +// } +// }) +// } \ No newline at end of file diff --git a/src/mol-repr/structure/visual/gaussian-surface-mesh.ts b/src/mol-repr/structure/visual/gaussian-surface-mesh.ts index 75e5550be..b4dbdce9d 100644 --- a/src/mol-repr/structure/visual/gaussian-surface-mesh.ts +++ b/src/mol-repr/structure/visual/gaussian-surface-mesh.ts @@ -1,58 +1,58 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - */ +// /** +// * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. +// * +// * @author Alexander Rose <alexander.rose@weirdbyte.de> +// */ -import { Unit, Structure } from 'mol-model/structure'; -import { UnitsVisual } from '../representation'; -import { VisualUpdateState } from '../../util'; -import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; -import { StructureElementIterator, getElementLoci, markElement } from './util/element'; -import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; -import { ParamDefinition as PD } from 'mol-util/param-definition'; -import { Mesh } from 'mol-geo/geometry/mesh/mesh'; -import { computeMarchingCubesMesh } from 'mol-geo/util/marching-cubes/algorithm'; -import { VisualContext } from 'mol-repr/representation'; -import { Theme } from 'mol-theme/theme'; +// import { Unit, Structure } from 'mol-model/structure'; +// import { UnitsVisual } from '../representation'; +// import { VisualUpdateState } from '../../util'; +// import { UnitsMeshVisual, UnitsMeshParams } from '../units-visual'; +// import { StructureElementIterator, getElementLoci, markElement } from './util/element'; +// import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; +// import { ParamDefinition as PD } from 'mol-util/param-definition'; +// import { Mesh } from 'mol-geo/geometry/mesh/mesh'; +// import { computeMarchingCubesMesh } from 'mol-geo/util/marching-cubes/algorithm'; +// import { VisualContext } from 'mol-repr/representation'; +// import { Theme } from 'mol-theme/theme'; -async function createGaussianSurfaceMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, mesh?: Mesh): Promise<Mesh> { - const { smoothness } = props - const { transform, field, idField } = await unit.computeGaussianDensity(props, ctx.runtime, ctx.webgl) +// async function createGaussianSurfaceMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, mesh?: Mesh): Promise<Mesh> { +// const { smoothness } = props +// const { transform, field, idField } = await unit.computeGaussianDensity(props, ctx.runtime, ctx.webgl) - const params = { - isoLevel: Math.exp(-smoothness), - scalarField: field, - idField - } - const surface = await computeMarchingCubesMesh(params, mesh).runAsChild(ctx.runtime) +// const params = { +// isoLevel: Math.exp(-smoothness), +// scalarField: field, +// idField +// } +// const surface = await computeMarchingCubesMesh(params, mesh).runAsChild(ctx.runtime) - Mesh.transformImmediate(surface, transform) - Mesh.computeNormalsImmediate(surface) - Mesh.uniformTriangleGroup(surface) +// Mesh.transformImmediate(surface, transform) +// Mesh.computeNormalsImmediate(surface) +// Mesh.uniformTriangleGroup(surface) - return surface; -} +// return surface; +// } -export const GaussianSurfaceParams = { - ...UnitsMeshParams, - ...GaussianDensityParams, -} -export type GaussianSurfaceParams = typeof GaussianSurfaceParams +// export const GaussianSurfaceParams = { +// ...UnitsMeshParams, +// ...GaussianDensityParams, +// } +// export type GaussianSurfaceParams = typeof GaussianSurfaceParams -export function GaussianSurfaceVisual(): UnitsVisual<GaussianSurfaceParams> { - return UnitsMeshVisual<GaussianSurfaceParams>({ - defaultProps: PD.getDefaultValues(GaussianSurfaceParams), - createGeometry: createGaussianSurfaceMesh, - createLocationIterator: StructureElementIterator.fromGroup, - getLoci: getElementLoci, - mark: markElement, - setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianSurfaceParams>, currentProps: PD.Values<GaussianSurfaceParams>) => { - if (newProps.resolution !== currentProps.resolution) state.createGeometry = true - if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true - if (newProps.smoothness !== currentProps.smoothness) state.createGeometry = true - if (newProps.useGpu !== currentProps.useGpu) state.createGeometry = true - if (newProps.ignoreCache !== currentProps.ignoreCache) state.createGeometry = true - } - }) -} \ No newline at end of file +// export function GaussianSurfaceVisual(): UnitsVisual<GaussianSurfaceParams> { +// return UnitsMeshVisual<GaussianSurfaceParams>({ +// defaultProps: PD.getDefaultValues(GaussianSurfaceParams), +// createGeometry: createGaussianSurfaceMesh, +// createLocationIterator: StructureElementIterator.fromGroup, +// getLoci: getElementLoci, +// mark: markElement, +// setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianSurfaceParams>, currentProps: PD.Values<GaussianSurfaceParams>) => { +// if (newProps.resolution !== currentProps.resolution) state.createGeometry = true +// if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true +// if (newProps.smoothness !== currentProps.smoothness) state.createGeometry = true +// if (newProps.useGpu !== currentProps.useGpu) state.createGeometry = true +// if (newProps.ignoreCache !== currentProps.ignoreCache) state.createGeometry = true +// } +// }) +// } \ No newline at end of file diff --git a/src/mol-repr/structure/visual/gaussian-surface-wireframe.ts b/src/mol-repr/structure/visual/gaussian-surface-wireframe.ts index dea76bc8d..c0a51d592 100644 --- a/src/mol-repr/structure/visual/gaussian-surface-wireframe.ts +++ b/src/mol-repr/structure/visual/gaussian-surface-wireframe.ts @@ -1,57 +1,57 @@ -/** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. - * - * @author Alexander Rose <alexander.rose@weirdbyte.de> - */ +// /** +// * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. +// * +// * @author Alexander Rose <alexander.rose@weirdbyte.de> +// */ -import { Unit, Structure } from 'mol-model/structure'; -import { UnitsVisual } from '../representation'; -import { VisualUpdateState } from '../../util'; -import { UnitsLinesVisual, UnitsLinesParams } from '../units-visual'; -import { StructureElementIterator, getElementLoci, markElement } from './util/element'; -import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; -import { ParamDefinition as PD } from 'mol-util/param-definition'; -import { Lines } from 'mol-geo/geometry/lines/lines'; -import { computeMarchingCubesLines } from 'mol-geo/util/marching-cubes/algorithm'; -import { VisualContext } from 'mol-repr/representation'; -import { Theme } from 'mol-theme/theme'; +// import { Unit, Structure } from 'mol-model/structure'; +// import { UnitsVisual } from '../representation'; +// import { VisualUpdateState } from '../../util'; +// import { UnitsLinesVisual, UnitsLinesParams } from '../units-visual'; +// import { StructureElementIterator, getElementLoci, markElement } from './util/element'; +// import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure/structure/unit/gaussian-density'; +// import { ParamDefinition as PD } from 'mol-util/param-definition'; +// import { Lines } from 'mol-geo/geometry/lines/lines'; +// import { computeMarchingCubesLines } from 'mol-geo/util/marching-cubes/algorithm'; +// import { VisualContext } from 'mol-repr/representation'; +// import { Theme } from 'mol-theme/theme'; -async function createGaussianWireframe(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, lines?: Lines): Promise<Lines> { - const { smoothness } = props - const { transform, field, idField } = await unit.computeGaussianDensity(props, ctx.runtime) +// function createGaussianWireframe(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, lines?: Lines): Promise<Lines> { +// const { smoothness } = props +// const { transform, field, idField } = await unit.computeGaussianDensity(props, ctx.runtime) - const params = { - isoLevel: Math.exp(-smoothness), - scalarField: field, - idField - } - const wireframe = await computeMarchingCubesLines(params, lines).runAsChild(ctx.runtime) +// const params = { +// isoLevel: Math.exp(-smoothness), +// scalarField: field, +// idField +// } +// const wireframe = await computeMarchingCubesLines(params, lines).runAsChild(ctx.runtime) - Lines.transformImmediate(wireframe, transform) +// Lines.transformImmediate(wireframe, transform) - return wireframe -} +// return wireframe +// } -export const GaussianWireframeParams = { - ...UnitsLinesParams, - ...GaussianDensityParams, - lineSizeAttenuation: PD.Boolean(false), -} -export type GaussianWireframeParams = typeof GaussianWireframeParams +// export const GaussianWireframeParams = { +// ...UnitsLinesParams, +// ...GaussianDensityParams, +// lineSizeAttenuation: PD.Boolean(false), +// } +// export type GaussianWireframeParams = typeof GaussianWireframeParams -export function GaussianWireframeVisual(): UnitsVisual<GaussianWireframeParams> { - return UnitsLinesVisual<GaussianWireframeParams>({ - defaultProps: PD.getDefaultValues(GaussianWireframeParams), - createGeometry: createGaussianWireframe, - createLocationIterator: StructureElementIterator.fromGroup, - getLoci: getElementLoci, - mark: markElement, - setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianWireframeParams>, currentProps: PD.Values<GaussianWireframeParams>) => { - if (newProps.resolution !== currentProps.resolution) state.createGeometry = true - if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true - if (newProps.smoothness !== currentProps.smoothness) state.createGeometry = true - if (newProps.useGpu !== currentProps.useGpu) state.createGeometry = true - if (newProps.ignoreCache !== currentProps.ignoreCache) state.createGeometry = true - } - }) -} \ No newline at end of file +// export function GaussianWireframeVisual(): UnitsVisual<GaussianWireframeParams> { +// return UnitsLinesVisual<GaussianWireframeParams>({ +// defaultProps: PD.getDefaultValues(GaussianWireframeParams), +// createGeometry: createGaussianWireframe, +// createLocationIterator: StructureElementIterator.fromGroup, +// getLoci: getElementLoci, +// mark: markElement, +// setUpdateState: (state: VisualUpdateState, newProps: PD.Values<GaussianWireframeParams>, currentProps: PD.Values<GaussianWireframeParams>) => { +// if (newProps.resolution !== currentProps.resolution) state.createGeometry = true +// if (newProps.radiusOffset !== currentProps.radiusOffset) state.createGeometry = true +// if (newProps.smoothness !== currentProps.smoothness) state.createGeometry = true +// if (newProps.useGpu !== currentProps.useGpu) state.createGeometry = true +// if (newProps.ignoreCache !== currentProps.ignoreCache) state.createGeometry = true +// } +// }) +// } \ No newline at end of file diff --git a/src/mol-repr/structure/visual/inter-unit-link-cylinder.ts b/src/mol-repr/structure/visual/inter-unit-link-cylinder.ts index f9cd1c147..5f298b7d9 100644 --- a/src/mol-repr/structure/visual/inter-unit-link-cylinder.ts +++ b/src/mol-repr/structure/visual/inter-unit-link-cylinder.ts @@ -19,7 +19,7 @@ import { PickingId } from 'mol-geo/geometry/picking'; import { VisualContext } from 'mol-repr/representation'; import { Theme } from 'mol-theme/theme'; -async function createInterUnitLinkCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<InterUnitLinkParams>, mesh?: Mesh) { +function createInterUnitLinkCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<InterUnitLinkParams>, mesh?: Mesh) { const links = structure.links const { bondCount, bonds } = links const { sizeFactor, sizeAspectRatio } = props diff --git a/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts b/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts index beaa507fe..1dcfc59d4 100644 --- a/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts +++ b/src/mol-repr/structure/visual/intra-unit-link-cylinder.ts @@ -20,7 +20,7 @@ import { PickingId } from 'mol-geo/geometry/picking'; import { VisualContext } from 'mol-repr/representation'; import { Theme } from 'mol-theme/theme'; -async function createIntraUnitLinkCylinderMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PD.Values<IntraUnitLinkParams>, mesh?: Mesh) { +function createIntraUnitLinkCylinderMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PD.Values<IntraUnitLinkParams>, mesh?: Mesh) { if (!Unit.isAtomic(unit)) return Mesh.createEmpty(mesh) const location = StructureElement.create(unit) diff --git a/src/mol-repr/structure/visual/nucleotide-block-mesh.ts b/src/mol-repr/structure/visual/nucleotide-block-mesh.ts index b3be2492c..2cf7c0b2d 100644 --- a/src/mol-repr/structure/visual/nucleotide-block-mesh.ts +++ b/src/mol-repr/structure/visual/nucleotide-block-mesh.ts @@ -41,7 +41,7 @@ export const NucleotideBlockMeshParams = { export const DefaultNucleotideBlockMeshProps = PD.getDefaultValues(NucleotideBlockMeshParams) export type NucleotideBlockMeshProps = typeof DefaultNucleotideBlockMeshProps -async function createNucleotideBlockMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: NucleotideBlockMeshProps, mesh?: Mesh) { +function createNucleotideBlockMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: NucleotideBlockMeshProps, mesh?: Mesh) { if (!Unit.isAtomic(unit)) return Mesh.createEmpty(mesh) const { sizeFactor } = props @@ -109,9 +109,6 @@ async function createNucleotideBlockMesh(ctx: VisualContext, unit: Unit, structu } } - if (i % 10000 === 0 && ctx.runtime.shouldUpdate) { - await ctx.runtime.update({ message: 'Nucleotide block mesh', current: i }); - } ++i } } diff --git a/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts b/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts index 2e27f6e0a..f3fb52f2d 100644 --- a/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts +++ b/src/mol-repr/structure/visual/polymer-backbone-cylinder.ts @@ -27,7 +27,8 @@ export const PolymerBackboneCylinderParams = { export const DefaultPolymerBackboneCylinderProps = PD.getDefaultValues(PolymerBackboneCylinderParams) export type PolymerBackboneCylinderProps = typeof DefaultPolymerBackboneCylinderProps -async function createPolymerBackboneCylinderMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PolymerBackboneCylinderProps, mesh?: Mesh) { +// TODO do group id based on polymer index not element index +function createPolymerBackboneCylinderMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PolymerBackboneCylinderProps, mesh?: Mesh) { const polymerElementCount = unit.polymerElements.length if (!polymerElementCount) return Mesh.createEmpty(mesh) @@ -42,7 +43,6 @@ async function createPolymerBackboneCylinderMesh(ctx: VisualContext, unit: Unit, const pB = Vec3.zero() const cylinderProps: CylinderProps = { radiusTop: 1, radiusBottom: 1, radialSegments } - let i = 0 const polymerBackboneIt = PolymerBackboneIterator(unit) while (polymerBackboneIt.hasNext) { const { centerA, centerB } = polymerBackboneIt.move() @@ -56,11 +56,6 @@ async function createPolymerBackboneCylinderMesh(ctx: VisualContext, unit: Unit, cylinderProps.radiusTop = cylinderProps.radiusBottom = theme.size.size(centerB) * sizeFactor builder.setGroup(OrderedSet.indexOf(elements, centerB.element)) addCylinder(builder, pB, pA, 0.5, cylinderProps) - - if (i % 10000 === 0 && ctx.runtime.shouldUpdate) { - await ctx.runtime.update({ message: 'Backbone mesh', current: i, max: polymerElementCount }); - } - ++i } return builder.getMesh() diff --git a/src/mol-repr/structure/visual/polymer-direction-wedge.ts b/src/mol-repr/structure/visual/polymer-direction-wedge.ts index 3c9dc41c3..f0df188e9 100644 --- a/src/mol-repr/structure/visual/polymer-direction-wedge.ts +++ b/src/mol-repr/structure/visual/polymer-direction-wedge.ts @@ -36,7 +36,7 @@ export const PolymerDirectionWedgeParams = { export const DefaultPolymerDirectionWedgeProps = PD.getDefaultValues(PolymerDirectionWedgeParams) export type PolymerDirectionWedgeProps = typeof DefaultPolymerDirectionWedgeProps -async function createPolymerDirectionWedgeMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PolymerDirectionWedgeProps, mesh?: Mesh) { +function createPolymerDirectionWedgeMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PolymerDirectionWedgeProps, mesh?: Mesh) { const polymerElementCount = unit.polymerElements.length if (!polymerElementCount) return Mesh.createEmpty(mesh) @@ -80,9 +80,6 @@ async function createPolymerDirectionWedgeMesh(ctx: VisualContext, unit: Unit, s builder.add(t, wedge) } - if (i % 10000 === 0 && ctx.runtime.shouldUpdate) { - await ctx.runtime.update({ message: 'Polymer direction mesh', current: i, max: polymerElementCount }); - } ++i } diff --git a/src/mol-repr/structure/visual/polymer-gap-cylinder.ts b/src/mol-repr/structure/visual/polymer-gap-cylinder.ts index 818837ce1..0bd618b6f 100644 --- a/src/mol-repr/structure/visual/polymer-gap-cylinder.ts +++ b/src/mol-repr/structure/visual/polymer-gap-cylinder.ts @@ -29,7 +29,7 @@ export const PolymerGapCylinderParams = { export const DefaultPolymerGapCylinderProps = PD.getDefaultValues(PolymerGapCylinderParams) export type PolymerGapCylinderProps = typeof DefaultPolymerGapCylinderProps -async function createPolymerGapCylinderMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PolymerGapCylinderProps, mesh?: Mesh) { +function createPolymerGapCylinderMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PolymerGapCylinderProps, mesh?: Mesh) { const polymerGapCount = unit.gapElements.length if (!polymerGapCount) return Mesh.createEmpty(mesh) @@ -66,9 +66,6 @@ async function createPolymerGapCylinderMesh(ctx: VisualContext, unit: Unit, stru addFixedCountDashedCylinder(builder, pB, pA, 0.5, segmentCount, cylinderProps) } - if (i % 10000 === 0 && ctx.runtime.shouldUpdate) { - await ctx.runtime.update({ message: 'Gap mesh', current: i, max: polymerGapCount }); - } i += 2 } diff --git a/src/mol-repr/structure/visual/polymer-trace-mesh.ts b/src/mol-repr/structure/visual/polymer-trace-mesh.ts index 6890b4853..0f9f4d38a 100644 --- a/src/mol-repr/structure/visual/polymer-trace-mesh.ts +++ b/src/mol-repr/structure/visual/polymer-trace-mesh.ts @@ -30,7 +30,7 @@ export type PolymerTraceMeshProps = typeof DefaultPolymerTraceMeshProps // TODO handle polymer ends properly -async function createPolymerTraceMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PolymerTraceMeshProps, mesh?: Mesh) { +function createPolymerTraceMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PolymerTraceMeshProps, mesh?: Mesh) { const polymerElementCount = unit.polymerElements.length if (!polymerElementCount) return Mesh.createEmpty(mesh) @@ -77,9 +77,6 @@ async function createPolymerTraceMesh(ctx: VisualContext, unit: Unit, structure: addTube(builder, curvePoints, normalVectors, binormalVectors, linearSegments, radialSegments, width, height, 1, v.secStrucFirst, v.secStrucLast) } - if (i % 10000 === 0 && ctx.runtime.shouldUpdate) { - await ctx.runtime.update({ message: 'Polymer trace mesh', current: i, max: polymerElementCount }); - } ++i } diff --git a/src/mol-repr/structure/visual/util/element.ts b/src/mol-repr/structure/visual/util/element.ts index 38188c438..e95a606a6 100644 --- a/src/mol-repr/structure/visual/util/element.ts +++ b/src/mol-repr/structure/visual/util/element.ts @@ -23,7 +23,7 @@ export interface ElementSphereMeshProps { sizeFactor: number } -export async function createElementSphereMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: ElementSphereMeshProps, mesh?: Mesh) { +export function createElementSphereMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: ElementSphereMeshProps, mesh?: Mesh) { const { detail, sizeFactor } = props const { elements } = unit; @@ -42,10 +42,6 @@ export async function createElementSphereMesh(ctx: VisualContext, unit: Unit, st meshBuilder.setGroup(i) addSphere(meshBuilder, v, theme.size.size(l) * sizeFactor, detail) - - if (i % 10000 === 0 && ctx.runtime.shouldUpdate) { - await ctx.runtime.update({ message: 'Sphere mesh', current: i, max: elementCount }); - } } return meshBuilder.getMesh() diff --git a/src/mol-repr/structure/visual/util/link.ts b/src/mol-repr/structure/visual/util/link.ts index a080395f4..5f102bdfe 100644 --- a/src/mol-repr/structure/visual/util/link.ts +++ b/src/mol-repr/structure/visual/util/link.ts @@ -66,7 +66,7 @@ export interface LinkCylinderMeshBuilderProps { * Each edge is included twice to allow for coloring/picking * the half closer to the first vertex, i.e. vertex a. */ -export async function createLinkCylinderMesh(ctx: VisualContext, linkBuilder: LinkCylinderMeshBuilderProps, props: LinkCylinderProps, mesh?: Mesh) { +export function createLinkCylinderMesh(ctx: VisualContext, linkBuilder: LinkCylinderMeshBuilderProps, props: LinkCylinderProps, mesh?: Mesh) { const { linkCount, referencePosition, position, order, flags, radius } = linkBuilder if (!linkCount) return Mesh.createEmpty(mesh) @@ -109,10 +109,6 @@ export async function createLinkCylinderMesh(ctx: VisualContext, linkBuilder: Li cylinderProps.radiusTop = cylinderProps.radiusBottom = linkRadius addCylinder(meshBuilder, va, vb, 0.5, cylinderProps) } - - if (edgeIndex % 10000 === 0 && ctx.runtime.shouldUpdate) { - await ctx.runtime.update({ message: 'Cylinder mesh', current: edgeIndex, max: linkCount }); - } } return meshBuilder.getMesh() -- GitLab