How can get xaxis of uv in world?

The direction obtained may be incorrect in some cases.
The texture directions of the two faces are consistent, but the calculated vectors differ by 90 degrees.
I got the same result using method one on the last two faces, and the same result using method two on the first two faces.

tets.skp (134.3 KB)


Sketchup.active_model.selection.each do |f|
  pts = f.uv_tile_at(f.vertices[0].position, true)
  uv_x_in_model = pts[2] - pts[0]
  puts uv_x_in_model.normalize


def get_texture_rotation(face)
  return nil unless face.material && face.get_UVHelper(true, true, Sketchup.create_texture_writer)

  uv_helper = face.get_UVHelper(true, true, Sketchup.create_texture_writer)
  points =

  uvq1 = uv_helper.get_front_UVQ(points[0])
  uvq2 = uv_helper.get_front_UVQ(points[1])
  vec = uvq2 - uvq1
  angle = vec.angle_between(X_AXIS)
  angle = -angle if (vec * X_AXIS).samedirection?(Z_AXIS)
  tr = Geom::Transformation.rotation(ORIGIN, face.normal, angle)
  vec = points[1] - points[0]

Sketchup.active_model.selection.each do |f|
  puts get_texture_rotation(f)

Please, do not call me out explicitly on topics. (I find it rude.)

If I have expertise and the time, I will answer. If not, I will not.
Basically, I do not profess to be an expert on texture mapping.

So, I’ll let someone else who knows give an answer.


Unable to obtain the correct X-axis for UV coordinates. · Issue #979 · SketchUp/api-issue-tracker (

1 Like