Anders and Briegel in Python
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

interaction.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Gets a reference to the node nearest to the mouse cursor
  2. function nearestNode() {
  3. raycaster.setFromCamera(mouse, camera);
  4. for (var i = 0; i < nodeGeometry.vertices.length; ++i) {
  5. if (raycaster.ray.distanceSqToPoint(nodeGeometry.vertices[i]) < 0.01) {
  6. return i;
  7. }
  8. }
  9. return undefined;
  10. }
  11. // Find out: what is the mouse pointing at?
  12. function checkIntersections() {
  13. var new_selection = nearestNode();
  14. if (new_selection != selection) {
  15. selection = new_selection;
  16. info.className = selection ? "visible" : "hidden";
  17. info.innerHTML = selection ? nodeGeometry.labels[new_selection] : info.innerHTML;
  18. render();
  19. }
  20. }
  21. // Update the mouse position tracker
  22. function onMouseMove(event) {
  23. mouse.wasClick = false;
  24. mouse.absx = event.clientX;
  25. mouse.absy = event.clientY;
  26. mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
  27. mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
  28. w = 200;
  29. h = 15;
  30. info.style.top = mouse.absy - h - 40 + "px";
  31. info.style.left = mouse.absx - w / 2 + "px";
  32. checkIntersections();
  33. }
  34. // Add qubits or whatever
  35. function onClick(event){
  36. if (!selection){return;}
  37. console.log(nodeGeometry.vertices[selection]);
  38. qubits.geometry.dynamic = true;
  39. qubits.geometry.vertices.push(nodeGeometry.vertices[selection].clone());
  40. qubits.geometry.verticesNeedUpdate = true;
  41. }