jonobr1 / two.js

A renderer agnostic two-dimensional drawing api for the web.
https://two.js.org
MIT License
8.29k stars 454 forks source link

[Enhancement] Use URL API for Making Textures' Sources Absolute Paths #670

Open jonobr1 opened 1 year ago

jonobr1 commented 1 year ago

Is your feature request related to a problem? Please describe. Two.js creates a texture registry so that multiple image elements aren't created for the same asset. To point to canonical versions of an image Two.js creates and stores a private <a /> tag and sets the href attribute to a given texture. The default browser behavior is to expand a resource's path from relative to absolute.

This works in the browser, but not in headless environments

Describe the solution you'd like Use the URL API instead of <a /> tags and look to see if Two.js is loaded in a browser or headless environment to expand URLs (in the case of browser) or not (in the case of headless).

This issue is based on the conversation from this issue: https://github.com/jonobr1/two.js/issues/668