Colorizing objects with IfcGUID
How can I set a color inside components based on IfcGUID of an element? The purpose is to correct colors inside the project or set a new color to a specific object. Is there any way to do that?
Thanks in advance for the help!
I have the same problem, can anyone help us?
I might need this feature too. Keep you posted if I come up with something
@lanjoni would you mind posting this thread in stackoverflow? I would be more than happy to provide an answer there!
This is a duplicate of #262. The latest version of the API allows to work with IFC GlobalIds and to colorize fragments easily. For instance, to colorize a specific item given its GlobalID, I can modify the load function from the IFCLoader tutorial like this:
async function loadIfc() {
const file = await fetch(
"https://thatopen.github.io/engine_components/resources/small.ifc",
);
const data = await file.arrayBuffer();
const buffer = new Uint8Array(data);
const model = await fragmentIfcLoader.load(buffer);
model.name = "example";
world.scene.three.add(model);
const globalID = "2idC0G3ezCdhA9WVjWe$4F";
const expressID = model.globalToExpressIDs.get(globalID);
const red = new THREE.Color(1, 0, 0);
if (expressID !== undefined) {
const map = model.getFragmentMap([expressID]);
for (const fragID in map) {
const fragment = fragments.list.get(fragID);
if (!fragment) continue;
const ids = map[fragID];
fragment.setColor(red, ids);
}
}
}
And I get this result:
https://github.com/ThatOpen/engine_components/assets/56475338/086cd145-d8f2-4ab0-9bc0-70479347cdd9