mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:12:46 +02:00
remove all the old visualization methods
This commit is contained in:
parent
1d3dc7b195
commit
54109c6c6f
2 changed files with 257 additions and 232 deletions
|
@ -42,7 +42,11 @@ var HAND_HEAD_MIX_RATIO = 0.0; // 0 = only use hands for search/move. 1 = only
|
|||
|
||||
var PICK_WITH_HAND_RAY = true;
|
||||
|
||||
var EQUIP_SPHERE_COLOR = { red: 179, green: 120, blue: 211 };
|
||||
var EQUIP_SPHERE_COLOR = {
|
||||
red: 179,
|
||||
green: 120,
|
||||
blue: 211
|
||||
};
|
||||
var EQUIP_SPHERE_ALPHA = 0.15;
|
||||
var EQUIP_SPHERE_SCALE_FACTOR = 0.65;
|
||||
|
||||
|
@ -66,12 +70,32 @@ var INTERSECT_COLOR = {
|
|||
green: 10,
|
||||
blue: 10
|
||||
}; // line color when pick hits
|
||||
var LINE_ENTITY_DIMENSIONS = {
|
||||
x: 1000,
|
||||
y: 1000,
|
||||
z: 1000
|
||||
|
||||
var COLORS_GRAB_SEARCHING_HALF_SQUEEZE = {
|
||||
red: 255,
|
||||
green: 97,
|
||||
blue: 129
|
||||
};
|
||||
|
||||
var COLORS_GRAB_SEARCHING_FULL_SQUEEZE = {
|
||||
red: 255,
|
||||
green: 97,
|
||||
blue: 129
|
||||
};
|
||||
|
||||
var COLORS_GRAB_DISTANCE_HOLD = {
|
||||
red: 238,
|
||||
green: 75,
|
||||
blue: 214
|
||||
};
|
||||
|
||||
var COLORS_EQUIP_SPHERE = {
|
||||
red: 116,
|
||||
green: 90,
|
||||
blue: 238
|
||||
};
|
||||
|
||||
|
||||
var LINE_LENGTH = 500;
|
||||
var PICK_MAX_DISTANCE = 500; // max length of pick-ray
|
||||
|
||||
|
@ -143,14 +167,6 @@ var DEFAULT_GRABBABLE_DATA = {
|
|||
var USE_BLACKLIST = true;
|
||||
var blacklist = [];
|
||||
|
||||
// we've created various ways of visualizing looking for and moving distant objects
|
||||
var USE_ENTITY_LINES_FOR_SEARCHING = false;
|
||||
var USE_OVERLAY_LINES_FOR_SEARCHING = true;
|
||||
|
||||
var USE_ENTITY_LINES_FOR_MOVING = false;
|
||||
var USE_OVERLAY_LINES_FOR_MOVING = false;
|
||||
|
||||
|
||||
var FORBIDDEN_GRAB_NAMES = ["Grab Debug Entity", "grab pointer"];
|
||||
var FORBIDDEN_GRAB_TYPES = ['Unknown', 'Light', 'PolyLine', 'Zone'];
|
||||
|
||||
|
@ -240,6 +256,7 @@ function findRayIntersection(pickRay, precise, include, exclude) {
|
|||
}
|
||||
return overlays;
|
||||
}
|
||||
|
||||
function entityIsGrabbedByOther(entityID) {
|
||||
// by convention, a distance grab sets the tag of its action to be grab-*owner-session-id*.
|
||||
var actionIDs = Entities.getActionIDs(entityID);
|
||||
|
@ -270,6 +287,7 @@ function propsArePhysical(props) {
|
|||
var USE_ATTACH_POINT_SETTINGS = true;
|
||||
|
||||
var ATTACH_POINT_SETTINGS = "io.highfidelity.attachPoints";
|
||||
|
||||
function getAttachPointSettings() {
|
||||
try {
|
||||
var str = Settings.getValue(ATTACH_POINT_SETTINGS);
|
||||
|
@ -283,10 +301,12 @@ function getAttachPointSettings() {
|
|||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function setAttachPointSettings(attachPointSettings) {
|
||||
var str = JSON.stringify(attachPointSettings);
|
||||
Settings.setValue(ATTACH_POINT_SETTINGS, str);
|
||||
}
|
||||
|
||||
function getAttachPointForHotspotFromSettings(hotspot, hand) {
|
||||
var attachPointSettings = getAttachPointSettings();
|
||||
var jointName = (hand === RIGHT_HAND) ? "RightHand" : "LeftHand";
|
||||
|
@ -297,6 +317,7 @@ function getAttachPointForHotspotFromSettings(hotspot, hand) {
|
|||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function storeAttachPointForHotspotInSettings(hotspot, hand, offsetPosition, offsetRotation) {
|
||||
var attachPointSettings = getAttachPointSettings();
|
||||
var jointName = (hand === RIGHT_HAND) ? "RightHand" : "LeftHand";
|
||||
|
@ -324,10 +345,12 @@ function removeMyAvatarFromCollidesWith(origCollidesWith) {
|
|||
// and we should not be showing lasers when someone else is using the Reticle to indicate a 2D minor mode.
|
||||
var EXTERNALLY_MANAGED_2D_MINOR_MODE = true;
|
||||
var EDIT_SETTING = "io.highfidelity.isEditting";
|
||||
|
||||
function isEditing() {
|
||||
var actualSettingValue = Settings.getValue(EDIT_SETTING) === "false" ? false : !!Settings.getValue(EDIT_SETTING);
|
||||
return EXTERNALLY_MANAGED_2D_MINOR_MODE && actualSettingValue;
|
||||
}
|
||||
|
||||
function isIn2DMode() {
|
||||
// In this version, we make our own determination of whether we're aimed a HUD element,
|
||||
// because other scripts (such as handControllerPointer) might be using some other visualization
|
||||
|
@ -335,6 +358,7 @@ function isIn2DMode() {
|
|||
return (EXTERNALLY_MANAGED_2D_MINOR_MODE &&
|
||||
(Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)));
|
||||
}
|
||||
|
||||
function restore2DMode() {
|
||||
if (!EXTERNALLY_MANAGED_2D_MINOR_MODE) {
|
||||
Reticle.setVisible(true);
|
||||
|
@ -487,7 +511,12 @@ EquipHotspotBuddy.prototype.updateHotspot = function (hotspot, timestamp) {
|
|||
overlayInfoSet.overlays.push(Overlays.addOverlay("model", {
|
||||
url: hotspot.modelURL,
|
||||
position: hotspot.worldPosition,
|
||||
rotation: {x: 0, y: 0, z: 0, w: 1},
|
||||
rotation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0,
|
||||
w: 1
|
||||
},
|
||||
dimensions: diameter * EQUIP_SPHERE_SCALE_FACTOR,
|
||||
scale: hotspot.modelScale,
|
||||
ignoreRayIntersection: true
|
||||
|
@ -497,7 +526,12 @@ EquipHotspotBuddy.prototype.updateHotspot = function (hotspot, timestamp) {
|
|||
// default sphere overlay
|
||||
overlayInfoSet.overlays.push(Overlays.addOverlay("sphere", {
|
||||
position: hotspot.worldPosition,
|
||||
rotation: {x: 0, y: 0, z: 0, w: 1},
|
||||
rotation: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0,
|
||||
w: 1
|
||||
},
|
||||
dimensions: diameter * EQUIP_SPHERE_SCALE_FACTOR,
|
||||
color: EQUIP_SPHERE_COLOR,
|
||||
alpha: EQUIP_SPHERE_ALPHA,
|
||||
|
@ -704,56 +738,7 @@ function MyController(hand) {
|
|||
}
|
||||
};
|
||||
|
||||
this.debugLine = function (closePoint, farPoint, color) {
|
||||
Entities.addEntity({
|
||||
type: "Line",
|
||||
name: "Grab Debug Entity",
|
||||
dimensions: LINE_ENTITY_DIMENSIONS,
|
||||
visible: true,
|
||||
position: closePoint,
|
||||
linePoints: [ZERO_VEC, farPoint],
|
||||
color: color,
|
||||
lifetime: 0.1,
|
||||
dynamic: false,
|
||||
ignoreForCollisions: true,
|
||||
userData: JSON.stringify({
|
||||
grabbableKey: {
|
||||
grabbable: false
|
||||
}
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
this.lineOn = function (closePoint, farPoint, color) {
|
||||
// draw a line
|
||||
if (this.pointer === null) {
|
||||
this.pointer = Entities.addEntity({
|
||||
type: "Line",
|
||||
name: "grab pointer",
|
||||
dimensions: LINE_ENTITY_DIMENSIONS,
|
||||
visible: true,
|
||||
position: closePoint,
|
||||
linePoints: [ZERO_VEC, farPoint],
|
||||
color: color,
|
||||
lifetime: LIFETIME,
|
||||
dynamic: false,
|
||||
ignoreForCollisions: true,
|
||||
userData: JSON.stringify({
|
||||
grabbableKey: {
|
||||
grabbable: false
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
var age = Entities.getEntityProperties(this.pointer, "age").age;
|
||||
this.pointer = Entities.editEntity(this.pointer, {
|
||||
position: closePoint,
|
||||
linePoints: [ZERO_VEC, farPoint],
|
||||
color: color,
|
||||
lifetime: age + LIFETIME
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.searchSphereOn = function(location, size, color) {
|
||||
|
||||
|
@ -830,10 +815,10 @@ function MyController(hand) {
|
|||
var searchSphereLocation = Vec3.sum(distantPickRay.origin,
|
||||
Vec3.multiply(distantPickRay.direction, this.searchSphereDistance));
|
||||
this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance,
|
||||
(this.triggerSmoothedGrab() || this.secondarySqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
||||
if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) {
|
||||
(this.triggerSmoothedGrab() || this.secondarySqueezed()) ? COLORS_GRAB_SEARCHING_FULL_SQUEEZE : COLORS_GRAB_SEARCHING_HALF_SQUEEZE);
|
||||
if (PICK_WITH_HAND_RAY) {
|
||||
this.overlayLineOn(handPosition, searchSphereLocation,
|
||||
(this.triggerSmoothedGrab() || this.secondarySqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
||||
(this.triggerSmoothedGrab() || this.secondarySqueezed()) ? COLORS_GRAB_SEARCHING_FULL_SQUEEZE : COLORS_GRAB_SEARCHING_HALF_SQUEEZE);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -881,14 +866,8 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.turnOffVisualizations = function() {
|
||||
if (USE_ENTITY_LINES_FOR_SEARCHING === true || USE_ENTITY_LINES_FOR_MOVING === true) {
|
||||
this.lineOff();
|
||||
}
|
||||
|
||||
if (USE_OVERLAY_LINES_FOR_SEARCHING === true || USE_OVERLAY_LINES_FOR_MOVING === true) {
|
||||
this.overlayLineOff();
|
||||
}
|
||||
|
||||
|
||||
this.searchSphereOff();
|
||||
restore2DMode();
|
||||
|
@ -1096,7 +1075,11 @@ function MyController(hand) {
|
|||
result.push({
|
||||
key: entityID.toString() + "0",
|
||||
entityID: entityID,
|
||||
localPosition: {x: 0, y: 0, z: 0},
|
||||
localPosition: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
worldPosition: entityXform.pos,
|
||||
radius: EQUIP_RADIUS,
|
||||
joints: wearableProps.joints,
|
||||
|
@ -1379,12 +1362,6 @@ function MyController(hand) {
|
|||
equipHotspotBuddy.highlightHotspot(potentialEquipHotspot);
|
||||
}
|
||||
|
||||
// search line visualizations
|
||||
if (USE_ENTITY_LINES_FOR_SEARCHING === true) {
|
||||
this.lineOn(rayPickInfo.searchRay.origin,
|
||||
Vec3.multiply(rayPickInfo.searchRay.direction, LINE_LENGTH),
|
||||
NO_INTERSECT_COLOR);
|
||||
}
|
||||
|
||||
this.searchIndicatorOn(rayPickInfo.searchRay);
|
||||
Reticle.setVisible(false);
|
||||
|
@ -1557,12 +1534,8 @@ function MyController(hand) {
|
|||
var handPosition = this.getHandPosition();
|
||||
|
||||
// visualizations
|
||||
if (USE_ENTITY_LINES_FOR_MOVING === true) {
|
||||
this.lineOn(handPosition, Vec3.subtract(grabbedProperties.position, handPosition), INTERSECT_COLOR);
|
||||
}
|
||||
if (USE_OVERLAY_LINES_FOR_MOVING === true) {
|
||||
|
||||
this.overlayLineOn(handPosition, grabbedProperties.position, INTERSECT_COLOR);
|
||||
}
|
||||
|
||||
var distanceToObject = Vec3.length(Vec3.subtract(MyAvatar.position, this.currentObjectPosition));
|
||||
var success = Entities.updateAction(this.grabbedEntity, this.actionID, {
|
||||
|
@ -1626,9 +1599,21 @@ function MyController(hand) {
|
|||
var pose = Controller.getPoseValue(standardControllerValue);
|
||||
var worldHandRotation = Quat.multiply(MyAvatar.orientation, pose.rotation);
|
||||
|
||||
var localHandUpAxis = this.hand === RIGHT_HAND ? {x: 1, y: 0, z: 0} : {x: -1, y: 0, z: 0};
|
||||
var localHandUpAxis = this.hand === RIGHT_HAND ? {
|
||||
x: 1,
|
||||
y: 0,
|
||||
z: 0
|
||||
} : {
|
||||
x: -1,
|
||||
y: 0,
|
||||
z: 0
|
||||
};
|
||||
var worldHandUpAxis = Vec3.multiplyQbyV(worldHandRotation, localHandUpAxis);
|
||||
var DOWN = {x: 0, y: -1, z: 0};
|
||||
var DOWN = {
|
||||
x: 0,
|
||||
y: -1,
|
||||
z: 0
|
||||
};
|
||||
|
||||
var DROP_ANGLE = Math.PI / 7;
|
||||
var HYSTERESIS_FACTOR = 1.1;
|
||||
|
@ -1743,8 +1728,16 @@ function MyController(hand) {
|
|||
}
|
||||
|
||||
Entities.editEntity(this.grabbedEntity, {
|
||||
velocity: {x: 0, y: 0, z: 0},
|
||||
angularVelocity: {x: 0, y: 0, z: 0},
|
||||
velocity: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
angularVelocity: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
dynamic: false
|
||||
});
|
||||
|
||||
|
@ -2105,7 +2098,9 @@ function MyController(hand) {
|
|||
// people are holding something and one of them will be able (if the other releases at the right time) to
|
||||
// bootstrap themselves with the held object. This happens because the meaning of "otherAvatar" in
|
||||
// the collision mask hinges on who the physics simulation owner is.
|
||||
Entities.editEntity(entityID, {"collidesWith": COLLIDES_WITH_WHILE_MULTI_GRABBED});
|
||||
Entities.editEntity(entityID, {
|
||||
"collidesWith": COLLIDES_WITH_WHILE_MULTI_GRABBED
|
||||
});
|
||||
}
|
||||
}
|
||||
setEntityCustomData(GRAB_USER_DATA_KEY, entityID, data);
|
||||
|
@ -2119,7 +2114,9 @@ function MyController(hand) {
|
|||
var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, handJointIndex);
|
||||
children.forEach(function(childID) {
|
||||
print("disconnecting stray child of hand: (" + _this.hand + ") " + childID);
|
||||
Entities.editEntity(childID, {parentID: NULL_UUID});
|
||||
Entities.editEntity(childID, {
|
||||
parentID: NULL_UUID
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -2129,7 +2126,9 @@ function MyController(hand) {
|
|||
// are delayed a bit. This keeps thrown things from colliding with the avatar's capsule so often.
|
||||
// The refcount is handled in this delayed fashion so things don't get confused if someone else
|
||||
// grabs the entity before the timeout fires.
|
||||
Entities.editEntity(entityID, { collidesWith: collidesWith });
|
||||
Entities.editEntity(entityID, {
|
||||
collidesWith: collidesWith
|
||||
});
|
||||
var data = getEntityCustomData(GRAB_USER_DATA_KEY, entityID, {});
|
||||
if (data && data["refCount"]) {
|
||||
data["refCount"] = data["refCount"] - 1;
|
||||
|
@ -2204,12 +2203,24 @@ function MyController(hand) {
|
|||
data["dynamic"] &&
|
||||
data["parentID"] == NULL_UUID &&
|
||||
!data["collisionless"]) {
|
||||
deactiveProps["velocity"] = {x: 0.0, y: 0.1, z: 0.0};
|
||||
deactiveProps["velocity"] = {
|
||||
x: 0.0,
|
||||
y: 0.1,
|
||||
z: 0.0
|
||||
};
|
||||
doSetVelocity = false;
|
||||
}
|
||||
if (noVelocity) {
|
||||
deactiveProps["velocity"] = {x: 0.0, y: 0.0, z: 0.0};
|
||||
deactiveProps["angularVelocity"] = {x: 0.0, y: 0.0, z: 0.0};
|
||||
deactiveProps["velocity"] = {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0
|
||||
};
|
||||
deactiveProps["angularVelocity"] = {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0
|
||||
};
|
||||
doSetVelocity = false;
|
||||
}
|
||||
|
||||
|
@ -2231,14 +2242,32 @@ function MyController(hand) {
|
|||
deactiveProps = {
|
||||
parentID: this.previousParentID,
|
||||
parentJointIndex: this.previousParentJointIndex,
|
||||
velocity: {x: 0.0, y: 0.0, z: 0.0},
|
||||
angularVelocity: {x: 0.0, y: 0.0, z: 0.0}
|
||||
velocity: {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0
|
||||
},
|
||||
angularVelocity: {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0
|
||||
}
|
||||
};
|
||||
Entities.editEntity(entityID, deactiveProps);
|
||||
} else if (noVelocity) {
|
||||
Entities.editEntity(entityID, {velocity: {x: 0.0, y: 0.0, z: 0.0},
|
||||
angularVelocity: {x: 0.0, y: 0.0, z: 0.0},
|
||||
dynamic: data["dynamic"]});
|
||||
Entities.editEntity(entityID, {
|
||||
velocity: {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0
|
||||
},
|
||||
angularVelocity: {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0
|
||||
},
|
||||
dynamic: data["dynamic"]
|
||||
});
|
||||
}
|
||||
} else {
|
||||
data = null;
|
||||
|
|
|
@ -45,6 +45,18 @@ var TARGET_MODEL_DIMENSIONS = {
|
|||
|
||||
};
|
||||
|
||||
|
||||
var COLORS_TELEPORT_CAN_TELEPORT = {
|
||||
red: 136,
|
||||
green: 255,
|
||||
blue: 241
|
||||
};
|
||||
var COLORS_TELEPORT_CANNOT_TELEPORT = {
|
||||
red: 68,
|
||||
green: 183,
|
||||
blue: 180
|
||||
};
|
||||
|
||||
function ThumbPad(hand) {
|
||||
this.hand = hand;
|
||||
var _thisPad = this;
|
||||
|
@ -275,11 +287,7 @@ function Teleporter() {
|
|||
var rightIntersection = Entities.findRayIntersection(teleporter.rightPickRay, true, [], [this.targetEntity]);
|
||||
|
||||
if (rightIntersection.intersects) {
|
||||
this.rightLineOn(rightPickRay.origin, rightIntersection.intersection, {
|
||||
red: 7,
|
||||
green: 36,
|
||||
blue: 44
|
||||
});
|
||||
this.rightLineOn(rightPickRay.origin, rightIntersection.intersection, COLORS_TELEPORT_CAN_TELEPORT);
|
||||
if (this.targetOverlay !== null) {
|
||||
this.updateTargetOverlay(rightIntersection);
|
||||
} else {
|
||||
|
@ -289,11 +297,7 @@ function Teleporter() {
|
|||
} else {
|
||||
|
||||
this.deleteTargetOverlay();
|
||||
this.rightLineOn(rightPickRay.origin, location, {
|
||||
red: 7,
|
||||
green: 36,
|
||||
blue: 44
|
||||
});
|
||||
this.rightLineOn(rightPickRay.origin, location, COLORS_TELEPORT_CANNOT_TELEPORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -325,11 +329,7 @@ function Teleporter() {
|
|||
|
||||
if (leftIntersection.intersects) {
|
||||
|
||||
this.leftLineOn(leftPickRay.origin, leftIntersection.intersection, {
|
||||
red: 7,
|
||||
green: 36,
|
||||
blue: 44
|
||||
});
|
||||
this.leftLineOn(leftPickRay.origin, leftIntersection.intersection, COLORS_TELEPORT_CAN_TELEPORT);
|
||||
if (this.targetOverlay !== null) {
|
||||
this.updateTargetOverlay(leftIntersection);
|
||||
} else {
|
||||
|
@ -341,11 +341,7 @@ function Teleporter() {
|
|||
|
||||
|
||||
this.deleteTargetOverlay();
|
||||
this.leftLineOn(leftPickRay.origin, location, {
|
||||
red: 7,
|
||||
green: 36,
|
||||
blue: 44
|
||||
});
|
||||
this.leftLineOn(leftPickRay.origin, location, COLORS_TELEPORT_CANNOT_TELEPORT);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue