diff --git a/src/mol-geo/representation/shape/index.ts b/src/mol-geo/representation/shape/index.ts index 0955145ad288e91436cdb884f5ae018aa6ce3ebe..dc6393dee5b079160349065337517c779725b3fb 100644 --- a/src/mol-geo/representation/shape/index.ts +++ b/src/mol-geo/representation/shape/index.ts @@ -64,7 +64,6 @@ export function ShapeRepresentation<P extends ShapeProps>(): ShapeRepresentation const state = createRenderableState(_props) _renderObject = createMeshRenderObject(values, state) - console.log(_renderObject) renderObjects.push(_renderObject) }); } @@ -114,6 +113,8 @@ export function ShapeRepresentation<P extends ShapeProps>(): ShapeRepresentation }, destroy() { // TODO + renderObjects.length = 0 + _renderObject = undefined } } } diff --git a/src/mol-geo/representation/structure/complex-representation.ts b/src/mol-geo/representation/structure/complex-representation.ts index 096d770f4c09de2311b42b5e68a47dccb0f0b68f..f10ddbdf2b91ec5c46feb5c4aa9f83a0cb161aa5 100644 --- a/src/mol-geo/representation/structure/complex-representation.ts +++ b/src/mol-geo/representation/structure/complex-representation.ts @@ -8,14 +8,14 @@ import { Structure } from 'mol-model/structure'; import { Task } from 'mol-task' import { PickingId } from '../../util/picking'; -import { Loci, EmptyLoci, isEmptyLoci } from 'mol-model/loci'; +import { Loci, EmptyLoci } from 'mol-model/loci'; import { MarkerAction } from '../../util/marker-data'; import { getQualityProps } from '../util'; import { StructureProps, DefaultStructureProps, StructureRepresentation } from '.'; import { ComplexVisual } from './complex-visual'; export function ComplexRepresentation<P extends StructureProps>(visualCtor: () => ComplexVisual<P>): StructureRepresentation<P> { - let visual: ComplexVisual<P> + let visual: ComplexVisual<P> | undefined let _props: P let _structure: Structure @@ -32,7 +32,7 @@ export function ComplexRepresentation<P extends StructureProps>(visualCtor: () = if (_structure.hashCode === structure.hashCode) { await update(_props) } else { - if (!await visual.update(ctx, _props)) { + if (visual && !await visual.update(ctx, _props)) { await visual.create(ctx, structure, _props) } } @@ -46,30 +46,27 @@ export function ComplexRepresentation<P extends StructureProps>(visualCtor: () = _props = Object.assign({}, DefaultStructureProps, _props, props, getQualityProps(props, _structure)) _props.colorTheme.structure = _structure - if (!await visual.update(ctx, _props)) { + if (visual && !await visual.update(ctx, _props)) { await visual.create(ctx, _structure, _props) } }) } function getLoci(pickingId: PickingId) { - let loci: Loci = EmptyLoci - const _loci = visual.getLoci(pickingId) - if (!isEmptyLoci(_loci)) loci = _loci - return loci + return visual ? visual.getLoci(pickingId) : EmptyLoci } function mark(loci: Loci, action: MarkerAction) { - visual.mark(loci, action) + if (visual) visual.mark(loci, action) } function destroy() { - visual.destroy() + if (visual) visual.destroy() } return { get renderObjects() { - return visual.renderObject ? [ visual.renderObject ] : [] + return visual && visual.renderObject ? [ visual.renderObject ] : [] }, get props() { return _props }, create, diff --git a/src/mol-geo/representation/structure/complex-visual.ts b/src/mol-geo/representation/structure/complex-visual.ts index 063ecf36dc20499485644fb736b9f853f2b1b4bf..514e8adae75500567171e03827cb28cb1069f42e 100644 --- a/src/mol-geo/representation/structure/complex-visual.ts +++ b/src/mol-geo/representation/structure/complex-visual.ts @@ -15,7 +15,7 @@ import { StructureProps, DefaultStructureMeshProps, MeshUpdateState } from '.'; import { deepEqual, ValueCell } from 'mol-util'; import { updateMeshValues, updateRenderableState } from '../util'; import { PickingId } from '../../util/picking'; -import { Loci, isEveryLoci } from 'mol-model/loci'; +import { Loci, isEveryLoci, EmptyLoci } from 'mol-model/loci'; import { MarkerAction, applyMarkerAction } from '../../util/marker-data'; import { Interval } from 'mol-data/int'; @@ -39,7 +39,7 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe const { defaultProps, createMesh, createLocationIterator, getLoci, mark, setUpdateState } = builder const updateState = MeshUpdateState.create() - let renderObject: MeshRenderObject + let renderObject: MeshRenderObject | undefined let currentProps: P let mesh: Mesh let currentStructure: Structure @@ -92,9 +92,10 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe return true }, getLoci(pickingId: PickingId) { - return getLoci(pickingId, currentStructure, renderObject.id) + return renderObject ? getLoci(pickingId, currentStructure, renderObject.id) : EmptyLoci }, mark(loci: Loci, action: MarkerAction) { + if (!renderObject) return const { tMarker } = renderObject.values const { groupCount, instanceCount } = locationIt @@ -117,6 +118,7 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe }, destroy() { // TODO + renderObject = undefined } } } \ No newline at end of file diff --git a/src/mol-geo/representation/structure/units-visual.ts b/src/mol-geo/representation/structure/units-visual.ts index 51d80f236646a267ad8e0eb207a4125c4452287d..ff390f1236746300590456e5c16785ebb33a91cc 100644 --- a/src/mol-geo/representation/structure/units-visual.ts +++ b/src/mol-geo/representation/structure/units-visual.ts @@ -123,6 +123,7 @@ export function UnitsMeshVisual<P extends UnitsMeshProps>(builder: UnitsMeshVisu }, destroy() { // TODO + renderObject = undefined } } } \ No newline at end of file diff --git a/src/mol-geo/representation/structure/visual/element-point.ts b/src/mol-geo/representation/structure/visual/element-point.ts index e58f1bee17d71ac6a7605317fb6000a6ce448ca4..1cfca71046ad68a32573dd5aedd0331132ccb106 100644 --- a/src/mol-geo/representation/structure/visual/element-point.ts +++ b/src/mol-geo/representation/structure/visual/element-point.ts @@ -17,7 +17,7 @@ import { deepEqual, defaults } from 'mol-util'; import { SortedArray } from 'mol-data/int'; import { RenderableState, PointValues } from 'mol-gl/renderable'; import { PickingId } from '../../../util/picking'; -import { Loci } from 'mol-model/loci'; +import { Loci, EmptyLoci } from 'mol-model/loci'; import { MarkerAction, createMarkers } from '../../../util/marker-data'; import { Vec3 } from 'mol-math/linear-algebra'; import { fillSerial } from 'mol-util/array'; @@ -48,7 +48,7 @@ export function createPointVertices(unit: Unit) { } export default function PointVisual(): UnitsVisual<PointProps> { - let renderObject: PointRenderObject + let renderObject: PointRenderObject | undefined let currentProps = DefaultPointProps let currentGroup: Unit.SymmetryGroup @@ -123,7 +123,7 @@ export default function PointVisual(): UnitsVisual<PointProps> { return false }, getLoci(pickingId: PickingId) { - return getElementLoci(pickingId, currentGroup, renderObject.id) + return renderObject ? getElementLoci(pickingId, currentGroup, renderObject.id) : EmptyLoci }, mark(loci: Loci, action: MarkerAction) { // TODO @@ -131,6 +131,7 @@ export default function PointVisual(): UnitsVisual<PointProps> { }, destroy() { // TODO + renderObject = undefined } } }