From 205f4c31d677a4b7b39cf296def290d038d04de3 Mon Sep 17 00:00:00 2001 From: Alexander Rose <alexander.rose@weirdbyte.de> Date: Mon, 27 Jan 2020 14:41:24 -0800 Subject: [PATCH] tweaked geometry and render-object types --- src/mol-geo/geometry/geometry.ts | 49 ++++++++-------- src/mol-gl/render-object.ts | 72 ++++++++++-------------- src/mol-gl/renderable/mesh.ts | 2 +- src/mol-gl/renderable/schema.ts | 22 ++++---- src/mol-repr/shape/representation.ts | 14 ++--- src/mol-repr/structure/complex-visual.ts | 12 ++-- src/mol-repr/structure/units-visual.ts | 11 ++-- src/mol-repr/volume/representation.ts | 11 ++-- 8 files changed, 89 insertions(+), 104 deletions(-) diff --git a/src/mol-geo/geometry/geometry.ts b/src/mol-geo/geometry/geometry.ts index 494e33232..b6e0b15f0 100644 --- a/src/mol-geo/geometry/geometry.ts +++ b/src/mol-geo/geometry/geometry.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -19,32 +19,30 @@ import { Spheres } from './spheres/spheres'; import { arrayMax } from '../../mol-util/array'; import { TransformData } from './transform-data'; import { Theme } from '../../mol-theme/theme'; -import { RenderObjectValuesType } from '../../mol-gl/render-object'; -import { ValueOf } from '../../mol-util/type-helpers'; +import { RenderObjectValues } from '../../mol-gl/render-object'; import { TextureMesh } from './texture-mesh/texture-mesh'; -export type GeometryKindType = { - 'mesh': Mesh, - 'points': Points, - 'spheres': Spheres, - 'text': Text, - 'lines': Lines, - 'direct-volume': DirectVolume, - 'texture-mesh': TextureMesh, -} -export type GeometryKindParams = { - 'mesh': Mesh.Params, - 'points': Points.Params, - 'spheres': Spheres.Params, - 'text': Text.Params, - 'lines': Lines.Params, - 'direct-volume': DirectVolume.Params, - 'texture-mesh': TextureMesh.Params, -} -export type GeometryKind = keyof GeometryKindType -export type Geometry = ValueOf<GeometryKindType> +export type GeometryKind = 'mesh' | 'points' | 'spheres' | 'text' | 'lines' | 'direct-volume' | 'texture-mesh' + +export type Geometry<T extends GeometryKind = GeometryKind> = + T extends 'mesh' ? Mesh : + T extends 'points' ? Points : + T extends 'spheres' ? Spheres : + T extends 'text' ? Text : + T extends 'lines' ? Lines : + T extends 'direct-volume' ? DirectVolume : + T extends 'texture-mesh' ? TextureMesh : never + +type GeometryParams<T extends GeometryKind> = + T extends 'mesh' ? Mesh.Params : + T extends 'points' ? Points.Params : + T extends 'spheres' ? Spheres.Params : + T extends 'text' ? Text.Params : + T extends 'lines' ? Lines.Params : + T extends 'direct-volume' ? DirectVolume.Params : + T extends 'texture-mesh' ? TextureMesh.Params : never -export interface GeometryUtils<G extends Geometry, P extends PD.Params = GeometryKindParams[G['kind']], V = RenderObjectValuesType[G['kind']]> { +export interface GeometryUtils<G extends Geometry, P extends PD.Params = GeometryParams<G['kind']>, V = RenderObjectValues<G['kind']>> { Params: P createEmpty(geometry?: G): G createValues(geometry: G, transform: TransformData, locationIt: LocationIterator, theme: Theme, props: PD.Values<P>): V @@ -56,7 +54,7 @@ export interface GeometryUtils<G extends Geometry, P extends PD.Params = Geometr } export namespace Geometry { - export type Params<G extends Geometry> = GeometryKindParams[G['kind']] + export type Params<G extends Geometry> = GeometryParams<G['kind']> export function getDrawCount(geometry: Geometry): number { switch (geometry.kind) { @@ -96,7 +94,6 @@ export namespace Geometry { case 'direct-volume': return DirectVolume.Utils as any case 'texture-mesh': return TextureMesh.Utils as any } - throw new Error('unknown geometry kind') } export function getGranularity(locationIt: LocationIterator, granularity: ColorType | SizeType) { diff --git a/src/mol-gl/render-object.ts b/src/mol-gl/render-object.ts index 3b758213f..bb11d58fb 100644 --- a/src/mol-gl/render-object.ts +++ b/src/mol-gl/render-object.ts @@ -1,11 +1,10 @@ /** - * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import { RenderableState, Renderable } from './renderable' -import { RenderableValues } from './renderable/schema'; import { idFactory } from '../mol-util/id-factory'; import { WebGLContext } from './webgl/context'; import { DirectVolumeValues, DirectVolumeRenderable } from './renderable/direct-volume'; @@ -20,53 +19,40 @@ const getNextId = idFactory(0, 0x7FFFFFFF) export const getNextMaterialId = idFactory(0, 0x7FFFFFFF) -export interface BaseRenderObject<T extends RenderableValues> { id: number, type: string, values: T, state: RenderableState, materialId: number } -export interface MeshRenderObject extends BaseRenderObject<MeshValues> { type: 'mesh' } -export interface PointsRenderObject extends BaseRenderObject<PointsValues> { type: 'points' } -export interface SpheresRenderObject extends BaseRenderObject<SpheresValues> { type: 'spheres' } -export interface TextRenderObject extends BaseRenderObject<TextValues> { type: 'text' } -export interface LinesRenderObject extends BaseRenderObject<LinesValues> { type: 'lines' } -export interface DirectVolumeRenderObject extends BaseRenderObject<DirectVolumeValues> { type: 'direct-volume' } -export interface TextureMeshRenderObject extends BaseRenderObject<TextureMeshValues> { type: 'texture-mesh' } - -// +export interface GraphicsRenderObject<T extends RenderObjectType = RenderObjectType> { + readonly id: number, + readonly type: T, + readonly values: RenderObjectValues<T>, + readonly state: RenderableState, + readonly materialId: number +} -export type GraphicsRenderObject = MeshRenderObject | PointsRenderObject | SpheresRenderObject | TextRenderObject | LinesRenderObject | DirectVolumeRenderObject | TextureMeshRenderObject +export type RenderObjectType = 'mesh' | 'points' | 'spheres' | 'text' | 'lines' | 'direct-volume' | 'texture-mesh' -export type RenderObjectKindType = { - 'mesh': MeshRenderObject - 'points': PointsRenderObject - 'spheres': SpheresRenderObject - 'text': TextRenderObject - 'lines': LinesRenderObject - 'direct-volume': DirectVolumeRenderObject - 'texture-mesh': TextureMeshRenderObject -} -export type RenderObjectValuesType = { - 'mesh': MeshValues - 'points': PointsValues - 'spheres': SpheresValues - 'text': TextValues - 'lines': LinesValues - 'direct-volume': DirectVolumeValues - 'texture-mesh': TextureMeshValues -} -export type RenderObjectType = keyof RenderObjectKindType +export type RenderObjectValues<T extends RenderObjectType> = + T extends 'mesh' ? MeshValues : + T extends 'points' ? PointsValues : + T extends 'spheres' ? SpheresValues : + T extends 'text' ? TextValues : + T extends 'lines' ? LinesValues : + T extends 'direct-volume' ? DirectVolumeValues : + T extends 'texture-mesh' ? TextureMeshValues : never // -export function createRenderObject<T extends RenderObjectType>(type: T, values: RenderObjectValuesType[T], state: RenderableState, materialId: number): RenderObjectKindType[T] { - return { id: getNextId(), type, values, state, materialId } as RenderObjectKindType[T] +export function createRenderObject<T extends RenderObjectType>(type: T, values: RenderObjectValues<T>, state: RenderableState, materialId: number): GraphicsRenderObject<T> { + return { id: getNextId(), type, values, state, materialId } as GraphicsRenderObject<T> } -export function createRenderable(ctx: WebGLContext, o: GraphicsRenderObject): Renderable<any> { +export function createRenderable<T extends RenderObjectType>(ctx: WebGLContext, o: GraphicsRenderObject<T>): Renderable<any> { switch (o.type) { - case 'mesh': return MeshRenderable(ctx, o.id, o.values, o.state, o.materialId) - case 'points': return PointsRenderable(ctx, o.id, o.values, o.state, o.materialId) - case 'spheres': return SpheresRenderable(ctx, o.id, o.values, o.state, o.materialId) - case 'text': return TextRenderable(ctx, o.id, o.values, o.state, o.materialId) - case 'lines': return LinesRenderable(ctx, o.id, o.values, o.state, o.materialId) - case 'direct-volume': return DirectVolumeRenderable(ctx, o.id, o.values, o.state, o.materialId) - case 'texture-mesh': return TextureMeshRenderable(ctx, o.id, o.values, o.state, o.materialId) + case 'mesh': return MeshRenderable(ctx, o.id, o.values as MeshValues, o.state, o.materialId) + case 'points': return PointsRenderable(ctx, o.id, o.values as PointsValues, o.state, o.materialId) + case 'spheres': return SpheresRenderable(ctx, o.id, o.values as SpheresValues, o.state, o.materialId) + case 'text': return TextRenderable(ctx, o.id, o.values as TextValues, o.state, o.materialId) + case 'lines': return LinesRenderable(ctx, o.id, o.values as LinesValues, o.state, o.materialId) + case 'direct-volume': return DirectVolumeRenderable(ctx, o.id, o.values as DirectVolumeValues, o.state, o.materialId) + case 'texture-mesh': return TextureMeshRenderable(ctx, o.id, o.values as TextureMeshValues, o.state, o.materialId) } -} \ No newline at end of file + throw new Error('unsupported type') +} diff --git a/src/mol-gl/renderable/mesh.ts b/src/mol-gl/renderable/mesh.ts index 77ef74a9a..c34240c37 100644 --- a/src/mol-gl/renderable/mesh.ts +++ b/src/mol-gl/renderable/mesh.ts @@ -20,7 +20,7 @@ export const MeshSchema = { dDoubleSided: DefineSpec('boolean'), dFlipSided: DefineSpec('boolean'), dIgnoreLight: DefineSpec('boolean'), -} +} as const export type MeshSchema = typeof MeshSchema export type MeshValues = Values<MeshSchema> diff --git a/src/mol-gl/renderable/schema.ts b/src/mol-gl/renderable/schema.ts index c795631a9..e662b8be0 100644 --- a/src/mol-gl/renderable/schema.ts +++ b/src/mol-gl/renderable/schema.ts @@ -62,7 +62,7 @@ export type KindValue = { 'sphere': Sphere3D } -export type Values<S extends RenderableSchema> = { [k in keyof S]: ValueCell<KindValue[S[k]['kind']]> } +export type Values<S extends RenderableSchema> = { readonly [k in keyof S]: ValueCell<KindValue[S[k]['kind']]> } export function splitValues(schema: RenderableSchema, values: RenderableValues) { const attributeValues: AttributeValues = {} @@ -128,12 +128,12 @@ export function ValueSpec<K extends ValueKind>(kind: K): ValueSpec<K> { // export type RenderableSchema = { - [k: string]: ( + readonly [k: string]: ( AttributeSpec<AttributeKind> | UniformSpec<UniformKind> | TextureSpec<TextureKind> | ValueSpec<ValueKind> | DefineSpec<DefineKind> | ElementsSpec<ElementsKind> ) } -export type RenderableValues = { [k: string]: ValueCell<any> } +export type RenderableValues = { readonly [k: string]: ValueCell<any> } // @@ -181,14 +181,14 @@ export const GlobalUniformSchema = { uHighlightColor: UniformSpec('v3'), uSelectColor: UniformSpec('v3'), -} +} as const export type GlobalUniformSchema = typeof GlobalUniformSchema export type GlobalUniformValues = Values<GlobalUniformSchema> // { [k in keyof GlobalUniformSchema]: ValueCell<any> } export const InternalSchema = { uObjectId: UniformSpec('i'), uPickable: UniformSpec('i', true), -} +} as const export type InternalSchema = typeof InternalSchema export type InternalValues = { [k in keyof InternalSchema]: ValueCell<any> } @@ -198,7 +198,7 @@ export const ColorSchema = { uColorTexDim: UniformSpec('v2'), tColor: TextureSpec('image-uint8', 'rgb', 'ubyte', 'nearest'), dColorType: DefineSpec('string', ['uniform', 'attribute', 'instance', 'group', 'group_instance']), -} +} as const export type ColorSchema = typeof ColorSchema export type ColorValues = Values<ColorSchema> @@ -209,14 +209,14 @@ export const SizeSchema = { tSize: TextureSpec('image-uint8', 'alpha', 'ubyte', 'nearest'), dSizeType: DefineSpec('string', ['uniform', 'attribute', 'instance', 'group', 'group_instance']), uSizeFactor: UniformSpec('f'), -} +} as const export type SizeSchema = typeof SizeSchema export type SizeValues = Values<SizeSchema> export const MarkerSchema = { uMarkerTexDim: UniformSpec('v2'), tMarker: TextureSpec('image-uint8', 'alpha', 'ubyte', 'nearest'), -} +} as const export type MarkerSchema = typeof MarkerSchema export type MarkerValues = Values<MarkerSchema> @@ -224,7 +224,7 @@ export const OverpaintSchema = { uOverpaintTexDim: UniformSpec('v2'), tOverpaint: TextureSpec('image-uint8', 'rgba', 'ubyte', 'nearest'), dOverpaint: DefineSpec('boolean'), -} +} as const export type OverpaintSchema = typeof OverpaintSchema export type OverpaintValues = Values<OverpaintSchema> @@ -235,7 +235,7 @@ export const TransparencySchema = { dTransparency: DefineSpec('boolean'), // dTransparencyType: DefineSpec('string', ['uniform', 'attribute', 'instance', 'group', 'group_instance']), // TODO dTransparencyVariant: DefineSpec('string', ['single', 'multi']), -} +} as const export type TransparencySchema = typeof TransparencySchema export type TransparencyValues = Values<TransparencySchema> @@ -277,6 +277,6 @@ export const BaseSchema = { boundingSphere: ValueSpec('sphere'), /** bounding sphere NOT taking aTransform into account */ invariantBoundingSphere: ValueSpec('sphere'), -} +} as const export type BaseSchema = typeof BaseSchema export type BaseValues = Values<BaseSchema> \ No newline at end of file diff --git a/src/mol-repr/shape/representation.ts b/src/mol-repr/shape/representation.ts index 5ba99bb13..35ef8437a 100644 --- a/src/mol-repr/shape/representation.ts +++ b/src/mol-repr/shape/representation.ts @@ -8,7 +8,7 @@ import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry'; import { Representation } from '../representation'; import { Shape, ShapeGroup } from '../../mol-model/shape'; import { Subject } from 'rxjs'; -import { getNextMaterialId, RenderObjectKindType, createRenderObject, RenderObjectValuesType } from '../../mol-gl/render-object'; +import { getNextMaterialId, createRenderObject, RenderObjectValues, GraphicsRenderObject } from '../../mol-gl/render-object'; import { Theme } from '../../mol-theme/theme'; import { LocationIterator } from '../../mol-geo/util/location-iterator'; import { VisualUpdateState } from '../util'; @@ -18,7 +18,7 @@ import { createMarkers } from '../../mol-geo/geometry/marker-data'; import { MarkerAction } from '../../mol-util/marker-action'; import { ValueCell } from '../../mol-util'; import { createColors } from '../../mol-geo/geometry/color-data'; -import { createSizes } from '../../mol-geo/geometry/size-data'; +import { createSizes, SizeData } from '../../mol-geo/geometry/size-data'; import { Loci, isEveryLoci, EmptyLoci } from '../../mol-model/loci'; import { Interval, OrderedSet } from '../../mol-data/int'; import { PickingId } from '../../mol-geo/geometry/picking'; @@ -44,8 +44,8 @@ export function ShapeRepresentation<D, G extends Geometry, P extends Geometry.Pa const updated = new Subject<number>() const _state = Representation.createState() const materialId = getNextMaterialId() - const renderObjects: RenderObjectKindType[G['kind']][] = [] - let _renderObject: RenderObjectKindType[G['kind']] | undefined + const renderObjects: GraphicsRenderObject<G['kind']>[] = [] + let _renderObject: GraphicsRenderObject<G['kind']> | undefined let _shape: Shape<G> let _theme = Theme.createEmpty() let currentProps: PD.Values<P> = PD.getDefaultValues(geometryUtils.Params as P) // TODO avoid casting @@ -136,7 +136,7 @@ export function ShapeRepresentation<D, G extends Geometry, P extends Geometry.Pa if (updateState.updateTransform || updateState.createGeometry) { // console.log('updateBoundingSphere') - geometryUtils.updateBoundingSphere(_renderObject.values as RenderObjectValuesType[G['kind']], _shape.geometry) + geometryUtils.updateBoundingSphere(_renderObject.values as RenderObjectValues<G['kind']>, _shape.geometry) } if (updateState.updateColor) { @@ -148,11 +148,11 @@ export function ShapeRepresentation<D, G extends Geometry, P extends Geometry.Pa // not all geometries have size data, so check here if ('uSize' in _renderObject.values) { // console.log('update size') - createSizes(locationIt, _theme.size, _renderObject.values) + createSizes(locationIt, _theme.size, _renderObject.values as SizeData) } } - geometryUtils.updateValues(_renderObject.values as RenderObjectValuesType[G['kind']], newProps) + geometryUtils.updateValues(_renderObject.values as RenderObjectValues<G['kind']>, newProps) geometryUtils.updateRenderableState(_renderObject.state, newProps) } diff --git a/src/mol-repr/structure/complex-visual.ts b/src/mol-repr/structure/complex-visual.ts index 9e83a816d..6a56a62c0 100644 --- a/src/mol-repr/structure/complex-visual.ts +++ b/src/mol-repr/structure/complex-visual.ts @@ -12,7 +12,7 @@ import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry'; import { LocationIterator } from '../../mol-geo/util/location-iterator'; import { Theme } from '../../mol-theme/theme'; import { createIdentityTransform } from '../../mol-geo/geometry/transform-data'; -import { createRenderObject, RenderObjectKindType, RenderObjectValuesType } from '../../mol-gl/render-object'; +import { createRenderObject, RenderObjectValues, GraphicsRenderObject } from '../../mol-gl/render-object'; import { UnitKind, UnitKindOptions } from './visual/util/common'; import { PickingId } from '../../mol-geo/geometry/picking'; import { Loci, isEveryLoci, EmptyLoci } from '../../mol-model/loci'; @@ -20,7 +20,7 @@ import { Interval } from '../../mol-data/int'; import { VisualUpdateState } from '../util'; import { ColorTheme } from '../../mol-theme/color'; import { ValueCell, deepEqual } from '../../mol-util'; -import { createSizes } from '../../mol-geo/geometry/size-data'; +import { createSizes, SizeData } from '../../mol-geo/geometry/size-data'; import { createColors } from '../../mol-geo/geometry/color-data'; import { MarkerAction } from '../../mol-util/marker-action'; import { Mat4 } from '../../mol-math/linear-algebra'; @@ -66,7 +66,7 @@ export function ComplexVisual<G extends Geometry, P extends ComplexParams & Geom const { updateValues, updateBoundingSphere, updateRenderableState } = builder.geometryUtils const updateState = VisualUpdateState.create() - let renderObject: RenderObjectKindType[G['kind']] | undefined + let renderObject: GraphicsRenderObject<G['kind']> | undefined let newProps: PD.Values<P> let newTheme: Theme @@ -144,7 +144,7 @@ export function ComplexVisual<G extends Geometry, P extends ComplexParams & Geom if (updateState.createGeometry) { if (newGeometry) { ValueCell.update(renderObject.values.drawCount, Geometry.getDrawCount(newGeometry)) - updateBoundingSphere(renderObject.values as RenderObjectValuesType[G['kind']], newGeometry) + updateBoundingSphere(renderObject.values as RenderObjectValues<G['kind']>, newGeometry) } else { throw new Error('expected geometry to be given') } @@ -153,7 +153,7 @@ export function ComplexVisual<G extends Geometry, P extends ComplexParams & Geom if (updateState.updateSize) { // not all geometries have size data, so check here if ('uSize' in renderObject.values) { - createSizes(locationIt, newTheme.size, renderObject.values) + createSizes(locationIt, newTheme.size, renderObject.values as SizeData) } } @@ -161,7 +161,7 @@ export function ComplexVisual<G extends Geometry, P extends ComplexParams & Geom createColors(locationIt, newTheme.color, renderObject.values) } - updateValues(renderObject.values as RenderObjectValuesType[G['kind']], newProps) + updateValues(renderObject.values as RenderObjectValues<G['kind']>, newProps) updateRenderableState(renderObject.state, newProps) } diff --git a/src/mol-repr/structure/units-visual.ts b/src/mol-repr/structure/units-visual.ts index 290088ede..0af2d3049 100644 --- a/src/mol-repr/structure/units-visual.ts +++ b/src/mol-repr/structure/units-visual.ts @@ -12,7 +12,7 @@ import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry'; import { LocationIterator } from '../../mol-geo/util/location-iterator'; import { Theme } from '../../mol-theme/theme'; import { createUnitsTransform, includesUnitKind } from './visual/util/common'; -import { createRenderObject, RenderObjectKindType, RenderObjectValuesType } from '../../mol-gl/render-object'; +import { createRenderObject, RenderObjectValues, GraphicsRenderObject } from '../../mol-gl/render-object'; import { UnitsParams } from './units-representation'; import { PickingId } from '../../mol-geo/geometry/picking'; import { Loci, isEveryLoci, EmptyLoci } from '../../mol-model/loci'; @@ -36,6 +36,7 @@ import { Lines } from '../../mol-geo/geometry/lines/lines'; import { Text } from '../../mol-geo/geometry/text/text'; import { DirectVolume } from '../../mol-geo/geometry/direct-volume/direct-volume'; import { TextureMesh } from '../../mol-geo/geometry/texture-mesh/texture-mesh'; +import { SizeValues } from '../../mol-gl/renderable/schema'; export type StructureGroup = { structure: Structure, group: Unit.SymmetryGroup } @@ -67,7 +68,7 @@ export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry const { createEmpty: createEmptyGeometry, updateValues, updateBoundingSphere, updateRenderableState } = builder.geometryUtils const updateState = VisualUpdateState.create() - let renderObject: RenderObjectKindType[G['kind']] | undefined + let renderObject: GraphicsRenderObject<G['kind']> | undefined let newProps: PD.Values<P> = Object.assign({}, defaultProps) let newTheme: Theme = Theme.createEmpty() @@ -183,14 +184,14 @@ export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry if (updateState.updateTransform || updateState.createGeometry) { // console.log('UnitsVisual.updateBoundingSphere') - updateBoundingSphere(renderObject.values as RenderObjectValuesType[G['kind']], newGeometry || geometry) + updateBoundingSphere(renderObject.values as RenderObjectValues<G['kind']>, newGeometry || geometry) } if (updateState.updateSize) { // not all geometries have size data, so check here if ('uSize' in renderObject.values) { // console.log('update size') - createSizes(locationIt, newTheme.size, renderObject.values) + createSizes(locationIt, newTheme.size, renderObject.values as SizeValues) } } @@ -199,7 +200,7 @@ export function UnitsVisual<G extends Geometry, P extends UnitsParams & Geometry createColors(locationIt, newTheme.color, renderObject.values) } - updateValues(renderObject.values as RenderObjectValuesType[G['kind']], newProps) + updateValues(renderObject.values as RenderObjectValues<G['kind']>, newProps) updateRenderableState(renderObject.state, newProps) } diff --git a/src/mol-repr/volume/representation.ts b/src/mol-repr/volume/representation.ts index 0cad56d6e..f8625e4f0 100644 --- a/src/mol-repr/volume/representation.ts +++ b/src/mol-repr/volume/representation.ts @@ -11,7 +11,7 @@ import { Geometry, GeometryUtils } from '../../mol-geo/geometry/geometry'; import { LocationIterator } from '../../mol-geo/util/location-iterator'; import { Theme } from '../../mol-theme/theme'; import { createIdentityTransform } from '../../mol-geo/geometry/transform-data'; -import { createRenderObject, RenderObjectKindType, RenderObjectValuesType, getNextMaterialId, GraphicsRenderObject } from '../../mol-gl/render-object'; +import { createRenderObject, RenderObjectValues, getNextMaterialId, GraphicsRenderObject } from '../../mol-gl/render-object'; import { PickingId } from '../../mol-geo/geometry/picking'; import { Loci, isEveryLoci, EmptyLoci } from '../../mol-model/loci'; import { Interval } from '../../mol-data/int'; @@ -28,6 +28,7 @@ import { Representation, RepresentationProvider, RepresentationContext, Represen import { BaseGeometry } from '../../mol-geo/geometry/base'; import { Subject } from 'rxjs'; import { Task } from '../../mol-task'; +import { SizeValues } from '../../mol-gl/renderable/schema'; export interface VolumeVisual<P extends VolumeParams> extends Visual<VolumeData, P> { } @@ -57,7 +58,7 @@ export function VolumeVisual<G extends Geometry, P extends VolumeParams & Geomet const { updateValues, updateBoundingSphere, updateRenderableState } = builder.geometryUtils const updateState = VisualUpdateState.create() - let renderObject: RenderObjectKindType[G['kind']] | undefined + let renderObject: GraphicsRenderObject<G['kind']> | undefined let newProps: PD.Values<P> let newTheme: Theme @@ -119,7 +120,7 @@ export function VolumeVisual<G extends Geometry, P extends VolumeParams & Geomet if (updateState.createGeometry) { if (newGeometry) { ValueCell.update(renderObject.values.drawCount, Geometry.getDrawCount(newGeometry)) - updateBoundingSphere(renderObject.values as RenderObjectValuesType[G['kind']], newGeometry) + updateBoundingSphere(renderObject.values as RenderObjectValues<G['kind']>, newGeometry) } else { throw new Error('expected geometry to be given') } @@ -128,7 +129,7 @@ export function VolumeVisual<G extends Geometry, P extends VolumeParams & Geomet if (updateState.updateSize) { // not all geometries have size data, so check here if ('uSize' in renderObject.values) { - createSizes(locationIt, newTheme.size, renderObject.values) + createSizes(locationIt, newTheme.size, renderObject.values as SizeValues) } } @@ -136,7 +137,7 @@ export function VolumeVisual<G extends Geometry, P extends VolumeParams & Geomet createColors(locationIt, newTheme.color, renderObject.values) } - updateValues(renderObject.values as RenderObjectValuesType[G['kind']], newProps) + updateValues(renderObject.values, newProps) updateRenderableState(renderObject.state, newProps) } -- GitLab