Closed ThisIsMonta closed 2 months ago
Related to #222. Probably both issues can be solved at the same time. Duplicate from https://github.com/ThatOpen/engine_fragment/issues/18.
We've implemented fragment cloning (and it can also be used to create fragment subsets).
It's available from @thatopen/components@2.1.17
and @thatopen/fragments@2.1.6
. By modifying the IFCLoader tutorial code 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 classifier = components.get(OBC.Classifier);
classifier.byEntity(model);
const found = classifier.find({
entities: ["IFCWALLSTANDARDCASE", "IFCSLAB"],
});
const clone = fragments.clone(model, found);
world.scene.three.add(clone);
window.addEventListener("keydown", (e) => {
clone.position.x += 1;
});
const map = clone.getFragmentMap([186]);
const hider = components.get(OBC.Hider);
hider.set(false, map);
}
I get this:
https://github.com/user-attachments/assets/8fc61ff2-d9b3-4c85-aaa7-eef65ffa3de7
Describe the bug 📝
Trying to clone a model but got an error :
Reproduction ▶️
No response
Steps to reproduce 🔢
No response
System Info 💻
Used Package Manager 📦
npm
Error Trace/Logs 📃
No response
Validations ✅