Language issue
How do I write in a language other than English? For example, Chinese?
The built-in text component and <a-text> primitive uses so-called (M)SDF fonts. These need to be generated with all the characters you plan to use. The default font only supports ASCII characters, so for characters from other writing systems, you'll have to generate your own font. See the following documentation page for details: https://aframe.io/docs/1.6.0/components/text.html#non-ascii-characters
Alternatively you can use the aframe-troika-text library. It uses Troika's text renderer under the hood, which can generate the font on the fly.
Should troika be A-Frame default?
maybe something like https://github.com/foxglove/three-text with @mapbox/tiny-sdf could be a first step
For my own projects I exclusively use Troika, mostly out of convenience but also because it builds nicely on top of the Three.js material system. I think making it the default in A-Frame isn't a bad idea, I'll try and experiment with it and create a PR.
What are the downsides from switching to Troika?
The only downside i can think of, is if aframe switching to WebGPURenderer (webgl2, webgpu) with TLS more glsl shader code needs to port to TSL, but what i read @lojjic have plans to support TLS ( correct me if i am wrong)
Yes TSL support is planned, but no concrete timeframe yet. It would bump up in priority if there were a significant number of people or projects asking for it. 😅
The other downside I can think of is that it's asynchronous, and runs in a worker by default. That could complicate things that expect to be able to use metrics of the text in a synchronous way -- e.g. scaling a background plane to match the text dimensions.
I hadn't even considered TSL in A-Frame, but that integration would encourage me to learn TSL and give me better grounds to advocate for it in the office.
I'd love to see troika as default (I'm all in on it), so it gets tested with aframe changes - I noticed that the troika aframe component does not work and throws this error on the aframe master branch:
troika-three-utils.esm.js:22 Uncaught TypeError: Cannot read properties of undefined (reading 'replace') at b (troika-three-utils.esm.js:22:17)
see https://glitch.com/edit/#!/gusty-childlike-durian
@lojjic I was going to post this as an issue on your github, but wasn't sure about the propriety of posting bugs that only appear on the master branch...
@mrxz switching to troika is still something we want to do?
@mrxz switching to troika is still something we want to do?
I do believe there are still many upsides to switching. But doing so in a backwards compatible turns out to be quite tricky, not to mention that there is no way to support MSDF fonts people have already generated.
For those interested, here's my WIP changes so far: https://github.com/aframevr/aframe/compare/master...mrxz:aframe:troika-text
@mrxz we can add a new text component and a deprecation message for the old one that we will remove in 1.8.0
@dmarcos That isn't a bad idea, the old component could also be moved into a separate repo (probably under c-frame) in case people still want to use it beyond 1.7.0. Though what would be a good name for the new component? Hard to beat text/<a-text> in terms of simplicity and clarity. 🤔
@mrxz We can also rip the band-aid and replace text with troika and put a console message "Text component has been replaced... link to migration info"
Yes I would also prefer we keep the text component name for the new implementation and make the breaking change only once. From your earlier comments @dmarcos it seemed you wanted to introduce the new component with a new name like maybe newtext, text2 and maybe later in 1.8.0 rename again to just text? Not good, it would mean I would need to change my projects twice.
The warning should only show if you use the text component in a way that is not supported by the new implementation, like using a custom font.
We could rename the existing one to text-legacy (similar to gltf-model-legacy, collada-model-legacy we have in aframe-extras) and keep it in the repo in the 1.7.0 release and just remove it in 1.8.0. If someone really need it, we'll recreate it in c-frame organization.
I’m fine with a single “text” component that detects old usage and throws a message in console for the dev to adjust
@mrxz troika for 1.7.0? yes, no?
@mrxz troika for 1.7.0? yes, no?
@dmarcos I don't really have the time to work on it now, so not for 1.7.0, I'm afraid. It might be for the better as well, since then we can do the replacement on master and really iron out the bugs before the next release.