bug fix for when web-entity is deleted while being scrolled

This commit is contained in:
Anthony J. Thibault 2016-08-18 18:37:52 -07:00
parent 7b248b440a
commit 4db1687746

View file

@ -253,6 +253,8 @@ function handLaserIntersectEntity(entityID, hand) {
var worldHandRotation = Quat.multiply(MyAvatar.orientation, pose.rotation);
var props = entityPropertiesCache.getProps(entityID);
if (props.position) {
var planePosition = props.position;
var planeNormal = Vec3.multiplyQbyV(props.rotation, {x: 0, y: 0, z: 1.0});
var rayStart = worldHandPosition;
@ -273,6 +275,10 @@ function handLaserIntersectEntity(entityID, hand) {
length: PICK_MAX_DISTANCE
};
return intersectionInfo;
} else {
// entity has been destroyed? or is no longer in cache
return null;
}
}
function rayIntersectPlane(planePosition, planeNormal, rayStart, rayDirection) {
@ -2109,7 +2115,7 @@ function MyController(hand) {
this.entityTouchingEnter = function() {
// test for intersection between controller laser and web entity plane.
var intersectInfo = handLaserIntersectEntity(this.grabbedEntity, this.hand);
if (intersectInfo) {
var pointerEvent = {
type: "Press",
id: this.hand + 1, // 0 is reserved for hardware mouse
@ -2125,12 +2131,13 @@ function MyController(hand) {
Entities.sendMousePressOnEntity(this.grabbedEntity, pointerEvent);
Entities.sendClickDownOnEntity(this.grabbedEntity, pointerEvent);
}
};
this.entityTouchingExit = function() {
// test for intersection between controller laser and web entity plane.
var intersectInfo = handLaserIntersectEntity(this.grabbedEntity, this.hand);
if (intersectInfo) {
var pointerEvent = {
type: "Release",
id: this.hand + 1, // 0 is reserved for hardware mouse
@ -2148,6 +2155,7 @@ function MyController(hand) {
Entities.sendClickReleaseOnEntity(this.grabbedEntity, pointerEvent);
Entities.sendHoverLeaveEntity(this.grabbedEntity, pointerEvent);
this.focusedEntity = null;
}
};
this.entityTouching = function() {
@ -2160,6 +2168,7 @@ function MyController(hand) {
// test for intersection between controller laser and web entity plane.
var intersectInfo = handLaserIntersectEntity(this.grabbedEntity, this.hand);
if (intersectInfo) {
if (Entities.keyboardFocusEntity != this.grabbedEntity) {
Entities.keyboardFocusEntity = this.grabbedEntity;
@ -2184,6 +2193,10 @@ function MyController(hand) {
this.intersectionDistance = intersectInfo.distance;
this.searchIndicatorOn(intersectInfo.searchRay);
Reticle.setVisible(false);
} else {
this.setState(STATE_OFF, "grabbed entity was destroyed");
return;
}
};
this.release = function() {