-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
CSS2D/3DRenderer: Ensure Object3D.visible
is correctly evaluated in object hierarchies.
#28293
Conversation
…stors are visible
For reproduction: https://jsfiddle.net/nhg8durq/ |
Um, I'm not sure why the CSS renderers behave differently compared to It's also better to fix this issue in if ( object.visible === false ) return; For if ( object.visible === false || ( _vector.z < - 1 || _vector.z > 1 )) return; The local @yomotsu Do you know why the CSS renderers handle children of invisible objects differently than |
Actually, I'm not entirely sure, and it seems that the potential problem might have gone unnoticed.
I thought nested CSS3DObjects are also nested in the DOM scene graph and parents Given these points, I think each CSS3DObject needs to check its ancestors' |
The solution would be more consistent when the same coding patterns are applied like in |
That makes sense and I tested adding that.
The above will stop the rendering process of children, However, CSS3DObjects will remain rendered without matrix updates because DOM elements are rendered because HTML is rendered in "retained mode", unlike WebGL or Canvas2D. e.g.
|
Clean up.
Clean up.
More clean up.
Do we still need to change the
|
Let's not apply any changes to |
The problem with Do you mind implementing the PR differently based on #28293 (comment)? |
function renderObject( object, scene, camera ) { | ||
|
||
if ( object.visible === false ) return; |
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.
It seems the ( object.visible === true ) &&
check further below can be removed now, right?
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.
That's right. The object has to be visible === true
below this line, so there's no need to check again.
Thus, line 138 can be
- const visible = ( object.visible === true ) && ( _vector.z >= - 1 && _vector.z <= 1 ) && ( object.layers.test( camera.layers ) === true );
+ const visible = ( _vector.z >= - 1 && _vector.z <= 1 ) && ( object.layers.test( camera.layers ) === true );
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.
Additionally, the line that sets the CSS display value can look like this,
because all elements are already set to display: none due to hideObject(object)
- object.element.style.display = ( visible === true ) ? '' : 'none';
if ( visible === true ) {
object.onBeforeRender( _this, scene, camera );
const element = object.element;
+ element.style.display = '';
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.
Beautiful!
Clean up.
Clean up.
Simplify code.
Simplify code.
Object3D.visible
is correctly evaluated in object hierarchies.
@Mugen87 There is another problem in
Due to the cache setting condition that objects must be visible (including their ancestors), when an object is initially invisible ,the So it is necessary to check if the cache is empty and set a default value , some code like this:
|
Good catch! Would you file another PR with your fix? |
…stors are visible
Related issue: #XXXX
Description
A clear and concise description of what the problem was and how this pull request solves it.
This contribution is funded by Example