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 Path decoding Bug & Fix #21693

Closed
ghost opened this issue Apr 21, 2021 · 1 comment
Closed

SVGLoader Path decoding Bug & Fix #21693

ghost opened this issue Apr 21, 2021 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 21, 2021

SVGLoader bug: parseFloats() ~ line 893

When a command in d has an exponent Eg: "15 -1.1368683772161603e-13"
It gets decoded by the first parseFloats() regex as:
[ "15", "-1.1368683772161603e", "-13"] and not
[ "15", "-1.1368683772161603e-13"]

Which leads to the second arg being set to -1.13... instead of something closer to 0.

FIX: I've changed the line
var array = string.split( /[\s,]+|(?=\s?[+-])/ );
to
var array = string.split( /[\s,]+|(?=\s?(?<![eE])[+-])/ )

Which adds a lookback to [+-] and won't match if either is preceeded by 'e|E'.

It seems to work for me.

@Mugen87
Copy link
Collaborator

Mugen87 commented Apr 21, 2021

Um, it seems you are not using the latest version of SVGLoader. This code was refactored with r126, see #21195.

@mrdoob mrdoob closed this as completed Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants