Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Rendering optimization for many labels #100

Merged
merged 8 commits into from
Sep 30, 2022
Merged

Conversation

aslipchenk
Copy link
Contributor

No description provided.

@@ -32,15 +51,4 @@ describe("Atom labels", () => {
wave.toggleLabels();
expect(labels.every((label) => label.visible === !areLabelsInitiallyShown)).toBeTruthy();
});

test("Label center is positioned on the atom surface", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good thing to test for - Label center is positioned on the atom surface - perhaps we should keep at least the explanation, if you are doing it in the above test

* @returns {Object.<string, Array.<Three.InstancedMesh>>} atomsHashMap
*/
makeHashMapFromAtomNames() {
const atomsHashMap = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function might better fit in src/mixins/atoms.js

createLabelSpritesAsPoints() {
if (this.#labels.length) {
this.#labels.forEach((label) => this.structureGroup.remove(label));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like should be isolated to this.removeLabels

map: texture,
depthTest: true,
depthFunc: THREE.NotEqualDepth,
transparent: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move the above config to settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean PointsMaterial params?

@@ -124,6 +190,8 @@ export const LabelsMixin = (superclass) =>
*/
toggleLabels() {
this.areLabelsShown = !this.areLabelsShown;
this.#labels.forEach((label) => (label.visible = this.areLabelsShown));
this.#labels.visible = this.areLabelsShown;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our convention was to use is..., are... for booleans to make it clear - so maybe visible -> areVisible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh... just found that the expression on line 194 is wrong, but the visible property is correct because it's a property of THREE.Object3d.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

atoms = atomGroup.children.filter((object) => object.type === "Mesh");
labels = atomGroup.children.filter((object) => object.type === "Sprite");
});

test("Labels are created for every atom", async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per https://github.com/Exabyte-io/wave.js/pull/100/files#r940467021 below - this should be called: "Labels are created for every atom and placed at their centers" probably

src/config.js Outdated
depthTest: true,
depthFunc: THREE.NotEqualDepth,
transparent: true,
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

/**
* this function is creates vertices hashMap where key is atom name, value is array of vertices where this atoms is situated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is creates -> creates
Why do we need this function? Let's explain in the docstring as well.

@@ -12,6 +11,8 @@ export const LabelsMixin = (superclass) =>
class extends superclass {
#texturesCache = {};

#labels = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should create a labelsGroup that will contain the labels for all atoms in the corresponding order as the atoms themselves

src/enums.js Outdated
@@ -27,6 +27,7 @@ export const ATOM_CONNECTION_LINE_NAME = "Atom_Connection";
export const MIN_ANGLE_POINTS_DISTANCE = 0.7;
export const MEASURE_LABELS_GROUP_NAME = "Measure_Labels";
export const ANGLE = "ANGLE";
export const LABELS_GROUP_NAME = "Labels Group";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably safer without the space Labels_Group, no?

);
if (!labelPointsByAtomName) return false;
const positions = labelPointsByAtomName.geometry.getAttribute("position")?.array;
let isHaveSomeLabel = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let hasLabel ...

@aslipchenk aslipchenk merged commit 34fb2a7 into dev Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants