Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/client/world/sky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ export class Sky {
setRoof(on: boolean, drop = 0) {
this.roof = on;
this.roofStreet = -drop;
uniforms.skyInside.value = uniforms.skyClearRooms.value = on || this.indoors ? 0 : 1;
uniforms.skyInside.value = on || this.indoors ? 0 : 1;
uniforms.skyClearRooms.value = this.indoors ? 0 : 1;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions tests/sky-fog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,20 @@ test('unlit fogged materials get the same indoor fog clearing', () => {
assert.ok('skyWing' in shader.uniforms);
});

test('room fog clearing is enabled for office floors, the garage and street, but not other maps or the roof', () => {
test('room fog clearing is enabled for office floors, the garage and street, and kept on the roof, but not other maps', () => {
const shader = compile(new THREE.MeshBasicMaterial({ fog: true }));
const clearRooms = () => (shader.uniforms.skyClearRooms as { value: number }).value;
const inside = () => (shader.uniforms.skyInside as { value: number }).value;
const sky = { roof: false, indoors: false, roofStreet: 0 } as unknown as Sky;
Sky.prototype.setIndoors.call(sky, false);
Sky.prototype.setRoof.call(sky, false);
assert.equal(clearRooms(), 1, 'office floors, garage and street clear fog from room fragments');
Sky.prototype.setRoof.call(sky, true);
assert.equal(clearRooms(), 0, 'the rooftop is outdoors, so its fog stays whole');
assert.equal(clearRooms(), 1, 'the rooftop stays outdoors but keeps clearing fog from the office interior below');
assert.equal(inside(), 0, 'the rooftop takes no lamplight from the office under your feet');
Sky.prototype.setRoof.call(sky, false);
assert.equal(clearRooms(), 1, 'returning from the roof to the office re-enables room clearing');
Sky.prototype.setIndoors.call(sky, true);
assert.equal(clearRooms(), 0, 'enclosed alternate maps do not use the office room boxes to clear fog');
assert.equal(inside(), 0, 'enclosed alternate maps take no office lamplight either');
});