Placing dynamic texture on a mesh

Is there a way to place a dynamic Texture on a model?
All examples are about planes, in docs I dont see a parametar for providing the mesh.

Sure can. It’s funny that you ask that because you’re right, seems like all examples from the doc are using just planes. May be something to be added.
Here’s one with just a sphere. You can use dynamicTexture with any shape/mesh (parametric or imported).
It relies on the UVs just like any other texture. Only thing you need to make sure of is the context and the size.

So when I import a model I have to create dynamicTexture and provide that dynamicTexture as value for material for the mesh?
Am I able to add mulitple textures?
By playing in the playground it doesnt place another text.

I think the explanation in the doc is pretty good (despite from lacking that example with a mesh)
First thing is: It is a texture, not a material. You create the texture ‘on the side’ of any material, then you assign this texture to the corresponding channel of your material (diffuse, albedo, emissive…).
A dynamic texture in essence has 3 parameters that are key:
A resolution, A size and A context.
The size and resolution work together to determine at what size/resolution the texture will be used on the mesh. This is quite important because this will determine how the texture will cover your mesh (UVs). If the texture is oversized, it will be cropped. If it is undersized it will cover only part of your mesh/material.
The context is simply ‘a helper’ to generate the texture in the canvas. You don’t really need to worry about it, except for calling ‘getContext’ on your dynamic texture and the rest of the magic will occur :grin: :magic_wand:

Sure, but if it’s not for the same, you need to create a new one (just like any other texture).
Though, you can also drawText (if it is about drawing text), you can drawText on an existing texture.
You can even draw multiple lines of text and then pick just the part you need (and update it on the fly). With a little trick :grin:
But then, you will still need to generate a new texture (if it’s not a replacement)

May be you should start by creating just the base and then share with us. Do you know how to create a playground and import external assets? That would be the easiest way…

Yes, I know. I just wanna make sure that I can do what I am thinking about.
I am not so exprienced with babyon, I worked in three a bit so I dont understand this so clearly, but I am finishing my project and I went into the problem.
I want to add multiple images on the mesh, so I can manipulate with them later. Decal cannot set the face if I dont use pickInfo, which will strech the decal if I just change it’s position with previous face value.
I know that texture is not the same as decal but how can I make the texture look like decal and add more of them to one mesh?
I have this repo, so can understand what I am doing.

But are you adding text or image?
Meanwhile, I gathered this small example of multi-lines for you:

And quickly rushed this example of selecting from the array (press kb ‘F’ to change line of text). Sorry, it’s very rushed from the above PG but might still give an indication on what is possible to do

For the beginning I am just adding images.
I let user import images and then the active one could be placed on the mesh with the click.
Could I make an array of all images that are put on the mesh and put them into texture as you did in first example? So it will be one texture for the whole mesh but with differente images.
How will I be able to put differente position for each image?

Sorry just got your answer. This looks more to me like something to work with masks and NME (or a procedural texture from NME).
So the user would manipulate the images but what is the goal of it? Is it for e-commerce or something ? Do you next need to generate a production file (2D texture)? Or do you only care about the visual representation?

This is e-commerce project for a client.
I have a panel of all images and I have canvas with a mesh.
From the panel you choose image you want and place it on the mesh by click.
Then all images that you placed on the mesh will be displayed in the panel so you can manipulate with them e.g scale, rotate, move X, move Y. When I move decal without changeing it’s face it will strech, so I want to solve that.
My goal is to add image to the mesh where user clicked, display the image on the panel with it’s size, rotate, X and Y. On changing any of these values I am cloning the properties of the decal and adding it to new decal, so the face value is as same as previous.

I want to have that functionality, I would add whatever it takes to finish.

Ok, now I finally get it (sorry I’m a low brain :brain: :grin:)
So I guess it could actually work with decals. But you would need a 2D projection of the decal in your panel and to set translation and rotation. I’m pretty sure I saw a similar topic not so long ago. Would just need to search for it. I will try find it for you and post it here.
Else, I’m not a specialist for that and I guess we now have enough information, so before I give you the wrong advise to choose from a method :wink: :wink: :laughing: let me just call-in one of the experts from the Team (see, I play it safe :sweat_smile:) cc @Evgeni_Popov

Have this repository if you need to see in details what I wrote and the results in react.
Just by moving decal you will see streching and cropping.

1 Like

Yes, just a bit of patience now. :hourglass_flowing_sand: The answer should come to you (most likely :wink:).
Meanwhile, have a great day :sunglasses:

Edit: Found the thread. One would need to check if applicable? :thinking:

This could be one way to do it. Applying UVmap to the model. First I could place decal in the UVMap and take it’s coordinates and just clone it in the model.
Simliar to this:

There are two other threads on the same subject:

(I answered on the last one)

I think you should focus on a single thread, it’s easier for people to understand what you are looking for (as for @mawa here).

Since I didnt know how to move the decal without streching I started looking for other ways how I can achieve the same thing differentaly. I would like to find the way how to move the decal, that video is just in case I dont find the solution.