Skip to content

Commit

Permalink
Fixed stars tearing along the line perpendicular to the ecliptic
Browse files Browse the repository at this point in the history
  • Loading branch information
nicross committed Jul 17, 2021
1 parent 6aa2f2d commit 0fb2dbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Added adjustable backlight to Dark Mode
- Added backlight strength slider to Graphics screen
- Added UI theme color cycling based on in-game solar time
- Fixed star projection

<details>
<summary>Spoiler Warning</summary>
Expand Down
22 changes: 13 additions & 9 deletions src/js/app/canvas/stars.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,8 @@ app.canvas.stars = (() => {
const horizonCutoff = horizon - (Math.max(1, (width / 1920) * 8))

for (const star of stars) {
const relative = engine.utility.vector3d.create({
x: firmament,
}).rotateEuler({
const relative = star.vector.rotateEuler({
pitch: rotation,
}).rotateEuler({
pitch: star.theta,
yaw: star.delta,
}).rotateQuaternion(conjugate)

const hangle = Math.atan2(relative.y, relative.x)
Expand Down Expand Up @@ -174,14 +169,23 @@ app.canvas.stars = (() => {
for (let i = 0; i < count; i += 1) {
const delta = srand(-1, 1)

// TODO: Convert delta/theta to a 3d unit vector so the projection doesn't tear North-South along the y-axis
stars.push({
const star = {
alpha: srand(1/2, 1),
delta: Math.PI / 2 * engine.utility.sign(delta) * (delta ** 2),
phase: 2 * Math.PI * srand(),
theta: 2 * Math.PI * srand(),
radius: engine.utility.lerpExp(0.5, 1, srand(), 8),
})
}

star.vector = engine.utility.vector3d.unitX()
.scale(firmament)
.rotateEuler({
pitch: star.theta,
yaw: star.delta,
})

// TODO: Convert delta/theta to a 3d unit vector so the projection doesn't tear North-South along the y-axis
stars.push(star)
}
}

Expand Down

0 comments on commit 0fb2dbb

Please sign in to comment.