wop commited on
Commit
bf84fea
Β·
verified Β·
1 Parent(s): 3a51fb5

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +236 -19
index.html CHANGED
@@ -1,19 +1,236 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Clear Outward Explosion - Low Lag</title>
7
+ <style>
8
+ body, html { margin:0; padding:0; width:100%; height:100%; background:#000; overflow:hidden; font-family:system-ui,sans-serif; }
9
+ #canvas-container { position:absolute; inset:0; z-index:1; }
10
+ #flash {
11
+ position:absolute; inset:0; background:linear-gradient(#ff450033, #8b000022); opacity:0;
12
+ z-index:5; pointer-events:none; transition:opacity 0.18s ease-out;
13
+ }
14
+ #flash.active { opacity:0.65; }
15
+ #flash.fade-out { opacity:0; transition:opacity 2s ease-out; }
16
+ #title-container {
17
+ position:absolute; inset:0; display:flex; align-items:center; justify-content:center; z-index:10; pointer-events:none;
18
+ }
19
+ #title {
20
+ color:#ffcc00; font-size:12vw; font-weight:900; text-transform:uppercase; letter-spacing:0.25em;
21
+ text-shadow:0 0 25px #ff6600aa, 0 0 60px #ff3300aa;
22
+ opacity:0; transform:scale(2.8); filter:blur(30px);
23
+ transition:all 0.8s cubic-bezier(0.15,1.4,0.3,1.1);
24
+ }
25
+ #title.revealed { opacity:0.92; transform:scale(1); filter:blur(0); }
26
+ #replay {
27
+ position:absolute; bottom:90px; left:50%; transform:translateX(-50%);
28
+ padding:18px 55px; background:transparent; color:#ffeb3b; border:1px solid #ff980055;
29
+ border-radius:50px; font-size:18px; letter-spacing:4px; text-transform:uppercase; cursor:pointer;
30
+ z-index:20; opacity:0; pointer-events:none; transition:all 0.9s;
31
+ }
32
+ #replay.visible { opacity:1; pointer-events:auto; }
33
+ #replay:hover { color:#fff; border-color:#ff9800; background:rgba(255,152,0,0.2); }
34
+ </style>
35
+ </head>
36
+ <body>
37
+
38
+ <div id="canvas-container"></div>
39
+ <div id="flash"></div>
40
+ <div id="title-container"><h1 id="title">BOOM</h1></div>
41
+ <button id="replay">RETRY</button>
42
+
43
+ <script type="importmap">
44
+ {
45
+ "imports": {
46
+ "three": "https://cdn.jsdelivr.net/npm/three@0.168.0/build/three.module.js",
47
+ "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.168.0/examples/jsm/"
48
+ }
49
+ }
50
+ </script>
51
+
52
+ <script type="module">
53
+ import * as THREE from 'three';
54
+ import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
55
+ import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
56
+ import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
57
+
58
+ const container = document.getElementById('canvas-container');
59
+ const flashEl = document.getElementById('flash');
60
+ const titleEl = document.getElementById('title');
61
+ const replayBtn = document.getElementById('replay');
62
+
63
+ const scene = new THREE.Scene();
64
+ scene.background = new THREE.Color(0x0a0014);
65
+
66
+ const camera = new THREE.PerspectiveCamera(60, innerWidth/innerHeight, 0.5, 4000);
67
+ camera.position.set(0, 0, 14); // bit farther for better view of propagation
68
+
69
+ const renderer = new THREE.WebGLRenderer({antialias:false, powerPreference:"high-performance"});
70
+ renderer.setSize(innerWidth, innerHeight);
71
+ renderer.setPixelRatio(Math.min(devicePixelRatio, 1.3));
72
+ container.appendChild(renderer.domElement);
73
+
74
+ const composer = new EffectComposer(renderer);
75
+ composer.addPass(new RenderPass(scene, camera));
76
+
77
+ const bloom = new UnrealBloomPass(new THREE.Vector2(innerWidth, innerHeight), 0.7, 0.2, 0.85);
78
+ bloom.threshold = 0.7;
79
+ composer.addPass(bloom);
80
+
81
+ // ─── Particles with staggered birth ───
82
+ const COUNT = 2000;
83
+ const geo = new THREE.BufferGeometry();
84
+ const pos = new Float32Array(COUNT*3);
85
+ const vel = new Float32Array(COUNT*3);
86
+ const col = new Float32Array(COUNT*3);
87
+ const siz = new Float32Array(COUNT);
88
+ const birth = new Float32Array(COUNT);
89
+
90
+ const palette = [
91
+ new THREE.Color(0xff6600),
92
+ new THREE.Color(0xff3300),
93
+ new THREE.Color(0xff9900),
94
+ new THREE.Color(0xffcc00),
95
+ new THREE.Color(0xff4422)
96
+ ];
97
+
98
+ for(let i = 0; i < COUNT; i++){
99
+ // start clustered near center
100
+ pos[i*3 ] = (Math.random() - 0.5) * 0.6;
101
+ pos[i*3+1] = (Math.random() - 0.5) * 0.6;
102
+ pos[i*3+2] = (Math.random() - 0.5) * 0.6;
103
+
104
+ const dist = Math.hypot(pos[i*3], pos[i*3+1], pos[i*3+2]) || 0.01;
105
+
106
+ // outward direction + speed scaling with distance (faster outer particles)
107
+ let dx = pos[i*3 ] / dist;
108
+ let dy = pos[i*3+1] / dist;
109
+ let dz = pos[i*3+2] / dist;
110
+ const speed = 18 + dist * 45 + Math.random() * 15;
111
+ vel[i*3 ] = dx * speed;
112
+ vel[i*3+1] = dy * speed;
113
+ vel[i*3+2] = dz * speed;
114
+
115
+ const c = palette[Math.floor(Math.random() * palette.length)];
116
+ const bright = 0.65 + Math.random() * 0.35;
117
+ col[i*3] = c.r * bright;
118
+ col[i*3+1] = c.g * bright;
119
+ col[i*3+2] = c.b * bright;
120
+
121
+ siz[i] = 9 + Math.random() * 14;
122
+
123
+ // KEY CHANGE: stagger birth strongly β€” central particles first, outer later
124
+ birth[i] = - (dist * 1.2 + Math.random() * 0.5);
125
+ }
126
+
127
+ geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
128
+ geo.setAttribute('velocity', new THREE.BufferAttribute(vel, 3));
129
+ geo.setAttribute('color', new THREE.BufferAttribute(col, 3));
130
+ geo.setAttribute('size', new THREE.BufferAttribute(siz, 1));
131
+ geo.setAttribute('birthTime', new THREE.BufferAttribute(birth, 1));
132
+
133
+ const mat = new THREE.ShaderMaterial({
134
+ uniforms: { uTime: {value:0} },
135
+ vertexShader: `
136
+ attribute vec3 velocity;
137
+ attribute vec3 color;
138
+ attribute float size;
139
+ attribute float birthTime;
140
+ varying vec3 vColor;
141
+ varying float vAlpha;
142
+ uniform float uTime;
143
+ void main(){
144
+ vColor = color;
145
+ float age = uTime - birthTime;
146
+ if(age < 0.0){ gl_Position=vec4(10000.0); vAlpha=0.0; return; }
147
+
148
+ float t = clamp(age * 1.3, 0.0, 1.0);
149
+ float eased = 1.0 - pow(1.0 - t, 2.5); // quick start, then decelerate
150
+
151
+ vec3 p = position + velocity * eased * 0.9;
152
+
153
+ float scale = 1.0 + (1.0 - eased) * 10.0; // bigger at birth
154
+
155
+ vec4 mv = modelViewMatrix * vec4(p, 1.0);
156
+ gl_PointSize = size * scale * (280.0 / -mv.z);
157
+ gl_Position = projectionMatrix * mv;
158
+
159
+ vAlpha = 1.0 - eased * eased; // smooth fade
160
+ }
161
+ `,
162
+ fragmentShader: `
163
+ varying vec3 vColor;
164
+ varying float vAlpha;
165
+ void main(){
166
+ vec2 c = gl_PointCoord - 0.5;
167
+ float d = length(c);
168
+ if(d > 0.5) discard;
169
+ gl_FragColor = vec4(vColor, (1.0 - d*d*1.8) * vAlpha * 0.95);
170
+ }
171
+ `,
172
+ transparent: true,
173
+ blending: THREE.AdditiveBlending,
174
+ depthWrite: false
175
+ });
176
+
177
+ scene.add(new THREE.Points(geo, mat));
178
+
179
+ // ─── Animation & Sequence ───
180
+ const clock = new THREE.Clock();
181
+ let time = 0;
182
+
183
+ function resetExplosion() {
184
+ time = 0;
185
+ titleEl.classList.remove('revealed');
186
+ flashEl.classList.remove('active','fade-out');
187
+ replayBtn.classList.remove('visible');
188
+ const bt = geo.attributes.birthTime.array;
189
+ for(let i = 0; i < COUNT; i++) {
190
+ const dist = Math.hypot(pos[i*3], pos[i*3+1], pos[i*3+2]) || 0.01;
191
+ bt[i] = - (dist * 1.2 + Math.random() * 0.5);
192
+ }
193
+ geo.attributes.birthTime.needsUpdate = true;
194
+ }
195
+
196
+ function explode() {
197
+ resetExplosion();
198
+
199
+ setTimeout(() => {
200
+ flashEl.classList.add('active');
201
+ bloom.strength = 1.3;
202
+
203
+ setTimeout(() => flashEl.classList.add('fade-out'), 500);
204
+
205
+ setTimeout(() => {
206
+ bloom.strength = 0.55;
207
+ titleEl.classList.add('revealed');
208
+ setTimeout(() => replayBtn.classList.add('visible'), 200);
209
+ }, 70);
210
+ }, 30);
211
+ }
212
+
213
+ function animate() {
214
+ requestAnimationFrame(animate);
215
+ time += clock.getDelta();
216
+ mat.uniforms.uTime.value = time;
217
+
218
+ if(time > 3.5) bloom.strength = 0.55 + Math.sin(time * 1.1) * 0.1;
219
+
220
+ composer.render();
221
+ }
222
+
223
+ animate();
224
+ explode();
225
+
226
+ replayBtn.addEventListener('click', explode);
227
+
228
+ window.addEventListener('resize', () => {
229
+ camera.aspect = innerWidth / innerHeight;
230
+ camera.updateProjectionMatrix();
231
+ renderer.setSize(innerWidth, innerHeight);
232
+ composer.setSize(innerWidth, innerHeight);
233
+ });
234
+ </script>
235
+ </body>
236
+ </html>