Ver Fonte

refactored mol-repr/visual

Alexander Rose há 6 anos atrás
pai
commit
e0a716c88e
29 ficheiros alterados com 105 adições e 60 exclusões
  1. 1 1
      src/mol-geo/geometry/transform-data.ts
  2. 2 1
      src/mol-model-props/rcsb/representations/assembly-symmetry-axes.ts
  3. 1 22
      src/mol-repr/representation.ts
  4. 1 0
      src/mol-repr/shape/representation.ts
  5. 4 5
      src/mol-repr/structure/complex-visual.ts
  6. 2 1
      src/mol-repr/structure/units-representation.ts
  7. 6 5
      src/mol-repr/structure/units-visual.ts
  8. 1 1
      src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts
  9. 1 1
      src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts
  10. 1 1
      src/mol-repr/structure/visual/carbohydrate-terminal-link-cylinder.ts
  11. 1 1
      src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts
  12. 1 1
      src/mol-repr/structure/visual/element-point.ts
  13. 1 1
      src/mol-repr/structure/visual/gaussian-density-point.ts
  14. 1 1
      src/mol-repr/structure/visual/gaussian-density-volume.ts
  15. 1 1
      src/mol-repr/structure/visual/gaussian-surface-mesh.ts
  16. 1 1
      src/mol-repr/structure/visual/gaussian-surface-wireframe.ts
  17. 1 1
      src/mol-repr/structure/visual/inter-unit-link-cylinder.ts
  18. 1 1
      src/mol-repr/structure/visual/intra-unit-link-cylinder.ts
  19. 1 1
      src/mol-repr/structure/visual/nucleotide-block-mesh.ts
  20. 1 1
      src/mol-repr/structure/visual/polymer-backbone-cylinder.ts
  21. 1 1
      src/mol-repr/structure/visual/polymer-direction-wedge.ts
  22. 1 1
      src/mol-repr/structure/visual/polymer-gap-cylinder.ts
  23. 1 1
      src/mol-repr/structure/visual/polymer-trace-mesh.ts
  24. 1 1
      src/mol-repr/structure/visual/util/element.ts
  25. 1 1
      src/mol-repr/structure/visual/util/link.ts
  26. 61 0
      src/mol-repr/visual.ts
  27. 2 1
      src/mol-repr/volume/direct-volume.ts
  28. 2 1
      src/mol-repr/volume/isosurface-mesh.ts
  29. 5 5
      src/mol-repr/volume/representation.ts

+ 1 - 1
src/mol-geo/geometry/transform-data.ts

@@ -43,7 +43,7 @@ export function createIdentityTransform(transformData?: TransformData): Transfor
 }
 
 const tmpTransformMat4 = Mat4.identity()
-export function setTransform(matrix: Mat4, transformData: TransformData) {
+export function setTransformData(matrix: Mat4, transformData: TransformData) {
     const instanceCount = transformData.instanceCount.ref.value
     const transform = transformData.transform.ref.value
     const aTransform = transformData.aTransform.ref.value

+ 2 - 1
src/mol-model-props/rcsb/representations/assembly-symmetry-axes.ts

@@ -5,7 +5,8 @@
  */
 
 import { ParamDefinition as PD } from 'mol-util/param-definition';
-import { RepresentationParamsGetter, RepresentationContext, VisualContext } from 'mol-repr/representation';
+import { RepresentationParamsGetter, RepresentationContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { ThemeRegistryContext, Theme } from 'mol-theme/theme';
 import { Structure } from 'mol-model/structure';
 import { StructureRepresentationProvider, StructureRepresentation, ComplexRepresentation, ComplexVisual } from 'mol-repr/structure/representation';

+ 1 - 22
src/mol-repr/representation.ts

@@ -4,7 +4,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-import { Task, RuntimeContext } from 'mol-task'
+import { Task } from 'mol-task'
 import { RenderObject } from 'mol-gl/render-object'
 import { PickingId } from '../mol-geo/geometry/picking';
 import { Loci, isEmptyLoci, EmptyLoci } from 'mol-model/loci';
@@ -240,25 +240,4 @@ namespace Representation {
             }
         }
     }
-}
-
-//
-
-export interface VisualContext {
-    readonly runtime: RuntimeContext
-    readonly webgl?: WebGLContext
-}
-// export type VisualFactory<D, P extends PD.Params> = (ctx: VisualContext) => Visual<D, P>
-
-export interface Visual<D, P extends PD.Params> {
-    /** Number of addressable groups in all instances of the visual */
-    readonly groupCount: number
-    readonly renderObject: RenderObject | undefined
-    createOrUpdate: (ctx: VisualContext, theme: Theme, props?: Partial<PD.Values<P>>, data?: D) => Promise<void> | void
-    getLoci: (pickingId: PickingId) => Loci
-    mark: (loci: Loci, action: MarkerAction) => boolean
-    setVisibility: (value: boolean) => void
-    setPickable: (value: boolean) => void
-    setTransform: (value: Mat4) => void
-    destroy: () => void
 }

+ 1 - 0
src/mol-repr/shape/representation.ts

@@ -109,6 +109,7 @@ export function ShapeRepresentation<P extends ShapeParams>(ctx: RepresentationCo
         setState(state: Partial<Representation.State>) {
             if (state.visible !== undefined) renderObjects.forEach(ro => ro.state.visible = state.visible!)
             if (state.pickable !== undefined) renderObjects.forEach(ro => ro.state.pickable = state.pickable!)
+            // TODO state.transform
 
             Representation.updateState(_state, state)
         },

+ 4 - 5
src/mol-repr/structure/complex-visual.ts

@@ -5,7 +5,7 @@
  */
 
 import { Structure } from 'mol-model/structure';
-import { Visual, VisualContext } from '../representation';
+import { Visual, VisualContext } from '../visual';
 import { MeshRenderObject, LinesRenderObject, PointsRenderObject, DirectVolumeRenderObject } from 'mol-gl/render-object';
 import { createComplexMeshRenderObject, UnitKind, UnitKindOptions, createComplexDirectVolumeRenderObject } from './visual/util/common';
 import { StructureMeshParams, StructureParams, StructureDirectVolumeParams } from './representation';
@@ -29,7 +29,6 @@ import { RenderableState } from 'mol-gl/renderable';
 import { UnitsParams } from './units-representation';
 import { DirectVolume } from 'mol-geo/geometry/direct-volume/direct-volume';
 import { Mat4 } from 'mol-math/linear-algebra';
-import { setTransform } from 'mol-geo/geometry/transform-data';
 
 export interface  ComplexVisual<P extends StructureParams> extends Visual<Structure, P> { }
 
@@ -195,13 +194,13 @@ export function ComplexVisual<P extends ComplexParams>(builder: ComplexVisualGeo
             return changed
         },
         setVisibility(value: boolean) {
-            if (renderObject) renderObject.state.visible = value
+            Visual.setVisibility(renderObject, value)
         },
         setPickable(value: boolean) {
-            if (renderObject) renderObject.state.pickable = value
+            Visual.setPickable(renderObject, value)
         },
         setTransform(value: Mat4) {
-            if (renderObject) setTransform(value, renderObject.values)
+            Visual.setTransform(renderObject, value)
         },
         destroy() {
             // TODO

+ 2 - 1
src/mol-repr/structure/units-representation.ts

@@ -8,7 +8,8 @@
 import { Structure, Unit } from 'mol-model/structure';
 import { Task } from 'mol-task'
 import { RenderObject } from 'mol-gl/render-object';
-import { Visual, RepresentationContext, RepresentationParamsGetter, Representation } from '../representation';
+import { RepresentationContext, RepresentationParamsGetter, Representation } from '../representation';
+import { Visual } from '../visual';
 import { Loci, EmptyLoci, isEmptyLoci } from 'mol-model/loci';
 import { StructureGroup } from './units-visual';
 import { StructureRepresentation, StructureParams } from './representation';

+ 6 - 5
src/mol-repr/structure/units-visual.ts

@@ -5,7 +5,8 @@
  */
 
 import { Unit, Structure } from 'mol-model/structure';
-import { RepresentationProps, Visual, VisualContext } from '../representation';
+import { RepresentationProps } from '../representation';
+import { Visual, VisualContext } from '../visual';
 import { StructureMeshParams, StructurePointsParams, StructureLinesParams, StructureDirectVolumeParams } from './representation';
 import { Loci, isEveryLoci, EmptyLoci } from 'mol-model/loci';
 import { MeshRenderObject, PointsRenderObject, LinesRenderObject, DirectVolumeRenderObject } from 'mol-gl/render-object';
@@ -31,7 +32,6 @@ import { SizeTheme } from 'mol-theme/size';
 import { UnitsParams } from './units-representation';
 import { RenderableState } from 'mol-gl/renderable';
 import { Mat4 } from 'mol-math/linear-algebra';
-import { setTransform } from 'mol-geo/geometry/transform-data';
 
 export type StructureGroup = { structure: Structure, group: Unit.SymmetryGroup }
 
@@ -169,6 +169,7 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB
             }
 
             if (updateState.updateTransform || updateState.createGeometry) {
+                console.log('UnitsVisual.updateBoundingSphere')
                 updateBoundingSphere(renderObject.values, newGeometry || geometry)
             }
 
@@ -239,13 +240,13 @@ export function UnitsVisual<P extends UnitsParams>(builder: UnitsVisualGeometryB
             return changed
         },
         setVisibility(value: boolean) {
-            if (renderObject) renderObject.state.visible = value
+            Visual.setVisibility(renderObject, value)
         },
         setPickable(value: boolean) {
-            if (renderObject) renderObject.state.pickable = value
+            Visual.setPickable(renderObject, value)
         },
         setTransform(value: Mat4) {
-            if (renderObject) setTransform(value, renderObject.values)
+            Visual.setTransform(renderObject, value)
         },
         destroy() {
             // TODO

+ 1 - 1
src/mol-repr/structure/visual/carbohydrate-link-cylinder.ts

@@ -18,7 +18,7 @@ import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { LocationIterator } from 'mol-geo/util/location-iterator';
 import { PickingId } from 'mol-geo/geometry/picking';
 import { VisualUpdateState } from '../../util';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 function createCarbohydrateLinkCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CarbohydrateLinkParams>, mesh?: Mesh) {

+ 1 - 1
src/mol-repr/structure/visual/carbohydrate-symbol-mesh.ts

@@ -23,7 +23,7 @@ import { LocationIterator } from 'mol-geo/util/location-iterator';
 import { PickingId } from 'mol-geo/geometry/picking';
 import { OrderedSet, Interval } from 'mol-data/int';
 import { EmptyLoci, Loci } from 'mol-model/loci';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 import { getResidueLoci } from './util/common';
 

+ 1 - 1
src/mol-repr/structure/visual/carbohydrate-terminal-link-cylinder.ts

@@ -18,7 +18,7 @@ import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { LocationIterator } from 'mol-geo/util/location-iterator';
 import { PickingId } from 'mol-geo/geometry/picking';
 import { VisualUpdateState } from '../../util';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 function createCarbohydrateTerminalLinkCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CarbohydrateTerminalLinkParams>, mesh?: Mesh) {

+ 1 - 1
src/mol-repr/structure/visual/cross-link-restraint-cylinder.ts

@@ -18,7 +18,7 @@ import { ParamDefinition as PD } from 'mol-util/param-definition';
 import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { LocationIterator } from 'mol-geo/util/location-iterator';
 import { PickingId } from 'mol-geo/geometry/picking';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 function createCrossLinkRestraintCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<CrossLinkRestraintParams>, mesh?: Mesh) {

+ 1 - 1
src/mol-repr/structure/visual/element-point.ts

@@ -13,7 +13,7 @@ import { UnitsPointsVisual, UnitsPointsParams } from '../units-visual';
 import { ParamDefinition as PD } from 'mol-util/param-definition';
 import { Points } from 'mol-geo/geometry/points/points';
 import { PointsBuilder } from 'mol-geo/geometry/points/points-builder';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 export const ElementPointParams = {

+ 1 - 1
src/mol-repr/structure/visual/gaussian-density-point.ts

@@ -15,7 +15,7 @@ import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure
 import { ParamDefinition as PD } from 'mol-util/param-definition';
 import { Points } from 'mol-geo/geometry/points/points';
 import { PointsBuilder } from 'mol-geo/geometry/points/points-builder';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 export const GaussianDensityPointParams = {

+ 1 - 1
src/mol-repr/structure/visual/gaussian-density-volume.ts

@@ -8,7 +8,7 @@ import { Structure, StructureElement } from 'mol-model/structure';
 import { VisualUpdateState } from '../../util';
 import { ParamDefinition as PD } from 'mol-util/param-definition';
 import { DirectVolume } from 'mol-geo/geometry/direct-volume/direct-volume';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 import { ComplexVisual, ComplexDirectVolumeVisual, ComplexDirectVolumeParams } from '../complex-visual';
 import { EmptyLoci } from 'mol-model/loci';

+ 1 - 1
src/mol-repr/structure/visual/gaussian-surface-mesh.ts

@@ -13,7 +13,7 @@ import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure
 import { ParamDefinition as PD } from 'mol-util/param-definition';
 import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { computeMarchingCubesMesh } from 'mol-geo/util/marching-cubes/algorithm';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 async function createGaussianSurfaceMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, mesh?: Mesh): Promise<Mesh> {

+ 1 - 1
src/mol-repr/structure/visual/gaussian-surface-wireframe.ts

@@ -13,7 +13,7 @@ import { GaussianDensityProps, GaussianDensityParams } from 'mol-model/structure
 import { ParamDefinition as PD } from 'mol-util/param-definition';
 import { Lines } from 'mol-geo/geometry/lines/lines';
 import { computeMarchingCubesLines } from 'mol-geo/util/marching-cubes/algorithm';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 async function createGaussianWireframe(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: GaussianDensityProps, lines?: Lines): Promise<Lines> {

+ 1 - 1
src/mol-repr/structure/visual/inter-unit-link-cylinder.ts

@@ -16,7 +16,7 @@ import { BitFlags } from 'mol-util';
 import { ParamDefinition as PD } from 'mol-util/param-definition';
 import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { PickingId } from 'mol-geo/geometry/picking';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 function createInterUnitLinkCylinderMesh(ctx: VisualContext, structure: Structure, theme: Theme, props: PD.Values<InterUnitLinkParams>, mesh?: Mesh) {

+ 1 - 1
src/mol-repr/structure/visual/intra-unit-link-cylinder.ts

@@ -17,7 +17,7 @@ import { BitFlags } from 'mol-util';
 import { ParamDefinition as PD } from 'mol-util/param-definition';
 import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { PickingId } from 'mol-geo/geometry/picking';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 function createIntraUnitLinkCylinderMesh(ctx: VisualContext, unit: Unit, structure: Structure, theme: Theme, props: PD.Values<IntraUnitLinkParams>, mesh?: Mesh) {

+ 1 - 1
src/mol-repr/structure/visual/nucleotide-block-mesh.ts

@@ -16,7 +16,7 @@ import { Box } from 'mol-geo/primitive/box';
 import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder';
 import { addCylinder } from 'mol-geo/geometry/mesh/builder/cylinder';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 import { VisualUpdateState } from 'mol-repr/util';
 import { CylinderProps } from 'mol-geo/primitive/cylinder';

+ 1 - 1
src/mol-repr/structure/visual/polymer-backbone-cylinder.ts

@@ -17,7 +17,7 @@ import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder';
 import { CylinderProps } from 'mol-geo/primitive/cylinder';
 import { addCylinder } from 'mol-geo/geometry/mesh/builder/cylinder';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 export const PolymerBackboneCylinderParams = {

+ 1 - 1
src/mol-repr/structure/visual/polymer-direction-wedge.ts

@@ -14,7 +14,7 @@ import { ParamDefinition as PD } from 'mol-util/param-definition';
 import { Wedge } from 'mol-geo/primitive/wedge';
 import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 import { VisualUpdateState } from 'mol-repr/util';
 

+ 1 - 1
src/mol-repr/structure/visual/polymer-gap-cylinder.ts

@@ -17,7 +17,7 @@ import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder';
 import { CylinderProps } from 'mol-geo/primitive/cylinder';
 import { addSphere } from 'mol-geo/geometry/mesh/builder/sphere';
 import { addFixedCountDashedCylinder } from 'mol-geo/geometry/mesh/builder/cylinder';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 const segmentCount = 10

+ 1 - 1
src/mol-repr/structure/visual/polymer-trace-mesh.ts

@@ -15,7 +15,7 @@ import { Mesh } from 'mol-geo/geometry/mesh/mesh';
 import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder';
 import { addSheet } from 'mol-geo/geometry/mesh/builder/sheet';
 import { addTube } from 'mol-geo/geometry/mesh/builder/tube';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 
 export const PolymerTraceMeshParams = {

+ 1 - 1
src/mol-repr/structure/visual/util/element.ts

@@ -14,7 +14,7 @@ import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder';
 import { addSphere } from 'mol-geo/geometry/mesh/builder/sphere';
 import { PickingId } from 'mol-geo/geometry/picking';
 import { LocationIterator } from 'mol-geo/util/location-iterator';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 import { Theme } from 'mol-theme/theme';
 import { StructureGroup } from 'mol-repr/structure/units-visual';
 

+ 1 - 1
src/mol-repr/structure/visual/util/link.ts

@@ -13,7 +13,7 @@ import { MeshBuilder } from 'mol-geo/geometry/mesh/mesh-builder';
 import { CylinderProps } from 'mol-geo/primitive/cylinder';
 import { addFixedCountDashedCylinder, addCylinder, addDoubleCylinder } from 'mol-geo/geometry/mesh/builder/cylinder';
 import { LocationIterator } from 'mol-geo/util/location-iterator';
-import { VisualContext } from 'mol-repr/representation';
+import { VisualContext } from 'mol-repr/visual';
 
 export const LinkCylinderParams = {
     linkScale: PD.Numeric(0.4, { min: 0, max: 1, step: 0.1 }),

+ 61 - 0
src/mol-repr/visual.ts

@@ -0,0 +1,61 @@
+/**
+ * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ *
+ * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ */
+
+import { RuntimeContext } from 'mol-task'
+import { RenderObject, MeshRenderObject, LinesRenderObject, PointsRenderObject, DirectVolumeRenderObject } from 'mol-gl/render-object'
+import { PickingId } from '../mol-geo/geometry/picking';
+import { Loci } from 'mol-model/loci';
+import { MarkerAction } from '../mol-geo/geometry/marker-data';
+import { ParamDefinition as PD } from 'mol-util/param-definition';
+import { WebGLContext } from 'mol-gl/webgl/context';
+import { Theme } from 'mol-theme/theme';
+import { Mat4 } from 'mol-math/linear-algebra';
+import { setTransformData } from 'mol-geo/geometry/transform-data';
+import { calculateTransformBoundingSphere } from 'mol-gl/renderable/util';
+import { Sphere3D } from 'mol-math/geometry';
+import { ValueCell } from 'mol-util';
+
+export interface VisualContext {
+    readonly runtime: RuntimeContext
+    readonly webgl?: WebGLContext
+}
+// export type VisualFactory<D, P extends PD.Params> = (ctx: VisualContext) => Visual<D, P>
+
+type VisualRenderObject = MeshRenderObject | LinesRenderObject | PointsRenderObject | DirectVolumeRenderObject
+
+export { Visual }
+interface Visual<D, P extends PD.Params> {
+    /** Number of addressable groups in all instances of the visual */
+    readonly groupCount: number
+    readonly renderObject: RenderObject | undefined
+    createOrUpdate: (ctx: VisualContext, theme: Theme, props?: Partial<PD.Values<P>>, data?: D) => Promise<void> | void
+    getLoci: (pickingId: PickingId) => Loci
+    mark: (loci: Loci, action: MarkerAction) => boolean
+    setVisibility: (value: boolean) => void
+    setPickable: (value: boolean) => void
+    setTransform: (value: Mat4) => void
+    destroy: () => void
+}
+namespace Visual {
+    export function setVisibility(renderObject: VisualRenderObject | undefined, value: boolean) {
+        if (renderObject) renderObject.state.visible = value
+    }
+
+    export function setPickable(renderObject: VisualRenderObject | undefined, value: boolean) {
+        if (renderObject) renderObject.state.pickable = value
+    }
+
+    export function setTransform(renderObject: VisualRenderObject | undefined, value: Mat4) {
+        if (renderObject) {
+            const { values } = renderObject
+            setTransformData(value, values)
+            const boundingSphere = calculateTransformBoundingSphere(values.invariantBoundingSphere.ref.value, values.aTransform.ref.value, values.instanceCount.ref.value)
+            if (!Sphere3D.equals(boundingSphere, values.boundingSphere.ref.value)) {
+                ValueCell.update(values.boundingSphere, boundingSphere)
+            }
+        }
+    }
+}

+ 2 - 1
src/mol-repr/volume/direct-volume.ts

@@ -19,8 +19,9 @@ import { createIdentityTransform } from 'mol-geo/geometry/transform-data';
 import { DirectVolume } from 'mol-geo/geometry/direct-volume/direct-volume';
 import { Geometry } from 'mol-geo/geometry/geometry';
 import { VisualUpdateState } from 'mol-repr/util';
-import { VisualContext, RepresentationContext, RepresentationParamsGetter } from 'mol-repr/representation';
+import { RepresentationContext, RepresentationParamsGetter } from 'mol-repr/representation';
 import { Theme, ThemeRegistryContext } from 'mol-theme/theme';
+import { VisualContext } from 'mol-repr/visual';
 
 function getBoundingBox(gridDimension: Vec3, transform: Mat4) {
     const bbox = Box3D.empty()

+ 2 - 1
src/mol-repr/volume/isosurface-mesh.ts

@@ -16,8 +16,9 @@ import { LocationIterator } from 'mol-geo/util/location-iterator';
 import { createIdentityTransform } from 'mol-geo/geometry/transform-data';
 import { Geometry } from 'mol-geo/geometry/geometry';
 import { VisualUpdateState } from 'mol-repr/util';
-import { VisualContext, RepresentationContext, RepresentationParamsGetter } from 'mol-repr/representation';
+import { RepresentationContext, RepresentationParamsGetter } from 'mol-repr/representation';
 import { Theme, ThemeRegistryContext } from 'mol-theme/theme';
+import { VisualContext } from 'mol-repr/visual';
 
 interface VolumeIsosurfaceProps {
     isoValue: number

+ 5 - 5
src/mol-repr/volume/representation.ts

@@ -5,7 +5,8 @@
  */
 
 import { Task } from 'mol-task'
-import { Representation, Visual, RepresentationContext, VisualContext, RepresentationProvider, RepresentationParamsGetter } from '../representation';
+import { Representation, RepresentationContext, RepresentationProvider, RepresentationParamsGetter } from '../representation';
+import { Visual, VisualContext } from '../visual';
 import { VolumeData } from 'mol-model/volume';
 import { Loci, EmptyLoci, isEveryLoci } from 'mol-model/loci';
 import { Geometry } from 'mol-geo/geometry/geometry';
@@ -23,7 +24,6 @@ import { Theme, createEmptyTheme } from 'mol-theme/theme';
 import { Subject } from 'rxjs';
 import { RenderableState } from 'mol-gl/renderable';
 import { Mat4 } from 'mol-math/linear-algebra';
-import { setTransform } from 'mol-geo/geometry/transform-data';
 
 export interface VolumeVisual<P extends VolumeParams> extends Visual<VolumeData, P> { }
 
@@ -125,13 +125,13 @@ export function VolumeVisual<P extends VolumeParams>(builder: VolumeVisualGeomet
             return changed
         },
         setVisibility(value: boolean) {
-            if (renderObject) renderObject.state.visible = value
+            Visual.setVisibility(renderObject, value)
         },
         setPickable(value: boolean) {
-            if (renderObject) renderObject.state.pickable = value
+            Visual.setPickable(renderObject, value)
         },
         setTransform(value: Mat4) {
-            if (renderObject) setTransform(value, renderObject.values)
+            Visual.setTransform(renderObject, value)
         },
         destroy() {
             // TODO