Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions client/src/app/routes/hangar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ export default class hangarRoute {

loadHangar() {
l.current_scene.scene.add(l.scenograph.objects.structures.hangar.mesh);
//this.targetStructure.visible = false;

l.scenograph.objects.structures.hangar.mesh.visible = true;
console.log(this.targetStructure.userData.config.hangars[0].position);

l.scenograph.objects.structures.hangar.mesh.position.x = this.targetStructure.userData.config.hangars[0].position.x;
l.scenograph.objects.structures.hangar.mesh.position.y = this.targetStructure.userData.config.hangars[0].position.y;
l.scenograph.objects.structures.hangar.mesh.position.z = this.targetStructure.userData.config.hangars[0].position.z;

l.scenograph.actors.player.vehicle.mesh.userData.object.position.x = this.targetStructure.userData.config.hangars[0].position.x;
l.scenograph.actors.player.vehicle.mesh.userData.object.position.z = - 2.5 + this.targetStructure.userData.config.hangars[0].position.z;
l.scenograph.actors.player.vehicle.mesh.userData.object.position.y = l.scenograph.objects.structures.hangar.mesh.position.y - 7.5;
l.scenograph.actors.player.vehicle.game.object.position.x = this.targetStructure.userData.config.hangars[0].position.x;
l.scenograph.actors.player.vehicle.game.object.position.z = - 2.5 + this.targetStructure.userData.config.hangars[0].position.z;
l.scenograph.actors.player.vehicle.game.object.position.y = l.scenograph.objects.structures.hangar.mesh.position.y - 7.5;

l.scenograph.actors.player.actorInstance.object.position.x = this.targetStructure.userData.config.hangars[0].position.x;
l.scenograph.actors.player.actorInstance.object.position.z = 10 + this.targetStructure.userData.config.hangars[0].position.z;
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/routes/singleplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export default class singlePlayerRoute {
// Set client mode.
l.mode = 'single_player';

l.scenograph.actors.map.get('Player One').setMode('vehicle');
l.scenograph.actors.player = l.scenograph.actors.get('Player One');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be set in menu logic

l.scenograph.actors.player.setMode('vehicle');

}

Expand Down
2 changes: 1 addition & 1 deletion client/src/app/scenograph/actors/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class Player {
async load() {

// Setup aircraft, used for the intro sequence.
this.vehicle = new l.scenograph.objects.vehicles.valiant();
this.vehicle = new l.scenograph.objects.vehicles.valiant(this.actorInstance);
await this.vehicle.load();
l.current_scene.scene.add(
this.vehicle.mesh
Expand Down
9 changes: 6 additions & 3 deletions client/src/app/scenograph/director.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import l from '@/helpers/l.js';
/**
* World Simulation
*/
import World from '#/game/src/world';
import World from '#/game/ecs/world';

/**
* Scene controllers
Expand Down Expand Up @@ -231,9 +231,12 @@ export default class Director {

// Load world instance from game classes.
load( sceneName ) {
this.world = new World( sceneName );
this.world = new World(sceneName);

return this;
console.log(this.world);
debugger;

return this;
}

// Load the objects in world instance to the current scene.
Expand Down
1 change: 0 additions & 1 deletion client/src/app/scenograph/objects/vehicles/person.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,4 @@ export default class Person {
}
}


}
10 changes: 5 additions & 5 deletions client/src/app/scenograph/objects/vehicles/raven.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Enemy bot.
*
*
* Currently hardcoded to use the Raven aircraft.
*/
import * as THREE from 'three';
Expand All @@ -11,7 +11,7 @@ import * as THREE from 'three';
import l from '@/helpers/l.js';
import { brightenMaterial, proceduralMetalMaterial } from '@/scenograph/materials.js';
import PirateActor from '#/game/src/actors/pirate';
import RavenObject from '#/game/src/objects/aircraft/raven';
import RavenObject from '#/game/src/objects/vehicles/raven';

export default class Raven {

Expand Down Expand Up @@ -140,10 +140,10 @@ export default class Raven {

/**
* Animate hook.
*
*
* This method is called within the main animation loop and
* therefore must only reference global objects or properties.
*
*
* @method animate
* @memberof Raven
* @global
Expand All @@ -158,5 +158,5 @@ export default class Raven {
}
}


}
138 changes: 70 additions & 68 deletions client/src/app/scenograph/objects/vehicles/valiant.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import * as THREE from 'three';
import l from '@/helpers/l.js';
import { brightenMaterial, proceduralMetalMaterial } from '@/scenograph/materials.js';
import Player from '#/game/src/actors/player';
import ValiantObject from '#/game/src/objects/aircraft/valiant';

export default class Valiant {

Expand Down Expand Up @@ -45,13 +44,17 @@ export default class Valiant {
// TrailRenderer effect showing a trailing effect on the thruster.
trail;

constructor() {
constructor(actorInstance) {
// Set internal game accessor to the game world actor instance.
this.game = actorInstance;

this.default_camera_distance = -35;
this.trail_position_y = 1.2;
this.trail_position_z = 1.5;
this.camera_distance = 0;

this.ready = false;
console.log(this);

}

Expand Down Expand Up @@ -122,7 +125,6 @@ export default class Valiant {

this.trail = l.current_scene.effects.trail.createTrail( this.mesh, 0, this.trail_position_y, this.trail_position_z );

this.mesh.userData.object = new ValiantObject( this.mesh );
}

createThrusterMesh( options ) {
Expand Down Expand Up @@ -309,9 +311,9 @@ export default class Valiant {
// Set the ship as ready.
l.current_scene.objects.demoShip.ready = true;
l.current_scene.objects.demoShip.camera_distance = l.current_scene.objects.demoShip.default_camera_distance + ( l.current_scene.room_depth / 2 );
l.current_scene.objects.demoShip.mesh.userData.object.position.x = l.current_scene.objects.demoShip.mesh.position.x;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to do something about the demo ship, it probably needs to be split off with its own NPC AI so that it can fly around in "demo" mode while the player is in menu.

l.current_scene.objects.demoShip.mesh.userData.object.position.y = l.current_scene.objects.demoShip.mesh.position.y;
l.current_scene.objects.demoShip.mesh.userData.object.position.z = l.current_scene.objects.demoShip.mesh.position.z;
// l.current_scene.objects.demoShip.mesh.userData.object.position.x = l.current_scene.objects.demoShip.mesh.position.x;
// l.current_scene.objects.demoShip.mesh.userData.object.position.y = l.current_scene.objects.demoShip.mesh.position.y;
// l.current_scene.objects.demoShip.mesh.userData.object.position.z = l.current_scene.objects.demoShip.mesh.position.z;
} );
}

Expand All @@ -328,12 +330,12 @@ export default class Valiant {
let changing = false;
for ( const [ controlName, keyMapping ] of Object.entries( mappings ) ) {
if ( l.scenograph.controls.keyboard.pressed( keyMapping ) ) {
this.mesh.userData.object.controls[ controlName ] = true;
this.game.actor.controls[ controlName ] = true;
changing = true;
}
else {

this.mesh.userData.object.controls[ controlName ] = false;
this.game.actor.controls[ controlName ] = false;

if ( l.scenograph.controls.touch ) {
// Check if any touchpad controls are being pressed
Expand All @@ -347,29 +349,29 @@ export default class Valiant {
) {
changing = true;
if ( l.scenograph.controls.touch.controls.moveUp ) {
this.mesh.userData.object.controls.moveUp = true;
this.game.actor.controls.moveUp = true;
}
if ( l.scenograph.controls.touch.controls.moveDown ) {
this.mesh.userData.object.controls.moveDown = true;
this.game.actor.controls.moveDown = true;
}
if ( l.scenograph.controls.touch.controls.moveForward ) {
this.mesh.userData.object.controls.throttleUp = true;
this.game.actor.controls.throttleUp = true;
}
if ( l.scenograph.controls.touch.controls.moveBackward ) {
this.mesh.userData.object.controls.throttleDown = true;
this.game.actor.controls.throttleDown = true;
}
if ( l.scenograph.controls.touch.controls.moveLeft ) {
this.mesh.userData.object.controls.moveLeft = true;
this.game.actor.controls.moveLeft = true;
}
if ( l.scenograph.controls.touch.controls.moveRight ) {
this.mesh.userData.object.controls.moveRight = true;
this.game.actor.controls.moveRight = true;
}
}

}
}
}
this.mesh.userData.object.controls.changing = changing;
this.game.actor.controls.changing = changing;

}

Expand All @@ -378,52 +380,54 @@ export default class Valiant {
this.mixer.update( delta );
}

// Rock the ship forward and back when moving horizontally
if ( this.mesh.userData.object.controls.throttleDown || this.mesh.userData.object.controls.throttleUp ) {
let pitchChange = this.mesh.userData.object.controls.throttleUp ? -1 : 1;
if ( Math.abs( this.mesh.rotation.x ) < 1 / 4 ) {
this.mesh.rotation.x += pitchChange / 10 / 180;
if ( this.game ) {
// Rock the ship forward and back when moving horizontally
if ( this.game.actor.controls.throttleDown || this.game.actor.controls.throttleUp ) {
let pitchChange = this.game.actor.controls.throttleUp ? -1 : 1;
if ( Math.abs( this.mesh.rotation.x ) < 1 / 4 ) {
this.mesh.rotation.x += pitchChange / 10 / 180;
}
}
}

// Rock the ship forward and back when moving vertically
if (
this.mesh.userData.object.controls.moveDown
||
this.mesh.userData.object.controls.moveUp
) {
let elevationChange = this.mesh.userData.object.controls.moveDown ? -1 : 1;
if ( Math.abs( this.mesh.rotation.x ) < 1 / 8 ) {
this.mesh.rotation.x += elevationChange / 10 / 180;
}
// Rock the ship forward and back when moving vertically
if (
this.game.actor.controls.moveDown
||
this.game.actor.controls.moveUp
) {
let elevationChange = this.game.actor.controls.moveDown ? -1 : 1;
if ( Math.abs( this.mesh.rotation.x ) < 1 / 8 ) {
this.mesh.rotation.x += elevationChange / 10 / 180;
}

if ( Math.abs( l.scenograph.cameras.player.rotation.x ) < 1 / 8 ) {
let radian = ( Math.PI / 180 );
l.scenograph.cameras.player.rotation.x += elevationChange * radian / 10;
if ( Math.abs( l.scenograph.cameras.player.rotation.x ) < 1 / 8 ) {
let radian = ( Math.PI / 180 );
l.scenograph.cameras.player.rotation.x += elevationChange * radian / 10;
}
}
else {
if ( l.scenograph.controls.touch && !l.scenograph.controls.touch.controls.rotationPad.mouseDown )
l.scenograph.cameras.player.rotation.x *= .9;
}
}
else {
if ( l.scenograph.controls.touch && !l.scenograph.controls.touch.controls.rotationPad.mouseDown )
l.scenograph.cameras.player.rotation.x *= .9;
}
}

// Update the position of the aircraft to spot determined by game logic.
updateMesh() {
this.mesh.position.x = this.mesh.userData.object.position.x;
this.mesh.position.y = this.mesh.userData.object.position.y;
this.mesh.position.z = this.mesh.userData.object.position.z;
this.mesh.rotation.x = this.mesh.userData.object.rotation.x;
this.mesh.rotation.y = this.mesh.userData.object.rotation.y;
this.mesh.rotation.z = this.mesh.userData.object.rotation.z;
sync() {
this.mesh.position.x = this.game.object.position.x;
this.mesh.position.y = this.game.object.position.y;
this.mesh.position.z = this.game.object.position.z;
this.mesh.rotation.x = this.game.object.rotation.x;
this.mesh.rotation.y = this.game.object.rotation.y;
this.mesh.rotation.z = this.game.object.rotation.z;
}

updateCamera( rY, tY, tZ ) {
var radian = ( Math.PI / 180 );

this.camera_distance = this.default_camera_distance + ( l.current_scene.room_depth / 2 );
if ( this.mesh.userData.object.airSpeed < 0 ) {
this.camera_distance -= this.mesh.userData.object.airSpeed * 4;
if ( this.game.object.airSpeed < 0 ) {
this.camera_distance -= this.game.object.airSpeed * 4;
}

let xDiff = this.mesh.position.x;
Expand All @@ -432,8 +436,7 @@ export default class Valiant {
l.scenograph.cameras.player.position.x = xDiff + this.camera_distance * Math.sin( this.mesh.rotation.y );
l.scenograph.cameras.player.position.z = zDiff + this.camera_distance * Math.cos( this.mesh.rotation.y );

if ( rY != 0 ) {

if ( rY != 0 && Math.abs(l.scenograph.cameras.player.rotation.y) < .3925 ) {
l.scenograph.cameras.player.rotation.y += rY;
}
else {
Expand Down Expand Up @@ -488,15 +491,15 @@ export default class Valiant {

if ( l.current_scene.objects.demoShip.ready ) {

if ( l.current_scene.settings.game_controls ) {
if ( l.current_scene.settings.game_controls && this.game ) {

if ( l.scenograph.actors.player.mode == 'vehicle' ) {
// Detect keyboard input and pass it to the ship state model.
this.updateControls();
}

if ( l.scenograph.modes.multiplayer.connected ) {
l.scenograph.modes.multiplayer.socket.emit( 'input', this.mesh.userData.object.controls );
l.scenograph.modes.multiplayer.socket.emit( 'input', this.game.actor.controls );
}

this.mesh.userData.actor.animate( delta );
Expand All @@ -506,13 +509,12 @@ export default class Valiant {
if ( l.mode != 'hangar')
this.updateAnimation( delta );

// Update the ships state model.
let [ rY, tY, tZ ] = this.mesh.userData.object.move( l.current_scene.stats.currentTime - l.current_scene.stats.lastTime );
this.updateMesh();

this.updateCamera( rY, tY, tZ );
if (this.game) {
this.sync();
this.updateCamera( this.game.object.rY, this.game.object.tY, this.game.object.tZ );

this.animateTrail( rY );
this.animateTrail( this.game.object.rY );
}

}
}
Expand All @@ -524,21 +526,21 @@ export default class Valiant {
let trailOffset = 0;

// Only offset the trail effect if we are going forward which is (z-1) in numerical terms
if ( this.mesh.userData.object.airSpeed < 0 ) {
if ( this.game.object.airSpeed < 0 ) {

// Update ship thruster
this.animateThruster( this.mesh.userData.object.airSpeed, this.thruster.centralConeBurner, .5 );
this.animateThruster( this.mesh.userData.object.airSpeed, this.thruster.outerCylBurner, .5 );
this.animateThruster( this.game.object.airSpeed, this.thruster.centralConeBurner, .5 );
this.animateThruster( this.game.object.airSpeed, this.thruster.outerCylBurner, .5 );

this.spinThruster( this.mesh.userData.object.airSpeed, this.thruster.rearConeBurner, -1 );
this.spinThruster( this.mesh.userData.object.airSpeed, this.thruster.centralConeBurner, 1 );
this.spinThruster( this.mesh.userData.object.airSpeed, this.thruster.outerCylBurner, -1 );
this.spinThruster( this.mesh.userData.object.airSpeed, this.thruster.innerCylBurner, 1 );
this.spinThruster( this.game.object.airSpeed, this.thruster.rearConeBurner, -1 );
this.spinThruster( this.game.object.airSpeed, this.thruster.centralConeBurner, 1 );
this.spinThruster( this.game.object.airSpeed, this.thruster.outerCylBurner, -1 );
this.spinThruster( this.game.object.airSpeed, this.thruster.innerCylBurner, 1 );

// Limit playback rate to 5x as large values freak out the browser.
this.thruster.videoElement.playbackRate = Math.min( 5, 0.25 + Math.abs( this.mesh.userData.object.airSpeed ) );
this.thruster.videoElement.playbackRate = Math.min( 5, 0.25 + Math.abs( this.game.object.airSpeed ) );

trailOffset += this.trail_position_z - Math.abs( this.mesh.userData.object.airSpeed );
trailOffset += this.trail_position_z - Math.abs( this.game.object.airSpeed );

this.trail.mesh.material.uniforms.headColor.value.set( 255 / 255, 212 / 255, 148 / 255, .8 ); // RGBA.
}
Expand All @@ -547,11 +549,11 @@ export default class Valiant {
}

// Update the trail position based on above calculations.
this.trail.targetObject.position.y = this.trail_position_y + this.mesh.userData.object.verticalSpeed;
this.trail.targetObject.position.y = this.trail_position_y + this.game.object.verticalSpeed;
this.trail.targetObject.position.z = trailOffset;

if ( rY != 0 ) {
this.trail.targetObject.position.x = rY * this.mesh.userData.object.airSpeed;
this.trail.targetObject.position.x = rY * this.game.object.airSpeed;
this.trail.targetObject.position.y += Math.abs( this.trail.targetObject.position.x ) / 4;
}
else {
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/scenograph/overlays/heads-up-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ export default class HeadsUpDisplay {
l.scenograph.overlays.hud.container.classList.remove('portrait');
}

let aspd = -l.scenograph.overlays.hud.frameToSecond(l.scenograph.actors.player.vehicle.mesh.userData.object.airSpeed);
let aspd = -l.scenograph.overlays.hud.frameToSecond(l.scenograph.actors.player.vehicle.game.object.airSpeed);
l.scenograph.overlays.hud.aspdElement.innerHTML = `AIRSPEED: ${aspd}km/h`;

let vspd = l.scenograph.overlays.hud.frameToSecond(l.scenograph.actors.player.vehicle.mesh.userData.object.verticalSpeed);
let vspd = l.scenograph.overlays.hud.frameToSecond(l.scenograph.actors.player.vehicle.game.object.verticalSpeed);
l.scenograph.overlays.hud.vspdElement.innerHTML = `VERT. SPD: ${vspd}km/h`;

let heading = THREE.MathUtils.radToDeg( l.scenograph.actors.player.vehicle.mesh.rotation.y );
Expand Down
Loading