Hi,
we are trying to upload image texture and apply to the mesh, am trying to add UI control to upload image.
i checked this link its working out.
I tried this approach but no luck
can somebody look into this
Thanks
vijay
Hi,
we are trying to upload image texture and apply to the mesh, am trying to add UI control to upload image.
i checked this link its working out.
I tried this approach but no luck
can somebody look into this
Thanks
vijay
You were trying to change the texture of the material of the mesh named āWolf3D_Outfit_Top.005ā.
This mesh doesnāt exist in your model.
Also, there is no sense in assigning any material to the root mesh newMeshes[0]
.
Here is the example with changing texture - https://playground.babylonjs.com/#JHRF6T#452
Please note that the shirt consists of several meshes, so youāll need to change texture for all of them.
@labris am looking for UI control Button to upload image from the sys, then append the image to the mesh.
Here you are - https://playground.babylonjs.com/#JHRF6T#453
@labris
am looking this kind of feature to upload image with dialog box for selecting the image
What is preventing you from using usual HTML in this case? All the mechanics is already in PG, one needs just to add file input, the same way like it is done in Sandbox.
I suppose you are looking for an example, are you? I found this one (below) from a recent post.
You would just need to add all actions TbD after file load to assign it to your texture/material.
Hope this helps,
Thanks @mawa almost thereā¦
using theFile object trying to get the file path so that i can pass to shirtTexture object
const shirtTexture = new BABYLON.Texture(āhttps://fashion-desings.s3.ap-south-1.amazonaws.com/common/casuals/tshirts/userchoice/blue_color.PNGā, scene);
to get file path tried using Window.URL.createObjectURL(theFile); but its not working out
Hi,
Hope you are well. Iām really not a specialist of this. I guess there must be other methods.
I also rushed this PG, It might require some ācleaningā especially for the refreshing of the DOM container/input which seems a bit buggy. Iām sorry, I donāt have too much time this morning but this part shouldnāt be all too hard to fix.
As for your issue, the essential part to understand is that when you are uploading a āFileā as an input, it actually creates a blob. Problem is a new texture requires a path/URL. So in order to get this url and pass it on to your texture, youāre gonna need two lines of code.
I have also added an id to the element. It can eventually help if you need to dispose of it or stuff. I have added some console.log just for your understanding of what data is called.
I hope this helps a little and meanwhile, have a great day
Edit: Sorry, just edited the link. Was missing the part of assigning user texture to material. Click on your button to apply loaded texture.
Thanks @mawa its done
fine tuned slightlyā¦
@Mawa one small helpā¦
With our existing logic we are using two buttons like āchoose fileā and āuploadā to upload images.
Now we want to use single button(green color) to upload images, Now i changed the logic accordingly.
Seems unless there is event handler we cannot upload imageā¦ Any workaround for this
pls suggest
Thanks
vij
Sorry, I donāt have time today and then, as I said, Iām no specialist of that.
Looks like you are willing to use the BJS gui to import the file. I donāt know if and how you can import directly in the canvas using the BJS GUI only. I suppose so but would need to investigate. May be better to try ask someone more knowledgeable than me for that. @carolhmj
Iām sorry but today and tomorrow will be a bit complicated for me so I will have to let the others enlighten you this. Meanwhile, have a great day
You can do it like this: