|
@@ -1,5 +1,6 @@ |
|
|
var editor = {}; |
|
|
var editor = {}; |
|
|
editor.nearest = undefined; |
|
|
editor.nearest = undefined; |
|
|
|
|
|
editor.gimbalVertices = []; |
|
|
|
|
|
|
|
|
editor.onFreeMove = function() { |
|
|
editor.onFreeMove = function() { |
|
|
var n = editor.nearestNode(mouse.ray); |
|
|
var n = editor.nearestNode(mouse.ray); |
|
@@ -16,14 +17,14 @@ editor.onFreeMove = function() { |
|
|
|
|
|
|
|
|
editor.onClick = function() { |
|
|
editor.onClick = function() { |
|
|
var n = editor.nearestNode(mouse.ray); |
|
|
var n = editor.nearestNode(mouse.ray); |
|
|
if (n) { |
|
|
|
|
|
|
|
|
//if (n.type=="node") { |
|
|
var p = abj.meta[n].position; |
|
|
var p = abj.meta[n].position; |
|
|
editor.gimbal.position.set(p.x, p.y, p.z); |
|
|
editor.gimbal.position.set(p.x, p.y, p.z); |
|
|
gui.controls.target.set(p.x, p.y, p.z); |
|
|
gui.controls.target.set(p.x, p.y, p.z); |
|
|
gui.hideNodeMessage(); |
|
|
gui.hideNodeMessage(); |
|
|
editor.nearest = undefined; |
|
|
editor.nearest = undefined; |
|
|
gui.render(); |
|
|
gui.render(); |
|
|
} |
|
|
|
|
|
|
|
|
//} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
editor.prepare = function() { |
|
|
editor.prepare = function() { |
|
@@ -34,9 +35,16 @@ editor.prepare = function() { |
|
|
|
|
|
|
|
|
// Gets a reference to the node nearest to the mouse cursor |
|
|
// Gets a reference to the node nearest to the mouse cursor |
|
|
editor.nearestNode = function(ray) { |
|
|
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; |
|
|
return undefined; |
|
@@ -54,8 +62,10 @@ editor.makeGimbal = function(center) { |
|
|
new THREE.Vector3(0, -1, 0), |
|
|
new THREE.Vector3(0, -1, 0), |
|
|
new THREE.Vector3(0, 0, -1) |
|
|
new THREE.Vector3(0, 0, -1) |
|
|
]; |
|
|
]; |
|
|
|
|
|
editor.gimbalVertices = pointGeometry.vertices; |
|
|
var tips = new THREE.Points(pointGeometry, materials.tip); |
|
|
var tips = new THREE.Points(pointGeometry, materials.tip); |
|
|
|
|
|
|
|
|
editor.gimbal.add(tips); |
|
|
editor.gimbal.add(tips); |
|
|
gui.scene.add(editor.gimbal); |
|
|
gui.scene.add(editor.gimbal); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|