Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nick 84 posts 451 karma points
    May 09, 2023 @ 05:21
    Nick
    0

    Rendering GLB (3D Animations) files within Umbraco

    Hi,

    Hope somebody could help me with a strange issue within my Umbraco 11 Cloud project, I'm using a Media picker to load a GLB file, which is a 3D rendered interactive model like this https://modelviewer.dev, but I'm receiving a 404 error on the glb file. Has anybody used these files within Umbraco and can help me resolve this issue?

    <model-viewer src="@(Model.Value<IPublishedContent>("video3DLink").Url())"
                  ar
                  ar-modes="webxr scene-viewer quick-look"
                  camera-controls
                  poster="@(Model.Value<IPublishedContent>("video3DImage").Url())"
                  shadow-intensity="1"
                  style="width: 100%; top: 0px; position: sticky"
                >
    

    And this renders out on the page as

    enter image description here

    Many thanks again for all your support

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 09, 2023 @ 07:48
    Jan Skovgaard
    0

    Hi Nick

    My suspicion about this issue is that the server does not know the correct MIME type for the glb file.

    So what I have been able to find out is that the mime type appears to be model/gltf-binary

    But I must admit that since we made the switch to .NET 5+ going from web.config til appsettings.json I'm not sure how to register new mime types.

    Before it was usually a matter of doing the following in a web.config

    <configuration>
        <system.webServer>
            <staticContent>
                <remove fileExtension=".glb" />
                <mimeMap fileExtension=".glb" mimeType="model/gltf-binary" />
            </staticContent>
        </system.webServer>
    </configuration>
    

    But I'm not quite sure on how to achieve it these days - Not sure if you can actually still use a web.config with the above in it since it should be picked up by the server assuming it's running on IIS - But since you're running cloud I guess it could perhaps work.

    I don't know if there is a more "correct" way of doing it these days.

    Hope this guides you in the right direction.

    /Jan

  • Nick 84 posts 451 karma points
    May 22, 2023 @ 17:25
    Nick
    0

    Thanks Jan,

    I've implemented that within the web.config but no joy. Also contacted Umbraco support, very helpful and supplied this possible solution:

    I talked with the developers when it's Net.Core You will need to do something like this I know its for another file format but its setup should be similar

    https://github.com/dotnet/aspnetcore/issues/22477 Seems like they can just configure it https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-7.0#fileextensioncontenttypeprovider

    I just added it by calling services.ConfigureOptions

    public class MyStaticFileOptions : IConfigureOptions<StaticFileOptions>
    {
    public void Configure(StaticFileOptions options)
    {
    var provider = new FileExtensionContentTypeProvider();
    provider.Mappings[".geojson"] = "application/json";
    options.ContentTypeProvider = provider;
    }
    }
    

    https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-7.0#fileextensioncontenttypeprovider

    And https://github.com/dotnet/aspnetcore/pull/22478/files

    Unfortunately this also didn't work for me, no errors but no file rendered either :-(

  • Harikrishna Parmar 43 posts 262 karma points c-trib
    May 29, 2023 @ 14:40
    Harikrishna Parmar
    100
    provider.Mappings.Add(".glb", "model/gltf-binary");
    provider.Mappings.Add(".gltf", "model/gltf+json");
    

    This would work. I have checked. it's working fine.

Please Sign in or register to post replies

Write your reply to:

Draft