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.

62 lignes
1.6KB

  1. var editor = {};
  2. editor.nearest = undefined;
  3. editor.onFreeMove = function() {
  4. var n = editor.nearestNode(mouse.ray);
  5. if (editor.nearest !== n) {
  6. editor.nearest = n;
  7. if (n) {
  8. gui.nodeMessage("Node " + n + " (VOP:" + abj.vops[n] + ")" +
  9. "<br/>" + "Click to edit neighbourhood");
  10. } else {
  11. gui.hideNodeMessage();
  12. }
  13. }
  14. };
  15. editor.onClick = function() {
  16. var n = editor.nearestNode(mouse.ray);
  17. if (n) {
  18. var p = abj.meta[n].position;
  19. editor.gimbal.position.set(p.x, p.y, p.z);
  20. gui.controls.target.set(p.x, p.y, p.z);
  21. gui.hideNodeMessage();
  22. editor.nearest = undefined;
  23. gui.render();
  24. }
  25. };
  26. editor.prepare = function() {
  27. mouse.onFreeMove = editor.onFreeMove;
  28. mouse.onClick = editor.onClick;
  29. editor.makeGimbal();
  30. };
  31. // Gets a reference to the node nearest to the mouse cursor
  32. editor.nearestNode = function(ray) {
  33. for (var i in abj.meta) {
  34. if (ray.distanceSqToPoint(abj.meta[i].position) < 0.03) {
  35. return i;
  36. }
  37. }
  38. return undefined;
  39. };
  40. editor.makeGimbal = function(center) {
  41. editor.gimbal = new THREE.Object3D();
  42. var pointGeometry = new THREE.Geometry();
  43. pointGeometry.vertices = [
  44. new THREE.Vector3(1, 0, 0),
  45. new THREE.Vector3(0, 1, 0),
  46. new THREE.Vector3(0, 0, 1),
  47. new THREE.Vector3(-1, 0, 0),
  48. new THREE.Vector3(0, -1, 0),
  49. new THREE.Vector3(0, 0, -1)
  50. ];
  51. var tips = new THREE.Points(pointGeometry, materials.tip);
  52. editor.gimbal.add(tips);
  53. gui.scene.add(editor.gimbal);
  54. };