Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
3809aef
Preserve gltf structure for root extensions
UX3D-haertl Jul 23, 2025
e301c69
Fix light animation pointer
UX3D-haertl Jul 23, 2025
44aa729
Register json pointer
UX3D-haertl Jul 29, 2025
4cc84ba
First working version of graph without event
UX3D-haertl Jul 30, 2025
a3e98d4
Use performance.now for timer
UX3D-haertl Jul 30, 2025
89f53f7
Expose custom events
UX3D-haertl Jul 31, 2025
ae8a860
Fix dispatch event
UX3D-haertl Aug 1, 2025
0902963
Fix event name
UX3D-haertl Aug 1, 2025
c57467e
Fix Event call
UX3D-haertl Aug 4, 2025
4867a70
Add play/pause/reset
UX3D-haertl Aug 5, 2025
ca2a904
Implement animation nodes
UX3D-haertl Aug 6, 2025
39b359c
Fix issues with animation
UX3D-haertl Aug 7, 2025
85acb01
Remove unneeded code
UX3D-haertl Aug 11, 2025
2702673
Support negativ time/reverse animation
UX3D-haertl Aug 11, 2025
db2f205
Add read-only pointers
UX3D-haertl Aug 11, 2025
cc89a69
Merge branch 'main' into feature/KHR_interactivity
UX3D-haertl Aug 12, 2025
d22309b
Register pointer for activeCamera
UX3D-haertl Aug 12, 2025
df1343d
Fix stopGraph function
UX3D-haertl Aug 21, 2025
2d869ee
Fix negative start/endTime
UX3D-haertl Aug 27, 2025
31ea96d
Fix undefined access
UX3D-haertl Aug 27, 2025
640ccb5
Add type checking for accessor access
UX3D-haertl Aug 27, 2025
de1f3fb
Add support for 64bit floats
UX3D-haertl Aug 29, 2025
bf2e06e
Update Readme
UX3D-haertl Aug 29, 2025
81769f8
Added picking pass
UX3D-haertl Aug 29, 2025
da894f0
Remove warnings
UX3D-haertl Sep 1, 2025
8856eb8
Rework reset
UX3D-haertl Sep 1, 2025
25c72a3
Finish read only pointers
UX3D-haertl Sep 2, 2025
9cd9730
Add KHR_node_visibility support
UX3D-haertl Sep 2, 2025
e62a6e2
Fix interpolant for booleans
UX3D-haertl Sep 2, 2025
064c62f
Add picking position
UX3D-haertl Sep 3, 2025
75f18bb
Add selection to interactivity and WIP hover support
UX3D-haertl Sep 9, 2025
5dae8ca
Add selectability to node/renderer
UX3D-haertl Sep 9, 2025
ae29676
Use 1x1 picking framebuffer
UX3D-haertl Sep 10, 2025
ed5a3d8
Compute ray origin for orthographic camera
UX3D-haertl Sep 10, 2025
13e20fc
Add hover pass
UX3D-haertl Sep 10, 2025
47ef042
Fix hover callbacks
UX3D-haertl Sep 11, 2025
e5cca9e
moved logic into engine
UX3D-haertl Sep 11, 2025
fa001c9
Calculate rayPosition from depth values to remove float texture requi…
UX3D-haertl Sep 15, 2025
73b0862
Increase depth precision
UX3D-haertl Sep 16, 2025
e7323b7
Convert arrays to matricies
UX3D-haertl Sep 16, 2025
1e8223e
Merge branch 'refactor/hoverSelection' into feature/KHR_interactivity
UX3D-haertl Sep 16, 2025
c8697ac
Use uint for picking color
UX3D-haertl Sep 16, 2025
9ced020
Fix type detection
UX3D-haertl Sep 16, 2025
8203374
Create copy of event data
UX3D-haertl Sep 16, 2025
74d2b50
Clone values in pointer get/set
UX3D-haertl Sep 16, 2025
191e46f
Make graphController call generic
UX3D-haertl Sep 17, 2025
68328d5
Merge remote-tracking branch 'origin/main' into feature/KHR_interacti…
UX3D-haertl Oct 13, 2025
8b59e86
Fix merge issue
UX3D-haertl Oct 16, 2025
b2e6daf
Add custom event listeners
UX3D-haertl Oct 16, 2025
061f0c3
WIP add interactivity tests
UX3D-haertl Oct 16, 2025
4a9668f
Use shorter test names
UX3D-haertl Oct 17, 2025
e44f292
Always recalculate globalMatrix
UX3D-haertl Oct 17, 2025
97a28f3
Fix test ignore
UX3D-haertl Oct 21, 2025
e2dfebe
Merge branch 'main' into feature/KHR_interactivity
UX3D-haertl Oct 21, 2025
17ad0c9
Fix formatting
UX3D-haertl Oct 21, 2025
b6728aa
Fix issues with pointer/get for int, bool and float
UX3D-haertl Oct 22, 2025
9bf97e7
Fix issue with root level extensions
UX3D-haertl Oct 23, 2025
173f55b
Improve test
UX3D-haertl Oct 23, 2025
520febd
Calculate near plane hit for perspective camera
UX3D-haertl Oct 24, 2025
f5cc043
Merge branch 'main' into feature/KHR_interactivity
UX3D-haertl Oct 24, 2025
4b64590
Remove unused frag defines
UX3D-haertl Oct 24, 2025
ecb8ee6
Add formatting to tests
UX3D-haertl Oct 24, 2025
62bb1a5
Update readme
UX3D-haertl Oct 24, 2025
1062724
Improved variable naming
UX3D-haertl Oct 24, 2025
744cbb8
Handle interactivity hover internal
UX3D-haertl Oct 24, 2025
b469197
Add and improve documentation
UX3D-haertl Oct 27, 2025
834e760
Add testing section to ReadMe
UX3D-haertl Oct 27, 2025
c933925
Add documentation for AnimationTimer
UX3D-haertl Oct 28, 2025
c77a568
Apply KHR_node_visibility to lights
UX3D-haertl Oct 28, 2025
3f05d6b
Add prettier ignore for readme
UX3D-haertl Oct 28, 2025
e057f8c
Update engine npm name
UX3D-haertl Oct 28, 2025
cc81fec
Fix projection matrix calculation check
UX3D-haertl Oct 28, 2025
7ceceba
Fix import
UX3D-haertl Oct 29, 2025
cd9936d
Add min max check for animations
UX3D-haertl Oct 29, 2025
990dd2b
Recreate engine on gltf loading to prevent race condition
UX3D-haertl Oct 29, 2025
f2d615e
Reapply event listeners
UX3D-haertl Oct 29, 2025
158b434
Revert "Reapply event listeners"
UX3D-haertl Oct 30, 2025
b3299ad
Automatically resubscribe
UX3D-haertl Oct 30, 2025
7e5457e
Stop playing on init
UX3D-haertl Oct 30, 2025
8bf6ee7
Add more code comments
UX3D-haertl Oct 30, 2025
bc532c5
Move test in function
UX3D-haertl Oct 30, 2025
21d1610
Engine switched to 1D arrays for matricies
UX3D-haertl Nov 3, 2025
f8ec032
Remove case fixes
UX3D-haertl Nov 14, 2025
cd3c3b2
Manually execute engine
UX3D-haertl Nov 25, 2025
94ac412
Fix computeMinMaxTime
UX3D-haertl Dec 8, 2025
7edd156
Fix animation end at maxTime
UX3D-haertl Dec 8, 2025
f1fd436
Fix active camera pointers
UX3D-haertl Dec 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ desktop.ini
.zed
.idea
.project

# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth/
/tests/testAssetDownloads
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ documentation/
.gitattributes
.gitmodules
.eslintrc.json
dist/main.js
dist/index.html

# files types to ignore
rollup.config.js
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
source/libs
source/libs
**/*.md
369 changes: 369 additions & 0 deletions API.md

Large diffs are not rendered by default.

87 changes: 77 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,38 @@ Try out the [glTF Sample Viewer](https://github.khronos.org/glTF-Sample-Viewer-R
## Table of Contents

- [Khronos glTF Sample Renderer](#khronos-gltf-sample-renderer)
- [Table of Contents](#table-of-contents)
- [Credits](#credits)
- [Features](#features)
- [API](#api)
- [GltfView](#gltfview)
- [GltfState](#gltfstate)
- [ResourceLoader](#resourceloader)
- [Render Fidelity Tools](#render-fidelity-tools)
- [Table of Contents](#table-of-contents)
- [Credits](#credits)
- [Features](#features)
- [API](#api)
- [GltfView](#gltfview)
- [GltfState](#gltfstate)
- [GraphController](#graphcontroller)
- [AnimationTimer](#animationtimer)
- [ResourceLoader](#resourceloader)
- [Render Fidelity Tools](#render-fidelity-tools)
- [Development](#development)
- [Formatting](#formatting)
- [Visual Studio Code](#visual-studio-code)
- [Visual Studio Code](#visual-studio-code)
- [Testing](#testing)

## Credits

Developed and refactored by [UX3D](https://www.ux3d.io/). Supported by the [Khronos Group](https://www.khronos.org/) and by [Google](https://www.google.com/) for the glTF Draco mesh compression import.
Formerly hosted together with the example frontend at the [glTF Sample Viewer](https://github.com/KhronosGroup/glTF-Sample-Viewer) repository. Original code based on the concluded [glTF-WebGL-PBR](https://github.com/KhronosGroup/glTF-Sample-Viewer/tree/glTF-WebGL-PBR) project. Previously supported by [Facebook](https://www.facebook.com/) for animations, skinning and morphing.
For KHR_interactivity, the behavior engine of the [glTF-InteractivityGraph-AuthoringTool](https://github.com/KhronosGroup/glTF-InteractivityGraph-AuthoringTool) is used.

## Features

- [x] glTF 2.0
- [KHR_accessor_float64](https://github.com/KhronosGroup/glTF/pull/2397)
- [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] [KHR_animation_pointer](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_animation_pointer)
- [x] [KHR_draco_mesh_compression](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_draco_mesh_compression)
- [x] [KHR_interactivity](https://github.com/KhronosGroup/glTF/pull/2293)
- [x] [KHR_lights_punctual](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_lights_punctual)
- [x] [KHR_materials_anisotropy](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_anisotropy)
- [x] [KHR_materials_clearcoat](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_clearcoat)
Expand All @@ -49,6 +60,9 @@ Formerly hosted together with the example frontend at the [glTF Sample Viewer](h
- [x] For dense volumes using KHR_materials_diffuse_transmission
- [ ] For sparse volumes using KHR_materials_transmission
- [x] [KHR_mesh_quantization](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_mesh_quantization)
- [x] [KHR_node_hoverability](https://github.com/KhronosGroup/glTF/pull/2426)
- [x] [KHR_node_selectability](https://github.com/KhronosGroup/glTF/pull/2422)
- [x] [KHR_node_visibility](https://github.com/KhronosGroup/glTF/pull/2410)
- [x] [KHR_texture_basisu](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_basisu)
- [x] [KHR_texture_transform](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform)
- [x] [KHR_xmp_json_ld](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_xmp_json_ld)
Expand Down Expand Up @@ -94,6 +108,21 @@ state.animationTimer.start();

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

#### GraphController

The GltfState contains an instance of the GraphController which can be used to load and execute `KHR_interactivity` graphs. One can also send custom events to the graph or subscribe to custom event via callbacks.

In the GltfState you can define an array of selection and hover points. Each element of the array represents one controller. If `triggerSelection` is set to `true`, the renderer will return the picking result of the clicked position via `selectionCallback`. The interactivity engine will be notified as well, if `KHR_node_selectability` is used in the current glTF.

If `enableHover` is set to `true`, the renderer will return the picking result of the hovered position via `hoverCallback`. The interactivity engine receives hover results independent of `enableHover` based on the `hoverPositions` array. `enableHover` enables the use of custom hover handling independent of `KHR_interactivity` and is set to `false` by default.

To make sure that `KHR_interactivity` always behaves correctly together with `KHR_node_selectability` and `KHR_node_hoverability`, update the values in the `hoverPositions` and `selectionPositions` arrays and trigger selections via `triggerSelection`. Currently, only one controller is supported. All entries except the first one of each array are ignored. Arrays are used to enable multiple controllers in the future without breaking the API.

#### AnimationTimer

The GltfState contains an instance of the AnimationTimer, which is used to play, pause and reset animations. It needs to be started to enable animations.
The `KHR_interactivity` extension controls animations if present. Therefore, the GraphController uses the time of the AnimationTimer to control animations. The GraphController is paused and resumed independently from the AnimationTimer, thus if an interactivity graph is paused, currently playing animations will continue playing if the AnimationTimer is not paused as well.

### ResourceLoader

The ResourceLoader can be used to load external resources and make them available to the renderer.
Expand All @@ -106,7 +135,21 @@ state.gltf = await resourceLoader.loadGltf("path/to/some.gltf");

The glTF Sample Renderer is integrated into Google's [render fidelity tools](https://github.com/google/model-viewer/tree/master/packages/render-fidelity-tools). The render fidelity tools allow the comparison of different renderers. To run the project follow the instructions [here](https://github.com/google/model-viewer/blob/master/README.md) and [here](https://github.com/google/model-viewer/blob/master/packages/render-fidelity-tools/README.md). For information on how the glTF Sample Renderer was integrated see the [pull request on Github](https://github.com/google/model-viewer/pull/1962).

## Formatting
## Development

After cloning this repository, run

```
npm install
```

to install all dependencies. To test and view your changes on a canvas, it is recommended to clone [glTF Sample Viewer](https://github.com/KhronosGroup/glTF-Sample-Viewer) which uses this renderer as a submodule.

`npm run build` will build the npm package and put the bundled code into the `dist` directory.

`npm run build_docs` will regenerate the [API documentation](API.md).

### Formatting

This repository uses [Prettier](https://prettier.io/) for code formatting and [ESLint](https://eslint.org/) for linting.

Expand All @@ -126,3 +169,27 @@ There are extensions for both Prettier and ESLint in Visual Studio Code. They ca
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)

You are encouraged to run Prettier and ESLint on your code before committing.

### Testing

glTF-Sample-Render uses [Playwright](https://playwright.dev/) for testing.\
Currently, only `KHR_interactivity` tests are implemented.

To run the tests run

```
npm run test
```

Playwright creates a new browser instance for each test. It can run on Chrome, Safari, Firefox and emulated mobile browsers. After all tests were run, a browser window with a summary will open. The `tests/testApp` directory contains a minimal frontend to be able to start a testing server. The server is started automatically. For debugging the test server you can also start it manually by running

```
npm run testApp
```

Tests are defined in the `tests` directory by files with the `.spec.ts` ending.\
The interactivity tests download all test assets from the [glTF-Test-Assets-Interactivity repository](https://github.com/KhronosGroup/glTF-Test-Assets-Interactivity), loads each test file and listens on the `test/onStart`, `test/onSuccess` and `test/onFailed` events to determine if an interactivity test passes or not. `test/onStart` returns the needed execution time in seconds.

You can also run more complex Playwright commands such as `npx playwright test --ui` or `npx playwright test --project chromium`. For more information check https://playwright.dev/docs/running-tests

One can also use the [Playwright extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-playwright.playwright) to run the test more easily with advanced parameters, run tests only selectively or debug tests by adding breakpoints.
7 changes: 6 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export default [
semi: "warn",
"no-extra-semi": "warn",
"no-undef": "warn",
"no-unused-vars": "warn",
"no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_"
}
],
"no-empty": "warn",
"no-redeclare": "warn",
"no-prototype-builtins": "warn",
Expand Down
Loading