Skip to content

SVGLoader pointsToStroke incorrect result using linecap square #26781

@IRobot1

Description

@IRobot1

Description

When passing a simple 2 point line shape to SVGLoader pointToStroke, when linecap is set to square, the resulting geometry is incorrect.

image

It works correctly when linecap is either butt or round.

Reproduction steps

create a 2 point line shape
getStrokeStyle passing linecap set to 'square'
pass resulting shape and stroke style to pointsToStroke

Code

const shape = new Shape();
  shape.moveTo(-12, 0);
  shape.lineTo(12, 0);

  const style = SVGLoader.getStrokeStyle(
    2,
    "white",
    undefined,
    "square",
    undefined
  );

  const geometry = SVGLoader.pointsToStroke(shape.getPoints(), style);
  const material = new MeshBasicMaterial({ side: DoubleSide });
  const rect = new Mesh(geometry, material);
  scene.add(rect);

Live example

https://codesandbox.io/s/three-stroke-square-test-3yn756

Screenshots

image

Version

156.1

Device

Desktop

Browser

Edge

OS

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions