Skip to content

Commit b449fe5

Browse files
committed
feat: make celestial bodies unreachable
1 parent efb424e commit b449fe5

5 files changed

Lines changed: 39 additions & 5 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# 8. Unreachable Celestial Bodies
2+
3+
Date: 2025-12-18
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
In the current implementation, the sun and moon are physical meshes positioned at a radius of 800 units from the player. While this works for the visual day/night cycle, it creates issues when the player uses the airplane mode. The player can easily fly close to or even collide with the sun/moon, breaking immersion. Celestial bodies should appear infinite distance away or at least unreachable.
12+
13+
## Decision
14+
15+
We will simulate "infinite" distance by:
16+
1. Increasing the main camera's `far` clipping plane from 1000 to 20000.
17+
2. Increasing the orbital radius of the celestial bodies from 800 to 10000.
18+
3. Scaling up the geometry of the celestial bodies (from radius 80 to 1000) to maintain their apparent angular size from the player's perspective.
19+
20+
## Consequences
21+
22+
### Positive
23+
- **Realism**: The sun and moon effectively become part of the skybox and cannot be reached by the player during normal gameplay.
24+
- **Immersion**: Maintaining the visual scale while increasing distance prevents the "toy world" feeling when flying.
25+
26+
### Negative
27+
- **Z-Fighting Risk**: Increasing the far plane significantly *can* reduce depth buffer precision, potentially causing z-fighting on distant overlapping geometry. However, given our low-poly art style and the lack of complex overlapping distant geometry, this risk is minimal.
28+
- **Performance**: A larger frustum *might* include slightly more objects in the culling check, but our chunk system limits active objects anyway.
29+
30+
## Compliance
31+
- The `WeatherSystem` class in `weather.js` will be updated to use the new larger radius and geometry size.
32+
- The `initScene` function in `scene.js` will be updated to use the new far plane value.

docs/adr/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
* [5. Sync Start Date with Real World](0005-sync-start-date-with-real-world.md)
88
* [6. Geometry Merging](0006-geometry-merging.md)
99
* [7. Object Pooling](0007-object-pooling.md)
10+
* [8. Unreachable Celestial Bodies](0008-unreachable-celestial-bodies.md)

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async function init() {
118118
verDiv.style.background = 'rgba(0,0,0,0.5)';
119119
verDiv.style.padding = '5px';
120120
verDiv.style.fontFamily = 'monospace';
121-
verDiv.innerHTML = 'v6.2.0: Performance & Weather Update';
121+
verDiv.innerHTML = 'v6.3.0: Unreachable Celestial Bodies';
122122
document.body.appendChild(verDiv);
123123

124124
animate(() => {

src/scene.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function initScene() {
1111

1212

1313

14-
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
14+
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 20000);
1515
camera.position.set(0, 5, 10);
1616

1717
renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance" });

src/weather.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,14 @@ export class WeatherSystem {
9696

9797
initSky() {
9898
// Sun
99-
const sunGeom = new THREE.SphereGeometry(80, 32, 32);
99+
// Increased size for distance (was 80)
100+
const sunGeom = new THREE.SphereGeometry(1000, 32, 32);
100101
const sunMat = new THREE.MeshBasicMaterial({
101102
color: 0xffdd44,
102103
fog: false
103104
});
104105
this.sun = new THREE.Mesh(sunGeom, sunMat);
105-
this.sun.position.set(50, 500, 50);
106+
this.sun.position.set(500, 5000, 500);
106107
this.scene.add(this.sun);
107108
}
108109

@@ -292,7 +293,7 @@ export class WeatherSystem {
292293
if (t >= 6 && t < 18) sunAngle = ((t - 6) / 12) * Math.PI;
293294
else sunAngle = ((t - 6) / 24) * Math.PI * 2;
294295

295-
const radius = 800;
296+
const radius = 10000;
296297
const sunRelX = Math.cos(sunAngle) * radius;
297298
const sunRelY = Math.sin(sunAngle) * radius;
298299

0 commit comments

Comments
 (0)