Skip to content

Commit

Permalink
Merge pull request #599 from kjvbrt/cell-opacity
Browse files Browse the repository at this point in the history
feat(event-display): calo cell opacity
  • Loading branch information
EdwardMoyse committed Aug 25, 2023
2 parents 897c2c9 + 33e0566 commit 9553acf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/phoenix-event-display/src/loaders/edm4hep-json-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ export class Edm4hepJsonLoader extends PhoenixLoader {
const eta = Math.asinh(z / rho);
const phi = Math.acos(x / rho) * Math.sign(y);
const cellLightness = this.valToLightness(rawCell.energy, 1e-3, 1);
const cellOpacity = this.valToOpacity(rawCell.energy, 1e-3, 1);

const cell = {
eta: eta,
Expand All @@ -436,6 +437,7 @@ export class Edm4hepJsonLoader extends PhoenixLoader {
side: cellSide,
length: cellSide, // expecting cells in multiple layers
color: '#' + this.convHSLtoHEX(cellsHue, 90, cellLightness),
opacity: cellOpacity,
};
cells.push(cell);
});
Expand Down Expand Up @@ -657,6 +659,19 @@ export class Edm4hepJsonLoader extends PhoenixLoader {
return lightness;
}

/** Return a opacity value from the passed number and range */
private valToOpacity(v: number, min: number, max: number): number {
let opacity = 0.2 + ((v - min) * 0.65) / (max - min);
if (opacity < 0.2) {
opacity = 0.2;
}
if (opacity > 0.8) {
opacity = 0.8;
}

return opacity;
}

/** Get the required collection */
private getCollByID(event: any, id: number) {
for (const collName in event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ export class PhoenixObjects {
length?: number;
side?: number;
color?: string;
opacity?: number;
},
defaultCellWidth: number = 30,
defaultCellLength: number = 30,
Expand All @@ -630,6 +631,8 @@ export class PhoenixObjects {
// material
const material = new MeshPhongMaterial({
color: clusterParams.color ?? EVENT_DATA_TYPE_COLORS.CaloClusters,
opacity: clusterParams.opacity ?? 1.0,
transparent: (clusterParams.opacity ?? 1.0) == 1.0 ? false : true,
});

// object
Expand All @@ -650,6 +653,7 @@ export class PhoenixObjects {
z?: number;
theta?: number;
color?: string;
opacity?: number;
side?: number;
length?: number;
uuid: string;
Expand Down

0 comments on commit 9553acf

Please sign in to comment.