Skip to content

Commit bd2f730

Browse files
committed
fixes
1 parent 5a72944 commit bd2f730

File tree

10 files changed

+98
-20
lines changed

10 files changed

+98
-20
lines changed

build/assets/world.glb

-4.05 KB
Binary file not shown.

src/ts/characters/Character.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ export class Character extends THREE.Object3D implements IWorldEntity
296296
this.world.cameraOperator.characterCaller = this;
297297
this.world.inputManager.setInputReceiver(this.world.cameraOperator);
298298
}
299+
else if (code === 'KeyR' && pressed === true && event.shiftKey === true)
300+
{
301+
this.world.restartScenario();
302+
}
299303
else
300304
{
301305
for (const action in this.actions) {
@@ -490,6 +494,10 @@ export class Character extends THREE.Object3D implements IWorldEntity
490494
keys: ['F'],
491495
desc: 'Enter vehicle'
492496
},
497+
{
498+
keys: ['Shift', '+', 'R'],
499+
desc: 'Respawn'
500+
},
493501
{
494502
keys: ['Shift', '+', 'C'],
495503
desc: 'Free camera'

src/ts/core/CameraOperator.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,25 @@ export class CameraOperator implements IInputReceiver
157157
this.target.copy(this.camera.position);
158158
this.setRadius(0, true);
159159
// this.world.dirLight.target = this.world.camera;
160+
161+
this.world.updateControls([
162+
{
163+
keys: ['W', 'S', 'A', 'D'],
164+
desc: 'Move around'
165+
},
166+
{
167+
keys: ['E', 'Q'],
168+
desc: 'Move up/down'
169+
},
170+
{
171+
keys: ['Shift'],
172+
desc: 'Speed up'
173+
},
174+
{
175+
keys: ['Shift', '+', 'C'],
176+
desc: 'Exit free camera mode'
177+
},
178+
]);
160179
}
161180

162181
public inputReceiverUpdate(timeStep: number): void

src/ts/core/World.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export class World
6565
public vehicles: Vehicle[] = [];
6666
public paths: Path[] = [];
6767

68+
private lastScenarioID: string;
69+
6870
constructor()
6971
{
7072
const scope = this;
@@ -104,7 +106,7 @@ export class World
104106

105107
// Three.js scene
106108
this.graphicsWorld = new THREE.Scene();
107-
this.camera = new THREE.PerspectiveCamera(80, window.innerWidth / window.innerHeight, 0.1, 610);
109+
this.camera = new THREE.PerspectiveCamera(80, window.innerWidth / window.innerHeight, 0.1, 1010);
108110
this.sky = new Sky(this);
109111
this.graphicsWorld.add(this.sky);
110112

@@ -472,6 +474,8 @@ export class World
472474

473475
public launchScenario(scenarioID: string): void
474476
{
477+
this.lastScenarioID = scenarioID;
478+
475479
this.clearEntities();
476480

477481
// Launch default scenario
@@ -482,6 +486,12 @@ export class World
482486
}
483487
}
484488

489+
public restartScenario(): void
490+
{
491+
if (this.lastScenarioID !== undefined) this.launchScenario(this.lastScenarioID);
492+
else console.warn('Can\'t restart scenario. Last scenarioID is undefined.');
493+
}
494+
485495
public clearEntities(): void
486496
{
487497
for (let i = 0; i < this.characters.length; i++) {

src/ts/data/Scenario.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export class Scenario
2929
if (root.userData.hasOwnProperty('default') && root.userData.default === 'true')
3030
{
3131
this.default = true;
32+
this.name += ' (default)';
3233
}
3334
if (root.userData.hasOwnProperty('spawn_always') && root.userData.spawn_always === 'true')
3435
{

src/ts/entities/Sky.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ export class Sky extends THREE.Object3D
4040
uniforms: THREE.UniformsUtils.clone(SkyShader.uniforms),
4141
fragmentShader: SkyShader.fragmentShader,
4242
vertexShader: SkyShader.vertexShader,
43-
side: THREE.BackSide,
43+
side: THREE.BackSide
4444
});
4545

4646
this.skyMesh = new THREE.Mesh(
47-
new THREE.SphereBufferGeometry(600, 32, 15),
47+
new THREE.SphereBufferGeometry(1000, 24, 12),
4848
this.skyMaterial
4949
);
5050
this.attach(this.skyMesh);

src/ts/vehicles/Airplane.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export class Airplane extends Vehicle implements IControllable, IWorldEntity
4343
this.collision.preStep = (body: CANNON.Body) => { this.physicsPreStep(body, this); };
4444

4545
this.actions = {
46-
'throttle': new KeyBinding('Space'),
47-
'brake': new KeyBinding('ShiftLeft'),
46+
'throttle': new KeyBinding('ShiftLeft'),
47+
'brake': new KeyBinding('Space'),
4848
'wheelBrake': new KeyBinding('KeyB'),
4949
'pitchUp': new KeyBinding('KeyS'),
5050
'pitchDown': new KeyBinding('KeyW'),
@@ -371,33 +371,45 @@ export class Airplane extends Vehicle implements IControllable, IWorldEntity
371371

372372
this.world.updateControls([
373373
{
374-
keys: ['W'],
375-
desc: 'Increase rotor RPM'
374+
keys: ['Shift'],
375+
desc: 'Speed up'
376376
},
377377
{
378-
keys: ['S'],
379-
desc: 'Decrease rotor RPM'
378+
keys: ['Space'],
379+
desc: 'Slow down'
380380
},
381381
{
382-
keys: ['', ''],
382+
keys: ['W', 'S'],
383383
desc: 'Elevators'
384384
},
385385
{
386-
keys: ['←', '→', 'or', 'A', 'D'],
386+
keys: ['A', 'D'],
387387
desc: 'Ailerons'
388388
},
389389
{
390390
keys: ['Q', 'E'],
391391
desc: 'Rudder / Steering'
392392
},
393393
{
394-
keys: ['Space'],
394+
keys: ['B'],
395395
desc: 'Brake'
396396
},
397+
{
398+
keys: ['V'],
399+
desc: 'View select'
400+
},
397401
{
398402
keys: ['F'],
399403
desc: 'Exit vehicle'
400404
},
405+
{
406+
keys: ['Shift', '+', 'R'],
407+
desc: 'Respawn'
408+
},
409+
{
410+
keys: ['Shift', '+', 'C'],
411+
desc: 'Free camera'
412+
},
401413
]);
402414
}
403415
}

src/ts/vehicles/Car.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,22 @@ export class Car extends Vehicle implements IControllable {
293293
keys: ['Space'],
294294
desc: 'Handbrake'
295295
},
296+
{
297+
keys: ['V'],
298+
desc: 'View select'
299+
},
296300
{
297301
keys: ['F'],
298302
desc: 'Exit vehicle'
299303
},
304+
{
305+
keys: ['Shift', '+', 'R'],
306+
desc: 'Respawn'
307+
},
308+
{
309+
keys: ['Shift', '+', 'C'],
310+
desc: 'Free camera'
311+
},
300312
]);
301313
}
302314

src/ts/vehicles/Helicopter.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export class Helicopter extends Vehicle implements IControllable, IWorldEntity
2222
this.collision.preStep = (body: CANNON.Body) => { this.physicsPreStep(body, this); };
2323

2424
this.actions = {
25-
'ascend': new KeyBinding('Space'),
26-
'descend': new KeyBinding('ShiftLeft'),
25+
'ascend': new KeyBinding('ShiftLeft'),
26+
'descend': new KeyBinding('Space'),
2727
'pitchUp': new KeyBinding('KeyS'),
2828
'pitchDown': new KeyBinding('KeyW'),
2929
'yawLeft': new KeyBinding('KeyQ'),
@@ -216,29 +216,41 @@ export class Helicopter extends Vehicle implements IControllable, IWorldEntity
216216

217217
this.world.updateControls([
218218
{
219-
keys: ['W'],
219+
keys: ['Shift'],
220220
desc: 'Ascend'
221221
},
222222
{
223-
keys: ['S'],
223+
keys: ['Space'],
224224
desc: 'Descend'
225225
},
226226
{
227-
keys: ['', ''],
227+
keys: ['W', 'S'],
228228
desc: 'Pitch'
229229
},
230230
{
231-
keys: ['←', '→', 'or', 'A', 'D'],
231+
keys: ['Q', 'E'],
232+
desc: 'Yaw'
233+
},
234+
{
235+
keys: ['A', 'D'],
232236
desc: 'Roll'
233237
},
234238
{
235-
keys: ['Q', 'E'],
236-
desc: 'Yaw'
239+
keys: ['V'],
240+
desc: 'View select'
237241
},
238242
{
239243
keys: ['F'],
240244
desc: 'Exit vehicle'
241245
},
246+
{
247+
keys: ['Shift', '+', 'R'],
248+
desc: 'Respawn'
249+
},
250+
{
251+
keys: ['Shift', '+', 'C'],
252+
desc: 'Free camera'
253+
},
242254
]);
243255
}
244256
}

src/ts/vehicles/Vehicle.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ export abstract class Vehicle extends THREE.Object3D
156156
this.world.cameraOperator.characterCaller = this.controllingCharacter;
157157
this.world.inputManager.setInputReceiver(this.world.cameraOperator);
158158
}
159+
else if (code === 'KeyR' && pressed === true && event.shiftKey === true)
160+
{
161+
this.world.restartScenario();
162+
}
159163
else
160164
{
161165
for (const action in this.actions) {

0 commit comments

Comments
 (0)