diff --git a/src/mol-geo/geometry/direct-volume/direct-volume.ts b/src/mol-geo/geometry/direct-volume/direct-volume.ts index 4bc8f20eed02909f432a3042aee54095624e80d5..e89cbf6956171467a5ad28f945a36d24d40ae63b 100644 --- a/src/mol-geo/geometry/direct-volume/direct-volume.ts +++ b/src/mol-geo/geometry/direct-volume/direct-volume.ts @@ -124,7 +124,17 @@ export namespace DirectVolume { } } - export function updateValues(values: DirectVolumeValues, directVolume: DirectVolume, props: PD.Values<Params>) { + export function updateValues(values: DirectVolumeValues, props: PD.Values<Params>) { + ValueCell.updateIfChanged(values.uIsoValue, props.isoValue) + ValueCell.updateIfChanged(values.uAlpha, props.alpha) + ValueCell.updateIfChanged(values.dUseFog, props.useFog) + ValueCell.updateIfChanged(values.dRenderMode, props.renderMode) + + const controlPoints = getControlPointsFromString(props.controlPoints) + createTransferFunctionTexture(controlPoints, values.tTransferTex) + } + + export function updateBoundingSphere(values: DirectVolumeValues, directVolume: DirectVolume) { const vertices = new Float32Array(values.aPosition.ref.value) transformPositionArray(values.uTransform.ref.value, vertices, 0, vertices.length / 3) const boundingSphere = calculateBoundingSphere( @@ -134,13 +144,5 @@ export namespace DirectVolume { if (!Sphere3D.equals(boundingSphere, values.boundingSphere.ref.value)) { ValueCell.update(values.boundingSphere, boundingSphere) } - - ValueCell.updateIfChanged(values.uIsoValue, props.isoValue) - ValueCell.updateIfChanged(values.uAlpha, props.alpha) - ValueCell.updateIfChanged(values.dUseFog, props.useFog) - ValueCell.updateIfChanged(values.dRenderMode, props.renderMode) - - const controlPoints = getControlPointsFromString(props.controlPoints) - createTransferFunctionTexture(controlPoints, values.tTransferTex) } } \ No newline at end of file diff --git a/src/mol-geo/geometry/lines/lines.ts b/src/mol-geo/geometry/lines/lines.ts index 9f56f34b7b3775bb69f39c72d2cc444750652083..03e67044216b291e60192254ce7e1415eeb80ccb 100644 --- a/src/mol-geo/geometry/lines/lines.ts +++ b/src/mol-geo/geometry/lines/lines.ts @@ -137,7 +137,12 @@ export namespace Lines { } } - export function updateValues(values: LinesValues, lines: Lines, props: PD.Values<Params>) { + export function updateValues(values: LinesValues, props: PD.Values<Params>) { + Geometry.updateValues(values, props) + ValueCell.updateIfChanged(values.dLineSizeAttenuation, props.lineSizeAttenuation) + } + + export function updateBoundingSphere(values: LinesValues, lines: Lines) { const boundingSphere = Sphere3D.addSphere( calculateBoundingSphere( values.aStart.ref.value, lines.lineCount, @@ -151,8 +156,5 @@ export namespace Lines { if (!Sphere3D.equals(boundingSphere, values.boundingSphere.ref.value)) { ValueCell.update(values.boundingSphere, boundingSphere) } - - Geometry.updateValues(values, props) - ValueCell.updateIfChanged(values.dLineSizeAttenuation, props.lineSizeAttenuation) } } \ No newline at end of file diff --git a/src/mol-geo/geometry/mesh/mesh.ts b/src/mol-geo/geometry/mesh/mesh.ts index 1b2f29df6a53e1f333d62bcb4d8e4b10c4f1bf49..8acf165afaf3b752bb16ca9267bb33a903754be7 100644 --- a/src/mol-geo/geometry/mesh/mesh.ts +++ b/src/mol-geo/geometry/mesh/mesh.ts @@ -408,7 +408,14 @@ export namespace Mesh { } } - export function updateValues(values: MeshValues, mesh: Mesh, props: PD.Values<Params>) { + export function updateValues(values: MeshValues, props: PD.Values<Params>) { + Geometry.updateValues(values, props) + ValueCell.updateIfChanged(values.dDoubleSided, props.doubleSided) + ValueCell.updateIfChanged(values.dFlatShaded, props.flatShaded) + ValueCell.updateIfChanged(values.dFlipSided, props.flipSided) + } + + export function updateBoundingSphere(values: MeshValues, mesh: Mesh) { const boundingSphere = calculateBoundingSphere( values.aPosition.ref.value, mesh.vertexCount, values.aTransform.ref.value, values.instanceCount.ref.value @@ -416,11 +423,6 @@ export namespace Mesh { if (!Sphere3D.equals(boundingSphere, values.boundingSphere.ref.value)) { ValueCell.update(values.boundingSphere, boundingSphere) } - - Geometry.updateValues(values, props) - ValueCell.updateIfChanged(values.dDoubleSided, props.doubleSided) - ValueCell.updateIfChanged(values.dFlatShaded, props.flatShaded) - ValueCell.updateIfChanged(values.dFlipSided, props.flipSided) } } diff --git a/src/mol-geo/geometry/points/points.ts b/src/mol-geo/geometry/points/points.ts index d6c28569add36be0ab6be1a6ad67c3a70ea44d04..08724686b3555a075c737f982a3bb961e7f174e9 100644 --- a/src/mol-geo/geometry/points/points.ts +++ b/src/mol-geo/geometry/points/points.ts @@ -92,7 +92,14 @@ export namespace Points { } } - export function updateValues(values: PointsValues, points: Points, props: PD.Values<Params>) { + export function updateValues(values: PointsValues, props: PD.Values<Params>) { + Geometry.updateValues(values, props) + ValueCell.updateIfChanged(values.dPointSizeAttenuation, props.pointSizeAttenuation) + ValueCell.updateIfChanged(values.dPointFilledCircle, props.pointFilledCircle) + ValueCell.updateIfChanged(values.uPointEdgeBleach, props.pointEdgeBleach) + } + + export function updateBoundingSphere(values: PointsValues, points: Points) { const boundingSphere = calculateBoundingSphere( values.aPosition.ref.value, points.pointCount, values.aTransform.ref.value, values.instanceCount.ref.value @@ -100,10 +107,5 @@ export namespace Points { if (!Sphere3D.equals(boundingSphere, values.boundingSphere.ref.value)) { ValueCell.update(values.boundingSphere, boundingSphere) } - - Geometry.updateValues(values, props) - ValueCell.updateIfChanged(values.dPointSizeAttenuation, props.pointSizeAttenuation) - ValueCell.updateIfChanged(values.dPointFilledCircle, props.pointFilledCircle) - ValueCell.updateIfChanged(values.uPointEdgeBleach, props.pointEdgeBleach) } } \ No newline at end of file diff --git a/src/mol-repr/structure/complex-visual.ts b/src/mol-repr/structure/complex-visual.ts index f51ab95c3bfa482026b76302ba701d3174e94282..ac70ac744eeb38023e28d6707acb07de71e62567 100644 --- a/src/mol-repr/structure/complex-visual.ts +++ b/src/mol-repr/structure/complex-visual.ts @@ -48,12 +48,13 @@ interface ComplexVisualBuilder<P extends ComplexParams, G extends Geometry> { interface ComplexVisualGeometryBuilder<P extends ComplexParams, G extends Geometry> extends ComplexVisualBuilder<P, G> { createEmptyGeometry(geometry?: G): G createRenderObject(ctx: VisualContext, structure: Structure, geometry: Geometry, locationIt: LocationIterator, theme: Theme, currentProps: PD.Values<P>): Promise<ComplexRenderObject> - updateValues(values: RenderableValues, geometry: Geometry, newProps: PD.Values<P>): void + updateValues(values: RenderableValues, newProps: PD.Values<P>): void, + updateBoundingSphere(values: RenderableValues, geometry: Geometry): void } export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeometryBuilder<P, Geometry>): ComplexVisual<P> { const { defaultProps, createGeometry, createLocationIterator, getLoci, mark, setUpdateState } = builder - const { createRenderObject, updateValues } = builder + const { createRenderObject, updateValues, updateBoundingSphere } = builder const updateState = VisualUpdateState.create() let renderObject: ComplexRenderObject | undefined @@ -99,6 +100,7 @@ export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeo if (updateState.createGeometry) { geometry = await createGeometry(ctx, currentStructure, theme, newProps, geometry) ValueCell.update(renderObject.values.drawCount, Geometry.getDrawCount(geometry)) + updateBoundingSphere(renderObject.values, geometry) updateState.updateColor = true } @@ -113,7 +115,7 @@ export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeo await createColors(ctx.runtime, locationIt, theme.color, renderObject.values) } - updateValues(renderObject.values, geometry, newProps) + updateValues(renderObject.values, newProps) updateRenderableState(renderObject.state, newProps) currentProps = newProps @@ -195,6 +197,7 @@ export function ComplexMeshVisual<P extends ComplexMeshParams>(builder: ComplexM }, createEmptyGeometry: Mesh.createEmpty, createRenderObject: createComplexMeshRenderObject, - updateValues: Mesh.updateValues + updateValues: Mesh.updateValues, + updateBoundingSphere: Mesh.updateBoundingSphere }) } \ No newline at end of file diff --git a/src/mol-repr/structure/units-visual.ts b/src/mol-repr/structure/units-visual.ts index a736a938d10b4fde2c4c0e49477ec4fd83d1bbb4..8679baa90ebda0c5aabd234660fd1a57b535522c 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/src/mol-repr/structure/units-visual.ts @@ -48,12 +48,13 @@ interface UnitsVisualBuilder<P extends UnitsParams, G extends Geometry> { interface UnitsVisualGeometryBuilder<P extends UnitsParams, G extends Geometry> extends UnitsVisualBuilder<P, G> { createEmptyGeometry(geometry?: G): G createRenderObject(ctx: VisualContext, group: Unit.SymmetryGroup, geometry: Geometry, locationIt: LocationIterator, theme: Theme, currentProps: PD.Values<P>): Promise<UnitsRenderObject> - updateValues(values: RenderableValues, geometry: Geometry, newProps: PD.Values<P>): void + updateValues(values: RenderableValues, newProps: PD.Values<P>): void + updateBoundingSphere(values: RenderableValues, geometry: Geometry): void } export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryBuilder<P, Geometry>): UnitsVisual<P> { const { defaultProps, createGeometry, createLocationIterator, getLoci, mark, setUpdateState } = builder - const { createEmptyGeometry, createRenderObject, updateValues } = builder + const { createEmptyGeometry, createRenderObject, updateValues, updateBoundingSphere } = builder const updateState = VisualUpdateState.create() let renderObject: UnitsRenderObject | undefined @@ -139,6 +140,7 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB ? await createGeometry(ctx, unit, currentStructure, theme, newProps, geometry) : createEmptyGeometry(geometry) ValueCell.update(renderObject.values.drawCount, Geometry.getDrawCount(geometry)) + updateBoundingSphere(renderObject.values, geometry) updateState.updateColor = true } @@ -155,7 +157,7 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB await createColors(ctx.runtime, locationIt, theme.color, renderObject.values) } - updateValues(renderObject.values, geometry, newProps) + updateValues(renderObject.values, newProps) updateRenderableState(renderObject.state, newProps) currentProps = newProps @@ -238,7 +240,8 @@ export function UnitsMeshVisual<P extends UnitsMeshParams>(builder: UnitsMeshVis }, createEmptyGeometry: Mesh.createEmpty, createRenderObject: createUnitsMeshRenderObject, - updateValues: Mesh.updateValues + updateValues: Mesh.updateValues, + updateBoundingSphere: Mesh.updateBoundingSphere }) } @@ -260,7 +263,8 @@ export function UnitsPointsVisual<P extends UnitsPointsParams>(builder: UnitsPoi builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme) if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.updateSize = true }, - updateValues: Points.updateValues + updateValues: Points.updateValues, + updateBoundingSphere: Points.updateBoundingSphere }) } @@ -282,7 +286,8 @@ export function UnitsLinesVisual<P extends UnitsLinesParams>(builder: UnitsLines builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme) if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.updateSize = true }, - updateValues: Lines.updateValues + updateValues: Lines.updateValues, + updateBoundingSphere: Lines.updateBoundingSphere }) } @@ -304,6 +309,7 @@ export function UnitsDirectVolumeVisual<P extends UnitsDirectVolumeParams>(build builder.setUpdateState(state, newProps, currentProps, newTheme, currentTheme) if (!SizeTheme.areEqual(newTheme.size, currentTheme.size)) state.createGeometry = true }, - updateValues: DirectVolume.updateValues + updateValues: DirectVolume.updateValues, + updateBoundingSphere: DirectVolume.updateBoundingSphere }) } \ No newline at end of file diff --git a/src/mol-repr/volume/direct-volume.ts b/src/mol-repr/volume/direct-volume.ts index 256f734bd60bf4581b7a166b1b800ce3428ec1d2..b2e8dea231970d2a3852c9aeffe78c6f5486c31f 100644 --- a/src/mol-repr/volume/direct-volume.ts +++ b/src/mol-repr/volume/direct-volume.ts @@ -178,7 +178,8 @@ export function DirectVolumeVisual(): VolumeVisual<DirectVolumeParams> { const state = createRenderableState(props) return createDirectVolumeRenderObject(values, state) }, - updateValues: DirectVolume.updateValues + updateValues: DirectVolume.updateValues, + updateBoundingSphere: DirectVolume.updateBoundingSphere }) } diff --git a/src/mol-repr/volume/isosurface-mesh.ts b/src/mol-repr/volume/isosurface-mesh.ts index 0daee148a0a6e036ef59051a5ac21c7ef6b5666b..e2b82d003379f030ea3855a06aa2d2c0c5e69558 100644 --- a/src/mol-repr/volume/isosurface-mesh.ts +++ b/src/mol-repr/volume/isosurface-mesh.ts @@ -63,7 +63,8 @@ export function IsosurfaceVisual(): VolumeVisual<IsosurfaceParams> { const state = createRenderableState(props) return createMeshRenderObject(values, state) }, - updateValues: Mesh.updateValues + updateValues: Mesh.updateValues, + updateBoundingSphere: Mesh.updateBoundingSphere }) } diff --git a/src/mol-repr/volume/representation.ts b/src/mol-repr/volume/representation.ts index 3e240f660e64e8edf45d58c0dbe09b151968bb29..e274058eb1344c786e6cab7db7501549a5ace2c1 100644 --- a/src/mol-repr/volume/representation.ts +++ b/src/mol-repr/volume/representation.ts @@ -36,12 +36,13 @@ interface VolumeVisualBuilder<P extends VolumeParams, G extends Geometry> { interface VolumeVisualGeometryBuilder<P extends VolumeParams, G extends Geometry> extends VolumeVisualBuilder<P, G> { createRenderObject(ctx: VisualContext, geometry: G, locationIt: LocationIterator, theme: Theme, currentProps: PD.Values<P>): Promise<VolumeRenderObject> - updateValues(values: RenderableValues, geometry: G, newProps: PD.Values<P>): void + updateValues(values: RenderableValues, newProps: PD.Values<P>): void, + updateBoundingSphere(values: RenderableValues, geometry: G): void } export function VolumeVisual<P extends VolumeParams>(builder: VolumeVisualGeometryBuilder<P, Geometry>): VolumeVisual<P> { const { defaultProps, createGeometry, getLoci, mark, setUpdateState } = builder - const { createRenderObject, updateValues } = builder + const { createRenderObject, updateValues, updateBoundingSphere } = builder const updateState = VisualUpdateState.create() let currentProps: PD.Values<P> @@ -67,9 +68,10 @@ export function VolumeVisual<P extends VolumeParams>(builder: VolumeVisualGeomet if (updateState.createGeometry) { geometry = await createGeometry(ctx, currentVolume, currentProps, geometry) ValueCell.update(renderObject.values.drawCount, Geometry.getDrawCount(geometry)) + updateBoundingSphere(renderObject.values, geometry) } - updateValues(renderObject.values, geometry, newProps) + updateValues(renderObject.values, newProps) updateRenderableState(renderObject.state, newProps) currentProps = newProps