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

How to go back and forth between Object3D nodes and ROOT Geometry nodes? #304

Closed
DraTeots opened this issue Apr 29, 2024 · 2 comments
Closed
Assignees
Labels

Comments

@DraTeots
Copy link

This is a question rather than a bug and it relates to #303.

jsroot UI have a navigation between ROOT geometry tree and the resulting three.js objects made by TGeoPainter.mjs build function. Jsroot GUI have it here:

image

Following the screenshot, there are two questions:

  1. If I have ROOT nodes path like /wold_volume/DIRC_0/DircModule_0 how I get it on Object3D
  2. If I have THREE.js object (e.g. obtained by raytracing), how I can I calculate its root geo node path (as above)?

P.S. I saw there are clones in Object3d and clones array where elements have couple of different IDs but they kind of didn't match.

@linev linev self-assigned this Apr 30, 2024
@linev linev added the question label Apr 30, 2024
@linev
Copy link
Member

linev commented Apr 30, 2024

After build() function one gets Object3D with clones assigned to the top element.
It is ClonedNodes class which contains compressed description of geometry - see geobase.mjs

Each end element of Object3D hierarchy has custom stack member which identifies element in clones.
For instance - get full name:

const fullname = clones.getStackName(obj3d.stack);

If you want access original TGeoNode object, one can do:

const info = clones.resolveStack(obj3d.stack);
console.log(`name ${info.name} obj ${info.obj}`);

If I have ROOT nodes path like /wold_volume/DIRC_0/DircModule_0 how I get it on Object3D

One can try to produce stack based by the name:

const stack = clones.findStackByName(fullname);

If it found - one can use it to select Object3D like:

const obj3d = clones.createObject3D(stack, toplevel); // returns last Object3D
const mesh = clones.createObject3D(stack, toplevel, 'mesh'); // returns Mesh instance assigned to Object3D

Be not confused by method name - it only create new instances if object as third argument is specified.

@linev
Copy link
Member

linev commented May 22, 2024

I guess, question was clarified and can be closed

@linev linev closed this as completed May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants