A fighter flight control system based on babylonjs+ammojs is implemented, and the flight control part is all implemented based on the ammojs physics engine:
npm install
npm start
npm run build
//Enable babylonjs physics using ammojs
this.scene.enablePhysics(new BABYLON.Vector3(0, -10, 0), new AmmoJSPlugin(true, Ammo));
//Load f18 model
let f18FighterAssets = new F18Assets(this._engine, this.scene)
await f18FighterAssets.init()
this.flyMesh = f18FighterAssets;;
//create airport
this.airportScene = new AirportScene(this.scene, this._engine)
await this.airportScene.init()
//create fighter
this.fly = new F18Physics(this._canvas, this._engine, this.scene, this.flyMesh)
this.fly.init(
position,
quaternion,
)
// camera controller
F18CameraController.ins.init(this._canvas, this.scene, this._engine)
//input controller
F18InputController.ins.init(this.scene)
// handle controller
F18GamepadController.ins.init(this.scene)
//Current view target aircraft
F18CameraController.ins.tergetVehicle(this.fly)
//Currently control the target aircraft
F18InputController.ins.tergetVehicle(this.fly)
// delete the plane
this.fly.dispose()
// make the plane explode
this.fly.explode()
fly
├─src
| ├─.DS_Store
| ├─ammo.d.ts (ammo ts prompt file)
| ├─game.ts (game entry file)
| ├─index.ejs (html template)
| ├─index.ts (project entry file)
| ├─vehicleObject (vehicle folder)
| | ├─f18 (f18 fighter related method collection)
| | | ├─f18Animation.ts (animation control implementation)
| | | ├─f18Assets.ts (resource loading strategy implementation)
| | | ├─f18CameraController.ts (camera controller)
| | | ├─f18Explode.ts (physical explosion related implementation)
| | | ├─f18GamePadController.ts(handle controller)
| | | ├─f18Global.ts (global variable)
| | | ├─f18HUD.ts (HUD head-up display implementation)
| | | ├─f18InputController.ts(input controller)
| | | ├─f18LODManager.ts(LOD Manager)
| | | ├─f18Physics.ts (implementation of aircraft physics body)
| | | └f18Sound.ts (3D stereo sound implementation)
| ├─physicsScene
| | └airportScene.ts (airport implementation)
| ├─interface
| | └fly.ts (flight control interface)
| ├─base
| | ├─config.ts (global configuration)
| | └funt.ts
| ├─assets (resource folder)
| | ├─video
| | ├─texture
| | ├─sound
| | ├─mesh
| | ├─image
| | ├─gui
├─map (map blender source file)
├─f18(F18 blender binding bone source file)
├─dist (packaging folder)