Skip to content

Commit 6da978e

Browse files
committed
Update deps and examples
1 parent c95fbef commit 6da978e

File tree

10 files changed

+190
-153
lines changed

10 files changed

+190
-153
lines changed

.github/workflows/eslint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Install Node.js
2727
uses: actions/setup-node@v4
2828
with:
29-
node-version: 22.9.0
29+
node-version: 22.14.0
3030
cache: 'npm'
3131

3232
- name: Install Modules

.github/workflows/publish.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Install Node.js
2222
uses: actions/setup-node@v4
2323
with:
24-
node-version: 22.9.0
24+
node-version: 22.14.0
2525
cache: 'npm'
2626

2727
- name: Get Package Version
@@ -37,7 +37,7 @@ jobs:
3737

3838
- name: Create Release
3939
id: create_release
40-
uses: softprops/action-gh-release@v1
40+
uses: softprops/action-gh-release@v2
4141
env:
4242
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4343
with:

.github/workflows/test.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
Test:
1313
strategy:
1414
matrix:
15-
os: [ubuntu-22.04]
15+
os: [ubuntu-22.04, ubuntu-22.04-arm, windows-2022, macos-14]
1616

1717
runs-on: ${{ matrix.os }}
1818

@@ -26,12 +26,20 @@ jobs:
2626
- name: Install Node.js
2727
uses: actions/setup-node@v4
2828
with:
29-
node-version: 22.9.0
29+
node-version: 22.14.0
3030
cache: 'npm'
3131

3232
- name: Install Modules
3333
run: npm ci
3434

35-
- name: Run Unit Tests
36-
if: matrix.os == 'ubuntu-22.04'
35+
- name: Tests - Linux
36+
if: matrix.os == 'ubuntu-22.04' || matrix.os == 'ubuntu-22.04'
3737
run: xvfb-run --auto-servernum npm run test-ci
38+
39+
# - name: Test - Windows
40+
# if: matrix.os == 'windows-2022'
41+
# run: npm run test-ci
42+
43+
- name: Test - MacOS
44+
if: matrix.os == 'macos-14'
45+
run: npm run test-ci

examples/palette/palette.mjs

+21-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { createRenderTarget } from './utils/create-render-target.js';
1414
import { populateScene } from './utils/populate-scene.js';
1515

1616

17+
const IS_PERF_MODE = true;
18+
1719
const hueModes = [
1820
'monochromatic', 'analagous', 'complementary', 'triadic', 'tetradic',
1921
];
@@ -27,7 +29,8 @@ const {
2729
isWebGL2: true,
2830
autoEsc: true,
2931
autoFullscreen: true,
30-
title: 'Palette Swap'
32+
title: 'Palette Swap',
33+
vsync: !IS_PERF_MODE,
3134
});
3235
addThreeHelpers(THREE, gl);
3336

@@ -205,6 +208,9 @@ const render = () => {
205208
screen.renderer.render(scenePost, cameraOrtho);
206209
};
207210

211+
let prevTime = Date.now();
212+
let frames = 0;
213+
208214
loop(() => {
209215
controls.update();
210216

@@ -213,4 +219,18 @@ loop(() => {
213219
}
214220

215221
render();
222+
223+
if (!IS_PERF_MODE) {
224+
return;
225+
}
226+
227+
frames++;
228+
const time = Date.now();
229+
if (time >= prevTime + 2000) {
230+
console.log(
231+
'FPS:', Math.floor((frames * 1000) / (time - prevTime)),
232+
);
233+
prevTime = time;
234+
frames = 0;
235+
}
216236
});

examples/palette/profile.txt

Whitespace-only changes.

examples/srgb/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/three/post.mjs

+22-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
2323
import { init, addThreeHelpers } from '../../index.js';
2424

2525

26+
const IS_PERF_MODE = true;
27+
2628
const __dirname = dirname(fileURLToPath(import.meta.url));
2729

2830

@@ -33,7 +35,7 @@ const {
3335
// isWebGL2: true,
3436
autoEsc: true,
3537
autoFullscreen: true,
36-
vsync: true,
38+
vsync: !IS_PERF_MODE,
3739
title: 'Postprocessing',
3840
});
3941
addThreeHelpers(THREE, gl);
@@ -311,10 +313,13 @@ function createMesh(geometry, scene, scale) {
311313
}
312314

313315

316+
let prevTime = Date.now();
317+
let frames = 0;
318+
314319
loop(() => {
315-
const time = Date.now() * 0.0004;
320+
const timedRotation = Date.now() * 0.0004;
316321

317-
if (mesh) mesh.rotation.y = - time;
322+
if (mesh) mesh.rotation.y = -timedRotation;
318323

319324
renderer.setViewport(0, 0, halfWidth, halfHeight);
320325
composerScene.render(delta);
@@ -330,4 +335,18 @@ loop(() => {
330335

331336
renderer.setViewport(halfWidth, halfHeight, halfWidth, halfHeight);
332337
composer4.render(delta);
338+
339+
if (!IS_PERF_MODE) {
340+
return;
341+
}
342+
343+
frames++;
344+
const time = Date.now();
345+
if (time >= prevTime + 1000) {
346+
console.log(
347+
'FPS:', Math.floor((frames * 1000) / (time - prevTime)),
348+
);
349+
prevTime = time;
350+
frames = 0;
351+
}
333352
});

js/index.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,6 @@ const _init = (_opts = {}) => {
106106
global.Image = Image;
107107
global._gl = webgl;
108108

109-
const loop = (cb) => {
110-
let i = 0;
111-
112-
const animation = () => {
113-
cb(i++);
114-
doc.requestAnimationFrame(animation);
115-
};
116-
117-
doc.requestAnimationFrame(animation);
118-
};
119-
120109
webgl.canvas = doc;
121110

122111
const core3d = {
@@ -129,7 +118,7 @@ const _init = (_opts = {}) => {
129118
canvas: doc,
130119
document: doc,
131120
window: doc,
132-
loop,
121+
loop: doc.loop,
133122
requestAnimationFrame : doc.requestAnimationFrame,
134123
addThreeHelpers,
135124
...require('./math'),

0 commit comments

Comments
 (0)