How to go back and forth between Object3D nodes and ROOT Geometry nodes?
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:
Following the screenshot, there are two questions:
- If I have ROOT nodes path like
/wold_volume/DIRC_0/DircModule_0how I get it on Object3D - 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.
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.
I guess, question was clarified and can be closed