oguzeroglu / TextureMerger

A lightweight library that creates a Texture Atlas from Three.js textures
MIT License
85 stars 8 forks source link

Merge textures from loaded models #4

Open antoinemacia opened 2 years ago

antoinemacia commented 2 years ago

Hello!

I would love to use this library to optimise our platform, though testing this on gltf models loaded in THREE, it seems the uv mapping is all over the place (Im using the code from the example, so via replacing uv rather than via the shader)

Screen Shot 2022-05-26 at 6 44 41 pm

Source file: out20211113-51-1jy7lkz-v1.glb.zip

I believe the UV coordinates range for the source object is not normalised (far lower than -1 and far greater than 1), and the UV range Im getting after running the lib is something like

{ startU: 0, endU: 1, startV:1, endV: 0} 

Does this seem right to you? Also, would you have a way to handle arbitrary UV coordinates range?

antoinemacia commented 2 years ago

After further inestigation, the uv on the origin model seem right, but somehow the UV get modified when assigning the texture generated by the canvas

I must say the texture produced by the canvas looks fine, and rather similar to the original texture, yet it seems the UV is incorrect, without even running any code on them..

Original texture

Canvas generated texture

Screen Shot 2022-05-27 at 3 32 10 pm Screen Shot 2022-05-27 at 3 31 30 pm