Skip to content
Snippets Groups Projects
Commit 043e23a1 authored by Alexander Rose's avatar Alexander Rose
Browse files

added shape.sourceData

parent f4d019ac
No related branches found
No related tags found
No related merge requests found
......@@ -67,7 +67,7 @@ async function getShape(ctx: RuntimeContext, plyFile: PlyFile, props: {}, shape?
const mesh = await getPlyMesh(ctx, vertex, face, shape && shape.geometry)
return shape || Shape.create(
'test', mesh,
'test', plyFile, mesh,
(groupId: number) => {
return Color.fromRgb(red.value(groupId), green.value(groupId), blue.value(groupId))
},
......
......@@ -15,6 +15,8 @@ export interface Shape<G extends Geometry = Geometry> {
readonly id: UUID
/** A name to describe the shape */
readonly name: string
/** The data used to create the shape */
readonly sourceData: unknown
/** 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 */
......@@ -30,10 +32,11 @@ export interface Shape<G extends Geometry = Geometry> {
}
export namespace Shape {
export function create<G extends Geometry>(name: string, geometry: G, getColor: Shape['getColor'], getSize: Shape['getSize'], getLabel: Shape['getLabel'], transforms?: Mat4[]): Shape<G> {
export function create<G extends Geometry>(name: string, sourceData: unknown, geometry: G, getColor: Shape['getColor'], getSize: Shape['getSize'], getLabel: Shape['getLabel'], transforms?: Mat4[]): Shape<G> {
return {
id: UUID.create22(),
name,
sourceData,
geometry,
transforms: transforms || [Mat4.identity()],
get groupCount() { return Geometry.getGroupCount(geometry) },
......
......@@ -107,7 +107,7 @@ export const SceneLabels = PluginBehavior.create<SceneLabelsProps>({
private getLabelsShape = (ctx: RuntimeContext, data: LabelsData, props: SceneLabelsProps, shape?: Shape<Text>) => {
this.geo = getLabelsText(data, props, this.geo)
return Shape.create('Scene Labels', this.geo, this.getColor, this.getSize, this.getLabel, data.transforms)
return Shape.create('Scene Labels', data, this.geo, this.getColor, this.getSize, this.getLabel, data.transforms)
}
/** Update structures to be labeled, returns true if changed */
......
......@@ -44,7 +44,7 @@ export async function getLabelRepresentation(ctx: RuntimeContext, structure: Str
function getLabelsShape(ctx: RuntimeContext, data: LabelsData, props: PD.Values<Text.Params>, shape?: Shape<Text>) {
const geo = getLabelsText(data, props, shape && shape.geometry);
return Shape.create('Scene Labels', geo, () => ColorNames.dimgrey, g => data.sizes[g], () => '')
return Shape.create('Scene Labels', data, geo, () => ColorNames.dimgrey, g => data.sizes[g], () => '')
}
const boundaryHelper = new BoundaryHelper();
......
......@@ -19,9 +19,6 @@ import { Representation } from 'mol-repr/representation';
import { MarkerAction } from 'mol-geo/geometry/marker-data';
import { EveryLoci } from 'mol-model/loci';
const parent = document.getElementById('app')!
parent.style.width = '100%'
parent.style.height = '100%'
......@@ -100,7 +97,7 @@ async function getShape(ctx: RuntimeContext, data: MyData, props: {}, shape?: Sh
const mesh = await getSphereMesh(ctx, centers, shape && shape.geometry)
const groupCount = centers.length / 3
return shape || Shape.create(
'test', mesh,
'test', data, mesh,
(groupId: number) => colors[groupId], // color: per group, same for instances
() => 1, // size: constant
(groupId: number, instanceId: number) => labels[instanceId * groupCount + groupId], // label: per group and instance
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment