pmndrs / three-stdlib

📚 Stand-alone library of threejs examples designed to run without transpilation in node & browser
https://npmjs.com/three-stdlib
MIT License
676 stars 110 forks source link

fix(KTX2Loader): web worker scope #374

Closed roelkok closed 5 days ago

roelkok commented 5 days ago

Why

The web workers created by KTX2Loader throw the following error: Uncaught ReferenceError: _KTX2Loader is not defined. This PR fixes that.

What

Updated the BasisWorker function to reference the variables that are prepended to the web worker code instead of referencing these values from the KTX2Loader class.

Although the BasisWorker function is defined within the KTX2Loader class, once it's stringified and used as code for a web worker it doesn't have access anymore to its original upper scope. Therefore it will throw an ReferenceError.

JSDoc type annotations have been added to get the right type hinting in the BasisWorker code.

Checklist

Fixes:

codesandbox-ci[bot] commented 5 days ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

github-actions[bot] commented 5 days ago

:tada: This PR is included in version 2.30.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket: