glTF Sample Viewer Web App
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] glTF 2.0
- KHR_accessor_float64
- [x] KHR_animation_pointer
- [x] KHR_draco_mesh_compression
- [x] KHR_implicit_shapes
- [x] KHR_interactivity
- [x] KHR_gaussian_splatting
- [x] KHR_lights_punctual
- [x] KHR_materials_anisotropy
- [x] KHR_materials_clearcoat
- [x] KHR_materials_diffuse_transmission
- [x] KHR_materials_dispersion
- [x] KHR_materials_emissive_strength
- [x] KHR_materials_ior
- [x] KHR_materials_iridescence
- [x] KHR_materials_pbrSpecularGlossiness
- [x] KHR_materials_retroreflection
- [x] KHR_materials_sheen
- [x] KHR_materials_specular
- [x] KHR_materials_transmission
- [x] KHR_materials_unlit
- [x] KHR_materials_variants
- [x] KHR_materials_volume
- KHR_materials_volume_scatter
- [x] KHR_meshopt_compression
- [x] KHR_mesh_quantization
- [x] KHR_node_hoverability
- [x] KHR_node_selectability
- [x] KHR_node_visibility
- [x] KHR_physics_rigid_bodies\
- [x] KHR_texture_basisu
- [x] KHR_texture_transform
- [x] KHR_xmp_json_ld
- [x] EXT_mesh_gpu_instancing
- [x] EXT_meshopt_compression
- [x] EXT_texture_webp
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_bodiesextension. 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 URLnoUI: Disable UIyaw=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 90distance=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:
- Checkout the
mainbranch
- Pull the submodule for the required glTF-Sample-Renderer
git submodule update --init --recursive
- Build the web app
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
- 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->ChromeorDebug->Add Configuration->Firefoxso the.vscode/launch.jsonfile is created. - For chrome: Append
/distto${workspaceFolder}in thelaunch.jsonfile Debug->Start Debuggingshould 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.