-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Use self to get global context before window in getEventPriority. #2493
Use self to get global context before window in getEventPriority. #2493
Conversation
Prior to this change, this code would throw an error when run inside of a WebWorker, since window is not defined inside of webworkers. This prevented us from using R3F inside of an offscreen canvas in a webworker.
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. Latest deployment of this branch, based on commit 2799a05:
|
We also make use of A work-around would be to specify an integer rather than a range for |
For our particular use case, this change alone suffices.
We specify an integer for DPR in our code, yeah, but our particular use case doesn't require us to set the frameloop. |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@react-three/fiber](https://togithub.com/pmndrs/react-three-fiber) | [`8.7.3` -> `8.7.4`](https://renovatebot.com/diffs/npm/@react-three%2ffiber/8.7.3/8.7.4) | [![age](https://badges.renovateapi.com/packages/npm/@react-three%2ffiber/8.7.4/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@react-three%2ffiber/8.7.4/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@react-three%2ffiber/8.7.4/compatibility-slim/8.7.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@react-three%2ffiber/8.7.4/confidence-slim/8.7.3)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>pmndrs/react-three-fiber</summary> ### [`v8.7.4`](https://togithub.com/pmndrs/react-three-fiber/releases/tag/v8.7.4) [Compare Source](https://togithub.com/pmndrs/react-three-fiber/compare/@react-three/fiber@8.7.3...v8.7.4) #### What's Changed - fix: use self to get global context before window by [@​joewhatkins](https://togithub.com/joewhatkins) in [https://github.com/pmndrs/react-three-fiber/pull/2493](https://togithub.com/pmndrs/react-three-fiber/pull/2493) #### New Contributors - [@​joewhatkins](https://togithub.com/joewhatkins) made their first contribution in [https://github.com/pmndrs/react-three-fiber/pull/2493](https://togithub.com/pmndrs/react-three-fiber/pull/2493) **Full Changelog**: pmndrs/react-three-fiber@v8.7.2...v8.7.4 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ziyadedher/ziyadedher). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xOTUuNSIsInVwZGF0ZWRJblZlciI6IjMyLjE5NS41In0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@react-three/fiber](https://togithub.com/pmndrs/react-three-fiber) | [`8.7.3` -> `8.7.4`](https://renovatebot.com/diffs/npm/@react-three%2ffiber/8.7.3/8.7.4) | [![age](https://badges.renovateapi.com/packages/npm/@react-three%2ffiber/8.7.4/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@react-three%2ffiber/8.7.4/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@react-three%2ffiber/8.7.4/compatibility-slim/8.7.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@react-three%2ffiber/8.7.4/confidence-slim/8.7.3)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>pmndrs/react-three-fiber</summary> ### [`v8.7.4`](https://togithub.com/pmndrs/react-three-fiber/releases/tag/v8.7.4) [Compare Source](https://togithub.com/pmndrs/react-three-fiber/compare/@react-three/fiber@8.7.3...v8.7.4) #### What's Changed - fix: use self to get global context before window by [@​joewhatkins](https://togithub.com/joewhatkins) in [https://github.com/pmndrs/react-three-fiber/pull/2493](https://togithub.com/pmndrs/react-three-fiber/pull/2493) #### New Contributors - [@​joewhatkins](https://togithub.com/joewhatkins) made their first contribution in [https://github.com/pmndrs/react-three-fiber/pull/2493](https://togithub.com/pmndrs/react-three-fiber/pull/2493) **Full Changelog**: pmndrs/react-three-fiber@v8.7.2...v8.7.4 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ziyadedher/ziyadedher). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xOTUuNSIsInVwZGF0ZWRJblZlciI6IjMyLjE5NS41In0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Prior to this change, this code would throw an error when run inside of a WebWorker, since window is not defined inside of webworkers.
This prevented us from using R3F inside of an offscreen canvas in a webworker.
See https://stackoverflow.com/questions/71587025/cant-use-offscreencanvas-with-react-three-fiber for an example.