Code Monkey home page Code Monkey logo

blazor3d's Introduction

Blazor3D

Blazor3D

Making opensource

Because of the war in Ukraine and often power outages in my city, I don't have much time to develop Blazor3D.

So, I decided to open its source code to the community. I hope it will be valuable for you.

You can find the source code in my other Blazor3D-Core repository.

It still requires documentation to do, but for those who never read the docs it's OK :)

Glory to Ukraine! Glory to the Heroes!

Overview

This repository contains examples of using the Blazor3D Viewercomponent in the ASP.NET Core Blazor applications.

If you want to find more tutorials, API Reference Guide etc., please, visit project webpage at https://blazor3d.com (for now it's on pause)

Live preview of these examples WebAsm versionj you can see at https://simutaroman.github.io/Blazor3D/

Installing

With .NET CLI

dotnet add package Blazor3D

With Package Manager

Install-Package Blazor3D

Or just download it from https://www.nuget.org/packages/Blazor3D and add it as project reference.

Using

With default scene

See example here

  1. Add usings to the _Imports.razor or to your page
@using Blazor3D.Viewers
  1. Put Blazor3D Viewer component to your page
<Viewer UseDefaultScene=@true></Viewer>

With custom scene

See example here

  1. Add usings to the _Imports.razor or to your page
@using Blazor3D.Settings
@using Blazor3D.Scenes
@using Blazor3D.Lights
@using Blazor3D.Maths
@using Blazor3D.Materials
@using Blazor3D.Objects
@using Blazor3D.Geometires
@using Blazor3D.Enums
  1. Put the View3D component to you blazor application page and add some code
<div class="row justify-content-center">
    <div class="col-6 v3d">
        <Viewer @ref="View3D1" ViewerSettings=@settings Scene=scene />
    </div>
</div>

@code {
    private Viewer View3D1 = null!;
    private Guid objGuid;
    private ViewerSettings settings = new ViewerSettings()
        {
            ContainerId = "example1",
        };

    private Scene scene = new Scene();
    protected override Task OnInitializedAsync()
    {
        scene.Add(new AmbientLight());
        scene.Add(new PointLight()
            {
                Position = new Vector3
                {
                    X = 1,
                    Y = 3,
                    Z = 0
                }
            });
        scene.Add(new Mesh());
        scene.Add(new Mesh
            {
                Geometry = new BoxGeometry
                {
                    Width = 2,
                    Height = 0.5f
                },
                Position = new Vector3
                {
                    X = -1,
                    Y = 1,
                    Z = -1
                }
                        ,
                Rotation = new Euler
                {
                    X = Math.PI / 4
                }
            });

        scene.Add(new Mesh
            {
                Geometry = new CircleGeometry(),
                Position = new Vector3
                {
                    X = 1,
                    Y = 1,
                    Z = -1
                },
                Scale = new Vector3(0.5f, 1f, 1f)
            });

        return base.OnInitializedAsync();
    }

Examples

Example01

This example shows how to:

  • Control the Blazor3D Viewer component's dimensions with CSS
  • Add custom ViewerSettings
  • Add user-defined scene
  • Add user-defined lights and meshes with different geometries
  • Turn on/off objects selecting mode
  • Subscribe ObjectSelected event

Example02

This example shows how to:

  • Control the Blazor3D Viewer component's dimensions with CSS and HTML element style
  • Add user-defined scene and lights
  • Import obj, Collada, Fbx, Gltf or Stl model on button click asyncronously
  • Control loaded object by its uuid with ObjectLoaded event
  • Import file when all required JS modules already loaded (inital load)

Example03

This example shows how to:

  • Control the Blazor3D Viewer component's dimensions with CSS
  • Use animated orthographic camera
  • Use helpers
  • Camera toggling
  • Stop camera animation on start using orbit control

Example04

This example shows how to:

  • Add new cubes (or it can be any mech) with specified positions
  • Update selected cube (or any mech) position (in fact the complete scene is updated)
  • Delete selected cube (or any mech) from the scene

Example05

This example shows how to:

  • Load a bitmap texture to the mesh using URL
  • Use different wrapping types
  • Use texture repeating, offset and rotation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.