question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to distinguish between spheres which are created using "addSphere()" and "state.currentGroup"?

See original GitHub issue

I created three groups where each group consists of two spheres using this code as follows (refer to the figure below). Group 1 (two red spheres), Group 2 (two green spheres), and Group 3 (two blue spheres).

const state = MeshBuilder.createState(data.centers.length * 128, data.centers.length * 128 / 2, mesh);
state.currentGroup = 0;
for(let i=0, j=0; i < data.centers.length; i +=3, ++j){
    state.currentGroup = j;
    addSphere(state, Vec3.create(data.centers[i],data.centers[i+1],data.centers[i+2]), data.radii[j], 3);
}
MeshBuilder.getMesh(state);

Because I assigned an unique “state.currentGroup” to each sphere as in the code above, my code worked fine to capture the interaction of each sphere.

My questions are as follows.

Q1) How can I distinguish between spheres in the same group using some kind of “Id”, e.g. state.currentGroup? I.e. is there a way either to use state.currentGroup of a sphere or to store an “ID” for the sphere so that my program identifies clicked sphere?

Q2) How can I determine first two arguments “initialCount” and “chunkSize” of MeshBuilder.createState()? Currently, I just used values of example code in the repository of Molstar.

스크린샷 2022-10-06 오후 10 06 19

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dsehnalcommented, Oct 6, 2022

The event also contains the information about the representation you clicked on, you can distinguish between the spheres like that, by including some more info in the sourceData field (or something like this) when you are creating your shape.

0reactions
simonryucommented, Oct 25, 2022

@dsehnal I store the information in a string array (named “InfoMap”) when I create each sphere in advance. Then molstar successfully shows the label (in this example radius of the sphere) in InfoMap which corresponds to a clicked sphere as illustrated in the figure below. Thank you again!

ShowRadius

@dsehnal Is there a way to identify “the id (or label whatever)” of the clicked sphere and then instantly to process something using “the identified id” rather than showing the information stored in advance when I create the sphere?

I tried to identify the label of the clicked sphere using the following code.

...
Shape.create(
...
(groupId: number) => 'ID: ' + SphereIDMap[groupId],
...
);
this.plugin.behaviors.interaction.click.subscribe(e => {
            type Loci = {
                [key: string]: any;
            };
            const lc : Loci = e.current.loci;
            console.log(lc.shape.getLabel());
}

I stored a globally unique id in “SphereIDMap” rather than an unique within the same representation (shape). Still, molstar successfully shows the label in right lower corner of its pane.

However, the console shows “ID: undefined” only (i.e. “lc.shape.getLabel()” does not return the stored id). If my program can get the unique id of clicked sphere, I could do my job.

@dsehnal

Should I follow another way? Or, did I make any mistake?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are the Earth System's Four Spheres? - Geography Realm
In this breakdown, all of the Earth's water is included in the hydrosphere. This includes surface water (such as rivers, lakes, and oceans), ......
Read more >
Source code for schrodinger.application.phase.phase_markers
Group() self.text_objects = [] # Create a torus marker if an aromatic feature ... has projected coordinates, arrows are created pointing to/from the...
Read more >
Earth's Spheres - COTF
Image of the Earth. Everything in Earth's system can be placed into one of four major subsystems: land, water, living things, or air....
Read more >
GSAS-II Developers Documentation - Read the Docs
NIST FPA Use Fundamental Parameters to determine GSAS-II profile function ... SetBinaryPath() is called to establish the directory where ...
Read more >
Opposite of OnWillRenderObejct? - Unity Forum
have you ever considered using the CullingGroup API? ... heres some code I wrote from a previous project that should help get you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found