Skip to content

Commit

Permalink
feat(event-display): improve color manager code
Browse files Browse the repository at this point in the history
  • Loading branch information
9inpachi committed May 6, 2021
1 parent d2e0547 commit 3839578
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export class ColorManager {
for (const child of Object.values(collection.children)) {
child.traverse((object) => {
// For jets and tracks
if (object && object['material']) {
(object['material'].color as Color).set(color);
}
(object?.['material']?.color as Color).set(color);
});
}
}
Expand All @@ -59,18 +57,18 @@ export class ColorManager {
const scene = this.sceneManager.getScene();
const vertices = scene.getObjectByName('Vertices');
vertices.traverse((object) => {
const { linkedTrackCollection, linkedTracks } = object.userData;

if (
object.name === 'Vertex' &&
object.userData.linkedTracks &&
object.userData.linkedTrackCollection === collectionName
linkedTrackCollection === collectionName &&
linkedTracks
) {
const colorForTracksVertex = new Color(Math.random() * 0xffffff);

const trackCollection = scene.getObjectByName(
object.userData.linkedTrackCollection
);
const trackCollection = scene.getObjectByName(linkedTrackCollection);

object.userData.linkedTracks.forEach((trackIndex: number) => {
linkedTracks.forEach((trackIndex: number) => {
trackCollection.children[trackIndex].traverse((trackObject) => {
trackObject?.['material']?.color?.set(colorForTracksVertex);
});
Expand Down

0 comments on commit 3839578

Please sign in to comment.