Imported geometry scaling + mapping issue

blender
geometry

#1

Hello all,

Together with my cousin (I’m dealing with 3D geometry, his scope is programing side of it) we’re working on a bigger project - let’s say adaptive geometry configurator.

We’ve come across some issues we’re unable to solve. It concerns geometry’s modification and wrong mapping output we get. I’ve read multiple threads and haven’t come across any sollution (but I might be wrong).

Basically, we’ve got our geometry, UV premapped and converted from Blender to glTF format. What we need to do is in order to adjust dimensions of the object, instead of scaling, take array of vertexes at one end and move it along for instance X axis. It works nice based on:

obj.geometry.vertices[idx].x = new_x;

But after this operation of course we get our native Blender mapping distorted. And here comes the question:
Is there any way we could within three.js set up some kind of overall mapping for imported and then adjusted geometry (it might be as simple as box/cube mapping), so that after vertex movement the mapping could be reapplied and thus save native texture proportions?

Hope it’s quite clear, if not, I’ll elaborate on it and incluse some explanatory picts.

All the best
Maciej


#2

Yes there are ways to manually transform and manipulate UVs on a geometry in threejs.
If you are working with a non-buffer geometry, look at the geometry.faceVetexUVs.
But there are no built-in functions to do UV mapping nor perform UV automation over a loaded geometry.

For example, in blender you may have UV tools like cube-projection etc which creates UVs for your geometry.
But such tools do not exist in Threejs unless you write one yourself or find some third party libraries.

As for moving vertices and updating UVs.
When you move specific vertex on a geometry, you will get distortion. To correct distortion, you’ll have to somehow be able to locate and update the “correct” UVs that corresponds with the moved vertices, otherwise you’ll get that distortion as you have described.

Depending on the complexity of your geometry and the way how it was UV map, this may be no simple task. You’ll need full understanding of the default overall UV layout and orientation and also may require strategic mapping to ease the process for dynamic runtime updates once you start moving your vertices.


#3

Thanks a lot for the input. My cousin’s already “fighting” with the issue following your suggestions. We’ll see how it works under the time pressure :slight_smile:

Again, thank you!