node.jsbackendhttp-live-streamingifcbim

BIM tiles backend handle


as working with ifc.js Components using Fragment IFC Streaming I had an issue handling files in backend I need to know which files I need to put in backend to have it streaming ?

`let filestream = fs.createReadStream(__dirname + '/small.ifc-processed.json');

app.get('/small.ifc-processed-global', (req, res) => {

filestream.pipe(res); })


Solution

  • after checking the source code, I could see that the FragmentIfcStreamer loader is asking to fetch a fragment file from a url (your backend).

    const groupUrl = this.url + globalDataFileId;
        const groupData = await fetch(groupUrl);
    

    https://github.com/ThatOpen/engine_components/blob/main/src/fragments/FragmentIfcStreamer/src/fragment-stream-loader.ts#L144-L149

    Thus you can set a url that points to your .frag file to load the geometries. Check this sample how do I managed to load geometries directly from the front-end:

    const loader = new OBC.FragmentStreamLoader(
      components
    );
    loader.url = "/fragments/"; //path inside my public folder in my frontend
    
    const rawGeometryData = await fetch(
      "/tiles/mymodelBIMtiles.ifc-global.json"
    );//path inside my public folder in my frontend
    
    const geometryData =
      await rawGeometryData.json();
    await loader.load(
      geometryData,
      true,
      undefined
    );
    

    and your json bim tiles should have the name of your fragment under the globalDataFileId property:

      ...
      "globalDataFileId": "mymodel.frag"
    }
    

    This way the IFCstreamer will fetch from the given url and the fragment file name, like this:

    await fetch("/fragments/mymodel.frag")
    

    this is my public folder structure by the way

    enter image description here

    Hope this was helpful and it serve as reference when reading the properties.