Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

fix: make scene save as visible #8664

Merged
merged 7 commits into from
Sep 8, 2023
Merged

fix: make scene save as visible #8664

merged 7 commits into from
Sep 8, 2023

Conversation

aditya-mitra
Copy link
Collaborator

Summary

  • save scene as png
  • make the component fields visible
  • change pixel ratio before resizing window

image

References

closes #8656

Checklist

  • If this PR is still a WIP, convert to a draft
  • When this PR is ready, mark it as "Ready for review"
  • ensure all checks pass
  • Changes have been manually QA'd
  • Changes reviewed by at least 2 approved reviewer

QA Steps

List any additional steps required to QA the changes of this PR, as well as any supplemental images or videos.

const interval = setInterval(() => {
const viewport = EngineRenderer.instance.renderContext.getParameter(
EngineRenderer.instance.renderContext.VIEWPORT
)
// todo - scrolling in and out sometimes causes weird pixel ratios that can cause this to fail
if (viewport[2] === Math.round(width * pixelRatio) && viewport[3] === Math.round(height * pixelRatio)) {
if (viewport[2] === Math.round(width) && viewport[3] === Math.round(height)) {
Copy link
Member

Choose a reason for hiding this comment

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

Pixel ratio must be preserved here

Copy link
Collaborator Author

@aditya-mitra aditya-mitra Sep 6, 2023

Choose a reason for hiding this comment

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

Tried this a few times, viewport comes out to be like 0 0 512 320 and height and width are also 320 and 512 respectively but pixelRatio is 2. So, the condition is not fulfilled. Also,pixelRatio is defined outside the promise so it does not change even though the promise inside changes the pixelRatio to 1.

const timeout = setTimeout(() => {
console.warn('Could not resize viewport in time')
clearTimeout(timeout)
clearInterval(interval)
reject()
}, 10000)

// set up effect composer
Copy link
Member

Choose a reason for hiding this comment

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

Why was this moved earlier up?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After testing this a lot of times, the timer functions are called before the resizing of the scene. So, the if condition above does not ever get satisfied and an error is thrown.
Synchronously calling them does not cause that error.

@HexaField HexaField merged commit f909830 into dev Sep 8, 2023
@HexaField HexaField deleted the fix/scene-save-as branch September 8, 2023 01:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] "save as" is broken in the Studio
2 participants