Anders and Briegel in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.2KB

  1. var colors = ["red", "green", "yellow", "blue", "pink", "orange", "purple"];
  2. function updateScene() {
  3. var oldState = scene.getObjectByName("graphstate");
  4. scene.remove(oldState);
  5. oldState = null;
  6. var geometry = new THREE.Geometry();
  7. for (var i in abj.vops) {
  8. var vop = abj.vops[i];
  9. var pos = abj.meta[i].position;
  10. var vertex = new THREE.Vector3(pos.x, pos.y, pos.z);
  11. geometry.vertices.push(vertex);
  12. geometry.colors[i] = new THREE.Color(colors[abj.vops[i] % colors.length]);
  13. }
  14. var edges = new THREE.Object3D();
  15. var my_edges = abj.edgelist();
  16. for (i=0; i < my_edges.length; ++i) {
  17. var edge = my_edges[i];
  18. var start = abj.meta[edge[0]].position;
  19. var startpos = new THREE.Vector3(start[0], start[1], start[2]);
  20. var end = abj.meta[edge[1]].position;
  21. var endpos = new THREE.Vector3(end[0], end[1], end[2]);
  22. var newEdge = makeEdge(startpos, endpos);
  23. edges.add(newEdge);
  24. }
  25. var particles = new THREE.Points(geometry, materials.qubit);
  26. var newState = new THREE.Object3D();
  27. newState.name = "graphstate";
  28. newState.add(particles);
  29. newState.add(edges);
  30. scene.add(newState);
  31. render();
  32. }