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

Fix: renderOrder of <Svg> meshes #1938

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/core/Svg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ export const Svg: ForwardRefComponent<SvgProps, Object3D> = /* @__PURE__ */ forw
path.userData?.style.fill !== undefined &&
path.userData.style.fill !== 'none' &&
SVGLoader.createShapes(path).map((shape, s) => (
<mesh key={s} {...fillMeshProps}>
<mesh key={s} {...fillMeshProps} renderOrder={s}>
<shapeGeometry args={[shape]} />
<meshBasicMaterial
color={path.userData!.style.fill}
opacity={path.userData!.style.fillOpacity}
transparent={true}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove transparent? It does affect grouping during sorting, but is that any relevant here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my experiments this was the only way i found to avoid the render order issues.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll investigate merging the geometries here. Definitely an issue with sorting, not z-fighting exactly.

side={DoubleSide}
depthWrite={false}
{...fillMaterial}
Expand All @@ -64,11 +63,10 @@ export const Svg: ForwardRefComponent<SvgProps, Object3D> = /* @__PURE__ */ forw
path.userData?.style.stroke !== undefined &&
path.userData.style.stroke !== 'none' &&
path.subPaths.map((_subPath, s) => (
<mesh key={s} geometry={strokeGeometries[p]![s]} {...strokeMeshProps}>
<mesh key={s} geometry={strokeGeometries[p]![s]} {...strokeMeshProps} renderOrder={s}>
<meshBasicMaterial
color={path.userData!.style.stroke}
opacity={path.userData!.style.strokeOpacity}
transparent={true}
side={DoubleSide}
depthWrite={false}
{...strokeMaterial}
Expand Down