Skip to content

surfacecolor attribute on <model> for models without materials (STL) #189

Open

Description

@jeanhbr

STL is one of the most widely shared 3D format on the web (3D printing and CAD sites), but it describes only geometry: no materials, colors or textures. Displayed in <model>, such models get a uniform grey default material, which is a regression for sites that show them in color today, and there's no way for authors to fix it without converting their assets.

This proposes a surfacecolor attribute on <model>, taking a CSS <color>:

<model src="part.stl" surfacecolor="tomato"></model>
  • It sets the base (diffuse) color of the default material used when the model has no materials of its own, as with STL. Models with their own materials (USDZ, glTF) are unaffected.
  • Alpha is ignored: the color's red, green and blue channels set the material's base color, and the model stays opaque. A translucent value like rgb(255 0 0 / 50%) renders as opaque red, not composited onto anything.
  • It's an HTML attribute rather than CSS because it describes the model object itself, the color of its surface, not the presentation of the <model> element's box. It's also applied when the model is loaded, not as live styling; changing it reloads the model.
  • The name is deliberately specific. It leaves surface, or a richer material definition (e.g. PBR parameters or a CSS @material rule), open for a more general design later.

Alternatives discussed: a CSS property or an @material rule, a separate material file (e.g. MTL), and a matcap image. All are more general, but each raises questions (overriding existing materials, targeting parts of a model) that a simple STL fallback color doesn't need to answer.

Activity

  1. cabanier commented on Nov 16, 2026

    @cabanier
    Member

    The element does not support STL. Only USDZ and GLB.
    Since STL doesn't support color or even units, it seems difficult to add this format.

  2. jeanhbr commented on Nov 18, 2026

    @jeanhbr
    Author

    Thanks for following up! WebKit is testing support for STL (it's currently testable under a developer preview flag - WebKit/WebKit#80652). Since a lot of websites (like 3D printing websites) are displaying STL models already, we'd want to see what it'd take for those websites to use the model element.

  3. cabanier commented on Nov 18, 2026

    @cabanier
    Member

    @zachernuk @mwyrzykowski Are you ok if other browsers add support for STL?

  4. zachernuk commented on Nov 18, 2026

    @zachernuk
    Contributor

    I'd love for folks to add support for it! Given that we agree that it's under-specified in terms of surface material, though, it's probably for the best for the implementations to be feature-flagged until we work out what we all like as a way of supplying the required parameters. In this instance, I think a scale and a color may need to be supplied.

  5. AdaRoseCannon commented on Nov 18, 2026

    @AdaRoseCannon
    Member

    iirc at TPAC there was a discussion about scale for formats where the scale is not defined and that we should have a non-normative note for the scale based upon the format of the model. Which seems appropriate here.

  6. DRx3D commented on Nov 18, 2026

    @DRx3D
    Contributor

    The danger in introducing several optional supported file formats is portability (remember "works best in Internet Explorer V6.5"). If a format is required, then there is the risk that someone won't support the format or the tag because it's too much work for their market.

    To make things worse, there is not a formal governance body that maintains the STL specification. The original was written 1987/88 with a proposed update in 2007 that became the additive manufacturing file format. Requiring a file format that is not well specified is a whole big portability issue.

  7. AdaRoseCannon commented on Nov 18, 2026

    @AdaRoseCannon
    Member

    I'm going to

    /agenda this to talk about STL at the next CG meeting on Dec 1st

  8. added
    agenda
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agenda

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions