Ruby API: position_material — align UV between horizontal top and rotated vertical group at oblique corner

Hello SketchUp community,

I’m developing a Ruby plugin for kitchen cabinet layouts. I have a challenging UV texture alignment problem and hope someone can help.


The Setup:

  • A horizontal countertop group (pianoTopOrizz) that forms an L-shape at each corner. Texture is applied using position_material with 2 points: anchor at the front corner apex + direction U along the main cabinet run.

  • Separate vertical tile panel groups (pianoTileVerticale) positioned against the wall, one per side of the corner. These are created in a group that may have a non-trivial rotation transform when the corner has a deviation angle ≠ 0.

  • Tile size: 10×10 cm, texture bitmap: 50×50 cm (5×5 tiles), set with mat.texture.size = [50.cm, 50.cm].


The Problem:

  • Corner deviation = 0° (perfect right angle): UV alignment between top and vertical panels is perfect :white_check_mark: — grout lines continue seamlessly from horizontal to vertical.

  • Corner deviation ≠ 0° (e.g., 8° or 12°): the vertical panel’s texture becomes misaligned with the top :cross_mark:.

I’ve tried several approaches:

Approach 1 — 1 point (default orientation)

p0_local = anchor_world.transform(group.transformation.inverse)
p0_f = p0_local.project_to_plane(face.plane)
face.position_material(mat, [p0_f, Geom::Point3d.new(0,0,0)], true)

The default orientation is parallel to the group’s local axes, which differs from the oblique top direction by the corner angle → visible offset = depth × sin(angle) mod tile_size (e.g., 65 × sin(12°) mod 10 ≈ 3 cm).

Approach 2 — 2 points, direction U from top (world space vector):

v_u_world = (second_pt - anchor_pt).normalize # same direction as top’s U
v_u_local = v_u_world.transform(group.transformation.inverse)
v_u_local.z = 0; v_u_local.normalize!
p1_f = p0_f.offset(v_u_local, 50.cm)
face.position_material(mat, [p0_f, Geom::Point3d.new(0,0,0),
p1_f, Geom::Point3d.new(1,0,0)], true)

Better alignment, but tiles appear distorted (very small, ~5×5 cm) when the group has a rotation transform. I suspect the world->local vector transformation is incorrect or the projection onto the face plane is wrong.


My Questions:

  1. With position_material(..., true) (local coordinates), should direction vectors be fully transformed into the group’s local coordinate system, or does SketchUp handle the group transform internally?

  2. For a vertical face inside a group with a rotation transform, what is the correct procedure to project a world-space direction vector onto the face plane so the texture scale is preserved (50×50 cm)?

  3. Is there a standard/recommended technique in Ruby for aligning UV between an adjacent horizontal surface (top) and vertical surfaces (backsplash) when one group has a non-trivial rotation?


Reference images:

The images show a kitchen with two non-90° corners (left: 8°, right: 12°). Letters A–L and numbers 1–9 mark the grout line reference points where horizontal top and vertical panels should align.

  • V1: Full overview — left corner (8°) with labels A–L, right corner (12°) with labels 1–9

  • V2: Zoom — left corner 8°, points A–L show expected alignment locations

  • V3: Zoom — right corner 12°, points 1–9 show same expected alignment

Thank you very much for any guidance!