Selaa lähdekoodia

Automatically center on new graphs

master
Pete Shadbolt 8 vuotta sitten
vanhempi
commit
9ceb2e8b0a
4 muutettua tiedostoa jossa 18 lisäystä ja 3 poistoa
  1. +1
    -0
      examples/lattice_demo.py
  2. +16
    -0
      static/scripts/graph.js
  3. +0
    -2
      static/scripts/materials.js
  4. +1
    -1
      static/scripts/tables.js

+ 1
- 0
examples/lattice_demo.py Näytä tiedosto

@@ -36,6 +36,7 @@ psi = GraphState()
for node in nodes:
psi.add_node(str(node), position=xyz(node[0], node[1]))
psi.act_hadamard(str(node))
psi.update(0.1)

for edge in edges:
psi.act_cz(str(edge[0]), str(edge[1]))


+ 16
- 0
static/scripts/graph.js Näytä tiedosto

@@ -6,6 +6,15 @@ graph.prepare = function() {
websocket.connect(graph.update);
};

graph.center = function() {
var middle = new THREE.Vector3(0, 0, 0);
for (var i in abj.node) {
middle = middle.add(abj.node[i].position);
}
middle = middle.multiplyScalar(1.0/abj.order());
return middle;
};

graph.update = function(newState) {
if (newState){abj.update(newState);}

@@ -23,6 +32,9 @@ graph.update = function(newState) {
geometry.colors.push(new THREE.Color(color));
}

graph.center();
gui.controls.target.copy(graph.center());

var edges = new THREE.Object3D();
var my_edges = abj.edgelist();
for (i = 0; i < my_edges.length; ++i) {
@@ -42,6 +54,10 @@ graph.update = function(newState) {
graph.object.add(edges);
gui.scene.add(graph.object);
gui.render();
geometry = null;
edges=null;
particles = null;
graph.object = null;
};

graph.test = function(command) {


+ 0
- 2
static/scripts/materials.js Näytä tiedosto

@@ -7,9 +7,7 @@ var curveProperties = {

materials.prepare = function() {
var ballSprite = new THREE.Texture(document.getElementById("ball"));
var tipSprite = new THREE.Texture(document.getElementById("tip"));
ballSprite.needsUpdate = true;
tipSprite.needsUpdate = true;
materials.edge = new THREE.LineBasicMaterial({
color: "gray",
transparent: false,


+ 1
- 1
static/scripts/tables.js
File diff suppressed because it is too large
Näytä tiedosto


Loading…
Peruuta
Tallenna