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

Enable use of Tools.LoadScript in a WebWorker #12884

Merged
merged 2 commits into from
Aug 18, 2022

Conversation

wmurphyrd
Copy link
Contributor

Fixes #12882

  • Checks if LoadScript is called from a WebWorker context and, if so, uses importScripts instead of HTMLScriptElement to load the script.
  • Ensures LoadScript always resolves with either onSuccess or onError

Use case: using ImportMeshAsync in a WebWorker for meshes requiring MeshoptCompression

RE the typings: there's apparently no clean solution as TypeScript is extremely not a fan of code designed to run in both DOM and WebWorker, these hideous double type assertions seemed less bad than falsely declaring importScripts as available on the Window interface

@azure-pipelines
Copy link

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

Copy link
Member

@sebavan sebavan left a comment

Choose a reason for hiding this comment

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

GG !!!! thanks a lot

@sebavan
Copy link
Member

sebavan commented Aug 18, 2022

Just a tiny format issue and good to go :-)

Copy link
Contributor

@deltakosh deltakosh left a comment

Choose a reason for hiding this comment

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

you rock! thanks a lot

@deltakosh deltakosh enabled auto-merge (squash) August 18, 2022 22:11
@azure-pipelines
Copy link

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@azure-pipelines
Copy link

@deltakosh deltakosh merged commit d17319a into BabylonJS:master Aug 18, 2022
RaananW pushed a commit that referenced this pull request Dec 9, 2022
* use importScripts instead of HTMLScriptElement when LoadScript is invoked in a WebWorker

* lint

Former-commit-id: 1aa95194fb1287d6c0033a04a93cdacc219024fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tools.LoadScript shouldn't return without calling onError / Infinite loading on ImportMeshAsync
3 participants