Browse Source

Replace graph rendering code with old version

master
Pete Shadbolt 8 years ago
parent
commit
d99e4a21a9
1 changed files with 31 additions and 35 deletions
  1. +31
    -35
      server/graph.js

+ 31
- 35
server/graph.js View File

@@ -1,39 +1,35 @@
var graph;
function updateScene(state) {
var oldState = scene.getObjectByName("graphstate");
scene.remove(oldState);
oldState = null;
var geometry = new THREE.Geometry();
//nodeGeometry.labels = [];
//nodeGeometry.colors = [];
for (var i in state.nodes) {
var node = state.nodes[i];
var pos = state.meta[i].pos;
var vertex = new THREE.Vector3(pos.x, pos.y, pos.z);
geometry.vertices.push(vertex);
//geometry.colors[i] = new THREE.Color(n.color);
//geometry.labels[i] = n.label;
}

function graph_model(){
this.geometry = new THREE.Geometry();
this.nodes = new THREE.Points(this.geometry, materials.qubit);
this.nodes.geometry.dynamic = true;
this.object = new THREE.Object3D();
this.object.add(this.nodes);
var edges = new THREE.Object3D();
for (i=0; i < state.edges.length; ++i) {
var edge = state.edges[i];
var start = state.meta[edge[0]].pos;
var end = state.meta[edge[1]].pos;
var newEdge = makeEdge(start, end);
edges.add(newEdge);
}

this.add_node = function(node){
var vertex = new THREE.Vector3(0, 0, 0);
this.nodes.geometry.vertices.push(vertex);
this.nodes.geometry.verticesNeedUpdate = true;
render();
};
var particles = new THREE.Points(geometry, materials.qubit);
var newState = new THREE.Object3D();
newState.name = "graphstate";
newState.add(particles);
newState.add(edges);
scene.add(newState);
render();
}



//function buildGraph(json) {
// Add all the qubits
//var geometry = new THREE.Geometry();
//var vertex = new THREE.Vector3(0, 0, 0);
//geometry.vertices.push(vertex);
//var nodes = new THREE.Points(geometry, materials.node);

// Add all the edges
//var edges = new THREE.Object3D();
//edges.add(makeEdge({
//"start": [0, 0, 0],
//"end": [1, 1, 1]
//}));
// Construct and return
//var graph = new THREE.Object3D();
//graph.add(nodes);
//graph.add(edges);
//return graph;
//}

Loading…
Cancel
Save