Skip to content

Commit 6c5a73e

Browse files
kpal81xdCopilot
andauthored
Structure fixes (#341)
* Update README and package name for clarity * Reorder script commands in package.json for better organization * chore: engines field to specify required Node.js version * fix: update lint scripts to include additional files for better linting * docs: improve README formatting and add library integration testing section * fix: correct formatting and improve readability in eslint and rollup config files * refactor: streamline CI workflow by removing unnecessary configurations and improving step organization * refactor: remove redundant test job from CI workflow * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: update job name for clarity in CI workflow --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent ac226e3 commit 6c5a73e

File tree

5 files changed

+84
-67
lines changed

5 files changed

+84
-67
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,48 @@
11
name: CI
22

33
on:
4-
workflow_dispatch:
54
push:
65
branches: [ main ]
7-
paths-ignore: ['README.md', 'LICENSE']
86
pull_request:
97
branches: [ main ]
10-
paths-ignore: ['README.md', 'LICENSE']
11-
12-
concurrency:
13-
group: ci-${{ github.event.pull_request.number || github.ref }}
14-
cancel-in-progress: true
158

169
jobs:
1710
build:
1811
name: Build
1912
runs-on: ubuntu-latest
20-
21-
timeout-minutes: 10
22-
23-
strategy:
24-
matrix:
25-
node-version: [18.x]
26-
2713
steps:
28-
- name: Checkout code
29-
uses: actions/checkout@v5
14+
- name: Check out code
15+
uses: actions/checkout@v5
3016

31-
- name: Use Node.js ${{ matrix.node-version }}
32-
uses: actions/setup-node@v4
33-
with:
34-
node-version: ${{ matrix.node-version }}
35-
cache: 'npm'
17+
- name: Set up Node.js 18.x
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 18.x
21+
cache: 'npm'
22+
registry-url: 'https://registry.npmjs.org/'
3623

37-
- name: Install
38-
run: npm ci
24+
- name: Install Dependencies
25+
run: npm ci
3926

40-
- name: Build
41-
run: npm run build
27+
- name: Build PlayCanvas Model Viewer
28+
run: npm run build
4229

4330
lint:
4431
name: Lint
4532
runs-on: ubuntu-latest
46-
47-
timeout-minutes: 10
48-
49-
strategy:
50-
matrix:
51-
node-version: [18.x]
52-
5333
steps:
54-
- name: Checkout code
55-
uses: actions/checkout@v5
34+
- name: Check out code
35+
uses: actions/checkout@v5
5636

57-
- name: Use Node.js ${{ matrix.node-version }}
58-
uses: actions/setup-node@v4
59-
with:
60-
node-version: ${{ matrix.node-version }}
61-
cache: 'npm'
37+
- name: Set up Node.js 18.x
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 18.x
41+
cache: 'npm'
42+
registry-url: 'https://registry.npmjs.org/'
6243

63-
- name: Install
64-
run: npm ci
44+
- name: Install Dependencies
45+
run: npm ci
6546

66-
- name: Lint
67-
run: npm run lint
47+
- name: Run ESLint
48+
run: npm run lint

README.md

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
# PlayCanvas glTF Viewer
1+
# PlayCanvas Model Viewer
2+
3+
[![Github Release](https://img.shields.io/github/v/release/playcanvas/model-viewer)](https://github.com/playcanvas/model-viewer/releases)
4+
[![License](https://img.shields.io/github/license/playcanvas/model-viewer)](https://github.com/playcanvas/model-viewer/blob/main/LICENSE)
5+
[![Discord](https://img.shields.io/badge/Discord-5865F2?style=flat&logo=discord&logoColor=white&color=black)](https://discord.gg/RSaMRzg)
6+
[![Reddit](https://img.shields.io/badge/Reddit-FF4500?style=flat&logo=reddit&logoColor=white&color=black)](https://www.reddit.com/r/PlayCanvas)
7+
[![X](https://img.shields.io/badge/X-000000?style=flat&logo=x&logoColor=white&color=black)](https://x.com/intent/follow?screen_name=playcanvas)
8+
9+
| [User Manual](https://developer.playcanvas.com) | [API Reference](https://api.playcanvas.com) | [Blog](https://blog.playcanvas.com) | [Forum](https://forum.playcanvas.com) |
210

311
The PlayCanvas glTF scene viewer is blazingly fast and 100% compliant with the glTF 2.0 spec.
412

@@ -38,18 +46,16 @@ Some URL query parameters are available to override certain aspects of the viewe
3846

3947
Ensure you have [Node.js](https://nodejs.org) installed (v18.0+). Then, from a command prompt, run:
4048

41-
npm install
42-
npm run build
49+
```
50+
npm install
51+
npm run build
52+
```
4353

4454
This will invoke Rollup and output the built viewer to the `dist` folder. To invoke Rollup with the `--watch` flag (which rebuilds the viewer on saving any source file), do:
4555

46-
npm run watch
47-
48-
## How to build with local PlayCanvas engine
49-
50-
You can set the npm build scripts to use local versions of the PlayCanvas engine & PlayCanvas extras builds by setting the following environment variables when launching the npm build scripts:
51-
52-
ENGINE_PATH=./path/to/engine npm run build
56+
```
57+
npm run watch
58+
```
5359

5460
## How to run
5561

@@ -68,3 +74,29 @@ Run:
6874
Open a browser and navigate to http://localhost:3000.
6975

7076
N.B. To load local models run `npx server --cors` in the directory containing the model (disables CORS).
77+
78+
## Library integration testing
79+
80+
The Model Viewer is built on the following open source libraries:
81+
82+
| Library | Details |
83+
| ------------------------------------------------------------- | ------------------------------------------- |
84+
| [PlayCanvas Engine](https://github.com/playcanvas/engine) | Powers the Editor's 3D View and Launch Page |
85+
| [Observer](https://github.com/playcanvas/playcanvas-observer) | Data binding and history |
86+
| [PCUI](https://github.com/playcanvas/pcui) | Front-end component library |
87+
88+
To test the integration of these libraries use [npm link](https://docs.npmjs.com/cli/v9/commands/npm-link). Follow these steps:
89+
90+
1. Create a global link from source
91+
92+
```sh
93+
cd <library>
94+
npm link
95+
```
96+
97+
2. Create a link to the global link
98+
99+
```sh
100+
cd model-viewer
101+
npm link <library>
102+
```

eslint.config.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import playcanvasConfig from '@playcanvas/eslint-config';
2-
import tsParser from '@typescript-eslint/parser';
32
import tsPlugin from '@typescript-eslint/eslint-plugin';
3+
import tsParser from '@typescript-eslint/parser';
44
import globals from 'globals';
55

66
export default [
@@ -22,20 +22,23 @@ export default [
2222
}
2323
},
2424
rules: {
25-
...tsPlugin.configs['recommended'].rules,
25+
...tsPlugin.configs.recommended.rules,
2626
'@typescript-eslint/ban-ts-comment': 'off',
2727
'@typescript-eslint/no-explicit-any': 'off',
2828
'@typescript-eslint/no-unused-vars': 'off',
2929
'jsdoc/require-param-type': 'off',
30-
'jsdoc/require-returns-type': 'off',
30+
'jsdoc/require-returns-type': 'off'
3131
}
3232
},
3333
{
3434
files: ['**/*.js', '**/*.mjs'],
3535
languageOptions: {
3636
globals: {
37-
...globals.browser
37+
...globals.node
3838
}
39+
},
40+
rules: {
41+
'import/no-unresolved': 'off'
3942
}
4043
}
4144
];

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "model-viewer",
2+
"name": "@playcanvas/model-viewer",
33
"version": "5.5.4",
44
"author": "PlayCanvas<support@playcanvas.com>",
55
"homepage": "https://playcanvas.com",
@@ -55,12 +55,13 @@
5555
},
5656
"scripts": {
5757
"build": "rollup -c",
58-
"watch": "rollup -c -w",
59-
"serve": "serve --cors dist",
6058
"develop": "cross-env BUILD_TYPE=debug concurrently --kill-others \"npm run watch\" \"npm run serve\"",
61-
"develop:local": "cross-env ENGINE_PATH=../engine npm run develop",
62-
"build:local": "cross-env ENGINE_PATH=../engine npm run build",
63-
"watch:local": "cross-env ENGINE_PATH=../engine npm run watch",
64-
"lint": "eslint src"
59+
"lint": "eslint src rollup.config.mjs eslint.config.mjs",
60+
"lint:fix": "eslint src rollup.config.mjs eslint.config.mjs --fix",
61+
"serve": "serve --cors dist",
62+
"watch": "rollup -c -w"
63+
},
64+
"engines": {
65+
"node": ">=18.0.0"
6566
}
6667
}

rollup.config.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const RESET_OUT = '\x1b[0m';
2626
const title = [
2727
'Building PlayCanvas Model Viewer',
2828
`type ${BOLD_OUT}${BUILD_TYPE}${REGULAR_OUT}`,
29-
`engine ${BOLD_OUT}${ENGINE_DIR}${REGULAR_OUT}`,
29+
`engine ${BOLD_OUT}${ENGINE_DIR}${REGULAR_OUT}`
3030
].map(l => `${BLUE_OUT}${l}`).join('\n');
3131
console.log(`${BLUE_OUT}${title}${RESET_OUT}\n`);
3232

@@ -35,8 +35,8 @@ const TARGETS = [
3535
src: 'src/index.html',
3636
transform: (contents) => {
3737
return contents.toString()
38-
.replace('__BASE_HREF__', process.env.BASE_HREF || '')
39-
.replace('__');
38+
.replace('__BASE_HREF__', process.env.BASE_HREF || '')
39+
.replace('__');
4040
}
4141
},
4242
{ src: 'src/manifest.json' },

0 commit comments

Comments
 (0)