Coder Social home page Coder Social logo

3d-web-viewers's Introduction

GLTF viewers

I decided to investigate the best way to display gLTF 3D models on a web page. My conclusion is that easiest thing is to use Sketchfab. Various opensource projects are happy to use it on their sites (e.g. see here on the Meshroom site). However, Sketchfab is not opensource and some of the features (such as specifying your own HDRI) are only available to paying customers.

If you want to host your assets yourself (and have full control) then the best opensource alternatives to Sketchfab seem to be three.js and babylon.js.

Both have online sandboxes where you can drag and drop .gltf, .glb and .obj files and experiment with what it's possible to do with these libraries:

Babylon.js provides a ready to go viewer that does things like centering and sizing your model to best fit within the viewer area and provides a default skybox, ground, shadows etc. which can be configured as covered in their documentation.

Three.js just provide a very basic viewer example which you can use as the basis for your own viewer and extend using the documentation for the GLTFLoader etc. An alternative starting off point might be the source code for the three.js sandbox which can be found here.

Initially, the babylon.js viewer was quicker to get started with but in the end it proved just as complicated as with three.js. Once you start wanting to do things like e.g. set an HDRI environment texture, you have to start resorting to Javascript.

You can see the results of my efforts with both libraries here - a simple scene consisting of three spheres, lit by an HDRI. For the babylon.js viewer, I gave up also trying to use the HDRI as the background but I'm sure it's possible.

screenshot

You can find the HTML in index.html and from there get to all the relevant Javascript etc.

Credits

The HDRI, used here, is by Greg Zaal and can be found here on Poly Haven. It's the same HDRI as forest.exr that's found in Blender (see here).

The CSS for the three.js viewer was taken from the code that accompanied this article by Manuel Timelthaler on creating a 3D viewer using three.js.

3d-web-viewers's People

Contributors

george-hawkins avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

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.