diff --git a/src/apps/canvas/structure-view.ts b/src/apps/canvas/structure-view.ts index 36865663af9be4f3e8a1190cd3648f8d29a56c0d..4490697d596f412d8d95292714c44984959091b1 100644 --- a/src/apps/canvas/structure-view.ts +++ b/src/apps/canvas/structure-view.ts @@ -156,24 +156,24 @@ export async function StructureView(viewer: Viewer, models: ReadonlyArray<Model> async function createStructureRepr() { if (structure) { console.log('createStructureRepr') - // await cartoon.createOrUpdate({ - // colorTheme: { name: 'unit-index' }, - // sizeTheme: { name: 'uniform', value: 0.2 }, - // useFog: false // TODO fog not working properly - // }, structure).run() - - await point.createOrUpdate({ + await cartoon.createOrUpdate({ colorTheme: { name: 'unit-index' }, sizeTheme: { name: 'uniform', value: 0.2 }, useFog: false // TODO fog not working properly }, structure).run() - // await ballAndStick.createOrUpdate({ + // await point.createOrUpdate({ // colorTheme: { name: 'unit-index' }, - // sizeTheme: { name: 'uniform', value: 0.1 }, + // sizeTheme: { name: 'uniform', value: 0.2 }, // useFog: false // TODO fog not working properly // }, structure).run() + await ballAndStick.createOrUpdate({ + colorTheme: { name: 'unit-index' }, + sizeTheme: { name: 'uniform', value: 0.1 }, + useFog: false // TODO fog not working properly + }, structure).run() + // await carbohydrate.createOrUpdate({ // colorTheme: { name: 'carbohydrate-symbol' }, // sizeTheme: { name: 'uniform', value: 1, factor: 1 }, diff --git a/src/mol-geo/representation/structure/complex-visual.ts b/src/mol-geo/representation/structure/complex-visual.ts index 542d169e70f5ca2f7ce66fb2863e833f8304fe26..343a6082d9a9af562cd7a7a63834301a46e0331c 100644 --- a/src/mol-geo/representation/structure/complex-visual.ts +++ b/src/mol-geo/representation/structure/complex-visual.ts @@ -44,17 +44,18 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe let mesh: Mesh let currentStructure: Structure let locationIt: LocationIterator - let conformationHashCode: number + let conformationHash: number async function create(ctx: RuntimeContext, structure: Structure, props: Partial<P> = {}) { currentProps = Object.assign({}, defaultProps, props) currentStructure = structure - conformationHashCode = Structure.conformationHash(currentStructure) + conformationHash = Structure.conformationHash(currentStructure) mesh = await createMesh(ctx, currentStructure, currentProps, mesh) locationIt = createLocationIterator(structure) renderObject = await createComplexMeshRenderObject(ctx, structure, mesh, locationIt, currentProps) + console.log(renderObject.values) } async function update(ctx: RuntimeContext, props: Partial<P>) { @@ -66,9 +67,9 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe MeshUpdateState.reset(updateState) setUpdateState(updateState, newProps, currentProps) - const newConformationHashCode = Structure.conformationHash(currentStructure) - if (newConformationHashCode !== conformationHashCode) { - conformationHashCode = newConformationHashCode + const newConformationHash = Structure.conformationHash(currentStructure) + if (newConformationHash !== conformationHash) { + conformationHash = newConformationHash updateState.createMesh = true } diff --git a/src/mol-geo/representation/structure/units-visual.ts b/src/mol-geo/representation/structure/units-visual.ts index 86ec2ac9d6478677624785be79c658793676847d..40914b11bf0eb5500b6747468302ca1fb6890e6d 100644 --- a/src/mol-geo/representation/structure/units-visual.ts +++ b/src/mol-geo/representation/structure/units-visual.ts @@ -61,7 +61,6 @@ export function UnitsMeshVisual<P extends UnitsMeshProps>(builder: UnitsMeshVisu // TODO create empty location iterator when not in unitKinds locationIt = createLocationIterator(group) renderObject = await createUnitsMeshRenderObject(ctx, group, mesh, locationIt, currentProps) - console.log(renderObject.values.uInstanceCount.ref.value, renderObject.values.uGroupCount.ref.value) } async function update(ctx: RuntimeContext, props: Partial<P> = {}) { diff --git a/src/mol-geo/representation/structure/visual/carbohydrate-link-cylinder.ts b/src/mol-geo/representation/structure/visual/carbohydrate-link-cylinder.ts index 6526391f04326d93df99dd68f5c35c69de5d16c0..dca53ec6fe4b9beab83016395e6139a1a2623bc0 100644 --- a/src/mol-geo/representation/structure/visual/carbohydrate-link-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/carbohydrate-link-cylinder.ts @@ -100,7 +100,7 @@ function CarbohydrateLinkIterator(structure: Structure): LocationIterator { location.bIndex = indexB as StructureElement.UnitIndex return location } - return LocationIterator(groupCount, instanceCount, getLocation) + return LocationIterator(groupCount, instanceCount, getLocation, true) } function getLinkLoci(pickingId: PickingId, structure: Structure, id: number) { diff --git a/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts b/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts index 6546a2b2ac14106953307cabfb2655f3db9b7311..50b85fb4da1223a8ba6ec89b97f9b2b1ba2af306 100644 --- a/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts +++ b/src/mol-geo/representation/structure/visual/carbohydrate-symbol-mesh.ts @@ -172,7 +172,7 @@ function CarbohydrateElementIterator(structure: Structure): LocationIterator { function isSecondary (elementIndex: number, instanceIndex: number) { return (elementIndex % 2) === 1 } - return LocationIterator(groupCount, instanceCount, getLocation, isSecondary) + return LocationIterator(groupCount, instanceCount, getLocation, true, isSecondary) } function getCarbohydrateLoci(pickingId: PickingId, structure: Structure, id: number) { diff --git a/src/mol-geo/representation/structure/visual/cross-link-restraint-cylinder.ts b/src/mol-geo/representation/structure/visual/cross-link-restraint-cylinder.ts index 6bd885217c6132fbbdce6ed6ed481aeb68afda33..735499fd290cee6d58f5213079613c20aed9d75b 100644 --- a/src/mol-geo/representation/structure/visual/cross-link-restraint-cylinder.ts +++ b/src/mol-geo/representation/structure/visual/cross-link-restraint-cylinder.ts @@ -84,7 +84,7 @@ function CrossLinkRestraintIterator(structure: Structure): LocationIterator { location.bIndex = pair.indexB return location } - return LocationIterator(groupCount, instanceCount, getLocation) + return LocationIterator(groupCount, instanceCount, getLocation, true) } function getLinkLoci(pickingId: PickingId, structure: Structure, id: number) { diff --git a/src/mol-geo/representation/structure/visual/util/common.ts b/src/mol-geo/representation/structure/visual/util/common.ts index de91023bf6d9d9a8df8904ab1d605b64b09af49e..6e5a74848abd82bc342c42f866e1132731aaf275 100644 --- a/src/mol-geo/representation/structure/visual/util/common.ts +++ b/src/mol-geo/representation/structure/visual/util/common.ts @@ -26,7 +26,9 @@ import { TransformData, createIdentityTransform, createTransforms } from '../../ export function createColors(ctx: RuntimeContext, locationIt: LocationIterator, props: ColorThemeProps, colorData?: ColorData): Promise<ColorData> { const colorTheme = ColorTheme(props) - switch (colorTheme.kind) { + // Always use 'group' kind for 'complex' location iterators, i.e. an instance may include multiple units + const kind = colorTheme.kind === 'instance' && locationIt.isComplex ? 'group' : colorTheme.kind + switch (kind) { case 'uniform': return createUniformColor(ctx, locationIt, colorTheme.color, colorData) case 'group': return createGroupColor(ctx, locationIt, colorTheme.color, colorData) case 'groupInstance': return createGroupInstanceColor(ctx, locationIt, colorTheme.color, colorData) diff --git a/src/mol-geo/representation/structure/visual/util/link.ts b/src/mol-geo/representation/structure/visual/util/link.ts index 865e52d99668e5d38d9c950928953049444e2253..3978bfc9aa16761e0c431526e0448d786220a2d7 100644 --- a/src/mol-geo/representation/structure/visual/util/link.ts +++ b/src/mol-geo/representation/structure/visual/util/link.ts @@ -146,6 +146,6 @@ export namespace LinkIterator { location.bIndex = bond.indexB as StructureElement.UnitIndex return location } - return LocationIterator(groupCount, instanceCount, getLocation) + return LocationIterator(groupCount, instanceCount, getLocation, true) } } \ No newline at end of file diff --git a/src/mol-geo/util/location-iterator.ts b/src/mol-geo/util/location-iterator.ts index 435d0c45c3be8181456098ec99331c4cf7f579d5..16c3517098b273acfd6fc7c48f58055fd07b335e 100644 --- a/src/mol-geo/util/location-iterator.ts +++ b/src/mol-geo/util/location-iterator.ts @@ -28,6 +28,8 @@ export interface LocationIterator extends Iterator<LocationValue> { readonly isNextNewInstance: boolean readonly groupCount: number readonly instanceCount: number + /** If true, may have multiple units per instance; if false one unit per instance */ + readonly isComplex: boolean move(): LocationValue reset(): void skipInstance(): void @@ -36,7 +38,7 @@ export interface LocationIterator extends Iterator<LocationValue> { type LocationGetter = (groupIndex: number, instanceIndex: number) => Location type IsSecondaryGetter = (groupIndex: number, instanceIndex: number) => boolean -export function LocationIterator(groupCount: number, instanceCount: number, getLocation: LocationGetter, isSecondary: IsSecondaryGetter = () => false): LocationIterator { +export function LocationIterator(groupCount: number, instanceCount: number, getLocation: LocationGetter, isComplex = false, isSecondary: IsSecondaryGetter = () => false): LocationIterator { const value: LocationValue = { location: NullLocation as Location, index: 0, @@ -55,6 +57,7 @@ export function LocationIterator(groupCount: number, instanceCount: number, getL get isNextNewInstance () { return isNextNewInstance }, get groupCount () { return groupCount }, get instanceCount () { return instanceCount }, + isComplex, move() { if (hasNext) { value.groupIndex = groupIndex