engine_components
                                
                                 engine_components copied to clipboard
                                
                                    engine_components copied to clipboard
                            
                            
                            
                        Be able to pass a callback function to url
Description 📝
I am using cloudfront to serve the files saved on backend, so I have a base url and a signed part after the file name. https://.cloudfront.net/geometry-1.frag?Policy=&Key-Pair-Id=&Signature= Also, this signed url has an expiration time, that why I believe a callback function give the full flexibility needed for all use cases.
Suggested solution 💡
I suggest to change in fragment-stream-loader.ts the this.url calls, like that:
const groupUrl = await this.url(globalDataFileId);
const fetched = await fetch(await this.url(indexesFile));
To be able to accept also string, it need also a condicional or a function that check that.
Alternative ⛕
No response
Additional context ☝️
No response
Validations ✅
- [X] Read the docs.
- [X] Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.
Hi, my backend requires authorization using an additional header in the fetch method, when I save ".frag" and ".json" files and load the json geometry file I request it like this:
Maybe an above solusion would be good for me too, alternatively I suggest to add an authorization header to the StreamLoader’s settings:  "loader.authorizationHeader" (like the “loader.url")
Solved from version @thatopen/[email protected] and @thatopen/[email protected]. I'm publishing later today.
Now you can specify a custom loading function like this:
import * as FRAGS from "@thatopen/fragments";
// To fetch properties
FRAGS.FragmentsGroup.fetch = (url: string) => {
   // Your logic....
   return result as Promise<Response>;
}
// To fetch geometries and other files
ifcStreamer.fetch = (url: string) => {
   // Your logic....
   return result as Promise<Response>;
}
Let me know if this doesn't work!