mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 01:13:32 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into default-when-av-fails
This commit is contained in:
commit
905c6147cf
13 changed files with 205 additions and 164 deletions
assignment-client/src/audio
interface/resources/controllers
libraries
audio-client/src
audio/src
render-utils/src
plugins/oculus/src
scripts/system/controllers
|
@ -113,7 +113,7 @@ int AudioMixerClientData::parseData(ReceivedMessage& message) {
|
|||
avatarAudioStream->setupCodec(_codec, _selectedCodecName, AudioConstants::MONO);
|
||||
qDebug() << "creating new AvatarAudioStream... codec:" << _selectedCodecName;
|
||||
|
||||
connect(avatarAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioMixerClientData::sendSelectAudioFormat);
|
||||
connect(avatarAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioMixerClientData::handleMismatchAudioFormat);
|
||||
|
||||
auto emplaced = _audioStreams.emplace(
|
||||
QUuid(),
|
||||
|
@ -345,6 +345,11 @@ QJsonObject AudioMixerClientData::getAudioStreamStats() {
|
|||
return result;
|
||||
}
|
||||
|
||||
void AudioMixerClientData::handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec) {
|
||||
qDebug() << __FUNCTION__ << "sendingNode:" << *node << "currentCodec:" << currentCodec << "recievedCodec:" << recievedCodec;
|
||||
sendSelectAudioFormat(node, currentCodec);
|
||||
}
|
||||
|
||||
void AudioMixerClientData::sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName) {
|
||||
auto replyPacket = NLPacket::create(PacketType::SelectedAudioFormat);
|
||||
replyPacket->writeString(selectedCodecName);
|
||||
|
|
|
@ -84,6 +84,7 @@ signals:
|
|||
void injectorStreamFinished(const QUuid& streamIdentifier);
|
||||
|
||||
public slots:
|
||||
void handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec);
|
||||
void sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName);
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,15 +1,26 @@
|
|||
{
|
||||
"name": "Hydra to Standard",
|
||||
"channels": [
|
||||
{ "from": "Hydra.LY", "filters": "invert", "to": "Standard.LY" },
|
||||
{ "from": "Hydra.LX", "to": "Standard.LX" },
|
||||
{ "from": "Hydra.LY", "to": "Standard.LY",
|
||||
"filters": [
|
||||
{ "type": "deadZone", "min": 0.05 },
|
||||
"invert"
|
||||
]
|
||||
},
|
||||
{ "from": "Hydra.LX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.LX" },
|
||||
{ "from": "Hydra.LT", "to": "Standard.LTClick",
|
||||
"peek": true,
|
||||
"filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ]
|
||||
},
|
||||
{ "from": "Hydra.LT", "to": "Standard.LT" },
|
||||
{ "from": "Hydra.RY", "filters": "invert", "to": "Standard.RY" },
|
||||
{ "from": "Hydra.RX", "to": "Standard.RX" },
|
||||
{ "from": "Hydra.LT", "to": "Standard.LT" },
|
||||
|
||||
{ "from": "Hydra.RY", "to": "Standard.RY",
|
||||
"filters": [
|
||||
{ "type": "deadZone", "min": 0.05 },
|
||||
"invert"
|
||||
]
|
||||
},
|
||||
{ "from": "Hydra.RX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.RX" },
|
||||
{ "from": "Hydra.RT", "to": "Standard.RTClick",
|
||||
"peek": true,
|
||||
"filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ]
|
||||
|
@ -28,7 +39,6 @@
|
|||
{ "from": [ "Hydra.R1", "Hydra.R3" ], "to": "Standard.RightPrimaryThumb" },
|
||||
{ "from": [ "Hydra.R2", "Hydra.R4" ], "to": "Standard.RightSecondaryThumb" },
|
||||
{ "from": [ "Hydra.L2", "Hydra.L4" ], "to": "Standard.LeftSecondaryThumb" },
|
||||
|
||||
{ "from": "Hydra.LeftHand", "to": "Standard.LeftHand" },
|
||||
{ "from": "Hydra.RightHand", "to": "Standard.RightHand" }
|
||||
]
|
||||
|
|
|
@ -2,12 +2,15 @@
|
|||
"name": "Oculus Touch to Standard",
|
||||
"channels": [
|
||||
{ "from": "OculusTouch.A", "to": "Standard.RightPrimaryThumb" },
|
||||
{ "from": "OculusTouch.B", "to": "Standard.RightSecondaryThumb" },
|
||||
{ "from": "OculusTouch.X", "to": "Standard.LeftPrimaryThumb" },
|
||||
{ "from": "OculusTouch.Y", "to": "Standard.LeftSecondaryThumb" },
|
||||
|
||||
{ "from": "OculusTouch.LY", "filters": "invert", "to": "Standard.LY" },
|
||||
{ "from": "OculusTouch.LX", "to": "Standard.LX" },
|
||||
{ "from": "OculusTouch.LY", "to": "Standard.LY",
|
||||
"filters": [
|
||||
{ "type": "deadZone", "min": 0.05 },
|
||||
"invert"
|
||||
]
|
||||
},
|
||||
{ "from": "OculusTouch.LX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.LX" },
|
||||
{ "from": "OculusTouch.LT", "to": "Standard.LTClick",
|
||||
"peek": true,
|
||||
"filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ]
|
||||
|
@ -17,8 +20,13 @@
|
|||
{ "from": "OculusTouch.LeftGrip", "to": "Standard.LeftGrip" },
|
||||
{ "from": "OculusTouch.LeftHand", "to": "Standard.LeftHand" },
|
||||
|
||||
{ "from": "OculusTouch.RY", "filters": "invert", "to": "Standard.RY" },
|
||||
{ "from": "OculusTouch.RX", "to": "Standard.RX" },
|
||||
{ "from": "OculusTouch.RY", "to": "Standard.RY",
|
||||
"filters": [
|
||||
{ "type": "deadZone", "min": 0.05 },
|
||||
"invert"
|
||||
]
|
||||
},
|
||||
{ "from": "OculusTouch.RX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.RX" },
|
||||
{ "from": "OculusTouch.RT", "to": "Standard.RTClick",
|
||||
"peek": true,
|
||||
"filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ]
|
||||
|
|
|
@ -119,6 +119,9 @@ AudioClient::AudioClient() :
|
|||
this, &AudioClient::processReceivedSamples, Qt::DirectConnection);
|
||||
connect(this, &AudioClient::changeDevice, this, [=](const QAudioDeviceInfo& outputDeviceInfo) { switchOutputToAudioDevice(outputDeviceInfo); });
|
||||
|
||||
connect(&_receivedAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioClient::handleMismatchAudioFormat);
|
||||
|
||||
|
||||
_inputDevices = getDeviceNames(QAudio::AudioInput);
|
||||
_outputDevices = getDeviceNames(QAudio::AudioOutput);
|
||||
|
||||
|
@ -147,6 +150,12 @@ AudioClient::~AudioClient() {
|
|||
}
|
||||
}
|
||||
|
||||
void AudioClient::handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec) {
|
||||
qDebug() << __FUNCTION__ << "sendingNode:" << *node << "currentCodec:" << currentCodec << "recievedCodec:" << recievedCodec;
|
||||
selectAudioFormat(recievedCodec);
|
||||
}
|
||||
|
||||
|
||||
void AudioClient::reset() {
|
||||
_receivedAudioStream.reset();
|
||||
_stats.reset();
|
||||
|
@ -532,7 +541,13 @@ void AudioClient::negotiateAudioFormat() {
|
|||
}
|
||||
|
||||
void AudioClient::handleSelectedAudioFormat(QSharedPointer<ReceivedMessage> message) {
|
||||
_selectedCodecName = message->readString();
|
||||
QString selectedCodecName = message->readString();
|
||||
selectAudioFormat(selectedCodecName);
|
||||
}
|
||||
|
||||
void AudioClient::selectAudioFormat(const QString& selectedCodecName) {
|
||||
|
||||
_selectedCodecName = selectedCodecName;
|
||||
|
||||
qDebug() << "Selected Codec:" << _selectedCodecName;
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ public:
|
|||
};
|
||||
|
||||
void negotiateAudioFormat();
|
||||
void selectAudioFormat(const QString& selectedCodecName);
|
||||
|
||||
const MixedProcessedAudioStream& getReceivedAudioStream() const { return _receivedAudioStream; }
|
||||
MixedProcessedAudioStream& getReceivedAudioStream() { return _receivedAudioStream; }
|
||||
|
@ -153,6 +154,7 @@ public slots:
|
|||
void handleNoisyMutePacket(QSharedPointer<ReceivedMessage> message);
|
||||
void handleMuteEnvironmentPacket(QSharedPointer<ReceivedMessage> message);
|
||||
void handleSelectedAudioFormat(QSharedPointer<ReceivedMessage> message);
|
||||
void handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec);
|
||||
|
||||
void sendDownstreamAudioStatsPacket() { _stats.sendDownstreamAudioStatsPacket(); }
|
||||
void handleAudioInput();
|
||||
|
|
|
@ -147,7 +147,7 @@ int InboundAudioStream::parseData(ReceivedMessage& message) {
|
|||
writeDroppableSilentSamples(networkSamples);
|
||||
// inform others of the mismatch
|
||||
auto sendingNode = DependencyManager::get<NodeList>()->nodeWithUUID(message.getSourceID());
|
||||
emit mismatchedAudioCodec(sendingNode, _selectedCodecName);
|
||||
emit mismatchedAudioCodec(sendingNode, _selectedCodecName, codecInPacket);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -182,7 +182,7 @@ public:
|
|||
void cleanupCodec();
|
||||
|
||||
signals:
|
||||
void mismatchedAudioCodec(SharedNodePointer sendingNode, const QString& desiredCodec);
|
||||
void mismatchedAudioCodec(SharedNodePointer sendingNode, const QString& currentCodec, const QString& recievedCodec);
|
||||
|
||||
public slots:
|
||||
/// This function should be called every second for all the stats to function properly. If dynamic jitter buffers
|
||||
|
|
|
@ -374,8 +374,6 @@ void AnimDebugDraw::update() {
|
|||
}
|
||||
}
|
||||
}
|
||||
data._vertexBuffer->resize(sizeof(Vertex) * numVerts);
|
||||
data._vertexBuffer->setSubData<Vertex>(0, vertices);
|
||||
|
||||
// draw markers from shared DebugDraw singleton
|
||||
for (auto& iter : markerMap) {
|
||||
|
@ -403,6 +401,9 @@ void AnimDebugDraw::update() {
|
|||
}
|
||||
DebugDraw::getInstance().clearRays();
|
||||
|
||||
data._vertexBuffer->resize(sizeof(Vertex) * numVerts);
|
||||
data._vertexBuffer->setSubData<Vertex>(0, vertices);
|
||||
|
||||
assert((!numVerts && !v) || (numVerts == (v - &vertices[0])));
|
||||
|
||||
render::Item::Bound theBound;
|
||||
|
|
|
@ -182,6 +182,12 @@ void OculusControllerManager::TouchDevice::update(float deltaTime, const control
|
|||
_poseStateMap.clear();
|
||||
_buttonPressedMap.clear();
|
||||
|
||||
ovrSessionStatus status;
|
||||
if (!OVR_SUCCESS(ovr_GetSessionStatus(_parent._session, &status)) || (ovrFalse == status.HmdMounted)) {
|
||||
// if the HMD isn't on someone's head, don't take input from the controllers
|
||||
return;
|
||||
}
|
||||
|
||||
int numTrackedControllers = 0;
|
||||
static const auto REQUIRED_HAND_STATUS = ovrStatus_OrientationTracked & ovrStatus_PositionTracked;
|
||||
auto tracking = ovr_GetTrackingState(_parent._session, 0, false);
|
||||
|
|
|
@ -70,15 +70,15 @@ var DISTANCE_HOLDING_UNITY_DISTANCE = 6; // The distance at which the distance
|
|||
var MOVE_WITH_HEAD = true; // experimental head-control of distantly held objects
|
||||
|
||||
var COLORS_GRAB_SEARCHING_HALF_SQUEEZE = {
|
||||
red: 255,
|
||||
green: 97,
|
||||
blue: 129
|
||||
red: 10,
|
||||
green: 10,
|
||||
blue: 255
|
||||
};
|
||||
|
||||
var COLORS_GRAB_SEARCHING_FULL_SQUEEZE = {
|
||||
red: 255,
|
||||
green: 97,
|
||||
blue: 129
|
||||
red: 250,
|
||||
green: 10,
|
||||
blue: 10
|
||||
};
|
||||
|
||||
var COLORS_GRAB_DISTANCE_HOLD = {
|
||||
|
@ -1378,7 +1378,7 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.distanceHoldingEnter = function() {
|
||||
|
||||
Messages.sendLocalMessage('Hifi-Teleport-Disabler','both');
|
||||
this.clearEquipHaptics();
|
||||
|
||||
// controller pose is in avatar frame
|
||||
|
@ -1534,7 +1534,9 @@ function MyController(hand) {
|
|||
|
||||
// visualizations
|
||||
|
||||
this.overlayLineOn(handPosition, grabbedProperties.position, COLORS_GRAB_DISTANCE_HOLD);
|
||||
var rayPickInfo = this.calcRayPickInfo(this.hand);
|
||||
|
||||
this.overlayLineOn(rayPickInfo.searchRay.origin, grabbedProperties.position, COLORS_GRAB_DISTANCE_HOLD);
|
||||
|
||||
var distanceToObject = Vec3.length(Vec3.subtract(MyAvatar.position, this.currentObjectPosition));
|
||||
var success = Entities.updateAction(this.grabbedEntity, this.actionID, {
|
||||
|
@ -1634,7 +1636,14 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.nearGrabbingEnter = function() {
|
||||
if (this.hand === 0) {
|
||||
Messages.sendLocalMessage('Hifi-Teleport-Disabler', 'left');
|
||||
|
||||
}
|
||||
if (this.hand === 1) {
|
||||
Messages.sendLocalMessage('Hifi-Teleport-Disabler', 'right');
|
||||
|
||||
}
|
||||
this.lineOff();
|
||||
this.overlayLineOff();
|
||||
|
||||
|
@ -1961,6 +1970,7 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.release = function() {
|
||||
Messages.sendLocalMessage('Hifi-Teleport-Disabler','none');
|
||||
this.turnOffVisualizations();
|
||||
|
||||
var noVelocity = false;
|
||||
|
|
|
@ -508,4 +508,3 @@ Script.scriptEnding.connect(function () {
|
|||
Script.clearInterval(settingsChecker);
|
||||
OffscreenFlags.navigationFocusDisabled = false;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,21 +1,13 @@
|
|||
// Created by james b. pollack @imgntn on 7/2/2016
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Creates a beam and target and then teleports you there when you let go of either activation button.
|
||||
// Creates a beam and target and then teleports you there.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
var inTeleportMode = false;
|
||||
|
||||
var currentFadeSphereOpacity = 1;
|
||||
var fadeSphereInterval = null;
|
||||
var fadeSphereUpdateInterval = null;
|
||||
//milliseconds between fading one-tenth -- so this is a half second fade total
|
||||
var USE_FADE_MODE = false;
|
||||
var USE_FADE_OUT = true;
|
||||
var FADE_OUT_INTERVAL = 25;
|
||||
|
||||
// instant
|
||||
// var NUMBER_OF_STEPS = 0;
|
||||
// var SMOOTH_ARRIVAL_SPACING = 0;
|
||||
|
@ -36,16 +28,13 @@ var NUMBER_OF_STEPS = 6;
|
|||
// var SMOOTH_ARRIVAL_SPACING = 10;
|
||||
// var NUMBER_OF_STEPS = 20;
|
||||
|
||||
|
||||
var TARGET_MODEL_URL = Script.resolvePath("../assets/models/teleport.fbx");
|
||||
var TARGET_MODEL_DIMENSIONS = {
|
||||
x: 1.15,
|
||||
y: 0.5,
|
||||
z: 1.15
|
||||
|
||||
};
|
||||
|
||||
|
||||
var COLORS_TELEPORT_CAN_TELEPORT = {
|
||||
red: 97,
|
||||
green: 247,
|
||||
|
@ -58,14 +47,22 @@ var COLORS_TELEPORT_CANNOT_TELEPORT = {
|
|||
blue: 141
|
||||
};
|
||||
|
||||
var MAX_AVATAR_SPEED = 0.25;
|
||||
|
||||
function ThumbPad(hand) {
|
||||
this.hand = hand;
|
||||
var _thisPad = this;
|
||||
|
||||
this.buttonPress = function(value) {
|
||||
_thisPad.buttonValue = value;
|
||||
};
|
||||
if (value === 0) {
|
||||
if (activationTimeout !== null) {
|
||||
Script.clearTimeout(activationTimeout);
|
||||
activationTimeout = null;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function Trigger(hand) {
|
||||
|
@ -91,7 +88,6 @@ function Teleporter() {
|
|||
this.targetOverlay = null;
|
||||
this.updateConnected = null;
|
||||
this.smoothArrivalInterval = null;
|
||||
this.fadeSphere = null;
|
||||
this.teleportHand = null;
|
||||
|
||||
this.initialize = function() {
|
||||
|
@ -128,83 +124,25 @@ function Teleporter() {
|
|||
if (inTeleportMode === true) {
|
||||
return;
|
||||
}
|
||||
if (isDisabled === 'both') {
|
||||
return;
|
||||
}
|
||||
|
||||
inTeleportMode = true;
|
||||
|
||||
if (this.smoothArrivalInterval !== null) {
|
||||
Script.clearInterval(this.smoothArrivalInterval);
|
||||
}
|
||||
if (fadeSphereInterval !== null) {
|
||||
Script.clearInterval(fadeSphereInterval);
|
||||
if (activationTimeout !== null) {
|
||||
Script.clearInterval(activationTimeout);
|
||||
}
|
||||
|
||||
this.teleportHand = hand;
|
||||
this.initialize();
|
||||
Script.update.connect(this.update);
|
||||
this.updateConnected = true;
|
||||
};
|
||||
|
||||
this.createFadeSphere = function(avatarHead) {
|
||||
var sphereProps = {
|
||||
position: avatarHead,
|
||||
size: -1,
|
||||
color: {
|
||||
red: 0,
|
||||
green: 0,
|
||||
blue: 0,
|
||||
},
|
||||
alpha: 1,
|
||||
solid: true,
|
||||
visible: true,
|
||||
ignoreRayIntersection: true,
|
||||
drawInFront: false
|
||||
};
|
||||
|
||||
currentFadeSphereOpacity = 10;
|
||||
|
||||
_this.fadeSphere = Overlays.addOverlay("sphere", sphereProps);
|
||||
Script.clearInterval(fadeSphereInterval)
|
||||
Script.update.connect(_this.updateFadeSphere);
|
||||
if (USE_FADE_OUT === true) {
|
||||
this.fadeSphereOut();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
this.fadeSphereOut = function() {
|
||||
|
||||
fadeSphereInterval = Script.setInterval(function() {
|
||||
if (currentFadeSphereOpacity <= 0) {
|
||||
Script.clearInterval(fadeSphereInterval);
|
||||
_this.deleteFadeSphere();
|
||||
fadeSphereInterval = null;
|
||||
return;
|
||||
}
|
||||
if (currentFadeSphereOpacity > 0) {
|
||||
currentFadeSphereOpacity = currentFadeSphereOpacity - 1;
|
||||
}
|
||||
|
||||
Overlays.editOverlay(_this.fadeSphere, {
|
||||
alpha: currentFadeSphereOpacity / 10
|
||||
})
|
||||
|
||||
}, FADE_OUT_INTERVAL);
|
||||
};
|
||||
|
||||
|
||||
this.updateFadeSphere = function() {
|
||||
var headPosition = MyAvatar.getHeadPosition();
|
||||
Overlays.editOverlay(_this.fadeSphere, {
|
||||
position: headPosition
|
||||
})
|
||||
};
|
||||
|
||||
this.deleteFadeSphere = function() {
|
||||
if (_this.fadeSphere !== null) {
|
||||
Script.update.disconnect(_this.updateFadeSphere);
|
||||
Overlays.deleteOverlay(_this.fadeSphere);
|
||||
_this.fadeSphere = null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.deleteTargetOverlay = function() {
|
||||
if (this.targetOverlay === null) {
|
||||
|
@ -221,6 +159,10 @@ function Teleporter() {
|
|||
}
|
||||
|
||||
this.exitTeleportMode = function(value) {
|
||||
if (activationTimeout !== null) {
|
||||
Script.clearTimeout(activationTimeout);
|
||||
activationTimeout = null;
|
||||
}
|
||||
if (this.updateConnected === true) {
|
||||
Script.update.disconnect(this.update);
|
||||
}
|
||||
|
@ -239,19 +181,26 @@ function Teleporter() {
|
|||
|
||||
|
||||
this.update = function() {
|
||||
if (isDisabled === 'both') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (teleporter.teleportHand === 'left') {
|
||||
if (isDisabled === 'left') {
|
||||
return;
|
||||
}
|
||||
teleporter.leftRay();
|
||||
|
||||
if ((leftPad.buttonValue === 0 || leftTrigger.buttonValue === 0) && inTeleportMode === true) {
|
||||
if ((leftPad.buttonValue === 0) && inTeleportMode === true) {
|
||||
_this.teleport();
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (isDisabled === 'right') {
|
||||
return;
|
||||
}
|
||||
teleporter.rightRay();
|
||||
|
||||
if ((rightPad.buttonValue === 0 || rightTrigger.buttonValue === 0) && inTeleportMode === true) {
|
||||
if ((rightPad.buttonValue === 0) && inTeleportMode === true) {
|
||||
_this.teleport();
|
||||
return;
|
||||
}
|
||||
|
@ -261,14 +210,12 @@ function Teleporter() {
|
|||
|
||||
this.rightRay = function() {
|
||||
|
||||
|
||||
var rightPosition = Vec3.sum(Vec3.multiplyQbyV(MyAvatar.orientation, Controller.getPoseValue(Controller.Standard.RightHand).translation), MyAvatar.position);
|
||||
|
||||
var rightControllerRotation = Controller.getPoseValue(Controller.Standard.RightHand).rotation;
|
||||
|
||||
var rightRotation = Quat.multiply(MyAvatar.orientation, rightControllerRotation)
|
||||
|
||||
|
||||
var rightFinal = Quat.multiply(rightRotation, Quat.angleAxis(90, {
|
||||
x: 1,
|
||||
y: 0,
|
||||
|
@ -308,14 +255,12 @@ function Teleporter() {
|
|||
|
||||
var leftRotation = Quat.multiply(MyAvatar.orientation, Controller.getPoseValue(Controller.Standard.LeftHand).rotation)
|
||||
|
||||
|
||||
var leftFinal = Quat.multiply(leftRotation, Quat.angleAxis(90, {
|
||||
x: 1,
|
||||
y: 0,
|
||||
z: 0
|
||||
}));
|
||||
|
||||
|
||||
var leftPickRay = {
|
||||
origin: leftPosition,
|
||||
direction: Quat.getUp(leftRotation),
|
||||
|
@ -337,7 +282,6 @@ function Teleporter() {
|
|||
this.createTargetOverlay();
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
this.deleteTargetOverlay();
|
||||
|
@ -351,7 +295,7 @@ function Teleporter() {
|
|||
start: closePoint,
|
||||
end: farPoint,
|
||||
color: color,
|
||||
ignoreRayIntersection: true, // always ignore this
|
||||
ignoreRayIntersection: true,
|
||||
visible: true,
|
||||
alpha: 1,
|
||||
solid: true,
|
||||
|
@ -363,14 +307,9 @@ function Teleporter() {
|
|||
|
||||
} else {
|
||||
var success = Overlays.editOverlay(this.rightOverlayLine, {
|
||||
lineWidth: 50,
|
||||
start: closePoint,
|
||||
end: farPoint,
|
||||
color: color,
|
||||
visible: true,
|
||||
ignoreRayIntersection: true, // always ignore this
|
||||
alpha: 1,
|
||||
glow: 1.0
|
||||
color: color
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -378,7 +317,7 @@ function Teleporter() {
|
|||
this.leftLineOn = function(closePoint, farPoint, color) {
|
||||
if (this.leftOverlayLine === null) {
|
||||
var lineProperties = {
|
||||
ignoreRayIntersection: true, // always ignore this
|
||||
ignoreRayIntersection: true,
|
||||
start: closePoint,
|
||||
end: farPoint,
|
||||
color: color,
|
||||
|
@ -395,11 +334,7 @@ function Teleporter() {
|
|||
var success = Overlays.editOverlay(this.leftOverlayLine, {
|
||||
start: closePoint,
|
||||
end: farPoint,
|
||||
color: color,
|
||||
visible: true,
|
||||
alpha: 1,
|
||||
solid: true,
|
||||
glow: 1.0
|
||||
color: color
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -452,16 +387,11 @@ function Teleporter() {
|
|||
this.exitTeleportMode();
|
||||
}
|
||||
if (this.intersection !== null) {
|
||||
if (USE_FADE_MODE === true) {
|
||||
this.createFadeSphere();
|
||||
}
|
||||
var offset = getAvatarFootOffset();
|
||||
this.intersection.intersection.y += offset;
|
||||
this.exitTeleportMode();
|
||||
this.smoothArrival();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -471,12 +401,8 @@ function Teleporter() {
|
|||
return midpoint
|
||||
};
|
||||
|
||||
|
||||
|
||||
this.getArrivalPoints = function(startPoint, endPoint) {
|
||||
var arrivalPoints = [];
|
||||
|
||||
|
||||
var i;
|
||||
var lastPoint;
|
||||
|
||||
|
@ -489,9 +415,9 @@ function Teleporter() {
|
|||
arrivalPoints.push(newPoint);
|
||||
}
|
||||
|
||||
arrivalPoints.push(endPoint)
|
||||
arrivalPoints.push(endPoint);
|
||||
|
||||
return arrivalPoints
|
||||
return arrivalPoints;
|
||||
};
|
||||
|
||||
this.smoothArrival = function() {
|
||||
|
@ -502,7 +428,6 @@ function Teleporter() {
|
|||
Script.clearInterval(_this.smoothArrivalInterval);
|
||||
return;
|
||||
}
|
||||
|
||||
var landingPoint = _this.arrivalPoints.shift();
|
||||
MyAvatar.position = landingPoint;
|
||||
|
||||
|
@ -510,8 +435,7 @@ function Teleporter() {
|
|||
_this.deleteTargetOverlay();
|
||||
}
|
||||
|
||||
|
||||
}, SMOOTH_ARRIVAL_SPACING)
|
||||
}, SMOOTH_ARRIVAL_SPACING);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -536,14 +460,14 @@ function getAvatarFootOffset() {
|
|||
toe = d.translation.y;
|
||||
}
|
||||
if (jointName === "RightToe_End") {
|
||||
toeTop = d.translation.y
|
||||
toeTop = d.translation.y;
|
||||
}
|
||||
})
|
||||
|
||||
var myPosition = MyAvatar.position;
|
||||
var offset = upperLeg + lowerLeg + foot + toe + toeTop;
|
||||
offset = offset / 100;
|
||||
return offset
|
||||
return offset;
|
||||
};
|
||||
|
||||
function getJointData() {
|
||||
|
@ -570,8 +494,18 @@ var rightTrigger = new Trigger('right');
|
|||
|
||||
var mappingName, teleportMapping;
|
||||
|
||||
var TELEPORT_DELAY = 100;
|
||||
var activationTimeout = null;
|
||||
var TELEPORT_DELAY = 0;
|
||||
|
||||
function isMoving() {
|
||||
var LY = Controller.getValue(Controller.Standard.LY);
|
||||
var LX = Controller.getValue(Controller.Standard.LX);
|
||||
if (LY !== 0 || LX !== 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function registerMappings() {
|
||||
mappingName = 'Hifi-Teleporter-Dev-' + Math.random();
|
||||
|
@ -582,23 +516,49 @@ function registerMappings() {
|
|||
teleportMapping.from(Controller.Standard.RightPrimaryThumb).peek().to(rightPad.buttonPress);
|
||||
teleportMapping.from(Controller.Standard.LeftPrimaryThumb).peek().to(leftPad.buttonPress);
|
||||
|
||||
teleportMapping.from(Controller.Standard.LeftPrimaryThumb).when(leftTrigger.down).to(function(value) {
|
||||
teleporter.enterTeleportMode('left')
|
||||
return;
|
||||
});
|
||||
teleportMapping.from(Controller.Standard.RightPrimaryThumb).when(rightTrigger.down).to(function(value) {
|
||||
teleporter.enterTeleportMode('right')
|
||||
return;
|
||||
});
|
||||
teleportMapping.from(Controller.Standard.RT).when(Controller.Standard.RightPrimaryThumb).to(function(value) {
|
||||
teleporter.enterTeleportMode('right')
|
||||
return;
|
||||
});
|
||||
teleportMapping.from(Controller.Standard.LT).when(Controller.Standard.LeftPrimaryThumb).to(function(value) {
|
||||
teleporter.enterTeleportMode('left')
|
||||
return;
|
||||
});
|
||||
teleportMapping.from(Controller.Standard.LeftPrimaryThumb)
|
||||
.to(function(value) {
|
||||
if (isDisabled === 'left' || isDisabled === 'both') {
|
||||
return;
|
||||
}
|
||||
if (activationTimeout !== null) {
|
||||
return
|
||||
}
|
||||
if (leftTrigger.down()) {
|
||||
return;
|
||||
}
|
||||
if (isMoving() === true) {
|
||||
return;
|
||||
}
|
||||
activationTimeout = Script.setTimeout(function() {
|
||||
Script.clearTimeout(activationTimeout);
|
||||
activationTimeout = null;
|
||||
teleporter.enterTeleportMode('left')
|
||||
}, TELEPORT_DELAY)
|
||||
return;
|
||||
});
|
||||
teleportMapping.from(Controller.Standard.RightPrimaryThumb)
|
||||
.to(function(value) {
|
||||
if (isDisabled === 'right' || isDisabled === 'both') {
|
||||
return;
|
||||
}
|
||||
if (activationTimeout !== null) {
|
||||
return
|
||||
}
|
||||
if (rightTrigger.down()) {
|
||||
return;
|
||||
}
|
||||
if (isMoving() === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
activationTimeout = Script.setTimeout(function() {
|
||||
teleporter.enterTeleportMode('right')
|
||||
Script.clearTimeout(activationTimeout);
|
||||
activationTimeout = null;
|
||||
}, TELEPORT_DELAY)
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
registerMappings();
|
||||
|
@ -614,8 +574,32 @@ function cleanup() {
|
|||
teleporter.disableMappings();
|
||||
teleporter.deleteTargetOverlay();
|
||||
teleporter.turnOffOverlayBeams();
|
||||
teleporter.deleteFadeSphere();
|
||||
if (teleporter.updateConnected !== null) {
|
||||
Script.update.disconnect(teleporter.update);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var isDisabled = false;
|
||||
var handleHandMessages = function(channel, message, sender) {
|
||||
var data;
|
||||
if (sender === MyAvatar.sessionUUID) {
|
||||
if (channel === 'Hifi-Teleport-Disabler') {
|
||||
if (message === 'both') {
|
||||
isDisabled = 'both';
|
||||
}
|
||||
if (message === 'left') {
|
||||
isDisabled = 'left';
|
||||
}
|
||||
if (message === 'right') {
|
||||
isDisabled = 'right'
|
||||
}
|
||||
if (message === 'none') {
|
||||
isDisabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Messages.subscribe('Hifi-Teleport-Disabler');
|
||||
Messages.messageReceived.connect(handleHandMessages);
|
Loading…
Reference in a new issue