|
@@ -11,13 +11,20 @@ import { Geometry } from 'mol-geo/geometry/geometry';
|
|
|
import { Mat4 } from 'mol-math/linear-algebra';
|
|
|
|
|
|
export interface Shape<G extends Geometry = Geometry> {
|
|
|
+ /** A uuid to identify a shape object */
|
|
|
readonly id: UUID
|
|
|
+ /** A name to describe the shape */
|
|
|
readonly name: string
|
|
|
+ /** The geometry of the shape, e.g. `Mesh` or `Lines` */
|
|
|
readonly geometry: G
|
|
|
+ /** An array of transformation matrices to describe multiple instances of the geometry */
|
|
|
readonly transforms: Mat4[]
|
|
|
+ /** Number of groups in the geometry */
|
|
|
readonly groupCount: number
|
|
|
- getColor(groupId: number): Color
|
|
|
- getLabel(groupId: number): string
|
|
|
+ /** Get color for a given group */
|
|
|
+ getColor(groupId: number, instanceId: number): Color
|
|
|
+ /** Get color for a given group */
|
|
|
+ getLabel(groupId: number, instanceId: number): string
|
|
|
}
|
|
|
|
|
|
export namespace Shape {
|
|
@@ -37,10 +44,11 @@ export namespace Shape {
|
|
|
readonly kind: 'group-location'
|
|
|
shape: Shape
|
|
|
group: number
|
|
|
+ instance: number
|
|
|
}
|
|
|
|
|
|
- export function Location(shape?: Shape, group?: number): Location {
|
|
|
- return { kind: 'group-location', shape: shape!, group: group || 0 };
|
|
|
+ export function Location(shape?: Shape, group?: number, instance?: number): Location {
|
|
|
+ return { kind: 'group-location', shape: shape!, group: group || 0, instance: instance || 0 };
|
|
|
}
|
|
|
|
|
|
export function isLocation(x: any): x is Location {
|
|
@@ -53,10 +61,11 @@ export namespace Shape {
|
|
|
readonly groups: ReadonlyArray<{
|
|
|
ids: OrderedSet<number>
|
|
|
}>
|
|
|
+ readonly instance: number
|
|
|
}
|
|
|
|
|
|
- export function Loci(shape: Shape, groups: ArrayLike<{ ids: OrderedSet<number> }>): Loci {
|
|
|
- return { kind: 'group-loci', shape, groups: groups as Loci['groups'] };
|
|
|
+ export function Loci(shape: Shape, groups: ArrayLike<{ ids: OrderedSet<number> }>, instance: number): Loci {
|
|
|
+ return { kind: 'group-loci', shape, groups: groups as Loci['groups'], instance };
|
|
|
}
|
|
|
|
|
|
export function isLoci(x: any): x is Loci {
|
|
@@ -66,6 +75,7 @@ export namespace Shape {
|
|
|
export function areLociEqual(a: Loci, b: Loci) {
|
|
|
if (a.shape !== b.shape) return false
|
|
|
if (a.groups.length !== b.groups.length) return false
|
|
|
+ if (a.instance !== b.instance) return false
|
|
|
for (let i = 0, il = a.groups.length; i < il; ++i) {
|
|
|
const groupA = a.groups[i]
|
|
|
const groupB = b.groups[i]
|