Add allowParentURIs option to GLTFFileLoader to allow RFC 3986 spec-compliant relative paths

The official glTF 2.0 Specification dictates that asset URIs follow internet standard RFC 3986 Section 6.2.2. While syntax-based normalization (removing .. segments) is strongly recommended (“SHOULD”), passing a non-normalized relative parent path (like "../textures/image.png") remains technically valid under the core specification.

Currently, the GLTFFileLoader aggressively treats the presence of ".." inside a URI string as a hard application failure. While this defensive default is logical for untrusted native environments (Electron, Node, Drop-in Sandboxes), it penalizes enterprise web application developers who run glTF assets in fully controlled, secure same-origin web server configurations with large distributed texture catalogs.

Proposed Solution:
Introduce a boolean configuration flag—allowParentURIs—to the GLTFFileLoader options block.

  • By default, it will remain false to maintain full safety protocols across native hosts.
  • When set to true, the internal string validation bypasses the restrictive ".." error throw, allowing the underlying environment (like the web browser) to natively parse the valid relative network request.

Use Case / Motivation:
Centralized content libraries where a single directory structure serves texture sheets across several localized sub-folders (e.g. ../shared_textures/wood_base.png). Forcing file modifications or forcing structural redesigns limits standard CDN optimization pipelines.

2 Likes

cc @bghgary

I’d like to echo this feature request. For me, the use case is a 3D Tiles dataset with textures shared between millions of glb tiles.

Because the tiles should work with other 3D Tiles clients such as Cesium.js, the preprocessUrlAsync workaround isn’t really an option. So for now, I’ve resorted to hacking out the validation. :confused:

lets ping @bghgary as he might have missed the first message :slight_smile:

Thanks for following up. I’m looking into this and will reply here once I’ve worked through the right API shape.

I opened Allow URL preprocessing to handle parent-relative glTF resources by bghgary · Pull Request #18854 · BabylonJS/Babylon.js · GitHub.

It keeps the current default rejection, but setting preprocessUrlAsync now opts into handling parent-relative URIs. The callback receives the asset’s rootUrl as an optional second argument and runs before the .. check, so a 3D Tiles client may preserve the URL or resolve it with new URL(url, rootUrl).href. Existing one-argument callbacks remain compatible.

3 Likes