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: Make createShapes() usable for other modules. #24293

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jun 30, 2022

Related issue: #24291 (comment)

Description

SVGLoader.createShapes() assumes userData.style is defined at a certain place. This breaks the usage of the method outside of the loader (e.g. in context of Font).

@Mugen87 Mugen87 added this to the r143 milestone Jul 4, 2022
@mrdoob mrdoob merged commit e860e3d into mrdoob:dev Jul 7, 2022
@mrdoob
Copy link
Owner

mrdoob commented Jul 7, 2022

Thanks!

@dreammonkey
Copy link

Hello, for some reason this change is breaking my typescript build.
I'm getting the following error and I'm not sure how I can fix it...

ERROR in ./node_modules/three/examples/jsm/loaders/SVGLoader.js 2110:113
Module parse failed: Unexpected token (2110:113)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| 
|               // check if path is solid or a hole
>               const isAHole = simplePaths.map( p => isHoleTo( p, simplePaths, scanlineMinX, scanlineMaxX, shapePath.userData?.style.fillRule ) );
| 
| 

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Sep 8, 2022

Is it because of optional chaining? We use ?. elsewhere in the code base I don't think we revert its usage.

I'm not a TS user so I can't tell you how to fix this issue in your build.

@dreammonkey
Copy link

Yes, when removing the ? the error is gone. Very silly issue. It is actually not the build that breaks but the storybook that I'm using for development. It seems related to storybookjs/storybook#11515 but I'm unable to fix it using the proposed solution: "target": "ES2018"

abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
snagy pushed a commit to snagy/three.js-1 that referenced this pull request Sep 21, 2022
@satyajitghana
Copy link

Is it because of optional chaining? We use ?. elsewhere in the code base I don't think we revert its usage.

I'm not a TS user so I can't tell you how to fix this issue in your build.

yes it's because of optional chaining, I had no issue till 0.140.2 but 0.146.0 gives this issue

@dreammonkey
Copy link

I resolved the issue by importing the SVGLoader from https://github.com/pmndrs/three-stdlib

The three jsm modules are not part of the three.js package and are ment to be copied into your own project.
The three-stdlib package solves this issue elegantly !

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Oct 28, 2022

The three jsm modules are not part of the three.js package and are ment to be copied into your own project.

Sorry, that is not true. examples/jsm is part of the npm package. The import of SVGLoader looks like so:

import { SVGLoader } from 'three/examples/jsm/loaders/SVGLoader.js';

@dreammonkey
Copy link

You are right, they are part of the package, but importing from three-stdlib solved the issue for me.

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

Successfully merging this pull request may close these issues.

4 participants