Skip to content

ViewHelper: Customize the viewport size and fix renderer.autoClear settings #31355

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ylfq
Copy link

@ylfq ylfq commented Jul 2, 2025

  1. ViewHelper was not able to adjust its display position automatically
  2. ViewHelper was only possible to manually clear the canvas to allow the helper and scene to display properly

This PR adds the function "setViewport" to customize the display location, and automatically handles the clear of the canvas

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 2, 2025

Do you mind demonstrating the issue with a live example that is fixed by this PR? (https://jsfiddle.net/mnqr9oj0/)

Can the issue be reproduced somehow with the editor (which is the primary user of ViewHelper in this repo)?

//

const x = domElement.offsetWidth - dim;
const y = renderer.isWebGPURenderer ? domElement.offsetHeight - dim : 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think it's correct to drop this check. WebGPURenderer and WebGLRenderer have different viewport conventions.

Copy link
Author

@ylfq ylfq Jul 2, 2025

Choose a reason for hiding this comment

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

I don't think it's correct to drop this check. WebGPURenderer and WebGLRenderer have different viewport conventions.

It's really an oversight on my part here, and I think it's good to delegate viewport operations directly to the user

Copy link
Author

Choose a reason for hiding this comment

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

I don't think it's correct to drop this check. WebGPURenderer and WebGLRenderer have different viewport conventions.

However, the helper can only get the renderer instance inside the render function, and the cached variables are outside.I think it's better to leave the location settings of the helper to the user, the difference between GL and GPU is harmless

Copy link
Collaborator

Choose a reason for hiding this comment

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

the difference between GL and GPU is harmless

The view helper won't be proper positioned without this code. So it must be restored. This is not something the user should care about on app level.

Copy link
Author

Choose a reason for hiding this comment

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

the difference between GL and GPU is harmless

The view helper won't be proper positioned without this code. So it must be restored. This is not something the user should care about on app level.

The new commit already takes care of this, using the renderer as an argument to the constructor
The new demo is here https://jsfiddle.net/sdtL5bao/

Copy link
Author

Choose a reason for hiding this comment

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

The new commit already takes care of this, using the renderer as an argument to the constructor The new demo is here https://jsfiddle.net/sdtL5bao/

Please ignore this commit for now, some bugs are not fully fixed

@ylfq
Copy link
Author

ylfq commented Jul 2, 2025

Do you mind demonstrating the issue with a live example that is fixed by this PR? (https://jsfiddle.net/mnqr9oj0/)

Can the issue be reproduced somehow with the editor (which is the primary user of ViewHelper in this repo)?

https://jsfiddle.net/ej1md8st/4/
Here's a simple demonstration of the ViewHelper, enable to adjust the position of the Helper, and the ability to render successfully without manual clear of the canvas

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 8, 2025

Your fiddle contains a runtime error because you are importing the ViewHelper module from the three repository but use it with the new ctor signature and API from the PR. That is not a usable live example.

You should demonstrate with a live example like https://jsfiddle.net/kofv1t6p/3/ what currently does not work. I'm afraid I still don't understand both issues you have raised in your initial post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants