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.

editor.js 1.9KB

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