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-rockets
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: purple
|
5 |
+
colorTo: purple
|
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.js"></script>
|
10 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/loaders/GLTFLoader.js"></script>
|
11 |
+
<style>
|
12 |
+
body {
|
13 |
+
margin: 0;
|
14 |
+
overflow: hidden;
|
15 |
+
font-family: 'Arial', sans-serif;
|
16 |
+
}
|
17 |
+
canvas {
|
18 |
+
display: block;
|
19 |
+
}
|
20 |
+
#ui {
|
21 |
+
position: absolute;
|
22 |
+
top: 0;
|
23 |
+
left: 0;
|
24 |
+
width: 100%;
|
25 |
+
padding: 20px;
|
26 |
+
color: white;
|
27 |
+
text-align: center;
|
28 |
+
pointer-events: none;
|
29 |
+
z-index: 100;
|
30 |
+
}
|
31 |
+
#crosshair {
|
32 |
+
position: absolute;
|
33 |
+
top: 50%;
|
34 |
+
left: 50%;
|
35 |
+
width: 20px;
|
36 |
+
height: 20px;
|
37 |
+
transform: translate(-50%, -50%);
|
38 |
+
pointer-events: none;
|
39 |
+
z-index: 101;
|
40 |
+
}
|
41 |
+
#crosshair::before, #crosshair::after {
|
42 |
+
content: '';
|
43 |
+
position: absolute;
|
44 |
+
background: rgba(255, 255, 255, 0.8);
|
45 |
+
}
|
46 |
+
#crosshair::before {
|
47 |
+
width: 2px;
|
48 |
+
height: 20px;
|
49 |
+
left: 9px;
|
50 |
+
top: 0;
|
51 |
+
}
|
52 |
+
#crosshair::after {
|
53 |
+
width: 20px;
|
54 |
+
height: 2px;
|
55 |
+
left: 0;
|
56 |
+
top: 9px;
|
57 |
+
}
|
58 |
+
#explosion {
|
59 |
+
position: absolute;
|
60 |
+
top: 50%;
|
61 |
+
left: 50%;
|
62 |
+
width: 200px;
|
63 |
+
height: 200px;
|
64 |
+
transform: translate(-50%, -50%);
|
65 |
+
border-radius: 50%;
|
66 |
+
background: radial-gradient(circle, rgba(255,100,0,0.8) 0%, rgba(255,50,0,0) 70%);
|
67 |
+
opacity: 0;
|
68 |
+
pointer-events: none;
|
69 |
+
z-index: 99;
|
70 |
+
transition: opacity 0.5s, transform 0.5s;
|
71 |
+
}
|
72 |
+
.button {
|
73 |
+
pointer-events: auto;
|
74 |
+
background: rgba(255, 255, 255, 0.2);
|
75 |
+
border: 1px solid rgba(255, 255, 255, 0.4);
|
76 |
+
color: white;
|
77 |
+
padding: 8px 16px;
|
78 |
+
border-radius: 4px;
|
79 |
+
cursor: pointer;
|
80 |
+
transition: all 0.3s;
|
81 |
+
}
|
82 |
+
.button:hover {
|
83 |
+
background: rgba(255, 255, 255, 0.4);
|
84 |
+
}
|
85 |
+
</style>
|
86 |
+
</head>
|
87 |
+
<body>
|
88 |
+
<div id="ui">
|
89 |
+
<h1 class="text-3xl font-bold mb-2">3D Rocket Launcher</h1>
|
90 |
+
<p class="mb-4">Click anywhere to launch rockets!</p>
|
91 |
+
<div class="flex justify-center gap-4">
|
92 |
+
<div class="button" id="fireRocket">Fire Rocket</div>
|
93 |
+
<div class="button" id="autoFire">Auto Fire</div>
|
94 |
+
</div>
|
95 |
+
<div class="mt-4">
|
96 |
+
<span id="rocketCount">0</span> Rockets Active
|
97 |
+
</div>
|
98 |
+
</div>
|
99 |
+
<div id="crosshair"></div>
|
100 |
+
<div id="explosion"></div>
|
101 |
+
|
102 |
+
<script>
|
103 |
+
// Scene setup
|
104 |
+
const scene = new THREE.Scene();
|
105 |
+
scene.background = new THREE.Color(0x111122);
|
106 |
+
|
107 |
+
// Camera setup
|
108 |
+
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
109 |
+
camera.position.z = 10;
|
110 |
+
camera.position.y = 5;
|
111 |
+
camera.lookAt(0, 0, 0);
|
112 |
+
|
113 |
+
// Renderer setup
|
114 |
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
115 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
116 |
+
renderer.setPixelRatio(window.devicePixelRatio);
|
117 |
+
document.body.appendChild(renderer.domElement);
|
118 |
+
|
119 |
+
// Controls
|
120 |
+
const controls = new THREE.OrbitControls(camera, renderer.domElement);
|
121 |
+
controls.enableDamping = true;
|
122 |
+
controls.dampingFactor = 0.05;
|
123 |
+
|
124 |
+
// Lights
|
125 |
+
const ambientLight = new THREE.AmbientLight(0x404040);
|
126 |
+
scene.add(ambientLight);
|
127 |
+
|
128 |
+
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
|
129 |
+
directionalLight.position.set(1, 1, 1);
|
130 |
+
scene.add(directionalLight);
|
131 |
+
|
132 |
+
// Rocket materials
|
133 |
+
const rocketBodyMaterial = new THREE.MeshPhongMaterial({
|
134 |
+
color: 0xff3333,
|
135 |
+
shininess: 100
|
136 |
+
});
|
137 |
+
|
138 |
+
const rocketNoseMaterial = new THREE.MeshPhongMaterial({
|
139 |
+
color: 0xffffff,
|
140 |
+
shininess: 100
|
141 |
+
});
|
142 |
+
|
143 |
+
const rocketFinMaterial = new THREE.MeshPhongMaterial({
|
144 |
+
color: 0x3333ff,
|
145 |
+
shininess: 50
|
146 |
+
});
|
147 |
+
|
148 |
+
// Create a procedural rocket model
|
149 |
+
function createRocket() {
|
150 |
+
const rocketGroup = new THREE.Group();
|
151 |
+
|
152 |
+
// Rocket body (cylinder)
|
153 |
+
const bodyGeometry = new THREE.CylinderGeometry(0.2, 0.2, 1, 32);
|
154 |
+
const body = new THREE.Mesh(bodyGeometry, rocketBodyMaterial);
|
155 |
+
body.position.y = 0.5;
|
156 |
+
rocketGroup.add(body);
|
157 |
+
|
158 |
+
// Rocket nose (cone)
|
159 |
+
const noseGeometry = new THREE.ConeGeometry(0.2, 0.4, 32);
|
160 |
+
const nose = new THREE.Mesh(noseGeometry, rocketNoseMaterial);
|
161 |
+
nose.position.y = 1.2;
|
162 |
+
rocketGroup.add(nose);
|
163 |
+
|
164 |
+
// Rocket fins (3 fins)
|
165 |
+
const finGeometry = new THREE.BoxGeometry(0.4, 0.1, 0.2);
|
166 |
+
for (let i = 0; i < 3; i++) {
|
167 |
+
const fin = new THREE.Mesh(finGeometry, rocketFinMaterial);
|
168 |
+
fin.position.y = 0.2;
|
169 |
+
fin.position.z = 0.1;
|
170 |
+
fin.rotation.x = Math.PI / 2;
|
171 |
+
fin.rotation.y = (i * Math.PI * 2 / 3);
|
172 |
+
fin.position.x = Math.sin(fin.rotation.y) * 0.3;
|
173 |
+
fin.position.z = Math.cos(fin.rotation.y) * 0.3;
|
174 |
+
rocketGroup.add(fin);
|
175 |
+
}
|
176 |
+
|
177 |
+
// Rocket engine (small cylinder)
|
178 |
+
const engineGeometry = new THREE.CylinderGeometry(0.15, 0.15, 0.2, 32);
|
179 |
+
const engine = new THREE.Mesh(engineGeometry, new THREE.MeshPhongMaterial({ color: 0x333333 }));
|
180 |
+
engine.position.y = 0;
|
181 |
+
rocketGroup.add(engine);
|
182 |
+
|
183 |
+
return rocketGroup;
|
184 |
+
}
|
185 |
+
|
186 |
+
// Particle systems
|
187 |
+
function createFireParticles() {
|
188 |
+
const particleCount = 100;
|
189 |
+
const particles = new THREE.BufferGeometry();
|
190 |
+
const positions = new Float32Array(particleCount * 3);
|
191 |
+
const colors = new Float32Array(particleCount * 3);
|
192 |
+
const sizes = new Float32Array(particleCount);
|
193 |
+
|
194 |
+
for (let i = 0; i < particleCount; i++) {
|
195 |
+
positions[i * 3] = (Math.random() - 0.5) * 0.2;
|
196 |
+
positions[i * 3 + 1] = Math.random() * -0.5;
|
197 |
+
positions[i * 3 + 2] = (Math.random() - 0.5) * 0.2;
|
198 |
+
|
199 |
+
// Fire colors (red, orange, yellow)
|
200 |
+
const color = new THREE.Color(
|
201 |
+
0.9 + Math.random() * 0.1,
|
202 |
+
0.3 + Math.random() * 0.3,
|
203 |
+
Math.random() * 0.2
|
204 |
+
);
|
205 |
+
colors[i * 3] = color.r;
|
206 |
+
colors[i * 3 + 1] = color.g;
|
207 |
+
colors[i * 3 + 2] = color.b;
|
208 |
+
|
209 |
+
sizes[i] = 0.1 + Math.random() * 0.2;
|
210 |
+
}
|
211 |
+
|
212 |
+
particles.setAttribute('position', new THREE.BufferAttribute(positions, 3));
|
213 |
+
particles.setAttribute('color', new THREE.BufferAttribute(colors, 3));
|
214 |
+
particles.setAttribute('size', new THREE.BufferAttribute(sizes, 1));
|
215 |
+
|
216 |
+
const particleMaterial = new THREE.PointsMaterial({
|
217 |
+
size: 0.1,
|
218 |
+
vertexColors: true,
|
219 |
+
transparent: true,
|
220 |
+
opacity: 0.8,
|
221 |
+
blending: THREE.AdditiveBlending
|
222 |
+
});
|
223 |
+
|
224 |
+
const particleSystem = new THREE.Points(particles, particleMaterial);
|
225 |
+
return particleSystem;
|
226 |
+
}
|
227 |
+
|
228 |
+
function createSmokeParticles() {
|
229 |
+
const particleCount = 50;
|
230 |
+
const particles = new THREE.BufferGeometry();
|
231 |
+
const positions = new Float32Array(particleCount * 3);
|
232 |
+
const colors = new Float32Array(particleCount * 3);
|
233 |
+
const sizes = new Float32Array(particleCount);
|
234 |
+
|
235 |
+
for (let i = 0; i < particleCount; i++) {
|
236 |
+
positions[i * 3] = (Math.random() - 0.5) * 0.5;
|
237 |
+
positions[i * 3 + 1] = Math.random() * -1;
|
238 |
+
positions[i * 3 + 2] = (Math.random() - 0.5) * 0.5;
|
239 |
+
|
240 |
+
// Smoke colors (gray to white)
|
241 |
+
const gray = 0.5 + Math.random() * 0.5;
|
242 |
+
const color = new THREE.Color(gray, gray, gray);
|
243 |
+
colors[i * 3] = color.r;
|
244 |
+
colors[i * 3 + 1] = color.g;
|
245 |
+
colors[i * 3 + 2] = color.b;
|
246 |
+
|
247 |
+
sizes[i] = 0.2 + Math.random() * 0.3;
|
248 |
+
}
|
249 |
+
|
250 |
+
particles.setAttribute('position', new THREE.BufferAttribute(positions, 3));
|
251 |
+
particles.setAttribute('color', new THREE.BufferAttribute(colors, 3));
|
252 |
+
particles.setAttribute('size', new THREE.BufferAttribute(sizes, 1));
|
253 |
+
|
254 |
+
const particleMaterial = new THREE.PointsMaterial({
|
255 |
+
size: 0.2,
|
256 |
+
vertexColors: true,
|
257 |
+
transparent: true,
|
258 |
+
opacity: 0.6,
|
259 |
+
blending: THREE.NormalBlending
|
260 |
+
});
|
261 |
+
|
262 |
+
const particleSystem = new THREE.Points(particles, particleMaterial);
|
263 |
+
return particleSystem;
|
264 |
+
}
|
265 |
+
|
266 |
+
// Rocket class
|
267 |
+
class Rocket {
|
268 |
+
constructor(startPosition) {
|
269 |
+
this.group = new THREE.Group();
|
270 |
+
this.rocket = createRocket();
|
271 |
+
this.fireParticles = createFireParticles();
|
272 |
+
this.smokeParticles = createSmokeParticles();
|
273 |
+
|
274 |
+
this.group.add(this.rocket);
|
275 |
+
this.group.add(this.fireParticles);
|
276 |
+
this.group.add(this.smokeParticles);
|
277 |
+
|
278 |
+
this.group.position.copy(startPosition);
|
279 |
+
|
280 |
+
// Create a random bezier curve back to center
|
281 |
+
const endPoint = new THREE.Vector3(0, 0, 0);
|
282 |
+
const control1 = new THREE.Vector3(
|
283 |
+
(Math.random() - 0.5) * 10,
|
284 |
+
Math.random() * 5,
|
285 |
+
(Math.random() - 0.5) * 10
|
286 |
+
);
|
287 |
+
const control2 = new THREE.Vector3(
|
288 |
+
(Math.random() - 0.5) * 10,
|
289 |
+
Math.random() * 5,
|
290 |
+
(Math.random() - 0.5) * 10
|
291 |
+
);
|
292 |
+
|
293 |
+
this.curve = new THREE.CubicBezierCurve3(
|
294 |
+
startPosition,
|
295 |
+
control1,
|
296 |
+
control2,
|
297 |
+
endPoint
|
298 |
+
);
|
299 |
+
|
300 |
+
this.progress = 0;
|
301 |
+
this.speed = 0.002 + Math.random() * 0.003;
|
302 |
+
this.alive = true;
|
303 |
+
this.exploded = false;
|
304 |
+
|
305 |
+
// Random rotation
|
306 |
+
this.rotationSpeed = new THREE.Vector3(
|
307 |
+
(Math.random() - 0.5) * 0.02,
|
308 |
+
(Math.random() - 0.5) * 0.02,
|
309 |
+
(Math.random() - 0.5) * 0.02
|
310 |
+
);
|
311 |
+
|
312 |
+
scene.add(this.group);
|
313 |
+
activeRockets.push(this);
|
314 |
+
updateRocketCount();
|
315 |
+
}
|
316 |
+
|
317 |
+
update() {
|
318 |
+
if (!this.alive) return;
|
319 |
+
|
320 |
+
this.progress += this.speed;
|
321 |
+
|
322 |
+
if (this.progress >= 1) {
|
323 |
+
this.explode();
|
324 |
+
return;
|
325 |
+
}
|
326 |
+
|
327 |
+
// Move along curve
|
328 |
+
const point = this.curve.getPoint(this.progress);
|
329 |
+
this.group.position.copy(point);
|
330 |
+
|
331 |
+
// Rotate rocket
|
332 |
+
this.rocket.rotation.x += this.rotationSpeed.x;
|
333 |
+
this.rocket.rotation.y += this.rotationSpeed.y;
|
334 |
+
this.rocket.rotation.z += this.rotationSpeed.z;
|
335 |
+
|
336 |
+
// Update particles
|
337 |
+
this.updateParticles();
|
338 |
+
}
|
339 |
+
|
340 |
+
updateParticles() {
|
341 |
+
// Fire particles
|
342 |
+
const firePositions = this.fireParticles.geometry.attributes.position.array;
|
343 |
+
for (let i = 0; i < firePositions.length; i += 3) {
|
344 |
+
firePositions[i + 1] -= 0.01;
|
345 |
+
if (firePositions[i + 1] < -0.5) {
|
346 |
+
firePositions[i] = (Math.random() - 0.5) * 0.2;
|
347 |
+
firePositions[i + 1] = 0;
|
348 |
+
firePositions[i + 2] = (Math.random() - 0.5) * 0.2;
|
349 |
+
}
|
350 |
+
}
|
351 |
+
this.fireParticles.geometry.attributes.position.needsUpdate = true;
|
352 |
+
|
353 |
+
// Smoke particles
|
354 |
+
const smokePositions = this.smokeParticles.geometry.attributes.position.array;
|
355 |
+
for (let i = 0; i < smokePositions.length; i += 3) {
|
356 |
+
smokePositions[i] += (Math.random() - 0.5) * 0.01;
|
357 |
+
smokePositions[i + 1] += 0.01;
|
358 |
+
smokePositions[i + 2] += (Math.random() - 0.5) * 0.01;
|
359 |
+
|
360 |
+
if (smokePositions[i + 1] > 0) {
|
361 |
+
smokePositions[i] = (Math.random() - 0.5) * 0.5;
|
362 |
+
smokePositions[i + 1] = -1 + Math.random() * 0.5;
|
363 |
+
smokePositions[i + 2] = (Math.random() - 0.5) * 0.5;
|
364 |
+
}
|
365 |
+
}
|
366 |
+
this.smokeParticles.geometry.attributes.position.needsUpdate = true;
|
367 |
+
}
|
368 |
+
|
369 |
+
explode() {
|
370 |
+
this.alive = false;
|
371 |
+
this.exploded = true;
|
372 |
+
|
373 |
+
// Show explosion effect
|
374 |
+
const explosion = document.getElementById('explosion');
|
375 |
+
explosion.style.opacity = '0.8';
|
376 |
+
explosion.style.transform = 'translate(-50%, -50%) scale(1)';
|
377 |
+
|
378 |
+
setTimeout(() => {
|
379 |
+
explosion.style.opacity = '0';
|
380 |
+
explosion.style.transform = 'translate(-50%, -50%) scale(0.5)';
|
381 |
+
}, 500);
|
382 |
+
|
383 |
+
// Remove from scene after a delay
|
384 |
+
setTimeout(() => {
|
385 |
+
scene.remove(this.group);
|
386 |
+
const index = activeRockets.indexOf(this);
|
387 |
+
if (index > -1) {
|
388 |
+
activeRockets.splice(index, 1);
|
389 |
+
}
|
390 |
+
updateRocketCount();
|
391 |
+
}, 1000);
|
392 |
+
}
|
393 |
+
}
|
394 |
+
|
395 |
+
// Active rockets array
|
396 |
+
let activeRockets = [];
|
397 |
+
|
398 |
+
// UI functions
|
399 |
+
function updateRocketCount() {
|
400 |
+
document.getElementById('rocketCount').textContent = activeRockets.length;
|
401 |
+
}
|
402 |
+
|
403 |
+
// Mouse position to 3D coordinates
|
404 |
+
function getMouseWorldPosition(event, targetZ = 0) {
|
405 |
+
const mouse = new THREE.Vector2();
|
406 |
+
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
|
407 |
+
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
|
408 |
+
|
409 |
+
const raycaster = new THREE.Raycaster();
|
410 |
+
raycaster.setFromCamera(mouse, camera);
|
411 |
+
|
412 |
+
const plane = new THREE.Plane(new THREE.Vector3(0, 0, 1), targetZ);
|
413 |
+
const intersection = new THREE.Vector3();
|
414 |
+
raycaster.ray.intersectPlane(plane, intersection);
|
415 |
+
|
416 |
+
return intersection;
|
417 |
+
}
|
418 |
+
|
419 |
+
// Event listeners
|
420 |
+
document.addEventListener('click', (event) => {
|
421 |
+
if (event.target.closest('.button')) return;
|
422 |
+
|
423 |
+
const mousePos = getMouseWorldPosition(event, 0);
|
424 |
+
new Rocket(mousePos);
|
425 |
+
});
|
426 |
+
|
427 |
+
document.getElementById('fireRocket').addEventListener('click', () => {
|
428 |
+
const x = (Math.random() - 0.5) * 10;
|
429 |
+
const y = (Math.random() - 0.5) * 10;
|
430 |
+
const z = (Math.random() - 0.5) * 10;
|
431 |
+
new Rocket(new THREE.Vector3(x, y, z));
|
432 |
+
});
|
433 |
+
|
434 |
+
let autoFireInterval = null;
|
435 |
+
document.getElementById('autoFire').addEventListener('click', function() {
|
436 |
+
if (autoFireInterval) {
|
437 |
+
clearInterval(autoFireInterval);
|
438 |
+
autoFireInterval = null;
|
439 |
+
this.textContent = 'Auto Fire';
|
440 |
+
} else {
|
441 |
+
autoFireInterval = setInterval(() => {
|
442 |
+
const x = (Math.random() - 0.5) * 10;
|
443 |
+
const y = (Math.random() - 0.5) * 10;
|
444 |
+
const z = (Math.random() - 0.5) * 10;
|
445 |
+
new Rocket(new THREE.Vector3(x, y, z));
|
446 |
+
}, 500);
|
447 |
+
this.textContent = 'Stop Auto Fire';
|
448 |
+
}
|
449 |
+
});
|
450 |
+
|
451 |
+
// Handle window resize
|
452 |
+
window.addEventListener('resize', () => {
|
453 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
454 |
+
camera.updateProjectionMatrix();
|
455 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
456 |
+
});
|
457 |
+
|
458 |
+
// Animation loop
|
459 |
+
function animate() {
|
460 |
+
requestAnimationFrame(animate);
|
461 |
+
|
462 |
+
controls.update();
|
463 |
+
|
464 |
+
// Update all rockets
|
465 |
+
for (let i = 0; i < activeRockets.length; i++) {
|
466 |
+
activeRockets[i].update();
|
467 |
+
}
|
468 |
+
|
469 |
+
renderer.render(scene, camera);
|
470 |
+
}
|
471 |
+
|
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-rockets" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
475 |
+
</html>
|
prompts.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Create a fun 3d threejs toy to shoot rockets with fire and smoke particles, a detailed procedural rocket 3d model, threejs app, the rocket would alway start at the mouse cursors and fly back to the center of the circle in a indirect slow smooth random bezier trajectory to explode in the screen center.
|