feat: initialize sunrise with 100-player shared rooms
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { Mesh, Points, Vector3 } from 'three';
|
||||
import { createNightSky } from '../src/scene/nightSky.ts';
|
||||
import { observer } from '../src/config/observer.ts';
|
||||
|
||||
test('decorative stars stay fixed across reloads and disappear in daylight', () => {
|
||||
const a = createNightSky(new Vector3()), b = createNightSky(new Vector3());
|
||||
const stars = a.group.children.find(child => child instanceof Points)! as Points;
|
||||
const other = b.group.children.find(child => child instanceof Points)! as Points;
|
||||
assert.deepEqual(stars.geometry.attributes.position.array, other.geometry.attributes.position.array);
|
||||
const date = new Date('2026-10-30T23:00:00+09:00');
|
||||
a.update(date, observer, -20);
|
||||
assert.equal(stars.visible, true);
|
||||
a.update(date, observer, 10);
|
||||
assert.equal(stars.visible, false);
|
||||
a.dispose(); b.dispose();
|
||||
});
|
||||
|
||||
test('moon moves from below the horizon into the northeastern night sky', () => {
|
||||
const eye = new Vector3(100, 500, -100);
|
||||
const sky = createNightSky(eye);
|
||||
const moon = sky.group.children.find(child => child instanceof Mesh)! as Mesh;
|
||||
sky.update(new Date('2026-10-30T18:00:00+09:00'), observer, -10);
|
||||
assert.ok(moon.position.y < eye.y);
|
||||
sky.update(new Date('2026-10-30T23:00:00+09:00'), observer, -30);
|
||||
const direction = moon.position.clone().sub(eye).normalize();
|
||||
assert.ok(direction.x > 0 && direction.z < 0 && direction.y > 0);
|
||||
assert.ok(Math.abs(Math.asin(direction.y) * 180 / Math.PI - 21) < 0.2);
|
||||
sky.dispose();
|
||||
});
|
||||
Reference in New Issue
Block a user