简体   繁体   中英

JS React GLTF loader query parameters

I have the .gltf and .bin files in a azure storage account. Downloading these files requires a SAS URI that follows the pattern: https://<saName>.blob.core.windows.net/<pathToBlob>?<sas> . While I build a SAS that is valid for downloading both the .gltf and .bin files, I am running into an issue where I specify the .gltf URL to the useGLTF hook. That call goes through, but when fetching the .bin file, under the hood the loader is dropping the query params, resulting in a URL https://<saName>.blob.core.windows.net/<pathToBin> which fails.

Is there a way to make the loader keep the query parameters?

For anyone running into this, you can use the setURLModifier() . In my case, this looks as:

    const { scene, animations } = useGLTF(props.path, false, false, (loader) => {
        loader.manager.setURLModifier((url) => {
            # alter the URL and return the new value
            return url;
        })
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM