rays never pick a line entity. some fixes to pointer.js

This commit is contained in:
Seth Alves 2015-05-15 13:10:16 -07:00
parent 1161f33b45
commit bb3d1a6a58
2 changed files with 26 additions and 15 deletions

View file

@ -24,23 +24,28 @@ function removeLine() {
function createOrUpdateLine(event) {
var pickRay = Camera.computePickRay(event.x, event.y);
var intersection = Entities.findRayIntersection(pickRay, true); // accurate picking
var props = Entities.getEntityProperties(intersection.entityID);
if (lineIsRezzed) {
Entities.editEntity(lineEntityID, {
position: nearLinePoint(intersection.intersection),
dimensions: Vec3.subtract(intersection.intersection, nearLinePoint(intersection.intersection)),
lifetime: 30 // renew lifetime
});
if (intersection.intersects) {
var dim = Vec3.subtract(intersection.intersection, nearLinePoint(intersection.intersection));
if (lineIsRezzed) {
Entities.editEntity(lineEntityID, {
position: nearLinePoint(intersection.intersection),
dimensions: dim,
lifetime: 60 + props.lifespan // renew lifetime
});
} else {
lineIsRezzed = true;
lineEntityID = Entities.addEntity({
type: "Line",
position: nearLinePoint(intersection.intersection),
dimensions: dim,
color: { red: 255, green: 255, blue: 255 },
lifetime: 60 // if someone crashes while pointing, don't leave the line there forever.
});
}
} else {
lineIsRezzed = true;
lineEntityID = Entities.addEntity({
type: "Line",
position: nearLinePoint(intersection.intersection),
dimensions: Vec3.subtract(intersection.intersection, nearLinePoint(intersection.intersection)),
color: { red: 255, green: 255, blue: 255 },
lifetime: 30 // if someone crashes while pointing, don't leave the line there forever.
});
removeLine();
}
}

View file

@ -53,6 +53,12 @@ class LineEntityItem : public EntityItem {
virtual ShapeType getShapeType() const { return SHAPE_TYPE_LINE; }
// never have a ray intersection pick a LineEntityItem.
virtual bool supportsDetailedRayIntersection() const { return true; }
virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
bool& keepSearching, OctreeElement*& element, float& distance, BoxFace& face,
void** intersectedObject, bool precisionPicking) const { return false; }
virtual void debugDump() const;
protected: