-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Applying CSS to A-frame's components #1102
Comments
To hide/show an entity you can use the visible attribute <a-entity visible="false:></a-entity>
We have mixins as an analog of CSS. This allows you to group a set of components/properties and apply them to multiple entities the same way you group CSS properties in classes. We could have used a CSS syntax for mixins but custom properties on CSS are discarded by many browsers. Their properties are not calculated and the values not shown in the dev tools. We could have carried our own parser but using CSS can lead to misunderstandigs. Most of the standard CSS properties don't apply to a 3D scene. We would have recreated CSS with complete different semantics. Also the CSS syntax does not accommodate well properties with complex values. background, padding or border have unlabeled complex values but it would be very confusing in the case of components. We would have to come up with an extended CSS syntax that allows for things like this: .red-cube {
geometry: { primitive: box; size: 5 }
material: { color: red }
} |
@dmarcos Oh, okay. Thanks for the info (I found out though that the attributes for |
@dmarcos Is that statement outdated? MDN says that all the modern browsers support custom properties.
That's totally fine. For example, SVG has
Instead of Just an idea, but <a-entity light="color: #AFA; intensity: 1.5" position="-1 1 0"></a-entity> could be written as /* apply to all a-entity elements */
a-entity {
--light: color: #AFA, intensity: 1.5;
--position: -1 1 0;
} With simple parsing of the property values, you'd apply them just like with attribute values. This is, in fact, very similar to SVG where some features that can be specified via attributes can also be specified via CSS. In SVG: <rect transform="rotate(45 50 50)"></rect> or /* apply to all rects in a similar way with CSS */
rect {
transform: rotate(45deg) transform-origin: 50px 50px;
} TLDR: it's totally doable from what I can tell! |
By the way, I saw @ngokevin's MSS, which is similar and useful! I also forgot to mention that it's simple to get the property values to JS: https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables#Values_in_JavaScript This could be done in a |
@trusktr Have you tried a |
I believe you'd have to watch for changes in
Maybe that the property syntax is official, part of CSS, so more flexible. One example: styles for regular elements as well as a-frame elements can be contained inside a single stylesheet. There's existing tooling for CSS (stylus, less, sass, postCSS, JSinCSS, etc).
That's true and a good point. It's not easy to tell Custom Elements how to behave whenever they have |
Regardless, MSS is super nice, I definitely have to say! Inspiring. :) |
It works, but it's reliant on JavaScript in many cases. I would like a CSS-like interface to create custom classes like ".hide-walls" on a house that would normally use CSS like this: |
I know this issue is close but I would like to add my use case to the question:
In my app I am combining A-Frame with regular HTML using HTML Shaders, so I am already styling my HTML content using CSS, so it would be nice to use CSS with A-Frame too. @trusktr Makes good points about SVG and postCSS, Sass etc and I also see how the CSS properties rotate() could match up to the A-Frame rotation. So I think CSS is the right way to go and I would encourage you open up debate about this. Custom Elements is still only v1, so maybe A-Frame could influence how the standard evolves. |
Is it possible to do this in some way? I noticed that using normal CSS doesn't work.
How to, for example, hide and show the elements with CSS?
The text was updated successfully, but these errors were encountered: