Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Commit af193b1

Browse files
Update Celestial Bodies Page
1 parent 9eeab52 commit af193b1

File tree

1 file changed

+40
-31
lines changed

1 file changed

+40
-31
lines changed

viewers/templates/Celestial Bodies.html

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@
9191
body.name = name;
9292
scene.add( body );
9393

94-
if (name === 'Earth') earth_loaded = true;
95-
if (name === 'Moon') moon_loaded = true;
94+
if (name === 'Earth') { body.receiveShadow = true; earth_loaded = true; }
95+
if (name === 'Moon') { body.castShadow = true; moon_loaded = true; }
9696
if (name === 'Sun') sun_loaded = true;
9797

98-
if (earth_loaded && moon_loaded && sun_loaded) {
98+
if (earth_loaded === true && moon_loaded === true && sun_loaded === true) {
99+
scene.getObjectByName( 'Earth' ).add( scene.getObjectByName( 'Moon' ) );
100+
scene.getObjectByName( 'Earth' ).rotation.y -= Math.PI / 3.0;
101+
99102
bump_map.dispose();
100103
normal_map.dispose();
101104
document.getElementById('div_loading').style.display = 'none';
@@ -118,6 +121,27 @@
118121
texture.dispose();
119122
}, undefined, () => { console.log( 'Error loading textures' ) });
120123

124+
await createCelestialBody(
125+
'Sun',
126+
5,
127+
'',
128+
{ x: 50, y: 3, z: 15 }
129+
);
130+
131+
await createCelestialBody(
132+
'Moon',
133+
0.5,
134+
'https://raw.githubusercontent.com/mrdoob/three.js/master/examples/textures/planets/moon_1024.jpg',
135+
{ x: 5, y: 1, z: 1.35 }
136+
);
137+
138+
await createCelestialBody(
139+
'Earth',
140+
2.25,
141+
'https://raw.githubusercontent.com/mrdoob/three.js/master/examples/textures/planets/earth_atmos_4096.jpg',
142+
{ x: -4, y: 3, z: -0.25 }
143+
);
144+
121145
let camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
122146
isMobile === true ? camera.position.set( 0, 0, 50 ) : camera.position.set( 0, 0, 12 );
123147
scene.add( camera );
@@ -141,17 +165,24 @@
141165
document.body.appendChild( renderer.domElement );
142166

143167
let controls = new OrbitControls( camera, renderer.domElement );
144-
controls.target.set( 0, 3, 0 );
168+
controls.target.set( 0, 4, 0 );
145169
controls.enableDamping = true;
170+
controls.autoRotate = true;
171+
controls.autoRotateSpeed = -0.05;
146172
controls.zoomSpeed = 0.6;
147173
controls.rotateSpeed = 0.6;
148174
controls.keyPanSpeed = 0.6;
149175
controls.panSpeed = 0.6;
150176

151177
let light = new THREE.DirectionalLight( 0xffffff, 5 );
152-
light.position.set( 25, 5, 50 );
153-
let ambient_light = new THREE.AmbientLight( 0xffffff, 0.075 );
178+
light.position.set( 50, 3, 15 );
179+
light.castShadow = true;
180+
light.shadow.mapSize.width = 2048;
181+
light.shadow.mapSize.height = 2048;
182+
183+
let ambient_light = new THREE.AmbientLight( 0xffffff, 0.09 );
154184
ambient_light.position.set( -3, 3, -25 );
185+
155186
scene.add( light, ambient_light );
156187

157188
// Emissive bloom post processing
@@ -164,42 +195,20 @@
164195

165196
let outputPass = scenePass.getTextureNode();
166197
let emissivePass = scenePass.getTextureNode( 'emissive' );
167-
let bloomPass = bloom( emissivePass, 1.5, 0.35 );
198+
let bloomPass = bloom( emissivePass, 2.5, 0.35 );
168199

169200
let postProcessing = new THREE.PostProcessing( renderer );
170201
postProcessing.outputNode = outputPass.add( bloomPass );
171202

172203
renderer.setAnimationLoop(() => {
173204
controls.update();
174205

175-
scene.rotation.y -= 0.00005; // Scene rotation
176-
scene.getObjectByName( 'Earth' ).rotation.y += 0.0005; // Earth rotation
177-
scene.getObjectByName( 'Moon' ).rotation.y -= 0.001; // Moon rotation
206+
scene.getObjectByName( 'Earth' ).rotation.y += 0.0005; // Earth + Moon rotation
207+
scene.getObjectByName( 'Moon' ).rotation.y -= 0.0015; // Moon rotation
178208

179209
postProcessing.render();
180210
});
181211

182-
await createCelestialBody(
183-
'Sun',
184-
5,
185-
'',
186-
{ x: 25, y: 5, z: 50 }
187-
);
188-
189-
await createCelestialBody(
190-
'Moon',
191-
0.5,
192-
'https://raw.githubusercontent.com/mrdoob/three.js/master/examples/textures/planets/moon_1024.jpg',
193-
{ x: 2.5, y: 3, z: 0 }
194-
);
195-
196-
await createCelestialBody(
197-
'Earth',
198-
2.25,
199-
'https://raw.githubusercontent.com/mrdoob/three.js/master/examples/textures/planets/earth_atmos_4096.jpg',
200-
{ x: -4, y: 3, z: 0 }
201-
);
202-
203212
window.addEventListener("resize", (event) => {
204213
camera.aspect = innerWidth / innerHeight;
205214
camera.updateProjectionMatrix();

0 commit comments

Comments
 (0)