Commit f4a1591a authored by amandaghassaei's avatar amandaghassaei
Browse files

show 3D cursor

parent d2587d80
...@@ -14,6 +14,10 @@ function init3DUI(globals) { ...@@ -14,6 +14,10 @@ function init3DUI(globals) {
var mouseDown = false; var mouseDown = false;
var highlightedObj; var highlightedObj;
var highlighter1 = new Node(new THREE.Vector3());
highlighter1.setTransparent();
globals.threeView.scene.add(highlighter1.getObject3D());
$(document).dblclick(function() { $(document).dblclick(function() {
}); });
...@@ -61,6 +65,11 @@ function init3DUI(globals) { ...@@ -61,6 +65,11 @@ function init3DUI(globals) {
highlightedObj.moveManually(intersection); highlightedObj.moveManually(intersection);
globals.nodePositionHasChanged = true; globals.nodePositionHasChanged = true;
} }
if (highlightedObj){
var position = highlightedObj.getPosition();
highlighter1.getObject3D().position.set(position.x, position.y, position.z);
}
} }
function getIntersectionWithObjectPlane(position){ function getIntersectionWithObjectPlane(position){
...@@ -75,9 +84,13 @@ function init3DUI(globals) { ...@@ -75,9 +84,13 @@ function init3DUI(globals) {
function setHighlightedObj(object){ function setHighlightedObj(object){
if (highlightedObj && (object != highlightedObj)) { if (highlightedObj && (object != highlightedObj)) {
highlightedObj.unhighlight(); highlightedObj.unhighlight();
highlighter1.getObject3D().visible = false;
} }
highlightedObj = object; highlightedObj = object;
if (highlightedObj) highlightedObj.highlight(); if (highlightedObj) {
highlightedObj.highlight();
highlighter1.getObject3D().visible = true;
}
} }
function checkForIntersections(e, objects){ function checkForIntersections(e, objects){
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
var nodeMaterial = new THREE.MeshBasicMaterial({color: 0x000000, side:THREE.DoubleSide}); var nodeMaterial = new THREE.MeshBasicMaterial({color: 0x000000, side:THREE.DoubleSide});
var nodeMaterialFixed = new THREE.MeshBasicMaterial({color: 0x000000, side:THREE.DoubleSide}); var nodeMaterialFixed = new THREE.MeshBasicMaterial({color: 0x000000, side:THREE.DoubleSide});
var nodeMaterialHighlight = new THREE.MeshBasicMaterial({color: 0xffffff, side:THREE.DoubleSide}); var nodeMaterialHighlight = new THREE.MeshBasicMaterial({color: 0xffffff, side:THREE.DoubleSide});
var nodeGeo = new THREE.SphereGeometry(1,20); var transparentMaterial = new THREE.MeshBasicMaterial({color: 0xffffff, side:THREE.DoubleSide, opacity:0.5, transparent:true});
var nodeGeo = new THREE.SphereGeometry(3,20);
nodeGeo.rotateX(Math.PI/2); nodeGeo.rotateX(Math.PI/2);
var nodeFixedGeo = new THREE.CubeGeometry(1, 1, 1); var nodeFixedGeo = new THREE.CubeGeometry(1, 1, 1);
nodeFixedGeo.applyMatrix( new THREE.Matrix4().makeTranslation(0, 0.25, 0) ); nodeFixedGeo.applyMatrix( new THREE.Matrix4().makeTranslation(0, 0.25, 0) );
...@@ -144,6 +145,10 @@ Node.prototype.unhighlight = function(){ ...@@ -144,6 +145,10 @@ Node.prototype.unhighlight = function(){
} }
}; };
Node.prototype.setTransparent = function(){
this.object3D.material = transparentMaterial;
};
Node.prototype.hide = function(){ Node.prototype.hide = function(){
this.object3D.visible = false; this.object3D.visible = false;
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment