-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathindex.html
More file actions
293 lines (252 loc) · 12.9 KB
/
index.html
File metadata and controls
293 lines (252 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>JJK: Cursed Technique</title>
<style>
body { margin: 0; overflow: hidden; background-color: #000; font-family: 'Courier New', sans-serif; }
#ui {
position: absolute;
top: 10%;
width: 100%;
text-align: center;
color: #fff;
pointer-events: none;
z-index: 10;
}
h1 {
font-size: 3rem; margin: 0; letter-spacing: 10px;
font-weight: 900;
text-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
background: linear-gradient(to bottom, #fff, #888);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
#technique-name {
font-size: 1.2rem; color: #00ffff; margin-top: 15px;
font-weight: bold; letter-spacing: 4px;
text-transform: uppercase;
text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}
/* Large Centered Camera Hub - Taller for Reel Context */
#video-container {
position: absolute;
bottom: 2%;
left: 18%;
transform: translateX(-50%) scaleX(-1);
width: 85vw;
max-width: 450px;
height: 42vh;
border: 2px solid rgba(255, 255, 255, 0.2);
z-index: 20;
background-color: #000;
border-radius: 25px;
overflow: hidden;
box-shadow: 0 0 40px rgba(0,0,0,0.9);
}
video { width: 100%; height: 100%; object-fit: cover; opacity: 0.8; }
#output_canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
#grain {
position: fixed; top: 0; left: 0; width: 100%; height: 100%;
pointer-events: none; z-index: 5;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.08'/%3E%3C/svg%3E");
}
</style>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.160.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
}
}
</script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/camera_utils/camera_utils.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/hands/hands.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@mediapipe/drawing_utils/drawing_utils.js" crossorigin="anonymous"></script>
</head>
<body>
<div id="grain"></div>
<div id="ui">
<h1>呪術廻戦</h1>
<div id="technique-name">CURSED ENERGY</div>
</div>
<div id="video-container">
<video class="input_video"></video>
<canvas id="output_canvas"></canvas>
</div>
<script type="module">
import * as THREE from 'three';
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
// --- Scene & Rendering ---
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 55;
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
document.body.appendChild(renderer.domElement);
const composer = new EffectComposer(renderer);
composer.addPass(new RenderPass(scene, camera));
const bloomPass = new UnrealBloomPass(new THREE.Vector2(window.innerWidth, window.innerHeight), 1.5, 0.4, 0.85);
composer.addPass(bloomPass);
const COUNT = 20000;
const geometry = new THREE.BufferGeometry();
const positions = new Float32Array(COUNT * 3);
const colors = new Float32Array(COUNT * 3);
const sizes = new Float32Array(COUNT);
const targetPositions = new Float32Array(COUNT * 3);
const targetColors = new Float32Array(COUNT * 3);
const targetSizes = new Float32Array(COUNT);
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
geometry.setAttribute('size', new THREE.BufferAttribute(sizes, 1));
const particles = new THREE.Points(geometry, new THREE.PointsMaterial({ size: 0.3, vertexColors: true, blending: THREE.AdditiveBlending, transparent: true, depthWrite: false }));
scene.add(particles);
// Technique Functions
function getRed(i) {
if(i < COUNT * 0.1) {
const r = Math.random() * 9;
const theta = Math.random() * 6.28; const phi = Math.acos(2 * Math.random() - 1);
return { x: r * Math.sin(phi) * Math.cos(theta), y: r * Math.sin(phi) * Math.sin(theta), z: r * Math.cos(phi), r: 3, g: 0.1, b: 0.1, s: 2.5 };
} else {
const armCount = 3; const t = (i / COUNT);
const angle = t * 15 + ((i % armCount) * (Math.PI * 2 / armCount));
const radius = 2 + (t * 40);
return { x: radius * Math.cos(angle), y: radius * Math.sin(angle), z: (Math.random() - 0.5) * (10 * t), r: 0.8, g: 0, b: 0, s: 1.0 };
}
}
function getVoid(i) {
if (i < COUNT * 0.15) {
const angle = Math.random() * Math.PI * 2;
return { x: 26 * Math.cos(angle), y: 26 * Math.sin(angle), z: (Math.random()-0.5) * 1, r: 1, g: 1, b: 1, s: 2.5 };
} else {
const radius = 30 + Math.random() * 90;
const theta = Math.random() * Math.PI * 2;
const phi = Math.acos(2 * Math.random() - 1);
return { x: radius * Math.sin(phi) * Math.cos(theta), y: radius * Math.sin(phi) * Math.sin(theta), z: radius * Math.cos(phi), r: 0.1, g: 0.6, b: 1.0, s: 0.7 };
}
}
function getPurple(i) {
if (Math.random() > 0.8) return { x: (Math.random() - 0.5) * 100, y: (Math.random() - 0.5) * 100, z: (Math.random() - 0.5) * 100, r: 0.5, g: 0.5, b: 0.7, s: 0.8 };
const r = 20; const theta = Math.random() * Math.PI * 2; const phi = Math.acos(2 * Math.random() - 1);
return { x: r * Math.sin(phi) * Math.cos(theta), y: r * Math.sin(phi) * Math.sin(theta), z: r * Math.cos(phi), r: 0.6, g: 0.5, b: 1.0, s: 2.5 };
}
function getShrine(i) {
const total = COUNT;
if (i < total * 0.3) return { x: (Math.random()-0.5)*80, y: -15, z: (Math.random()-0.5)*80, r: 0.4, g: 0, b: 0, s: 0.8 };
else if (i < total * 0.4) {
const px = ((i%4)<2?1:-1)*12; const pz = ((i%4)%2==0?1:-1)*8;
return { x: px+(Math.random()-0.5)*2, y: -15+Math.random()*30, z: pz+(Math.random()-0.5)*2, r: 0.2, g: 0.2, b: 0.2, s: 0.6 };
} else if (i < total * 0.6) {
const t = Math.random() * Math.PI * 2; const rad = Math.random() * 30;
const curve = Math.pow(rad/30, 2) * 10;
return { x: rad*Math.cos(t), y: 15 - curve + (Math.random()*2), z: rad*Math.sin(t)*0.6, r: 0.6, g: 0, b: 0, s: 0.6 };
} else return { x: 0, y: 0, z: 0, r: 0, g: 0, b: 0, s: 0 };
}
// Hand Tracking
let currentTech = 'neutral';
let shakeIntensity = 0;
const videoElement = document.querySelector('.input_video');
const canvasElement = document.getElementById('output_canvas');
const canvasCtx = canvasElement.getContext('2d');
let glowColor = '#00ffff';
const hands = new Hands({locateFile: (file) => `https://cdn.jsdelivr.net/npm/@mediapipe/hands/${file}`});
hands.setOptions({ maxNumHands: 2, modelComplexity: 1, minDetectionConfidence: 0.7 });
hands.onResults((results) => {
canvasCtx.clearRect(0, 0, canvasElement.width, canvasElement.height);
let detected = 'neutral';
if (results.multiHandLandmarks) {
results.multiHandLandmarks.forEach((lm) => {
drawConnectors(canvasCtx, lm, HAND_CONNECTIONS, {color: glowColor, lineWidth: 5});
drawLandmarks(canvasCtx, lm, {color: '#fff', lineWidth: 1, radius: 2});
const isUp = (t, p) => lm[t].y < lm[p].y;
const pinch = Math.hypot(lm[8].x - lm[4].x, lm[8].y - lm[4].y);
if (pinch < 0.04) detected = 'purple';
else if (isUp(8,6) && isUp(12,10) && isUp(16,14) && isUp(20,18)) detected = 'shrine';
else if (isUp(8,6) && isUp(12,10) && !isUp(16,14)) detected = 'void';
else if (isUp(8,6) && !isUp(12,10)) detected = 'red';
});
}
updateState(detected);
});
function updateState(tech) {
if(currentTech === tech) return;
currentTech = tech;
const nameEl = document.getElementById('technique-name');
shakeIntensity = tech !== 'neutral' ? 0.4 : 0;
if(tech === 'shrine') { glowColor = '#ff0000'; nameEl.innerText = "Domain Expansion: Malevolent Shrine"; bloomPass.strength = 2.5; }
else if(tech === 'purple') { glowColor = '#bb00ff'; nameEl.innerText = "Secret Technique: Hollow Purple"; bloomPass.strength = 4.0; }
else if(tech === 'void') { glowColor = '#00ffff'; nameEl.innerText = "Domain Expansion: Infinite Void"; bloomPass.strength = 2.0; }
else if(tech === 'red') { glowColor = '#ff3333'; nameEl.innerText = "Reverse Cursed Technique: Red"; bloomPass.strength = 2.5; }
else { glowColor = '#00ffff'; nameEl.innerText = "Neutral State"; bloomPass.strength = 1.0; }
for(let i=0; i<COUNT; i++) {
let p;
if(tech === 'neutral') {
if(i < COUNT * 0.05) {
const r = 15 + Math.random()*20; const t = Math.random()*6.28; const ph = Math.random()*3.14;
p = { x: r*Math.sin(ph)*Math.cos(t), y: r*Math.sin(ph)*Math.sin(t), z: r*Math.cos(ph), r: 0.1, g: 0.1, b: 0.2, s: 0.4 };
} else p = { x:0, y:0, z:0, r:0, g:0, b:0, s:0 };
}
else if(tech === 'red') p = getRed(i);
else if(tech === 'void') p = getVoid(i);
else if(tech === 'purple') p = getPurple(i);
else if(tech === 'shrine') p = getShrine(i);
targetPositions[i*3] = p.x; targetPositions[i*3+1] = p.y; targetPositions[i*3+2] = p.z;
targetColors[i*3] = p.r; targetColors[i*3+1] = p.g; targetColors[i*3+2] = p.b;
targetSizes[i] = p.s;
}
}
const cameraUtils = new Camera(videoElement, {
onFrame: async () => {
canvasElement.width = videoElement.videoWidth;
canvasElement.height = videoElement.videoHeight;
await hands.send({image: videoElement});
}, width: 640, height: 480
});
cameraUtils.start();
// Animation
function animate() {
requestAnimationFrame(animate);
if (shakeIntensity > 0) {
renderer.domElement.style.transform = `translate(${(Math.random()-0.5)*shakeIntensity*40}px, ${(Math.random()-0.5)*shakeIntensity*40}px)`;
} else {
renderer.domElement.style.transform = 'translate(0,0)';
}
const pos = particles.geometry.attributes.position.array;
const col = particles.geometry.attributes.color.array;
const siz = particles.geometry.attributes.size.array;
for(let i=0; i<COUNT*3; i++) {
pos[i] += (targetPositions[i] - pos[i]) * 0.1;
col[i] += (targetColors[i] - col[i]) * 0.1;
}
for(let i=0; i<COUNT; i++) siz[i] += (targetSizes[i] - siz[i]) * 0.1;
particles.geometry.attributes.position.needsUpdate = true;
particles.geometry.attributes.color.needsUpdate = true;
particles.geometry.attributes.size.needsUpdate = true;
// UPDATED ROTATION LOGIC: Locking rotation for Shrine
if(currentTech === 'red') {
particles.rotation.z -= 0.1;
} else if (currentTech === 'purple') {
particles.rotation.z += 0.2;
particles.rotation.y += 0.05;
} else if (currentTech === 'shrine') {
// FORCE UPRIGHT: Reset and freeze all rotations
particles.rotation.set(0, 0, 0);
} else {
// Default Neutral rotation
particles.rotation.y += 0.005;
}
composer.render();
}
animate();
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
composer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>