Integrate 3D model to nopCommerce.

6 месяцев назад
Integrating 3D models into nopCommerce is a little tricky.
The 3D model was working perfectly at the .netcore web project but not working at the nopCommerce plugin. It took a long time to figure out the issue. The below codes are needed to use for showing 3D models in the concrete class of the INopStartup.

public void Configure(IApplicationBuilder application)
{
    application.UseStaticFiles(
    new StaticFileOptions
    {
        ServeUnknownFileTypes = true,
        DefaultContentType = "text/plane"
    });
}

The js hierarchy
NopHtml.AppendScriptParts(ResourceLocation.Footer, "~/Plugins/Payments.PayPalStandard/Content/appscripts/appscripts.js", excludeFromBundle: true);
NopHtml.AppendScriptParts(ResourceLocation.Footer, "~/Plugins/Payments.PayPalStandard/Content/lib/threejs/OrbitControls.js", excludeFromBundle: true);
NopHtml.AppendScriptParts(ResourceLocation.Footer, "~/Plugins/Payments.PayPalStandard/Content/lib/threejs/OBJLoader.js", excludeFromBundle: true);
NopHtml.AppendScriptParts(ResourceLocation.Footer, "~/Plugins/Payments.PayPalStandard/Content/lib/threejs/three.min.js", excludeFromBundle: true);

The output
https://ibb.co/wN5w8j4
6 месяцев назад
I had a similar challenge for a BabylonJS integration I built.  They use .glb model files, so I came up with this targeted approach for my plugin to solve the 404 issue:

        public void Configure(IApplicationBuilder application)
        {
            // Add support for serving up .glb 3D model file types
            var fileProvider = EngineContext.Current.Resolve<INopFileProvider>();
            var provider = new FileExtensionContentTypeProvider
            {
                Mappings = { [".glb"] = "model/gltf-binary" }
            };
            application.UseStaticFiles(new StaticFileOptions
            {
                FileProvider = new PhysicalFileProvider(fileProvider.GetAbsolutePath("files/product3dassets")),
                RequestPath = "/files/product3dassets",
                ContentTypeProvider = provider
            });
        }