Coder Social home page Coder Social logo

three's Introduction

THREE

C# port of Three.js three.js is a very powerful, simple and useful OpenGL Graphics library. I always want to express my deep appreciation to the team that created this library.(https://github.com/mrdoob/three.js). There was a time when I wanted to show how to use these 3D geometry and mathematical theories with OpenGL libraries. In that case, the examples of three.js was a very good.

However, someone who are familiar with structural languages such as C++, Java, C#, etc find it difficult to understand how three.js works. So I decided to port three.js to C++, C#. However, it seemed that it would take too much time to port the massive examples of three.js Fortunately, I found very simple and key examples in Learning Three.js written by Jos Dirksen(https://github.com/josdirksen/learning-threejs) Most of three.js core have been completed, but some code have not yet been done because I am lazy. I don't know if I can afford it, the rest will be completed as soon as time permits.

There is C++ port of Three.js (https://github.com/hjoykim/ThreeCpp)

Example code

    public override void Load(GLControl glControl)
    {
        base.Load(glControl);

        InitRenderer();

        InitCamera();

        InitCameraController();

        scene.Background = Color.Hex(0xffffff);

        var axes = new AxesHelper(20);

        scene.Add(axes);

        var planeGeometry = new PlaneGeometry(60, 20);
        var planeMaterial = new MeshBasicMaterial() { Color = Color.Hex(0xcccccc) };
        var plane = new Mesh(planeGeometry, planeMaterial);

        plane.Rotation.X = (float)(-0.5 * Math.PI);
        plane.Position.Set(15, 0, 0);

        scene.Add(plane);

        // create a cube
        var cubeGeometry = new BoxGeometry(4, 4, 4);
        var cubeMaterial = new MeshBasicMaterial(){ Color=Color.Hex(0xff0000), Wireframe= true};
        var cube = new Mesh(cubeGeometry, cubeMaterial);

        // position the cube
        cube.Position.Set(-4, 3, 0);

        // add the cube to the scene
    
	    scene.Add(cube);

  //      // create a sphere
        var sphereGeometry = new SphereGeometry(4, 20, 20);
        var sphereMaterial = new MeshBasicMaterial() { Color = Color.Hex(0x7777ff), Wireframe = true };
        var sphere = new Mesh(sphereGeometry, sphereMaterial);

  //      // position the sphere
        sphere.Position.Set(20, 4, 2);

  //      // add the sphere to the scene
        scene.Add(sphere);

    }
    public override void Render()
    {
        controls.Update();
        this.renderer.Render(scene, camera);
    }

Example Screen Capture

All examples have a trackball controller.

Rotation : Move mouse while mouse left button pressed

Move : Move mouse while mouse middle button pressed

Zoom : Mouse scroll

Chapter01 - First Scene

image

Chapter02 - Geometries

image

Chapter03 - Lensflares Light

image

Chapter04 -MeshPhysicalMaterial

some examples are include DataLoader like as .obj image

Chapter05-Basic-3D-Geometries-Polyhedron

image

Chapter06 Text Geometry, Binary Operation

image image

Cahpter07 -All the examples have been completed, but they have not been committed yet

Chapter08 - Load Obj file with MTL

image

Chapter09 - Trackball controls

image

Chapter10 env map

image

Chapter11 SimplePass1

image

three's People

Contributors

hjoykim avatar michaelsakharov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

three's Issues

Something weird is up with Shadow Maps.

If you put a Directional Light with Shadows on the world, then a Point Light.

Only places the Directional Light doesn't cast a shadow on will Point Lights apply any light.
It's as if Every Shadowmap is affecting every light. If you then turn on the Point lights shadow it does the same.
The directional light will only light up places the Point light doesn't cast a shadow onto

Here's a pic of the Directional shadows but no Point light shadows.
You can see the only places lit are the places the Sun lights up, everywhere else remains dark.
(Red circle is where the Point Light is, the Point Light is Red)
image

Now here's a pic of the Point light also casting shadows, now the Sun only lights up places that don't have shadows from the Point Light.
image

Fog Color wrong system type.

Fog Color should be THREE.Math.Color not System.Drawing.Color

Error Message gone when I changed it.

Edit : my fault :)

