@@ -4,12 +4,20 @@ const ZOOM_DIST = 5; // how close the camera gets (in planet radii + of
44const TWEEN_SPEED = 0.07 ; // lerp factor for camera movement
55
66export function main ( canvas , onPlanetFocus ) {
7-
7+ const loader = new THREE . TextureLoader ( ) ;
88 const renderer = new THREE . WebGLRenderer ( { antialias : true , canvas } ) ;
99 renderer . setPixelRatio ( window . devicePixelRatio ) ;
1010 renderer . toneMapping = THREE . ACESFilmicToneMapping ;
1111 renderer . toneMappingExposure = 2.0 ;
1212
13+ const createRepeatingTexture = ( path , repeatX = 2 , repeatY = 1 ) => {
14+ const tex = loader . load ( path ) ;
15+ tex . wrapS = THREE . RepeatWrapping ;
16+ tex . wrapT = THREE . RepeatWrapping ;
17+ tex . repeat . set ( repeatX , repeatY ) ;
18+ return tex ;
19+ } ;
20+
1321 const fov = 45 ;
1422 const aspect = canvas . clientWidth / canvas . clientHeight ;
1523 const near = 0.1 ;
@@ -37,20 +45,19 @@ export function main(canvas, onPlanetFocus) {
3745 // Sun
3846 const sunGeo = new THREE . SphereGeometry ( 4.5 , 64 , 64 ) ;
3947 const sunMat = new THREE . MeshStandardMaterial ( {
40- color : 0xe8ffff ,
41- emissive : 0x88ffee ,
42- emissiveIntensity : 3.2 ,
43- roughness : 0.0 ,
44- metalness : 0.0
48+ map : createRepeatingTexture ( '/textures/glorptest.png' , 3 , 3 ) ,
49+ emissiveMap : loader . load ( '/textures/suntexture.webp' ) , // same tex drives the glow
50+ emissive : 0x91ffaf ,
51+ emissiveIntensity : 0.1 ,
4552 } ) ;
4653 const sun = new THREE . Mesh ( sunGeo , sunMat ) ;
4754 scene . add ( sun ) ;
4855
4956 // Planets
5057 const planetData = [
51- { radius : 1.1 , orbitR : 14 , speed : 0.8 , tilt : 0.2 , color : 0xff6644 , emissive : 0x441100 } ,
52- { radius : 1.5 , orbitR : 24 , speed : 0.45 , tilt : 0.35 , color : 0x44aaff , emissive : 0x001133 } ,
53- { radius : 1.2 , orbitR : 36 , speed : 0.25 , tilt : 0.15 , color : 0x88dd55 , emissive : 0x112200 } ,
58+ { radius : 1.1 , orbitR : 14 , speed : 0.8 , tilt : 0.2 , color : 0xff6644 , emissive : 0x441100 , texture : '/textures/texture1.webp' } ,
59+ { radius : 1.5 , orbitR : 24 , speed : 0.45 , tilt : 0.35 , color : 0x44aaff , emissive : 0x001133 , texture : '/textures/texture2.webp' } ,
60+ { radius : 1.2 , orbitR : 36 , speed : 0.25 , tilt : 0.15 , color : 0x88dd55 , emissive : 0x112200 , texture : '/textures/texture3.webp' } ,
5461 ] ;
5562
5663 const planets = planetData . flatMap ( d => {
@@ -72,9 +79,7 @@ export function main(canvas, onPlanetFocus) {
7279 return [ 0 , 1 , 2 ] . map ( i => {
7380 const geo = new THREE . SphereGeometry ( d . radius , 36 , 36 ) ;
7481 const mat = new THREE . MeshStandardMaterial ( {
75- color : d . color ,
76- emissive : d . emissive ,
77- emissiveIntensity : 1.0 ,
82+ map : loader . load ( d . texture ) ,
7883 roughness : 0.65 ,
7984 metalness : 0.05
8085 } ) ;
0 commit comments