Skip to content
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

HTMLMesh: Add some more input types and support rounded rectangles. #24030

Merged
merged 7 commits into from
May 10, 2022

Conversation

AdaRoseCannon
Copy link
Contributor

@AdaRoseCannon AdaRoseCannon commented May 8, 2022

Description

Using common input types with this before was doable but very hacky, this renders them similar to how the browser does.

  • Supports uniform border radius (added to enable the other features)
  • Supports font-weight
  • Supports Input Checkboxes
  • Supports Input Radio
  • Supports Input Range
  • Those elements take their colour from the CSS accent color property
  • An appropriate light dark contrast colour is used depending on the accent colour like how the browser does it

image

A light accent color (hotpink)

image

A dark accent color (teal)

Live demo

This contribution is funded by Samsung Internet

@Mugen87 Mugen87 changed the title Add some more input types and support rounded rectangles HTMLMesh: Add some more input types and support rounded rectangles. May 8, 2022
@AdaRoseCannon
Copy link
Contributor Author

Here is a screenshot confirming the correct border behaviour
The two have different borders so don't support border radius.

The bottom one has all the same borders so supports it.

image

@mrdoob mrdoob added this to the r141 milestone May 9, 2022
@AdaRoseCannon
Copy link
Contributor Author

I just tested these in VR, unfortunately clicking on the range slider does nothing, I don't think it can respond to synthetic events.

I could add code to handle range sliders in the event handler or I could remove support for rendering the range slider and say it is unsupported. Do you have a preference?

@AdaRoseCannon
Copy link
Contributor Author

I just added the code for supporting the interactivity with range, it updates the value then fires the input event.

@mrdoob mrdoob merged commit 3ac055c into mrdoob:dev May 10, 2022
@mrdoob
Copy link
Owner

mrdoob commented May 10, 2022

Thanks!

abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
…rdoob#24030)

* Add some more input types and support rounded rectangles

* actually perform border check

* remove unneeded code

* s/roundRectPath/buildRectPath/

* range input handler

* Clean up.

* More clean up.

Co-authored-by: mrdoob <[email protected]>
Comment on lines +356 to +357
const luminance = Math.sqrt( 0.299 * ( color.r ** 2 ) + 0.587 * ( color.g ** 2 ) + 0.114 * ( color.b ** 2 ) );
const accentTextColor = luminance < 0.5 ? 'white' : '#111111';
Copy link
Collaborator

Choose a reason for hiding this comment

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

@AdaRoseCannon are these luminance coefficients chosen to match a particular (web?) specification, or are they more subjective and OK to change?

Sorry for bumping an old PR! I am considering how/if to update this in #28880, for consistency in color management across the library. These seem to be luminance coefficients for Rec. 601, rather than Rec. 709 / sRGB, but I just want to check if there's some additional reason here. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was just for toggling the text color light/dark mode. It feels like a lifetime ago now but iirc I picked it because it closely matched Chrome's behaviour at the time so that what you see on the desktop closely matches the WebXR experience. Because it is just a binary toggle it's probably fine to change it however you need and it will probably work okay.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, that makes sense to me — thank you!

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.

5 participants