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

wip, representation destroy method

parent 00f5ff24
No related branches found
No related tags found
No related merge requests found
...@@ -64,7 +64,6 @@ export function ShapeRepresentation<P extends ShapeProps>(): ShapeRepresentation ...@@ -64,7 +64,6 @@ export function ShapeRepresentation<P extends ShapeProps>(): ShapeRepresentation
const state = createRenderableState(_props) const state = createRenderableState(_props)
_renderObject = createMeshRenderObject(values, state) _renderObject = createMeshRenderObject(values, state)
console.log(_renderObject)
renderObjects.push(_renderObject) renderObjects.push(_renderObject)
}); });
} }
...@@ -114,6 +113,8 @@ export function ShapeRepresentation<P extends ShapeProps>(): ShapeRepresentation ...@@ -114,6 +113,8 @@ export function ShapeRepresentation<P extends ShapeProps>(): ShapeRepresentation
}, },
destroy() { destroy() {
// TODO // TODO
renderObjects.length = 0
_renderObject = undefined
} }
} }
} }
......
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
import { Structure } from 'mol-model/structure'; import { Structure } from 'mol-model/structure';
import { Task } from 'mol-task' import { Task } from 'mol-task'
import { PickingId } from '../../util/picking'; 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 { MarkerAction } from '../../util/marker-data';
import { getQualityProps } from '../util'; import { getQualityProps } from '../util';
import { StructureProps, DefaultStructureProps, StructureRepresentation } from '.'; import { StructureProps, DefaultStructureProps, StructureRepresentation } from '.';
import { ComplexVisual } from './complex-visual'; import { ComplexVisual } from './complex-visual';
export function ComplexRepresentation<P extends StructureProps>(visualCtor: () => ComplexVisual<P>): StructureRepresentation<P> { export function ComplexRepresentation<P extends StructureProps>(visualCtor: () => ComplexVisual<P>): StructureRepresentation<P> {
let visual: ComplexVisual<P> let visual: ComplexVisual<P> | undefined
let _props: P let _props: P
let _structure: Structure let _structure: Structure
...@@ -32,7 +32,7 @@ export function ComplexRepresentation<P extends StructureProps>(visualCtor: () = ...@@ -32,7 +32,7 @@ export function ComplexRepresentation<P extends StructureProps>(visualCtor: () =
if (_structure.hashCode === structure.hashCode) { if (_structure.hashCode === structure.hashCode) {
await update(_props) await update(_props)
} else { } else {
if (!await visual.update(ctx, _props)) { if (visual && !await visual.update(ctx, _props)) {
await visual.create(ctx, structure, _props) await visual.create(ctx, structure, _props)
} }
} }
...@@ -46,30 +46,27 @@ export function ComplexRepresentation<P extends StructureProps>(visualCtor: () = ...@@ -46,30 +46,27 @@ export function ComplexRepresentation<P extends StructureProps>(visualCtor: () =
_props = Object.assign({}, DefaultStructureProps, _props, props, getQualityProps(props, _structure)) _props = Object.assign({}, DefaultStructureProps, _props, props, getQualityProps(props, _structure))
_props.colorTheme.structure = _structure _props.colorTheme.structure = _structure
if (!await visual.update(ctx, _props)) { if (visual && !await visual.update(ctx, _props)) {
await visual.create(ctx, _structure, _props) await visual.create(ctx, _structure, _props)
} }
}) })
} }
function getLoci(pickingId: PickingId) { function getLoci(pickingId: PickingId) {
let loci: Loci = EmptyLoci return visual ? visual.getLoci(pickingId) : EmptyLoci
const _loci = visual.getLoci(pickingId)
if (!isEmptyLoci(_loci)) loci = _loci
return loci
} }
function mark(loci: Loci, action: MarkerAction) { function mark(loci: Loci, action: MarkerAction) {
visual.mark(loci, action) if (visual) visual.mark(loci, action)
} }
function destroy() { function destroy() {
visual.destroy() if (visual) visual.destroy()
} }
return { return {
get renderObjects() { get renderObjects() {
return visual.renderObject ? [ visual.renderObject ] : [] return visual && visual.renderObject ? [ visual.renderObject ] : []
}, },
get props() { return _props }, get props() { return _props },
create, create,
......
...@@ -15,7 +15,7 @@ import { StructureProps, DefaultStructureMeshProps, MeshUpdateState } from '.'; ...@@ -15,7 +15,7 @@ import { StructureProps, DefaultStructureMeshProps, MeshUpdateState } from '.';
import { deepEqual, ValueCell } from 'mol-util'; import { deepEqual, ValueCell } from 'mol-util';
import { updateMeshValues, updateRenderableState } from '../util'; import { updateMeshValues, updateRenderableState } from '../util';
import { PickingId } from '../../util/picking'; 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 { MarkerAction, applyMarkerAction } from '../../util/marker-data';
import { Interval } from 'mol-data/int'; import { Interval } from 'mol-data/int';
...@@ -39,7 +39,7 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe ...@@ -39,7 +39,7 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe
const { defaultProps, createMesh, createLocationIterator, getLoci, mark, setUpdateState } = builder const { defaultProps, createMesh, createLocationIterator, getLoci, mark, setUpdateState } = builder
const updateState = MeshUpdateState.create() const updateState = MeshUpdateState.create()
let renderObject: MeshRenderObject let renderObject: MeshRenderObject | undefined
let currentProps: P let currentProps: P
let mesh: Mesh let mesh: Mesh
let currentStructure: Structure let currentStructure: Structure
...@@ -92,9 +92,10 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe ...@@ -92,9 +92,10 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe
return true return true
}, },
getLoci(pickingId: PickingId) { getLoci(pickingId: PickingId) {
return getLoci(pickingId, currentStructure, renderObject.id) return renderObject ? getLoci(pickingId, currentStructure, renderObject.id) : EmptyLoci
}, },
mark(loci: Loci, action: MarkerAction) { mark(loci: Loci, action: MarkerAction) {
if (!renderObject) return
const { tMarker } = renderObject.values const { tMarker } = renderObject.values
const { groupCount, instanceCount } = locationIt const { groupCount, instanceCount } = locationIt
...@@ -117,6 +118,7 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe ...@@ -117,6 +118,7 @@ export function ComplexMeshVisual<P extends ComplexMeshProps>(builder: ComplexMe
}, },
destroy() { destroy() {
// TODO // TODO
renderObject = undefined
} }
} }
} }
\ No newline at end of file
...@@ -123,6 +123,7 @@ export function UnitsMeshVisual<P extends UnitsMeshProps>(builder: UnitsMeshVisu ...@@ -123,6 +123,7 @@ export function UnitsMeshVisual<P extends UnitsMeshProps>(builder: UnitsMeshVisu
}, },
destroy() { destroy() {
// TODO // TODO
renderObject = undefined
} }
} }
} }
\ No newline at end of file
...@@ -17,7 +17,7 @@ import { deepEqual, defaults } from 'mol-util'; ...@@ -17,7 +17,7 @@ import { deepEqual, defaults } from 'mol-util';
import { SortedArray } from 'mol-data/int'; import { SortedArray } from 'mol-data/int';
import { RenderableState, PointValues } from 'mol-gl/renderable'; import { RenderableState, PointValues } from 'mol-gl/renderable';
import { PickingId } from '../../../util/picking'; 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 { MarkerAction, createMarkers } from '../../../util/marker-data';
import { Vec3 } from 'mol-math/linear-algebra'; import { Vec3 } from 'mol-math/linear-algebra';
import { fillSerial } from 'mol-util/array'; import { fillSerial } from 'mol-util/array';
...@@ -48,7 +48,7 @@ export function createPointVertices(unit: Unit) { ...@@ -48,7 +48,7 @@ export function createPointVertices(unit: Unit) {
} }
export default function PointVisual(): UnitsVisual<PointProps> { export default function PointVisual(): UnitsVisual<PointProps> {
let renderObject: PointRenderObject let renderObject: PointRenderObject | undefined
let currentProps = DefaultPointProps let currentProps = DefaultPointProps
let currentGroup: Unit.SymmetryGroup let currentGroup: Unit.SymmetryGroup
...@@ -123,7 +123,7 @@ export default function PointVisual(): UnitsVisual<PointProps> { ...@@ -123,7 +123,7 @@ export default function PointVisual(): UnitsVisual<PointProps> {
return false return false
}, },
getLoci(pickingId: PickingId) { getLoci(pickingId: PickingId) {
return getElementLoci(pickingId, currentGroup, renderObject.id) return renderObject ? getElementLoci(pickingId, currentGroup, renderObject.id) : EmptyLoci
}, },
mark(loci: Loci, action: MarkerAction) { mark(loci: Loci, action: MarkerAction) {
// TODO // TODO
...@@ -131,6 +131,7 @@ export default function PointVisual(): UnitsVisual<PointProps> { ...@@ -131,6 +131,7 @@ export default function PointVisual(): UnitsVisual<PointProps> {
}, },
destroy() { destroy() {
// TODO // TODO
renderObject = undefined
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment