Skip to content

Commit 3a5e147

Browse files
authored
Merge pull request #621 from KhronosGroup/maintenance/formatting
added prettier formatting
2 parents 5b1c210 + b73c210 commit 3a5e147

File tree

13 files changed

+633
-508
lines changed

13 files changed

+633
-508
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
glTF-Sample-Renderer/source/libs

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "none",
4+
"tabWidth": 4,
5+
"bracketSpacing": true,
6+
"printWidth": 100
7+
}

README.md

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
glTF Sample Viewer Web App
2-
==============================
1+
# glTF Sample Viewer Web App
32

43
[![](../assets/images/BoomBox.jpg)](https://github.khronos.org/glTF-Sample-Viewer-Release/)
54

65
This is the official [Khronos glTF 2.0](https://www.khronos.org/gltf/) Sample Viewer using [WebGL 2.0](https://www.khronos.org/webgl/):
76

8-
9-
Viewer
10-
======
7+
# Viewer
118

129
Link to the live [glTF 2.0 Sample Viewer](https://github.khronos.org/glTF-Sample-Viewer-Release/).
1310

14-
Features
15-
--------
11+
## Features
1612

1713
### glTF
14+
1815
- [x] glTF 2.0
1916
- [x] [KHR_animation_pointer](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_animation_pointer)
2017
- [x] [KHR_draco_mesh_compression](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_draco_mesh_compression)
@@ -34,8 +31,8 @@ Features
3431
- [x] [KHR_materials_variants](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_variants)
3532
- [x] [KHR_materials_volume](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_volume)
3633
- [KHR_materials_volume_scatter](https://github.com/KhronosGroup/glTF/blob/e17468db6fd9ae3ce73504a9f317bd853af01a30/extensions/2.0/Khronos/KHR_materials_volume_scatter/README.md)
37-
- [x] For dense volumes using KHR_materials_diffuse_transmission
38-
- [ ] For sparse volumes using KHR_materials_transmission
34+
- [x] For dense volumes using KHR_materials_diffuse_transmission
35+
- [ ] For sparse volumes using KHR_materials_transmission
3936
- [x] [KHR_mesh_quantization](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_mesh_quantization)
4037
- [x] [KHR_texture_basisu](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_basisu)
4138
- [x] [KHR_texture_transform](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform)
@@ -44,6 +41,7 @@ Features
4441
- [x] [EXT_texture_webp](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/EXT_texture_webp)
4542

4643
### UI
44+
4745
- Select all [glTF-Sample-Assets](https://github.com/KhronosGroup/glTF-Sample-Assets) directly via UI
4846
- Load your own glTF/glb and HDR files via drag and drop
4947
- Customize lighting and tone mapping
@@ -55,9 +53,7 @@ Features
5553
- Show statistics about the currently loaded file
5654
- Specify URL parameters to modify behavior on load
5755

58-
59-
Usage
60-
-----
56+
## Usage
6157

6258
### Controls
6359

@@ -73,50 +69,52 @@ Usage
7369

7470
### Change glTF model
7571

76-
* Choose one of the glTF models in the selection list
77-
* Drag and drop glTF files into viewer
72+
- Choose one of the glTF models in the selection list
73+
- Drag and drop glTF files into viewer
7874

7975
### Change the environment map
80-
* Drag and drop a .hdr panorama file
76+
77+
- Drag and drop a .hdr panorama file
8178

8279
### URL parameters
80+
8381
URL parameters are added at the end of the sample viewer URL: \
8482
`?key=value&another_key=another_value`
8583

8684
Possible parameters:
85+
8786
- `model=URL_to_file`: Load glTF/glb from specified URL
88-
- `noUI`: Disable UI
87+
- `noUI`: Disable UI
8988
- `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.
9089
- `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
9190
- `distance=5`: The models gets smaller with positive and bigger with negative numbers. Relative to the initial camera position.
9291

93-
Setup
94-
-----
92+
## Setup
9593

9694
For local usage and debugging, please follow these instructions:
9795

9896
1. Checkout the [`main`](../../tree/main) branch
9997

100-
2. Pull the submodule for the required [glTF-Sample-Renderer](https://github.com/KhronosGroup/glTF-Sample-Renderer) `git submodule update --init --recursive`
98+
2. Pull the submodule for the required [glTF-Sample-Renderer](https://github.com/KhronosGroup/glTF-Sample-Renderer) `git submodule update --init --recursive`
10199

102100
3. Build the web app
103-
- run `npm install`
104-
- start a demo in the browser with `npm run dev`, and open http://localhost:8000.
101+
- run `npm install`
102+
- start a demo in the browser with `npm run dev`, and open http://localhost:8000.
105103

106104
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 webserver.
107105

108-
Debugging
109-
---------
106+
## Debugging
110107

111-
* Requirements
112-
* [Visual Studio Code](https://code.visualstudio.com/) or [vscodium](https://github.com/VSCodium/vscodium)
113-
* [Chrome](https://www.google.com/chrome/) or [Firefox](https://www.mozilla.org/en-US/firefox/new/)
114-
* Install the [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) or [Debugger for Firefox](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-firefox-debug) extension for Visual Studio Code
115-
* 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.
116-
* For chrome: Append `/dist` to `${workspaceFolder}` in the `launch.json` file
117-
* `Debug->Start Debugging` should now launch a Chrome or Firefox window with the sample viewer and VS Code breakpoints should be hit.
108+
- Requirements
109+
- [Visual Studio Code](https://code.visualstudio.com/) or [vscodium](https://github.com/VSCodium/vscodium)
110+
- [Chrome](https://www.google.com/chrome/) or [Firefox](https://www.mozilla.org/en-US/firefox/new/)
111+
- Install the [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) or [Debugger for Firefox](https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-firefox-debug) extension for Visual Studio Code
112+
- 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.
113+
- For chrome: Append `/dist` to `${workspaceFolder}` in the `launch.json` file
114+
- `Debug->Start Debugging` should now launch a Chrome or Firefox window with the sample viewer and VS Code breakpoints should be hit.
118115

119116
### Known Issues
117+
120118
npm install / npm run dev give the following warnings:
121119

122120
The following warning comes from a thirdparty and does not affect sample viewer since the mentioned line 179 is never executed.
@@ -167,4 +165,25 @@ npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supporte
167165
npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
168166
npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
169167
npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
170-
```
168+
```
169+
170+
## Formatting
171+
172+
This repository uses [Prettier](https://prettier.io/) for code formatting and [ESLint](https://eslint.org/) for linting.
173+
174+
To check the formatting and linting of the code run:
175+
176+
```bash
177+
npm run format
178+
```
179+
180+
Prettier and ESLint are configured to only run on files in the "source" folder and ignore files in "source/libs".
181+
182+
#### Visual Studio Code
183+
184+
There are extensions for both Prettier and ESLint in Visual Studio Code. They can be found in the marketplace:
185+
186+
- [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
187+
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
188+
189+
You are encouraged to run Prettier and ESLint on your code before committing.

eslint.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
1+
import eslint from '@eslint/js';
22
import js from "@eslint/js";
33
import globals from 'globals';
44

55
export default [
6+
eslint.configs.recommended,
67
js.configs.recommended,
78
{
89
languageOptions: {
9-
ecmaVersion: 2020,
10+
ecmaVersion: 2022,
1011
sourceType: "module",
1112
globals: {
1213
...globals.browser,
@@ -38,6 +39,6 @@ export default [
3839
}
3940
},
4041
{
41-
ignores: ["/**/dist/*", "/**/libs/*"]
42+
ignores: ["/**/dist/*", "**/libs/*"]
4243
}
4344
];

glTF-Sample-Renderer

Submodule glTF-Sample-Renderer updated 50 files

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import main from './GltfSVApp.js';
1+
import main from "./GltfSVApp.js";
22

33
main();

package-lock.json

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"test": "echo \"Error: no test specified\" && exit 1",
1414
"lint": "eslint src/**/*.js main.js rollup.config.js glTF-Sample-Renderer/source/**/*.js",
1515
"lint:fix": "eslint --fix src/**/*.js main.js rollup.config.js glTF-Sample-Renderer/source/**/*.js",
16+
"prettier": "npx prettier src/**/*.js main.js glTF-Sample-Renderer/source/**/*.js --check",
17+
"prettier:fix": "npm run prettier -- --write",
18+
"format": "npm run prettier:fix && npm run lint:fix",
1619
"postversion": "git push && git push --tags"
1720
},
1821
"watch": {
@@ -66,8 +69,10 @@
6669
"@rollup/plugin-wasm": "^6.2.2",
6770
"concurrently": "^8.2.2",
6871
"eslint": "^9.5.0",
72+
"eslint-config-prettier": "^10.1.8",
6973
"http-server": "^14.1.1",
7074
"npm-watch": "^0.13.0",
75+
"prettier": "^3.6.2",
7176
"rollup": "^4.23.0",
7277
"rollup-plugin-copy": "^3.5.0",
7378
"rollup-plugin-delete": "^2.0.0",

0 commit comments

Comments
 (0)