Skip to content

SVGLoader pointsToStroke incorrect UV mapping when texture applied #27464

@IRobot1

Description

@IRobot1

Description

This problem isn't new. It's been around for a long time.

When adding a texture to the stroke generated by SVGLoader.pointsToStroke, the resulting UV mapping is incorrect for straight parts and the last triangle.

The UV mapping for a Bezier curve look really good except at the end
image

The UV mapping for a straight line doesn't look good at all
image

The UV mapping for a curved lines looks good for the bends, but not for the straight lines
image

Reproduction steps

set stroke style
pass points into SVGLoader.pointsToStroke to get geometry
assign texture to material
add mesh to scene

Code

const style = SVGLoader.getStrokeStyle(0.12, "black", "miter", "butt");

const texture = new TextureLoader().load("./src/road.png");

  const geometry = SVGLoader.pointsToStroke(
    straightpoints.map((v) => new Vector2(v.x, v.y)),
    style
  );
  const material = new MeshBasicMaterial({ map: texture });
  const rect = new Mesh(geometry, material);
  scene.add(rect);
  rect.position.x = 0.2;

Live example

https://codesandbox.io/p/sandbox/three-stroke-texture-uv-h9w76x?file=%2Fsrc%2Findex.js

Screenshots

image

image

image

Version

160

Device

Desktop

Browser

Edge

OS

Windows

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions