Skip to content

Commit 858b17f

Browse files
committed
Use .applyColorCorrection on ground textures and dressing material color
1 parent 858bc10 commit 858b17f

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ <h1>
144144
});
145145
</script>
146146

147-
<a-scene overlay-visibility>
147+
<a-scene renderer="colorManagement: false" overlay-visibility>
148148

149149
<a-entity environment="preset: forest" preset-switcher id="environment"></a-entity>
150150

index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ AFRAME.registerComponent('environment', {
7474
init: function () {
7575
this.environmentData = {};
7676

77+
// renderer system for color correction
78+
this.rendererSystem = this.el.sceneEl.systems.renderer;
79+
7780
// stage ground diameter (and sky radius)
7881
this.STAGE_SIZE = 200;
7982

@@ -270,13 +273,18 @@ AFRAME.registerComponent('environment', {
270273
skycol.r = (skycol.r + 1.0) / 2.0;
271274
skycol.g = (skycol.g + 1.0) / 2.0;
272275
skycol.b = (skycol.b + 1.0) / 2.0;
273-
this.hemilight.setAttribute('light', {'color': '#' + skycol.getHexString()});
276+
this.hemilight.setAttribute('light', {
277+
'color': '#' + skycol.getHexString(),
278+
'intensity': 0.6
279+
});
274280
this.sunlight.setAttribute('light', {'intensity': 0.6});
275-
this.hemilight.setAttribute('light', {'intensity': 0.6});
276281
}
277282
else {
283+
this.hemilight.setAttribute('light', {
284+
'color': '#CEE4F0',
285+
'intensity': 0.1 + sunPos.y * 0.5
286+
});
278287
this.sunlight.setAttribute('light', {'intensity': 0.1 + sunPos.y * 0.5});
279-
this.hemilight.setAttribute('light', {'intensity': 0.1 + sunPos.y * 0.5});
280288
}
281289

282290
this.sunlight.setAttribute('light', {
@@ -553,6 +561,7 @@ AFRAME.registerComponent('environment', {
553561
this.gridTexture.wrapS = THREE.RepeatWrapping;
554562
this.gridTexture.wrapT = THREE.RepeatWrapping;
555563
this.gridTexture.repeat.set(texRepeat, texRepeat);
564+
this.rendererSystem.applyColorCorrection(this.gridTexture);
556565

557566
this.groundCanvas = document.createElement('canvas');
558567
this.groundCanvas.width = groundResolution;
@@ -561,6 +570,7 @@ AFRAME.registerComponent('environment', {
561570
this.groundTexture.wrapS = THREE.RepeatWrapping;
562571
this.groundTexture.wrapT = THREE.RepeatWrapping;
563572
this.groundTexture.repeat.set(texRepeat, texRepeat);
573+
this.rendererSystem.applyColorCorrection(this.groundTexture);
564574

565575
// ground material diffuse map is the regular ground texture and the grid texture
566576
// is used in the emissive map. This way, the grid is always equally visible, even at night.
@@ -943,6 +953,7 @@ AFRAME.registerComponent('environment', {
943953
var material = new THREE.MeshLambertMaterial({
944954
color: new THREE.Color(this.environmentData.dressingColor)
945955
});
956+
this.rendererSystem.applyColorCorrection(material.color);
946957

947958
// create mesh
948959
var mesh = new THREE.Mesh(bufgeo, material);

0 commit comments

Comments
 (0)