Open donmccurdy opened 1 year ago
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 offsetLeft
slider around? Could I ask what operating system you're using?
I tried modifying CSS3DRenderer with two changes:
perspective: ${fov}px
from viewElementtransform: perspective(${fov}px) ...
to cameraElementThis appears to fix the positioning problems in Chrome and Firefox, but not Safari. I'm not sure yet if there is a downside.
what operating system you're using
oh right, you used mac, this is win. mac m1 indeed has a problem
actually now I can reproduce in win chrome too
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. 🫤
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