-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix rendering if 3D viewport is hidden initially #5429
Conversation
true, | ||
); | ||
}); | ||
OrthoViewValuesWithoutTDView.forEach(id => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for the 3d viewport did not succeed here, if it's hidden initially. In that case, the mouse handlers were not set up. Since, there is a waitForElementWithId
two lines below for each viewport, I'd hope that this change doesn't break anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this won't be a problem, as the waitForElementWithId
works with promises. The onliest thing I see is that if one of the viewports is never rendered, that there will be endless calls of window.requestAnimationFrame
as long as wk is opened in a browser tab.
I think this is not optimal. Maybe we can add a timeout to this function and retrigger adding the mouse controllers for all inputcatchers that were newly rendered when the layout is changed.
But this would be a thing for another PR.
Note:
export function waitForElementWithId(elementId: string): Promise<*> {
const tryToResolve = resolve => {
const el = document.getElementById(elementId);
if (el) {
resolve(el);
} else {
window.requestAnimationFrame(() => tryToResolve(resolve));
}
};
return new Promise(tryToResolve);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I cross-referenced this comment in the corresponding issue: #3475
I agree that this is out-of-scope for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current workaround does not work for me when I stack all ortho views together and have the XY-viewport open.
Lets investigate why 🔍
true, | ||
); | ||
}); | ||
OrthoViewValuesWithoutTDView.forEach(id => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this won't be a problem, as the waitForElementWithId
works with promises. The onliest thing I see is that if one of the viewports is never rendered, that there will be endless calls of window.requestAnimationFrame
as long as wk is opened in a browser tab.
I think this is not optimal. Maybe we can add a timeout to this function and retrigger adding the mouse controllers for all inputcatchers that were newly rendered when the layout is changed.
But this would be a thing for another PR.
Note:
export function waitForElementWithId(elementId: string): Promise<*> {
const tryToResolve = resolve => {
const el = document.getElementById(elementId);
if (el) {
resolve(el);
} else {
window.requestAnimationFrame(() => tryToResolve(resolve));
}
};
return new Promise(tryToResolve);
}
My 🔍 results: Then why are the viewport cameras updated once the 3d viewport is rendered? How to solve this (imo): It looks like implementing this change is quite some work, but think it is necessary and that a quick fix would not be sufficient / too dirty and might result in related bugs later on. Note: The changes in |
You can verify my thesis by commenting out the loop starting at this line and
If you uncomment the lines again, then the 3rd step should work and data should be visible in the xy viewport |
…iewport rects in input catcher
if (!this.controls) { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By postponing this null-check to the exact points where it's necessary (i.e., in setTargetAndFixPosition
), we can eagerly instantiate the CameraController which should fix the issue.
Thanks for the detailed investigation and write-up 👍 👍 From your last sentence, I could derive a relatively simple solution. I simply removed the guard and limited its scope so that it doesn't affect the CameraController.
Yes, I agree, that an architectural change would be even better. However, as a quick fix, I hope that my above workaround is adequate.
See my other comments. The changes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was finally able to test the fix and it works 🚀 🧻
I just created an issue for this: #5436 |
URL of deployed dev instance (used for testing):
Steps to test:
Issues: