mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
remove prints and format
This commit is contained in:
parent
3492367c63
commit
5ca14b528b
5 changed files with 147 additions and 81 deletions
|
@ -23,5 +23,6 @@ Script.load("system/controllers/handControllerGrab.js");
|
||||||
Script.load("system/controllers/handControllerPointer.js");
|
Script.load("system/controllers/handControllerPointer.js");
|
||||||
Script.load("system/controllers/squeezeHands.js");
|
Script.load("system/controllers/squeezeHands.js");
|
||||||
Script.load("system/controllers/grab.js");
|
Script.load("system/controllers/grab.js");
|
||||||
|
Script.load("system/controllers/teleport.js");
|
||||||
Script.load("system/dialTone.js");
|
Script.load("system/dialTone.js");
|
||||||
Script.load("system/firstPersonHMD.js");
|
Script.load("system/firstPersonHMD.js");
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -49,8 +49,8 @@ var DROP_WITHOUT_SHAKE = false;
|
||||||
|
|
||||||
var DISTANCE_HOLDING_RADIUS_FACTOR = 3.5; // multiplied by distance between hand and object
|
var DISTANCE_HOLDING_RADIUS_FACTOR = 3.5; // multiplied by distance between hand and object
|
||||||
var DISTANCE_HOLDING_ACTION_TIMEFRAME = 0.1; // how quickly objects move to their new position
|
var DISTANCE_HOLDING_ACTION_TIMEFRAME = 0.1; // how quickly objects move to their new position
|
||||||
var DISTANCE_HOLDING_UNITY_MASS = 1200; // The mass at which the distance holding action timeframe is unmodified
|
var DISTANCE_HOLDING_UNITY_MASS = 1200; // The mass at which the distance holding action timeframe is unmodified
|
||||||
var DISTANCE_HOLDING_UNITY_DISTANCE = 6; // The distance at which the distance holding action timeframe is unmodified
|
var DISTANCE_HOLDING_UNITY_DISTANCE = 6; // The distance at which the distance holding action timeframe is unmodified
|
||||||
var MOVE_WITH_HEAD = true; // experimental head-control of distantly held objects
|
var MOVE_WITH_HEAD = true; // experimental head-control of distantly held objects
|
||||||
|
|
||||||
var NO_INTERSECT_COLOR = {
|
var NO_INTERSECT_COLOR = {
|
||||||
|
@ -81,7 +81,7 @@ var EQUIP_RADIUS = 0.1; // radius used for palm vs equip-hotspot for equipping.
|
||||||
var NEAR_GRABBING_ACTION_TIMEFRAME = 0.05; // how quickly objects move to their new position
|
var NEAR_GRABBING_ACTION_TIMEFRAME = 0.05; // how quickly objects move to their new position
|
||||||
|
|
||||||
var NEAR_GRAB_RADIUS = 0.15; // radius used for palm vs object for near grabbing.
|
var NEAR_GRAB_RADIUS = 0.15; // radius used for palm vs object for near grabbing.
|
||||||
var NEAR_GRAB_MAX_DISTANCE = 1.0; // you cannot grab objects that are this far away from your hand
|
var NEAR_GRAB_MAX_DISTANCE = 1.0; // you cannot grab objects that are this far away from your hand
|
||||||
|
|
||||||
var NEAR_GRAB_PICK_RADIUS = 0.25; // radius used for search ray vs object for near grabbing.
|
var NEAR_GRAB_PICK_RADIUS = 0.25; // radius used for search ray vs object for near grabbing.
|
||||||
|
|
||||||
|
@ -251,13 +251,15 @@ function propsArePhysical(props) {
|
||||||
// If another script is managing the reticle (as is done by HandControllerPointer), we should not be setting it here,
|
// If another script is managing the reticle (as is done by HandControllerPointer), we should not be setting it here,
|
||||||
// and we should not be showing lasers when someone else is using the Reticle to indicate a 2D minor mode.
|
// 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 EXTERNALLY_MANAGED_2D_MINOR_MODE = true;
|
||||||
|
|
||||||
function isIn2DMode() {
|
function isIn2DMode() {
|
||||||
// In this version, we make our own determination of whether we're aimed a HUD element,
|
// 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
|
// because other scripts (such as handControllerPointer) might be using some other visualization
|
||||||
// instead of setting Reticle.visible.
|
// instead of setting Reticle.visible.
|
||||||
return (EXTERNALLY_MANAGED_2D_MINOR_MODE &&
|
return (EXTERNALLY_MANAGED_2D_MINOR_MODE &&
|
||||||
(Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)));
|
(Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function restore2DMode() {
|
function restore2DMode() {
|
||||||
if (!EXTERNALLY_MANAGED_2D_MINOR_MODE) {
|
if (!EXTERNALLY_MANAGED_2D_MINOR_MODE) {
|
||||||
Reticle.setVisible(true);
|
Reticle.setVisible(true);
|
||||||
|
@ -399,7 +401,6 @@ function MyController(hand) {
|
||||||
this.updateSmoothedTrigger();
|
this.updateSmoothedTrigger();
|
||||||
|
|
||||||
if (this.ignoreInput()) {
|
if (this.ignoreInput()) {
|
||||||
// print('in ignore input turn off')
|
|
||||||
this.turnOffVisualizations();
|
this.turnOffVisualizations();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -520,7 +521,7 @@ function MyController(hand) {
|
||||||
visible: true
|
visible: true
|
||||||
};
|
};
|
||||||
this.searchSphere = Overlays.addOverlay("sphere", sphereProperties);
|
this.searchSphere = Overlays.addOverlay("sphere", sphereProperties);
|
||||||
print('CREATED SEARCH OVERLAY : '+ this.searchSphere)
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Overlays.editOverlay(this.searchSphere, {
|
Overlays.editOverlay(this.searchSphere, {
|
||||||
|
@ -529,7 +530,7 @@ function MyController(hand) {
|
||||||
color: color,
|
color: color,
|
||||||
visible: true
|
visible: true
|
||||||
});
|
});
|
||||||
print('EDITED SEARCH OVERLAY : '+ this.searchSphere)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -547,7 +548,6 @@ function MyController(hand) {
|
||||||
alpha: 1
|
alpha: 1
|
||||||
};
|
};
|
||||||
this.overlayLine = Overlays.addOverlay("line3d", lineProperties);
|
this.overlayLine = Overlays.addOverlay("line3d", lineProperties);
|
||||||
print('CREATED OVERLAY IT IS ' + this.overlayLine )
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Overlays.editOverlay(this.overlayLine, {
|
Overlays.editOverlay(this.overlayLine, {
|
||||||
|
@ -560,9 +560,8 @@ function MyController(hand) {
|
||||||
drawInFront: true, // Even when burried inside of something, show it.
|
drawInFront: true, // Even when burried inside of something, show it.
|
||||||
alpha: 1
|
alpha: 1
|
||||||
});
|
});
|
||||||
print('edited overlay line ' + this.overlayLine )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.searchIndicatorOn = function(distantPickRay) {
|
this.searchIndicatorOn = function(distantPickRay) {
|
||||||
|
@ -577,12 +576,12 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var searchSphereLocation = Vec3.sum(distantPickRay.origin,
|
var searchSphereLocation = Vec3.sum(distantPickRay.origin,
|
||||||
Vec3.multiply(distantPickRay.direction, this.searchSphereDistance));
|
Vec3.multiply(distantPickRay.direction, this.searchSphereDistance));
|
||||||
this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance,
|
this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance,
|
||||||
(this.triggerSmoothedGrab() || this.secondarySqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
(this.triggerSmoothedGrab() || this.secondarySqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
||||||
if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) {
|
if ((USE_OVERLAY_LINES_FOR_SEARCHING === true) && PICK_WITH_HAND_RAY) {
|
||||||
this.overlayLineOn(handPosition, searchSphereLocation,
|
this.overlayLineOn(handPosition, searchSphereLocation,
|
||||||
(this.triggerSmoothedGrab() || this.secondarySqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
(this.triggerSmoothedGrab() || this.secondarySqueezed()) ? INTERSECT_COLOR : NO_INTERSECT_COLOR);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -766,13 +765,9 @@ function MyController(hand) {
|
||||||
|
|
||||||
this.overlayLineOff = function() {
|
this.overlayLineOff = function() {
|
||||||
if (_this.overlayLine !== null) {
|
if (_this.overlayLine !== null) {
|
||||||
Overlays.deleteOverlay(this.overlayLine);
|
Overlays.deleteOverlay(this.overlayLine);
|
||||||
print('REMOVING OVERLAY LINE' + this.overlayLine)
|
_this.overlayLine = null;
|
||||||
_this.overlayLine = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// print('overlay shoudl be null and is line is ' + this.overlayLine)
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.searchSphereOff = function() {
|
this.searchSphereOff = function() {
|
||||||
|
@ -805,27 +800,21 @@ function MyController(hand) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.turnOffVisualizations = function(hand) {
|
this.turnOffVisualizations = function(hand) {
|
||||||
// print('TURN OFF VISUALIZATIONS: ' + hand)
|
|
||||||
if (USE_ENTITY_LINES_FOR_SEARCHING === true || USE_ENTITY_LINES_FOR_MOVING === true) {
|
if (USE_ENTITY_LINES_FOR_SEARCHING === true || USE_ENTITY_LINES_FOR_MOVING === true) {
|
||||||
this.lineOff();
|
this.lineOff();
|
||||||
// print('after line off')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (USE_OVERLAY_LINES_FOR_SEARCHING === true || USE_OVERLAY_LINES_FOR_MOVING === true) {
|
if (USE_OVERLAY_LINES_FOR_SEARCHING === true || USE_OVERLAY_LINES_FOR_MOVING === true) {
|
||||||
this.overlayLineOff();
|
this.overlayLineOff();
|
||||||
// print('after overlay line off')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (USE_PARTICLE_BEAM_FOR_MOVING === true) {
|
if (USE_PARTICLE_BEAM_FOR_MOVING === true) {
|
||||||
this.particleBeamOff();
|
this.particleBeamOff();
|
||||||
// print('after particle beam off')
|
|
||||||
|
|
||||||
}
|
}
|
||||||
this.searchSphereOff();
|
this.searchSphereOff();
|
||||||
restore2DMode();
|
restore2DMode();
|
||||||
|
|
||||||
// print('after all turn off calls')
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.triggerPress = function(value) {
|
this.triggerPress = function(value) {
|
||||||
|
@ -901,18 +890,34 @@ function MyController(hand) {
|
||||||
this.createHotspots = function() {
|
this.createHotspots = function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
|
|
||||||
var HAND_EQUIP_SPHERE_COLOR = { red: 90, green: 255, blue: 90 };
|
var HAND_EQUIP_SPHERE_COLOR = {
|
||||||
|
red: 90,
|
||||||
|
green: 255,
|
||||||
|
blue: 90
|
||||||
|
};
|
||||||
var HAND_EQUIP_SPHERE_ALPHA = 0.7;
|
var HAND_EQUIP_SPHERE_ALPHA = 0.7;
|
||||||
var HAND_EQUIP_SPHERE_RADIUS = 0.01;
|
var HAND_EQUIP_SPHERE_RADIUS = 0.01;
|
||||||
|
|
||||||
var HAND_GRAB_SPHERE_COLOR = { red: 90, green: 90, blue: 255 };
|
var HAND_GRAB_SPHERE_COLOR = {
|
||||||
|
red: 90,
|
||||||
|
green: 90,
|
||||||
|
blue: 255
|
||||||
|
};
|
||||||
var HAND_GRAB_SPHERE_ALPHA = 0.3;
|
var HAND_GRAB_SPHERE_ALPHA = 0.3;
|
||||||
var HAND_GRAB_SPHERE_RADIUS = NEAR_GRAB_RADIUS;
|
var HAND_GRAB_SPHERE_RADIUS = NEAR_GRAB_RADIUS;
|
||||||
|
|
||||||
var EQUIP_SPHERE_COLOR = { red: 90, green: 255, blue: 90 };
|
var EQUIP_SPHERE_COLOR = {
|
||||||
|
red: 90,
|
||||||
|
green: 255,
|
||||||
|
blue: 90
|
||||||
|
};
|
||||||
var EQUIP_SPHERE_ALPHA = 0.3;
|
var EQUIP_SPHERE_ALPHA = 0.3;
|
||||||
|
|
||||||
var GRAB_BOX_COLOR = { red: 90, green: 90, blue: 255 };
|
var GRAB_BOX_COLOR = {
|
||||||
|
red: 90,
|
||||||
|
green: 90,
|
||||||
|
blue: 255
|
||||||
|
};
|
||||||
var GRAB_BOX_ALPHA = 0.1;
|
var GRAB_BOX_ALPHA = 0.1;
|
||||||
|
|
||||||
this.hotspotOverlays = [];
|
this.hotspotOverlays = [];
|
||||||
|
@ -936,7 +941,6 @@ function MyController(hand) {
|
||||||
overlay: overlay,
|
overlay: overlay,
|
||||||
type: "hand"
|
type: "hand"
|
||||||
});
|
});
|
||||||
print('ADDED HAND SPHERE OVERLAY : '+overlay)
|
|
||||||
|
|
||||||
// add larger blue sphere around the palm.
|
// add larger blue sphere around the palm.
|
||||||
overlay = Overlays.addOverlay("sphere", {
|
overlay = Overlays.addOverlay("sphere", {
|
||||||
|
@ -949,13 +953,16 @@ function MyController(hand) {
|
||||||
ignoreRayIntersection: true,
|
ignoreRayIntersection: true,
|
||||||
drawInFront: false
|
drawInFront: false
|
||||||
});
|
});
|
||||||
print('ADDED HAND SPHERE OVERLAY : '+overlay)
|
|
||||||
|
|
||||||
this.hotspotOverlays.push({
|
this.hotspotOverlays.push({
|
||||||
entityID: undefined,
|
entityID: undefined,
|
||||||
overlay: overlay,
|
overlay: overlay,
|
||||||
type: "hand",
|
type: "hand",
|
||||||
localPosition: {x: 0, y: 0, z: 0}
|
localPosition: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,13 +986,16 @@ function MyController(hand) {
|
||||||
ignoreRayIntersection: true,
|
ignoreRayIntersection: true,
|
||||||
drawInFront: false
|
drawInFront: false
|
||||||
});
|
});
|
||||||
print('ADDED GRAB BOX OVERLAY : '+ overlay)
|
|
||||||
|
|
||||||
_this.hotspotOverlays.push({
|
_this.hotspotOverlays.push({
|
||||||
entityID: entityID,
|
entityID: entityID,
|
||||||
overlay: overlay,
|
overlay: overlay,
|
||||||
type: "near",
|
type: "near",
|
||||||
localPosition: {x: 0, y: 0, z: 0}
|
localPosition: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1007,7 +1017,6 @@ function MyController(hand) {
|
||||||
ignoreRayIntersection: true,
|
ignoreRayIntersection: true,
|
||||||
drawInFront: false
|
drawInFront: false
|
||||||
});
|
});
|
||||||
print('ADDED SPHERE HOTSTPOT OVERLAY : '+ overlay)
|
|
||||||
|
|
||||||
_this.hotspotOverlays.push({
|
_this.hotspotOverlays.push({
|
||||||
entityID: hotspot.entityID,
|
entityID: hotspot.entityID,
|
||||||
|
@ -1023,7 +1032,9 @@ function MyController(hand) {
|
||||||
var props;
|
var props;
|
||||||
this.hotspotOverlays.forEach(function(overlayInfo) {
|
this.hotspotOverlays.forEach(function(overlayInfo) {
|
||||||
if (overlayInfo.type === "hand") {
|
if (overlayInfo.type === "hand") {
|
||||||
Overlays.editOverlay(overlayInfo.overlay, { position: _this.getHandPosition() });
|
Overlays.editOverlay(overlayInfo.overlay, {
|
||||||
|
position: _this.getHandPosition()
|
||||||
|
});
|
||||||
} else if (overlayInfo.type === "equip") {
|
} else if (overlayInfo.type === "equip") {
|
||||||
_this.entityPropertyCache.updateEntity(overlayInfo.entityID);
|
_this.entityPropertyCache.updateEntity(overlayInfo.entityID);
|
||||||
props = _this.entityPropertyCache.getProps(overlayInfo.entityID);
|
props = _this.entityPropertyCache.getProps(overlayInfo.entityID);
|
||||||
|
@ -1035,15 +1046,16 @@ function MyController(hand) {
|
||||||
} else if (overlayInfo.type === "near") {
|
} else if (overlayInfo.type === "near") {
|
||||||
_this.entityPropertyCache.updateEntity(overlayInfo.entityID);
|
_this.entityPropertyCache.updateEntity(overlayInfo.entityID);
|
||||||
props = _this.entityPropertyCache.getProps(overlayInfo.entityID);
|
props = _this.entityPropertyCache.getProps(overlayInfo.entityID);
|
||||||
Overlays.editOverlay(overlayInfo.overlay, { position: props.position, rotation: props.rotation });
|
Overlays.editOverlay(overlayInfo.overlay, {
|
||||||
|
position: props.position,
|
||||||
|
rotation: props.rotation
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.destroyHotspots = function() {
|
this.destroyHotspots = function() {
|
||||||
this.hotspotOverlays.forEach(function(overlayInfo) {
|
this.hotspotOverlays.forEach(function(overlayInfo) {
|
||||||
print('deleting overlay hotspot ' + overlayInfo.overlay)
|
|
||||||
|
|
||||||
Overlays.deleteOverlay(overlayInfo.overlay);
|
Overlays.deleteOverlay(overlayInfo.overlay);
|
||||||
});
|
});
|
||||||
this.hotspotOverlays = [];
|
this.hotspotOverlays = [];
|
||||||
|
@ -1071,8 +1083,8 @@ function MyController(hand) {
|
||||||
var pickRay = {
|
var pickRay = {
|
||||||
origin: PICK_WITH_HAND_RAY ? worldHandPosition : Camera.position,
|
origin: PICK_WITH_HAND_RAY ? worldHandPosition : Camera.position,
|
||||||
direction: PICK_WITH_HAND_RAY ? Quat.getUp(worldHandRotation) : Vec3.mix(Quat.getUp(worldHandRotation),
|
direction: PICK_WITH_HAND_RAY ? Quat.getUp(worldHandRotation) : Vec3.mix(Quat.getUp(worldHandRotation),
|
||||||
Quat.getFront(Camera.orientation),
|
Quat.getFront(Camera.orientation),
|
||||||
HAND_HEAD_MIX_RATIO),
|
HAND_HEAD_MIX_RATIO),
|
||||||
length: PICK_MAX_DISTANCE
|
length: PICK_MAX_DISTANCE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1157,7 +1169,11 @@ function MyController(hand) {
|
||||||
if (wearableProps && wearableProps.joints) {
|
if (wearableProps && wearableProps.joints) {
|
||||||
result.push({
|
result.push({
|
||||||
entityID: entityID,
|
entityID: entityID,
|
||||||
localPosition: {x: 0, y: 0, z: 0},
|
localPosition: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
worldPosition: entityXform.pos,
|
worldPosition: entityXform.pos,
|
||||||
radius: EQUIP_RADIUS,
|
radius: EQUIP_RADIUS,
|
||||||
joints: wearableProps.joints
|
joints: wearableProps.joints
|
||||||
|
@ -1174,8 +1190,8 @@ function MyController(hand) {
|
||||||
|
|
||||||
var refCount = ("refCount" in grabProps) ? grabProps.refCount : 0;
|
var refCount = ("refCount" in grabProps) ? grabProps.refCount : 0;
|
||||||
var okToEquipFromOtherHand = ((this.getOtherHandController().state == STATE_NEAR_GRABBING ||
|
var okToEquipFromOtherHand = ((this.getOtherHandController().state == STATE_NEAR_GRABBING ||
|
||||||
this.getOtherHandController().state == STATE_DISTANCE_HOLDING) &&
|
this.getOtherHandController().state == STATE_DISTANCE_HOLDING) &&
|
||||||
this.getOtherHandController().grabbedEntity == hotspot.entityID);
|
this.getOtherHandController().grabbedEntity == hotspot.entityID);
|
||||||
if (refCount > 0 && !okToEquipFromOtherHand) {
|
if (refCount > 0 && !okToEquipFromOtherHand) {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
print("equip is skipping '" + props.name + "': grabbed by someone else");
|
print("equip is skipping '" + props.name + "': grabbed by someone else");
|
||||||
|
@ -1423,8 +1439,8 @@ function MyController(hand) {
|
||||||
// search line visualizations
|
// search line visualizations
|
||||||
if (USE_ENTITY_LINES_FOR_SEARCHING === true) {
|
if (USE_ENTITY_LINES_FOR_SEARCHING === true) {
|
||||||
this.lineOn(rayPickInfo.searchRay.origin,
|
this.lineOn(rayPickInfo.searchRay.origin,
|
||||||
Vec3.multiply(rayPickInfo.searchRay.direction, LINE_LENGTH),
|
Vec3.multiply(rayPickInfo.searchRay.direction, LINE_LENGTH),
|
||||||
NO_INTERSECT_COLOR);
|
NO_INTERSECT_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.searchIndicatorOn(rayPickInfo.searchRay);
|
this.searchIndicatorOn(rayPickInfo.searchRay);
|
||||||
|
@ -1515,7 +1531,7 @@ function MyController(hand) {
|
||||||
|
|
||||||
// controller pose is in avatar frame
|
// controller pose is in avatar frame
|
||||||
var avatarControllerPose = Controller.getPoseValue((this.hand === RIGHT_HAND) ?
|
var avatarControllerPose = Controller.getPoseValue((this.hand === RIGHT_HAND) ?
|
||||||
Controller.Standard.RightHand : Controller.Standard.LeftHand);
|
Controller.Standard.RightHand : Controller.Standard.LeftHand);
|
||||||
|
|
||||||
// transform it into world frame
|
// transform it into world frame
|
||||||
var controllerPositionVSAvatar = Vec3.multiplyQbyV(MyAvatar.orientation, avatarControllerPose.translation);
|
var controllerPositionVSAvatar = Vec3.multiplyQbyV(MyAvatar.orientation, avatarControllerPose.translation);
|
||||||
|
@ -1537,7 +1553,7 @@ function MyController(hand) {
|
||||||
|
|
||||||
// scale delta controller hand movement by radius.
|
// scale delta controller hand movement by radius.
|
||||||
var handMoved = Vec3.multiply(Vec3.subtract(controllerPositionVSAvatar, this.previousControllerPositionVSAvatar),
|
var handMoved = Vec3.multiply(Vec3.subtract(controllerPositionVSAvatar, this.previousControllerPositionVSAvatar),
|
||||||
radius);
|
radius);
|
||||||
|
|
||||||
/// double delta controller rotation
|
/// double delta controller rotation
|
||||||
// var DISTANCE_HOLDING_ROTATION_EXAGGERATION_FACTOR = 2.0; // object rotates this much more than hand did
|
// var DISTANCE_HOLDING_ROTATION_EXAGGERATION_FACTOR = 2.0; // object rotates this much more than hand did
|
||||||
|
@ -1562,7 +1578,7 @@ function MyController(hand) {
|
||||||
var lastVelocity = Vec3.subtract(controllerPositionVSAvatar, this.previousControllerPositionVSAvatar);
|
var lastVelocity = Vec3.subtract(controllerPositionVSAvatar, this.previousControllerPositionVSAvatar);
|
||||||
lastVelocity = Vec3.multiply(lastVelocity, 1.0 / deltaObjectTime);
|
lastVelocity = Vec3.multiply(lastVelocity, 1.0 / deltaObjectTime);
|
||||||
var newRadialVelocity = Vec3.dot(lastVelocity,
|
var newRadialVelocity = Vec3.dot(lastVelocity,
|
||||||
Vec3.normalize(Vec3.subtract(grabbedProperties.position, controllerPosition)));
|
Vec3.normalize(Vec3.subtract(grabbedProperties.position, controllerPosition)));
|
||||||
|
|
||||||
var VELOCITY_AVERAGING_TIME = 0.016;
|
var VELOCITY_AVERAGING_TIME = 0.016;
|
||||||
this.grabRadialVelocity = (deltaObjectTime / VELOCITY_AVERAGING_TIME) * newRadialVelocity +
|
this.grabRadialVelocity = (deltaObjectTime / VELOCITY_AVERAGING_TIME) * newRadialVelocity +
|
||||||
|
@ -1571,7 +1587,7 @@ function MyController(hand) {
|
||||||
var RADIAL_GRAB_AMPLIFIER = 10.0;
|
var RADIAL_GRAB_AMPLIFIER = 10.0;
|
||||||
if (Math.abs(this.grabRadialVelocity) > 0.0) {
|
if (Math.abs(this.grabRadialVelocity) > 0.0) {
|
||||||
this.grabRadius = this.grabRadius + (this.grabRadialVelocity * deltaObjectTime *
|
this.grabRadius = this.grabRadius + (this.grabRadialVelocity * deltaObjectTime *
|
||||||
this.grabRadius * RADIAL_GRAB_AMPLIFIER);
|
this.grabRadius * RADIAL_GRAB_AMPLIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
var newTargetPosition = Vec3.multiply(this.grabRadius, Quat.getUp(controllerRotation));
|
var newTargetPosition = Vec3.multiply(this.grabRadius, Quat.getUp(controllerRotation));
|
||||||
|
@ -1689,16 +1705,28 @@ function MyController(hand) {
|
||||||
if (this.fastHandMoveTimer < 0) {
|
if (this.fastHandMoveTimer < 0) {
|
||||||
this.fastHandMoveDetected = false;
|
this.fastHandMoveDetected = false;
|
||||||
}
|
}
|
||||||
var FAST_HAND_SPEED_REST_TIME = 1; // sec
|
var FAST_HAND_SPEED_REST_TIME = 1; // sec
|
||||||
var FAST_HAND_SPEED_THRESHOLD = 0.4; // m/sec
|
var FAST_HAND_SPEED_THRESHOLD = 0.4; // m/sec
|
||||||
if (Vec3.length(worldHandVelocity) > FAST_HAND_SPEED_THRESHOLD) {
|
if (Vec3.length(worldHandVelocity) > FAST_HAND_SPEED_THRESHOLD) {
|
||||||
this.fastHandMoveDetected = true;
|
this.fastHandMoveDetected = true;
|
||||||
this.fastHandMoveTimer = FAST_HAND_SPEED_REST_TIME;
|
this.fastHandMoveTimer = FAST_HAND_SPEED_REST_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 worldHandUpAxis = Vec3.multiplyQbyV(worldHandRotation, localHandUpAxis);
|
||||||
var DOWN = {x: 0, y: -1, z: 0};
|
var DOWN = {
|
||||||
|
x: 0,
|
||||||
|
y: -1,
|
||||||
|
z: 0
|
||||||
|
};
|
||||||
var ROTATION_THRESHOLD = Math.cos(Math.PI / 8);
|
var ROTATION_THRESHOLD = Math.cos(Math.PI / 8);
|
||||||
|
|
||||||
var handIsUpsideDown = false;
|
var handIsUpsideDown = false;
|
||||||
|
@ -1800,8 +1828,16 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.editEntity(this.grabbedEntity, {
|
Entities.editEntity(this.grabbedEntity, {
|
||||||
velocity: {x: 0, y: 0, z: 0},
|
velocity: {
|
||||||
angularVelocity: {x: 0, y: 0, z: 0},
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
angularVelocity: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
dynamic: false
|
dynamic: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1868,7 +1904,7 @@ function MyController(hand) {
|
||||||
if (nearPickedCandidateEntities.indexOf(this.grabbedEntity) == -1) {
|
if (nearPickedCandidateEntities.indexOf(this.grabbedEntity) == -1) {
|
||||||
// for whatever reason, the held/equipped entity has been pulled away. ungrab or unequip.
|
// for whatever reason, the held/equipped entity has been pulled away. ungrab or unequip.
|
||||||
print("handControllerGrab -- autoreleasing held or equipped item because it is far from hand." +
|
print("handControllerGrab -- autoreleasing held or equipped item because it is far from hand." +
|
||||||
props.parentID + " " + vec3toStr(props.position));
|
props.parentID + " " + vec3toStr(props.position));
|
||||||
|
|
||||||
if (this.state == STATE_NEAR_GRABBING) {
|
if (this.state == STATE_NEAR_GRABBING) {
|
||||||
this.callEntityMethodOnGrabbed("releaseGrab");
|
this.callEntityMethodOnGrabbed("releaseGrab");
|
||||||
|
@ -2110,7 +2146,9 @@ function MyController(hand) {
|
||||||
// people are holding something and one of them will be able (if the other releases at the right time) to
|
// 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
|
// 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.
|
// 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);
|
setEntityCustomData(GRAB_USER_DATA_KEY, entityID, data);
|
||||||
|
@ -2124,7 +2162,9 @@ function MyController(hand) {
|
||||||
var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, handJointIndex);
|
var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, handJointIndex);
|
||||||
children.forEach(function(childID) {
|
children.forEach(function(childID) {
|
||||||
print("disconnecting stray child of hand: (" + _this.hand + ") " + childID);
|
print("disconnecting stray child of hand: (" + _this.hand + ") " + childID);
|
||||||
Entities.editEntity(childID, {parentID: NULL_UUID});
|
Entities.editEntity(childID, {
|
||||||
|
parentID: NULL_UUID
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2170,12 +2210,24 @@ function MyController(hand) {
|
||||||
data["dynamic"] &&
|
data["dynamic"] &&
|
||||||
data["parentID"] == NULL_UUID &&
|
data["parentID"] == NULL_UUID &&
|
||||||
!data["collisionless"]) {
|
!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;
|
doSetVelocity = false;
|
||||||
}
|
}
|
||||||
if (noVelocity) {
|
if (noVelocity) {
|
||||||
deactiveProps["velocity"] = {x: 0.0, y: 0.0, z: 0.0};
|
deactiveProps["velocity"] = {
|
||||||
deactiveProps["angularVelocity"] = {x: 0.0, y: 0.0, z: 0.0};
|
x: 0.0,
|
||||||
|
y: 0.0,
|
||||||
|
z: 0.0
|
||||||
|
};
|
||||||
|
deactiveProps["angularVelocity"] = {
|
||||||
|
x: 0.0,
|
||||||
|
y: 0.0,
|
||||||
|
z: 0.0
|
||||||
|
};
|
||||||
doSetVelocity = false;
|
doSetVelocity = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2188,7 +2240,7 @@ function MyController(hand) {
|
||||||
// be fixed.
|
// be fixed.
|
||||||
Entities.editEntity(entityID, {
|
Entities.editEntity(entityID, {
|
||||||
velocity: this.currentVelocity
|
velocity: this.currentVelocity
|
||||||
// angularVelocity: this.currentAngularVelocity
|
// angularVelocity: this.currentAngularVelocity
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2198,14 +2250,32 @@ function MyController(hand) {
|
||||||
deactiveProps = {
|
deactiveProps = {
|
||||||
parentID: this.previousParentID,
|
parentID: this.previousParentID,
|
||||||
parentJointIndex: this.previousParentJointIndex,
|
parentJointIndex: this.previousParentJointIndex,
|
||||||
velocity: {x: 0.0, y: 0.0, z: 0.0},
|
velocity: {
|
||||||
angularVelocity: {x: 0.0, y: 0.0, z: 0.0}
|
x: 0.0,
|
||||||
|
y: 0.0,
|
||||||
|
z: 0.0
|
||||||
|
},
|
||||||
|
angularVelocity: {
|
||||||
|
x: 0.0,
|
||||||
|
y: 0.0,
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Entities.editEntity(entityID, deactiveProps);
|
Entities.editEntity(entityID, deactiveProps);
|
||||||
} else if (noVelocity) {
|
} else if (noVelocity) {
|
||||||
Entities.editEntity(entityID, {velocity: {x: 0.0, y: 0.0, z: 0.0},
|
Entities.editEntity(entityID, {
|
||||||
angularVelocity: {x: 0.0, y: 0.0, z: 0.0},
|
velocity: {
|
||||||
dynamic: data["dynamic"]});
|
x: 0.0,
|
||||||
|
y: 0.0,
|
||||||
|
z: 0.0
|
||||||
|
},
|
||||||
|
angularVelocity: {
|
||||||
|
x: 0.0,
|
||||||
|
y: 0.0,
|
||||||
|
z: 0.0
|
||||||
|
},
|
||||||
|
dynamic: data["dynamic"]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data = null;
|
data = null;
|
||||||
|
@ -2261,20 +2331,20 @@ var handleHandMessages = function(channel, message, sender) {
|
||||||
if (sender === MyAvatar.sessionUUID) {
|
if (sender === MyAvatar.sessionUUID) {
|
||||||
if (channel === 'Hifi-Hand-Disabler') {
|
if (channel === 'Hifi-Hand-Disabler') {
|
||||||
if (message === 'left') {
|
if (message === 'left') {
|
||||||
leftController.turnOffVisualizations('left');
|
leftController.turnOffVisualizations('left');
|
||||||
handToDisable = LEFT_HAND;
|
handToDisable = LEFT_HAND;
|
||||||
}
|
}
|
||||||
if (message === 'right') {
|
if (message === 'right') {
|
||||||
rightController.turnOffVisualizations('right');
|
rightController.turnOffVisualizations('right');
|
||||||
handToDisable = RIGHT_HAND;
|
handToDisable = RIGHT_HAND;
|
||||||
}
|
}
|
||||||
if (message === "both") {
|
if (message === "both") {
|
||||||
print('disable both')
|
print('disable both')
|
||||||
leftController.turnOffVisualizations('left');
|
leftController.turnOffVisualizations('left');
|
||||||
rightController.turnOffVisualizations('right');
|
rightController.turnOffVisualizations('right');
|
||||||
}
|
}
|
||||||
if (message === 'both' || message === 'none') {
|
if (message === 'both' || message === 'none') {
|
||||||
// handToDisable = message;
|
// handToDisable = message;
|
||||||
}
|
}
|
||||||
} else if (channel === 'Hifi-Hand-Grab') {
|
} else if (channel === 'Hifi-Hand-Grab') {
|
||||||
try {
|
try {
|
||||||
|
@ -2352,5 +2422,4 @@ function handleMenuItemEvent(menuItem) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu.menuItemEvent.connect(handleMenuItemEvent);
|
Menu.menuItemEvent.connect(handleMenuItemEvent);
|
||||||
|
|
|
@ -39,7 +39,7 @@ var NUMBER_OF_STEPS = 6;
|
||||||
// var NUMBER_OF_STEPS = 20;
|
// var NUMBER_OF_STEPS = 20;
|
||||||
|
|
||||||
|
|
||||||
var TARGET_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/james/teleporter/target.fbx';
|
var TARGET_MODEL_URL = Script.resolvePath("../assets/models/teleport.fbx");
|
||||||
var TARGET_MODEL_DIMENSIONS = {
|
var TARGET_MODEL_DIMENSIONS = {
|
||||||
x: 1.15,
|
x: 1.15,
|
||||||
y: 0.5,
|
y: 0.5,
|
||||||
|
@ -584,22 +584,18 @@ function registerMappings() {
|
||||||
teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress);
|
teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress);
|
||||||
|
|
||||||
teleportMapping.from(Controller.Standard.LeftPrimaryThumb).when(leftTrigger.down).to(function(value) {
|
teleportMapping.from(Controller.Standard.LeftPrimaryThumb).when(leftTrigger.down).to(function(value) {
|
||||||
print('tel 1')
|
|
||||||
teleporter.enterTeleportMode('left')
|
teleporter.enterTeleportMode('left')
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
teleportMapping.from(Controller.Standard.RightPrimaryThumb).when(rightTrigger.down).to(function(value) {
|
teleportMapping.from(Controller.Standard.RightPrimaryThumb).when(rightTrigger.down).to(function(value) {
|
||||||
print('tel 2')
|
|
||||||
teleporter.enterTeleportMode('right')
|
teleporter.enterTeleportMode('right')
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
teleportMapping.from(Controller.Standard.RT).when(Controller.Standard.RightPrimaryThumb).to(function(value) {
|
teleportMapping.from(Controller.Standard.RT).when(Controller.Standard.RightPrimaryThumb).to(function(value) {
|
||||||
print('tel 3')
|
|
||||||
teleporter.enterTeleportMode('right')
|
teleporter.enterTeleportMode('right')
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
teleportMapping.from(Controller.Standard.LT).when(Controller.Standard.LeftPrimaryThumb).to(function(value) {
|
teleportMapping.from(Controller.Standard.LT).when(Controller.Standard.LeftPrimaryThumb).to(function(value) {
|
||||||
print('tel 4')
|
|
||||||
teleporter.enterTeleportMode('left')
|
teleporter.enterTeleportMode('left')
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue