Update index.html
Browse files- index.html +121 -18
index.html
CHANGED
@@ -1,19 +1,122 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<title>Spin Launch Simulation</title>
|
6 |
+
<style>
|
7 |
+
body { margin: 0; overflow: hidden; }
|
8 |
+
#info { position: absolute; top: 10px; left: 10px; color: white; }
|
9 |
+
</style>
|
10 |
+
</head>
|
11 |
+
<body>
|
12 |
+
<div id="info">Spin Launch Simulation: Adjust parameters using the GUI.</div>
|
13 |
+
<!-- Include Three.js and dat.GUI from CDN -->
|
14 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r152/three.min.js"></script>
|
15 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.9/dat.gui.min.js"></script>
|
16 |
+
<script>
|
17 |
+
// Set up Three.js scene, camera, and renderer
|
18 |
+
const scene = new THREE.Scene();
|
19 |
+
const camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 10000);
|
20 |
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
21 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
22 |
+
document.body.appendChild(renderer.domElement);
|
23 |
+
|
24 |
+
// Add basic lighting
|
25 |
+
const light = new THREE.PointLight(0xffffff, 1);
|
26 |
+
light.position.set(50, 50, 50);
|
27 |
+
scene.add(light);
|
28 |
+
|
29 |
+
// Create simple geometries for launcher, payload, and manned vehicle
|
30 |
+
const payloadGeometry = new THREE.CylinderGeometry(1, 1, 3, 32);
|
31 |
+
const payloadMaterial = new THREE.MeshLambertMaterial({ color: 0xff0000 });
|
32 |
+
const payload = new THREE.Mesh(payloadGeometry, payloadMaterial);
|
33 |
+
scene.add(payload);
|
34 |
+
|
35 |
+
// Position payload at the end of a "spin arm"
|
36 |
+
payload.position.set(20, 0, 0); // Starting position
|
37 |
+
|
38 |
+
// Create a simple representation for the manned vehicle (e.g., a box)
|
39 |
+
const vehicleGeometry = new THREE.BoxGeometry(3, 3, 3);
|
40 |
+
const vehicleMaterial = new THREE.MeshLambertMaterial({ color: 0x0000ff });
|
41 |
+
const mannedVehicle = new THREE.Mesh(vehicleGeometry, vehicleMaterial);
|
42 |
+
mannedVehicle.position.set(-20, 10, 0); // Pre-positioned in orbit for rendezvous
|
43 |
+
scene.add(mannedVehicle);
|
44 |
+
|
45 |
+
// Set camera position
|
46 |
+
camera.position.z = 50;
|
47 |
+
|
48 |
+
// Define control parameters for each stage
|
49 |
+
const params = {
|
50 |
+
stage: 1,
|
51 |
+
spinRate: 0.1, // radians per second
|
52 |
+
launchVelocity: 0, // computed from spin rate and radius
|
53 |
+
thrusterBurn: 1.0, // duration (seconds)
|
54 |
+
despinRate: 0.05, // decrease in rotation per second
|
55 |
+
dockingSpeed: 0.1, // approach speed
|
56 |
+
nextStage: function() {
|
57 |
+
if (this.stage < 5) {
|
58 |
+
this.stage++;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
};
|
62 |
+
|
63 |
+
// Setup GUI
|
64 |
+
const gui = new dat.GUI();
|
65 |
+
gui.add(params, 'stage', 1, 5, 1).name('Stage').listen();
|
66 |
+
gui.add(params, 'spinRate', 0.01, 1.0).name('Spin Rate');
|
67 |
+
gui.add(params, 'thrusterBurn', 0.5, 5.0).name('Thruster Burn');
|
68 |
+
gui.add(params, 'despinRate', 0.01, 0.2).name('Despin Rate');
|
69 |
+
gui.add(params, 'dockingSpeed', 0.01, 0.5).name('Docking Speed');
|
70 |
+
gui.add(params, 'nextStage').name('Next Stage');
|
71 |
+
|
72 |
+
// Animation variables
|
73 |
+
let elapsedTime = 0;
|
74 |
+
const clock = new THREE.Clock();
|
75 |
+
|
76 |
+
function animate() {
|
77 |
+
requestAnimationFrame(animate);
|
78 |
+
const delta = clock.getDelta();
|
79 |
+
elapsedTime += delta;
|
80 |
+
|
81 |
+
// Example Stage Behavior: Stage 1 (Spin-Up)
|
82 |
+
if (params.stage === 1) {
|
83 |
+
// Rotate payload around a central axis (simulate spin)
|
84 |
+
payload.position.x = 20 * Math.cos(elapsedTime * params.spinRate);
|
85 |
+
payload.position.y = 20 * Math.sin(elapsedTime * params.spinRate);
|
86 |
+
// Update computed launch velocity (v = ω*r)
|
87 |
+
params.launchVelocity = params.spinRate * 20;
|
88 |
+
}
|
89 |
+
|
90 |
+
// Stage 2: Brief thruster burn (simulate orbital insertion)
|
91 |
+
if (params.stage === 2 && elapsedTime < 5) {
|
92 |
+
// Slightly adjust payload trajectory upward (simplified)
|
93 |
+
payload.position.z += params.thrusterBurn * delta * 2;
|
94 |
+
}
|
95 |
+
|
96 |
+
// Stage 3: Despin and stabilization
|
97 |
+
if (params.stage === 3 && elapsedTime < 10) {
|
98 |
+
// Gradually reduce rotation (despin effect)
|
99 |
+
// For illustration, we slow the rotation by reducing spinRate over time
|
100 |
+
params.spinRate = Math.max(0.01, params.spinRate - params.despinRate * delta);
|
101 |
+
}
|
102 |
+
|
103 |
+
// Stage 4: Rendezvous with manned vehicle (approach simulation)
|
104 |
+
if (params.stage === 4) {
|
105 |
+
// Linearly interpolate payload's position toward the manned vehicle’s docking port
|
106 |
+
payload.position.lerp(mannedVehicle.position, params.dockingSpeed * delta);
|
107 |
+
}
|
108 |
+
|
109 |
+
// Stage 5: Integrated mission operations (combined orbit)
|
110 |
+
if (params.stage === 5) {
|
111 |
+
// Have payload and manned vehicle move together along an orbital path (for illustration)
|
112 |
+
payload.position.x += 0.05;
|
113 |
+
mannedVehicle.position.x += 0.05;
|
114 |
+
}
|
115 |
+
|
116 |
+
renderer.render(scene, camera);
|
117 |
+
}
|
118 |
+
|
119 |
+
animate();
|
120 |
+
</script>
|
121 |
+
</body>
|
122 |
</html>
|