Skip to content

Commit

Permalink
SOF-7354: more experiment with colors x3
Browse files Browse the repository at this point in the history
  • Loading branch information
pranabdas committed May 14, 2024
1 parent 144e039 commit 173af7c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/mixins/atoms.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,16 @@ export const AtomsMixin = (superclass) =>
const atomHSL = {};
new THREE.Color(atomColor).getHSL(atomHSL);
const label = parseInt(atomicLabelsArray[atomicIndex], 10) || 0;
let hue;
let hue, saturation;
if (label !== 0) {
if (label % 2 === 0) {
// even labels
hue = atomHSL.h + (label * 0.1) / 2;
saturation = atomHSL.s + (label * 0.1) / 2;
} else {
// odd labels
hue = atomHSL.h - ((label + 1) * 0.1) / 2;
saturation = atomHSL.s - ((label + 1) * 0.1) / 2;
}

// hue is cyclic
Expand All @@ -123,9 +125,10 @@ export const AtomsMixin = (superclass) =>
hue += 1;
}

saturation = Math.max(0, Math.min(1, saturation));
new THREE.Color(atomColor).setHSL(atomHSL);
sphereMesh.material.emissiveIntensity = 0.25;
sphereMesh.material.emissive.setHSL(hue, atomHSL.s, atomHSL.l);
sphereMesh.material.emissive.setHSL(hue, saturation, atomHSL.l);
}
atomsGroup.add(sphereMesh);
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 173af7c

Please sign in to comment.