Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +475 -19
- prompts.txt +1 -0
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title: 3d
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: 3d-rocket-launcher
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: yellow
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,475 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>3D Rocket Launcher</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
9 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/controls/OrbitControls.min.js"></script>
|
10 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/loaders/GLTFLoader.min.js"></script>
|
11 |
+
<style>
|
12 |
+
body {
|
13 |
+
margin: 0;
|
14 |
+
overflow: hidden;
|
15 |
+
font-family: 'Arial', sans-serif;
|
16 |
+
}
|
17 |
+
#canvas-container {
|
18 |
+
position: absolute;
|
19 |
+
width: 100%;
|
20 |
+
height: 100%;
|
21 |
+
}
|
22 |
+
#ui {
|
23 |
+
position: absolute;
|
24 |
+
top: 20px;
|
25 |
+
left: 20px;
|
26 |
+
z-index: 100;
|
27 |
+
color: white;
|
28 |
+
text-shadow: 1px 1px 2px black;
|
29 |
+
}
|
30 |
+
#flag {
|
31 |
+
position: absolute;
|
32 |
+
width: 40px;
|
33 |
+
height: 60px;
|
34 |
+
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="red" d="M14.4 6L14 4H5v17h2v-7h5.6l.4 2h7V6z"/></svg>');
|
35 |
+
background-size: contain;
|
36 |
+
background-repeat: no-repeat;
|
37 |
+
cursor: move;
|
38 |
+
z-index: 50;
|
39 |
+
user-select: none;
|
40 |
+
}
|
41 |
+
#launch-btn {
|
42 |
+
position: absolute;
|
43 |
+
bottom: 30px;
|
44 |
+
left: 50%;
|
45 |
+
transform: translateX(-50%);
|
46 |
+
padding: 12px 24px;
|
47 |
+
background: linear-gradient(to right, #ff5e62, #ff9966);
|
48 |
+
color: white;
|
49 |
+
border: none;
|
50 |
+
border-radius: 30px;
|
51 |
+
font-size: 18px;
|
52 |
+
font-weight: bold;
|
53 |
+
cursor: pointer;
|
54 |
+
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
|
55 |
+
z-index: 100;
|
56 |
+
transition: all 0.3s;
|
57 |
+
}
|
58 |
+
#launch-btn:hover {
|
59 |
+
transform: translateX(-50%) scale(1.05);
|
60 |
+
box-shadow: 0 6px 20px rgba(0,0,0,0.3);
|
61 |
+
}
|
62 |
+
#launch-btn:active {
|
63 |
+
transform: translateX(-50%) scale(0.98);
|
64 |
+
}
|
65 |
+
.explosion-particle {
|
66 |
+
position: absolute;
|
67 |
+
width: 8px;
|
68 |
+
height: 8px;
|
69 |
+
border-radius: 50%;
|
70 |
+
pointer-events: none;
|
71 |
+
}
|
72 |
+
</style>
|
73 |
+
</head>
|
74 |
+
<body>
|
75 |
+
<div id="canvas-container"></div>
|
76 |
+
<div id="ui">
|
77 |
+
<h1 class="text-3xl font-bold">🚀 Rocket Launcher</h1>
|
78 |
+
<p class="text-lg">Drag the flag to set target, then launch!</p>
|
79 |
+
</div>
|
80 |
+
<div id="flag"></div>
|
81 |
+
<button id="launch-btn">LAUNCH ROCKET</button>
|
82 |
+
|
83 |
+
<script>
|
84 |
+
// Scene setup
|
85 |
+
const scene = new THREE.Scene();
|
86 |
+
scene.background = new THREE.Color(0x87CEEB);
|
87 |
+
scene.fog = new THREE.FogExp2(0x87CEEB, 0.002);
|
88 |
+
|
89 |
+
// Camera
|
90 |
+
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
91 |
+
camera.position.set(0, 10, 30);
|
92 |
+
|
93 |
+
// Renderer
|
94 |
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
95 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
96 |
+
renderer.shadowMap.enabled = true;
|
97 |
+
document.getElementById('canvas-container').appendChild(renderer.domElement);
|
98 |
+
|
99 |
+
// Controls
|
100 |
+
const controls = new THREE.OrbitControls(camera, renderer.domElement);
|
101 |
+
controls.enableDamping = true;
|
102 |
+
controls.dampingFactor = 0.05;
|
103 |
+
controls.minDistance = 10;
|
104 |
+
controls.maxDistance = 100;
|
105 |
+
|
106 |
+
// Lights
|
107 |
+
const ambientLight = new THREE.AmbientLight(0x404040);
|
108 |
+
scene.add(ambientLight);
|
109 |
+
|
110 |
+
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
|
111 |
+
directionalLight.position.set(10, 20, 10);
|
112 |
+
directionalLight.castShadow = true;
|
113 |
+
directionalLight.shadow.mapSize.width = 2048;
|
114 |
+
directionalLight.shadow.mapSize.height = 2048;
|
115 |
+
scene.add(directionalLight);
|
116 |
+
|
117 |
+
// Ground
|
118 |
+
const groundGeometry = new THREE.PlaneGeometry(200, 200);
|
119 |
+
const groundMaterial = new THREE.MeshStandardMaterial({
|
120 |
+
color: 0x3a5f0b,
|
121 |
+
roughness: 0.8,
|
122 |
+
metalness: 0.2
|
123 |
+
});
|
124 |
+
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
|
125 |
+
ground.rotation.x = -Math.PI / 2;
|
126 |
+
ground.receiveShadow = true;
|
127 |
+
scene.add(ground);
|
128 |
+
|
129 |
+
// Launch pad
|
130 |
+
const padGeometry = new THREE.CylinderGeometry(3, 3, 0.5, 32);
|
131 |
+
const padMaterial = new THREE.MeshStandardMaterial({
|
132 |
+
color: 0x555555,
|
133 |
+
roughness: 0.7,
|
134 |
+
metalness: 0.3
|
135 |
+
});
|
136 |
+
const launchPad = new THREE.Mesh(padGeometry, padMaterial);
|
137 |
+
launchPad.position.set(0, 0.25, 0);
|
138 |
+
launchPad.receiveShadow = true;
|
139 |
+
scene.add(launchPad);
|
140 |
+
|
141 |
+
// Rocket
|
142 |
+
let rocket;
|
143 |
+
function createRocket() {
|
144 |
+
const group = new THREE.Group();
|
145 |
+
|
146 |
+
// Rocket body
|
147 |
+
const bodyGeometry = new THREE.CylinderGeometry(0.5, 0.3, 3, 32);
|
148 |
+
const bodyMaterial = new THREE.MeshStandardMaterial({
|
149 |
+
color: 0xffffff,
|
150 |
+
roughness: 0.2,
|
151 |
+
metalness: 0.7
|
152 |
+
});
|
153 |
+
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
|
154 |
+
body.position.y = 1.5;
|
155 |
+
body.castShadow = true;
|
156 |
+
group.add(body);
|
157 |
+
|
158 |
+
// Rocket nose
|
159 |
+
const noseGeometry = new THREE.ConeGeometry(0.5, 1, 32);
|
160 |
+
const noseMaterial = new THREE.MeshStandardMaterial({
|
161 |
+
color: 0xff0000,
|
162 |
+
roughness: 0.2,
|
163 |
+
metalness: 0.7
|
164 |
+
});
|
165 |
+
const nose = new THREE.Mesh(noseGeometry, noseMaterial);
|
166 |
+
nose.position.y = 3.5;
|
167 |
+
nose.castShadow = true;
|
168 |
+
group.add(nose);
|
169 |
+
|
170 |
+
// Fins
|
171 |
+
const finGeometry = new THREE.BoxGeometry(0.8, 0.1, 0.5);
|
172 |
+
const finMaterial = new THREE.MeshStandardMaterial({
|
173 |
+
color: 0x0000ff,
|
174 |
+
roughness: 0.5,
|
175 |
+
metalness: 0.3
|
176 |
+
});
|
177 |
+
|
178 |
+
for (let i = 0; i < 3; i++) {
|
179 |
+
const fin = new THREE.Mesh(finGeometry, finMaterial);
|
180 |
+
fin.position.y = 0.5;
|
181 |
+
fin.rotation.y = (i * Math.PI * 2) / 3;
|
182 |
+
fin.position.x = Math.sin(fin.rotation.y) * 0.6;
|
183 |
+
fin.position.z = Math.cos(fin.rotation.y) * 0.6;
|
184 |
+
fin.rotation.z = Math.PI / 4;
|
185 |
+
fin.castShadow = true;
|
186 |
+
group.add(fin);
|
187 |
+
}
|
188 |
+
|
189 |
+
// Engine
|
190 |
+
const engineGeometry = new THREE.CylinderGeometry(0.4, 0.5, 0.5, 32);
|
191 |
+
const engineMaterial = new THREE.MeshStandardMaterial({
|
192 |
+
color: 0x333333,
|
193 |
+
roughness: 0.8,
|
194 |
+
metalness: 0.1
|
195 |
+
});
|
196 |
+
const engine = new THREE.Mesh(engineGeometry, engineMaterial);
|
197 |
+
engine.position.y = 0.25;
|
198 |
+
engine.castShadow = true;
|
199 |
+
group.add(engine);
|
200 |
+
|
201 |
+
// Flame (will be animated)
|
202 |
+
const flameGeometry = new THREE.ConeGeometry(0.6, 1.5, 32);
|
203 |
+
const flameMaterial = new THREE.MeshStandardMaterial({
|
204 |
+
color: 0xff6600,
|
205 |
+
emissive: 0xff6600,
|
206 |
+
emissiveIntensity: 1,
|
207 |
+
transparent: true,
|
208 |
+
opacity: 0.8
|
209 |
+
});
|
210 |
+
const flame = new THREE.Mesh(flameGeometry, flameMaterial);
|
211 |
+
flame.position.y = -0.5;
|
212 |
+
flame.rotation.x = Math.PI;
|
213 |
+
group.add(flame);
|
214 |
+
group.userData.flame = flame;
|
215 |
+
|
216 |
+
group.position.set(0, 0, 0);
|
217 |
+
group.scale.set(0.8, 0.8, 0.8);
|
218 |
+
return group;
|
219 |
+
}
|
220 |
+
|
221 |
+
// Flag dragging
|
222 |
+
const flag = document.getElementById('flag');
|
223 |
+
let isDragging = false;
|
224 |
+
let offsetX, offsetY;
|
225 |
+
|
226 |
+
flag.addEventListener('mousedown', (e) => {
|
227 |
+
isDragging = true;
|
228 |
+
offsetX = e.clientX - flag.offsetLeft;
|
229 |
+
offsetY = e.clientY - flag.offsetTop;
|
230 |
+
flag.style.opacity = '0.8';
|
231 |
+
});
|
232 |
+
|
233 |
+
document.addEventListener('mousemove', (e) => {
|
234 |
+
if (!isDragging) return;
|
235 |
+
|
236 |
+
flag.style.left = (e.clientX - offsetX) + 'px';
|
237 |
+
flag.style.top = (e.clientY - offsetY) + 'px';
|
238 |
+
});
|
239 |
+
|
240 |
+
document.addEventListener('mouseup', () => {
|
241 |
+
isDragging = false;
|
242 |
+
flag.style.opacity = '1';
|
243 |
+
});
|
244 |
+
|
245 |
+
// Convert screen position to 3D world position
|
246 |
+
function screenToWorld(x, y) {
|
247 |
+
const vector = new THREE.Vector3(
|
248 |
+
(x / window.innerWidth) * 2 - 1,
|
249 |
+
-(y / window.innerHeight) * 2 + 1,
|
250 |
+
0.5
|
251 |
+
);
|
252 |
+
vector.unproject(camera);
|
253 |
+
const dir = vector.sub(camera.position).normalize();
|
254 |
+
const distance = -camera.position.y / dir.y;
|
255 |
+
const pos = camera.position.clone().add(dir.multiplyScalar(distance));
|
256 |
+
return pos;
|
257 |
+
}
|
258 |
+
|
259 |
+
// Launch rocket
|
260 |
+
const launchBtn = document.getElementById('launch-btn');
|
261 |
+
let isRocketFlying = false;
|
262 |
+
let rocketTarget = new THREE.Vector3(10, 0, 10);
|
263 |
+
let rocketStartTime = 0;
|
264 |
+
const flightDuration = 5000; // ms
|
265 |
+
|
266 |
+
launchBtn.addEventListener('click', () => {
|
267 |
+
if (isRocketFlying) return;
|
268 |
+
|
269 |
+
// Get flag position in 3D world
|
270 |
+
const flagRect = flag.getBoundingClientRect();
|
271 |
+
const flagCenterX = flagRect.left + flagRect.width / 2;
|
272 |
+
const flagCenterY = flagRect.top + flagRect.height / 2;
|
273 |
+
rocketTarget = screenToWorld(flagCenterX, flagCenterY);
|
274 |
+
|
275 |
+
// Create rocket
|
276 |
+
if (rocket) scene.remove(rocket);
|
277 |
+
rocket = createRocket();
|
278 |
+
scene.add(rocket);
|
279 |
+
|
280 |
+
isRocketFlying = true;
|
281 |
+
rocketStartTime = Date.now();
|
282 |
+
|
283 |
+
// Animate flame
|
284 |
+
animateFlame();
|
285 |
+
});
|
286 |
+
|
287 |
+
// Animate rocket flame
|
288 |
+
function animateFlame() {
|
289 |
+
if (!isRocketFlying || !rocket) return;
|
290 |
+
|
291 |
+
const flame = rocket.userData.flame;
|
292 |
+
if (flame) {
|
293 |
+
// Randomize flame size for flickering effect
|
294 |
+
const scale = 0.8 + Math.random() * 0.4;
|
295 |
+
flame.scale.set(scale, scale, scale);
|
296 |
+
}
|
297 |
+
|
298 |
+
requestAnimationFrame(animateFlame);
|
299 |
+
}
|
300 |
+
|
301 |
+
// Create explosion
|
302 |
+
function createExplosion(position) {
|
303 |
+
// Create particles
|
304 |
+
const particleCount = 200;
|
305 |
+
const particles = new THREE.BufferGeometry();
|
306 |
+
const positions = new Float32Array(particleCount * 3);
|
307 |
+
const colors = new Float32Array(particleCount * 3);
|
308 |
+
const sizes = new Float32Array(particleCount);
|
309 |
+
|
310 |
+
const colorChoices = [
|
311 |
+
new THREE.Color(0xff6600), // Orange
|
312 |
+
new THREE.Color(0xff0000), // Red
|
313 |
+
new THREE.Color(0xffff00), // Yellow
|
314 |
+
new THREE.Color(0xffffff) // White
|
315 |
+
];
|
316 |
+
|
317 |
+
for (let i = 0; i < particleCount; i++) {
|
318 |
+
// Random position in sphere
|
319 |
+
const theta = Math.random() * Math.PI * 2;
|
320 |
+
const phi = Math.random() * Math.PI;
|
321 |
+
const radius = 0.1 + Math.random() * 2;
|
322 |
+
|
323 |
+
positions[i * 3] = position.x + radius * Math.sin(phi) * Math.cos(theta);
|
324 |
+
positions[i * 3 + 1] = position.y + radius * Math.cos(phi);
|
325 |
+
positions[i * 3 + 2] = position.z + radius * Math.sin(phi) * Math.sin(theta);
|
326 |
+
|
327 |
+
// Random color
|
328 |
+
const color = colorChoices[Math.floor(Math.random() * colorChoices.length)];
|
329 |
+
colors[i * 3] = color.r;
|
330 |
+
colors[i * 3 + 1] = color.g;
|
331 |
+
colors[i * 3 + 2] = color.b;
|
332 |
+
|
333 |
+
// Random size
|
334 |
+
sizes[i] = 0.5 + Math.random() * 1.5;
|
335 |
+
}
|
336 |
+
|
337 |
+
particles.setAttribute('position', new THREE.BufferAttribute(positions, 3));
|
338 |
+
particles.setAttribute('color', new THREE.BufferAttribute(colors, 3));
|
339 |
+
particles.setAttribute('size', new THREE.BufferAttribute(sizes, 1));
|
340 |
+
|
341 |
+
// Particle material
|
342 |
+
const particleMaterial = new THREE.PointsMaterial({
|
343 |
+
size: 1,
|
344 |
+
vertexColors: true,
|
345 |
+
transparent: true,
|
346 |
+
opacity: 0.8,
|
347 |
+
blending: THREE.AdditiveBlending
|
348 |
+
});
|
349 |
+
|
350 |
+
const particleSystem = new THREE.Points(particles, particleMaterial);
|
351 |
+
scene.add(particleSystem);
|
352 |
+
|
353 |
+
// Animate particles
|
354 |
+
const startTime = Date.now();
|
355 |
+
const duration = 2000; // 2 seconds
|
356 |
+
|
357 |
+
function animateParticles() {
|
358 |
+
const elapsed = Date.now() - startTime;
|
359 |
+
const progress = elapsed / duration;
|
360 |
+
|
361 |
+
if (progress >= 1) {
|
362 |
+
scene.remove(particleSystem);
|
363 |
+
return;
|
364 |
+
}
|
365 |
+
|
366 |
+
// Update particle positions (fly outward and fade)
|
367 |
+
const positions = particles.attributes.position.array;
|
368 |
+
for (let i = 0; i < particleCount; i++) {
|
369 |
+
// Move particles outward
|
370 |
+
positions[i * 3] += (positions[i * 3] - position.x) * 0.02;
|
371 |
+
positions[i * 3 + 1] += (positions[i * 3 + 1] - position.y) * 0.02;
|
372 |
+
positions[i * 3 + 2] += (positions[i * 3 + 2] - position.z) * 0.02;
|
373 |
+
|
374 |
+
// Add some randomness
|
375 |
+
positions[i * 3] += (Math.random() - 0.5) * 0.2;
|
376 |
+
positions[i * 3 + 1] += (Math.random() - 0.5) * 0.2;
|
377 |
+
positions[i * 3 + 2] += (Math.random() - 0.5) * 0.2;
|
378 |
+
}
|
379 |
+
|
380 |
+
particles.attributes.position.needsUpdate = true;
|
381 |
+
particleMaterial.opacity = 1 - progress;
|
382 |
+
|
383 |
+
requestAnimationFrame(animateParticles);
|
384 |
+
}
|
385 |
+
|
386 |
+
animateParticles();
|
387 |
+
}
|
388 |
+
|
389 |
+
// Animation loop
|
390 |
+
function animate() {
|
391 |
+
requestAnimationFrame(animate);
|
392 |
+
|
393 |
+
// Update controls
|
394 |
+
controls.update();
|
395 |
+
|
396 |
+
// Update rocket flight
|
397 |
+
if (isRocketFlying && rocket) {
|
398 |
+
const elapsed = Date.now() - rocketStartTime;
|
399 |
+
const progress = Math.min(elapsed / flightDuration, 1);
|
400 |
+
|
401 |
+
if (progress >= 1) {
|
402 |
+
// Rocket reached target - explode!
|
403 |
+
createExplosion(rocket.position);
|
404 |
+
scene.remove(rocket);
|
405 |
+
isRocketFlying = false;
|
406 |
+
rocket = null;
|
407 |
+
} else {
|
408 |
+
// Calculate bezier curve path
|
409 |
+
const startPoint = new THREE.Vector3(0, 0, 0);
|
410 |
+
const controlPoint1 = new THREE.Vector3(
|
411 |
+
rocketTarget.x * 0.3,
|
412 |
+
rocketTarget.y + 30,
|
413 |
+
rocketTarget.z * 0.3
|
414 |
+
);
|
415 |
+
const controlPoint2 = new THREE.Vector3(
|
416 |
+
rocketTarget.x * 0.7,
|
417 |
+
rocketTarget.y + 20,
|
418 |
+
rocketTarget.z * 0.7
|
419 |
+
);
|
420 |
+
const endPoint = new THREE.Vector3(rocketTarget.x, rocketTarget.y, rocketTarget.z);
|
421 |
+
|
422 |
+
// Get position on curve
|
423 |
+
const t = progress;
|
424 |
+
const u = 1 - t;
|
425 |
+
const tt = t * t;
|
426 |
+
const uu = u * u;
|
427 |
+
const uuu = uu * u;
|
428 |
+
const ttt = tt * t;
|
429 |
+
|
430 |
+
const point = new THREE.Vector3(0, 0, 0);
|
431 |
+
point.x = uuu * startPoint.x;
|
432 |
+
point.y = uuu * startPoint.y;
|
433 |
+
point.z = uuu * startPoint.z;
|
434 |
+
|
435 |
+
point.x += 3 * uu * t * controlPoint1.x;
|
436 |
+
point.y += 3 * uu * t * controlPoint1.y;
|
437 |
+
point.z += 3 * uu * t * controlPoint1.z;
|
438 |
+
|
439 |
+
point.x += 3 * u * tt * controlPoint2.x;
|
440 |
+
point.y += 3 * u * tt * controlPoint2.y;
|
441 |
+
point.z += 3 * u * tt * controlPoint2.z;
|
442 |
+
|
443 |
+
point.x += ttt * endPoint.x;
|
444 |
+
point.y += ttt * endPoint.y;
|
445 |
+
point.z += ttt * endPoint.z;
|
446 |
+
|
447 |
+
// Set rocket position and rotation
|
448 |
+
rocket.position.copy(point);
|
449 |
+
|
450 |
+
// Calculate direction for rotation
|
451 |
+
if (elapsed > 50) { // Wait a frame to have previous position
|
452 |
+
const direction = point.clone().sub(rocket.userData.lastPosition).normalize();
|
453 |
+
rocket.lookAt(point.clone().add(direction));
|
454 |
+
rocket.rotateX(Math.PI / 2); // Adjust because rocket model points up
|
455 |
+
}
|
456 |
+
|
457 |
+
rocket.userData.lastPosition = point.clone();
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
renderer.render(scene, camera);
|
462 |
+
}
|
463 |
+
|
464 |
+
// Handle window resize
|
465 |
+
window.addEventListener('resize', () => {
|
466 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
467 |
+
camera.updateProjectionMatrix();
|
468 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
469 |
+
});
|
470 |
+
|
471 |
+
// Start animation
|
472 |
+
animate();
|
473 |
+
</script>
|
474 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=LukasBe/3d-rocket-launcher" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
475 |
+
</html>
|
prompts.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Create and amazing 3d threejs based rocket laucning toy, the user can drag a flag over the screen, then then launch great looking 3d procedural detailed rocket that flies in indirect interesting bezier path slowly to the flag where it exploded in a beaturiful particle based smoke,fire and sparks ...
|