├── .github └── workflows │ ├── Blazor3DRelease.yml │ └── blazor3d_component.yml ├── .gitignore ├── LICENSE ├── README.md ├── doc ├── Blazor3D.xml └── HomagGroup.Blazor3D.xml ├── gfx └── Logo │ ├── Blazor3D-Inkscape.svg │ ├── blazor3d.blend │ ├── blazor3d.blend1 │ ├── blazor3d.glb │ ├── blazor3d.gltf │ └── blazor3d.svg └── src ├── dotnet ├── Blazor3D.Web │ ├── .dockerignore │ ├── Blazor3D.Web.sln │ ├── Blazor3D.Web │ │ ├── Areas │ │ │ └── Identity │ │ │ │ └── Pages │ │ │ │ └── _ViewStart.cshtml │ │ ├── Blazor3D.Web.csproj │ │ ├── Controllers │ │ │ ├── HomeController.cs │ │ │ └── ReferenceController.cs │ │ ├── Data │ │ │ └── ApplicationDbContext.cs │ │ ├── Dockerfile │ │ ├── Migrations │ │ │ ├── 20220708070619_Initial.Designer.cs │ │ │ ├── 20220708070619_Initial.cs │ │ │ └── ApplicationDbContextModelSnapshot.cs │ │ ├── Models │ │ │ └── ErrorViewModel.cs │ │ ├── Program.cs │ │ ├── Properties │ │ │ ├── launchSettings.json │ │ │ ├── serviceDependencies.json │ │ │ └── serviceDependencies.local.json │ │ ├── Templates │ │ │ └── Index.html │ │ ├── Views │ │ │ ├── Home │ │ │ │ ├── GettingStarted.cshtml │ │ │ │ ├── Index.cshtml │ │ │ │ ├── Privacy.cshtml │ │ │ │ └── Tutorials.cshtml │ │ │ ├── Shared │ │ │ │ ├── Error.cshtml │ │ │ │ ├── _Layout.cshtml │ │ │ │ ├── _Layout.cshtml.css │ │ │ │ ├── _LayoutMain.cshtml │ │ │ │ ├── _LayoutMain.cshtml.css │ │ │ │ ├── _LoginPartial.cshtml │ │ │ │ └── _ValidationScriptsPartial.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ └── _ViewStart.cshtml │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── blazor3dweb.db │ │ ├── blazor3dweb.db-shm │ │ ├── blazor3dweb.db-wal │ │ └── wwwroot │ │ │ ├── about.txt │ │ │ ├── android-chrome-192x192.png │ │ │ ├── android-chrome-512x512.png │ │ │ ├── apple-touch-icon.png │ │ │ ├── blazor3d.svg │ │ │ ├── css │ │ │ └── site.css │ │ │ ├── favicon-16x16.png │ │ │ ├── favicon-32x32.png │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ └── site.js │ │ │ ├── lib │ │ │ ├── bootstrap │ │ │ │ ├── LICENSE │ │ │ │ └── dist │ │ │ │ │ ├── css │ │ │ │ │ ├── bootstrap-grid.css │ │ │ │ │ ├── bootstrap-grid.css.map │ │ │ │ │ ├── bootstrap-grid.min.css │ │ │ │ │ ├── bootstrap-grid.min.css.map │ │ │ │ │ ├── bootstrap-grid.rtl.css │ │ │ │ │ ├── bootstrap-grid.rtl.css.map │ │ │ │ │ ├── bootstrap-grid.rtl.min.css │ │ │ │ │ ├── bootstrap-grid.rtl.min.css.map │ │ │ │ │ ├── bootstrap-reboot.css │ │ │ │ │ ├── bootstrap-reboot.css.map │ │ │ │ │ ├── bootstrap-reboot.min.css │ │ │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ │ │ ├── bootstrap-reboot.rtl.css │ │ │ │ │ ├── bootstrap-reboot.rtl.css.map │ │ │ │ │ ├── bootstrap-reboot.rtl.min.css │ │ │ │ │ ├── bootstrap-reboot.rtl.min.css.map │ │ │ │ │ ├── bootstrap-utilities.css │ │ │ │ │ ├── bootstrap-utilities.css.map │ │ │ │ │ ├── bootstrap-utilities.min.css │ │ │ │ │ ├── bootstrap-utilities.min.css.map │ │ │ │ │ ├── bootstrap-utilities.rtl.css │ │ │ │ │ ├── bootstrap-utilities.rtl.css.map │ │ │ │ │ ├── bootstrap-utilities.rtl.min.css │ │ │ │ │ ├── bootstrap-utilities.rtl.min.css.map │ │ │ │ │ ├── bootstrap.css │ │ │ │ │ ├── bootstrap.css.map │ │ │ │ │ ├── bootstrap.min.css │ │ │ │ │ ├── bootstrap.min.css.map │ │ │ │ │ ├── bootstrap.rtl.css │ │ │ │ │ ├── bootstrap.rtl.css.map │ │ │ │ │ ├── bootstrap.rtl.min.css │ │ │ │ │ └── bootstrap.rtl.min.css.map │ │ │ │ │ └── js │ │ │ │ │ ├── bootstrap.bundle.js │ │ │ │ │ ├── bootstrap.bundle.js.map │ │ │ │ │ ├── bootstrap.bundle.min.js │ │ │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ │ │ ├── bootstrap.esm.js │ │ │ │ │ ├── bootstrap.esm.js.map │ │ │ │ │ ├── bootstrap.esm.min.js │ │ │ │ │ ├── bootstrap.esm.min.js.map │ │ │ │ │ ├── bootstrap.js │ │ │ │ │ ├── bootstrap.js.map │ │ │ │ │ ├── bootstrap.min.js │ │ │ │ │ └── bootstrap.min.js.map │ │ │ ├── jquery-validation-unobtrusive │ │ │ │ ├── LICENSE.txt │ │ │ │ ├── jquery.validate.unobtrusive.js │ │ │ │ └── jquery.validate.unobtrusive.min.js │ │ │ ├── jquery-validation │ │ │ │ ├── LICENSE.md │ │ │ │ └── dist │ │ │ │ │ ├── additional-methods.js │ │ │ │ │ ├── additional-methods.min.js │ │ │ │ │ ├── jquery.validate.js │ │ │ │ │ └── jquery.validate.min.js │ │ │ └── jquery │ │ │ │ ├── LICENSE.txt │ │ │ │ └── dist │ │ │ │ ├── jquery.js │ │ │ │ ├── jquery.min.js │ │ │ │ └── jquery.min.map │ │ │ ├── reference │ │ │ ├── Blazor3D.Cameras.Camera.html │ │ │ ├── Blazor3D.Cameras.OrthographicCamera.html │ │ │ ├── Blazor3D.Cameras.PerspectiveCamera.html │ │ │ ├── Blazor3D.Controls.OrbitControls.html │ │ │ ├── Blazor3D.Core.BufferGeometry.html │ │ │ ├── Blazor3D.Core.Object3D.html │ │ │ ├── Blazor3D.Enums.Import3DFormats.html │ │ │ ├── Blazor3D.Events.LoadedModuleEventHandler.html │ │ │ ├── Blazor3D.Events.LoadedObjectEventHandler.html │ │ │ ├── Blazor3D.Events.Object3DArgs.html │ │ │ ├── Blazor3D.Events.SelectedObjectEventHandler.html │ │ │ ├── Blazor3D.Geometires.BoxGeometry.html │ │ │ ├── Blazor3D.Geometires.CapsuleGeometry.html │ │ │ ├── Blazor3D.Geometires.CircleGeometry.html │ │ │ ├── Blazor3D.Geometires.ConeGeometry.html │ │ │ ├── Blazor3D.Geometires.CylinderGeometry.html │ │ │ ├── Blazor3D.Geometires.DodecahedronGeometry.html │ │ │ ├── Blazor3D.Geometires.IcosahedronGeometry.html │ │ │ ├── Blazor3D.Geometires.OctahedronGeometry.html │ │ │ ├── Blazor3D.Geometires.PlaneGeometry.html │ │ │ ├── Blazor3D.Geometires.RingGeometry.html │ │ │ ├── Blazor3D.Geometires.SphereGeometry.html │ │ │ ├── Blazor3D.Geometires.TetrahedronGeometry.html │ │ │ ├── Blazor3D.Geometires.TorusGeometry.html │ │ │ ├── Blazor3D.Geometires.TorusKnotGeometry.html │ │ │ ├── Blazor3D.Helpers.ArrowHelper.html │ │ │ ├── Blazor3D.Helpers.AxesHelper.html │ │ │ ├── Blazor3D.Helpers.BoxHelper.html │ │ │ ├── Blazor3D.Helpers.GridHelper.html │ │ │ ├── Blazor3D.Helpers.PlaneHelper.html │ │ │ ├── Blazor3D.Helpers.PointLightHelper.html │ │ │ ├── Blazor3D.Helpers.PolarGridHelper.html │ │ │ ├── Blazor3D.Lights.AmbientLight.html │ │ │ ├── Blazor3D.Lights.Light.html │ │ │ ├── Blazor3D.Lights.PointLight.html │ │ │ ├── Blazor3D.Materials.Material.html │ │ │ ├── Blazor3D.Materials.MeshStandardMaterial.html │ │ │ ├── Blazor3D.Maths.Euler.html │ │ │ ├── Blazor3D.Maths.Plane.html │ │ │ ├── Blazor3D.Maths.Vector3.html │ │ │ ├── Blazor3D.Objects.Group.html │ │ │ ├── Blazor3D.Objects.Mesh.html │ │ │ ├── Blazor3D.Scenes.Scene.html │ │ │ ├── Blazor3D.Settings.AnimateRotationSettings.html │ │ │ ├── Blazor3D.Settings.ImportSettings.html │ │ │ ├── Blazor3D.Settings.ViewerSettings.html │ │ │ ├── Blazor3D.Settings.WebGLRendererSettings.html │ │ │ ├── Blazor3D.Viewers.Viewer.html │ │ │ └── Index.html │ │ │ └── site.webmanifest │ ├── ReferenceGenerator │ │ ├── Extensions │ │ │ └── ParserExtensions.cs │ │ ├── HtmlGenerator.cs │ │ ├── Models │ │ │ ├── BaseModel.cs │ │ │ ├── ConstructorModel.cs │ │ │ ├── ErrorViewModel.cs │ │ │ ├── EventModel.cs │ │ │ ├── FieldModel.cs │ │ │ ├── MethodModel.cs │ │ │ ├── Param.cs │ │ │ ├── PropertyModel.cs │ │ │ ├── ReferenceModel.cs │ │ │ └── TypeModel.cs │ │ ├── Parser.cs │ │ ├── ReferenceGenerator.csproj │ │ ├── Settings │ │ │ └── TemplateSettings.cs │ │ └── Utils │ │ │ ├── BreadCrumbsFactory.cs │ │ │ └── PathCombiner.cs │ └── Todo.txt └── Blazor3D │ ├── Blazor3D.Tests │ ├── Cameras │ │ ├── OrthographicCameraTests.cs │ │ └── PerspectiveCameraTests.cs │ ├── Helpers │ │ ├── ArrowHelperTests.cs │ │ ├── AxesHelperTests.cs │ │ ├── BoxHelperTests.cs │ │ ├── GridHelperTests.cs │ │ ├── PlaneHelperTests.cs │ │ ├── PointLightHelperTests.cs │ │ └── PolarGridHelperTests.cs │ ├── HomagGroup.Blazor3D.Tests.csproj │ ├── Settings │ │ └── AnimateRotationSettingsTests.cs │ └── Usings.cs │ ├── Blazor3D.sln │ ├── Blazor3D │ ├── Cameras │ │ ├── Camera.cs │ │ ├── OrthographicCamera.cs │ │ └── PerspectiveCamera.cs │ ├── ComponentHelpers │ │ ├── ChildrenHelper.cs │ │ └── SerializationHelper.cs │ ├── Controls │ │ └── OrbitControls.cs │ ├── Core │ │ ├── BufferGeometry.cs │ │ └── Object3D.cs │ ├── Enums │ │ ├── ImportModels.cs │ │ ├── Lines │ │ │ ├── LineCap.cs │ │ │ └── LineJoin.cs │ │ └── WrappingType.cs │ ├── Events │ │ ├── LoadedModuleEventHandler.cs │ │ ├── LoadedObjectEventHandler.cs │ │ ├── Object3DArgs.cs │ │ └── SelectedObjectEventHandler.cs │ ├── Extras │ │ └── Core │ │ │ └── Shape.cs │ ├── Geometires │ │ ├── BoxGeometry.cs │ │ ├── CapsuleGeometry.cs │ │ ├── CircleGeometry.cs │ │ ├── ConeGeometry.cs │ │ ├── Curves │ │ │ └── SplineCurveGeometry.cs │ │ ├── CylinderGeometry.cs │ │ ├── DodecahedronGeometry.cs │ │ ├── ExtrudeGeometry.cs │ │ ├── ExtrudeGeometryOptions.cs │ │ ├── IcosahedronGeometry.cs │ │ ├── Lines │ │ │ └── LineGeometry.cs │ │ ├── OctahedronGeometry.cs │ │ ├── PlaneGeometry.cs │ │ ├── RingGeometry.cs │ │ ├── ShapeGeometry.cs │ │ ├── SphereGeometry.cs │ │ ├── TetrahedronGeometry.cs │ │ ├── Text │ │ │ ├── TextExtrudeGeometry.cs │ │ │ ├── TextShapeGeometry.cs │ │ │ └── TextStrokeGeometry.cs │ │ ├── TorusGeometry.cs │ │ └── TorusKnotGeometry.cs │ ├── Helpers │ │ ├── ArrowHelper.cs │ │ ├── AxesHelper.cs │ │ ├── BoxHelper.cs │ │ ├── GridHelper.cs │ │ ├── PlaneHelper.cs │ │ ├── PointLightHelper.cs │ │ └── PolarGridHelper.cs │ ├── HomagGroup.Blazor3D.csproj │ ├── Lights │ │ ├── AmbientLight.cs │ │ ├── Light.cs │ │ └── PointLight.cs │ ├── Materials │ │ ├── LineBasicMaterial.cs │ │ ├── Material.cs │ │ ├── MeshStandardMaterial.cs │ │ └── SpriteMaterial.cs │ ├── Maths │ │ ├── Euler.cs │ │ ├── Plane.cs │ │ ├── Vector2.cs │ │ └── Vector3.cs │ ├── Objects │ │ ├── Group.cs │ │ ├── Line.cs │ │ ├── Mesh.cs │ │ ├── Sprite.cs │ │ └── Text.cs │ ├── Scenes │ │ └── Scene.cs │ ├── Settings │ │ ├── AnimateObject3DSettings.cs │ │ ├── AnimateRotationSettings.cs │ │ ├── ImportSettings.cs │ │ ├── SpriteImportSettings.cs │ │ ├── ViewerSettings.cs │ │ └── WebGLRendererSettings.cs │ ├── Textures │ │ └── Texture.cs │ ├── Viewers │ │ ├── Viewer.razor │ │ ├── Viewer.razor.cs │ │ └── Viewer.razor.css │ ├── _Imports.razor │ └── wwwroot │ │ └── js │ │ ├── bundle.js │ │ ├── bundle.js.LICENSE.txt │ │ └── bundle.js.map │ ├── TestServer │ ├── App.razor │ ├── Pages │ │ ├── Error.cshtml │ │ ├── Error.cshtml.cs │ │ ├── Index.razor │ │ ├── Page2.razor │ │ ├── Page3.razor │ │ ├── Page4.razor │ │ ├── Page5.razor │ │ ├── Page6.razor │ │ ├── Page7.razor │ │ ├── _Host.cshtml │ │ └── _Layout.cshtml │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── TestServer.csproj │ ├── _Imports.razor │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ ├── css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ ├── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ │ ├── css │ │ │ │ └── open-iconic-bootstrap.min.css │ │ │ │ └── fonts │ │ │ │ ├── open-iconic.eot │ │ │ │ ├── open-iconic.otf │ │ │ │ ├── open-iconic.svg │ │ │ │ ├── open-iconic.ttf │ │ │ │ └── open-iconic.woff │ │ └── site.css │ │ ├── favicon.ico │ │ ├── fonts │ │ └── helvetiker_regular.typeface.json │ │ ├── images │ │ └── Blazor.png │ │ └── uv_grid_opengl.jpg │ ├── TestWebAsm │ ├── App.razor │ ├── Pages │ │ └── Index.razor │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── TestWebAsm.csproj │ ├── _Imports.razor │ └── wwwroot │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ ├── icon-192.png │ │ └── index.html │ └── Todo.txt └── javascript ├── Builders ├── CameraBuilder.js ├── GeometryBuilder.js ├── GroupBuilder.js ├── HelperBuilder.js ├── LightBuilder.js ├── LineBuilder.js ├── MaterialBuilder.js ├── MeshBuilder.js ├── SceneBuilder.js ├── SpriteBuilder.js ├── TextBuilder.js ├── TextGeometryBuilder.js └── TextureBuilder.js ├── Utils └── Transforms.js ├── Viewer ├── Exporters.js ├── Loaders.js └── Viewer3D.js ├── index.js ├── package-lock.json ├── package.json └── webpack.config.js /.github/workflows/Blazor3DRelease.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | tags: 4 | - "v[0-9]+.[0-9]+.[0-9]+" 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | timeout-minutes: 15 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | - name: Verify commit exists in origin/main 13 | run: | 14 | git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* 15 | git branch --remote --contains | grep origin/main 16 | - name: Set VERSION variable from tag 17 | run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV 18 | - name: Build 19 | run: dotnet build --configuration Release /p:Version=${VERSION} ./src/dotnet/Blazor3D/Blazor3D.sln 20 | #- name: Test 21 | # run: dotnet test --configuration Release /p:Version=${VERSION} --no-build 22 | - name: Pack 23 | run: dotnet pack --configuration Release /p:Version=${VERSION} --no-build --output . ./src/dotnet/Blazor3D/Blazor3D.sln 24 | - name: Push 25 | run: dotnet nuget push Blazor3D.${VERSION}.nupkg --api-key ${NUGET_TOKEN} --source https://api.nuget.org/v3/index.json 26 | env: 27 | NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }} 28 | -------------------------------------------------------------------------------- /.github/workflows/blazor3d_component.yml: -------------------------------------------------------------------------------- 1 | name: Blazor3D 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v2 18 | with: 19 | dotnet-version: 6.0.x 20 | - name: Restore dependencies 21 | run: dotnet restore ./src/dotnet/Blazor3D/Blazor3D.sln 22 | - name: Build 23 | run: dotnet build --no-restore ./src/dotnet/Blazor3D/Blazor3D.sln 24 | - name: test 25 | run: dotnet test --no-build --verbosity normal ./src/dotnet/Blazor3D/Blazor3D.sln 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-2023 Roman Simuta 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blazor3D-Core 2 | Blazor component that displays 3D things :) 3 | 4 | Blazor + ThreeJS = Blazor3D 5 | 6 | You can find the documentation and examples of using Blazor3D [here](https://github.com/HomagGroup/Blazor3D) 7 | 8 | ## Build Instructions 9 | ### Build the Javascript bundle using webpack 10 | * From a node.js command prompt, navigate to `Blazor3D-Core\src\javascript` 11 | * Run `npx webpack --mode production` 12 | * A `bundle.js` will be created inside `Blazor3D-Core\src\dotnet\Blazor3D\Blazor3D\wwwroot\js` which Blazor can reference 13 | 14 | ### Build the dotnet assembly 15 | * Build the csproj from VSCode or Visual Studio 16 | * `dotnet pack` to package into a `nupkg` -------------------------------------------------------------------------------- /gfx/Logo/blazor3d.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/gfx/Logo/blazor3d.blend -------------------------------------------------------------------------------- /gfx/Logo/blazor3d.blend1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/gfx/Logo/blazor3d.blend1 -------------------------------------------------------------------------------- /gfx/Logo/blazor3d.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/gfx/Logo/blazor3d.glb -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32616.157 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazor3D.Web", "Blazor3D.Web\Blazor3D.Web.csproj", "{89E3D180-80E3-4096-9C2F-0CCB76146CEC}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReferenceGenerator", "ReferenceGenerator\ReferenceGenerator.csproj", "{277A8BB3-3EDB-4F59-BFEF-D0A2D83EB7E6}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{50951ED3-CAAC-4F74-80EC-816C5CDA2112}" 11 | ProjectSection(SolutionItems) = preProject 12 | Todo.txt = Todo.txt 13 | EndProjectSection 14 | EndProject 15 | Global 16 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 17 | Debug|Any CPU = Debug|Any CPU 18 | Release|Any CPU = Release|Any CPU 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {89E3D180-80E3-4096-9C2F-0CCB76146CEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {89E3D180-80E3-4096-9C2F-0CCB76146CEC}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {89E3D180-80E3-4096-9C2F-0CCB76146CEC}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {89E3D180-80E3-4096-9C2F-0CCB76146CEC}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {277A8BB3-3EDB-4F59-BFEF-D0A2D83EB7E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {277A8BB3-3EDB-4F59-BFEF-D0A2D83EB7E6}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {277A8BB3-3EDB-4F59-BFEF-D0A2D83EB7E6}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {277A8BB3-3EDB-4F59-BFEF-D0A2D83EB7E6}.Release|Any CPU.Build.0 = Release|Any CPU 29 | EndGlobalSection 30 | GlobalSection(SolutionProperties) = preSolution 31 | HideSolutionNode = FALSE 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {981DCC82-F78F-4F65-9D98-E0069D965559} 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Areas/Identity/Pages/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Blazor3D.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | aspnet-Blazor3D.Web-2ED8FB4E-D473-438D-B544-D5600D703B72 8 | Linux 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Always 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using Blazor3D.Web.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | using System.Diagnostics; 4 | 5 | namespace Blazor3D.Web.Controllers 6 | { 7 | public class HomeController : Controller 8 | { 9 | private readonly ILogger _logger; 10 | 11 | public HomeController(ILogger logger) 12 | { 13 | _logger = logger; 14 | } 15 | 16 | public IActionResult Index() 17 | { 18 | ViewData["Title"] = "Blazor3D"; 19 | return View(); 20 | } 21 | 22 | public IActionResult Tutorials() 23 | { 24 | ViewData["Title"] = "Blazor3D Tutorials"; 25 | return View(); 26 | } 27 | 28 | public IActionResult GettingStarted() 29 | { 30 | ViewData["Title"] = "Blazor3D Getting Started tutorial"; 31 | return View(); 32 | } 33 | 34 | public IActionResult Privacy() 35 | { 36 | ViewData["Title"] = "Privacy"; 37 | return View(); 38 | } 39 | 40 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 41 | public IActionResult Error() 42 | { 43 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Controllers/ReferenceController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using ReferenceGenerator; 4 | using ReferenceGenerator.Models; 5 | using ReferenceGenerator.Utils; 6 | 7 | namespace Blazor3D.Web.Controllers 8 | { 9 | public class ReferenceController : Controller 10 | { 11 | private readonly IWebHostEnvironment _hostEnvironment; 12 | public ReferenceController(IWebHostEnvironment hostEnvironment) 13 | { 14 | _hostEnvironment = hostEnvironment; 15 | } 16 | 17 | // POST: ReferenceController/Create 18 | [HttpPost] 19 | [ValidateAntiForgeryToken] 20 | public async Task Generate(IFormCollection collection) 21 | { 22 | try 23 | { 24 | var parser = new Parser(); 25 | parser.ReadAndParse(); 26 | 27 | var generator = new HtmlGenerator(); 28 | var refPath = PathCombiner.Combine(_hostEnvironment.WebRootPath, "/reference/"); 29 | var templatePath = PathCombiner.Combine(Directory.GetCurrentDirectory(), "\\Templates\\Index.html"); 30 | await generator.Generate(parser.Reference, refPath, templatePath); 31 | return Redirect("/reference/Index.html"); 32 | } 33 | catch 34 | { 35 | return View(); 36 | } 37 | } 38 | 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Data/ApplicationDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | 4 | namespace Blazor3D.Web.Data 5 | { 6 | public class ApplicationDbContext : IdentityDbContext 7 | { 8 | public ApplicationDbContext(DbContextOptions options) 9 | : base(options) 10 | { 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Dockerfile: -------------------------------------------------------------------------------- 1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. 2 | 3 | FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base 4 | WORKDIR /app 5 | EXPOSE 80 6 | EXPOSE 443 7 | 8 | FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build 9 | WORKDIR /src 10 | COPY ["Blazor3D.Web/Blazor3D.Web.csproj", "Blazor3D.Web/"] 11 | RUN dotnet restore "Blazor3D.Web/Blazor3D.Web.csproj" 12 | COPY . . 13 | WORKDIR "/src/Blazor3D.Web" 14 | RUN dotnet build "Blazor3D.Web.csproj" -c Release -o /app/build 15 | 16 | FROM build AS publish 17 | RUN dotnet publish "Blazor3D.Web.csproj" -c Release -o /app/publish 18 | 19 | FROM base AS final 20 | WORKDIR /app 21 | COPY --from=publish /app/publish . 22 | ENTRYPOINT ["dotnet", "Blazor3D.Web.dll"] -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace Blazor3D.Web.Models 2 | { 3 | public class ErrorViewModel 4 | { 5 | public string? RequestId { get; set; } 6 | 7 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 8 | } 9 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Program.cs: -------------------------------------------------------------------------------- 1 | using Blazor3D.Web.Data; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | 7 | // Add services to the container. 8 | var connectionString = builder.Configuration.GetConnectionString("DefaultConnection"); 9 | builder.Services.AddDbContext(options => 10 | //options.UseSqlServer(connectionString) 11 | options.UseSqlite(connectionString) 12 | ); 13 | builder.Services.AddDatabaseDeveloperPageExceptionFilter(); 14 | 15 | builder.Services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true) 16 | .AddEntityFrameworkStores(); 17 | builder.Services.AddControllersWithViews(); 18 | 19 | var app = builder.Build(); 20 | 21 | // Configure the HTTP request pipeline. 22 | if (app.Environment.IsDevelopment()) 23 | { 24 | app.UseMigrationsEndPoint(); 25 | } 26 | else 27 | { 28 | app.UseExceptionHandler("/Home/Error"); 29 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 30 | app.UseHsts(); 31 | } 32 | 33 | app.UseHttpsRedirection(); 34 | app.UseStaticFiles(); 35 | 36 | app.UseRouting(); 37 | 38 | app.UseAuthentication(); 39 | app.UseAuthorization(); 40 | 41 | app.MapControllerRoute( 42 | name: "default", 43 | pattern: "{controller=Home}/{action=Index}/{id?}"); 44 | app.MapRazorPages(); 45 | 46 | app.Run(); 47 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:32599", 7 | "sslPort": 44348 8 | } 9 | }, 10 | "profiles": { 11 | "Blazor3D.Web": { 12 | "commandName": "Project", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | }, 17 | "applicationUrl": "https://localhost:7146;http://localhost:5146", 18 | "dotnetRunMessages": true 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | }, 27 | "Docker": { 28 | "commandName": "Docker", 29 | "launchBrowser": true, 30 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 31 | "publishAllPorts": true, 32 | "useSSL": true 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql", 5 | "connectionId": "ConnectionStrings:DefaultConnection" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql.local", 5 | "connectionId": "ConnectionStrings:DefaultConnection" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/Home/GettingStarted.cshtml: -------------------------------------------------------------------------------- 1 | 

