|
@@ -5,6 +5,8 @@
|
|
* @author David Sehnal <david.sehnal@gmail.com>
|
|
* @author David Sehnal <david.sehnal@gmail.com>
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
+// TODO multiple cylinders for higher bond orders
|
|
|
|
+
|
|
import { ValueCell } from 'mol-util/value-cell'
|
|
import { ValueCell } from 'mol-util/value-cell'
|
|
|
|
|
|
import { RenderObject, createMeshRenderObject, MeshRenderObject } from 'mol-gl/render-object'
|
|
import { RenderObject, createMeshRenderObject, MeshRenderObject } from 'mol-gl/render-object'
|
|
@@ -22,7 +24,7 @@ import { Vec3, Mat4 } from 'mol-math/linear-algebra';
|
|
import { createUniformColor } from '../../util/color-data';
|
|
import { createUniformColor } from '../../util/color-data';
|
|
import { defaults } from 'mol-util';
|
|
import { defaults } from 'mol-util';
|
|
import { Loci, isEveryLoci } from 'mol-model/loci';
|
|
import { Loci, isEveryLoci } from 'mol-model/loci';
|
|
-import { FlagAction, applyFlagAction, createFlags } from '../../util/flag-data';
|
|
|
|
|
|
+import { MarkerAction, applyMarkerAction, createMarkers } from '../../util/marker-data';
|
|
|
|
|
|
function createBondMesh(unit: Unit, mesh?: Mesh) {
|
|
function createBondMesh(unit: Unit, mesh?: Mesh) {
|
|
return Task.create('Cylinder mesh', async ctx => {
|
|
return Task.create('Cylinder mesh', async ctx => {
|
|
@@ -110,15 +112,15 @@ export default function BondUnitsRepresentation(): UnitsRepresentation<BondProps
|
|
await ctx.update('Computing bond colors');
|
|
await ctx.update('Computing bond colors');
|
|
const color = createUniformColor({ value: 0xFF0000 })
|
|
const color = createUniformColor({ value: 0xFF0000 })
|
|
|
|
|
|
- await ctx.update('Computing bond flags');
|
|
|
|
- const flag = createFlags(instanceCount * elementCount)
|
|
|
|
|
|
+ await ctx.update('Computing bond marks');
|
|
|
|
+ const marker = createMarkers(instanceCount * elementCount)
|
|
|
|
|
|
const values: MeshValues = {
|
|
const values: MeshValues = {
|
|
...getMeshData(mesh),
|
|
...getMeshData(mesh),
|
|
aTransform: transforms,
|
|
aTransform: transforms,
|
|
aInstanceId: ValueCell.create(fillSerial(new Float32Array(instanceCount))),
|
|
aInstanceId: ValueCell.create(fillSerial(new Float32Array(instanceCount))),
|
|
...color,
|
|
...color,
|
|
- ...flag,
|
|
|
|
|
|
+ ...marker,
|
|
|
|
|
|
uAlpha: ValueCell.create(defaults(props.alpha, 1.0)),
|
|
uAlpha: ValueCell.create(defaults(props.alpha, 1.0)),
|
|
uInstanceCount: ValueCell.create(instanceCount),
|
|
uInstanceCount: ValueCell.create(instanceCount),
|
|
@@ -173,9 +175,9 @@ export default function BondUnitsRepresentation(): UnitsRepresentation<BondProps
|
|
}
|
|
}
|
|
return null
|
|
return null
|
|
},
|
|
},
|
|
- applyFlags(loci: Loci, action: FlagAction) {
|
|
|
|
|
|
+ mark(loci: Loci, action: MarkerAction) {
|
|
const group = currentGroup
|
|
const group = currentGroup
|
|
- const tFlag = cylinders.values.tFlag
|
|
|
|
|
|
+ const tMarker = cylinders.values.tMarker
|
|
const unit = group.units[0]
|
|
const unit = group.units[0]
|
|
if (!Unit.isAtomic(unit)) return
|
|
if (!Unit.isAtomic(unit)) return
|
|
|
|
|
|
@@ -183,9 +185,9 @@ export default function BondUnitsRepresentation(): UnitsRepresentation<BondProps
|
|
const instanceCount = group.units.length
|
|
const instanceCount = group.units.length
|
|
|
|
|
|
let changed = false
|
|
let changed = false
|
|
- const array = tFlag.ref.value.array
|
|
|
|
|
|
+ const array = tMarker.ref.value.array
|
|
if (isEveryLoci(loci)) {
|
|
if (isEveryLoci(loci)) {
|
|
- applyFlagAction(array, 0, elementCount * instanceCount, action)
|
|
|
|
|
|
+ applyMarkerAction(array, 0, elementCount * instanceCount, action)
|
|
changed = true
|
|
changed = true
|
|
} else if (Bond.isLoci(loci)) {
|
|
} else if (Bond.isLoci(loci)) {
|
|
for (const b of loci.bonds) {
|
|
for (const b of loci.bonds) {
|
|
@@ -194,7 +196,7 @@ export default function BondUnitsRepresentation(): UnitsRepresentation<BondProps
|
|
const _idx = unit.bonds.getEdgeIndex(b.aIndex, b.bIndex)
|
|
const _idx = unit.bonds.getEdgeIndex(b.aIndex, b.bIndex)
|
|
if (_idx !== -1) {
|
|
if (_idx !== -1) {
|
|
const idx = _idx
|
|
const idx = _idx
|
|
- if (applyFlagAction(array, idx, idx + 1, action) && !changed) {
|
|
|
|
|
|
+ if (applyMarkerAction(array, idx, idx + 1, action) && !changed) {
|
|
changed = true
|
|
changed = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -204,7 +206,7 @@ export default function BondUnitsRepresentation(): UnitsRepresentation<BondProps
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if (changed) {
|
|
if (changed) {
|
|
- ValueCell.update(tFlag, tFlag.ref.value)
|
|
|
|
|
|
+ ValueCell.update(tMarker, tMarker.ref.value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|