Skip to content

Commit

Permalink
Merge pull request #45 from BarthPaleologue/PatchCurrentRelease
Browse files Browse the repository at this point in the history
1.7.1 - Better spaceship
  • Loading branch information
BarthPaleologue committed Feb 26, 2024
2 parents 19e48c5 + d15d9d0 commit 9a79d88
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches: [ "main" ]
jobs:
build:
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:

jobs:
check-version:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ concurrency:
cancel-in-progress: false

jobs:
# Build job
build:
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
jobs:
eslint:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
node-version: [16, 18]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tauri-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
publish-tauri:
permissions:
contents: write
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
jobs:
jest:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
node-version: [16, 18]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
},
"version": "1.7.0",
"version": "1.7.1",
"description": "CosmosJourneyer",
"name": "cosmos-journeyer",
"scripts": {
Expand Down
Binary file modified src/asset/spaceship/wanderer.glb
Binary file not shown.
2 changes: 1 addition & 1 deletion src/html/mainMenu.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h3>Bug reports</h3>

<h3>Know how to code?</h3>

<p>CosmosJourneyer is an open-source project which means anyone can help built it! Why not you?<br /> You can
<p>CosmosJourneyer is an open-source project which means anyone can help build it! Why not you?<br /> You can
check out
<a target="_blank"
href="https://github.com/BarthPaleologue/CosmosJourneyer">the repository of the project</a> for more details.
Expand Down
2 changes: 1 addition & 1 deletion src/shaders/starfieldFragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void main() {
vec4 starfieldColor = texture2D(starfieldTexture, starfieldUV);
starfieldColor.rgb = pow(starfieldColor.rgb, vec3(2.2));// deeper blacks

if (depth == 1.0) {
if (screenColor == vec4(0.0) && depth == 1.0) {
finalColor = vec4(starfieldColor.rgb * visibility, starfieldColor.a);
}

Expand Down
2 changes: 1 addition & 1 deletion src/shaders/utils/worldFromUV.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ vec3 worldFromUV(vec2 pos, mat4 inverseProjection, mat4 inverseView) {
vec4 ndc = vec4(pos.xy * 2.0 - 1.0, 1.0, 1.0); // get ndc position (z = 1 because the depth buffer is reversed)
vec4 posVS = inverseProjection * ndc; // unproject the ndc coordinates : we are now in view space if i understand correctly
vec4 posWS = inverseView * posVS; // then we use inverse view to get to world space, division by w to get actual coordinates
return posWS.xyz; // the coordinates in world space
return posWS.xyz / posWS.w;
}
2 changes: 1 addition & 1 deletion src/ts/orbit/axisRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class AxisRenderer {
setVisibility(visible: boolean) {
this._isVisible = visible;
for (const axisMesh of this.axisMeshes) {
axisMesh.visibility = visible ? 1 : 0;
axisMesh.setEnabled(visible);
}
}

Expand Down
19 changes: 11 additions & 8 deletions src/ts/orbit/orbitRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class OrbitRenderer {

private orbitMaterial: StandardMaterial | null = null;

private isVisibile = false;
private _isVisible = false;

setOrbitalObjects(orbitalObjects: OrbitalObject[]) {
this.reset();
Expand All @@ -39,7 +39,7 @@ export class OrbitRenderer {
this.createOrbitMesh(orbitalObject);
}

this.setVisibility(this.isVisibile);
this.setVisibility(this.isVisible());
}

private createOrbitMesh(orbitalObject: OrbitalObject) {
Expand All @@ -61,17 +61,18 @@ export class OrbitRenderer {
}

setVisibility(visible: boolean) {
this.isVisibile = visible;
this._isVisible = visible;
for (const orbitMesh of this.orbitMeshes) {
orbitMesh.visibility = visible ? 1 : 0;
orbitMesh.setEnabled(visible);
}
}

isVisible(): boolean {
return this.isVisibile;
return this._isVisible;
}

update() {
if(!this._isVisible) return;
for (let i = 0; i < this.orbitalObjects.length; i++) {
const orbitalObject = this.orbitalObjects[i];
const orbitMesh = this.orbitMeshes[i];
Expand All @@ -89,8 +90,10 @@ export class OrbitRenderer {
this.orbitMeshes = [];
this.orbitalObjects = [];

this.orbitMaterial = new StandardMaterial("orbitMaterial");
this.orbitMaterial.emissiveColor = Color3.White();
this.orbitMaterial.disableLighting = true;
if(this.orbitMaterial === null) {
this.orbitMaterial = new StandardMaterial("orbitMaterial");
this.orbitMaterial.emissiveColor = Color3.White();
this.orbitMaterial.disableLighting = true;
}
}
}
3 changes: 0 additions & 3 deletions src/ts/spaceship/abstractThruster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@ export abstract class AbstractThruster {

protected throttle = 0;

readonly localNozzleDown: Vector3;

readonly plume: SolidPlume;

readonly parentAggregate: PhysicsAggregate;

protected constructor(mesh: AbstractMesh, direction: Vector3, parentAggregate: PhysicsAggregate) {
this.mesh = mesh;

this.localNozzleDown = direction;
this.plume = new SolidPlume(mesh, mesh.getScene());

this.parentAggregate = parentAggregate;
Expand Down
17 changes: 11 additions & 6 deletions src/ts/spaceship/shipControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class ShipControls implements Controls {

this.firstPersonCamera = new FreeCamera("firstPersonCamera", Vector3.Zero(), scene);
this.firstPersonCamera.parent = this.getTransform();
this.firstPersonCamera.position = new Vector3(0, 1.2, 3.5);

this.firstPersonCamera.position = new Vector3(0, 1.2, 4);
this.thirdPersonCamera = new ArcRotateCamera("thirdPersonCamera", -3.14 / 2, 3.14 / 2.2, ShipControls.BASE_CAMERA_RADIUS, Vector3.Zero(), scene);
this.thirdPersonCamera.parent = this.getTransform();
this.thirdPersonCamera.lowerRadiusLimit = 10;
Expand Down Expand Up @@ -117,10 +117,15 @@ export class ShipControls implements Controls {
if (this.spaceship.getWarpDrive().isDisabled()) {
this.spaceship.increaseMainEngineThrottle(deltaTime * SpaceShipControlsInputs.map.throttle.value);

this.spaceship.aggregate.body.applyForce(
getUpwardDirection(this.getTransform()).scale(9.8 * 10 * SpaceShipControlsInputs.map.upDown.value),
this.spaceship.aggregate.body.getObjectCenterWorld()
);
if(SpaceShipControlsInputs.map.upDown.value !== 0) {
if(this.spaceship.isLanded()) {
this.spaceship.takeOff();
}
this.spaceship.aggregate.body.applyForce(
getUpwardDirection(this.getTransform()).scale(9.8 * 10 * SpaceShipControlsInputs.map.upDown.value),
this.spaceship.aggregate.body.getObjectCenterWorld()
);
}
} else {
this.spaceship.getWarpDrive().increaseTargetThrottle(deltaTime * SpaceShipControlsInputs.map.throttle.value);
}
Expand Down
8 changes: 5 additions & 3 deletions src/ts/spaceship/spaceship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ export class Spaceship implements Transformable {
return this.state === ShipState.LANDED;
}

public takeOff() {
this.state = ShipState.FLYING;
this.aggregate.body.setMotionType(PhysicsMotionType.DYNAMIC);
}

private land(deltaTime: number) {
if (this.targetLandingPad !== null) {
this.landOnPad(this.targetLandingPad, deltaTime);
Expand Down Expand Up @@ -357,9 +362,6 @@ export class Spaceship implements Transformable {
});
} else {
this.aggregate.body.applyForce(forwardDirection.scale(-3000), this.aggregate.body.getObjectCenterWorld());
this.mainThrusters.forEach(thruster => {
thruster.setThrottle(0);
});
}

// damp other speed
Expand Down
2 changes: 1 addition & 1 deletion src/ts/utils/solidPlume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TransformNode } from "@babylonjs/core/Meshes";

export class SolidPlume {
static TUNNEL_LENGTH = 3;
static MAX_NB_PARTICLES = 3000;
static MAX_NB_PARTICLES = 2000;

targetNbParticles = 0;
nbParticles = 0;
Expand Down

0 comments on commit 9a79d88

Please sign in to comment.