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.
Features
glTF
- glTF 2.0
- KHR_accessor_float64
- Animations
- KHR_animation_pointer
- Mesh Attributes not supported since WebGL2 only supports 32 bit
- Skins not supported since WebGL2 only supports 32 bit
- KHR_animation_pointer
- KHR_draco_mesh_compression
- KHR_implicit_shapes
- KHR_interactivity
- KHR_gaussian_splatting
- KHR_lights_punctual
- KHR_materials_anisotropy
- KHR_materials_clearcoat
- KHR_materials_diffuse_transmission
- KHR_materials_dispersion
- KHR_materials_emissive_strength
- KHR_materials_ior
- KHR_materials_iridescence
- KHR_materials_pbrSpecularGlossiness
- KHR_materials_retroreflection
- KHR_materials_sheen
- KHR_materials_specular
- KHR_materials_transmission
- KHR_materials_unlit
- KHR_materials_variants
- KHR_materials_volume
- KHR_materials_volume_scatter
- For dense volumes using KHR_materials_diffuse_transmission
- For sparse volumes using KHR_materials_transmission
- KHR_meshopt_compression
- KHR_mesh_quantization
- KHR_node_hoverability
- KHR_node_selectability
- KHR_node_visibility
- KHR_physics_rigid_bodies
Supported Engines:- NVIDIA PhysX (limitations)
- KHR_texture_basisu
- KHR_texture_transform
- KHR_xmp_json_ld
- EXT_mesh_gpu_instancing
- EXT_meshopt_compression
- 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
- run
npm install - start a demo in the browser with
npm run dev, and open http://localhost:5173.
- run
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.
