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.

graph.js 1.5KB

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
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
il y a 8 ans
il y a 8 ans
il y a 8 ans
il y a 8 ans
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var graph = {};
  2. graph.colors = ["red", "green", "yellow", "green", "pink", "orange", "purple"];
  3. graph.prepare = function() {
  4. materials.prepare();
  5. websocket.connect(graph.update);
  6. };
  7. graph.update = function(newState) {
  8. if (newState){abj.update(newState);}
  9. if (graph.object){gui.scene.remove(graph.object);}
  10. graph.object = null;
  11. var geometry = new THREE.Geometry();
  12. geometry.colors = [];
  13. for (var i in abj.node) {
  14. var color = graph.colors[abj.node[i].vop % graph.colors.length];
  15. if (abj.node[i].color !== undefined){
  16. color = abj.node[i].color;
  17. }
  18. geometry.vertices.push(abj.node[i].position);
  19. geometry.colors.push(new THREE.Color(color));
  20. }
  21. var edges = new THREE.Object3D();
  22. var my_edges = abj.edgelist();
  23. for (i = 0; i < my_edges.length; ++i) {
  24. var edge = my_edges[i];
  25. var start = abj.node[edge[0]].position;
  26. var startpos = new THREE.Vector3(start.x, start.y, start.z);
  27. var end = abj.node[edge[1]].position;
  28. var endpos = new THREE.Vector3(end.x, end.y, end.z);
  29. var newEdge = materials.makeCurve(startpos, endpos);
  30. edges.add(newEdge);
  31. }
  32. var particles = new THREE.Points(geometry, materials.qubit);
  33. graph.object = new THREE.Object3D();
  34. graph.object.name = "graphstate";
  35. graph.object.add(particles);
  36. graph.object.add(edges);
  37. gui.scene.add(graph.object);
  38. gui.render();
  39. };
  40. graph.test = function(command) {
  41. //Act the command
  42. //Send it back to the server, ultimately thru to python
  43. };