Creoox / creoox-ifc2gltfcxconverter

Public repository of Creoox & XeoKit convertion Tool
Other
14 stars 2 forks source link

glTF scene nodes should not all have 'name' attributes #12

Closed xeolabs closed 5 months ago

xeolabs commented 5 months ago

When convert2xkt parses the scene hierarchy within the glTF, at each node, it expects a name attribute only if that node represents an IFC element.

ifc2gltf 3.0 appears to be putting a name on every node in the hierarchy. This confuses convert2xkt, which creates within the XKT a single object for the root node.

For example, in the "wefly" IFC model (attached to this issue), ifc2gltf creates a hierarchy like below (some elements removed for clarity).

We have a root node with name "Z_UP" and convert2xkt only creates a single object for that, which gets the all the geometries belonging to the meshes belonging to all it's child nodes.

Can we make it so that only those nodes that correspond to IFC elements get a name?

{

  "nodes": [
    {
      "mesh": 0,
      "name": "0RDVTmkVv60xF$yp_gU2jx:1"
    },
    {
      "name": "0RDVTmkVv60xF$yp_gU2jx",
      "children": [
        0
      ]
    },
    {
      "mesh": 1,
      "name": "1$tmFYRHz19vYLD1Ei_BQt:1"
    },
    {
      "name": "1$tmFYRHz19vYLD1Ei_BQt",
      "children": [
        2
      ]
    },
    {
      "name": "2$GsIqF25CuxDwFY5eDaza",
      "children": [
        1,
        3
      ]
    },
    {
      "name": "2HFT1tPaLB7PX1UrR6FImw",
      "children": [
        4
      ]
    },
    {
      "name": "0oh7FXRJLF8u5Kh$VQeOvS",
      "children": [
        5
      ]
    },
    {
      "name": "3YCEIliHvChPu6tL0DJsgj",
      "children": [
        6
      ]
    },
    {
      "matrix": [
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        -1.0,
        0.0,
        0.0,
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        1.0
      ],
      "name": "Z_UP",
      "children": [
        7
      ]
    }
  ],
  "scene": 0,
  "scenes": [
    {
      "nodes": [
        8
      ]
    }
  ],
  "buffers": [
    {
      "byteLength": 1668,
      "uri": "model.bin"
    }
  ]
}
ifcapps commented 5 months ago

Ok, removed name attribute for sub-items. Only IfcElement derived nodes have a name attribute in latest version 3.2

xeolabs commented 5 months ago

I'm still getting the name on the root node - see "Z_UP" on the root in the snippet below

  "nodes": [
    {
      "mesh": 0
    },
    {
      "matrix": [
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        1.0,
        0.0,
        0.12535130977630804,
        2.517587661743163,
        -0.47145077586174,
        1.0
      ],
      "mesh": 1
    },
    {
      "mesh": 2
    },
    {
      "name": "0RDVTmkVv60xF$yp_gU2jx",
      "children": [
        0,
        1,
        2
      ]
    },
    {
      "mesh": 3
    },
    {
      "name": "1$tmFYRHz19vYLD1Ei_BQt",
      "children": [
        4
      ]
    },
    {
      "name": "2$GsIqF25CuxDwFY5eDaza",
      "children": [
        3,
        5
      ]
    },
    {
      "name": "2HFT1tPaLB7PX1UrR6FImw",
      "children": [
        6
      ]
    },
    {
      "name": "0oh7FXRJLF8u5Kh$VQeOvS",
      "children": [
        7
      ]
    },
    {
      "name": "3YCEIliHvChPu6tL0DJsgj",
      "children": [
        8
      ]
    },
    {
      "matrix": [
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        -1.0,
        0.0,
        0.0,
        1.0,
        0.0,
        0.0,
        0.0,
        0.0,
        0.0,
        1.0
      ],
      "name": "Z_UP",
      "children": [
        9
      ]
    }
  ],
  "scene": 0,
  "scenes": [
    {
      "nodes": [
        10
      ]
    }
  ],
ifcapps commented 5 months ago

"Z_UP" should be removed too? I thought that one remains

xeolabs commented 5 months ago

If you were to always have a name on the root node, to indicate something like "Z_UP" or "Y_UP", then I could make convert2xkt always expect that root name as a special case.

Are we using that root name as such a special case? I lose track..

ifcapps commented 5 months ago

I don't really need it. I can just remove it, better not to have too many special cases in the code :)

xeolabs commented 5 months ago

Yip go for it. IMO if we need to know the coordinate frame (Z/Y up) then it should be in the metadata anyway.

ifcapps commented 5 months ago

Ok, I removed the name "Z_UP" with latest release