diff --git a/IcarusView/3MF_test/Web3D.pack/Program.cs b/IcarusView/3MF_test/Web3D.pack/Program.cs index 2c86ce9..faef9e3 100644 --- a/IcarusView/3MF_test/Web3D.pack/Program.cs +++ b/IcarusView/3MF_test/Web3D.pack/Program.cs @@ -1,10 +1,15 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.StaticFiles; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.FileProviders; using Web3D.pack.Data; var builder = WebApplication.CreateBuilder(args); +// configuration setup +Microsoft.Extensions.Configuration.ConfigurationManager configuration = builder.Configuration; + // Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); @@ -24,6 +29,7 @@ if (!app.Environment.IsDevelopment()) var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider(); // NOTE: Add new mappings provider.Mappings[".3mf"] = "model"; // NOTE: add the extension (with period) and its type +provider.Mappings[".3dm"] = "model"; // NOTE: add the extension (with period) and its type @@ -36,6 +42,39 @@ app.UseStaticFiles(new StaticFileOptions // NOTE: replace the line app.UseStatic ContentTypeProvider = provider }); +// gestione static files x modelli 3D: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0 +string path3mf = configuration.GetValue("ServerConf:path3mf") ?? configuration.GetValue("OptConf:path3mf") ?? ""; +if (!string.IsNullOrEmpty(path3mf)) +{ + // verifico esista folder disegni + if (Directory.Exists(path3mf)) + { + // gestione cartella x PDF + app.UseStaticFiles(new StaticFileOptions + { + FileProvider = new PhysicalFileProvider(path3mf), + RequestPath = "/3mf", + ContentTypeProvider = provider + }); + } +} +string path3dm = configuration.GetValue("ServerConf:path3dm") ?? configuration.GetValue("OptConf:path3dm") ?? ""; +if (!string.IsNullOrEmpty(path3dm)) +{ + // verifico esista folder disegni + if (Directory.Exists(path3dm)) + { + // gestione cartella x PDF + app.UseStaticFiles(new StaticFileOptions + { + FileProvider = new PhysicalFileProvider(path3dm), + RequestPath = "/3dm", + ContentTypeProvider = provider + }); + } +} + + app.UseHttpsRedirection(); app.UseStaticFiles(); diff --git a/IcarusView/3MF_test/Web3D.pack/Web3D.pack.csproj b/IcarusView/3MF_test/Web3D.pack/Web3D.pack.csproj index 3198540..5d95dcd 100644 --- a/IcarusView/3MF_test/Web3D.pack/Web3D.pack.csproj +++ b/IcarusView/3MF_test/Web3D.pack/Web3D.pack.csproj @@ -8,10 +8,11 @@ + + - diff --git a/IcarusView/3MF_test/Web3D.pack/appsettings.json b/IcarusView/3MF_test/Web3D.pack/appsettings.json index 10f68b8..e2f2681 100644 --- a/IcarusView/3MF_test/Web3D.pack/appsettings.json +++ b/IcarusView/3MF_test/Web3D.pack/appsettings.json @@ -5,5 +5,9 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "ServerConf": { + "path3mf": "\\\\iis01\\Test3D\\3mf", + "path3dm": "\\\\iis01\\Test3D\\3dm" + } } diff --git a/IcarusView/3MF_test/Web3D.pack/libman.json b/IcarusView/3MF_test/Web3D.pack/libman.json index 267e841..a082988 100644 --- a/IcarusView/3MF_test/Web3D.pack/libman.json +++ b/IcarusView/3MF_test/Web3D.pack/libman.json @@ -1,17 +1,17 @@ { "version": "1.0", "defaultProvider": "filesystem", - "libraries": [ - { - "library": "C:\\Users\\zaccaria.majid\\Downloads\\package", - "destination": "wwwroot/lib/package/" - }, - { - "library": "C:\\Users\\zaccaria.majid\\Downloads\\", - "destination": "wwwroot/lib/Downloads/", - "files": [ - "webgl-visualizer-1.1.230926-beta.842.tgz" - ] - } - ] + //"libraries": [ + // { + // "library": "C:\\Users\\zaccaria.majid\\Downloads\\package", + // "destination": "wwwroot/lib/package/" + // }, + // { + // "library": "C:\\Users\\zaccaria.majid\\Downloads\\", + // "destination": "wwwroot/lib/Downloads/", + // "files": [ + // "webgl-visualizer-1.1.230926-beta.842.tgz" + // ] + // } + //] } \ No newline at end of file diff --git a/IcarusView/3MF_test/Web3D.pack/wwwroot/lib/node_modules/webgl-visualizer/styles/LogoClassic_NoText.png b/IcarusView/3MF_test/Web3D.pack/wwwroot/images/LogoClassic_NoText.png similarity index 100% rename from IcarusView/3MF_test/Web3D.pack/wwwroot/lib/node_modules/webgl-visualizer/styles/LogoClassic_NoText.png rename to IcarusView/3MF_test/Web3D.pack/wwwroot/images/LogoClassic_NoText.png diff --git a/IcarusView/3MF_test/Web3D.pack/wwwroot/lib/node_modules/webgl-visualizer/draw/webgl_draw.js b/IcarusView/3MF_test/Web3D.pack/wwwroot/lib/node_modules/webgl-visualizer/draw/webgl_draw.js index 8100234..4ad078e 100644 --- a/IcarusView/3MF_test/Web3D.pack/wwwroot/lib/node_modules/webgl-visualizer/draw/webgl_draw.js +++ b/IcarusView/3MF_test/Web3D.pack/wwwroot/lib/node_modules/webgl-visualizer/draw/webgl_draw.js @@ -316,45 +316,45 @@ function AdaptSeceneToContest() { window.addEventListener('resize', onWindowResize); // calcolo origine - const points_array = [ new THREE.Vector3( 0, 0, 0)] ; - var ORIG_Geometry = new THREE.BufferGeometry() ; - ORIG_Geometry.setFromPoints( points_array) ; - var ORIG_Material = new THREE.PointsMaterial({ size: 5, sizeAttenuation : true, color : new THREE.Color( 0x000000)}); - ORIG = new THREE.Points( ORIG_Geometry, ORIG_Material) ; - SetOrig( ORIG) ; - - // creazione sistema di riferimento nell'origine - const axesHelper = new THREE.AxesHelper( 75 ) ; - axesHelper.rotation.set( -Math.PI/2, 0 ,0) ; - axesHelper.position.set( ORIG.position.x, ORIG.position.y, ORIG.position.z) ; - scene.add( axesHelper ); - - // creazione della griglia (V1 = finita, V2 = infinita) - const size = 1000000 ; - const divisions = 10000 ; - if ( ! m_bGrid_v1) { - // GRIGLIA INFINITA - const gridHelper = new THREE.GridHelper( size, divisions) ; - gridHelper.position.set( ORIG.position.x, ORIG.position.y, ORIG.position.z) ; - gridHelper.material.transparent = true ; - gridHelper.material.opacity = 0.25 ; - setFog() ; - scene.add( gridHelper) ; - } - else { - // GRIGLIA FINITA - // prendo dimensione del Box - var dDimX = Math.abs( GLBox3D.max.x - GLBox3D.min.x) ; - var dDimY = Math.abs( GLBox3D.max.y - GLBox3D.min.y) ; - var dDimZ = Math.abs( GLBox3D.max.z - GLBox3D.min.z) ; - var dDim = 1.5 * Math.sqrt( dDimX * dDimX + dDimY * dDimY + dDimZ * dDimZ) ; - const gridHelper = new THREE.GridHelper( dDim, Math.ceil( 0.1 * dDim)) ; - gridHelper.position.set( ORIG.position.x + 0.5 * dDim , ORIG.position.y, ORIG.position.z - 0.5 * dDim) ; - gridHelper.material.transparent = true ; - gridHelper.material.opacity = 0.45 ; - scene.add( gridHelper) ; - - } + const points_array = [ new THREE.Vector3( 0, 0, 0)] ; + var ORIG_Geometry = new THREE.BufferGeometry() ; + ORIG_Geometry.setFromPoints( points_array) ; + var ORIG_Material = new THREE.PointsMaterial({ size: 5, sizeAttenuation : true, color : new THREE.Color( 0x000000)}); + ORIG = new THREE.Points( ORIG_Geometry, ORIG_Material) ; + SetOrig( ORIG) ; + + // creazione sistema di riferimento nell'origine + const axesHelper = new THREE.AxesHelper( 75 ) ; + axesHelper.rotation.set( -Math.PI/2, 0 ,0) ; + axesHelper.position.set( ORIG.position.x, ORIG.position.y, ORIG.position.z) ; + scene.add( axesHelper ); + + // creazione della griglia (V1 = finita, V2 = infinita) + const size = 1000000 ; + const divisions = 10000 ; + if ( ! m_bGrid_v1) { + // GRIGLIA INFINITA + const gridHelper = new THREE.GridHelper( size, divisions) ; + gridHelper.position.set( ORIG.position.x, ORIG.position.y, ORIG.position.z) ; + gridHelper.material.transparent = true ; + gridHelper.material.opacity = 0.25 ; + setFog() ; + scene.add( gridHelper) ; + } + else { + // GRIGLIA FINITA + // prendo dimensione del Box + var dDimX = Math.abs( GLBox3D.max.x - GLBox3D.min.x) ; + var dDimY = Math.abs( GLBox3D.max.y - GLBox3D.min.y) ; + var dDimZ = Math.abs( GLBox3D.max.z - GLBox3D.min.z) ; + var dDim = 1.5 * Math.sqrt( dDimX * dDimX + dDimY * dDimY + dDimZ * dDimZ) ; + const gridHelper = new THREE.GridHelper( dDim, Math.ceil( 0.1 * dDim)) ; + gridHelper.position.set( ORIG.position.x + 0.5 * dDim , ORIG.position.y, ORIG.position.z - 0.5 * dDim) ; + gridHelper.material.transparent = true ; + gridHelper.material.opacity = 0.45 ; + scene.add( gridHelper) ; + + } render(); diff --git a/IcarusView/3MF_test/Web3D.pack/wwwroot/lib/node_modules/webgl-visualizer/draw/webgl_drawCS.js b/IcarusView/3MF_test/Web3D.pack/wwwroot/lib/node_modules/webgl-visualizer/draw/webgl_drawCS.js index 01296b3..0ab08c3 100644 --- a/IcarusView/3MF_test/Web3D.pack/wwwroot/lib/node_modules/webgl-visualizer/draw/webgl_drawCS.js +++ b/IcarusView/3MF_test/Web3D.pack/wwwroot/lib/node_modules/webgl-visualizer/draw/webgl_drawCS.js @@ -127,7 +127,7 @@ function setLoaders() { cDiv[i].style.border = '#afc5d6'; cDiv[i].style.backgroundSize = 'contain'; - cDiv[i].style.backgroundImage = 'url(~/styles/LogoClassic_NoText.png)' + cDiv[i].style.backgroundImage = 'url(images/LogoClassic_NoText.png)' } } @@ -151,7 +151,7 @@ function init() { let startTime = performance.now(); return new Promise(() => { setTimeout(() => { - loader.load('~/models/3mf/' + fName, function (object) { + loader.load('3mf/' + fName, function (object) { object.rotation.set(-Math.PI / 2, 0, 0); object.traverse(function (child) { child.castShadow = true;