lass mich das netz mit der Maus bewegen!
Browse files- index.html +45 -2
index.html
CHANGED
|
@@ -285,15 +285,58 @@
|
|
| 285 |
|
| 286 |
renderer.render(scene, camera);
|
| 287 |
}
|
| 288 |
-
|
| 289 |
function onWindowResize() {
|
| 290 |
camera.aspect = window.innerWidth / window.innerHeight;
|
| 291 |
camera.updateProjectionMatrix();
|
| 292 |
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 293 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
|
| 295 |
// Initialize the visualization
|
| 296 |
init();
|
| 297 |
-
|
|
|
|
| 298 |
</body>
|
| 299 |
</html>
|
|
|
|
| 285 |
|
| 286 |
renderer.render(scene, camera);
|
| 287 |
}
|
|
|
|
| 288 |
function onWindowResize() {
|
| 289 |
camera.aspect = window.innerWidth / window.innerHeight;
|
| 290 |
camera.updateProjectionMatrix();
|
| 291 |
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 292 |
}
|
| 293 |
+
|
| 294 |
+
// Mouse interaction variables
|
| 295 |
+
let isDragging = false;
|
| 296 |
+
let previousMousePosition = { x: 0, y: 0 };
|
| 297 |
+
|
| 298 |
+
// Mouse event handlers
|
| 299 |
+
function onMouseDown(event) {
|
| 300 |
+
isDragging = true;
|
| 301 |
+
previousMousePosition = {
|
| 302 |
+
x: event.clientX,
|
| 303 |
+
y: event.clientY
|
| 304 |
+
};
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
function onMouseMove(event) {
|
| 308 |
+
if (!isDragging) return;
|
| 309 |
+
|
| 310 |
+
const deltaX = event.clientX - previousMousePosition.x;
|
| 311 |
+
const deltaY = event.clientY - previousMousePosition.y;
|
| 312 |
+
|
| 313 |
+
networkGroup.rotation.y += deltaX * 0.01;
|
| 314 |
+
networkGroup.rotation.x += deltaY * 0.01;
|
| 315 |
+
|
| 316 |
+
previousMousePosition = {
|
| 317 |
+
x: event.clientX,
|
| 318 |
+
y: event.clientY
|
| 319 |
+
};
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
function onMouseUp() {
|
| 323 |
+
isDragging = false;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
// Add mouse event listeners
|
| 327 |
+
function addMouseControls() {
|
| 328 |
+
renderer.domElement.addEventListener('mousedown', onMouseDown, false);
|
| 329 |
+
renderer.domElement.addEventListener('mousemove', onMouseMove, false);
|
| 330 |
+
renderer.domElement.addEventListener('mouseup', onMouseUp, false);
|
| 331 |
+
renderer.domElement.addEventListener('mouseleave', onMouseUp, false);
|
| 332 |
+
|
| 333 |
+
// Change cursor style
|
| 334 |
+
renderer.domElement.style.cursor = 'grab';
|
| 335 |
+
}
|
| 336 |
|
| 337 |
// Initialize the visualization
|
| 338 |
init();
|
| 339 |
+
addMouseControls();
|
| 340 |
+
</script>
|
| 341 |
</body>
|
| 342 |
</html>
|