Skip to content

Commit 28a090b

Browse files
Merge remote-tracking branch 'dev/main'
2 parents d502411 + e548228 commit 28a090b

12 files changed

Lines changed: 57 additions & 62 deletions

File tree

js/Celestiary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default class Celestiary {
9090
this.scene.toggleStarLabels()
9191
this.firstTime = false
9292
}
93-
}, 1000)
93+
}, this.firstTime ? 1000 : 0)
9494
}
9595

9696
let path

js/Planet.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export default class Planet extends Object {
103103
*/
104104
newOrbit(scene, orbit) {
105105
const group = named(new Group(), 'orbit')
106-
group.visible = true
107106
const ellipseCurve = new EllipseCurve(
108107
0, 0,
109108
1, ellipseSemiMinorAxisCurve(assertInRange(orbit.eccentricity, 0, 1)),
@@ -192,7 +191,8 @@ export default class Planet extends Object {
192191

193192
const labelLOD = new LOD()
194193
const name = capitalize(this.name)
195-
const labelSheet = new SpriteSheet(1, name)
194+
// TODO: single sheet for all planets/moons
195+
const labelSheet = named(new SpriteSheet(1, name), 'label')
196196
labelSheet.add(0, 0, 0, name, labelTextColor)
197197
labelLOD.addLevel(FAR_OBJ, labelTooNearDist)
198198
labelLOD.addLevel(labelSheet.compile(), labelTooNearDist)
@@ -269,9 +269,9 @@ export default class Planet extends Object {
269269
}
270270
const group = new Group
271271
group.add(surface)
272-
const internalGuidesRadius = this.props.radius.scalar * 0.7
272+
const internalGuidesRadius = this.props.radius.scalar * 0.9
273273
group.add(new AxesHelper(internalGuidesRadius))
274-
group.add(sphere({radius: internalGuidesRadius, wireframe: true, color: 0x808080}))
274+
// group.add(sphere({radius: internalGuidesRadius, wireframe: true, color: 0x808080}))
275275
return named(group, 'planet surface and guides')
276276
}
277277

js/Scene.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import * as Shared from './shared.js'
1212
import * as Utils from './utils.js'
1313

1414

15-
const
16-
lengthScale = Shared.LENGTH_SCALE
1715
const INITIAL_STEP_BACK_MULT = 10
1816

1917

@@ -190,7 +188,7 @@ export default class Scene {
190188
tPos.setFromMatrixPosition(obj.matrixWorld)
191189
const pPos = new Vector3
192190
const cPos = new Vector3
193-
const surfaceAltitude = obj.props.radius.scalar // * lengthScale
191+
const surfaceAltitude = obj.props.radius.scalar
194192
pPos.set(0, 0, 0) // TODO(pablo): maybe put platform at surfaceAltitude
195193
const camDist = obj.initialCameraDistance || (surfaceAltitude * INITIAL_STEP_BACK_MULT)
196194
const elevationAngleRad = 15 / 360 * Math.PI * 2
@@ -366,7 +364,7 @@ export default class Scene {
366364

367365
/** */
368366
togglePlanetLabels() {
369-
Utils.visitToggleProperty(this.objects['sun'], 'name', 'label', 'visible')
367+
Utils.visitToggleProperty(this.objects['sun'], 'name', 'label LOD', 'visible')
370368
}
371369

372370

js/Stars.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import StarsBufferGeometry from './StarsBufferGeometry.js'
1515
import StarsCatalog, {FAVES} from './StarsCatalog.js'
1616
import {assertDefined} from './assert.js'
1717
import * as Material from './material.js'
18-
import {FAR_OBJ, STAR_VOLUME_METERS} from './shared.js'
18+
import {FAR_OBJ, STARS_RADIUS_METER, SUN_RADIUS_METER} from './shared.js'
1919
import {named} from './utils.js'
2020

2121

@@ -42,7 +42,7 @@ export default class Stars extends Object {
4242
this.labelLOD = named(new LOD, 'LabelsLOD')
4343
this.labelLOD.visible = showLabels
4444
this.labelLOD.addLevel(this.labelsGroup, 1)
45-
this.labelLOD.addLevel(FAR_OBJ, STAR_VOLUME_METERS)
45+
this.labelLOD.addLevel(FAR_OBJ, STARS_RADIUS_METER)
4646
this.add(this.labelLOD)
4747
this.geom = null
4848

@@ -75,7 +75,6 @@ export default class Stars extends Object {
7575
show() {
7676
this.geom = new StarsBufferGeometry(this.catalog)
7777
const starImage = Material.pathTexture('star_glow', '.png')
78-
const sunSizeMeters = 6.957e8
7978
const starsMaterial = new ShaderMaterial({
8079
uniforms: {
8180
texSampler: {value: starImage},
@@ -87,7 +86,7 @@ export default class Stars extends Object {
8786
// surface just meet the glow in the png image.
8887
// STAR_MAGNIFY_2: {value: 2e4}, // 2e4, 2e9
8988
// CAMERA_EXPOSURE: {value: 3e16 * 3.7e-38},
90-
STAR_MAGNIFY_2: {value: 1/sunSizeMeters * 1e1},
89+
STAR_MAGNIFY_2: {value: 1/SUN_RADIUS_METER * 1e1},
9190
CAMERA_EXPOSURE: {value: 1},
9291
MIN_BRIGHT: {value: 1},
9392
MAX_BRIGHT: {value: 2e16}, // half-float max

js/StarsBufferGeometry.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {BufferAttribute, BufferGeometry} from 'three'
22
import {StarSpectra} from './StarsCatalog.js'
3-
import {METERS_PER_LIGHTYEAR} from './shared.js'
43

54

65
/** Pack the data from a StarsCatalog into a BufferGeometry. */

js/StarsCatalog.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {LENGTH_SCALE, METERS_PER_LIGHTYEAR} from './shared.js'
1+
import {LENGTH_SCALE, LIGHTYEAR_METER} from './shared.js'
22
import {assertEquals, assertNotNullOrUndefined} from './utils.js'
33

44
// Format description at https://en.wikibooks.org/wiki/Celestia/Binary_Star_File
@@ -49,7 +49,7 @@ export default class StarsCatalog {
4949
minMag = -8.25390625,
5050
maxMag = 15.4453125,
5151
// 1E1 looks decent. 2E1 much more intriguing but a little fake.
52-
starScale = METERS_PER_LIGHTYEAR,
52+
starScale = LIGHTYEAR_METER,
5353
lengthScale = LENGTH_SCALE) {
5454
/** @type {StarByHip} */
5555
this.starByHip = starByHip
@@ -150,9 +150,9 @@ export default class StarsCatalog {
150150
/** @type {StarProps} */
151151
const star = {
152152
hipId: hipId,
153-
x: x * METERS_PER_LIGHTYEAR,
154-
y: y * METERS_PER_LIGHTYEAR,
155-
z: z * METERS_PER_LIGHTYEAR,
153+
x: x * LIGHTYEAR_METER,
154+
y: y * LIGHTYEAR_METER,
155+
z: z * LIGHTYEAR_METER,
156156
absMag: absMag,
157157
kind: kind,
158158
spectralType: type,

js/ThreeUI.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {Pass} from 'three/addons/postprocessing/Pass.js';
2525
import {RenderPass} from 'three/addons/postprocessing/RenderPass.js';
2626
import {ShaderPass} from 'three/addons/postprocessing/ShaderPass.js';
2727
import Fullscreen from '@pablo-mayrgundter/fullscreen.js/fullscreen.js'
28-
import {INITIAL_FOV, METERS_PER_LIGHTYEAR} from './shared.js'
28+
import {INITIAL_FOV, SMALLEST_SIZE_METER, STARS_RADIUS_METER, SUN_RADIUS_METER} from './shared.js'
2929
import {named} from './utils.js'
3030

3131

@@ -94,9 +94,13 @@ export default class ThreeUi {
9494

9595
/** Sets camera near and far to deimos and local star cluster. */
9696
configLargeScene() {
97-
this.camera.near = 6e5 // Little less than radius of deimos
98-
this.camera.far = METERS_PER_LIGHTYEAR * 2e4 // Celestia catalog max
97+
this.camera.near = SMALLEST_SIZE_METER
98+
this.camera.far = STARS_RADIUS_METER * 2
9999
this.camera.updateProjectionMatrix()
100+
101+
// This is a bit of a hack. Starting the camera away from center so there's
102+
// less obvious jumping around, e.g. seeing inside of sun.
103+
this.camera.position.z = SUN_RADIUS_METER * 1e3
100104
}
101105

102106

js/guide/Orbit.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function setup() {
176176
const orbit = curPlanet.orbit.props
177177
// console.log('has orbit!', orbit);
178178
// TODO: orig code read this as semiMajorAxis.scalar
179-
const aRadius = 1// orbit.semiMajorAxis * LENGTH_SCALE;
179+
const aRadius = 1
180180
const bRadius = aRadius * Math.sqrt(1.0 - Math.pow(orbit.eccentricity, 2.0))
181181
const angle = 1.0 * simTimeSecs / orbit.siderealOrbitPeriod.scalar * Shared.twoPi
182182
const x = aRadius * Math.cos(angle)

js/guide/Stars.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {ReactElement, useEffect} from 'react'
22
import ThreeUi from '../ThreeUI'
33
import StarsFromApp from '../Stars'
44
import {getSunProps} from '../StarsCatalog'
5-
import {METERS_PER_LIGHTYEAR, ASTRO_UNIT_METER} from '../shared'
5+
import {ASTRO_UNIT_METER} from '../shared'
66
import {ui as uiId} from './index.module.css'
77

88

js/shapes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
AdditiveBlending,
33
ArrowHelper,
4+
BackSide,
45
BoxGeometry,
56
BufferAttribute,
67
BufferGeometry,
@@ -77,7 +78,8 @@ export function sphere(opts) {
7778
depthTest: true,
7879
depthWrite: false,
7980
toneMapped: false,
80-
transparent: true,
81+
transparent: false,
82+
side: BackSide,
8183
}) :
8284
new MeshPhongMaterial({
8385
flatShading: true,

0 commit comments

Comments
 (0)