GLTFExporter GLB compatible with Facebook viewer

After facebook announced glTF support on their timeline I’ve been trying to use the GLTFExporter to generate some binary glTF (glb) to test this new feature.

But I’ve found some problems so far:

  • GLB Chunks must be 4-byte aligned #13395
  • Validation: Fix znear and zfar: #13396
  • Vertex Color: Facebook supports just RGBA but not RGB. As shown on the validation message:
    [msg] => Vertex COLOR_0 attributes of type RGB are (temporarily) notsupported. They must be RGBA.. Although COLOR_0 could be vec3 or vec4 and we could include an optional parameter to force the conversion of the color attribute from 3 to 4 components, I don’t think we should do that hack as our current implementation is following the spec and I don’t see any other use case for that conversion than just hijack the facebook validator while they’re working on fixing it. <– Update: This should be done in the following weeks, so we don’t need to workaround it
  • Non indexed meshes are not supported: `[msg] => Mesh primitives without indices are (temporary) unsupported.
  • Export other primitive modes (Currently just TRIANGLE supported)

More info:

Author: Fantashit

11 thoughts on “GLTFExporter GLB compatible with Facebook viewer

  1. Could you make the GLTFExporter hack in a fork that’s used in but not elsewhere?

    Yeah, no worries!

    I would hope we’ll have fixed this flaw by the time r91 comes out

    Oh, I’m aiming to release ~March 1st. Changed release cycle to beginning of the month to have proper month releases.

    Seems like we still have more features to add before promoting this anyway. I don’t think we are exporting roughness, metallic, normal or alpha maps.

    Latest test, using 2 diffuse maps, clouds one being a transparent png:

    Not sure where the apparent alphaTest: 0.5 is coming from…

  2. As of build 161 and on (current App Store version is 160) of main FB app, this won’t be a crasher anymore and we’ll remove this validation check. I expect this to happen within the week.

  3. Makes me wonder though…

    The “real” reason THREE.GLTFExporter can’t export THREE.Geometry is because when we convert THREE.Geometry to THREE.BufferGeometry we’re creating a color attribute which is, in most of the cases, full of zeros.

    So, one “solution” (and optimisation) would be to not export the color attribute if material.vertexColors is set to THREE.NoColors?

  4. @ov I think both of those are likely to be fixed around r91:

    1. multi-material export #13536
    2. metal/roughness fixes #13501

    It’s possible that Facebook’s materials aren’t quite right yet either, but glTF is pretty specific about how things should appear so eventually we should converge.

  5. Hey folks — as of this morning, Facebook no longer rejects RGB (VEC3) vertex colours as “invalid”.

    The power-of-two textures requirements remains for the moment, but I’m working on that too.

Comments are closed.