flight sim: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Basic Flight Sim</title>
<style>
body { margin: 0; overflow: hidden; }
canvas { display: block; }
</style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/three@0.152.2/build/three.min.js"></script>
<script>
// Scene Setup
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x87ceeb); // sky blue
const camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Ground
const groundGeometry = new THREE.PlaneGeometry(1000, 1000);
const groundMaterial = new THREE.MeshPhongMaterial({color: 0x228B22}); // green ground
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
ground.rotation.x = - Math.PI / 2;
scene.add(ground);
// Light
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
directionalLight.position.set(100, 100, 100);
scene.add(directionalLight);
// Plane (simple box shape)
const planeGeometry = new THREE.BoxGeometry(2, 0.5, 6);
const planeMaterial = new THREE.MeshPhongMaterial({color: 0xff0000});
const plane = new THREE.Mesh(planeGeometry, planeMaterial);
scene.add(plane);
plane.position.y = 5;
// Controls state
let pitch = 0; // rotation around X
let yaw = 0; // rotation around Y
let roll = 0; // rotation around Z
let speed = 0.5; // forward speed
const keys = {
ArrowUp: false,
ArrowDown: false,
ArrowLeft: false,
ArrowRight: false,
KeyA: false,
KeyD: false
};
// Keyboard listeners
window.addEventListener('keydown', e => {
if(keys.hasOwnProperty(e.code)) {
keys[e.code] = true;
}
});
window.addEventListener('keyup', e => {
if(keys.hasOwnProperty(e.code)) {
keys[e.code] = false;
}
});
function animate() {
requestAnimationFrame(animate);
// Update rotation based on input
if(keys.ArrowUp) pitch -= 0.005;
if(keys.ArrowDown) pitch += 0.005;
if(keys.ArrowLeft) roll += 0.005;
if(keys.ArrowRight) roll -= 0.005;
if(keys.KeyA) yaw += 0.005;
if(keys.KeyD) yaw -= 0.005;
// Apply rotation to plane
plane.rotation.set(pitch, yaw, roll);
// Move plane forward based on its orientation
const forward = new THREE.Vector3(0, 0, -1);
forward.applyEuler(plane.rotation);
forward.multiplyScalar(speed);
plane.position.add(forward);
// Camera follows the plane
const cameraOffset = new THREE.Vector3(0, 3, 10);
cameraOffset.applyEuler(plane.rotation);
camera.position.copy(plane.position).add(cameraOffset);
camera.lookAt(plane.position);
renderer.render(scene, camera);
}
animate();
// Handle window resize
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth/window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>
i was bored so i javascript a flight sim works on Three.js
GENERAL INFO
- Predecessor: Low-Bypass Fighter Jet (LBFJ)
- Successors 1 craft(s)
- Created On: iOS
- Game Version: 1.3.204.1
- Price: $33,680k
- Number of Parts: 29
- Dimensions: 4 m x 7 m x 13 m
PERFORMANCE
- Total Delta V: 0m/s
- Total Thrust: 300N
- Engines: 4
- Wet Mass: 15,978kg
- Dry Mass: 13,091kg
STAGES
| Stage | Engines | Delta V | Thrust | Burn | Mass |
|---|---|---|---|---|---|
| 1 | 3 | 0m/s | 0N | 0s | 15,978kg |
Hello there. Here are some tips: Using your own colour scheme helps, Showing images in flight makes people intrigued. if you want help building jets, i'm here. Cya!