|
|
@@ -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); |
|
|
|
}; |
|
|
|
|