Giter Club home page Giter Club logo

gltf-sample-viewer's Introduction

Khronos glTF 2.0 Sample Viewer

This is the official Khronos glTF 2.0 Sample Viewer using WebGL: glTF 2.0 Sample Viewer

Table of Contents

Version

Development for PBR next phase one

Credits

Refactored and developed by UX3D. Supported by the Khronos Group and by Google for the glTF Draco mesh compression import. Original code based on the former glTF-WebGL-PBR project. Previously supported by Facebook for animations, skinning and morphing.

Features

Setup

For local usage and debugging, please follow these instructions:

  1. Make sure Git LFS is installed.

  2. Checkout the master branch

  3. Pull the submodules for the required glTF sample models and environments git submodule update --init --recursive

  4. To build the npm package for publishing:

    • run npm install
    • run npm run build

This will create a new gltf-viewer.js and gltf-viewer.module.js in the dist directory.

API

glTF Sample Viewer can be used without the web app, for example for integration into a thirdparty web application or for automated testing (see Render Fidelity Tools).

The API consists of several components that in combination allow flexible configuration of the gltf viewer.

More detailed information about the API is listed in the api documentation.

GltfView

The GltfView component is associated with one WebGL2 context. In practice this means it will be associated with one HTML5 Canvas. This component manages the interaction between the canvas and the GL context. For example it therefore specifies the viewport, the swapchain and can be used to schedule frame renders.

const view = new GltfView(webGl2Context);

The view is also used to render frames, either on every window repaint event or on demand, e.g. when taking a frame capture.

const update = () =>
{
    view.renderFrame(state, canvas.width, canvas.height);
    window.requestAnimationFrame(update);
};
window.requestAnimationFrame(update);

GltfState

The GltfState encapsulates the state of the content of a GltfView. As currently some WebGL resources are stored directly in the Gltf objects, the state cannot be shared between views.

const state = view.createState();
state.sceneIndex = 0;
state.animationIndices = [0, 1, 2];
state.animationTimer.start();

The state is passed to the view.renderFrame function to specify the content that should be renderered.

ResourceLoader

ResourceLoader can be used to load external resources and make them available to the renderer.

state.gltf = await resourceLoader.loadGltf("path/to/some.gltf");

Web App

You can find an example application for the gltf viewer in the app_web subdirectory of the sample viewer repository. A live demo can be found at https://github.khronos.org/glTF-Sample-Viewer-Release/.

Running a local version

Open a terminal window in the repository root an run the following commands

cd app_web
npm install 
npm run dev

now you can access glTF Sample Viewer with Chrome or Firefox at the URL http://localhost:8000

Render Fidelity Tools

The gltf sample viewer is integrated into Google's render fidelity tools. This makes it possible to compare different renderers. To run the render fidelity tools follow the instructions here and here. For information on how the gltf sample viewer was integrated see the pull request on github.

Physically-Based Materials in glTF 2.0

With the change from glTF 1.0 to glTF 2.0, one of the largest changes included core support for materials that could be used for physically-based shading. Part of this process involved choosing technically accurate, yet user-friendly, parameters for which developers and artists could use intuitively. This resulted in the introduction of the Metallic-Roughness Material to glTF. If you would like to read more about glTF, you can find the content at its GitHub page.

A good reference about Physically-Based Materials and its workflow can be found on the THE PBR GUIDE - PART 1 and THE PBR GUIDE - PART 2 from allegorithmic.

For implementation details and further theory, please find more information in the Real Shading in Unreal Engine 4 presentation from the SIGGRAPH 2013 course.

gltf-sample-viewer's People

Contributors

ux3d-becher avatar jim-ec avatar ux3d-hohenester avatar ux3d-nopper avatar ux3d-haertl avatar ux3d-wahlster avatar ux3d-labode avatar ux3d-kanzler avatar emackey avatar ux3d-goll avatar snagy avatar moneimne avatar pascalschoen avatar ux3d-bernhardt avatar abwood avatar sbtron avatar timvanscherpenzeel avatar but0n avatar mahiuchun avatar peted70 avatar pasu avatar dependabot[bot] avatar fanna avatar lunarsong avatar corporateshark avatar zellski avatar ziriax avatar pjcozzi avatar paramveerpatil avatar msfeldstein 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.