Skip to content

Commit

Permalink
feat(event-display): ability to scale CaloClusters
Browse files Browse the repository at this point in the history
  • Loading branch information
9inpachi committed Apr 5, 2021
1 parent 6f14d29 commit ff666e2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 7 deletions.
42 changes: 35 additions & 7 deletions packages/phoenix-event-display/src/loaders/phoenix-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,14 @@ export class PhoenixLoader implements EventDataLoader {
typeFolder: any,
typeFolderPM: PhoenixMenuNode
) => {
const scaleJets = (value: number) => {
this.graphicsLibrary.getSceneManager().scaleJets(value);
};
if (typeFolder) {
const sizeMenu = typeFolder
.add({ jetsScale: 100 }, 'jetsScale', 1, 200)
.name('Jets Size (%)');
sizeMenu.onChange((value: number) => {
this.graphicsLibrary.getSceneManager().scaleJets(value);
});
sizeMenu.onChange(scaleJets);
}
// Phoenix menu
if (typeFolderPM) {
Expand All @@ -181,9 +182,7 @@ export class PhoenixLoader implements EventDataLoader {
min: 1,
max: 200,
allowCustomValue: true,
onChange: (value: number) => {
this.graphicsLibrary.getSceneManager().scaleJets(value);
},
onChange: scaleJets,
});
}
};
Expand All @@ -210,11 +209,40 @@ export class PhoenixLoader implements EventDataLoader {
new Cut('energy', 0, 10000),
];

const addCaloClusterOptions = (
typeFolder: any,
typeFolderPM: PhoenixMenuNode
) => {
const scaleCaloClusters = (value: number) => {
this.graphicsLibrary
.getSceneManager()
.scaleChildrenObjects('CaloClusters', value / 100);
};
if (typeFolder) {
const sizeMenu = typeFolder
.add({ caloClustersScale: 100 }, 'caloClustersScale', 1, 400)
.name('CaloClusters Size (%)');
sizeMenu.onChange(scaleCaloClusters);
}
// Phoenix menu
if (typeFolderPM) {
typeFolderPM.addConfig('slider', {
label: 'CaloClusters Size (%)',
value: 100,
min: 1,
max: 400,
allowCustomValue: true,
onChange: scaleCaloClusters,
});
}
};

this.addObjectType(
eventData.CaloClusters,
PhoenixObjects.getCluster,
'CaloClusters',
cuts
cuts,
addCaloClusterOptions
);
}

Expand Down
15 changes: 15 additions & 0 deletions packages/phoenix-event-display/src/three/scene-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,21 @@ export class SceneManager {
});
}

/**
* Scale lowest level objects in a group.
* @param groupName Name of the group to scale objects of.
* @param value Value of the scale. Default is 1.
*/
public scaleChildrenObjects(groupName: string, value: number) {
const object = this.scene.getObjectByName(groupName);

object.traverse((objectChild: Object3D) => {
if (objectChild.children.length === 0) {
objectChild.scale.setScalar(value);
}
});
}

/**
* Add label to the three.js object.
* @param label Label to add to the event object.
Expand Down

0 comments on commit ff666e2

Please sign in to comment.