Getting started with Blazor3D. WebAssembly project.

2 |

1 Create Blazor WebAssembly project

3 |
4 |
5 |

Use .NET command-line inteface (CLI) to create Blazor WebAssembly project

6 |
dotnet new blazorwasm -o Blazor3D.GettingStarted
7 |

Open project using IDE of your choice. In this tutorial the Visual Studio Code used.

8 |
9 |
-------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_LayoutMain"; 3 | } 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/Home/Tutorials.cshtml: -------------------------------------------------------------------------------- 1 | 

Blazor3D tutorials

2 |
3 |
4 | 9 |
10 |
11 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/Shared/_Layout.cshtml.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | a { 11 | color: #0077cc; 12 | } 13 | 14 | .btn-primary { 15 | color: #fff; 16 | background-color: #1b6ec2; 17 | border-color: #1861ac; 18 | } 19 | 20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 21 | color: #fff; 22 | background-color: #1b6ec2; 23 | border-color: #1861ac; 24 | } 25 | 26 | .border-top { 27 | border-top: 1px solid #e5e5e5; 28 | } 29 | .border-bottom { 30 | border-bottom: 1px solid #e5e5e5; 31 | } 32 | 33 | .box-shadow { 34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 35 | } 36 | 37 | button.accept-policy { 38 | font-size: 1rem; 39 | line-height: inherit; 40 | } 41 | 42 | .footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | white-space: nowrap; 47 | line-height: 60px; 48 | } 49 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/Shared/_LayoutMain.cshtml.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | a { 11 | color: #0077cc; 12 | } 13 | 14 | .btn-primary { 15 | color: #fff; 16 | background-color: #1b6ec2; 17 | border-color: #1861ac; 18 | } 19 | 20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 21 | color: #fff; 22 | background-color: #1b6ec2; 23 | border-color: #1861ac; 24 | } 25 | 26 | .border-top { 27 | border-top: 1px solid #e5e5e5; 28 | } 29 | .border-bottom { 30 | border-bottom: 1px solid #e5e5e5; 31 | } 32 | 33 | .box-shadow { 34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 35 | } 36 | 37 | button.accept-policy { 38 | font-size: 1rem; 39 | line-height: inherit; 40 | } 41 | 42 | .footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | white-space: nowrap; 47 | line-height: 60px; 48 | } 49 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/Shared/_LoginPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Identity 2 | @inject SignInManager SignInManager 3 | @inject UserManager UserManager 4 | 5 | 27 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Blazor3D.Web 2 | @using Blazor3D.Web.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | //"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-Blazor3D.Web-2ED8FB4E-D473-438D-B544-D5600D703B71;Trusted_Connection=True;MultipleActiveResultSets=true" 4 | "DefaultConnection": "Data Source=blazor3dweb.db" 5 | }, 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft.AspNetCore": "Warning" 10 | } 11 | }, 12 | "AllowedHosts": "*" 13 | } 14 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/blazor3dweb.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D.Web/Blazor3D.Web/blazor3dweb.db -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/blazor3dweb.db-shm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D.Web/Blazor3D.Web/blazor3dweb.db-shm -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/blazor3dweb.db-wal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D.Web/Blazor3D.Web/blazor3dweb.db-wal -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/about.txt: -------------------------------------------------------------------------------- 1 | This favicon was generated using the following font: 2 | 3 | - Font Title: Kufam 4 | - Font Author: Copyright 2019 The Kufam Project Authors (https://github.com/originaltype/kufam) 5 | - Font Source: http://fonts.gstatic.com/s/kufam/v19/C8c-4cY7pG7w_oSJDszBXsKCcBH3SK47qQCJHvIwYg.ttf 6 | - Font License: SIL Open Font License, 1.1 (http://scripts.sil.org/OFL)) 7 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/android-chrome-192x192.png -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/android-chrome-512x512.png -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/apple-touch-icon.png -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-size: 14px; 3 | } 4 | 5 | 6 | 7 | html { 8 | position: relative; 9 | min-height: 100%; 10 | } 11 | 12 | body { 13 | margin-bottom: 60px; 14 | } 15 | 16 | a, .nav-link, .btn-link { 17 | color: tomato; 18 | font-weight: 400; 19 | } 20 | 21 | a:hover, .nav-link:hover, .btn-link:hover { 22 | color: black; 23 | } 24 | b, strong { 25 | font-weight: 500; 26 | } 27 | 28 | .fontlight { 29 | font-weight: 400; 30 | } 31 | 32 | .referenceNav { 33 | line-height: 1rem; 34 | } 35 | 36 | .refNavLink { 37 | padding: 0.3rem 1rem; 38 | } 39 | 40 | .topOffset { 41 | padding-top: 5rem; 42 | } 43 | 44 | .btmOffset { 45 | padding-bottom: 2rem; 46 | } 47 | 48 | .blazor3d { 49 | width:36px; 50 | margin:5px; 51 | 52 | } 53 | 54 | .navbar-light .navbar-brand { 55 | color: tomato; 56 | } 57 | 58 | .navbar-light .navbar-brand:hover { 59 | color: black; 60 | } 61 | 62 | video { 63 | object-fit: cover; 64 | position: absolute; 65 | top:4rem; 66 | left: 0; 67 | height: 100%; 68 | width: 100%; 69 | filter: brightness(50%); 70 | } 71 | 72 | .video-wrapper { 73 | padding: 0px; 74 | margin:0px; 75 | border: none; 76 | width: 100%; 77 | height: 50vw; 78 | position: relative; 79 | overflow: visible; 80 | text-align: center; 81 | display: flex; 82 | align-items: center; 83 | justify-content: center; 84 | } 85 | 86 | .header { 87 | top: 5rem; 88 | position: relative; 89 | color: white; 90 | text-shadow: 1px 1px 8px rgba(0,0,0,0.6); 91 | font-size: 1rem; 92 | } 93 | 94 | .headerCode { 95 | background-color:black; 96 | font-size: 1.2rem; 97 | } 98 | 99 | @media (min-width: 768px) { 100 | html { 101 | font-size: 16px; 102 | } 103 | 104 | .header { 105 | font-size: 1.5rem; 106 | } 107 | 108 | .headerCode { 109 | font-size: 2rem; 110 | } 111 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/favicon-16x16.png -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/favicon-32x32.png -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2021 Twitter, Inc. 4 | Copyright (c) 2011-2021 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Blazor3D.Web/wwwroot/site.webmanifest: -------------------------------------------------------------------------------- 1 | {"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Models/BaseModel.cs: -------------------------------------------------------------------------------- 1 | using ReferenceGenerator.Extensions; 2 | using System.Xml; 3 | 4 | namespace ReferenceGenerator.Models 5 | { 6 | public abstract class BaseModel 7 | { 8 | protected BaseModel(string type = "Base") 9 | { 10 | Type = type; 11 | } 12 | public string Name { get; set; } = string.Empty; 13 | public string ShortName { get; set; } = string.Empty; 14 | public string NameSpace { get; set; } = string.Empty; 15 | public string Summary { get; set; } = string.Empty; 16 | public string Type { get; } = "Base"; 17 | public string Inherit { get; set; } 18 | 19 | public List Params { get; } = new List(); 20 | 21 | public XmlNode XmlNode { get; set; } = null!; 22 | 23 | public virtual void Parse() 24 | { 25 | int idx = Name.LastIndexOf('.'); 26 | 27 | if (idx == -1) 28 | { 29 | return; 30 | } 31 | 32 | NameSpace = Name[..idx]; 33 | ShortName = Name[(idx + 1)..]; 34 | 35 | if (XmlNode.HasChildNodes) 36 | { 37 | foreach (XmlNode node in XmlNode.ChildNodes) 38 | { 39 | if (node.Name == "summary") 40 | { 41 | Summary = node.InnerXml.Trim().ParseSummary(); 42 | }; 43 | 44 | if (node.Name == "inheritdoc") 45 | { 46 | Inherit = node.InnerXml.Trim().ParseSummary(); 47 | }; 48 | 49 | if (node.Name == "param") 50 | { 51 | var pname = node.Attributes?.GetNamedItem("name")?.Value ?? string.Empty; 52 | Params.Add(new Param 53 | { 54 | ShortName = pname, 55 | Name = pname, 56 | Summary = node.InnerXml.Trim().ParseSummary() 57 | }); 58 | } 59 | 60 | } 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Models/ConstructorModel.cs: -------------------------------------------------------------------------------- 1 | namespace ReferenceGenerator.Models 2 | { 3 | public class ConstructorModel : MethodModel 4 | { 5 | public ConstructorModel():base("Constructor") 6 | { 7 | 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace ReferenceGenerator.Models 2 | { 3 | public class ErrorViewModel 4 | { 5 | public string? RequestId { get; set; } 6 | 7 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 8 | } 9 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Models/EventModel.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace ReferenceGenerator.Models 3 | { 4 | public class EventModel : BaseModel 5 | { 6 | public EventModel() : base("Event") 7 | { 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Models/FieldModel.cs: -------------------------------------------------------------------------------- 1 | namespace ReferenceGenerator.Models 2 | { 3 | public class FieldModel : BaseModel 4 | { 5 | public FieldModel() : base("Field") 6 | { 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Models/MethodModel.cs: -------------------------------------------------------------------------------- 1 | using ReferenceGenerator.Extensions; 2 | using System.Xml; 3 | 4 | namespace ReferenceGenerator.Models 5 | { 6 | public class MethodModel : BaseModel 7 | { 8 | public MethodModel() : base("Method") 9 | { 10 | } 11 | protected MethodModel(string type) : base(type) 12 | { 13 | } 14 | 15 | //public List Params { get; } = new List(); 16 | public string ReturnValue { get; set; } = string.Empty; 17 | 18 | private string ProcessMethodParamsString(string str) 19 | { 20 | var prms = str.Trim(new[] { '(', ')' }).Split(','); 21 | var newPrms = new List(); 22 | Array.ForEach(prms, x => 23 | { 24 | var idx = x.LastIndexOf("."); 25 | newPrms.Add(x[(idx + 1)..]); 26 | }); 27 | 28 | return $"({string.Join(", ", newPrms)})"; 29 | } 30 | 31 | public override void Parse() 32 | { 33 | var name = Name.Replace(".#ctor", null) 34 | .Replace("System.String", "string") 35 | .Replace("System.Single", "float"); 36 | 37 | Name = new string(name); 38 | 39 | var fullName = name; 40 | var prms = string.Empty; 41 | int idx = name.LastIndexOf("("); 42 | 43 | if (idx != -1) 44 | { 45 | fullName = name[..idx]; 46 | prms = name[(idx)..]; 47 | } 48 | prms = ProcessMethodParamsString(prms); 49 | 50 | idx = fullName.LastIndexOf("."); 51 | if (idx == -1) 52 | { 53 | return; 54 | } 55 | 56 | //Name = fullName; 57 | ShortName = fullName[(idx + 1)..] + prms; 58 | 59 | if (XmlNode.HasChildNodes) 60 | { 61 | foreach (XmlNode node in XmlNode.ChildNodes) 62 | { 63 | if (node.Name == "summary") 64 | { 65 | Summary = node.InnerXml.Trim().ParseSummary(); 66 | }; 67 | 68 | if (node.Name == "param") 69 | { 70 | var pname = node.Attributes?.GetNamedItem("name")?.Value ?? string.Empty; 71 | Params.Add(new Param 72 | { 73 | ShortName = pname, 74 | Name = pname, 75 | Summary = node.InnerXml.Trim().ParseSummary() 76 | }); 77 | } 78 | if (node.Name == "returns") 79 | { 80 | ReturnValue = node.InnerXml.Trim().ParseSummary(); 81 | } 82 | } 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Models/Param.cs: -------------------------------------------------------------------------------- 1 | namespace ReferenceGenerator.Models 2 | { 3 | public class Param : BaseModel 4 | { 5 | public Param() : base("Param") 6 | { 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Models/PropertyModel.cs: -------------------------------------------------------------------------------- 1 | namespace ReferenceGenerator.Models 2 | { 3 | public class PropertyModel : BaseModel 4 | { 5 | public PropertyModel() : base("Property") 6 | { 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Models/ReferenceModel.cs: -------------------------------------------------------------------------------- 1 | namespace ReferenceGenerator.Models 2 | { 3 | public class ReferenceModel : BaseModel 4 | { 5 | public ReferenceModel() : base("Reference") 6 | { 7 | } 8 | 9 | 10 | public List Types { get; set; } = new List(); 11 | 12 | public override void Parse() 13 | { 14 | base.Parse(); 15 | foreach (var item in Types) 16 | { 17 | item.Parse(); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Models/TypeModel.cs: -------------------------------------------------------------------------------- 1 | namespace ReferenceGenerator.Models 2 | { 3 | public class TypeModel : BaseModel 4 | { 5 | public TypeModel() : base("Type") 6 | { 7 | } 8 | 9 | public List Methods { get; set; } = new List(); 10 | public List Constructors { get; set; } = new List(); 11 | public List Properties { get; set; } = new List(); 12 | public List Fields { get; set; } = new List(); 13 | 14 | public List Events { get; set; } = new List(); 15 | 16 | public override void Parse() 17 | { 18 | base.Parse(); 19 | 20 | 21 | foreach (var method in Constructors) 22 | { 23 | method.Parse(); 24 | } 25 | foreach (var method in Methods) 26 | { 27 | method.Parse(); 28 | } 29 | foreach (var prop in Properties) 30 | { 31 | prop.Parse(); 32 | } 33 | foreach (var field in Fields) 34 | { 35 | field.Parse(); 36 | } 37 | foreach (var ev in Events) 38 | { 39 | ev.Parse(); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/ReferenceGenerator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Settings/TemplateSettings.cs: -------------------------------------------------------------------------------- 1 | namespace ReferenceGenerator.Settings 2 | { 3 | public static class TemplateSettings 4 | { 5 | public const string TitleTemplate = "{!{Title}!}"; 6 | public const string HeaderTemplate = "{!{Header}!}"; 7 | public const string NameSpaceTemplate = "{!{NameSpace}!}"; 8 | public const string ContentTemplate = "{!{Content}!}"; 9 | public const string NavTemplate = "{!{Nav}!}"; 10 | public const string BreadcrumbsTemplate = "{!{Breadcrumbs}!}"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Utils/BreadCrumbsFactory.cs: -------------------------------------------------------------------------------- 1 |  2 | using ReferenceGenerator.Models; 3 | 4 | namespace ReferenceGenerator.Utils 5 | { 6 | internal static class BreadCrumbsFactory 7 | { 8 | internal static string GetIndexBreadcrumbs() 9 | { 10 | return "
  • Reference Guide
  • "; 11 | } 12 | 13 | internal static string GetTypeBreadcrumbs(TypeModel type) 14 | { 15 | var bc = "
  • Reference Guide
  • " + 16 | $"
  • {type.ShortName}
  • "; 17 | return bc; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/ReferenceGenerator/Utils/PathCombiner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ReferenceGenerator.Utils 8 | { 9 | public static class PathCombiner 10 | { 11 | public static string Combine(string path1, string path2) 12 | { 13 | if (Path.IsPathRooted(path2)) 14 | { 15 | path2 = path2.TrimStart(Path.DirectorySeparatorChar); 16 | path2 = path2.TrimStart(Path.AltDirectorySeparatorChar); 17 | } 18 | 19 | return Path.Combine(path1, path2); 20 | } 21 | 22 | public static string Combine(string path1, string path2, string path3) 23 | { 24 | if (Path.IsPathRooted(path2)) 25 | { 26 | path2 = path2.TrimStart(Path.DirectorySeparatorChar); 27 | path2 = path2.TrimStart(Path.AltDirectorySeparatorChar); 28 | } 29 | 30 | if (Path.IsPathRooted(path3)) 31 | { 32 | path2 = path3.TrimStart(Path.DirectorySeparatorChar); 33 | path2 = path3.TrimStart(Path.AltDirectorySeparatorChar); 34 | } 35 | 36 | return Path.Combine(path1, path2); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D.Web/Todo.txt: -------------------------------------------------------------------------------- 1 | - remove register link -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Cameras/OrthographicCameraTests.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Cameras; 2 | 3 | namespace HomagGroup.Blazor3D.Tests.Cameras 4 | { 5 | [TestClass] 6 | public class OrthographicCameraTests 7 | { 8 | [TestMethod] 9 | public void DefaultConstuctorShouldCreateWithPredefinedValues() 10 | { 11 | var camera = new OrthographicCamera(); 12 | Assert.AreEqual("OrthographicCamera", camera.Type); 13 | Assert.AreEqual(0.1, camera.Near); 14 | Assert.AreEqual(2000, camera.Far); 15 | Assert.AreEqual(-1, camera.Left); 16 | Assert.AreEqual(1, camera.Right); 17 | Assert.AreEqual(1, camera.Top); 18 | Assert.AreEqual(-1, camera.Bottom); 19 | Assert.AreEqual(1, camera.Zoom); 20 | Assert.IsNotNull(camera.AnimateRotationSettings); 21 | Assert.IsNotNull(camera.LookAt); 22 | Assert.IsNotNull(camera.Up); 23 | } 24 | 25 | [TestMethod] 26 | public void ConstuctorWithParamsShouldCreateWithSpecifiedValues() 27 | { 28 | var camera = new OrthographicCamera(left: -2, right: 2, top: 2, bottom: -2, near: 0, far: 100, zoom: 0.5); 29 | Assert.AreEqual("OrthographicCamera", camera.Type); 30 | Assert.AreEqual(0, camera.Near); 31 | Assert.AreEqual(100, camera.Far); 32 | Assert.AreEqual(-2, camera.Left); 33 | Assert.AreEqual(2, camera.Right); 34 | Assert.AreEqual(2, camera.Top); 35 | Assert.AreEqual(-2, camera.Bottom); 36 | Assert.AreEqual(0.5, camera.Zoom); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Cameras/PerspectiveCameraTests.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Cameras; 2 | 3 | namespace HomagGroup.Blazor3D.Tests.Cameras 4 | { 5 | [TestClass] 6 | public class PerspectiveCameraTests 7 | { 8 | [TestMethod] 9 | public void DefaultConstuctorShouldCreateWithPredefinedValues() 10 | { 11 | var camera = new PerspectiveCamera(); 12 | Assert.AreEqual("PerspectiveCamera", camera.Type); 13 | Assert.AreEqual(0.1, camera.Near); 14 | Assert.AreEqual(1000, camera.Far); 15 | Assert.AreEqual(75, camera.Fov); 16 | Assert.IsNotNull(camera.AnimateRotationSettings); 17 | Assert.IsNotNull(camera.LookAt); 18 | } 19 | 20 | [TestMethod] 21 | public void ConstuctorWithParamsShouldCreateWithPredefinedValues() 22 | { 23 | var camera = new PerspectiveCamera(fov:10, near:0.2, far:100); 24 | Assert.AreEqual("PerspectiveCamera", camera.Type); 25 | Assert.AreEqual(0.2, camera.Near); 26 | Assert.AreEqual(100, camera.Far); 27 | Assert.AreEqual(10, camera.Fov); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Helpers/ArrowHelperTests.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Helpers; 2 | using HomagGroup.Blazor3D.Maths; 3 | 4 | namespace HomagGroup.Blazor3D.Tests.Helpers 5 | { 6 | [TestClass] 7 | public class ArrowHelperTests 8 | { 9 | [TestMethod] 10 | public void DefaultConstuctorShouldCreateWithPredefinedValues() 11 | { 12 | var arrow = new ArrowHelper(); 13 | Assert.AreEqual("ArrowHelper", arrow.Type); 14 | Assert.AreEqual(0, arrow.Dir.X); 15 | Assert.AreEqual(0, arrow.Dir.Y); 16 | Assert.AreEqual(1, arrow.Dir.Z); 17 | Assert.AreEqual(0, arrow.Origin.X); 18 | Assert.AreEqual(0, arrow.Origin.Y); 19 | Assert.AreEqual(0, arrow.Origin.Z); 20 | Assert.AreEqual(1, arrow.Length); 21 | Assert.AreEqual("0xffff00", arrow.Color); 22 | Assert.AreEqual(0.2, arrow.HeadLength); 23 | Assert.AreEqual(0.2*0.2, arrow.HeadWidth); 24 | } 25 | 26 | [TestMethod] 27 | public void ConstuctorWithParamsShouldCreateWithSpecifiedValues() 28 | { 29 | var arrow = new ArrowHelper( 30 | dir: new Vector3(3, 3, 3), 31 | origin: new Vector3(3,3,3), 32 | length: 5, 33 | color: "red", 34 | headLength: 2, 35 | headWidth: 4); 36 | Assert.AreEqual("ArrowHelper", arrow.Type); 37 | Assert.AreEqual(3, arrow.Dir.X); 38 | Assert.AreEqual(3, arrow.Dir.Y); 39 | Assert.AreEqual(3, arrow.Dir.Z); 40 | Assert.AreEqual(3, arrow.Origin.X); 41 | Assert.AreEqual(3, arrow.Origin.Y); 42 | Assert.AreEqual(3, arrow.Origin.Z); 43 | Assert.AreEqual(5, arrow.Length); 44 | Assert.AreEqual("red", arrow.Color); 45 | Assert.AreEqual(2, arrow.HeadLength); 46 | Assert.AreEqual(4, arrow.HeadWidth); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Helpers/AxesHelperTests.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Helpers; 2 | 3 | namespace HomagGroup.Blazor3D.Tests.Helpers 4 | { 5 | [TestClass] 6 | public class AxesHelperTests 7 | { 8 | [TestMethod] 9 | public void DefaultConstuctorShouldCreateWithPredefinedValues() 10 | { 11 | var helper = new AxesHelper(); 12 | Assert.AreEqual("AxesHelper", helper.Type); 13 | Assert.AreEqual(1, helper.Size); 14 | } 15 | 16 | [TestMethod] 17 | public void ConstuctorWithParamsShouldCreateWithSpecifiedValues() 18 | { 19 | var helper = new AxesHelper(5); 20 | Assert.AreEqual("AxesHelper", helper.Type); 21 | Assert.AreEqual(5, helper.Size); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Helpers/BoxHelperTests.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Helpers; 2 | using HomagGroup.Blazor3D.Objects; 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace HomagGroup.Blazor3D.Tests.Helpers 7 | { 8 | [TestClass] 9 | public class BoxHelperTests 10 | { 11 | [TestMethod] 12 | public void DefaultConstuctorShouldCreateWithPredefinedValues() 13 | { 14 | var helper = new BoxHelper(); 15 | Assert.AreEqual("BoxHelper", helper.Type); 16 | Assert.IsNull(helper.Object3D); 17 | Assert.AreEqual("0xffff00", helper.Color); 18 | } 19 | 20 | [TestMethod] 21 | public void ConstuctorWithParamsShouldCreateWithSpecifiedValues() 22 | { 23 | var mesh = new Mesh(); 24 | var helper = new BoxHelper(mesh, "red"); 25 | Assert.AreEqual("BoxHelper", helper.Type); 26 | Assert.IsNotNull(helper.Object3D); 27 | Assert.AreEqual("red", helper.Color); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Helpers/GridHelperTests.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Helpers; 2 | 3 | namespace HomagGroup.Blazor3D.Tests.Helpers 4 | { 5 | [TestClass] 6 | public class GridHelperTests 7 | { 8 | [TestMethod] 9 | public void DefaultConstuctorShouldCreateWithPredefinedValues() 10 | { 11 | var grid = new GridHelper(); 12 | Assert.AreEqual("GridHelper", grid.Type); 13 | Assert.AreEqual(10, grid.Size); 14 | Assert.AreEqual(10, grid.Divisions); 15 | Assert.AreEqual("0x444444", grid.ColorCenterLine); 16 | Assert.AreEqual("0x888888", grid.ColorGrid); 17 | 18 | } 19 | 20 | [TestMethod] 21 | public void ConstuctorWithParamsShouldCreateWithSpecifiedValues() 22 | { 23 | var grid = new GridHelper(6, 6, "red", "orange"); 24 | Assert.AreEqual("GridHelper", grid.Type); 25 | Assert.AreEqual(6, grid.Size); 26 | Assert.AreEqual(6, grid.Divisions); 27 | Assert.AreEqual("red", grid.ColorCenterLine); 28 | Assert.AreEqual("orange", grid.ColorGrid); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Helpers/PlaneHelperTests.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Helpers; 2 | using HomagGroup.Blazor3D.Maths; 3 | 4 | namespace HomagGroup.Blazor3D.Tests.Helpers 5 | { 6 | [TestClass] 7 | public class PlaneHelperTests 8 | { 9 | [TestMethod] 10 | public void DefaultConstuctorShouldCreateWithPredefinedValues() 11 | { 12 | var plane = new PlaneHelper(); 13 | Assert.AreEqual("PlaneHelper", plane.Type); 14 | Assert.IsNotNull(plane.Plane); 15 | Assert.IsNotNull(plane.Plane.Normal); 16 | Assert.AreEqual(1, plane.Plane.Normal.X); 17 | Assert.AreEqual(0, plane.Plane.Normal.Y); 18 | Assert.AreEqual(0, plane.Plane.Normal.Z); 19 | Assert.AreEqual(0, plane.Plane.Constant); 20 | Assert.AreEqual(1, plane.Size); 21 | Assert.AreEqual("0xffff00", plane.Color); 22 | 23 | } 24 | 25 | [TestMethod] 26 | public void ConstuctorWithParamsShouldCreateWithSpecifiedValues() 27 | { 28 | var plane = new PlaneHelper(new Plane(new Vector3(1, 1, 1), 1)); 29 | Assert.AreEqual("PlaneHelper", plane.Type); 30 | Assert.IsNotNull(plane.Plane); 31 | Assert.IsNotNull(plane.Plane.Normal); 32 | Assert.AreEqual(1, plane.Plane.Normal.X); 33 | Assert.AreEqual(1, plane.Plane.Normal.Y); 34 | Assert.AreEqual(1, plane.Plane.Normal.Z); 35 | Assert.AreEqual(1, plane.Plane.Constant); 36 | Assert.AreEqual(1, plane.Size); 37 | Assert.AreEqual("0xffff00", plane.Color); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Helpers/PointLightHelperTests.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Helpers; 2 | using HomagGroup.Blazor3D.Lights; 3 | 4 | namespace HomagGroup.Blazor3D.Tests.Helpers 5 | { 6 | [TestClass] 7 | public class PointLightHelperTests 8 | { 9 | [TestMethod] 10 | public void DefaultConstuctorShouldCreateWithPredefinedValues() 11 | { 12 | var helper = new PointLightHelper(); 13 | Assert.AreEqual("PointLightHelper", helper.Type); 14 | Assert.IsNotNull(helper.Light); 15 | Assert.IsNull(helper.Color); 16 | Assert.AreEqual(1, helper.SphereSize); 17 | } 18 | 19 | [TestMethod] 20 | public void ConstuctorWithParamsShouldCreateWithSpecifiedValues() 21 | { 22 | var light = new PointLight() 23 | { 24 | Color = "red" 25 | }; 26 | 27 | var helper = new PointLightHelper(light, 2, "blue"); 28 | Assert.AreEqual("PointLightHelper", helper.Type); 29 | Assert.IsNotNull(helper.Light); 30 | Assert.AreEqual("red", helper.Light.Color); 31 | Assert.AreEqual(2, helper.SphereSize); 32 | Assert.AreEqual("blue", helper.Color); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Helpers/PolarGridHelperTests.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Helpers; 2 | 3 | namespace HomagGroup.Blazor3D.Tests.Helpers 4 | { 5 | [TestClass] 6 | public class PolarGridHelperTests 7 | { 8 | [TestMethod] 9 | public void DefaultConstuctorShouldCreateWithPredefinedValues() 10 | { 11 | var grid = new PolarGridHelper(); 12 | Assert.AreEqual("PolarGridHelper", grid.Type); 13 | Assert.AreEqual(10, grid.Radius); 14 | Assert.AreEqual(16, grid.Radials); 15 | Assert.AreEqual(8, grid.Circles); 16 | Assert.AreEqual(64, grid.Divisions); 17 | Assert.AreEqual("0x444444", grid.Color1); 18 | Assert.AreEqual("0x888888", grid.Color2); 19 | 20 | } 21 | 22 | [TestMethod] 23 | public void ConstuctorWithParamsShouldCreateWithSpecifiedValues() 24 | { 25 | var grid = new PolarGridHelper(2, 2, 6, 32, "red", "orange"); 26 | Assert.AreEqual("PolarGridHelper", grid.Type); 27 | Assert.AreEqual(2, grid.Radius); 28 | Assert.AreEqual(2, grid.Radials); 29 | Assert.AreEqual(6, grid.Circles); 30 | Assert.AreEqual(32, grid.Divisions); 31 | Assert.AreEqual("red", grid.Color1); 32 | Assert.AreEqual("orange", grid.Color2); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/HomagGroup.Blazor3D.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | false 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Settings/AnimateRotationSettingsTests.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Settings; 2 | 3 | namespace HomagGroup.Blazor3D.Tests.Settings 4 | { 5 | [TestClass] 6 | public class AnimateRotationSettingsTests 7 | { 8 | [TestMethod] 9 | public void DefaultConstuctorShouldCreateWithPredefinedValues() 10 | { 11 | var settings = new AnimateRotationSettings(); 12 | 13 | Assert.AreEqual(false, settings.AnimateRotation); 14 | Assert.AreEqual(0.1, settings.ThetaX); 15 | Assert.AreEqual(0.1, settings.ThetaY); 16 | Assert.AreEqual(0.1, settings.ThetaZ); 17 | Assert.AreEqual(5, settings.Radius); 18 | 19 | } 20 | 21 | [TestMethod] 22 | public void ConstuctorWithParamsShouldCreateWithSpecifiedValues() 23 | { 24 | var settings = new AnimateRotationSettings(true, 1, 1, 1, 1); 25 | 26 | Assert.AreEqual(true, settings.AnimateRotation); 27 | Assert.AreEqual(1, settings.ThetaX); 28 | Assert.AreEqual(1, settings.ThetaY); 29 | Assert.AreEqual(1, settings.ThetaZ); 30 | Assert.AreEqual(1, settings.Radius); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.Tests/Usings.cs: -------------------------------------------------------------------------------- 1 | global using Microsoft.VisualStudio.TestTools.UnitTesting; -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.2.32505.173 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestWebAsm", "TestWebAsm\TestWebAsm.csproj", "{B6536EF2-FBFD-4CA5-A89A-E098600F5796}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestServer", "TestServer\TestServer.csproj", "{CC396385-BA20-4B3C-98AF-963160281B20}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HomagGroup.Blazor3D", "Blazor3D\HomagGroup.Blazor3D.csproj", "{F4B9477B-E078-4898-8BF2-50EBDA12D76D}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documents", "Documents", "{40998448-A3C4-455A-9447-5A89398A616F}" 13 | ProjectSection(SolutionItems) = preProject 14 | Todo.txt = Todo.txt 15 | EndProjectSection 16 | EndProject 17 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HomagGroup.Blazor3D.Tests", "Blazor3D.Tests\HomagGroup.Blazor3D.Tests.csproj", "{121CFD4A-111F-439A-A680-7A654426A075}" 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|Any CPU = Debug|Any CPU 22 | Release|Any CPU = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {B6536EF2-FBFD-4CA5-A89A-E098600F5796}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {B6536EF2-FBFD-4CA5-A89A-E098600F5796}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {B6536EF2-FBFD-4CA5-A89A-E098600F5796}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {B6536EF2-FBFD-4CA5-A89A-E098600F5796}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {CC396385-BA20-4B3C-98AF-963160281B20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 30 | {CC396385-BA20-4B3C-98AF-963160281B20}.Debug|Any CPU.Build.0 = Debug|Any CPU 31 | {CC396385-BA20-4B3C-98AF-963160281B20}.Release|Any CPU.ActiveCfg = Release|Any CPU 32 | {CC396385-BA20-4B3C-98AF-963160281B20}.Release|Any CPU.Build.0 = Release|Any CPU 33 | {F4B9477B-E078-4898-8BF2-50EBDA12D76D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 34 | {F4B9477B-E078-4898-8BF2-50EBDA12D76D}.Debug|Any CPU.Build.0 = Debug|Any CPU 35 | {F4B9477B-E078-4898-8BF2-50EBDA12D76D}.Release|Any CPU.ActiveCfg = Release|Any CPU 36 | {F4B9477B-E078-4898-8BF2-50EBDA12D76D}.Release|Any CPU.Build.0 = Release|Any CPU 37 | {121CFD4A-111F-439A-A680-7A654426A075}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 38 | {121CFD4A-111F-439A-A680-7A654426A075}.Debug|Any CPU.Build.0 = Debug|Any CPU 39 | {121CFD4A-111F-439A-A680-7A654426A075}.Release|Any CPU.ActiveCfg = Release|Any CPU 40 | {121CFD4A-111F-439A-A680-7A654426A075}.Release|Any CPU.Build.0 = Release|Any CPU 41 | EndGlobalSection 42 | GlobalSection(SolutionProperties) = preSolution 43 | HideSolutionNode = FALSE 44 | EndGlobalSection 45 | GlobalSection(ExtensibilityGlobals) = postSolution 46 | SolutionGuid = {3D4E6CCE-4405-49FA-B226-ED0F28169FDC} 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Cameras/Camera.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | using HomagGroup.Blazor3D.Maths; 3 | using HomagGroup.Blazor3D.Settings; 4 | 5 | namespace HomagGroup.Blazor3D.Cameras 6 | { 7 | /// 8 | /// Abstract base class for cameras. 9 | /// Wrapper for three.js Camera 10 | /// 11 | /// 12 | public abstract class Camera : Object3D 13 | { 14 | protected Camera(string type = "Camera") : base(type) 15 | { 16 | } 17 | 18 | /// 19 | /// Settings used for camera's animated rotations. 20 | /// 21 | public AnimateRotationSettings AnimateRotationSettings { get; set; } = new AnimateRotationSettings(); 22 | 23 | /// 24 | /// The point camera looks at. 25 | /// 26 | public Vector3 LookAt { get; set; } = new Vector3(); 27 | 28 | 29 | /// 30 | /// This is used by the LookAt method, for example, to determine the orientation of the result. 31 | /// Default is ( 0, 1, 0 ). 32 | /// 33 | public Vector3 Up { get; set; } = new Vector3(0, 1, 0); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Cameras/OrthographicCamera.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Cameras 2 | { 3 | /// 4 | /// Camera that uses orthographic projection. 5 | /// In this projection mode, an object's size in the rendered image stays constant regardless of its distance from the camera. 6 | /// This can be useful for rendering 2D scenes and UI elements, amongst other things. 7 | /// 8 | public sealed class OrthographicCamera : Camera 9 | { 10 | public OrthographicCamera() : base("OrthographicCamera") 11 | { 12 | 13 | } 14 | 15 | /// 16 | /// Constructor with parameters. 17 | /// 18 | /// Camera frustum left plane. Default is -1. 19 | /// Camera frustum right plane. Default is 1. 20 | /// Camera frustum top plane. Default is 1. 21 | /// Camera frustum bottom plane. Default is -1. 22 | /// Camera frustum near plane distance. Default is 0.1. 23 | /// Camera frustum far plane distance. Default is 1000. 24 | /// Zoom factor of the camera. Default is 1. 25 | public OrthographicCamera(double left = -1, double right = 1, double top = 1, double bottom = -1, double near = 0.1, double far = 2000, double zoom = 1) : this() 26 | { 27 | Left = left; 28 | Right = right; 29 | Top = top; 30 | Bottom = bottom; 31 | Near = near; 32 | Far = far; 33 | Zoom = zoom; 34 | } 35 | 36 | /// 37 | /// Camera frustum left plane. Default is -1. 38 | /// 39 | public double Left { get; set; } = -1; 40 | 41 | /// 42 | /// Camera frustum right plane. Default is 1. 43 | /// 44 | public double Right { get; set; } = 1; 45 | 46 | /// 47 | /// Camera frustum top plane. Default is 1. 48 | /// 49 | public double Top { get; set; } = 1; 50 | 51 | /// 52 | /// Camera frustum bottom plane. Default is -1. 53 | /// 54 | public double Bottom { get; set; } = -1; 55 | 56 | /// 57 | /// Camera frustum near plane distance. Default is 0.1. 58 | /// 59 | public double Near { get; set; } = 0.1; 60 | 61 | /// 62 | /// Camera frustum far plane distance. Default is 2000. 63 | /// 64 | public double Far { get; set; } = 2000; 65 | 66 | /// 67 | /// Zoom factor of the camera. Default is 1. 68 | /// 69 | public double Zoom { get; set; } = 1; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Cameras/PerspectiveCamera.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Cameras 2 | { 3 | /// 4 | /// Camera that uses perspective projection. 5 | /// This projection mode is designed to mimic the way the human eyes see. 6 | /// It is the most common projection mode used for rendering a 3D scene. 7 | /// Wrapper for three.js PerspectiveCamera 8 | /// 9 | /// 10 | public sealed class PerspectiveCamera : Camera 11 | { 12 | public PerspectiveCamera() : base("PerspectiveCamera") 13 | { 14 | } 15 | 16 | /// 17 | /// Constructor with parameters. 18 | /// 19 | /// Camera frustum vertical field of view. Default is 75. 20 | /// Camera frustum near plane distance. Default is 0.1. 21 | /// Camera frustum far plane distance. Default is 1000. 22 | public PerspectiveCamera(double fov, double near, double far) : this() 23 | { 24 | Fov = fov; 25 | Near = near; 26 | Far = far; 27 | } 28 | 29 | /// 30 | /// Camera frustum vertical field of view. Default is 75. 31 | /// 32 | public double Fov { get; set; } = 75; 33 | 34 | /// 35 | /// Camera frustum near plane distance. Default is 0.1. 36 | /// 37 | public double Near { get; set; } = 0.1; 38 | 39 | /// 40 | /// Camera frustum far plane distance. Default is 1000. 41 | /// 42 | public double Far { get; set; } = 1000; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/ComponentHelpers/ChildrenHelper.cs: -------------------------------------------------------------------------------- 1 |  2 | using HomagGroup.Blazor3D.Core; 3 | 4 | namespace HomagGroup.Blazor3D.ComponentHelpers 5 | { 6 | internal static class ChildrenHelper 7 | { 8 | internal static void RemoveObjectByUuid(Guid uuid, List children) 9 | { 10 | Object3D? result = null; 11 | foreach (var child in children) 12 | { 13 | if (child.Uuid == uuid) 14 | { 15 | result = child; 16 | break; 17 | } 18 | 19 | if (child.Children.Count > 0) 20 | { 21 | RemoveObjectByUuid(uuid, child.Children); 22 | }; 23 | } 24 | 25 | if (result != null) 26 | children.Remove(result); 27 | } 28 | 29 | internal static Object3D? GetObjectByUuid(Guid uuid, List children) 30 | { 31 | Object3D? result = null; 32 | foreach (var child in children) 33 | { 34 | if (child.Uuid == uuid) 35 | { 36 | return child; 37 | } 38 | 39 | if (child.Children.Count > 0) 40 | { 41 | result = GetObjectByUuid(uuid, child.Children); 42 | if (result != null) 43 | { 44 | return result; 45 | } 46 | }; 47 | } 48 | return result; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/ComponentHelpers/SerializationHelper.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Serialization; 3 | 4 | namespace HomagGroup.Blazor3D.ComponentHelpers 5 | { 6 | internal static class SerializationHelper 7 | { 8 | internal static JsonSerializerSettings GetSerializerSettings() 9 | { 10 | return new JsonSerializerSettings() 11 | { 12 | ContractResolver = new CamelCasePropertyNamesContractResolver(), 13 | ReferenceLoopHandling = ReferenceLoopHandling.Ignore, 14 | }; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Controls/OrbitControls.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Maths; 2 | 3 | namespace HomagGroup.Blazor3D.Controls 4 | { 5 | /// 6 | /// Orbit controls. 7 | /// 8 | public sealed class OrbitControls 9 | { 10 | /// 11 | /// If true, then enabled. Otherwise, disabled. Default is true. 12 | /// 13 | public bool Enabled { get; set; } = true; 14 | /// 15 | /// Minimal distance. Default is 0. 16 | /// 17 | public double MinDistance { get; set; } = 0; 18 | /// 19 | /// Maximal distance to zoom. Default is 10000; 20 | /// 21 | public double MaxDistance { get; set; } = 10000; 22 | 23 | /// 24 | /// The point where the camera is looking at. Default is (0,0,0). 25 | /// 26 | public Vector3 TargetPosition { get; set; } = new Vector3(); 27 | 28 | /// 29 | /// If true, then panning enabled. Otherwise, panning disabled. Default is true 30 | /// 31 | public bool EnablePan { get; set; } = true; 32 | 33 | /// 34 | /// If true, than damping enabled. Otherwise, damping disabled. Default is true 35 | /// 36 | public bool EnableDamping { get; set; } = false; 37 | 38 | /// 39 | /// Damping factor. Default is 0.05 40 | /// 41 | public double DampingFactor = 0.05; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Core/BufferGeometry.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Core 2 | { 3 | /// 4 | /// A representation of geometry for mesh, line, or point. 5 | /// Includes vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers, 6 | /// reducing the cost of passing all this data to the GPU. 7 | /// Wrapper for three.js BufferGeometry 8 | /// 9 | public abstract class BufferGeometry 10 | { 11 | protected BufferGeometry(string type) 12 | { 13 | Type = type; 14 | } 15 | 16 | /// 17 | /// Optional name of the object. Default is an empty string. It has not to be unique. 18 | /// 19 | public string Name { get; set; } = null!; 20 | 21 | /// 22 | /// Universal unique identifier of this object instance. It's automatically assigned Guid, so it shouldn't be edited. 23 | /// 24 | public Guid Uuid { get; set; } = Guid.NewGuid(); 25 | 26 | public string Type { get; } = "Geometry"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Core/Object3D.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Maths; 2 | using HomagGroup.Blazor3D.Settings; 3 | 4 | namespace HomagGroup.Blazor3D.Core 5 | { 6 | /// 7 | /// It's a base abstract class for most objects in HomagGroup.Blazor3D. 8 | /// It provides functionality for manipulating objects in 3D space. 9 | ///Wrapper for three.js Object3D 10 | /// 11 | public abstract class Object3D 12 | { 13 | protected Object3D(string type) 14 | { 15 | Type = type; 16 | } 17 | 18 | /// 19 | /// Represents the object's local position. Default is (0, 0, 0). 20 | /// 21 | public Vector3 Position { get; set; } = new Vector3(); 22 | 23 | /// 24 | /// Object's local rotation, in radians. 25 | /// 26 | public Euler Rotation { get; set; } = new Euler(); 27 | 28 | /// 29 | /// Represents the object's local scale. Default is (1, 1, 1). 30 | /// 31 | public Vector3 Scale { get; set; } = new Vector3(1, 1, 1); 32 | 33 | public string Type { get; } = "Object3D"; 34 | 35 | /// 36 | /// Optional name of the object. Default is an empty string. It has not to be unique. 37 | /// 38 | public string Name { get; set; } = string.Empty; 39 | 40 | /// 41 | /// Universal unique identifier of this object instance. It's automatically assigned Guid, so it shouldn't be edited. 42 | /// 43 | public Guid Uuid { get; set; } = Guid.NewGuid(); 44 | 45 | /// 46 | /// Collection of child objects. 47 | /// 48 | public List Children { get; set; } = new List(); 49 | 50 | /// 51 | /// Settings to create movement animations on the object 52 | /// 53 | public AnimateObject3DSettings AnimateObject3DSettings { get; set; } 54 | 55 | /// 56 | /// Adds a child object to the Children collection. 57 | /// 58 | /// Child to be added. 59 | public void Add(Object3D child) 60 | { 61 | Children.Add(child); 62 | } 63 | 64 | /// 65 | /// Adds the elements of the specified collection to the end of Children list. 66 | /// 67 | /// Collection of children objects. 68 | public void AddRange(IEnumerable elements) 69 | { 70 | Children.AddRange(elements); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Enums/ImportModels.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Scenes; 2 | 3 | namespace HomagGroup.Blazor3D.Enums 4 | { 5 | /// 6 | /// 3D model formats, which can be used for importing to or exporting from . 7 | /// 8 | public enum Import3DFormats 9 | { 10 | /// 11 | ///Wavefront Object format. 12 | /// 13 | Obj, 14 | /// 15 | /// Collada format. 16 | /// 17 | Collada, 18 | /// 19 | /// Autodesk FBX format. 20 | /// 21 | Fbx, 22 | /// 23 | /// glTF format. 24 | /// 25 | Gltf, 26 | /// 27 | /// Stl format. 28 | /// 29 | Stl 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Enums/Lines/LineCap.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Enums.Lines 2 | { 3 | public enum LineCap 4 | { 5 | Round, 6 | Butt, 7 | Square 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Enums/Lines/LineJoin.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Enums.Lines 2 | { 3 | public enum LineJoin 4 | { 5 | Round, 6 | Bevel, 7 | Miter 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Enums/WrappingType.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Enums 2 | { 3 | /// 4 | /// These define the texture's WrapS and WrapT properties, which define horizontal and vertical texture wrapping. 5 | /// 6 | public enum WrappingType 7 | { 8 | /// 9 | /// The texture will simply repeat to infinity 10 | /// 11 | RepeatWrapping = 1000, 12 | /// 13 | /// The last pixel of the texture stretches to the edge of the mesh. 14 | /// 15 | ClampToEdgeWrapping = 1001, 16 | /// 17 | /// The texture will repeats to infinity, mirroring on each repeat. 18 | /// 19 | MirroredRepeatWrapping = 1002 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Events/LoadedModuleEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Events 2 | { 3 | /// 4 | /// Delegate that handles JsModuleLoaded event. 5 | /// 6 | /// Task 7 | public delegate Task LoadedModuleEventHandler(); 8 | } 9 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Events/LoadedObjectEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Events 2 | { 3 | /// 4 | /// Delegate that handles ObjectLoaded event. 5 | /// 6 | /// arguments for ObjectLoaded event handler. 7 | public delegate Task LoadedObjectEventHandler(Object3DArgs e); 8 | } 9 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Events/Object3DArgs.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Events 2 | { 3 | internal class Object3DStaticArgs 4 | { 5 | public string ContainerId { get; set; } = null!; 6 | 7 | public Guid UUID { get; set; } 8 | } 9 | 10 | /// 11 | /// Arguments for ObjectSelected and ObjectLoaded event handlers. 12 | /// 13 | public class Object3DArgs 14 | { 15 | /// 16 | /// Selected or Loaded object unique identifier. 17 | /// 18 | public Guid UUID { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Events/SelectedObjectEventHandler.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Events 2 | { 3 | /// 4 | /// Delegate that handles ObjectSelected event. 5 | /// 6 | /// arguments for ObjectSelected event handler. 7 | public delegate void SelectedObjectEventHandler(Object3DArgs e); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Extras/Core/Shape.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Geometires; 2 | using HomagGroup.Blazor3D.Maths; 3 | 4 | namespace HomagGroup.Blazor3D.Extras.Core 5 | { 6 | /// 7 | /// Defines an arbitrary 2d shape plane using paths with optional holes). 8 | /// It can be used with , , to get points, or to get triangulated faces. 9 | /// 10 | public class Shape 11 | { 12 | /// 13 | /// Universal unique identifier 14 | /// 15 | public Guid Uuid { get; set; } = Guid.NewGuid(); 16 | 17 | /// 18 | /// Array of representing the shape verticies. 19 | /// 20 | public List Points { get; set; } = new List(); 21 | 22 | /// 23 | /// Moves the current point to the specified point. Can be used for the first element of the Points collection. 24 | /// 25 | /// point. 26 | /// MoveTo() can be used only to define first shape point 27 | public void MoveTo(Vector2 point) 28 | { 29 | if (Points.Count > 0) 30 | { 31 | throw new OverflowException("MoveTo() can be used only to define first shape point"); 32 | } 33 | Points.Add(point); 34 | } 35 | 36 | /// 37 | /// Moves the current point to the specified point. 38 | /// 39 | /// X coordinate of the specified point. 40 | /// Y coordinate of the specified point. 41 | public void MoveTo(double x, double y) 42 | { 43 | MoveTo(new Vector2(x, y)); 44 | } 45 | 46 | /// 47 | /// Adds the vertice to the shape path. 48 | /// 49 | /// point. 50 | /// LineTo() cannot be used to define first shape point 51 | public void LineTo(Vector2 point) 52 | { 53 | if (Points.Count == 0) 54 | { 55 | throw new OverflowException("LineTo() cannot be used to define first shape point"); 56 | } 57 | Points.Add(point); 58 | } 59 | 60 | /// 61 | /// Adds the vertice to the shape path. 62 | /// 63 | /// X coordinate of the specified vertice. 64 | /// Y coordinate of the specified vertice. 65 | public void LineTo(double x, double y) 66 | { 67 | LineTo(new Vector2(x, y)); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/CapsuleGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Geometires 4 | { 5 | /// 6 | /// Class for a capsule with given radus and height. It is constructed using a lathe. 7 | /// Wrapper for three.js CapsuleGeometry 8 | /// 9 | public sealed class CapsuleGeometry : BufferGeometry 10 | { 11 | public CapsuleGeometry() : base("CapsuleGeometry") 12 | { 13 | } 14 | 15 | /// 16 | /// Constructor with parameters 17 | /// 18 | /// Radius of the capsule. Default is 1. 19 | /// Length of the middle section. Default is 1. 20 | /// Number of curve segments used to build the caps. Default is 4. 21 | /// Number of segmented faces around the circumference of the capsule. Default is 8. 22 | public CapsuleGeometry(double radius = 1, double length = 1, int capSegments = 4, int radialSegments = 8) : this() 23 | { 24 | Radius = radius; 25 | Length = length; 26 | CapSegments = capSegments; 27 | RadialSegments = radialSegments; 28 | } 29 | 30 | /// 31 | /// Radius of the capsule. Default is 1. 32 | /// 33 | public double Radius { get; set; } = 1; 34 | 35 | /// 36 | /// Length of the middle section. Default is 1. 37 | /// 38 | public double Length { get; set; } = 1; 39 | 40 | /// 41 | /// Number of curve segments used to build the caps. Default is 4. 42 | /// 43 | public int CapSegments { get; set; } = 4; 44 | 45 | /// 46 | /// Number of segmented faces around the circumference of the capsule. Default is 8. 47 | /// 48 | public int RadialSegments { get; set; } = 8; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/CircleGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Geometires 4 | { 5 | /// 6 | /// Class for a simple shape of Euclidean geometry. 7 | /// It is constructed from a number of triangular segments that are oriented around a central point and extend as far out as a given radius. 8 | /// It is built counter-clockwise from a start angle and a given central angle. 9 | /// It can also be used to create regular polygons, where the number of segments determines the number of sides. 10 | /// This class inherits from 11 | /// Wrapper for three.js CircleGeometry 12 | /// 13 | /// 14 | public sealed class CircleGeometry : BufferGeometry 15 | { 16 | public CircleGeometry() : base("CircleGeometry") 17 | { 18 | } 19 | 20 | /// 21 | /// Constructor with parameters 22 | /// 23 | /// Radius of the circle. Default is 1. 24 | /// Number of segments (triangles). Minimum = 3, default = 8. 25 | /// Start angle for first segment. Default is 0 (three o'clock position). 26 | /// The central angle, often called theta, of the circular sector. The default is 2*Pi, which makes for a complete circle. 27 | public CircleGeometry(double radius = 1, int segments = 8, double thetaStart = 0, double thetaLength = (double)(2 * System.Math.PI)) : this() 28 | { 29 | Radius = radius; 30 | Segments = segments; 31 | ThetaStart = thetaStart; 32 | ThetaLength = thetaLength; 33 | } 34 | 35 | /// 36 | /// Radius of the circle. Default is 1. 37 | /// 38 | public double Radius { get; set; } = 1; 39 | 40 | /// 41 | /// Number of segments (triangles). Minimum = 3, default = 8. 42 | /// 43 | public int Segments { get; set; } = 8; 44 | 45 | /// 46 | /// Start angle for first segment. Default is 0 (three o'clock position). 47 | /// 48 | public double ThetaStart { get; set; } = 0; 49 | 50 | /// 51 | /// The central angle, often called theta, of the circular sector. The default is 2*Pi, which makes for a complete circle. 52 | /// 53 | public double ThetaLength { get; set; } = (double)(2 * System.Math.PI); 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/Curves/SplineCurveGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | using HomagGroup.Blazor3D.Maths; 3 | 4 | namespace HomagGroup.Blazor3D.Geometires.Curves 5 | { 6 | public class SplineCurveGeometry : BufferGeometry 7 | { 8 | public SplineCurveGeometry() : base("SplineCurveGeometry") 9 | {} 10 | 11 | public List Points { get; set; } = new List(); 12 | 13 | /// 14 | /// This value determines the amount of divisions when calculating the cumulative segment lengths of a curve via .getLengths. 15 | /// To ensure precision when using methods like .getSpacedPoints, it is recommended to increase .arcLengthDivisions if the curve is very large. Default is 200. 16 | /// 17 | public int ArcLengthDivisions { get; set; } = 200; 18 | 19 | /// 20 | /// number of pieces to divide the curve into. Default is 5. 21 | /// 22 | public int Divisions { get; set; } = 5; 23 | } 24 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/DodecahedronGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Geometires 4 | { 5 | /// 6 | /// A class for generating a dodecahedron geometries. 7 | /// Wrapper for three.js DodecahedronGeometry 8 | /// 9 | public class DodecahedronGeometry : BufferGeometry 10 | { 11 | public DodecahedronGeometry() : base("DodecahedronGeometry") 12 | { 13 | } 14 | 15 | /// 16 | /// Constructor with parametes 17 | /// 18 | /// Radius of the dodecahedron. Default is 1. 19 | /// Default is 0. Setting this to a value greater than 0 adds vertices making it no longer a dodecahedron. 20 | public DodecahedronGeometry(double radius = 1, int detail = 0) : this() 21 | { 22 | Radius = radius; 23 | Detail = detail; 24 | } 25 | 26 | /// 27 | /// Radius of the dodecahedron. Default is 1. 28 | /// 29 | public double Radius { get; set; } = 1; 30 | 31 | /// 32 | /// Default is 0. Setting this to a value greater than 0 adds vertices making it no longer a dodecahedron. 33 | /// 34 | public int Detail { get; set; } = 0; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/ExtrudeGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | using HomagGroup.Blazor3D.Extras.Core; 3 | 4 | namespace HomagGroup.Blazor3D.Geometires 5 | { 6 | /// 7 | /// Creates extruded geometry from a path shape. 8 | /// 9 | public class ExtrudeGeometry : BufferGeometry 10 | { 11 | public ExtrudeGeometry() : base("ExtrudeGeometry") 12 | { 13 | } 14 | 15 | /// 16 | /// Construcor with parameters. 17 | /// 18 | /// polygonal shape. 19 | /// options used for extrusion. 20 | public ExtrudeGeometry(Shape shape, ExtrudeGeometryOptions options) : this() 21 | { 22 | Shape = shape; 23 | ExtrudeOptions = options; 24 | } 25 | 26 | /// 27 | /// polygonal shape. 28 | /// 29 | public Shape Shape { get; set; } = new Shape(); 30 | 31 | /// 32 | /// options used for extrusion. 33 | /// 34 | public ExtrudeGeometryOptions ExtrudeOptions { get; set; } = new ExtrudeGeometryOptions(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/ExtrudeGeometryOptions.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Geometires 2 | { 3 | /// 4 | /// Options used for extrusion. 5 | /// 6 | public class ExtrudeGeometryOptions 7 | { 8 | /// 9 | /// Extrusion depth. Default is 1. 10 | /// 11 | public double Depth { get; set; } = 1; 12 | 13 | /// 14 | /// Apply beveling to the shape. Default is true. 15 | /// 16 | public bool BevelEnabled { get; set; } = true; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/IcosahedronGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Geometires 4 | { 5 | /// 6 | /// A class for generating an icosahedron geometry. 7 | /// Wrapper for three.js IcosahedronGeometry 8 | /// 9 | public class IcosahedronGeometry : BufferGeometry 10 | { 11 | public IcosahedronGeometry() : base("IcosahedronGeometry") 12 | { 13 | } 14 | 15 | /// 16 | /// Constructor with parameters 17 | /// 18 | /// Radius of the icosahedron. Default is 1. 19 | /// Default is 0. Setting this to a value greater than 0 adds more vertices making it no longer an icosahedron. When detail is greater than 1, it's closer to a sphere. 20 | public IcosahedronGeometry(double radius = 1, int detail = 0) : this() 21 | { 22 | Radius = radius; 23 | Detail = detail; 24 | } 25 | 26 | /// 27 | /// Radius of the icosahedron. Default is 1. 28 | /// 29 | public double Radius { get; set; } = 1; 30 | 31 | /// 32 | /// Default is 0. Setting this to a value greater than 0 adds more vertices making it no longer an icosahedron. When detail is greater than 1, it's closer to a sphere. 33 | /// 34 | public int Detail { get; set; } = 0; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/Lines/LineGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | using HomagGroup.Blazor3D.Maths; 3 | 4 | namespace HomagGroup.Blazor3D.Geometires.Lines 5 | { 6 | public class LineGeometry : BufferGeometry 7 | { 8 | public LineGeometry() : base("LineGeometry") 9 | { 10 | 11 | } 12 | 13 | public List Points { get; set; } = new List(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/OctahedronGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Geometires 4 | { 5 | /// 6 | /// A class for generating an octahedron geometry. 7 | /// Wrapper for three.js OctahedronGeometry 8 | /// 9 | public sealed class OctahedronGeometry : BufferGeometry 10 | { 11 | public OctahedronGeometry() : base("OctahedronGeometry") 12 | { 13 | } 14 | /// 15 | /// Constructor with parameters 16 | /// 17 | /// Radius of the octahedron. Default is 1. 18 | /// Default is 0. Setting this to a value greater than 0 adds more vertices making it no longer an octahedron. 19 | public OctahedronGeometry(double radius = 1, int detail = 0) : this() 20 | { 21 | Radius = radius; 22 | Detail = detail; 23 | } 24 | 25 | /// 26 | /// Radius of the octahedron. Default is 1. 27 | /// 28 | public double Radius { get; set; } = 1; 29 | 30 | /// 31 | /// Default is 0. Setting this to a value greater than 0 adds more vertices making it no longer an octahedron. 32 | /// 33 | public int Detail { get; set; } = 0; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/PlaneGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Geometires 4 | { 5 | /// 6 | /// A class for generating plane geometries. 7 | /// Wrapper for three.js PlaneGeometry 8 | /// 9 | public sealed class PlaneGeometry : BufferGeometry 10 | { 11 | public PlaneGeometry() : base("PlaneGeometry") 12 | { 13 | } 14 | /// 15 | /// Constructor with parameters 16 | /// 17 | /// The length of the edges parallel to the X axis. Default is 1. 18 | /// The length of the edges parallel to the Y axis. Default is 1. 19 | /// Number of segmented rectangular faces along the width of the sides. Default is 1. 20 | /// Number of segmented rectangular faces along the height of the sides. Default is 1. 21 | public PlaneGeometry(double width = 1, double height = 1, int widthSegments = 1, int heightSegments = 1) : this() 22 | { 23 | Width = width; 24 | Height = height; 25 | WidthSegments = widthSegments; 26 | HeightSegments = heightSegments; 27 | } 28 | 29 | /// 30 | /// The length of the edges parallel to the X axis. Default is 1. 31 | /// 32 | public double Width { get; set; } = 1; 33 | 34 | /// 35 | /// The length of the edges parallel to the Y axis. Default is 1. 36 | /// 37 | public double Height { get; set; } = 1; 38 | 39 | /// 40 | /// Number of segmented rectangular faces along the width of the sides. Default is 1. 41 | /// 42 | public int WidthSegments { get; set; } = 1; 43 | 44 | /// 45 | /// Number of segmented rectangular faces along the height of the sides. Default is 1. 46 | /// 47 | public int HeightSegments { get; set; } = 1; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/ShapeGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | using HomagGroup.Blazor3D.Extras.Core; 3 | 4 | namespace HomagGroup.Blazor3D.Geometires 5 | { 6 | /// 7 | /// Creates an one-sided polygonal geometry from one or more path shapes. 8 | /// 9 | public class ShapeGeometry : BufferGeometry 10 | { 11 | public ShapeGeometry() : base("ShapeGeometry") 12 | { 13 | } 14 | 15 | /// 16 | /// onstructor with parameters 17 | /// 18 | /// polygonal shape. 19 | public ShapeGeometry(Shape shape):this() 20 | { 21 | Shape = shape; 22 | } 23 | 24 | /// 25 | /// polygonal shape. 26 | /// 27 | public Shape Shape { get; set; } = new Shape(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/TetrahedronGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Geometires 4 | { 5 | /// 6 | /// A class for generating a tetrahedron geometries. 7 | /// Wrapper for three.js TetrahedronGeometry 8 | /// 9 | public sealed class TetrahedronGeometry : BufferGeometry 10 | { 11 | 12 | public TetrahedronGeometry() : base("TetrahedronGeometry") 13 | { 14 | } 15 | /// 16 | /// Constructor with parameters 17 | /// 18 | /// Radius of the tetrahedron. Default is 1. 19 | /// Default is 0. Setting this to a value greater than 0 adds more vertices making it no longer an tetrahedron. 20 | public TetrahedronGeometry(double radius = 1, int detail = 0) : this() 21 | { 22 | Radius = radius; 23 | Detail = detail; 24 | } 25 | 26 | /// 27 | /// Radius of the tetrahedron. Default is 1. 28 | /// 29 | public double Radius { get; set; } = 1; 30 | 31 | /// 32 | /// Default is 0. Setting this to a value greater than 0 adds more vertices making it no longer an tetrahedron. 33 | /// 34 | public int Detail { get; set; } = 0; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/Text/TextExtrudeGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Geometires.Text 4 | { 5 | /// 6 | /// Represents geometry to build extruded text 7 | /// 8 | public class TextExtrudeGeometry : TextShapeGeometry 9 | { 10 | public TextExtrudeGeometry() : base("TextExtrudeGeometry") 11 | { 12 | } 13 | 14 | /// 15 | /// Thickness to extrude text. Default is 50. 16 | /// 17 | public double Height { get; set; } = 50; 18 | 19 | /// 20 | /// Number of points on the curves. Default is 12. 21 | /// 22 | public int CurveSegments { get; set; } = 12; 23 | 24 | /// 25 | /// Turn on bevel. Default is False. 26 | /// 27 | public bool BevelEnabled { get; set; } = false; 28 | 29 | /// 30 | /// How deep into text bevel goes. Default is 10. 31 | /// 32 | public double BevelThickness { get; set; } = 10; 33 | 34 | /// 35 | /// How far from text outline is bevel. Default is 8. 36 | /// 37 | public double BevelSize { get; set; } = 8; 38 | 39 | /// 40 | /// How far from text outline bevel starts. Default is 0. 41 | /// 42 | public double BevelOffset { get; set; } = 0; 43 | 44 | /// 45 | /// Number of bevel segments 46 | /// 47 | public int BevelSegments { get; set; } = 3; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/Text/TextShapeGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Geometires.Text 4 | { 5 | /// 6 | /// Represents geometry to build shape text 7 | /// 8 | public class TextShapeGeometry : BufferGeometry 9 | { 10 | public TextShapeGeometry() : base("TextShapeGeometry") 11 | { 12 | } 13 | 14 | protected TextShapeGeometry(string type) : base(type) 15 | { 16 | } 17 | 18 | /// 19 | /// The text that needs to be shown 20 | /// 21 | public string Text { get; set; } = "Hello, HomagGroup.Blazor3D!"; 22 | 23 | /// 24 | /// The path or URL to the file. This can also be a Data URI 25 | /// 26 | public string FontURL { get; set; } = string.Empty; 27 | 28 | /// 29 | /// Size of the text. Default is 100. 30 | /// 31 | public double Size { get; set; } = 100; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/Text/TextStrokeGeometry.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Geometires.Text 2 | { 3 | /// 4 | /// Represents geometry to build stroke text 5 | /// 6 | public class TextStrokeGeometry : TextShapeGeometry 7 | { 8 | /// 9 | /// Constructor 10 | /// 11 | public TextStrokeGeometry() : base("TextStrokeGeometry") 12 | { 13 | } 14 | 15 | /// 16 | /// Stroke width 17 | /// 18 | public double StrokeWidth { get; set; } = 1; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Geometires/TorusGeometry.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Geometires 4 | { 5 | /// 6 | /// A class for generating torus geometries. 7 | /// Wrapper for three.js TorusGeometry 8 | /// 9 | public sealed class TorusGeometry : BufferGeometry 10 | { 11 | public TorusGeometry() : base("TorusGeometry") 12 | { 13 | } 14 | 15 | /// 16 | /// Constructor with parameters 17 | /// 18 | /// Radius of the torus, from the center of the torus to the center of the tube. Default is 1. 19 | /// Radius of the tube. Default is 0.4. 20 | /// Number of radial segments. Default is 8. 21 | /// Number of tubular segments. Default is 6. 22 | /// Central angle. Default is Math.PI * 2. 23 | public TorusGeometry(double radius = 1, double tube = 0.4f, int radialSegments = 8, int tubularSegments = 6, double arc = (double)(2 * Math.PI)) : this() 24 | { 25 | Radius = radius; 26 | Tube = tube; 27 | RadialSegments = radialSegments; 28 | TubularSegments = tubularSegments; 29 | Arc = arc; 30 | } 31 | 32 | /// 33 | /// Radius of the torus, from the center of the torus to the center of the tube. Default is 1. 34 | /// 35 | public double Radius { get; set; } = 1; 36 | 37 | /// 38 | /// Radius of the tube. Default is 0.4. 39 | /// 40 | public double Tube { get; set; } = 0.4f; 41 | 42 | /// 43 | /// Number of radial segments. Default is 8. 44 | /// 45 | public int RadialSegments { get; set; } = 8; 46 | 47 | /// 48 | /// Number of tubular segments. Default is 6. 49 | /// 50 | public int TubularSegments { get; set; } = 6; 51 | 52 | /// 53 | /// Central angle. Default is Math.PI * 2. 54 | /// 55 | public double Arc { get; set; } = (double)(2 * Math.PI); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Helpers/AxesHelper.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Helpers 4 | { 5 | /// 6 | /// An axis object to visualize the 3 axes in a simple way. 7 | /// The X axis is red.The Y axis is green.The Z axis is blue. 8 | /// This object inherits from 9 | /// Wrapper for three.js AxesHelper 10 | /// 11 | /// 12 | public sealed class AxesHelper : Object3D 13 | { 14 | public AxesHelper() : base("AxesHelper") 15 | { 16 | } 17 | 18 | /// 19 | /// Constructor with parameters 20 | /// 21 | /// Size of the lines representing the axes. Default is 1. 22 | public AxesHelper(double size = 1) : this() 23 | { 24 | Size = size; 25 | } 26 | 27 | 28 | /// 29 | /// Size of the lines representing the axes. Default is 1. 30 | /// 31 | public double Size { get; set; } = 1; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Helpers/BoxHelper.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Helpers 4 | { 5 | /// 6 | /// Helper object to graphically show the world-axis-aligned bounding box around an object. 7 | /// This object inherits from 8 | /// Wrapper for three.js BoxHelper 9 | /// 10 | /// 11 | public sealed class BoxHelper : Object3D 12 | { 13 | public BoxHelper() : base("BoxHelper") 14 | { 15 | } 16 | 17 | public BoxHelper(Object3D object3d = null!, string color = "0xffff00") : this() 18 | { 19 | Object3D = object3d; 20 | Color = color; 21 | } 22 | 23 | /// 24 | /// The to show the world-axis-aligned boundingbox. 25 | /// 26 | public Object3D Object3D { get; set; } = null!; 27 | 28 | public string Color { get; set; } = "0xffff00"; 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Helpers/GridHelper.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Helpers 4 | { 5 | /// 6 | /// The GridHelper is an object to define grids. Grids are two-dimensional arrays of lines. 7 | /// This object inherits from 8 | /// Wrapper for three.js GridHelper 9 | /// 10 | /// 11 | public sealed class GridHelper : Object3D 12 | { 13 | public GridHelper() : base("GridHelper") 14 | { 15 | } 16 | 17 | public GridHelper(double size = 10, int devisions = 10, string colorCenterLine = "0x444444", string colorGrid = "0x888888") : this() 18 | { 19 | Size = size; 20 | Divisions = devisions; 21 | ColorCenterLine = colorCenterLine; 22 | ColorGrid = colorGrid; 23 | } 24 | 25 | /// 26 | /// The size of the grid. Default is 10. 27 | /// 28 | public double Size { get; set; } = 10; 29 | 30 | /// 31 | /// The number of divisions across the grid. Default is 10. 32 | /// 33 | public int Divisions { get; set; } = 10; 34 | 35 | /// 36 | /// The color of the centerline. This can be a Color, a hexadecimal value and an CSS-Color name. Default is "0x444444:. 37 | /// 38 | public string ColorCenterLine { get; set; } = "0x444444"; 39 | 40 | /// 41 | /// The color of the lines of the grid. This can be a Color, a hexadecimal value and an CSS-Color name. Default is "0x888888". 42 | /// 43 | public string ColorGrid { get; set; } = "0x888888"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Helpers/PlaneHelper.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | using HomagGroup.Blazor3D.Maths; 3 | 4 | namespace HomagGroup.Blazor3D.Helpers 5 | { 6 | /// 7 | /// Helper object to visualize a . 8 | /// This object inherits from 9 | /// Wrapper for three.js PlaneHelper 10 | /// 11 | /// 12 | public sealed class PlaneHelper : Object3D 13 | { 14 | public PlaneHelper() : base("PlaneHelper") 15 | { 16 | } 17 | 18 | /// 19 | /// Constructor with parameters 20 | /// 21 | /// The to visualize. 22 | /// Side length of plane helper. Default is 1. 23 | /// The color of the helper. Default is "0xffff00". 24 | public PlaneHelper(Plane plane = null!, double size = 1, string color = "0xffff00") : this() 25 | { 26 | Plane = plane ?? new Plane(); 27 | Size = size; 28 | Color = color; 29 | } 30 | 31 | /// 32 | /// The to visualize. 33 | /// 34 | public Plane Plane { get; set; } = new Plane(); 35 | 36 | /// 37 | /// Side length of plane helper. Default is 1. 38 | /// 39 | public double Size { get; set; } = 1; 40 | 41 | /// 42 | /// The color of the helper. Default is "0xffff00". 43 | /// 44 | public string Color { get; set; } = "0xffff00"; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Helpers/PointLightHelper.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | using HomagGroup.Blazor3D.Lights; 3 | using HomagGroup.Blazor3D.Objects; 4 | 5 | namespace HomagGroup.Blazor3D.Helpers 6 | { 7 | /// 8 | /// This displays a helper object consisting of a spherical for visualizing a . 9 | /// This object inherits from 10 | /// Wrapper for three.js PointLightHelper 11 | /// 12 | public sealed class PointLightHelper : Object3D 13 | { 14 | public PointLightHelper() : base("PointLightHelper") 15 | { 16 | } 17 | 18 | /// 19 | /// Constructor with parameters 20 | /// 21 | /// The light to be visualized. Must be already added to the scene. 22 | /// The size of the sphere helper. Default is 1. 23 | /// The size of the sphere helper. If color is not set, the helper will take the color of the light. 24 | public PointLightHelper(PointLight light = null!, double sphereSize = 1, string color = null!) : this() 25 | { 26 | Light = light ?? new PointLight(); 27 | SphereSize = sphereSize; 28 | Color = color; 29 | } 30 | 31 | /// 32 | /// The light to be visualized. Must be already added to the scene. 33 | /// 34 | public PointLight Light { get; set; } = new PointLight(); 35 | 36 | /// 37 | /// The size of the sphere helper. Default is 1. 38 | /// 39 | public double SphereSize { get; set; } = 1; 40 | 41 | /// 42 | /// The size of the sphere helper. If color is not set, the helper will take the color of the light. 43 | /// 44 | public string Color { get; set; } = null!; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Helpers/PolarGridHelper.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | 4 | namespace HomagGroup.Blazor3D.Helpers 5 | { 6 | /// 7 | /// The PolarGridHelper is an object to define polar grids. Grids are two-dimensional arrays of lines. 8 | /// This object inherits from 9 | /// Wrapper for three.js PolarGridHelper 10 | /// 11 | /// 12 | public class PolarGridHelper : Object3D 13 | { 14 | public PolarGridHelper() : base("PolarGridHelper") 15 | { 16 | } 17 | 18 | public PolarGridHelper( 19 | double radius = 10, 20 | int radials = 16, 21 | int circles = 8, 22 | int divisions = 64, 23 | string color1 = "0x444444", 24 | string color2 = "0x888888") : this() 25 | { 26 | Radius = radius; 27 | Radials = radials; 28 | Circles = circles; 29 | Divisions = divisions; 30 | Color1 = color1; 31 | Color2 = color2; 32 | } 33 | 34 | /// 35 | /// The radius of the polar grid. This can be any positive number. Default is 10. 36 | /// 37 | public double Radius { get; set; } = 10; 38 | 39 | /// 40 | /// The number of radial lines. This can be any positive integer. Default is 16. 41 | /// 42 | public int Radials { get; set; } = 16; 43 | 44 | /// 45 | /// The number of circles. This can be any positive integer. Default is 8. 46 | /// 47 | public int Circles { get; set; } = 8; 48 | /// 49 | /// The number of line segments used for each circle. This can be any positive integer that is 3 or greater. Default is 64. 50 | /// 51 | public int Divisions { get; set; } = 64; 52 | 53 | /// 54 | /// The first color used for grid elements. This can be a Color, a hexadecimal value and an CSS-Color name. Default is "0x444444". 55 | /// 56 | public string Color1 { get; set; } = "0x444444"; 57 | 58 | /// 59 | /// The second color used for grid elements. This can be a Color, a hexadecimal value and an CSS-Color name. Default is 0x888888 60 | /// 61 | public string Color2 { get; set; } = "0x888888"; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/HomagGroup.Blazor3D.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | True 8 | ..\..\..\..\doc\HomagGroup.Blazor3D.xml 9 | 10 | 11 | 12 | Blazor3D 13 | HOMAG-Group 14 | Blazor3D, three.js, Blazor, Razor, Homag-Group, Homag, HomagGroup 15 | git 16 | https://github.com/HomagGroup/HomagGroup.Blazor3D-Core 17 | This Razor class library (RCL) contains the Blazor component which allows you create 3D scenes inside your Blazor application. 18 | This Blazor3D component uses three.js library to display 3D scenes on html canvas. 19 | See examples of using here https://github.com/HomagGroup/HomagGroup.Blazor3D 20 | 21 | Blazor3D 22 | 23 | 24 | 25 | 1701;1702;1591 26 | 27 | 28 | 29 | 1701;1702;1591 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Lights/AmbientLight.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Lights 2 | { 3 | /// 4 | /// This light globally illuminates all objects in the scene equally. 5 | /// This light cannot be used to cast shadows as it does not have a direction. 6 | /// This class inherits from 7 | /// Wrapper for three.js AmbientLight 8 | /// 9 | /// 10 | public sealed class AmbientLight : Light 11 | { 12 | public AmbientLight() : base("AmbientLight") 13 | { 14 | Intensity = 0.6f; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Lights/Light.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Lights 4 | { 5 | /// 6 | /// Abstract base class for lights. 7 | /// Wrapper for three.js Light 8 | /// 9 | /// 10 | public abstract class Light : Object3D 11 | { 12 | protected Light(string type = "Light") : base(type) 13 | { 14 | } 15 | 16 | /// 17 | /// Light color. 18 | /// You can use web color values to set up required color. 19 | /// Default value is "white" 20 | /// 21 | public string Color { get; set; } = "white"; 22 | 23 | /// 24 | /// Value of the light's strength/intensity. Default is 1. 25 | /// 26 | public double Intensity { get; set; } = 1; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Lights/PointLight.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Lights 2 | { 3 | /// 4 | /// A light that gets emitted from a single point in all directions. A common use case for this is to replicate the light emitted from a bare lightbulb. 5 | /// This light can cast shadows 6 | /// This class inherits from 7 | /// Wrapper for three.js PointLight 8 | /// 9 | /// 10 | public sealed class PointLight : Light 11 | { 12 | public PointLight() : base("PointLight") 13 | { 14 | 15 | } 16 | /// 17 | /// When distance value is NOT 0, light will attenuate linearly from maximum intensity at the light's position down to zero at this distance from the light. 18 | /// When distance is zero, light does not attenuate. 19 | /// Default is 0. 20 | /// 21 | public double Distance { get; set; } = 0; 22 | 23 | /// 24 | /// The amount the light dims along the distance of the light 25 | /// Default is 1. 26 | /// 27 | public double Decay { get; set; } = 1; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Materials/LineBasicMaterial.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Materials 2 | { 3 | /// 4 | /// A material for drawing wireframe-style geometries. 5 | /// 6 | public class LineBasicMaterial : Material 7 | { 8 | /// 9 | /// Default constructor 10 | /// 11 | public LineBasicMaterial() : base("LineBasicMaterial") 12 | { 13 | } 14 | 15 | /// 16 | /// Define appearance of line ends. Possible values are 'butt', 'round' and 'square'. Default is 'round'. 17 | /// 18 | public string LineCap { get; set; } = "round";// todo: deal with enum 19 | 20 | /// 21 | /// Define appearance of line joints. Possible values are 'round', 'bevel' and 'miter'. Default is 'round'. 22 | /// 23 | public string LineJoin { get; set; } = "round";// todo: deal with enum 24 | 25 | 26 | /// 27 | /// Controls line thickness. Default is 1. 28 | /// Due to limitations of the OpenGL Core Profile with the WebGL renderer on most platforms linewidth will always be 1 regardless of the set value. 29 | /// 30 | public double LineWidth { get; set; } = 1; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Materials/MeshStandardMaterial.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Textures; 2 | 3 | namespace HomagGroup.Blazor3D.Materials 4 | { 5 | /// 6 | /// A standard physically based Material, using Metallic-Roughness workflow. 7 | /// This class inherits from 8 | /// Wrapper for three.js MeshStandardMaterial 9 | /// 10 | /// 11 | public sealed class MeshStandardMaterial : Material 12 | { 13 | 14 | public MeshStandardMaterial() : base("MeshStandardMaterial") 15 | { 16 | 17 | } 18 | 19 | /// 20 | /// Define whether the material is rendered with flat shading. Default is false. 21 | /// 22 | public bool FlatShading { get; set; } = false; 23 | 24 | /// 25 | /// How much the material is like a metal. Non-metallic materials such as wood or stone use 0.0, metallic use 1.0, with nothing (usually) in between. Default is 0.0. A value between 0.0 and 1.0 could be used for a rusty metal look. If metalnessMap is also provided, both values are multiplied. 26 | /// 27 | public double Metalness { get; set; } = 0; 28 | 29 | /// 30 | /// How rough the material appears. 0.0 means a smooth mirror reflection, 1.0 means fully diffuse. Default is 1.0. If roughnessMap is also provided, both values are multiplied. 31 | /// 32 | public double Roughness { get; set; } = 1; 33 | 34 | /// 35 | /// Render geometry as wireframe. Default is false (i.e. render as flat polygons). 36 | /// 37 | public bool Wireframe { get; set; } = false; 38 | 39 | /// 40 | /// The color map. May optionally include an alpha channel, typically combined with Transparent (todo) or AlphaTest(todo). Default is null. The texture map color is modulated by the diffuse Color. 41 | /// 42 | public Texture Map { get; set; } = new Texture(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Materials/SpriteMaterial.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Maths; 2 | using HomagGroup.Blazor3D.Textures; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace HomagGroup.Blazor3D.Materials 10 | { 11 | public class SpriteMaterial : Material 12 | { 13 | public SpriteMaterial() : base("SpriteMaterial") 14 | { 15 | } 16 | 17 | /// 18 | /// The color map. May optionally include an alpha channel, typically combined with Transparent (todo) or AlphaTest(todo). Default is null. The texture map color is modulated by the diffuse Color. 19 | /// 20 | public Texture Map { get; set; } = new Texture(); 21 | 22 | /// 23 | /// Whether the size of the sprite is attenuated by the camera depth. (Perspective camera only.) 24 | /// Default is true. 25 | /// 26 | public bool SizeAttenuation { get; set; } = true; 27 | 28 | /// 29 | /// The rotation of the sprite in radians. Default is 0. 30 | /// 31 | public double Rotation { get; set; } = 0; 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Maths/Euler.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Maths 2 | { 3 | /// 4 | /// Representing Euler Angles. 5 | /// Euler angles describe a rotational transformation by rotating an object on its various axes in specified amounts per axis, and a specified axis order. 6 | /// Iterating through a Euler instance will yield its components (x, y, z, order) in the corresponding order. 7 | /// Wrapper for three.js Euler 8 | /// 9 | public sealed class Euler 10 | { 11 | /// 12 | /// The double angle of the X axis in radians. Default is 0. Optional. 13 | /// 14 | public double X { get; set; } 15 | /// 16 | /// The double angle of the Y axis in radians. Default is 0. Optional. 17 | /// 18 | public double Y { get; set; } 19 | /// 20 | /// The double angle of the Z axis in radians. Default is 0. Optional. 21 | /// 22 | public double Z { get; set; } 23 | /// 24 | /// String representing the order that the rotations are applied. Default is 'XYZ'. Must be upper case. 25 | /// 26 | public string Order { get; set; } = "XYZ"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Maths/Plane.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Maths 2 | { 3 | /// 4 | /// A two dimensional surface that extends infinitely in 3d space, represented in Hessian normal form by a unit length normal vector and a constant. 5 | /// Wrapper for three.js Plane 6 | /// 7 | public sealed class Plane 8 | { 9 | public Plane() 10 | { 11 | 12 | } 13 | 14 | /// 15 | /// Constructor with parameters. 16 | /// 17 | /// A unit length Vector3 defining the normal of the plane. Default is (1, 0, 0). 18 | /// The signed distance from the origin to the plane. Default is 0. 19 | public Plane(Vector3 normal = null!, double constant = 0) 20 | { 21 | Normal = normal ?? new Vector3(1, 0, 0); 22 | Constant = constant; 23 | } 24 | 25 | /// 26 | /// A unit length Vector3 defining the normal of the plane. Default is (1, 0, 0). 27 | /// 28 | public Vector3 Normal { get; set; } = new Vector3(1, 0, 0); 29 | 30 | /// 31 | /// The signed distance from the origin to the plane. Default is 0. 32 | /// 33 | public double Constant { get; set; } = 0; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Maths/Vector2.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Maths 2 | { 3 | /// 4 | /// Class representing a 2D vector. A 2D vector is an ordered pair of numbers (labeled x and y), which can be used to represent a number of things, such as point in 2D space, direction or any ordered pair of numbers. 5 | /// Wrapper for three.js Vector2 6 | /// 7 | public sealed class Vector2 8 | { 9 | /// 10 | /// Default constructor. 11 | /// 12 | public Vector2() 13 | { 14 | 15 | } 16 | 17 | /// 18 | /// Constructor with parameters. 19 | /// 20 | /// double X value of this vector. Default is 0. 21 | /// double Y value of this vector. Default is 0. 22 | public Vector2(double x, double y) 23 | { 24 | X = x; 25 | Y = y; 26 | } 27 | 28 | /// 29 | /// double X value of this vector. Default is 0. 30 | /// 31 | public double X { get; set; } 32 | 33 | /// 34 | /// double Y value of this vector. Default is 0. 35 | /// 36 | public double Y { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Maths/Vector3.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Maths 2 | { 3 | /// 4 | /// Class representing a 3D vector. A 3D vector is an ordered triplet of numbers (labeled x, y, and z), 5 | /// which can be used to represent a number of things, such as: 6 | ///
      7 | ///
    • A point in 3D space.
    • 8 | ///
    • A direction, length or scale in 3D space.
    • 9 | ///
    • Any arbitrary ordered triplet of numbers.
    • 10 | ///
    11 | /// Wrapper for three.js Vector3 12 | ///
    13 | public sealed class Vector3 14 | { 15 | /// 16 | /// Default constructor. 17 | /// 18 | public Vector3() 19 | { 20 | 21 | } 22 | 23 | /// 24 | /// Constructor with parameters. 25 | /// 26 | /// double X value of this vector. Default is 0. 27 | /// double Y value of this vector. Default is 0. 28 | /// double Z value of this vector. Default is 0. 29 | public Vector3(double x, double y, double z) 30 | { 31 | X = x; 32 | Y = y; 33 | Z = z; 34 | } 35 | 36 | /// 37 | /// double X value of this vector. Default is 0. 38 | /// 39 | public double X { get; set; } 40 | 41 | /// 42 | /// double Y value of this vector. Default is 0. 43 | /// 44 | public double Y { get; set; } 45 | 46 | /// 47 | /// double Z value of this vector. Default is 0. 48 | /// 49 | public double Z { get; set; } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Objects/Group.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Objects 4 | { 5 | /// 6 | /// This is almost identical to an . Its purpose is to make working with groups of objects syntactically clearer. 7 | /// This object inherits from 8 | /// Wrapper for three.js Group 9 | /// 10 | /// 11 | public sealed class Group : Object3D 12 | { 13 | public Group() : base("Group") 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Objects/Line.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | using HomagGroup.Blazor3D.Geometires; 3 | using HomagGroup.Blazor3D.Geometires.Lines; 4 | using HomagGroup.Blazor3D.Materials; 5 | 6 | namespace HomagGroup.Blazor3D.Objects 7 | { 8 | public class Line : Object3D 9 | { 10 | public Line() : base("Line") { } 11 | 12 | /// 13 | /// Collection of (or derived classes) materials, defining the object's appearance. 14 | /// 15 | public Material Material { get; set; } = new LineBasicMaterial(); 16 | 17 | /// 18 | /// An instance of (or derived classes), defining the object's structure. 19 | /// 20 | public BufferGeometry Geometry { get; set; } = new LineGeometry(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Objects/Mesh.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | using HomagGroup.Blazor3D.Geometires; 3 | using HomagGroup.Blazor3D.Materials; 4 | 5 | namespace HomagGroup.Blazor3D.Objects 6 | { 7 | /// 8 | /// Class representing triangulated polygon mesh based objects. Also serves as a base for other classes. 9 | /// This object inherits from 10 | /// Wrapper for three.js Mesh 11 | /// 12 | /// 13 | public class Mesh : Object3D 14 | { 15 | public Mesh() : base("Mesh") 16 | { 17 | 18 | } 19 | 20 | protected Mesh(string type) : base(type) 21 | { 22 | 23 | } 24 | 25 | //TODO: make Array of materials 26 | /// 27 | /// Collection of (or derived classes) materials, defining the object's appearance. 28 | /// 29 | public Material Material { get; set; } = new MeshStandardMaterial(); 30 | 31 | /// 32 | /// An instance of (or derived classes), defining the object's structure. 33 | /// 34 | public BufferGeometry Geometry { get; set; } = new BoxGeometry(); 35 | 36 | /// 37 | /// Material to draw edges with EdgesGeometry. If not specified, no edges will be drawn. 38 | /// 39 | public LineBasicMaterial EdgesMaterial { get; set; } = null!; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Objects/Sprite.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | using HomagGroup.Blazor3D.Geometires; 3 | using HomagGroup.Blazor3D.Materials; 4 | using HomagGroup.Blazor3D.Maths; 5 | using HomagGroup.Blazor3D.Textures; 6 | 7 | namespace HomagGroup.Blazor3D.Objects 8 | { 9 | /// 10 | /// Class representing triangulated polygon mesh based objects. Also serves as a base for other classes. 11 | /// This object inherits from 12 | /// Wrapper for three.js Mesh 13 | /// 14 | /// 15 | public class Sprite : Object3D 16 | { 17 | public Sprite() : base("Sprite") 18 | { 19 | 20 | } 21 | 22 | protected Sprite(string type) : base(type) 23 | { 24 | 25 | } 26 | 27 | /// 28 | /// Collection of (or derived classes) materials, defining the object's appearance. 29 | /// 30 | public SpriteMaterial Material { get; set; } = new SpriteMaterial(); 31 | 32 | /// 33 | /// The sprite's anchor point, and the point around which the sprite rotates. A value of (0.5,0.5) 34 | /// coresponds to the midpoint of the sprite. A value of (0,0) corresponds to the lower left corner of the sprite. 35 | /// The default is (0.5,0.5) 36 | /// 37 | public Vector2 Center { get; set; } = new Vector2(0.5,0.5); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Objects/Text.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Objects 2 | { 3 | public class Text : Mesh 4 | { 5 | public Text() : base("Text") 6 | { 7 | 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Scenes/Scene.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Core; 2 | 3 | namespace HomagGroup.Blazor3D.Scenes 4 | { 5 | /// 6 | /// Scenes allow you to set up what and where is to be rendered by HomagGroup.Blazor3D. 7 | /// This is the place where you put your 3D objects and lights. 8 | /// This object inherits from 9 | /// Wrapper for three.js Scene 10 | /// 11 | /// 12 | public sealed class Scene : Object3D 13 | { 14 | public Scene() : base("Scene") 15 | { 16 | 17 | } 18 | 19 | /// 20 | /// Scene background color. 21 | /// You can use web color values to set up required color. 22 | /// Default value is "DarkSlateBlue"> 23 | /// 24 | public string BackGroundColor { get; set; } = "DarkSlateBlue"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Settings/AnimateObject3DSettings.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Maths; 2 | 3 | namespace HomagGroup.Blazor3D.Settings; 4 | 5 | /// 6 | /// Settings used for animations on Object3D/>. 7 | /// 8 | public class AnimateObject3DSettings 9 | { 10 | /// 11 | /// The option indicates whether the animation on the object should be applied. Default is false. 12 | /// 13 | public bool AnimateObject { get; set; } = false; 14 | 15 | /// 16 | /// a list of points representing the path for object movement. 17 | /// 18 | public List Points { get; set; } = new List(); 19 | 20 | /// 21 | /// The animation speed 22 | /// 23 | public int Speed { get; set; } = 1; 24 | 25 | /// 26 | /// An index pointer for traversing the list 27 | /// 28 | public int IndexPointer { get; set; } = 0; 29 | 30 | /// 31 | /// The option to indicate whether the animation should restart when it finishes. 32 | /// 33 | public bool LoopAnimation { get; set; } = false; 34 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Settings/AnimateRotationSettings.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Maths; 2 | 3 | namespace HomagGroup.Blazor3D.Settings 4 | { 5 | /// 6 | /// Settings used for animated rotations. 7 | /// 8 | public sealed class AnimateRotationSettings 9 | { 10 | public AnimateRotationSettings() 11 | { 12 | 13 | } 14 | 15 | /// 16 | /// Constructor with parameters 17 | /// 18 | /// The option indicates whether the rotation animation should be applied. Default is false. 19 | /// The angle in degreees to rotate around the X axis on each animation frame. Default is 0.1. 20 | /// The angle in degreees to rotate around the Y axis on each animation frame. Default is 0.1. 21 | /// The angle in degreees to rotate around the Z axis on each animation frame. Default is 0.1. 22 | /// Radius of rotation. Default is 5. 23 | public AnimateRotationSettings(bool animateRotation = false, double thetaX = 0.1, double thetaY = 0.1, double thetaZ = 0.1, double radius = 5) 24 | { 25 | AnimateRotation = animateRotation; 26 | ThetaX = thetaX; 27 | ThetaY = thetaY; 28 | ThetaZ = thetaZ; 29 | Radius = radius; 30 | } 31 | 32 | /// 33 | /// The option indicates whether the rotation animation should be applied. Default is false. 34 | /// 35 | public bool AnimateRotation { get; set; } = false; 36 | 37 | /// 38 | /// The angle in degreees to rotate around the X axis on each animation frame. Default is 0.1. 39 | /// 40 | public double ThetaX { get; set; } = 0.1; 41 | /// 42 | /// The angle in degreees to rotate around the Y axis on each animation frame. Default is 0.1. 43 | /// 44 | public double ThetaY { get; set; } = 0.1; 45 | /// 46 | /// The angle in degreees to rotate around the Z axis on each animation frame. Default is 0.1. 47 | /// 48 | public double ThetaZ { get; set; } = 0.1; 49 | /// 50 | /// Radius of rotation. Default is 5. 51 | /// 52 | public double Radius { get; set; } = 5; 53 | /// 54 | /// Stops animation when user starts using orbit controls. Default is false. 55 | /// 56 | public bool StopAnimationOnOrbitControlMove { get; set; } = false; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Settings/ImportSettings.cs: -------------------------------------------------------------------------------- 1 |  2 | using HomagGroup.Blazor3D.Enums; 3 | using HomagGroup.Blazor3D.Materials; 4 | using Newtonsoft.Json; 5 | using Newtonsoft.Json.Converters; 6 | 7 | namespace HomagGroup.Blazor3D.Settings 8 | { 9 | /// 10 | /// Settings that will be applied during 3D model file importing. 11 | /// 12 | public class ImportSettings 13 | { 14 | /// 15 | /// format of 3D model. 16 | /// 17 | [JsonConverter(typeof(StringEnumConverter))] //todo: may be use serialization helper 18 | public Import3DFormats Format { get; set; } 19 | /// 20 | /// URL of the 3D model file. 21 | /// 22 | public string FileURL { get; set; } = null!; 23 | /// 24 | /// URL of the texture file 25 | /// 26 | public string? TextureURL { get; set; } = null; 27 | /// 28 | /// UUID of the object to be loaded. Nullable. If not specified, the new Guid is genrated. 29 | /// 30 | public Guid? Uuid { get; set; } = null; 31 | /// 32 | /// Material that will be applied to all loaded meshes. 33 | /// Currently works only for STL format. 34 | /// If not specified, the default is applied to the imported objects. 35 | /// 36 | public MeshStandardMaterial Material { get; set; } = null!; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Settings/SpriteImportSettings.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Enums; 2 | using HomagGroup.Blazor3D.Materials; 3 | using HomagGroup.Blazor3D.Maths; 4 | using Newtonsoft.Json.Converters; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace HomagGroup.Blazor3D.Settings 12 | { 13 | public class SpriteImportSettings 14 | { 15 | /// 16 | /// URL of the sprite image. 17 | /// 18 | public string FileURL { get; set; } = null!; 19 | 20 | /// 21 | /// UUID of the object to be loaded. Nullable. If not specified, the new Guid is genrated. 22 | /// 23 | public Guid? Uuid { get; set; } = null; 24 | 25 | /// 26 | /// Material that will be applied to loaded sprites. 27 | /// If not specified, the default is applied to the imported objects. 28 | /// 29 | public SpriteMaterial Material { get; set; } = null!; 30 | 31 | /// 32 | /// Optional name of the object. Default is an empty string. It has not to be unique. 33 | /// 34 | public string Name { get; set; } = string.Empty; 35 | 36 | /// 37 | /// A Vector3 representing the object's local position. Default is (0,0,0). 38 | /// 39 | public Vector3 Position { get; set; } = new Vector3(0, 0, 0); 40 | 41 | /// 42 | /// Ojbect's local rotation 43 | /// 44 | public Euler Rotation { get; set; } = new Euler(); 45 | 46 | /// 47 | /// The object's local scale. Default is a Vector3(1, 1, 1) 48 | /// 49 | public Vector3 Scale { get; set; } = new Vector3(1, 1, 1); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Settings/ViewerSettings.cs: -------------------------------------------------------------------------------- 1 | using HomagGroup.Blazor3D.Viewers; 2 | 3 | namespace HomagGroup.Blazor3D.Settings 4 | { 5 | /// 6 | /// Class for HomagGroup.Blazor3D Viewer settings. 7 | /// 8 | public sealed class ViewerSettings 9 | { 10 | /// 11 | /// Identifier of the html container where instance will be created. 12 | /// Must be unique on the html page! Default is "blazorview3d" 13 | /// 14 | public string ContainerId { get; set; } = "blazorview3d"; 15 | 16 | /// 17 | /// If true, user can select objects by mouse. Default is false. 18 | /// 19 | public bool CanSelect { get; set; } = false; 20 | 21 | /// 22 | /// If true, the helpers can be selected by mouse. Default is false. 23 | /// 24 | public bool CanSelectHelpers { get; set; } = false; 25 | 26 | /// 27 | /// Color the selected element is highlighted. Default is "lime". 28 | /// 29 | public string SelectedColor { get; set; } = "lime"; 30 | 31 | /// 32 | /// Show or hide ViewHelper 33 | /// 34 | public bool ShowViewHelper { get; set; } = true; 35 | 36 | /// 37 | /// HomagGroup.Blazor3D Viewer WebGLRenderer settings 38 | /// 39 | public WebGLRendererSettings WebGLRendererSettings { get; set; } = new WebGLRendererSettings(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Settings/WebGLRendererSettings.cs: -------------------------------------------------------------------------------- 1 | namespace HomagGroup.Blazor3D.Settings 2 | { 3 | /// 4 | /// Class for HomagGroup.Blazor3D Viewer WebGLRenderer settings. 5 | /// 6 | public class WebGLRendererSettings 7 | { 8 | /// 9 | /// Whether to perform antialiasing. Default is true. 10 | /// 11 | public bool Antialias { get; set; } = true; 12 | 13 | /// 14 | /// controls the default clear alpha value. When set to true, the value is 0. Otherwise it's 1. Default is false. 15 | /// 16 | public bool Alpha { get; set; } = false; 17 | 18 | /// 19 | /// whether the renderer will assume that colors have premultiplied alpha. Default is true. 20 | /// 21 | public bool PremultipliedAlpha { get; set; } = true; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Viewers/Viewer.razor: -------------------------------------------------------------------------------- 1 | @inject IJSRuntime JSRuntime 2 | @implements IDisposable 3 | 4 |
    5 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/Viewers/Viewer.razor.css: -------------------------------------------------------------------------------- 1 | .viewer3dContainer { 2 | width: 100%; 3 | height:100%; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @using Microsoft.JSInterop 3 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Blazor3D/wwwroot/js/bundle.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | * Copyright © 2022 Roman Simuta aka siroman 3 | * Copyright © 2010-2021 three.js authors https://threejs.org/ 4 | */ 5 | 6 | /*! 7 | fflate - fast JavaScript compression/decompression 8 | 9 | Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE 10 | version 0.6.9 11 | */ 12 | 13 | /** 14 | * @license 15 | * Copyright 2010-2022 Three.js Authors 16 | * SPDX-License-Identifier: MIT 17 | */ 18 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Not found 8 | 9 |

    Sorry, there's nothing at this address.

    10 |
    11 |
    12 |
    13 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model TestServer.Pages.ErrorModel 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Error 11 | 12 | 13 | 14 | 15 | 16 |
    17 |
    18 |

    Error.

    19 |

    An error occurred while processing your request.

    20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

    24 | Request ID: @Model.RequestId 25 |

    26 | } 27 | 28 |

    Development Mode

    29 |

    30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

    32 |

    33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

    38 |
    39 |
    40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace TestServer.Pages 6 | { 7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 8 | [IgnoreAntiforgeryToken] 9 | public class ErrorModel : PageModel 10 | { 11 | public string? RequestId { get; set; } 12 | 13 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 14 | 15 | private readonly ILogger _logger; 16 | 17 | public ErrorModel(ILogger logger) 18 | { 19 | _logger = logger; 20 | } 21 | 22 | public void OnGet() 23 | { 24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace TestServer.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = "_Layout"; 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/Pages/_Layout.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | @namespace TestServer.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | @RenderBody() 18 | 19 |
    20 | 21 | An error has occurred. This application may no longer respond until reloaded. 22 | 23 | 24 | An unhandled exception has occurred. See browser dev tools for details. 25 | 26 | Reload 27 | 🗙 28 |
    29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.AspNetCore.Components.Web; 3 | 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | 7 | // Add services to the container. 8 | builder.Services.AddRazorPages(); 9 | builder.Services.AddServerSideBlazor(); 10 | 11 | var app = builder.Build(); 12 | 13 | // Configure the HTTP request pipeline. 14 | if (!app.Environment.IsDevelopment()) 15 | { 16 | app.UseExceptionHandler("/Error"); 17 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 18 | app.UseHsts(); 19 | } 20 | 21 | app.UseHttpsRedirection(); 22 | 23 | app.UseStaticFiles(); 24 | 25 | app.UseRouting(); 26 | 27 | app.MapBlazorHub(); 28 | app.MapFallbackToPage("/_Host"); 29 | 30 | app.Run(); 31 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:7034", 7 | "sslPort": 44309 8 | } 9 | }, 10 | "profiles": { 11 | "TestServer": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "applicationUrl": "https://localhost:7027;http://localhost:5027", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | TestServer 4 | 5 |
    6 | 9 | 10 |
    11 |
    12 | About 13 |
    14 | 15 |
    16 | @Body 17 |
    18 |
    19 |
    20 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 640.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 641px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .top-row, article { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 |
    11 | 48 |
    49 | 50 | @code { 51 | private bool collapseNavMenu = true; 52 | 53 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 54 | 55 | private void ToggleNavMenu() 56 | { 57 | collapseNavMenu = !collapseNavMenu; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/TestServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using TestServer 10 | @using TestServer.Shared 11 | @using HomagGroup.Blazor3D 12 | @using HomagGroup.Blazor3D.Settings 13 | 14 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft.AspNetCore": "Warning" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestServer/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestServer/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestServer/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestServer/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestServer/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/wwwroot/images/Blazor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestServer/wwwroot/images/Blazor.png -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestServer/wwwroot/uv_grid_opengl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestServer/wwwroot/uv_grid_opengl.jpg -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/App.razor: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Not found 8 | 9 |

    Sorry, there's nothing at this address.

    10 |
    11 |
    12 |
    13 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @using HomagGroup.Blazor3D.Enums 3 | @using HomagGroup.Blazor3D.Geometires 4 | @using HomagGroup.Blazor3D.Lights 5 | @using HomagGroup.Blazor3D.Maths 6 | @using HomagGroup.Blazor3D.Objects 7 | @using HomagGroup.Blazor3D.Scenes 8 | @using HomagGroup.Blazor3D.Viewers 9 | 10 |
    11 |
    12 | 13 |
    14 |
    15 | 16 |
    17 | 18 |
    19 | 20 | @code { 21 | private Viewer View3D1 = null!; 22 | private Guid objGuid; 23 | private ViewerSettings settings = new ViewerSettings() 24 | { 25 | ContainerId = "rsid", 26 | }; 27 | 28 | private Scene scene = new Scene(); 29 | 30 | protected override Task OnInitializedAsync() 31 | { 32 | scene.Add(new AmbientLight()); 33 | scene.Add(new PointLight() 34 | { 35 | Decay = 2, 36 | Position = new Vector3 37 | { 38 | X = 1, 39 | Y = 3, 40 | Z = 0 41 | } 42 | }); 43 | scene.Add(new Mesh()); 44 | scene.Add(new Mesh 45 | { 46 | Geometry = new BoxGeometry 47 | { 48 | Width = 2, 49 | Height = 0.5f 50 | }, 51 | Position = new Vector3 52 | { 53 | X = -1, 54 | Y = 1, 55 | Z = -1 56 | } 57 | , 58 | Rotation = new Euler 59 | { 60 | X = Math.PI/4 61 | } 62 | }); 63 | 64 | scene.Add(new Mesh 65 | { 66 | Geometry = new CircleGeometry(), 67 | Position = new Vector3 68 | { 69 | X = 1, 70 | Y = 1, 71 | Z = -1 72 | }, 73 | Scale = new Vector3(0.5f, 1f, 1f) 74 | }); 75 | 76 | return base.OnInitializedAsync(); 77 | } 78 | 79 | private async Task OnLoadObjButtonClick() 80 | { 81 | //await View3D1.Import3DModelAsync( 82 | // Import3DFormats.Fbx, 83 | // "https://threejs.org/examples/models/fbx/Samba%20Dancing.fbx", 84 | // null, 85 | // Guid.NewGuid()); 86 | // await View3D1.SetCameraPositionAsync(new Vector3(0, 100, 250)); 87 | 88 | // await View3D1.Import3DModelAsync( 89 | // Import3DFormats.Gltf, 90 | // "https://threejs.org/examples/models/gltf/DamagedHelmet/glTF/DamagedHelmet.gltf", 91 | // null, 92 | // Guid.NewGuid()); 93 | // await View3D1.SetCameraPositionAsync(new Vector3(0, 1, 5)); 94 | } 95 | 96 | } 97 | 98 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.Web; 2 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 3 | using TestWebAsm; 4 | 5 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 6 | builder.RootComponents.Add("#app"); 7 | builder.RootComponents.Add("head::after"); 8 | 9 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 10 | 11 | await builder.Build().RunAsync(); 12 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:21892", 7 | "sslPort": 44332 8 | } 9 | }, 10 | "profiles": { 11 | "TestWebAsm": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 16 | "applicationUrl": "https://localhost:7097;http://localhost:5097", 17 | "environmentVariables": { 18 | "ASPNETCORE_ENVIRONMENT": "Development" 19 | } 20 | }, 21 | "IIS Express": { 22 | "commandName": "IISExpress", 23 | "launchBrowser": true, 24 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
    4 | 7 | 8 |
    9 |
    10 | About 11 |
    12 | 13 |
    14 | @Body 15 |
    16 |
    17 |
    18 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row:not(.auth) { 41 | display: none; 42 | } 43 | 44 | .top-row.auth { 45 | justify-content: space-between; 46 | } 47 | 48 | .top-row ::deep a, .top-row ::deep .btn-link { 49 | margin-left: 0; 50 | } 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .page { 55 | flex-direction: row; 56 | } 57 | 58 | .sidebar { 59 | width: 250px; 60 | height: 100vh; 61 | position: sticky; 62 | top: 0; 63 | } 64 | 65 | .top-row { 66 | position: sticky; 67 | top: 0; 68 | z-index: 1; 69 | } 70 | 71 | .top-row.auth ::deep a:first-child { 72 | flex: 1; 73 | text-align: right; 74 | width: 0; 75 | } 76 | 77 | .top-row, article { 78 | padding-left: 2rem !important; 79 | padding-right: 1.5rem !important; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  9 | 10 |
    11 | 18 |
    19 | 20 | @code { 21 | private bool collapseNavMenu = true; 22 | 23 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 24 | 25 | private void ToggleNavMenu() 26 | { 27 | collapseNavMenu = !collapseNavMenu; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/TestWebAsm.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using TestWebAsm 10 | @using TestWebAsm.Shared 11 | @using HomagGroup.Blazor3D 12 | @using HomagGroup.Blazor3D.Settings 13 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | h1:focus { 8 | outline: none; 9 | } 10 | 11 | a, .btn-link { 12 | color: #0071c1; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .content { 22 | padding-top: 1.1rem; 23 | } 24 | 25 | .valid.modified:not([type=checkbox]) { 26 | outline: 1px solid #26b050; 27 | } 28 | 29 | .invalid { 30 | outline: 1px solid red; 31 | } 32 | 33 | .validation-message { 34 | color: red; 35 | } 36 | 37 | #blazor-error-ui { 38 | background: lightyellow; 39 | bottom: 0; 40 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 41 | display: none; 42 | left: 0; 43 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 44 | position: fixed; 45 | width: 100%; 46 | z-index: 1000; 47 | } 48 | 49 | #blazor-error-ui .dismiss { 50 | cursor: pointer; 51 | position: absolute; 52 | right: 0.75rem; 53 | top: 0.5rem; 54 | } 55 | 56 | .blazor-error-boundary { 57 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 58 | padding: 1rem 1rem 1rem 3.7rem; 59 | color: white; 60 | } 61 | 62 | .blazor-error-boundary::after { 63 | content: "An error has occurred." 64 | } 65 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestWebAsm/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestWebAsm/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestWebAsm/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestWebAsm/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestWebAsm/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/wwwroot/icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HomagGroup/Blazor3D-Core/b49ca6c22fce72bab048f8ff2d3c64220d2129f8/src/dotnet/Blazor3D/TestWebAsm/wwwroot/icon-192.png -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/TestWebAsm/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | TestWebAsm 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
    Loading...
    16 | 17 |
    18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
    22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/dotnet/Blazor3D/Todo.txt: -------------------------------------------------------------------------------- 1 | - basic geometries 2 | -------------------------------------------------------------------------------- /src/javascript/Builders/CameraBuilder.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import Transforms from "../Utils/Transforms"; 3 | 4 | class CameraBuilder { 5 | 6 | static BuildCamera(options, aspect) { 7 | let camera; 8 | if ((options.type == "PerspectiveCamera")) { 9 | camera = new THREE.PerspectiveCamera( 10 | options.fov, 11 | aspect, 12 | options.near, 13 | options.far 14 | ); 15 | } 16 | 17 | if ((options.type == "OrthographicCamera")) { 18 | camera = new THREE.OrthographicCamera( 19 | options.left * aspect, 20 | options.right * aspect, 21 | options.top, 22 | options.bottom, 23 | options.near, 24 | options.far 25 | ); 26 | camera.zoom = options.zoom; 27 | } 28 | 29 | camera.uuid = options.uuid; 30 | Transforms.setPosition(camera, options.position); 31 | Transforms.setRotation(camera, options.rotation); 32 | Transforms.setScale(camera, options.scale); 33 | camera.up = new THREE.Vector3(options.up.x, options.up.y, options.up.z); 34 | let {x, y, z} = options.lookAt; 35 | camera.lookAt(x, y, z); 36 | return camera; 37 | } 38 | } 39 | 40 | export default CameraBuilder; 41 | -------------------------------------------------------------------------------- /src/javascript/Builders/GroupBuilder.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import Transforms from "../Utils/Transforms"; 3 | import SceneBuilder from "./SceneBuilder"; 4 | 5 | class GroupBuilder { 6 | 7 | static BuildGroup(options, scene) { 8 | const group = new THREE.Group(); 9 | options.children.forEach((childOptions) => { 10 | // todo: changes for text here (see Viewer.SetScene) 11 | var child = SceneBuilder.BuildChild(childOptions, scene); 12 | if (child) { 13 | group.add(child); 14 | } 15 | }); 16 | Transforms.setPosition(group, options.position); 17 | Transforms.setRotation(group, options.rotation); 18 | Transforms.setScale(group, options.scale); 19 | return group; 20 | } 21 | } 22 | 23 | export default GroupBuilder; -------------------------------------------------------------------------------- /src/javascript/Builders/LightBuilder.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import Transforms from "../Utils/Transforms"; 3 | 4 | class LightBuilder { 5 | static BuildAmbientLight(options) { 6 | const light = new THREE.AmbientLight(options.color, options.intensity); 7 | Transforms.setPosition(light, options.position); 8 | return light; 9 | } 10 | 11 | static BuildPointLight(options) { 12 | const light = new THREE.PointLight( 13 | options.color, 14 | options.intensity, 15 | options.distance, 16 | options.decay 17 | ); 18 | light.uuid = options.uuid; 19 | Transforms.setPosition(light, options.position); 20 | return light; 21 | } 22 | } 23 | 24 | export default LightBuilder; 25 | -------------------------------------------------------------------------------- /src/javascript/Builders/LineBuilder.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import Transforms from "../Utils/Transforms"; 3 | import GeometryBuilder from "./GeometryBuilder"; 4 | import MaterialBuilder from "./MaterialBuilder"; 5 | 6 | class LineBuilder { 7 | static BuildMesh(options) { 8 | const geometry = GeometryBuilder.buildGeometry(options.geometry); 9 | const material = MaterialBuilder.buildMaterial(options.material); 10 | const line = new THREE.Line(geometry, material); 11 | 12 | //todo: linecaps ... 13 | 14 | 15 | line.uuid = options.uuid; 16 | Transforms.setPosition(line, options.position); 17 | Transforms.setRotation(line,options.rotation); 18 | Transforms.setScale(line,options.scale); 19 | return line; 20 | } 21 | } 22 | 23 | export default LineBuilder; 24 | -------------------------------------------------------------------------------- /src/javascript/Builders/MaterialBuilder.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import TextureBuilder from "./TextureBuilder"; 3 | 4 | class MaterialBuilder { 5 | static buildMaterial(options) { 6 | if (options.type == "MeshStandardMaterial") { 7 | 8 | let map = TextureBuilder.buildTexture(options.map); 9 | 10 | const material = new THREE.MeshStandardMaterial({ 11 | color: options.color, 12 | transparent : options.transparent, 13 | opacity : options.opacity, 14 | flatShading : options.flatShading, 15 | metalness: options.metalness, 16 | roughness: options.roughness, 17 | wireframe: options.wireframe, 18 | map: map, 19 | depthTest: options.depthTest, 20 | depthWrite: options.depthWrite 21 | }); 22 | material.uuid = options.uuid; 23 | return material; 24 | } 25 | 26 | if (options.type == "LineBasicMaterial") { 27 | 28 | const material = new THREE.LineBasicMaterial({ 29 | color: options.color, 30 | transparent : options.transparent, 31 | opacity : options.opacity, 32 | linecap : options.lineCap, 33 | linejoin : options.lineJoin, 34 | linewidth : options.lineWidth, 35 | depthTest: options.depthTest, 36 | depthWrite: options.depthWrite 37 | }); 38 | material.uuid = options.uuid; 39 | return material; 40 | } 41 | 42 | if(options.type == "SpriteMaterial") { 43 | let map = TextureBuilder.buildTexture(options.map); 44 | const material = new THREE.SpriteMaterial({ 45 | isSpriteMaterial:true, 46 | color: options.color, 47 | transparent : options.transparent, 48 | opacity : options.opacity, 49 | map: map, 50 | rotation: options.rotation, 51 | depthTest: options.depthTest, 52 | depthWrite: options.depthWrite 53 | }) 54 | material.uuid = options.uuid; 55 | return material; 56 | } 57 | } 58 | } 59 | 60 | export default MaterialBuilder; 61 | -------------------------------------------------------------------------------- /src/javascript/Builders/MeshBuilder.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import Transforms from "../Utils/Transforms"; 3 | import GeometryBuilder from "./GeometryBuilder"; 4 | import MaterialBuilder from "./MaterialBuilder"; 5 | 6 | class MeshBuilder { 7 | static BuildMesh(options) { 8 | const geometry = GeometryBuilder.buildGeometry(options.geometry); 9 | const material = MaterialBuilder.buildMaterial(options.material); 10 | const mesh = new THREE.Mesh(geometry, material); 11 | mesh.uuid = options.uuid; 12 | 13 | if (options.edgesMaterial) { 14 | const edges = this.BuildEdges(geometry, options.edgesMaterial); 15 | mesh.add(edges); 16 | } 17 | 18 | Transforms.setPosition(mesh, options.position); 19 | Transforms.setRotation(mesh, options.rotation); 20 | Transforms.setScale(mesh, options.scale); 21 | return mesh; 22 | } 23 | 24 | static BuildEdges(geometry, options) { 25 | const edges = new THREE.EdgesGeometry(geometry); 26 | const material = MaterialBuilder.buildMaterial(options); 27 | return new THREE.LineSegments(edges, material); 28 | } 29 | } 30 | 31 | export default MeshBuilder; 32 | -------------------------------------------------------------------------------- /src/javascript/Builders/SceneBuilder.js: -------------------------------------------------------------------------------- 1 | import HelperBuilder from "./HelperBuilder"; 2 | import LightBuilder from "./LightBuilder"; 3 | import MeshBuilder from "./MeshBuilder"; 4 | import GroupBuilder from "./GroupBuilder"; 5 | import LineBuilder from "./LineBuilder"; 6 | import SpriteBuilder from "./SpriteBuilder"; 7 | 8 | class SceneBuilder { 9 | 10 | static BuildChild(options, scene) { 11 | if (options.type == "Mesh") { 12 | return MeshBuilder.BuildMesh(options); 13 | } 14 | 15 | if (options.type == "Line") { 16 | return LineBuilder.BuildMesh(options); 17 | } 18 | 19 | if (options.type == "SplineCurve"){ 20 | return SplineCurveBuilder.BuildMesh(options) 21 | } 22 | 23 | if (options.type == "Group") { 24 | return GroupBuilder.BuildGroup(options); 25 | } 26 | 27 | if (options.type == "AmbientLight") { 28 | return LightBuilder.BuildAmbientLight(options); 29 | } 30 | 31 | if (options.type == "PointLight") { 32 | return LightBuilder.BuildPointLight(options); 33 | } 34 | 35 | if (options.type.includes("Helper")) { 36 | return HelperBuilder.BuildHelper(options, scene); 37 | } 38 | 39 | if (options.type.includes("Sprite")) { 40 | return SpriteBuilder.BuildSprite(options); 41 | } 42 | } 43 | } 44 | 45 | export default SceneBuilder; 46 | -------------------------------------------------------------------------------- /src/javascript/Builders/SpriteBuilder.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import Transforms from "../Utils/Transforms"; 3 | import MaterialBuilder from "./MaterialBuilder"; 4 | 5 | class SpriteBuilder { 6 | 7 | static BuildSprite(options) { 8 | const material = MaterialBuilder.buildMaterial(options.material); 9 | const sprite = new THREE.Sprite(material); 10 | sprite.center = options.center; 11 | Transforms.setPosition(sprite, options.position); 12 | Transforms.setRotation(sprite, options.rotation); 13 | Transforms.setScale(sprite, options.scale); 14 | sprite.uuid = options.uuid; 15 | sprite.name = options.name; 16 | return sprite; 17 | } 18 | } 19 | 20 | export default SpriteBuilder; 21 | -------------------------------------------------------------------------------- /src/javascript/Builders/TextBuilder.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import Transforms from "../Utils/Transforms"; 3 | import MaterialBuilder from "./MaterialBuilder"; 4 | import TextGeometryBuilder from "./TextGeometryBuilder" 5 | import { FontLoader } from 'three/examples/jsm/loaders/FontLoader.js'; 6 | 7 | class TextBuilder { 8 | 9 | static BuildText(options, parent) { 10 | 11 | const loader = new FontLoader(); 12 | 13 | loader.load( 14 | // font URL 15 | options.geometry.fontURL, 16 | // callback function called on font loading 17 | function (font) { 18 | const geometry = TextGeometryBuilder.buildGeometry(options.geometry, font); 19 | 20 | if (options.geometry.type != "TextStrokeGeometry") { 21 | const material = MaterialBuilder.buildMaterial(options.material); 22 | const mesh = new THREE.Mesh(geometry, material); 23 | mesh.uuid = options.uuid; 24 | Transforms.setPosition(mesh, options.position); 25 | Transforms.setRotation(mesh, options.rotation); 26 | Transforms.setScale(mesh, options.scale); 27 | parent.add(mesh); 28 | } 29 | else { // build stroke text here 30 | const strokeText = new THREE.Group(); 31 | Transforms.setPosition(strokeText, options.position); 32 | Transforms.setRotation(strokeText, options.rotation); 33 | Transforms.setScale(strokeText, options.scale); 34 | strokeText.uuid = options.uuid; 35 | 36 | const matDark = new THREE.MeshBasicMaterial({ 37 | color: options.material.color, 38 | side: THREE.DoubleSide 39 | }); 40 | 41 | geometry.forEach(element => { 42 | const strokeMesh = new THREE.Mesh(element, matDark); 43 | strokeText.add(strokeMesh); 44 | }); 45 | 46 | parent.add(strokeText); 47 | } 48 | }, 49 | 50 | // onProgress callback 51 | function (xhr) { 52 | 53 | }, 54 | 55 | // onError callback 56 | function (err) { 57 | console.error('Font loading failed. ', err); 58 | } 59 | ); 60 | } 61 | } 62 | 63 | export default TextBuilder; -------------------------------------------------------------------------------- /src/javascript/Builders/TextGeometryBuilder.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | import { TextGeometry } from 'three/examples/jsm/geometries/TextGeometry'; 3 | import { SVGLoader } from "three/examples/jsm/loaders/SVGLoader" 4 | 5 | class TextGeometryBuilder { 6 | static buildGeometry(options, font) { 7 | if (options.type == "TextExtrudeGeometry") { 8 | const geometry = new TextGeometry(options.text, 9 | { 10 | font: font, 11 | size: options.size, 12 | height: options.height, 13 | curveSegments: options.curveSegments, 14 | bevelEnabled: options.bevelEnabled, 15 | bevelThickness: options.bevelThickness, 16 | bevelSize: options.bevelSize, 17 | bevelOffset: options.bevelOffset, 18 | bevelSegments: options.bevelSegments, 19 | }); 20 | geometry.uuid = options.uuid; 21 | return geometry; 22 | } 23 | 24 | if (options.type == "TextShapeGeometry") { 25 | const shapes = font.generateShapes(options.text, options.size); 26 | const geometry = new THREE.ShapeGeometry(shapes); 27 | geometry.uuid = options.uuid; 28 | return geometry; 29 | } 30 | 31 | if (options.type == "TextStrokeGeometry") { 32 | const shapes = font.generateShapes(options.text, options.size); 33 | const holeShapes = []; 34 | 35 | for (let i = 0; i < shapes.length; i++) { 36 | if (shapes[i].holes && shapes[i].holes.length > 0) { 37 | for (let j = 0; j < shapes[i].holes.length; j++) { 38 | holeShapes.push(shapes[i].holes[j]); 39 | } 40 | } 41 | } 42 | 43 | shapes.push.apply(shapes, holeShapes); 44 | 45 | const style = SVGLoader.getStrokeStyle(options.strokeWidth); 46 | const geometries = []; 47 | for (let i = 0; i < shapes.length; i++) { 48 | const points = shapes[i].getPoints(); 49 | const geometry = SVGLoader.pointsToStroke(points, style); 50 | geometries.push(geometry); 51 | } 52 | return geometries; 53 | } 54 | 55 | console.log("geometry type not found", options); 56 | } 57 | } 58 | 59 | export default TextGeometryBuilder; 60 | -------------------------------------------------------------------------------- /src/javascript/Builders/TextureBuilder.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | 3 | class TextureBuilder { 4 | static buildTexture(options) { 5 | if (options.type == "Texture") { 6 | let texture = new THREE.Texture(); 7 | if(options.textureUrl){ 8 | texture = new THREE.TextureLoader().load( options.textureUrl ); 9 | texture.uuid = options.uuid; 10 | texture.wrapS = options.wrapS; 11 | texture.wrapT = options.wrapT; 12 | texture.repeat = options.repeat; 13 | texture.offset = options.offset; 14 | texture.center = options.center; 15 | texture.rotation = options.rotation; 16 | return texture; 17 | } 18 | return null; // if no texture needs to be loaded, return null 19 | } 20 | } 21 | } 22 | 23 | export default TextureBuilder; 24 | -------------------------------------------------------------------------------- /src/javascript/Utils/Transforms.js: -------------------------------------------------------------------------------- 1 | import * as THREE from "three"; 2 | 3 | class Transforms { 4 | static setPosition(object3d, position) { 5 | let { x, y, z } = position; 6 | object3d.position.set(x, y, z); 7 | } 8 | 9 | static setRotation(object3d, eulerOptions) { 10 | let { x, y, z, order } = eulerOptions; 11 | object3d.setRotationFromEuler(new THREE.Euler( x, y, z, order )); 12 | } 13 | 14 | static setScale(object3d, scale) { 15 | let { x, y, z } = scale; 16 | object3d.scale.set(x, y, z); 17 | } 18 | } 19 | 20 | export default Transforms; 21 | -------------------------------------------------------------------------------- /src/javascript/Viewer/Exporters.js: -------------------------------------------------------------------------------- 1 | import { GLTFExporter } from "three/examples/jsm/exporters/GLTFExporter"; 2 | import { ColladaExporter } from "three/examples/jsm/exporters/ColladaExporter"; 3 | import { OBJExporter } from "three/examples/jsm/exporters/OBJExporter"; 4 | 5 | function save(blob, filename) { 6 | const link = document.createElement("a"); 7 | link.style.display = "none"; 8 | // document.body.appendChild( link ); // Firefox workaround, see #6594 9 | link.href = URL.createObjectURL(blob); 10 | link.download = filename; 11 | link.click(); 12 | } 13 | 14 | function saveString(text, filename) { 15 | save(new Blob([text], { type: "text/plain" }), filename); 16 | } 17 | 18 | function saveArrayBuffer(buffer, filename) { 19 | save(new Blob([buffer], { type: "application/octet-stream" }), filename); 20 | } 21 | 22 | class Exporters { 23 | static exportOBJ(input) { 24 | const objExporter = new OBJExporter(); 25 | const result = objExporter.parse(input); 26 | saveString(result, "scene.obj"); 27 | } 28 | 29 | static exportGLTF(input) { 30 | const gltfExporter = new GLTFExporter(); 31 | gltfExporter.parse(input, function (result) { 32 | if (result instanceof ArrayBuffer) { 33 | saveArrayBuffer(result, "scene.glb"); 34 | } else { 35 | const output = JSON.stringify(result, null, 2); 36 | saveString(output, "scene.gltf"); 37 | } 38 | }); 39 | } 40 | 41 | static exportCollada(input) { 42 | const exporter = new ColladaExporter(); 43 | const result = exporter.parse(input, undefined, { 44 | upAxis: "Y_UP", 45 | unitName: "millimeter", 46 | unitMeter: 0.001, 47 | }); 48 | saveString(result.data, "scene.dae"); 49 | } 50 | } 51 | 52 | export default Exporters; 53 | -------------------------------------------------------------------------------- /src/javascript/index.js: -------------------------------------------------------------------------------- 1 | import Viewer3D from "./Viewer/Viewer3D"; 2 | 3 | let viewer3d; 4 | 5 | const resizeObserver = new ResizeObserver((entries) => { 6 | viewer3d.onResize(); 7 | }); 8 | 9 | export function loadViewer(json) { 10 | const options = JSON.parse(json); 11 | let container = document.getElementById(options.viewerSettings.containerId); 12 | if (!container) { 13 | console.warn("Container not found!"); 14 | return; 15 | } 16 | resizeObserver.observe(container); 17 | viewer3d = new Viewer3D(options, container); 18 | } 19 | 20 | export function updateScene(json) { 21 | const sceneOptions = JSON.parse(json); 22 | viewer3d.updateScene(sceneOptions); 23 | } 24 | 25 | export function removeByUuid(guid) { 26 | return viewer3d.removeByUuid(guid); 27 | } 28 | 29 | export function selectByUuid(guid) { 30 | return viewer3d.selectByUuid(guid); 31 | } 32 | 33 | export function clearScene() { 34 | viewer3d.clearScene(); 35 | } 36 | 37 | export function import3DModel(json) { 38 | const settings = JSON.parse(json); 39 | return JSON.stringify(viewer3d.import3DModel(settings)); 40 | } 41 | 42 | export function importSprite(json) { 43 | const settings = JSON.parse(json); 44 | return JSON.stringify(viewer3d.importSprite(settings)); 45 | } 46 | 47 | export function setCameraPosition(position, lookAt) { 48 | viewer3d.setCameraPosition(position, lookAt); 49 | } 50 | 51 | export function updateCamera(json) { 52 | const options = JSON.parse(json); 53 | viewer3d.updateCamera(options); 54 | } 55 | 56 | export function showCurrentCameraInfo() { 57 | viewer3d.showCurrentCameraInfo(); 58 | } 59 | 60 | export function updateOrbitControls(json){ 61 | const options = JSON.parse(json); 62 | viewer3d.updateOrbitControls(options); 63 | } 64 | 65 | export function getSceneItemByGuid(guid) { 66 | const item = viewer3d.getSceneItemByGuid(guid); 67 | return JSON.stringify(item); 68 | } 69 | -------------------------------------------------------------------------------- /src/javascript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blazor3dviewer", 3 | "version": "1.0.0", 4 | "description": "", 5 | "private": true, 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "build": "webpack --progress --profile", 9 | "watch": "webpack --progress --profile --watch", 10 | "production": "webpack --progress --profile --mode production" 11 | }, 12 | "keywords": [], 13 | "author": "", 14 | "license": "ISC", 15 | "dependencies": { 16 | "three": "^0.143.0" 17 | }, 18 | "devDependencies": { 19 | "webpack": "^5.82.0", 20 | "webpack-cli": "^5.0.2" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/javascript/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | 4 | const bundleFileName = 'bundle'; 5 | const dirName = '../dotnet/Blazor3D/Blazor3D/wwwroot/js'; 6 | 7 | module.exports = (env, argv) => { 8 | //todo: bundle.min.js for production mode 9 | return { 10 | mode: argv.mode === "production" ? "production" : "development", 11 | entry: ['./index.js'], 12 | output: { 13 | library:{ 14 | type: 'module' 15 | }, 16 | umdNamedDefine: true, 17 | filename: bundleFileName + ".js", 18 | path: path.resolve(__dirname, dirName), 19 | }, 20 | plugins: [ 21 | new webpack.BannerPlugin({ 22 | banner: `Copyright © 2022 Roman Simuta aka siroman \nCopyright © 2010-2021 three.js authors https://threejs.org/` 23 | }) 24 | ], 25 | experiments: { 26 | outputModule: true, 27 | }, 28 | }; 29 | }; --------------------------------------------------------------------------------