-
-
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
Update HTMLMesh to observe DOM mutation and support Canvas elements #23386
Conversation
- enable html2canvas updates to be made automatically based on dom updates - also add Stats.js to VR Sandbox
hmm, it seems window.requestAnimationFrame() doesn't really play nice in webxr mode, let me find a fix for that |
This might do the job. Looks cool! |
Thanks! |
stats.dom.style.width = '80px'; | ||
stats.dom.style.height = '48px'; |
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.
How come this is needed?
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'll have to check, but I think the floating parent div doesn't have an explicit width and height (computed size - offsetWidth and offsetHeight should reflect the true dimensions tho)
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.
yeah, looks like these 2 lines aren't needed at all to work...
// Canvas elements doesn't trigger DOM updates, so we have to update the texture | ||
statsMesh.material.map.update(); |
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 canvas element resizes?
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.
ah, could be clearer in the description, canvas can trigger dom changes, this line is needed because render updates on the 2d canvas context needs a manual update call.
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.
Hmm, is this for stats.js or in general?
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.
we will need to call .update() only if the input dom element is an actively updating canvas.
for all other dom types, MutationObserver calls the .update()
automatically. (I was thinking maybe add a html marquee element as another HTMLMesh example)
…rdoob#23386) * Update HTMLMesh to observe DOM mutation and support Canvas elements - enable html2canvas updates to be made automatically based on dom updates - also add Stats.js to VR Sandbox * Switch raf to setTimeout in HTMLMesh, also fix repeat notes in haptics
Description
video: https://twitter.com/BlurSpline/status/1487453742488190983
demo: https://raw.githack.com/zz85/three.js/html_mesh/examples/webxr_vr_sandbox.html