-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
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
CSS3DRenderer: Transforms broken depending on container size and position #26950
Comments
I dont get the bug above in any of the browsers, but tbh I had enough issues with css3d trying to use it in production to just abandon all hope for it. It is broken in random browsers in unexpected ways. |
@makc that's surprising to me -- in Chrome, the face stays centered as you drag the |
I tried modifying CSS3DRenderer with two changes:
This appears to fix the positioning problems in Chrome and Firefox, but not Safari. I'm not sure yet if there is a downside. |
oh right, you used mac, this is win. mac m1 indeed has a problem |
Ahh ok! Hm... interesting that those specific values do not trigger the bug in Chrome for me, only fractional offsets. Perhaps the conditions for the bug are slightly different in windows. 🫤 |
Hi, I reproduce the bug on iphone, ipadOS 16.1 with threejs 0.159 |
Description
Background: The purpose of THREE.CSS3DRenderer is to apply CSS transforms to HTML elements, such that they appear to be within the 3D scene. They're still HTML elements of course, are not drawn to the depth buffer, and cannot participate in occlusion and lighting like THREE.Mesh objects.
Problem: The CSS 3D transforms required for correct element placement are very fragile to specific conditions of the DOM element given to CSS3DRenderer. The specific conditions are, very unfortunately, different in every major browser:
display: absolute
, then.offsetTop
and.offsetLeft
MUST be whole numbers. If they contain a fractional part, rendering will be displaced vertically or horizontally. When domElement usesdisplay: sticky
, everything is fine.domElement
. I haven't figured out logic of it, but using even numbers for both width and height appears to avoid the problem.display: sticky
on any ancestor of domElement will cause the CSS transforms to break badly during scrolling.Presumably these are some browser bugs involved, but this was complex enough to track down in detail that I think we may want this issue documenting the situation. This bug also affects implementations derived from CSS3DRenderer, including drei's
<HTML />
component and threlte's<HTML />
component.This is likely related to the root cause for a number of other issues, including:
Reproduction steps
:)
to change its background colorCode
See live example.
Live example
https://jsfiddle.net/donmccurdy/twy3p2zv/
Screenshots
Version
r157
Device
Desktop
Browser
Chrome, Firefox, Safari
OS
MacOS
The text was updated successfully, but these errors were encountered: