Skip to content

Commit acf645c

Browse files
committed
feat: added deimos and several tweaks of lighting stuff
1 parent 34e1471 commit acf645c

6 files changed

Lines changed: 159 additions & 45 deletions

File tree

src/app/assets/glb/NASA_Deimos.glb

1.53 MB
Binary file not shown.

src/app/assets/shaders/atmosphere/atmosphereFragment.glsl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/* Variables shared from a vertex shader to a fragment shader. */
2-
varying vec3 vertexNormal;
2+
in vec3 vertexNormal;
33

4-
/* Declare an output variable for the fragment color.
5-
This replaces the deprecated 'gl_FragColor' in GLSL ES 3.0.
6-
*/
4+
/* Declare an output variable for the fragment color. This replaces the
5+
deprecated 'gl_FragColor' in GLSL ES 3.0. */
76
out vec4 FragColor;
87

98
void main() {

src/app/components/landing-location/landing-location.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { MarsScene } from '../mars-scene/mars-scene.component';
1111
selector: 'sms-landing-location',
1212
template: `
1313
<section class="flex flex-col gap-8">
14-
<!-- <div id="canvas-container">
14+
<div id="canvas-container">
1515
<ngt-canvas
1616
[camera]="canvasCamera"
1717
[lookAt]="canvasLookAt"
@@ -20,7 +20,7 @@ import { MarsScene } from '../mars-scene/mars-scene.component';
2020
>
2121
<sms-mars-scene *canvasContent />
2222
</ngt-canvas>
23-
</div> -->
23+
</div>
2424
2525
<sms-landing-location-table />
2626
</section>
@@ -36,7 +36,7 @@ import { MarsScene } from '../mars-scene/mars-scene.component';
3636
})
3737
export class LandingLocationComponent {
3838
protected canvasCamera: NgtCameraParameters = {
39-
position: [0, 0, 20],
39+
position: [0, 0, 16],
4040
};
4141
protected canvasLookAt: NgtVector3 = [0, 0, 0];
4242
}

src/app/components/mars-scene/mars-atmosphere-mesh.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class MarsAtmosphereMeshComponent {
4545
* heightSegments].
4646
*/
4747
protected geometryArgs: ConstructorParameters<typeof SphereGeometry> = [
48-
8, 64, 64,
48+
6.8, 64, 64,
4949
];
5050

5151
/** */
@@ -55,6 +55,7 @@ export class MarsAtmosphereMeshComponent {
5555
fragmentShader: atmosphereFragmentShader,
5656
side: BackSide,
5757
blending: AdditiveBlending,
58+
transparent: true,
5859
};
5960

6061
/** Obtain the mesh reference with `viewChild` signal. */
@@ -74,6 +75,6 @@ export class MarsAtmosphereMeshComponent {
7475
*/
7576
private animate() {
7677
const atmosphereMeshEl = this.meshRef().nativeElement;
77-
atmosphereMeshEl.scale.set(1.1, 1.1, 1.1);
78+
atmosphereMeshEl.scale.set(1.25, 1.25, 1.25);
7879
}
7980
}

src/app/components/mars-scene/mars-mesh.component.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from 'angular-three';
1515
import { textureResource } from 'angular-three-soba/loaders';
1616
import {
17+
BackSide,
1718
DoubleSide,
1819
GLSL3,
1920
Mesh,
@@ -37,7 +38,7 @@ extend({ Mesh, SphereGeometry, MeshStandardMaterial, ShaderMaterial });
3738
standalone: true,
3839
template: `
3940
<!-- This mesh allows shadows from the directional light. -->
40-
<ngt-mesh [position]="[0, 0, 0]" castShadow>
41+
<ngt-mesh [position]="[0, 0, 0]" receiveShadow>
4142
<ngt-sphere-geometry *args="overlayGeoArgs" />
4243
<ngt-mesh-standard-material [parameters]="overlayMatParams" />
4344
</ngt-mesh>
@@ -51,9 +52,9 @@ extend({ Mesh, SphereGeometry, MeshStandardMaterial, ShaderMaterial });
5152
@let _textures = marsTextures.value();
5253
<!-- @let map = _textures?.map;
5354
@let normalMap = _textures?.normalMap;
54-
@let bumpMap = _textures?.bumpMap; -->
55+
@let bumpMap = _textures?.bumpMap;
5556
56-
<!-- <ngt-mesh-standard-material
57+
<ngt-mesh-standard-material
5758
[map]="map"
5859
[normalMap]="normalMap"
5960
[bumpMap]="bumpMap"
@@ -84,7 +85,7 @@ export class MarsMeshComponent {
8485

8586
/** Height and width segments. */
8687
private readonly sphereSegments = 64;
87-
private readonly sphereRadius = 8;
88+
private readonly sphereRadius = 6.8;
8889

8990
/**
9091
* Geometry arguments, in this case: [radius, widthSegments,
@@ -101,7 +102,7 @@ export class MarsMeshComponent {
101102
* radius to overlay.
102103
*/
103104
protected overlayGeoArgs: ConstructorParameters<typeof SphereGeometry> = [
104-
this.sphereRadius + 0.05,
105+
this.sphereRadius + 0.05, // Offset it so it doesn't overlap the below mesh.
105106
this.sphereSegments,
106107
this.sphereSegments,
107108
];
@@ -132,11 +133,20 @@ export class MarsMeshComponent {
132133
normalMap: './textures/mars_4k_normal.jpg',
133134
}));
134135

136+
/** Used at the commented code to check the differences. */
137+
protected meshMatParams: MeshStandardMaterialParameters = {
138+
color: 0xbd5417,
139+
wireframe: false,
140+
opacity: 1,
141+
transparent: false,
142+
}
143+
135144
/** */
136145
protected marsShaderParameters: ShaderMaterialParameters = {
137146
glslVersion: GLSL3,
138147
vertexShader: marsVertexShader,
139148
fragmentShader: marsFragmentShader,
149+
shadowSide: BackSide,
140150
side: DoubleSide,
141151
uniforms: {
142152
/**
@@ -172,7 +182,9 @@ export class MarsMeshComponent {
172182
*/
173183
private animate() {
174184
const sphereMeshEl = this.meshRef().nativeElement;
175-
sphereMeshEl.rotateY(0.0002);
185+
/** Uncomment to enable planet rotation on its axis. */
186+
// sphereMeshEl.rotateY(0.0004);
187+
sphereMeshEl.rotateY(0.00007) // True rate of rotation in radians per sec
176188
}
177189

178190
/**

0 commit comments

Comments
 (0)