Animation Lib Compatible ?

Amazing projects that made threejs's user like me easy to use in csharp.

Anyway , which threejs version that you use ?

And there is any library like TweenJS or Gsap in javascript to make animation in csharp project ?

Thankyou , keep going

MTLloader substring wrong position

if(key=="ka" || key=="kd" || key=="ks" || key=="ke")
{
==> fix with this == > value = (pos >= 0) ? line.Substring(pos-1) : "";
value = value.Substring(pos).Trim();
var ss = Regex.Split(value, delimiter_pattern);
info.Add(key, new float[] { float.Parse(ss[0]), float.Parse(ss[1]), float.Parse(ss[2]) });
}

boneMatrices cannot be converted into a Bitmap

Trying to get Skeletons and SkinnedMesh's working, but ran into an issue.
In the GLRenderer line 1576, it's trying to convert a Float array into a bitmap, this goes back to the issue before with LTC textures, I'm unsure if we can even store floats in a bitmap.

image

Strage beaviour when zoomin

HI. I tried to import a geometry from this X3d file. If the camera stays close to the object, everything looks correct. If I move away I seem to see the meshes of the objects behind.
What could be the problem?

Very near zoom

immagine

Other zoom level

immagine

This is the X3d file....

1M001934.zip

Maui 지원 되나요?

윈폼에서 도움 받아서 잘 개발하고 있습니다.
Maui에서도 사용 가능 한가요?

ShaderChunks in Files prevents overwriting shaders

Having Shader Chunks in files actually prevents one of the things Three.js supports, Which is Overwriting Shaders from code.
The Cascaded Shadow Mapping example from here: https://github.com/mrdoob/three.js/tree/dev/examples/js/csm
is Overwriting the lights_fragment_begin and lights_pars_begin shaders with a new one that supports CSM. This is possible because the shaders are stored in variables, it seems this used to be the case here but was replaced with files. Sure you could replace the Files, But that means Losing the original, so Disabling your changes means Reverting the file, it is no longer possible to Toggle CSM On and Off without Losing Performance with it off. Being able to Overwrite but also keep the previous shader is all possible In code in a much simpler/easier way.
It's also in general much harder to replace files From code, and The code doesn't support reloading said files so replacing them from code isn't really possible.

Serialization

Would be nice that Serialized scenes from ThreeJs could be loaded in a json format here.
Did you start with this? I could help.

RectAreaLights

Do the Rect Area Lights work in your port yet?
Also, this is a great project! It took me a while to find it but this is by far the best Threejs port to .net.

DLL library

May you build it as DLL library with DLL library for render control to use ut on winforms?

Also I hope build it for .net 4.0 or 4.5

Thank you.

Nuget package

Hello, it seems that not too long ago, the nuget package for this project dissappeared from nuget.org. Are there any plans to bring it back?

Assimp Loader?

Porting over all the different Model Loader THREE.js would be a lot of work, so was thinking maybe we could make a Loader for Assimp, it's a powerful library capable of loading essentially any model format you can think of. It stores them all into the same format, so if we load its format we automatically support a ton of model formats.

That way we still get to load all the model formats without the need of porting every individual loader.

3d object loaders are not working

3d object loaders (MTLLoader, OBJLoader, STLLoader, X3DLoader) throw an exception "The input string was not in a correct format".

Solution: Instead of using
float.Parse(value)
please use
float.Parse(value, CultureInfo.InvariantCulture.NumberFormat)
in the mentioned object loader classes.

OpenGL backend

I've just been pointing to your (very interesting) project...

I've noticed you're using OpenTK. I would suggest you to look at Silk.Net and its OpenGL implementation.

Also consider the new WebGPU Native api as a broad, cross platform API, also provided by Silk.Net... I guess these would give a lot more momentum to the project

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.