Skip to content

Commit

Permalink
Merge pull request #12 from davidpiegza/update-to-three-js-r83
Browse files Browse the repository at this point in the history
Update to three.js r83
  • Loading branch information
davidpiegza authored Jan 14, 2017
2 parents ed287c5 + 6e25ee1 commit f2ac8c3
Show file tree
Hide file tree
Showing 9 changed files with 29,870 additions and 24,114 deletions.
6 changes: 6 additions & 0 deletions build/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Create minified version

Using `uglifyjs`:

npm install uglify-js -g
uglifyjs -c -m -- Graph.js webgl-frameworks/Three.js utils/*.js layouts/*.js drawings/*.js > build/graph.min.js
19 changes: 15 additions & 4 deletions build/graph.min.js

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions drawings/simple_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ Drawing.SimpleGraph = function(options) {

function init() {
// Three.js initialization
renderer = new THREE.WebGLRenderer({alpha: true});
renderer.setSize( window.innerWidth, window.innerHeight );
renderer = new THREE.WebGLRenderer({alpha: true, antialias: true});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);


camera = new THREE.PerspectiveCamera(40, window.innerWidth/window.innerHeight, 1, 1000000);
camera.position.z = 5000;
Expand All @@ -102,9 +104,9 @@ Drawing.SimpleGraph = function(options) {

// Node geometry
if(that.layout === "3d") {
geometry = new THREE.CubeGeometry( 25, 25, 25 );
geometry = new THREE.BoxGeometry( 25, 25, 25 );
} else {
geometry = new THREE.CubeGeometry( 50, 50, 0 );
geometry = new THREE.BoxGeometry( 50, 50, 0 );
}

// Create node selection, if set
Expand Down Expand Up @@ -226,16 +228,20 @@ Drawing.SimpleGraph = function(options) {
* Create an edge object (line) and add it to the scene.
*/
function drawEdge(source, target) {
material = new THREE.LineBasicMaterial({ color: 0xff0000, opacity: 1, linewidth: 0.5 });
material = new THREE.LineBasicMaterial({ color: 0xff0000, opacity: 1, linewidth: 1 });

var tmp_geo = new THREE.Geometry();
tmp_geo.vertices.push(source.data.draw_object.position);
tmp_geo.vertices.push(target.data.draw_object.position);

line = new THREE.Line( tmp_geo, material, THREE.LinePieces );
line = new THREE.LineSegments( tmp_geo, material );
line.scale.x = line.scale.y = line.scale.z = 1;
line.originalScale = 1;

// NOTE: Deactivated frustumCulled, otherwise it will not draw all lines (even though
// it looks like the lines are in the view frustum).
line.frustumCulled = false;

geometries.push(tmp_geo);

scene.add( line );
Expand Down
2 changes: 1 addition & 1 deletion drawings/sphere_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ Drawing.SphereGraph = function(options) {
tmp_geo.vertices.push(source.data.draw_object.position);
tmp_geo.vertices.push(target.data.draw_object.position);

line = new THREE.Line( tmp_geo, material, THREE.LinePieces );
line = new THREE.LineSegments( tmp_geo, material );
line.scale.x = line.scale.y = line.scale.z = 1;
line.originalScale = 1;

Expand Down
1 change: 1 addition & 0 deletions index_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Graph Visualization</title>
<script type="text/javascript" src="Graph.js"></script>
<script type="text/javascript" src="webgl-frameworks/three.min.js"></script>
Expand Down
14 changes: 12 additions & 2 deletions utils/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,18 @@ THREE.Label = function(text, parameters) {
xc.textBaseline = 'top';
xc.fillText(text, 0, 0);

var geometry = new THREE.CubeGeometry(len, 200, 0);
var xm = new THREE.MeshBasicMaterial({map: new THREE.Texture(labelCanvas), transparent: true});
var geometry = new THREE.BoxGeometry(len, 200, 0);
var xm = new THREE.MeshBasicMaterial({
map: new THREE.CanvasTexture(
labelCanvas,
THREE.UVMapping,
THREE.ClampToEdgeWrapping,
THREE.ClampToEdgeWrapping,
THREE.LinearFilter,
THREE.LinearFilter
),
transparent: true
});
xm.map.needsUpdate = true;

// set text canvas to cube geometry
Expand Down
3 changes: 1 addition & 2 deletions utils/ObjectSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ THREE.ObjectSelection = function(parameters) {
var parameters = parameters || {};

this.domElement = parameters.domElement || document;
this.projector = new THREE.Projector();
this.INTERSECTED;

var _this = this;
Expand All @@ -42,7 +41,7 @@ THREE.ObjectSelection = function(parameters) {

this.render = function(scene, camera) {
var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
this.projector.unprojectVector( vector, camera );
vector.unproject(camera);

var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize());

Expand Down
Loading

0 comments on commit f2ac8c3

Please sign in to comment.