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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>MS1-V</title>
|
| 7 |
+
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@500&display=swap" rel="stylesheet">
|
| 8 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
| 9 |
+
<style>
|
| 10 |
+
* {
|
| 11 |
+
margin: 0;
|
| 12 |
+
padding: 0;
|
| 13 |
+
box-sizing: border-box;
|
| 14 |
+
}
|
| 15 |
+
body {
|
| 16 |
+
overflow: hidden;
|
| 17 |
+
background: #000;
|
| 18 |
+
font-family: 'Orbitron', sans-serif;
|
| 19 |
+
}
|
| 20 |
+
canvas {
|
| 21 |
+
position: fixed;
|
| 22 |
+
top: 0;
|
| 23 |
+
left: 0;
|
| 24 |
+
}
|
| 25 |
+
.title-screen {
|
| 26 |
+
position: fixed;
|
| 27 |
+
top: 0;
|
| 28 |
+
left: 0;
|
| 29 |
+
width: 100%;
|
| 30 |
+
height: 100%;
|
| 31 |
+
background: #000;
|
| 32 |
+
display: flex;
|
| 33 |
+
justify-content: center;
|
| 34 |
+
align-items: center;
|
| 35 |
+
flex-direction: column;
|
| 36 |
+
color: #0ff;
|
| 37 |
+
text-align: center;
|
| 38 |
+
z-index: 20;
|
| 39 |
+
transition: opacity 1s ease-in-out;
|
| 40 |
+
}
|
| 41 |
+
.title-screen h1 {
|
| 42 |
+
font-size: 5em;
|
| 43 |
+
margin-bottom: 20px;
|
| 44 |
+
}
|
| 45 |
+
.title-screen button {
|
| 46 |
+
padding: 15px 30px;
|
| 47 |
+
background: rgba(0, 255, 255, 0.2);
|
| 48 |
+
border: 2px solid #0ff;
|
| 49 |
+
color: #0ff;
|
| 50 |
+
cursor: pointer;
|
| 51 |
+
font-size: 1.2em;
|
| 52 |
+
border-radius: 10px;
|
| 53 |
+
transition: all 0.3s;
|
| 54 |
+
}
|
| 55 |
+
.title-screen button:hover {
|
| 56 |
+
background: #0ff;
|
| 57 |
+
color: #000;
|
| 58 |
+
}
|
| 59 |
+
.interface {
|
| 60 |
+
position: fixed;
|
| 61 |
+
top: 20px;
|
| 62 |
+
left: 20px;
|
| 63 |
+
background: rgba(0, 0, 0, 0.8);
|
| 64 |
+
border: 2px solid #0ff;
|
| 65 |
+
padding: 20px;
|
| 66 |
+
color: #0ff;
|
| 67 |
+
z-index: 10;
|
| 68 |
+
display: none;
|
| 69 |
+
border-radius: 15px;
|
| 70 |
+
backdrop-filter: blur(5px);
|
| 71 |
+
}
|
| 72 |
+
.controls {
|
| 73 |
+
margin-top: 15px;
|
| 74 |
+
display: flex;
|
| 75 |
+
gap: 10px;
|
| 76 |
+
}
|
| 77 |
+
.controls button {
|
| 78 |
+
flex: 1;
|
| 79 |
+
padding: 12px;
|
| 80 |
+
background: rgba(0, 255, 255, 0.2);
|
| 81 |
+
border: 1px solid #0ff;
|
| 82 |
+
color: #0ff;
|
| 83 |
+
cursor: pointer;
|
| 84 |
+
transition: all 0.3s;
|
| 85 |
+
border-radius: 8px;
|
| 86 |
+
text-transform: uppercase;
|
| 87 |
+
letter-spacing: 1px;
|
| 88 |
+
}
|
| 89 |
+
.controls button:hover {
|
| 90 |
+
background: #0ff;
|
| 91 |
+
color: #000;
|
| 92 |
+
}
|
| 93 |
+
.toggle-button {
|
| 94 |
+
position: fixed;
|
| 95 |
+
top: 20px;
|
| 96 |
+
right: 20px;
|
| 97 |
+
padding: 12px 20px;
|
| 98 |
+
background: rgba(0, 255, 255, 0.2);
|
| 99 |
+
color: #0ff;
|
| 100 |
+
border: 1px solid #0ff;
|
| 101 |
+
cursor: pointer;
|
| 102 |
+
z-index: 10;
|
| 103 |
+
border-radius: 8px;
|
| 104 |
+
text-transform: uppercase;
|
| 105 |
+
letter-spacing: 1px;
|
| 106 |
+
}
|
| 107 |
+
.toggle-button:hover {
|
| 108 |
+
background: #0ff;
|
| 109 |
+
color: #000;
|
| 110 |
+
}
|
| 111 |
+
.track-list {
|
| 112 |
+
margin-top: 20px;
|
| 113 |
+
}
|
| 114 |
+
.track-list select {
|
| 115 |
+
padding: 10px;
|
| 116 |
+
background: rgba(0, 255, 255, 0.2);
|
| 117 |
+
border: 1px solid #0ff;
|
| 118 |
+
color: #0ff;
|
| 119 |
+
border-radius: 8px;
|
| 120 |
+
width: 100%;
|
| 121 |
+
}
|
| 122 |
+
</style>
|
| 123 |
+
</head>
|
| 124 |
+
<body>
|
| 125 |
+
<div class="title-screen" id="titleScreen">
|
| 126 |
+
<h1>MS1-V</h1>
|
| 127 |
+
<button id="startButton">Start</button>
|
| 128 |
+
</div>
|
| 129 |
+
<button class="toggle-button">Controls</button>
|
| 130 |
+
<div class="interface">
|
| 131 |
+
<input type="file" id="audioFile" accept="audio/*">
|
| 132 |
+
<div class="track-list">
|
| 133 |
+
<label for="trackSelect">Select Track:</label>
|
| 134 |
+
<select id="trackSelect">
|
| 135 |
+
<option value="">Select a track</option>
|
| 136 |
+
<option value="track1.mp3">Track 1</option>
|
| 137 |
+
<option value="track2.mp3">Track 2</option>
|
| 138 |
+
<option value="track3.mp3">Track 3</option>
|
| 139 |
+
</select>
|
| 140 |
+
</div>
|
| 141 |
+
<div class="controls">
|
| 142 |
+
<button id="play">Play</button>
|
| 143 |
+
<button id="pause">Pause</button>
|
| 144 |
+
<button id="stop">Stop</button>
|
| 145 |
+
</div>
|
| 146 |
+
</div>
|
| 147 |
+
<script>
|
| 148 |
+
const scene = new THREE.Scene();
|
| 149 |
+
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 2000);
|
| 150 |
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
| 151 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 152 |
+
document.body.appendChild(renderer.domElement);
|
| 153 |
+
|
| 154 |
+
let isDragging = false;
|
| 155 |
+
let previousMousePosition = { x: 0, y: 0 };
|
| 156 |
+
let cameraAngle = { x: 0, y: 0 };
|
| 157 |
+
const cameraDistance = 100;
|
| 158 |
+
|
| 159 |
+
document.addEventListener('mousedown', (e) => {
|
| 160 |
+
isDragging = true;
|
| 161 |
+
previousMousePosition = { x: e.clientX, y: e.clientY };
|
| 162 |
+
});
|
| 163 |
+
|
| 164 |
+
document.addEventListener('mousemove', (e) => {
|
| 165 |
+
if (!isDragging) return;
|
| 166 |
+
|
| 167 |
+
const deltaMove = {
|
| 168 |
+
x: e.clientX - previousMousePosition.x,
|
| 169 |
+
y: e.clientY - previousMousePosition.y
|
| 170 |
+
};
|
| 171 |
+
|
| 172 |
+
cameraAngle.x += deltaMove.y * 0.005;
|
| 173 |
+
cameraAngle.y += deltaMove.x * 0.005;
|
| 174 |
+
|
| 175 |
+
cameraAngle.x = Math.max(-Math.PI/2, Math.min(Math.PI/2, cameraAngle.x));
|
| 176 |
+
|
| 177 |
+
previousMousePosition = { x: e.clientX, y: e.clientY };
|
| 178 |
+
});
|
| 179 |
+
|
| 180 |
+
document.addEventListener('mouseup', () => {
|
| 181 |
+
isDragging = false;
|
| 182 |
+
});
|
| 183 |
+
|
| 184 |
+
const lineMaterial = new THREE.LineBasicMaterial({
|
| 185 |
+
color: 0x00ffff,
|
| 186 |
+
transparent: true,
|
| 187 |
+
opacity: 0.3,
|
| 188 |
+
blending: THREE.AdditiveBlending
|
| 189 |
+
});
|
| 190 |
+
|
| 191 |
+
function createBassPattern(frequency, intensity) {
|
| 192 |
+
const pattern = new THREE.Group();
|
| 193 |
+
const geometry = new THREE.TorusKnotGeometry(10 * intensity, 2, 100, 16);
|
| 194 |
+
const material = new THREE.MeshBasicMaterial({
|
| 195 |
+
color: 0x00ffff,
|
| 196 |
+
wireframe: true,
|
| 197 |
+
transparent: true,
|
| 198 |
+
opacity: intensity
|
| 199 |
+
});
|
| 200 |
+
const torusKnot = new THREE.Mesh(geometry, material);
|
| 201 |
+
pattern.add(torusKnot);
|
| 202 |
+
|
| 203 |
+
for(let i = 0; i < 3; i++) {
|
| 204 |
+
const sphereGeo = new THREE.SphereGeometry(5 * intensity, 32, 32);
|
| 205 |
+
const sphereMat = new THREE.MeshBasicMaterial({
|
| 206 |
+
color: 0x00ffff,
|
| 207 |
+
wireframe: true,
|
| 208 |
+
transparent: true,
|
| 209 |
+
opacity: intensity * 0.5
|
| 210 |
+
});
|
| 211 |
+
const sphere = new THREE.Mesh(sphereGeo, sphereMat);
|
| 212 |
+
sphere.position.setFromSphericalCoords(
|
| 213 |
+
20 * intensity,
|
| 214 |
+
i * Math.PI * 2/3,
|
| 215 |
+
frequency * Math.PI
|
| 216 |
+
);
|
| 217 |
+
pattern.add(sphere);
|
| 218 |
+
}
|
| 219 |
+
return pattern;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
function createParticleSystem(count, size, spread) {
|
| 223 |
+
const geometry = new THREE.BufferGeometry();
|
| 224 |
+
const positions = new Float32Array(count * 3);
|
| 225 |
+
const colors = new Float32Array(count * 3);
|
| 226 |
+
const scales = new Float32Array(count);
|
| 227 |
+
|
| 228 |
+
for(let i = 0; i < count * 3; i += 3) {
|
| 229 |
+
positions[i] = (Math.random() - 0.5) * spread;
|
| 230 |
+
positions[i + 1] = (Math.random() - 0.5) * spread;
|
| 231 |
+
positions[i + 2] = (Math.random() - 0.5) * spread;
|
| 232 |
+
scales[i/3] = Math.random();
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
|
| 236 |
+
geometry.setAttribute('color', new THREE.BufferAttribute(colors, 3));
|
| 237 |
+
geometry.setAttribute('scale', new THREE.BufferAttribute(scales, 1));
|
| 238 |
+
|
| 239 |
+
const material = new THREE.PointsMaterial({
|
| 240 |
+
size: size,
|
| 241 |
+
vertexColors: true,
|
| 242 |
+
blending: THREE.AdditiveBlending,
|
| 243 |
+
transparent: true,
|
| 244 |
+
opacity: 0.8,
|
| 245 |
+
});
|
| 246 |
+
|
| 247 |
+
const particles = new THREE.Points(geometry, material);
|
| 248 |
+
const lines = new THREE.LineSegments(new THREE.BufferGeometry(), lineMaterial);
|
| 249 |
+
|
| 250 |
+
return { particles, lines };
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
const innerSystem = createParticleSystem(3000, 0.5, 80);
|
| 254 |
+
const midSystem = createParticleSystem(4000, 0.3, 150);
|
| 255 |
+
const outerSystem = createParticleSystem(5000, 0.2, 200);
|
| 256 |
+
const bassSystem = createParticleSystem(2000, 1.0, 100);
|
| 257 |
+
|
| 258 |
+
let bassPattern = null;
|
| 259 |
+
|
| 260 |
+
[innerSystem, midSystem, outerSystem, bassSystem].forEach(system => {
|
| 261 |
+
scene.add(system.particles);
|
| 262 |
+
scene.add(system.lines);
|
| 263 |
+
});
|
| 264 |
+
|
| 265 |
+
camera.position.z = cameraDistance;
|
| 266 |
+
|
| 267 |
+
function updateParticleSystem(system, frequencyData, baseIndex, scale, bass, time) {
|
| 268 |
+
const positions = system.particles.geometry.attributes.position.array;
|
| 269 |
+
const colors = system.particles.geometry.attributes.color.array;
|
| 270 |
+
const scales = system.particles.geometry.attributes.scale.array;
|
| 271 |
+
|
| 272 |
+
const evolutionFactor = Math.sin(time * 0.0005) * 0.5 + 0.5;
|
| 273 |
+
|
| 274 |
+
const linePositions = [];
|
| 275 |
+
const lineIndices = [];
|
| 276 |
+
|
| 277 |
+
for(let i = 0; i < positions.length; i += 3) {
|
| 278 |
+
const freqIndex = (baseIndex + Math.floor(i/30)) % frequencyData.length;
|
| 279 |
+
const frequency = frequencyData[freqIndex] / 255;
|
| 280 |
+
|
| 281 |
+
const angle = (i/3) * 0.1 + time * 0.001;
|
| 282 |
+
const radius = scale * (0.5 + 0.5 * frequency);
|
| 283 |
+
|
| 284 |
+
if(bass > 0.7) {
|
| 285 |
+
const bassImpact = Math.pow(bass - 0.7, 2);
|
| 286 |
+
positions[i] = Math.cos(angle) * radius * Math.sin(angle * 2 + evolutionFactor) * (1 + bassImpact);
|
| 287 |
+
positions[i + 1] = Math.sin(angle) * radius * Math.cos(angle * 3 + evolutionFactor) * (1 + bassImpact);
|
| 288 |
+
positions[i + 2] = Math.cos(angle * 2) * radius * Math.sin(angle + evolutionFactor) * (1 + bassImpact);
|
| 289 |
+
} else {
|
| 290 |
+
positions[i] *= 1 + frequency * 0.02 * (1 + evolutionFactor);
|
| 291 |
+
positions[i + 1] *= 1 + frequency * 0.02 * (1 + evolutionFactor);
|
| 292 |
+
positions[i + 2] *= 1 + frequency * 0.02 * (1 + evolutionFactor);
|
| 293 |
+
}
|
| 294 |
+
|
| 295 |
+
const distance = Math.sqrt(positions[i]**2 + positions[i+1]**2 + positions[i+2]**2);
|
| 296 |
+
if(distance > scale) {
|
| 297 |
+
positions[i] *= scale/distance;
|
| 298 |
+
positions[i+1] *= scale/distance;
|
| 299 |
+
positions[i+2] *= scale/distance;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
colors[i] = Math.sin(frequency * Math.PI + bass + evolutionFactor) * 0.5 + 0.5;
|
| 303 |
+
colors[i + 1] = Math.cos(frequency * Math.PI * 0.5 + bass + evolutionFactor) * 0.5 + 0.5;
|
| 304 |
+
colors[i + 2] = frequency + bass * 0.5;
|
| 305 |
+
|
| 306 |
+
scales[i/3] = frequency * (2 + bass * 2) * (1 + evolutionFactor);
|
| 307 |
+
|
| 308 |
+
if(i % 9 === 0) {
|
| 309 |
+
linePositions.push(positions[i], positions[i+1], positions[i+2]);
|
| 310 |
+
if(linePositions.length > 6) {
|
| 311 |
+
lineIndices.push(linePositions.length/3 - 2, linePositions.length/3 - 1);
|
| 312 |
+
}
|
| 313 |
+
}
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
const lineGeometry = new THREE.BufferGeometry();
|
| 317 |
+
lineGeometry.setAttribute('position', new THREE.Float32BufferAttribute(linePositions, 3));
|
| 318 |
+
lineGeometry.setIndex(lineIndices);
|
| 319 |
+
system.lines.geometry.dispose();
|
| 320 |
+
system.lines.geometry = lineGeometry;
|
| 321 |
+
|
| 322 |
+
system.particles.geometry.attributes.position.needsUpdate = true;
|
| 323 |
+
system.particles.geometry.attributes.color.needsUpdate = true;
|
| 324 |
+
system.particles.geometry.attributes.scale.needsUpdate = true;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
let audioContext, audioAnalyser, audioSource;
|
| 328 |
+
let audioElement = new Audio();
|
| 329 |
+
|
| 330 |
+
document.getElementById('audioFile').addEventListener('change', function(event) {
|
| 331 |
+
audioElement.src = URL.createObjectURL(event.target.files[0]);
|
| 332 |
+
});
|
| 333 |
+
|
| 334 |
+
document.getElementById('trackSelect').addEventListener('change', function(event) {
|
| 335 |
+
audioElement.src = event.target.value;
|
| 336 |
+
});
|
| 337 |
+
|
| 338 |
+
document.getElementById('startButton').addEventListener('click', () => {
|
| 339 |
+
document.getElementById('titleScreen').style.opacity = 0;
|
| 340 |
+
setTimeout(() => {
|
| 341 |
+
document.getElementById('titleScreen').style.display = 'none';
|
| 342 |
+
}, 1000);
|
| 343 |
+
});
|
| 344 |
+
|
| 345 |
+
document.getElementById('play').addEventListener('click', () => audioElement.play());
|
| 346 |
+
document.getElementById('pause').addEventListener('click', () => audioElement.pause());
|
| 347 |
+
document.getElementById('stop').addEventListener('click', () => {
|
| 348 |
+
audioElement.pause();
|
| 349 |
+
audioElement.currentTime = 0;
|
| 350 |
+
});
|
| 351 |
+
|
| 352 |
+
document.querySelector('.toggle-button').addEventListener('click', () => {
|
| 353 |
+
const interfaceDiv = document.querySelector('.interface');
|
| 354 |
+
interfaceDiv.style.display = interfaceDiv.style.display === 'none' ? 'block' : 'none';
|
| 355 |
+
});
|
| 356 |
+
|
| 357 |
+
audioElement.addEventListener('play', () => {
|
| 358 |
+
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 359 |
+
audioSource = audioContext.createMediaElementSource(audioElement);
|
| 360 |
+
audioAnalyser = audioContext.createAnalyser();
|
| 361 |
+
audioSource.connect(audioAnalyser);
|
| 362 |
+
audioAnalyser.connect(audioContext.destination);
|
| 363 |
+
audioAnalyser.fftSize = 2048;
|
| 364 |
+
const bufferLength = audioAnalyser.frequencyBinCount;
|
| 365 |
+
const dataArray = new Uint8Array(bufferLength);
|
| 366 |
+
|
| 367 |
+
function animate() {
|
| 368 |
+
requestAnimationFrame(animate);
|
| 369 |
+
const time = Date.now();
|
| 370 |
+
audioAnalyser.getByteFrequencyData(dataArray);
|
| 371 |
+
|
| 372 |
+
const bass = Math.max(...dataArray.slice(0, 10)) / 255;
|
| 373 |
+
const mid = Math.max(...dataArray.slice(10, 100)) / 255;
|
| 374 |
+
const treble = Math.max(...dataArray.slice(100, 200)) / 255;
|
| 375 |
+
|
| 376 |
+
camera.position.x = cameraDistance * Math.sin(cameraAngle.y) * Math.cos(cameraAngle.x);
|
| 377 |
+
camera.position.y = cameraDistance * Math.sin(cameraAngle.x);
|
| 378 |
+
camera.position.z = cameraDistance * Math.cos(cameraAngle.y) * Math.cos(cameraAngle.x);
|
| 379 |
+
camera.lookAt(scene.position);
|
| 380 |
+
|
| 381 |
+
if(bass > 0.7) {
|
| 382 |
+
if(!bassPattern) {
|
| 383 |
+
bassPattern = createBassPattern(bass, bass - 0.7);
|
| 384 |
+
scene.add(bassPattern);
|
| 385 |
+
}
|
| 386 |
+
bassPattern.scale.set(1 + bass, 1 + bass, 1 + bass);
|
| 387 |
+
bassPattern.rotation.x += 0.02;
|
| 388 |
+
bassPattern.rotation.y += 0.03;
|
| 389 |
+
} else if(bassPattern) {
|
| 390 |
+
scene.remove(bassPattern);
|
| 391 |
+
bassPattern = null;
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
updateParticleSystem(innerSystem, dataArray, 0, 80, bass, time);
|
| 395 |
+
updateParticleSystem(midSystem, dataArray, 100, 150, bass, time);
|
| 396 |
+
updateParticleSystem(outerSystem, dataArray, 200, 200, bass, time);
|
| 397 |
+
updateParticleSystem(bassSystem, dataArray.slice(0, 10), 0, 100 * bass, bass, time);
|
| 398 |
+
|
| 399 |
+
innerSystem.particles.rotation.y += 0.003 * (1 + bass * 0.5);
|
| 400 |
+
midSystem.particles.rotation.x += 0.002 * (1 + mid * 0.5);
|
| 401 |
+
outerSystem.particles.rotation.z += 0.001 * (1 + treble * 0.5);
|
| 402 |
+
if(bassSystem.particles) {
|
| 403 |
+
bassSystem.particles.rotation.y -= 0.005 * (1 + bass);
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
renderer.render(scene, camera);
|
| 407 |
+
}
|
| 408 |
+
animate();
|
| 409 |
+
});
|
| 410 |
+
|
| 411 |
+
window.addEventListener('resize', () => {
|
| 412 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
| 413 |
+
camera.updateProjectionMatrix();
|
| 414 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 415 |
+
});
|
| 416 |
+
</script>
|
| 417 |
+
</body>
|
| 418 |
</html>
|