|
@@ -18,6 +18,7 @@ import { createTransforms, createColors, createSizes } from './utils';
|
|
|
import { deepEqual, defaults } from 'mol-util';
|
|
|
import { SortedArray } from 'mol-data/int';
|
|
|
import { RenderableState, PointValues } from 'mol-gl/renderable';
|
|
|
+import { PickingId } from '../../util/picking';
|
|
|
|
|
|
export const DefaultPointProps = {
|
|
|
colorTheme: { name: 'instance-index' } as ColorTheme,
|
|
@@ -50,7 +51,8 @@ export function createPointVertices(unit: Unit) {
|
|
|
export default function Point(): UnitsRepresentation<PointProps> {
|
|
|
const renderObjects: RenderObject[] = []
|
|
|
let points: PointRenderObject
|
|
|
- let curProps = DefaultPointProps
|
|
|
+ let currentProps = DefaultPointProps
|
|
|
+ let currentGroup: Unit.SymmetryGroup
|
|
|
|
|
|
let _units: ReadonlyArray<Unit>
|
|
|
let _elements: SortedArray
|
|
@@ -58,14 +60,16 @@ export default function Point(): UnitsRepresentation<PointProps> {
|
|
|
return {
|
|
|
renderObjects,
|
|
|
create(group: Unit.SymmetryGroup, props: PointProps = {}) {
|
|
|
+ currentProps = Object.assign({}, DefaultPointProps, props)
|
|
|
+
|
|
|
return Task.create('Point.create', async ctx => {
|
|
|
renderObjects.length = 0 // clear
|
|
|
- curProps = { ...DefaultPointProps, ...props }
|
|
|
+ currentGroup = group
|
|
|
|
|
|
_units = group.units
|
|
|
_elements = group.elements;
|
|
|
|
|
|
- const { colorTheme, sizeTheme } = curProps
|
|
|
+ const { colorTheme, sizeTheme } = currentProps
|
|
|
const elementCount = _elements.length
|
|
|
|
|
|
const vertexMap = VertexMap.create(
|
|
@@ -119,8 +123,8 @@ export default function Point(): UnitsRepresentation<PointProps> {
|
|
|
return Task.create('Point.update', async ctx => {
|
|
|
if (!points || !_units || !_elements) return false
|
|
|
|
|
|
- const newProps = { ...curProps, ...props }
|
|
|
- if (deepEqual(curProps, newProps)) {
|
|
|
+ const newProps = { ...currentProps, ...props }
|
|
|
+ if (deepEqual(currentProps, newProps)) {
|
|
|
console.log('props identical, nothing to change')
|
|
|
return true
|
|
|
}
|
|
@@ -135,20 +139,30 @@ export default function Point(): UnitsRepresentation<PointProps> {
|
|
|
// fillSerial(new Uint32Array(elementCount + 1))
|
|
|
// )
|
|
|
|
|
|
- if (!deepEqual(curProps.colorTheme, newProps.colorTheme)) {
|
|
|
- console.log('colorTheme changed', curProps.colorTheme, newProps.colorTheme)
|
|
|
+ if (!deepEqual(currentProps.colorTheme, newProps.colorTheme)) {
|
|
|
+ console.log('colorTheme changed', currentProps.colorTheme, newProps.colorTheme)
|
|
|
// await ctx.update('Computing point colors');
|
|
|
// const color = createColors(_units, _elementGroup, vertexMap, newProps.colorTheme)
|
|
|
// ValueCell.update(points.props.color, color)
|
|
|
}
|
|
|
|
|
|
- if (!deepEqual(curProps.sizeTheme, newProps.sizeTheme)) {
|
|
|
- console.log('sizeTheme changed', curProps.sizeTheme, newProps.sizeTheme)
|
|
|
+ if (!deepEqual(currentProps.sizeTheme, newProps.sizeTheme)) {
|
|
|
+ console.log('sizeTheme changed', currentProps.sizeTheme, newProps.sizeTheme)
|
|
|
}
|
|
|
|
|
|
- curProps = newProps
|
|
|
+ currentProps = newProps
|
|
|
return false
|
|
|
})
|
|
|
+ },
|
|
|
+ getLocation(pickingId: PickingId) {
|
|
|
+ const { objectId, instanceId, elementId } = pickingId
|
|
|
+ if (points.id === objectId) {
|
|
|
+ const l = Element.Location()
|
|
|
+ l.unit = currentGroup.units[instanceId]
|
|
|
+ l.element = currentGroup.elements[elementId]
|
|
|
+ return l
|
|
|
+ }
|
|
|
+ return null
|
|
|
}
|
|
|
}
|
|
|
}
|