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
Copy Markdown
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
63 changes: 30 additions & 33 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,9 @@ export default class Director {

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

return this;
return this;
}

// Load the objects in world instance to the current scene.
Expand All @@ -246,70 +246,67 @@ export default class Director {
}

async loadInstance() {
console.log(this.world);
await this.world.entities.forEach(async entity => {

await this.world.config.objects.forEach( async object_config => {
if ( object_config.model == 'extractor' ) {
if ( entity.config.components.Renderable.object == 'extractor' ) {
l.scenograph.director.loadObject(
object_config,
entity,
await l.scenograph.objects.structures.extractor.get()
);
}
if ( object_config.model == 'platform' ) {
if ( entity.config.components.Renderable.object == 'platform' ) {
l.scenograph.director.loadObject(
object_config,
entity,
await l.scenograph.objects.structures.platform.get()
);
}
if ( object_config.model == 'refinery' ) {
if ( entity.config.components.Renderable.object == 'refinery' ) {
l.scenograph.director.loadObject(
object_config,
entity,
await l.scenograph.objects.structures.refinery.get()
);
}
} );

this.world.config.actors.forEach( async object_config => {
if ( object_config.class == 'cargoShip' ) {
if ( entity.config.components.Renderable.object == 'cargoShip' ) {
l.scenograph.director.loadObject(
object_config,
entity,
await l.scenograph.objects.vehicles.cargoShip.get()
);
}
if ( object_config.class == 'pirate' ) {
if ( entity.config.components.Renderable.object == 'pirate' ) {
l.scenograph.director.loadObject(
object_config,
entity,
await l.scenograph.objects.vehicles.raven.get()
);
}

} );

this.world.instance.actors.forEach(async actorInstance => {
if ( actorInstance.config.class == 'player' ) {
await l.scenograph.actors.registerActor( actorInstance );
if ( entity.config.components.Renderable.object == 'valiant' || entity.config.components.Renderable.object == 'person' ) {
await l.scenograph.actors.registerActor( entity );
}
});

}

async loadObject( config, object ) {
object.position.x = config.position.x;
object.position.y = config.position.y;
object.position.z = config.position.z;
async loadObject(entity, scenographObject) {
console.log(entity, scenographObject);
scenographObject.position.x = entity.components.Transform.position.x;
scenographObject.position.y = entity.components.Transform.position.y;
scenographObject.position.z = entity.components.Transform.position.z;

if ( config.rotation ) {
object.rotation.x = config.rotation.x;
object.rotation.y = config.rotation.y;
object.rotation.z = config.rotation.z;
if ( entity.rotation ) {
scenographObject.rotation.x = entity.components.Transform.rotation.x;
scenographObject.rotation.y = entity.components.Transform.rotation.y;
scenographObject.rotation.z = entity.components.Transform.rotation.z;
}

object.name = config.name;
object.userData.config = config;
scenographObject.name = entity.components.Name;
scenographObject.userData.entity = entity;

// @todo: add to current_scene array relevant to object class.
// @todo: add to current_scene array relevant to scenographObject class.

l.current_scene.scene.add(
object
scenographObject
);
}

Expand Down
27 changes: 15 additions & 12 deletions client/src/app/scenograph/objects/vehicles/cargo_ship.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class CargoShip {

/**
* Paths
*
*
* @todo: Refactor into a common path setting and updating class.
*/
getPath() {
Expand All @@ -62,7 +62,7 @@ export default class CargoShip {
}

async getAll() {

let path = this.getPath();

const path_points = [];
Expand Down Expand Up @@ -90,10 +90,10 @@ export default class CargoShip {
await this.load();

this.locations.forEach( async ( location, i ) => {

let mesh = this.mesh.clone();
mesh.userData.path = this.getPath();

// Bump each starting point for the cargo ships
for ( let j = 0; j < i; j++) {
mesh.userData.path.advance();
Expand Down Expand Up @@ -121,15 +121,18 @@ export default class CargoShip {
mesh.userData.path = this.getPath();

let i = this.instances.length;

// Bump each starting point for the cargo ships
for ( let j = 0; j < i; j++) {
mesh.userData.path.advance();
}

mesh.position.copy( mesh.userData.path.current() );
mesh.name = 'Cargo Ship #' + ( i + 1 );

console.log(mesh.name, mesh.position, mesh.userData);
mesh.position.copy( mesh.userData.path.current() );


mesh.userData.objectClass = 'cargoShip';
mesh.userData.targetable = true;
mesh.userData.size = this.size;
Expand All @@ -139,7 +142,7 @@ export default class CargoShip {

mesh.matrixAutoUpdate = false;

this.instances.push( mesh );
this.instances.push(mesh);

return mesh;
}
Expand Down Expand Up @@ -202,10 +205,10 @@ export default class CargoShip {

/**
* Animate hook.
*
*
* This method is called within the main animation loop and
* therefore must only reference global objects or properties.
*
*
* @method animate
* @memberof CargoShips
* @global
Expand All @@ -217,10 +220,10 @@ export default class CargoShip {
l.scenograph.objects.vehicles.cargoShip.instances.forEach( ( cargo_ship ) => {

cargo_ship.userData.actor.animate( delta );

} );
}

}

}
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 {
}
}


}
Loading