question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"geo.attributes.position is undefined" when selecting in multiple objects

See original GitHub issue

I’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:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
mysterybearcommented, Oct 3, 2022

I’ve been able to work around the issues I was having as suggested in #83 (see also #126)

0reactions
mysterybearcommented, Sep 30, 2022

Web-ifc-viewer is just a wrapper around web-ifc-three thinking In the example I mentioned I’m able to load multiple IFC files and highlight them all without seeing any error. Maybe you can put together a minimal example I can reproduce?

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best way to get vertices of a mesh three.js - Stack Overflow
I think you're getting tripped-up by some semantics regarding three.js objects. 1) A Mesh does not have vertices. A Mesh contains references ...
Read more >
TypeError: this.attributes.position is undefined · Issue #7304
I am trying to convert the code that had loads of sprites to THREE.Points, and they had positions re-set on every render as...
Read more >
DragControls: Cannot read property 'y' of undefined - Questions
Working with a proven example - after dragging a cube - getting this error when trying to log the position.y value of an...
Read more >
Class: Point - Highcharts API
SVGElement>|undefined. Array for multiple SVG graphics representing the point in the chart. Only used in cases where the point can not be represented...
Read more >
Geometry - Cesium Documentation
Attributes, which make up the geometry's vertices. Each property in this object corresponds to a GeometryAttribute containing the attribute's data. Attributes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found