I have some TextGeometry
that is supposed to be a 1 to 1 representation of a HTML (h1
) element:
export default class Title {
constructor($el, $scene) {
this.scene = $scene;
this.title = $el.firstElementChild;
this.offset = new THREE.Vector2(0, 0);
const loader = new THREE.FontLoader();
loader.load('/RL-Unno.json', (font) => {
const geometry = new THREE.TextGeometry(this.title.innerHTML, {
font: font,
size: 150,
height: 1
});
geometry.center();
this.init(geometry);
})
}
...
}
As you can see, I already get the text from the html element this.tile
itself. How do I also get it’s size? Currently size
is set to 150, but since that’s not px
whatsoever, I need a way to get the element’s size and adjust the geometry accordingly. How can I do so?
I know of this.title.style.fontSize
, but again, this would return a value calculated in px
, which would not conform to the geometry’s size attribute.