From 41a83246f20e36b6e95386be999a7f2c9565b609 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Thu, 19 May 2016 02:22:33 +0100 Subject: [PATCH] Not much --- static/scripts/editor.js | 20 +++++++++++++++----- static/scripts/gui.js | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/static/scripts/editor.js b/static/scripts/editor.js index 70c887c..f57cee3 100644 --- a/static/scripts/editor.js +++ b/static/scripts/editor.js @@ -1,5 +1,6 @@ var editor = {}; editor.nearest = undefined; +editor.gimbalVertices = []; editor.onFreeMove = function() { var n = editor.nearestNode(mouse.ray); @@ -16,14 +17,14 @@ editor.onFreeMove = function() { editor.onClick = function() { var n = editor.nearestNode(mouse.ray); - if (n) { + //if (n.type=="node") { var p = abj.meta[n].position; editor.gimbal.position.set(p.x, p.y, p.z); gui.controls.target.set(p.x, p.y, p.z); gui.hideNodeMessage(); editor.nearest = undefined; gui.render(); - } + //} }; editor.prepare = function() { @@ -34,9 +35,16 @@ editor.prepare = function() { // Gets a reference to the node nearest to the mouse cursor editor.nearestNode = function(ray) { - for (var i in abj.meta) { - if (ray.distanceSqToPoint(abj.meta[i].position) < 0.03) { - return i; + for (var i=0; i < editor.gimbalVertices.length; ++i) { + if (ray.distanceSqToPoint(editor.gimbalVertices[i]) < 0.03) { + //return {type: "gimbal", node: i}; + } + } + + for (var j in abj.meta) { + if (ray.distanceSqToPoint(abj.meta[j].position) < 0.03) { + //return {type: "node", node: i}; + return j; } } return undefined; @@ -54,8 +62,10 @@ editor.makeGimbal = function(center) { new THREE.Vector3(0, -1, 0), new THREE.Vector3(0, 0, -1) ]; + editor.gimbalVertices = pointGeometry.vertices; var tips = new THREE.Points(pointGeometry, materials.tip); editor.gimbal.add(tips); gui.scene.add(editor.gimbal); }; + diff --git a/static/scripts/gui.js b/static/scripts/gui.js index e0993cf..2850603 100644 --- a/static/scripts/gui.js +++ b/static/scripts/gui.js @@ -17,7 +17,7 @@ gui.prepare = function() { gui.controls.target.set(0, 0, 0); gui.controls.rotateSpeed = 0.2; gui.controls.userPanSpeed = 0.1; - gui.camera.position.set(4, 4, 10); + gui.camera.position.set(0, 0, 10); }; // Someone resized the window