Skip to content
Snippets Groups Projects
Commit 7fd12c56 authored by Alexander Rose's avatar Alexander Rose
Browse files

tweaks/fixes

parent 47442be9
No related branches found
No related tags found
No related merge requests found
...@@ -317,21 +317,21 @@ namespace Scene { ...@@ -317,21 +317,21 @@ namespace Scene {
get markerAverage() { get markerAverage() {
if (markerAverageDirty) { if (markerAverageDirty) {
markerAverage = calculateMarkerAverage(); markerAverage = calculateMarkerAverage();
markerAverageDirty = true; markerAverageDirty = false;
} }
return markerAverage; return markerAverage;
}, },
get opacityAverage() { get opacityAverage() {
if (opacityAverageDirty) { if (opacityAverageDirty) {
opacityAverage = calculateOpacityAverage(); opacityAverage = calculateOpacityAverage();
opacityAverageDirty = true; opacityAverageDirty = false;
} }
return opacityAverage; return opacityAverage;
}, },
get hasOpaque() { get hasOpaque() {
if (hasOpaqueDirty) { if (hasOpaqueDirty) {
hasOpaque = calculateHasOpaque(); hasOpaque = calculateHasOpaque();
hasOpaqueDirty = true; hasOpaqueDirty = false;
} }
return hasOpaque; return hasOpaque;
}, },
......
/** /**
* Copyright (c) 2017-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2017-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
...@@ -177,15 +177,15 @@ namespace SymmetryOperator { ...@@ -177,15 +177,15 @@ namespace SymmetryOperator {
export interface Coordinates { x: ArrayLike<number>, y: ArrayLike<number>, z: ArrayLike<number> } export interface Coordinates { x: ArrayLike<number>, y: ArrayLike<number>, z: ArrayLike<number> }
export function createMapping<T extends number>(operator: SymmetryOperator, coords: Coordinates, radius: ((index: T) => number)): ArrayMapping<T> { function _createMapping<T extends number>(operator: SymmetryOperator, coords: Coordinates, radius: ((index: T) => number)): ArrayMapping<T> {
const invariantPosition = createCoordinateMapper(SymmetryOperator.Default, coords); const invariantPosition = createCoordinateMapper(SymmetryOperator.Default, coords);
const position = operator.isIdentity ? invariantPosition : createCoordinateMapper(operator, coords); const position = operator.isIdentity ? invariantPosition : createCoordinateMapper(operator, coords);
const { x, y, z } = createProjections(operator, coords); const { x, y, z } = createProjections(operator, coords);
return { operator, coordinates: coords, invariantPosition, position, x, y, z, r: radius }; return { operator, coordinates: coords, invariantPosition, position, x, y, z, r: radius };
} }
export function createMappingZeroRadius<T extends number>(operator: SymmetryOperator, coords: Coordinates): ArrayMapping<T> { export function createMapping<T extends number>(operator: SymmetryOperator, coords: Coordinates, radius: ((index: T) => number) = _zeroRadius) {
return createMapping(operator, coords, _zeroRadius); return _createMapping(operator, coords, radius);
} }
export function createCoordinateMapper<T extends number>(t: SymmetryOperator, coords: Coordinates): CoordinateMapper<T> { export function createCoordinateMapper<T extends number>(t: SymmetryOperator, coords: Coordinates): CoordinateMapper<T> {
......
/** /**
* Copyright (c) 2017-2022 mol* contributors, licensed under MIT, See LICENSE file for more info. * Copyright (c) 2017-2023 mol* contributors, licensed under MIT, See LICENSE file for more info.
* *
* @author David Sehnal <david.sehnal@gmail.com> * @author David Sehnal <david.sehnal@gmail.com>
* @author Alexander Rose <alexander.rose@weirdbyte.de> * @author Alexander Rose <alexander.rose@weirdbyte.de>
...@@ -46,7 +46,7 @@ namespace Unit { ...@@ -46,7 +46,7 @@ namespace Unit {
export function create<K extends Kind>(id: number, invariantId: number, chainGroupId: number, traits: Traits, kind: Kind, model: Model, operator: SymmetryOperator, elements: StructureElement.Set, props?: K extends Kind.Atomic ? AtomicProperties : CoarseProperties): Unit { export function create<K extends Kind>(id: number, invariantId: number, chainGroupId: number, traits: Traits, kind: Kind, model: Model, operator: SymmetryOperator, elements: StructureElement.Set, props?: K extends Kind.Atomic ? AtomicProperties : CoarseProperties): Unit {
switch (kind) { switch (kind) {
case Kind.Atomic: return new Atomic(id, invariantId, chainGroupId, traits, model, elements, SymmetryOperator.createMappingZeroRadius(operator, model.atomicConformation), props ?? AtomicProperties()); case Kind.Atomic: return new Atomic(id, invariantId, chainGroupId, traits, model, elements, SymmetryOperator.createMapping(operator, model.atomicConformation), props ?? AtomicProperties());
case Kind.Spheres: return createCoarse(id, invariantId, chainGroupId, traits, model, Kind.Spheres, elements, SymmetryOperator.createMapping(operator, model.coarseConformation.spheres, getSphereRadiusFunc(model)), props ?? CoarseProperties()); case Kind.Spheres: return createCoarse(id, invariantId, chainGroupId, traits, model, Kind.Spheres, elements, SymmetryOperator.createMapping(operator, model.coarseConformation.spheres, getSphereRadiusFunc(model)), props ?? CoarseProperties());
case Kind.Gaussians: return createCoarse(id, invariantId, chainGroupId, traits, model, Kind.Gaussians, elements, SymmetryOperator.createMapping(operator, model.coarseConformation.gaussians, getGaussianRadiusFunc(model)), props ?? CoarseProperties()); case Kind.Gaussians: return createCoarse(id, invariantId, chainGroupId, traits, model, Kind.Gaussians, elements, SymmetryOperator.createMapping(operator, model.coarseConformation.gaussians, getGaussianRadiusFunc(model)), props ?? CoarseProperties());
} }
...@@ -247,7 +247,7 @@ namespace Unit { ...@@ -247,7 +247,7 @@ namespace Unit {
} }
const conformation = (this.model.atomicConformation !== model.atomicConformation || operator !== this.conformation.operator) const conformation = (this.model.atomicConformation !== model.atomicConformation || operator !== this.conformation.operator)
? SymmetryOperator.createMappingZeroRadius(operator, model.atomicConformation) ? SymmetryOperator.createMapping(operator, model.atomicConformation)
: this.conformation; : this.conformation;
return new Atomic(this.id, this.invariantId, this.chainGroupId, this.traits, model, this.elements, conformation, props); return new Atomic(this.id, this.invariantId, this.chainGroupId, this.traits, model, this.elements, conformation, props);
} }
...@@ -408,7 +408,7 @@ namespace Unit { ...@@ -408,7 +408,7 @@ namespace Unit {
} }
const conformation = coarseConformation !== modelCoarseConformation const conformation = coarseConformation !== modelCoarseConformation
? SymmetryOperator.createMappingZeroRadius(this.conformation.operator, modelCoarseConformation) ? SymmetryOperator.createMapping(this.conformation.operator, modelCoarseConformation)
: this.conformation; : this.conformation;
return new Coarse(this.id, this.invariantId, this.chainGroupId, this.traits, model, this.kind, this.elements, conformation, props) as Unit.Spheres | Unit.Gaussians; // TODO get rid of casting return new Coarse(this.id, this.invariantId, this.chainGroupId, this.traits, model, this.kind, this.elements, conformation, props) as Unit.Spheres | Unit.Gaussians; // TODO get rid of casting
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment