"geo.attributes.position is undefined" when selecting in multiple objects
See original GitHub issueI’m representing multiple objects in the same ifc loader in React. As I have the models in different urls the code for loading them is something like this:
ifcModels=[]
layers.forEach((layer)=>{
const url = layer.url_ifc
let center = {}
loader.load(
url,
(object) => {
scene.add(object);
ifcModels.push(object)
const box = new Box3().setFromObject(object);
center = box.getCenter(new Vector3());
const size = box.getSize(new Vector3()).length();
const r = size//Math.sqrt(3)*size/2;
const theta = 0;
const phi = 0;
const camara_x = r * Math.cos(phi) * Math.sin(theta)+center.x;
const camara_y = r * Math.sin(phi) * Math.sin(theta)+center.y;
const camara_z = r * Math.cos(theta)+center.z;
camera.position.x = camara_x;
camera.position.y = camara_y;
camera.position.z = camara_z;
scene.add(object);
}
);
})
This is working fine; however, I also want to highlight the subsets following the tutorial here: https://ifcjs.github.io/info/docs/Guide/web-ifc-three/Tutorials/Highlighting. With just one model it’s working fine, but with two I can only select subsets from one model, when I try to select the second one I have the warning in ifc.createSubset. Even if I select this latter model first I get the same error.
Unhandled Rejection (TypeError): geo.attributes.position is undefined
Unhandled Rejection (TypeError): geo.attributes.position is undefined
highlight
src/components/modelos/Detalles_ifc.js:343
340 | const id = await ifc.getExpressId(geometry, index);
341 |
342 | // Creates subset
> 343 | ifc.createSubset({
| ^ 344 | modelID: object.id,
345 | ids: [id],
346 | material: material,
I tried with useRef as sugested here: https://github.com/IFCjs/web-ifc-three/issues/87 but I get the same error.
UPDATE!!
I looked around ICFLoader.js and I saw this.state.models only contains the last model loaded, therefore, I guess when it tries to find the position of the subset in the second model it’s undefined.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
I’ve been able to work around the issues I was having as suggested in #83 (see also #126)
Ah, you’re right, you can load multiple IFC’s in that example. I assumed it was just replacing the IFC every time you select a new one. Okay cool it seems to work, I’ll check it out and try to adapt my code this way, cheers!