I’m aware that we can fit a texture canvas to fit a mesh (Use TextureCanvas to fit texture to mesh) but what about the other way round?
What I am trying to do is create mini-3D scenes that would teach a subject, so each scene would have a heading and optional description, then the scene itself would demonstrate something - Like a 3D model.
The problem is that for each of the pieces of text (DynamicTextures) I create a Plane and specify the width and height. Some of the descriptions might be long and I use trial and error to set the plane to the right size.
The Canvas2D has a measureText function, I don’t think this will do what I need and it doesn’t accept a font as a parameter.
Would it be possible to measure the text rendered onto the canvas and return the correct size the plane needs to be?
Here’s a playground I created, the text doesn’t quite fit and I will need to change the size of the plane.
ps. Also on my Playground I am using CustomMaterial to do the transparentcy (a little trick I found), but on my local machine I am using the npm module and ‘CustomMaterial cannot be found’, when I search in
babylon.module.d.ts I cannot find CustomMaterial. How do I import it?