-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13b4f06
commit 9cb6960
Showing
8 changed files
with
323 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// src/components/Planet/AtmosphereLayer.tsx | ||
import React from 'react'; | ||
import { AtmosphereShaderMaterial } from './shaders/atmosphereShader'; | ||
|
||
const AtmosphereLayer: React.FC = () => ( | ||
<mesh scale={[1.1, 1.1, 1.1]}> | ||
<sphereGeometry args={[1, 64, 64]} /> | ||
<primitive attach="material" object={AtmosphereShaderMaterial} /> | ||
</mesh> | ||
); | ||
|
||
export default AtmosphereLayer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// src/components/Planet/CloudsLayer.tsx | ||
import React, { useRef } from 'react'; | ||
import { CloudsShaderMaterial } from './shaders/cloudsShader'; | ||
import { useFrame } from '@react-three/fiber'; | ||
import * as THREE from 'three'; | ||
|
||
const CloudsLayer: React.FC = () => { | ||
const cloudsRef = useRef<THREE.Mesh>(null); | ||
|
||
useFrame(({ clock }) => { | ||
CloudsShaderMaterial.uniforms.time.value = clock.getElapsedTime(); | ||
}); | ||
|
||
return ( | ||
<mesh ref={cloudsRef} scale={[1.05, 1.05, 1.05]}> | ||
<sphereGeometry args={[1, 64, 64]} /> | ||
<primitive attach="material" object={CloudsShaderMaterial} /> | ||
</mesh> | ||
); | ||
}; | ||
|
||
export default CloudsLayer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// src/components/Planet/shaders/atmosphereShader.ts | ||
import * as THREE from 'three'; | ||
|
||
export const AtmosphereShaderMaterial = new THREE.ShaderMaterial({ | ||
vertexShader: ` | ||
varying vec3 vNormal; | ||
varying vec3 vPosition; | ||
void main() { | ||
vNormal = normalize(normalMatrix * normal); | ||
vPosition = position; | ||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); | ||
} | ||
`, | ||
fragmentShader: ` | ||
varying vec3 vNormal; | ||
varying vec3 vPosition; | ||
void main() { | ||
// Calculate atmosphere intensity based on viewing angle | ||
float intensity = pow(0.8 - dot(vNormal, vec3(0.0, 0.0, 1.0)), 4.0); | ||
// Create a gradient from blue to light blue | ||
vec3 atmosphereColor = mix( | ||
vec3(0.4, 0.7, 1.0), // Light blue | ||
vec3(0.6, 0.8, 1.0), // Lighter blue | ||
intensity | ||
); | ||
// Add slight color variation based on height | ||
float heightFactor = vPosition.y * 0.1 + 0.5; | ||
atmosphereColor *= heightFactor; | ||
gl_FragColor = vec4(atmosphereColor, intensity * 0.3); | ||
} | ||
`, | ||
blending: THREE.AdditiveBlending, | ||
side: THREE.BackSide, | ||
transparent: true, | ||
}); |
Oops, something went wrong.