Skip to content

Commit 6feb7b9

Browse files
authored
Merge pull request #12 from davidpiegza/update-to-three-js-r83
Update to three.js r83
2 parents 25f596a + fccbc92 commit 6feb7b9

File tree

9 files changed

+29870
-24114
lines changed

9 files changed

+29870
-24114
lines changed

build/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Create minified version
2+
3+
Using `uglifyjs`:
4+
5+
npm install uglify-js -g
6+
uglifyjs -c -m -- Graph.js webgl-frameworks/Three.js utils/*.js layouts/*.js drawings/*.js > build/graph.min.js

build/graph.min.js

Lines changed: 15 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

drawings/simple_graph.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ Drawing.SimpleGraph = function(options) {
7676

7777
function init() {
7878
// Three.js initialization
79-
renderer = new THREE.WebGLRenderer({alpha: true});
80-
renderer.setSize( window.innerWidth, window.innerHeight );
79+
renderer = new THREE.WebGLRenderer({alpha: true, antialias: true});
80+
renderer.setPixelRatio(window.devicePixelRatio);
81+
renderer.setSize(window.innerWidth, window.innerHeight);
82+
8183

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

103105
// Node geometry
104106
if(that.layout === "3d") {
105-
geometry = new THREE.CubeGeometry( 25, 25, 25 );
107+
geometry = new THREE.BoxGeometry( 25, 25, 25 );
106108
} else {
107-
geometry = new THREE.CubeGeometry( 50, 50, 0 );
109+
geometry = new THREE.BoxGeometry( 50, 50, 0 );
108110
}
109111

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

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

235-
line = new THREE.Line( tmp_geo, material, THREE.LinePieces );
237+
line = new THREE.LineSegments( tmp_geo, material );
236238
line.scale.x = line.scale.y = line.scale.z = 1;
237239
line.originalScale = 1;
238240

241+
// NOTE: Deactivated frustumCulled, otherwise it will not draw all lines (even though
242+
// it looks like the lines are in the view frustum).
243+
line.frustumCulled = false;
244+
239245
geometries.push(tmp_geo);
240246

241247
scene.add( line );

drawings/sphere_graph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ Drawing.SphereGraph = function(options) {
250250
tmp_geo.vertices.push(source.data.draw_object.position);
251251
tmp_geo.vertices.push(target.data.draw_object.position);
252252

253-
line = new THREE.Line( tmp_geo, material, THREE.LinePieces );
253+
line = new THREE.LineSegments( tmp_geo, material );
254254
line.scale.x = line.scale.y = line.scale.z = 1;
255255
line.originalScale = 1;
256256

index_example.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<!DOCTYPE html>
1515
<html>
1616
<head>
17+
<meta charset="utf-8">
1718
<title>Graph Visualization</title>
1819
<script type="text/javascript" src="Graph.js"></script>
1920
<script type="text/javascript" src="webgl-frameworks/three.min.js"></script>

utils/Label.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,18 @@ THREE.Label = function(text, parameters) {
3737
xc.textBaseline = 'top';
3838
xc.fillText(text, 0, 0);
3939

40-
var geometry = new THREE.CubeGeometry(len, 200, 0);
41-
var xm = new THREE.MeshBasicMaterial({map: new THREE.Texture(labelCanvas), transparent: true});
40+
var geometry = new THREE.BoxGeometry(len, 200, 0);
41+
var xm = new THREE.MeshBasicMaterial({
42+
map: new THREE.CanvasTexture(
43+
labelCanvas,
44+
THREE.UVMapping,
45+
THREE.ClampToEdgeWrapping,
46+
THREE.ClampToEdgeWrapping,
47+
THREE.LinearFilter,
48+
THREE.LinearFilter
49+
),
50+
transparent: true
51+
});
4252
xm.map.needsUpdate = true;
4353

4454
// set text canvas to cube geometry

utils/ObjectSelection.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ THREE.ObjectSelection = function(parameters) {
1616
var parameters = parameters || {};
1717

1818
this.domElement = parameters.domElement || document;
19-
this.projector = new THREE.Projector();
2019
this.INTERSECTED;
2120

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

4342
this.render = function(scene, camera) {
4443
var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
45-
this.projector.unprojectVector( vector, camera );
44+
vector.unproject(camera);
4645

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

0 commit comments

Comments
 (0)