mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-19 20:09:37 +02:00
put a green sphere at the point being pointed to
This commit is contained in:
parent
558f68c150
commit
f6cbeb37f8
1 changed files with 23 additions and 6 deletions
|
@ -12,6 +12,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
var lineEntityID = null;
|
var lineEntityID = null;
|
||||||
|
var sphereEntityID = null;
|
||||||
var lineIsRezzed = false;
|
var lineIsRezzed = false;
|
||||||
|
|
||||||
var BUTTON_SIZE = 32;
|
var BUTTON_SIZE = 32;
|
||||||
|
@ -58,7 +59,11 @@ function nearLinePoint(targetPosition) {
|
||||||
function removeLine() {
|
function removeLine() {
|
||||||
if (lineIsRezzed) {
|
if (lineIsRezzed) {
|
||||||
Entities.deleteEntity(lineEntityID);
|
Entities.deleteEntity(lineEntityID);
|
||||||
|
if (sphereEntityID) {
|
||||||
|
Entities.deleteEntity(sphereEntityID);
|
||||||
|
}
|
||||||
lineEntityID = null;
|
lineEntityID = null;
|
||||||
|
sphereEntityID = null;
|
||||||
lineIsRezzed = false;
|
lineIsRezzed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +71,10 @@ function removeLine() {
|
||||||
|
|
||||||
function createOrUpdateLine(event) {
|
function createOrUpdateLine(event) {
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
if (sphereEntityID) {
|
||||||
|
Entities.deleteEntity(sphereEntityID);
|
||||||
|
sphereEntityID = null;
|
||||||
|
}
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking
|
var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking
|
||||||
var props = Entities.getEntityProperties(intersection.entityID);
|
var props = Entities.getEntityProperties(intersection.entityID);
|
||||||
|
|
||||||
|
@ -78,7 +87,6 @@ function createOrUpdateLine(event) {
|
||||||
position: MyAvatar.position,
|
position: MyAvatar.position,
|
||||||
lifetime: 15 + props.lifespan // renew lifetime
|
lifetime: 15 + props.lifespan // renew lifetime
|
||||||
});
|
});
|
||||||
// Entities.setAllPoints(lineEntityID, points);
|
|
||||||
} else {
|
} else {
|
||||||
lineIsRezzed = true;
|
lineIsRezzed = true;
|
||||||
lineEntityID = Entities.addEntity({
|
lineEntityID = Entities.addEntity({
|
||||||
|
@ -90,6 +98,15 @@ function createOrUpdateLine(event) {
|
||||||
lifetime: 15 // if someone crashes while pointing, don't leave the line there forever.
|
lifetime: 15 // if someone crashes while pointing, don't leave the line there forever.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sphereEntityID = Entities.addEntity({
|
||||||
|
type: "Sphere",
|
||||||
|
position: intersection.intersection,
|
||||||
|
ignoreForCollisions: 1,
|
||||||
|
dimensions: { x: 0.6, y: 0.6, z: 0.6 },
|
||||||
|
color: { red: 0, green: 255, blue: 0 },
|
||||||
|
lifetime: 15 // if someone crashes while pointing, don't leave the line there forever.
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
removeLine();
|
removeLine();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue