Hi all, this is my first post. I’m just starting to learn three.js and JS (I’ve been coding C# in Unity for 10 years). I have a project coming up that’s going to have a lot of text objects in the 3D space so I’m trying out troika-three-text to see if it’ll work for my needs.
So far so good, I can easily create text in my scene… Now I’d like to preload the font using the method provided by the maker but I can’t figure out how to reference the font after it has been loaded. Here’s what I’ve tried so far. Thanks for any help/guidance on this. -t
import { Text } from 'troika-three-text';
import { preloadFont } from 'troika-three-text';
preloadFont(
{
font: 'https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxM.woff',
characters: 'abcdefghijklmnopqrstuvwxyz',
},
() => {
console.log('preload font complete');
},
);
// then later after I know the font has been loaded...
function createText() {
const myText = new Text();
myText.text = 'hello!!';
myText.font = // ???? how do reference the preloaded font?
myText.sync();
return myText;
}
export { createText };