Profile
Back to NewsBack
GitHub Trending 4 min
Reader Mode
KhronosGroup/glTF-Sample-Viewer: Physically-Based Rendering in glTF 2.0 using WebGL

KhronosGroup/glTF-Sample-Viewer: Physically-Based Rendering in glTF 2.0 using WebGL

15 hours ago

glTF Sample Viewer Web App

</a>

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

Viewer

Link to the live glTF 2.0 Sample Viewer.

Pushes to main deploy to the live viewer. Pushes to other branches deploy to https://github.khronos.org/glTF-Sample-Viewer-Release/preview//, preserving slashes in branch names (for example, feature/foo deploys to preview/feature/foo/). Main deployments preserve the branch previews. Dependabot updates still run the build and size checks but do not deploy previews. Deleting a branch removes its preview directory without affecting the live viewer or other branch previews. Preview cleanup runs from the workflow on the default branch.

Features

glTF

- [x] Animations - [x] KHR_animation_pointer - [ ] Mesh Attributes not supported since WebGL2 only supports 32 bit - [ ] Skins not supported since WebGL2 only supports 32 bit - [x] For dense volumes using KHR_materials_diffuse_transmission - [ ] For sparse volumes using KHR_materials_transmission Supported Engines: - NVIDIA PhysX (limitations)

UI

  • Select all glTF-Sample-Assets directly via UI
  • Load your own glTF/glb and HDR files via drag and drop
  • Customize lighting and tone mapping
  • Check validation errors with the integrated glTF-Validator
  • Select different material variants
  • Enable/disable specific animations
  • Enable/disable glTF features/extensions and view debug channels
  • Download renderings and current camera properties
  • Show statistics about the currently loaded file
  • Specify URL parameters to modify behavior on load
  • The Physics tab will only be visible if a loaded glTF contains the KHR_physics_rigid_bodies extension. It provides functionality to enable/disable/reset the physics simulation, select a physics engine, manually step through the simulation and enable/disable debug visualization.

Usage

Controls

click + drag : Rotate model

shift + drag \ middle mouse button + drag : Pan camera

scroll \ right click + drag : Zoom camera

GUI : Use to change models and settings

Change glTF model

  • Choose one of the glTF models in the selection list
  • Drag and drop glTF files into viewer

Change the environment map

  • Drag and drop a .hdr panorama file

URL parameters

URL parameters are added at the end of the sample viewer URL: \ ?key=value&another_key=another_value

Possible parameters:

  • model=URL_to_file: Load glTF/glb from specified URL
  • noUI: Disable UI
  • yaw=90: Orbit the camera around the model along the Y-axis in degrees. With 90 degrees you look at the model from the left side.
  • pitch=90: Orbit the camera around the model along the X-axis in degrees. With 90 degrees you look at the model from the top. Value range: -90 to 90
  • distance=5: The models gets smaller with positive and bigger with negative numbers. Relative to the initial camera position.

Setup

For local usage and debugging, please follow these instructions:

  1. Checkout the main branch
  1. Pull the submodule for the required glTF-Sample-Renderer git submodule update --init --recursive
  1. Build the web app
- run npm install - start a demo in the browser with npm run dev, and open http://localhost:5173.

When making changes, the project is automatically rebuilt and the ./dist directory is populated with the web app. This directory contains all files necessary for deployment to a web server.

Debugging

  • Requirements
- Visual Studio Code or vscodium - Chrome or Firefox
  • Install the Debugger for Chrome or Debugger for Firefox extension for Visual Studio Code
  • Open the project directory in Visual Studio Code and select Debug->Add Configuration->Chrome or Debug->Add Configuration->Firefox so the .vscode/launch.json file is created.
  • For chrome: Append /dist to ${workspaceFolder} in the launch.json file
  • Debug->Start Debugging should now launch a Chrome or Firefox window with the sample viewer and VS Code breakpoints should be hit.

Formatting

Running npm run format normalizes formatting and prints linting issues, fixing if possible.

Chat with me