Skip to content

Commit 336e8e4

Browse files
Update Three.js to 0.185.1 and use modern color management API
1 parent 84906e9 commit 336e8e4

3 files changed

Lines changed: 80 additions & 42 deletions

File tree

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
"assets"
4343
],
4444
"dependencies": {
45-
"@types/three": "^0.156.0",
4645
"skinview-utils": "^0.7.1",
47-
"three": "^0.156.0"
46+
"three": "^0.185.1"
4847
},
4948
"devDependencies": {
49+
"@types/three": "^0.185.1",
5050
"@rollup/plugin-node-resolve": "^15.0.2",
5151
"@swc/core": "^1.3.53",
5252
"@typescript-eslint/eslint-plugin": "^8.31.1",

src/viewer.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ import {
3131
DepthTexture,
3232
Clock,
3333
Object3D,
34-
ColorManagement,
34+
35+
SRGBColorSpace,
3536
} from "three";
3637
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
3738
import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js";
3839
import { FullScreenQuad } from "three/examples/jsm/postprocessing/Pass.js";
3940
import { RenderPass } from "three/examples/jsm/postprocessing/RenderPass.js";
4041
import { ShaderPass } from "three/examples/jsm/postprocessing/ShaderPass.js";
4142
import { FXAAShader } from "three/examples/jsm/shaders/FXAAShader.js";
43+
import { OutputPass } from "three/examples/jsm/postprocessing/OutputPass.js";
4244
import { PlayerAnimation } from "./animation.js";
4345
import { type BackEquipment, PlayerObject } from "./model.js";
4446
import { NameTagObject } from "./nametag.js";
@@ -343,13 +345,14 @@ export class SkinViewer {
343345
this.camera.add(this.cameraLight);
344346
this.scene.add(this.camera);
345347
this.scene.add(this.globalLight);
346-
ColorManagement.enabled = false;
347348

348349
this.renderer = new WebGLRenderer({
349350
canvas: this.canvas,
350351
preserveDrawingBuffer: options.preserveDrawingBuffer === true, // default: false
351352
});
352353

354+
this.renderer.outputColorSpace = SRGBColorSpace;
355+
353356
this.onDevicePixelRatioChange = () => {
354357
this.renderer.setPixelRatio(window.devicePixelRatio);
355358
this.updateComposerSize();
@@ -385,6 +388,7 @@ export class SkinViewer {
385388
this.fxaaPass = new ShaderPass(FXAAShader);
386389
this.composer.addPass(this.renderPass);
387390
this.composer.addPass(this.fxaaPass);
391+
this.composer.addPass(new OutputPass());
388392

389393
this.playerObject = new PlayerObject();
390394
this.playerObject.name = "player";
@@ -510,6 +514,7 @@ export class SkinViewer {
510514
this.skinTexture.dispose();
511515
}
512516
this.skinTexture = new CanvasTexture(this.skinCanvas);
517+
this.skinTexture.colorSpace = SRGBColorSpace;
513518
this.skinTexture.magFilter = NearestFilter;
514519
this.skinTexture.minFilter = NearestFilter;
515520
this.playerObject.skin.map = this.skinTexture;
@@ -520,6 +525,7 @@ export class SkinViewer {
520525
this.capeTexture.dispose();
521526
}
522527
this.capeTexture = new CanvasTexture(this.capeCanvas);
528+
this.capeTexture.colorSpace = SRGBColorSpace;
523529
this.capeTexture.magFilter = NearestFilter;
524530
this.capeTexture.minFilter = NearestFilter;
525531
this.playerObject.cape.map = this.capeTexture;
@@ -531,6 +537,7 @@ export class SkinViewer {
531537
this.earsTexture.dispose();
532538
}
533539
this.earsTexture = new CanvasTexture(this.earsCanvas);
540+
this.earsTexture.colorSpace = SRGBColorSpace;
534541
this.earsTexture.magFilter = NearestFilter;
535542
this.earsTexture.minFilter = NearestFilter;
536543
this.playerObject.ears.map = this.earsTexture;
@@ -676,6 +683,7 @@ export class SkinViewer {
676683
if (mapping !== undefined) {
677684
this.backgroundTexture.mapping = mapping;
678685
}
686+
this.backgroundTexture.colorSpace = SRGBColorSpace;
679687
this.backgroundTexture.needsUpdate = true;
680688
this.scene.background = this.backgroundTexture;
681689
} else {

0 commit comments

Comments
 (0)