Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVGLoader pointsToStroke incorrect results when linejoin set to bevel #26784

Closed
IRobot1 opened this issue Sep 17, 2023 · 2 comments · Fixed by #27121
Closed

SVGLoader pointsToStroke incorrect results when linejoin set to bevel #26784

IRobot1 opened this issue Sep 17, 2023 · 2 comments · Fixed by #27121

Comments

@IRobot1
Copy link

IRobot1 commented Sep 17, 2023

Description

When passing a simple 3 point shape to SVGLoader pointToStroke, when linejoin is set to bevel, the resulting geometry is incorrect.

image

It works correctly when line join is set to miter or round

Two clues that might help

  1. If I use positive y values, it renders correctly
  shape.moveTo(-4, 4);
  shape.lineTo(0, 0);
  shape.lineTo(4, 4);
  1. If I make the material DoubleSided it renders correctly

Reproduction steps

create a 3 point line shape
getStrokeStyle passing linejoin set to 'bevek'
pass resulting shape and stroke style to pointsToStroke
render the resulting geometry to a mesh

Code

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

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

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

Live example

https://codesandbox.io/s/three-linejoin-bevel-test-4t7ppp

Screenshots

image

Version

156.1

Device

Desktop

Browser

Edge

OS

Windows

@IRobot1
Copy link
Author

IRobot1 commented Sep 17, 2023

When I rotate the scene (using orbit), the missing triangles are facing backwards. So likely the normal is just wrong or not being calculated.

@WestLangley
Copy link
Collaborator

When I rotate the scene (using orbit), the missing triangles are facing backwards.

That is a winding order issue, not a normals issue. Try

  material.side = DoubleSide;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants