Terminator Posted August 7, 2016 Share Posted August 7, 2016 Hello, is there an easy way to draw text on an object? I was working on a project and I needed to attach different texts on certain objects, so what I did is that I transformed the text into images and I added the image as a texture (which is not the best solution, since I may have a lot of texts, so if I used this approach I will end with a lot of images). so my questions is, is there a ways to draw texts on a 3D object using the code without assuming that each text is an image? Quote Link to comment Share on other sites More sharing options...
jerome Posted August 8, 2016 Share Posted August 8, 2016 yep, two approaches : - the dynamic texture : http://doc.babylonjs.com/classes/2.4/DynamicTexture (there's a tuto, but I can't find it back) - the canvas2D : http://doc.babylonjs.com/overviews/Canvas2D_Text2D Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 8, 2016 Share Posted August 8, 2016 3:) shaders Quote Link to comment Share on other sites More sharing options...
jerome Posted August 8, 2016 Share Posted August 8, 2016 yep, you're right : shaders too and of course, the easy method : mesh.drawTextOnSurface("hello Word"); ooops, sorry, it doesn"t exist yet Nabroski 1 Quote Link to comment Share on other sites More sharing options...
Terminator Posted August 13, 2016 Author Share Posted August 13, 2016 @jerome thanks for the links, I checked the link about canvas2D, then I saw the example: http://babylonjs-playground.com/#1ONKPJ#5 but there is no 3D objects there, do you know how I can draw the text on a cube for example? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 15, 2016 Share Posted August 15, 2016 Here is an example of dynamicTexture line (64): http://www.babylonjs-playground.com/#1023O#30 Even better, using Canvas2D with a mesh: http://babylonjs-playground.com/#EPFQG#4 Quote Link to comment Share on other sites More sharing options...
dbawel Posted August 16, 2016 Share Posted August 16, 2016 As @Deltakosh posted, a dynamic texture is the best method in my opinion. Simply create a dynamic Texture and apply it to the ambient, emmissive, or other channel of your material. A dynamicTexture will also provide you with additional options and functionality which are unique in WebGL. DB Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.