mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 12:12:32 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into 21660-updateNitpickForQuest
This commit is contained in:
commit
1fd34eeee8
36 changed files with 1660 additions and 306 deletions
|
@ -130,12 +130,16 @@ int AvatarMixerClientData::parseData(ReceivedMessage& message, const SlaveShared
|
||||||
}
|
}
|
||||||
_lastReceivedSequenceNumber = sequenceNumber;
|
_lastReceivedSequenceNumber = sequenceNumber;
|
||||||
glm::vec3 oldPosition = getPosition();
|
glm::vec3 oldPosition = getPosition();
|
||||||
|
bool oldHasPriority = _avatar->getHasPriority();
|
||||||
|
|
||||||
// compute the offset to the data payload
|
// compute the offset to the data payload
|
||||||
if (!_avatar->parseDataFromBuffer(message.readWithoutCopy(message.getBytesLeftToRead()))) {
|
if (!_avatar->parseDataFromBuffer(message.readWithoutCopy(message.getBytesLeftToRead()))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regardless of what the client says, restore the priority as we know it without triggering any update.
|
||||||
|
_avatar->setHasPriorityWithoutTimestampReset(oldHasPriority);
|
||||||
|
|
||||||
auto newPosition = getPosition();
|
auto newPosition = getPosition();
|
||||||
if (newPosition != oldPosition) {
|
if (newPosition != oldPosition) {
|
||||||
//#define AVATAR_HERO_TEST_HACK
|
//#define AVATAR_HERO_TEST_HACK
|
||||||
|
|
|
@ -19,11 +19,8 @@
|
||||||
|
|
||||||
class MixerAvatar : public AvatarData {
|
class MixerAvatar : public AvatarData {
|
||||||
public:
|
public:
|
||||||
bool getHasPriority() const { return _hasPriority; }
|
|
||||||
void setHasPriority(bool hasPriority) { _hasPriority = hasPriority; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _hasPriority { false };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using MixerAvatarSharedPointer = std::shared_ptr<MixerAvatar>;
|
using MixerAvatarSharedPointer = std::shared_ptr<MixerAvatar>;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
{ "from": "Keyboard.D", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" },
|
{ "from": "Keyboard.D", "when": ["Keyboard.RightMouseButton", "!Keyboard.Control"], "to": "Actions.LATERAL_RIGHT" },
|
||||||
{ "from": "Keyboard.E", "when": "!Keyboard.Control", "to": "Actions.LATERAL_RIGHT" },
|
{ "from": "Keyboard.E", "when": "!Keyboard.Control", "to": "Actions.LATERAL_RIGHT" },
|
||||||
{ "from": "Keyboard.Q", "when": "!Keyboard.Control", "to": "Actions.LATERAL_LEFT" },
|
{ "from": "Keyboard.Q", "when": "!Keyboard.Control", "to": "Actions.LATERAL_LEFT" },
|
||||||
|
{ "from": "Keyboard.T", "when": "!Keyboard.Control", "to": "Actions.TogglePushToTalk" },
|
||||||
|
|
||||||
{ "comment" : "Mouse turn need to be small continuous increments",
|
{ "comment" : "Mouse turn need to be small continuous increments",
|
||||||
"from": { "makeAxis" : [
|
"from": { "makeAxis" : [
|
||||||
|
|
1
interface/resources/icons/tablet-icons/mic-ptt-a.svg
Normal file
1
interface/resources/icons/tablet-icons/mic-ptt-a.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg id="Art" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50"><defs><style>.cls-1{fill-rule:evenodd;}</style></defs><title>mic-ptt-a</title><path class="cls-1" d="M34.52,10.09l-1.85,1.85a13.19,13.19,0,0,0-9.82-4.46,13.35,13.35,0,0,0-9.58,4.2L11.42,9.84a15.66,15.66,0,0,1,23.1.25Zm-6.13,6.13,1.85-1.85a9.62,9.62,0,0,0-14.53-.25L17.55,16a7.34,7.34,0,0,1,5.3-2.44A6.85,6.85,0,0,1,28.39,16.22ZM23,16a3.58,3.58,0,0,1,1.51.3,3.68,3.68,0,0,1,1.26.88,3.88,3.88,0,0,1,.84,1.3A3.94,3.94,0,0,1,26.9,20v5.07a1.91,1.91,0,0,1,.48-.05A3.93,3.93,0,0,1,30,26.07a3.38,3.38,0,0,1,1.5-.32,3.27,3.27,0,0,1,2.77,1.36,2.75,2.75,0,0,1,.85-.1,3.35,3.35,0,0,1,1.33.25,3.18,3.18,0,0,1,1.12.76,3.23,3.23,0,0,1,.73,1.13,3.32,3.32,0,0,1,.24,1.32v3.31a12.27,12.27,0,0,1-.43,3.41l-1.36,5.65a2.67,2.67,0,0,1-1,1.55A2.89,2.89,0,0,1,34,45H23a4.47,4.47,0,0,1-1.76-.43,3.88,3.88,0,0,1-1.36-1.12L14.1,35.7a3.72,3.72,0,0,1-.8-2.35,3.64,3.64,0,0,1,.28-1.5,3.75,3.75,0,0,1,.84-1.27,3.9,3.9,0,0,1,2.77-1.18,4.5,4.5,0,0,1,2,.54V19.88a4.06,4.06,0,0,1,1.13-2.78,3.74,3.74,0,0,1,1.25-.83A3.85,3.85,0,0,1,23,16Zm0,2a1.89,1.89,0,0,0-.74.12,2,2,0,0,0-1.06,1,1.92,1.92,0,0,0-.15.74V35.21l-2.32-3.06a2,2,0,0,0-.7-.59,1.88,1.88,0,0,0-.9-.2,1.85,1.85,0,0,0-.74.15,2,2,0,0,0-.63.43,2,2,0,0,0-.4.63,1.9,1.9,0,0,0-.13.74,2,2,0,0,0,.38,1.17l5.86,7.79a1.79,1.79,0,0,0,.68.57A1.74,1.74,0,0,0,23,43H34a1.23,1.23,0,0,0,.59-.15.88.88,0,0,0,.24-.23.71.71,0,0,0,.13-.31l1.37-5.6a12,12,0,0,0,.37-3V30.43a1.7,1.7,0,0,0-.43-1.07,1.31,1.31,0,0,0-.47-.37,1.35,1.35,0,0,0-.59-.11,1.46,1.46,0,0,0-.55.11,1.23,1.23,0,0,0-.46.32,1.64,1.64,0,0,0-.43,1.07h-.48v-1a1.52,1.52,0,0,0-.12-.66,1.61,1.61,0,0,0-.37-.56,1.63,1.63,0,0,0-1.22-.54,2,2,0,0,0-1.23.54,1.77,1.77,0,0,0-.36.53,1.57,1.57,0,0,0-.11.64v1h-.49V29a2.22,2.22,0,0,0-.58-1.44,1.71,1.71,0,0,0-.62-.44A1.88,1.88,0,0,0,27.4,27a2,2,0,0,0-.74.13,1.85,1.85,0,0,0-.63.41,2,2,0,0,0-.53,1.36v1.5h-.57V20a2,2,0,0,0-.54-1.44,1.75,1.75,0,0,0-.63-.44A1.73,1.73,0,0,0,23,18Z"/></svg>
|
After Width: | Height: | Size: 1.9 KiB |
24
interface/resources/icons/tablet-icons/mic-ptt-i.svg
Normal file
24
interface/resources/icons/tablet-icons/mic-ptt-i.svg
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 23.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="Art" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
|
||||||
|
<style type="text/css">
|
||||||
|
.st0{fill:#FFFFFF;}
|
||||||
|
</style>
|
||||||
|
<path class="st0" d="M16.7,13.2c-0.3,0.3-0.7,0.6-1,0.9l1.8,1.9c1.4-1.5,3.3-2.4,5.3-2.4c2.2,0,4.2,0.9,5.5,2.7l1.8-1.8
|
||||||
|
C26.8,10.3,20.8,9.8,16.7,13.2z M32.7,11.9l1.9-1.9c-0.3-0.3-0.6-0.7-1-1c-6.3-5.9-16.2-5.6-22.1,0.7l1.9,1.8
|
||||||
|
c2.5-2.6,5.9-4.2,9.6-4.2C26.6,7.5,30.2,9.1,32.7,11.9z M38.3,29.1c-0.2-0.4-0.4-0.8-0.7-1.1c-0.3-0.3-0.7-0.6-1.1-0.8
|
||||||
|
C36,27.1,35.6,27,35.1,27c-0.3,0-0.6,0-0.8,0.1c-0.6-0.9-1.7-1.4-2.8-1.4c-0.5,0-1,0.1-1.5,0.3c-0.7-0.7-1.6-1-2.6-1.1
|
||||||
|
c-0.2,0-0.3,0-0.5,0.1V20c0-0.5-0.1-1-0.3-1.5c-0.2-0.5-0.5-0.9-0.8-1.3c-0.4-0.4-0.8-0.7-1.3-0.9C24,16.1,23.5,16,23,16
|
||||||
|
c-0.5,0-1,0.1-1.4,0.3c-0.5,0.2-0.9,0.5-1.3,0.8c-0.7,0.7-1.1,1.7-1.1,2.8v10.1c-0.6-0.3-1.3-0.5-2-0.5c-1,0-2,0.4-2.8,1.2
|
||||||
|
c-0.4,0.4-0.6,0.8-0.8,1.3c-0.2,0.5-0.3,1-0.3,1.5c0,0.9,0.3,1.7,0.8,2.4l5.8,7.8c0.4,0.5,0.8,0.9,1.4,1.1c0.6,0.3,1.2,0.4,1.8,0.4
|
||||||
|
h11c0.6,0,1.2-0.2,1.8-0.6c0.5-0.4,0.9-0.9,1-1.6l1.4-5.6c0.3-1.1,0.4-2.3,0.4-3.4v-3.3C38.6,30,38.5,29.6,38.3,29.1z M36.7,33.7
|
||||||
|
c0,1-0.1,2-0.4,3L35,42.3c0,0.1-0.1,0.2-0.1,0.3c-0.1,0.1-0.1,0.2-0.2,0.2C34.4,42.9,34.2,43,34,43H23c-0.3,0-0.6,0-0.8-0.2
|
||||||
|
c-0.3-0.1-0.5-0.3-0.7-0.6l-5.9-7.8c-0.2-0.3-0.4-0.7-0.4-1.2c0-0.3,0-0.5,0.1-0.7c0.1-0.2,0.2-0.4,0.4-0.6c0.2-0.2,0.4-0.3,0.6-0.4
|
||||||
|
c0.2-0.1,0.5-0.2,0.7-0.2c0.3,0,0.6,0.1,0.9,0.2c0.3,0.1,0.5,0.3,0.7,0.6l2.3,3.1V19.9c0-0.3,0.1-0.5,0.2-0.7c0.2-0.5,0.6-0.8,1.1-1
|
||||||
|
C22.5,18,22.7,18,23,18c0.3,0,0.5,0,0.8,0.1c0.2,0.1,0.5,0.2,0.6,0.4c0.4,0.4,0.6,0.9,0.5,1.4v10.4h0.6v-1.5c0-0.5,0.2-1,0.5-1.4
|
||||||
|
c0.2-0.2,0.4-0.3,0.6-0.4c0.2-0.1,0.5-0.1,0.7-0.1c0.3,0,0.5,0,0.8,0.1c0.2,0.1,0.4,0.2,0.6,0.4c0.4,0.4,0.6,0.9,0.6,1.4v1.3h0.5v-1
|
||||||
|
c0-0.2,0-0.4,0.1-0.6c0.1-0.2,0.2-0.4,0.4-0.5c0.3-0.3,0.8-0.5,1.2-0.5c0.5,0,0.9,0.2,1.2,0.5c0.2,0.2,0.3,0.3,0.4,0.6
|
||||||
|
c0.1,0.2,0.1,0.4,0.1,0.7v1h0.5c0-0.4,0.2-0.8,0.4-1.1c0.1-0.1,0.3-0.3,0.5-0.3c0.2-0.1,0.4-0.1,0.6-0.1c0.2,0,0.4,0,0.6,0.1
|
||||||
|
c0.2,0.1,0.3,0.2,0.5,0.4c0.3,0.3,0.4,0.7,0.4,1.1V33.7z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.3 KiB |
|
@ -113,6 +113,10 @@ Item {
|
||||||
visible: root.expanded
|
visible: root.expanded
|
||||||
text: "Avatars Updated: " + root.updatedAvatarCount
|
text: "Avatars Updated: " + root.updatedAvatarCount
|
||||||
}
|
}
|
||||||
|
StatText {
|
||||||
|
visible: root.expanded
|
||||||
|
text: "Heroes Count/Updated: " + root.heroAvatarCount + "/" + root.updatedHeroAvatarCount
|
||||||
|
}
|
||||||
StatText {
|
StatText {
|
||||||
visible: root.expanded
|
visible: root.expanded
|
||||||
text: "Avatars NOT Updated: " + root.notUpdatedAvatarCount
|
text: "Avatars NOT Updated: " + root.notUpdatedAvatarCount
|
||||||
|
|
|
@ -115,6 +115,10 @@ Item {
|
||||||
visible: root.expanded
|
visible: root.expanded
|
||||||
text: "Avatars Updated: " + root.updatedAvatarCount
|
text: "Avatars Updated: " + root.updatedAvatarCount
|
||||||
}
|
}
|
||||||
|
StatText {
|
||||||
|
visible: root.expanded
|
||||||
|
text: "Heroes Count/Updated: " + root.heroAvatarCount + "/" + root.updatedHeroAvatarCount
|
||||||
|
}
|
||||||
StatText {
|
StatText {
|
||||||
visible: root.expanded
|
visible: root.expanded
|
||||||
text: "Avatars NOT Updated: " + root.notUpdatedAvatarCount
|
text: "Avatars NOT Updated: " + root.notUpdatedAvatarCount
|
||||||
|
|
|
@ -104,7 +104,6 @@ Rectangle {
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
x: 2 * margins.paddings;
|
x: 2 * margins.paddings;
|
||||||
spacing: columnOne.width;
|
|
||||||
width: parent.width;
|
width: parent.width;
|
||||||
|
|
||||||
// mute is in its own row
|
// mute is in its own row
|
||||||
|
@ -119,12 +118,81 @@ Rectangle {
|
||||||
labelTextOn: "Mute microphone";
|
labelTextOn: "Mute microphone";
|
||||||
backgroundOnColor: "#E3E3E3";
|
backgroundOnColor: "#E3E3E3";
|
||||||
checked: AudioScriptingInterface.muted;
|
checked: AudioScriptingInterface.muted;
|
||||||
onCheckedChanged: {
|
onClicked: {
|
||||||
|
if (AudioScriptingInterface.pushToTalk && !checked) {
|
||||||
|
// disable push to talk if unmuting
|
||||||
|
AudioScriptingInterface.pushToTalk = false;
|
||||||
|
}
|
||||||
AudioScriptingInterface.muted = checked;
|
AudioScriptingInterface.muted = checked;
|
||||||
checked = Qt.binding(function() { return AudioScriptingInterface.muted; }); // restore binding
|
checked = Qt.binding(function() { return AudioScriptingInterface.muted; }); // restore binding
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HifiControlsUit.Switch {
|
||||||
|
height: root.switchHeight;
|
||||||
|
switchWidth: root.switchWidth;
|
||||||
|
labelTextOn: "Noise Reduction";
|
||||||
|
backgroundOnColor: "#E3E3E3";
|
||||||
|
checked: AudioScriptingInterface.noiseReduction;
|
||||||
|
onCheckedChanged: {
|
||||||
|
AudioScriptingInterface.noiseReduction = checked;
|
||||||
|
checked = Qt.binding(function() { return AudioScriptingInterface.noiseReduction; }); // restore binding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HifiControlsUit.Switch {
|
||||||
|
id: pttSwitch
|
||||||
|
height: root.switchHeight;
|
||||||
|
switchWidth: root.switchWidth;
|
||||||
|
labelTextOn: qsTr("Push To Talk (T)");
|
||||||
|
backgroundOnColor: "#E3E3E3";
|
||||||
|
checked: (bar.currentIndex === 0) ? AudioScriptingInterface.pushToTalkDesktop : AudioScriptingInterface.pushToTalkHMD;
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (bar.currentIndex === 0) {
|
||||||
|
AudioScriptingInterface.pushToTalkDesktop = checked;
|
||||||
|
} else {
|
||||||
|
AudioScriptingInterface.pushToTalkHMD = checked;
|
||||||
|
}
|
||||||
|
checked = Qt.binding(function() {
|
||||||
|
if (bar.currentIndex === 0) {
|
||||||
|
return AudioScriptingInterface.pushToTalkDesktop;
|
||||||
|
} else {
|
||||||
|
return AudioScriptingInterface.pushToTalkHMD;
|
||||||
|
}
|
||||||
|
}); // restore binding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
spacing: 24;
|
||||||
|
HifiControlsUit.Switch {
|
||||||
|
id: warnMutedSwitch
|
||||||
|
height: root.switchHeight;
|
||||||
|
switchWidth: root.switchWidth;
|
||||||
|
labelTextOn: qsTr("Warn when muted");
|
||||||
|
backgroundOnColor: "#E3E3E3";
|
||||||
|
checked: AudioScriptingInterface.warnWhenMuted;
|
||||||
|
onClicked: {
|
||||||
|
AudioScriptingInterface.warnWhenMuted = checked;
|
||||||
|
checked = Qt.binding(function() { return AudioScriptingInterface.warnWhenMuted; }); // restore binding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HifiControlsUit.Switch {
|
||||||
|
id: audioLevelSwitch
|
||||||
|
height: root.switchHeight;
|
||||||
|
switchWidth: root.switchWidth;
|
||||||
|
labelTextOn: qsTr("Audio Level Meter");
|
||||||
|
backgroundOnColor: "#E3E3E3";
|
||||||
|
checked: AvatarInputs.showAudioTools;
|
||||||
|
onCheckedChanged: {
|
||||||
|
AvatarInputs.showAudioTools = checked;
|
||||||
|
checked = Qt.binding(function() { return AvatarInputs.showAudioTools; }); // restore binding
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HifiControlsUit.Switch {
|
HifiControlsUit.Switch {
|
||||||
id: stereoInput;
|
id: stereoInput;
|
||||||
height: root.switchHeight;
|
height: root.switchHeight;
|
||||||
|
@ -137,38 +205,31 @@ Rectangle {
|
||||||
checked = Qt.binding(function() { return AudioScriptingInterface.isStereoInput; }); // restore binding
|
checked = Qt.binding(function() { return AudioScriptingInterface.isStereoInput; }); // restore binding
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
spacing: 24;
|
|
||||||
HifiControlsUit.Switch {
|
|
||||||
height: root.switchHeight;
|
|
||||||
switchWidth: root.switchWidth;
|
|
||||||
labelTextOn: "Noise Reduction";
|
|
||||||
backgroundOnColor: "#E3E3E3";
|
|
||||||
checked: AudioScriptingInterface.noiseReduction;
|
|
||||||
onCheckedChanged: {
|
|
||||||
AudioScriptingInterface.noiseReduction = checked;
|
|
||||||
checked = Qt.binding(function() { return AudioScriptingInterface.noiseReduction; }); // restore binding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HifiControlsUit.Switch {
|
|
||||||
id: audioLevelSwitch
|
|
||||||
height: root.switchHeight;
|
|
||||||
switchWidth: root.switchWidth;
|
|
||||||
labelTextOn: qsTr("Audio Level Meter");
|
|
||||||
backgroundOnColor: "#E3E3E3";
|
|
||||||
checked: AvatarInputs.showAudioTools;
|
|
||||||
onCheckedChanged: {
|
|
||||||
AvatarInputs.showAudioTools = checked;
|
|
||||||
checked = Qt.binding(function() { return AvatarInputs.showAudioTools; }); // restore binding
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Separator {}
|
Item {
|
||||||
|
anchors.left: parent.left
|
||||||
|
width: rightMostInputLevelPos;
|
||||||
|
height: pttText.height;
|
||||||
|
RalewayRegular {
|
||||||
|
id: pttText
|
||||||
|
x: margins.paddings;
|
||||||
|
color: hifi.colors.white;
|
||||||
|
width: rightMostInputLevelPos;
|
||||||
|
height: paintedHeight;
|
||||||
|
wrapMode: Text.WordWrap;
|
||||||
|
font.italic: true
|
||||||
|
size: 16;
|
||||||
|
|
||||||
|
text: (bar.currentIndex === 0) ? qsTr("Press and hold the button \"T\" to talk.") :
|
||||||
|
qsTr("Press and hold grip triggers on both of your controllers to talk.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Separator { }
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
x: margins.paddings;
|
x: margins.paddings;
|
||||||
|
@ -223,7 +284,7 @@ Rectangle {
|
||||||
text: devicename
|
text: devicename
|
||||||
onPressed: {
|
onPressed: {
|
||||||
if (!checked) {
|
if (!checked) {
|
||||||
stereoMic.checked = false;
|
stereoInput.checked = false;
|
||||||
AudioScriptingInterface.setStereoInput(false); // the next selected audio device might not support stereo
|
AudioScriptingInterface.setStereoInput(false); // the next selected audio device might not support stereo
|
||||||
AudioScriptingInterface.setInputDevice(info, bar.currentIndex === 1);
|
AudioScriptingInterface.setInputDevice(info, bar.currentIndex === 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,21 @@
|
||||||
|
|
||||||
import QtQuick 2.5
|
import QtQuick 2.5
|
||||||
import QtGraphicalEffects 1.0
|
import QtGraphicalEffects 1.0
|
||||||
|
import stylesUit 1.0
|
||||||
|
|
||||||
import TabletScriptingInterface 1.0
|
import TabletScriptingInterface 1.0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
HifiConstants { id: hifi; }
|
||||||
|
|
||||||
readonly property var level: AudioScriptingInterface.inputLevel;
|
readonly property var level: AudioScriptingInterface.inputLevel;
|
||||||
|
|
||||||
property bool gated: false;
|
property bool gated: false;
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; });
|
AudioScriptingInterface.noiseGateOpened.connect(function() { gated = false; });
|
||||||
AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; });
|
AudioScriptingInterface.noiseGateClosed.connect(function() { gated = true; });
|
||||||
}
|
}
|
||||||
|
|
||||||
property bool standalone: false;
|
property bool standalone: false;
|
||||||
property var dragTarget: null;
|
property var dragTarget: null;
|
||||||
|
|
||||||
|
@ -64,6 +67,9 @@ Rectangle {
|
||||||
hoverEnabled: true;
|
hoverEnabled: true;
|
||||||
scrollGestureEnabled: false;
|
scrollGestureEnabled: false;
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
if (AudioScriptingInterface.pushToTalk) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
AudioScriptingInterface.muted = !AudioScriptingInterface.muted;
|
AudioScriptingInterface.muted = !AudioScriptingInterface.muted;
|
||||||
Tablet.playSound(TabletEnums.ButtonClick);
|
Tablet.playSound(TabletEnums.ButtonClick);
|
||||||
}
|
}
|
||||||
|
@ -106,9 +112,10 @@ Rectangle {
|
||||||
Image {
|
Image {
|
||||||
readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg";
|
readonly property string unmutedIcon: "../../../icons/tablet-icons/mic-unmute-i.svg";
|
||||||
readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg";
|
readonly property string mutedIcon: "../../../icons/tablet-icons/mic-mute-i.svg";
|
||||||
|
readonly property string pushToTalkIcon: "../../../icons/tablet-icons/mic-ptt-i.svg";
|
||||||
|
|
||||||
id: image;
|
id: image;
|
||||||
source: AudioScriptingInterface.muted ? mutedIcon : unmutedIcon;
|
source: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? pushToTalkIcon : AudioScriptingInterface.muted ? mutedIcon : unmutedIcon;
|
||||||
|
|
||||||
width: 30;
|
width: 30;
|
||||||
height: 30;
|
height: 30;
|
||||||
|
@ -133,7 +140,7 @@ Rectangle {
|
||||||
|
|
||||||
readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted;
|
readonly property string color: AudioScriptingInterface.muted ? colors.muted : colors.unmuted;
|
||||||
|
|
||||||
visible: AudioScriptingInterface.muted;
|
visible: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) || AudioScriptingInterface.muted;
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left;
|
left: parent.left;
|
||||||
|
@ -152,7 +159,7 @@ Rectangle {
|
||||||
|
|
||||||
color: parent.color;
|
color: parent.color;
|
||||||
|
|
||||||
text: AudioScriptingInterface.muted ? "MUTED" : "MUTE";
|
text: (AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk) ? (HMD.active ? "MUTED PTT" : "MUTED PTT-(T)") : (AudioScriptingInterface.muted ? "MUTED" : "MUTE");
|
||||||
font.pointSize: 12;
|
font.pointSize: 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +169,7 @@ Rectangle {
|
||||||
verticalCenter: parent.verticalCenter;
|
verticalCenter: parent.verticalCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 50;
|
width: AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk ? (HMD.active ? 27 : 25) : 50;
|
||||||
height: 4;
|
height: 4;
|
||||||
color: parent.color;
|
color: parent.color;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +180,7 @@ Rectangle {
|
||||||
verticalCenter: parent.verticalCenter;
|
verticalCenter: parent.verticalCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 50;
|
width: AudioScriptingInterface.pushToTalk && !AudioScriptingInterface.pushingToTalk ? (HMD.active ? 27 : 25) : 50;
|
||||||
height: 4;
|
height: 4;
|
||||||
color: parent.color;
|
color: parent.color;
|
||||||
}
|
}
|
||||||
|
@ -228,12 +235,12 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: gatedIndicator;
|
id: gatedIndicator;
|
||||||
visible: gated && !AudioScriptingInterface.clipping
|
visible: gated && !AudioScriptingInterface.clipping
|
||||||
|
|
||||||
radius: 4;
|
radius: 4;
|
||||||
width: 2 * radius;
|
width: 2 * radius;
|
||||||
height: 2 * radius;
|
height: 2 * radius;
|
||||||
color: "#0080FF";
|
color: "#0080FF";
|
||||||
|
@ -242,12 +249,12 @@ Rectangle {
|
||||||
verticalCenter: parent.verticalCenter;
|
verticalCenter: parent.verticalCenter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: clippingIndicator;
|
id: clippingIndicator;
|
||||||
visible: AudioScriptingInterface.clipping
|
visible: AudioScriptingInterface.clipping
|
||||||
|
|
||||||
radius: 4;
|
radius: 4;
|
||||||
width: 2 * radius;
|
width: 2 * radius;
|
||||||
height: 2 * radius;
|
height: 2 * radius;
|
||||||
color: colors.red;
|
color: colors.red;
|
||||||
|
|
|
@ -1599,12 +1599,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
connect(userInputMapper.data(), &UserInputMapper::actionEvent, [this](int action, float state) {
|
connect(userInputMapper.data(), &UserInputMapper::actionEvent, [this](int action, float state) {
|
||||||
using namespace controller;
|
using namespace controller;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
|
auto audioScriptingInterface = reinterpret_cast<scripting::Audio*>(DependencyManager::get<AudioScriptingInterface>().data());
|
||||||
{
|
{
|
||||||
auto actionEnum = static_cast<Action>(action);
|
auto actionEnum = static_cast<Action>(action);
|
||||||
int key = Qt::Key_unknown;
|
int key = Qt::Key_unknown;
|
||||||
static int lastKey = Qt::Key_unknown;
|
static int lastKey = Qt::Key_unknown;
|
||||||
bool navAxis = false;
|
bool navAxis = false;
|
||||||
switch (actionEnum) {
|
switch (actionEnum) {
|
||||||
|
case Action::TOGGLE_PUSHTOTALK:
|
||||||
|
if (state > 0.0f) {
|
||||||
|
audioScriptingInterface->setPushingToTalk(true);
|
||||||
|
} else if (state <= 0.0f) {
|
||||||
|
audioScriptingInterface->setPushingToTalk(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case Action::UI_NAV_VERTICAL:
|
case Action::UI_NAV_VERTICAL:
|
||||||
navAxis = true;
|
navAxis = true;
|
||||||
if (state > 0.0f) {
|
if (state > 0.0f) {
|
||||||
|
@ -4310,6 +4319,7 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||||
if (_keyboardMouseDevice->isActive()) {
|
if (_keyboardMouseDevice->isActive()) {
|
||||||
_keyboardMouseDevice->keyReleaseEvent(event);
|
_keyboardMouseDevice->keyReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::focusOutEvent(QFocusEvent* event) {
|
void Application::focusOutEvent(QFocusEvent* event) {
|
||||||
|
@ -5241,6 +5251,9 @@ void Application::loadSettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto audioScriptingInterface = reinterpret_cast<scripting::Audio*>(DependencyManager::get<AudioScriptingInterface>().data());
|
||||||
|
audioScriptingInterface->loadData();
|
||||||
|
|
||||||
getMyAvatar()->loadData();
|
getMyAvatar()->loadData();
|
||||||
_settingsLoaded = true;
|
_settingsLoaded = true;
|
||||||
}
|
}
|
||||||
|
@ -5250,6 +5263,9 @@ void Application::saveSettings() const {
|
||||||
DependencyManager::get<AudioClient>()->saveSettings();
|
DependencyManager::get<AudioClient>()->saveSettings();
|
||||||
DependencyManager::get<LODManager>()->saveSettings();
|
DependencyManager::get<LODManager>()->saveSettings();
|
||||||
|
|
||||||
|
auto audioScriptingInterface = reinterpret_cast<scripting::Audio*>(DependencyManager::get<AudioScriptingInterface>().data());
|
||||||
|
audioScriptingInterface->saveData();
|
||||||
|
|
||||||
Menu::getInstance()->saveSettings();
|
Menu::getInstance()->saveSettings();
|
||||||
getMyAvatar()->saveData();
|
getMyAvatar()->saveData();
|
||||||
PluginManager::getInstance()->saveSettings();
|
PluginManager::getInstance()->saveSettings();
|
||||||
|
|
|
@ -232,96 +232,142 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
||||||
auto avatarMap = getHashCopy();
|
auto avatarMap = getHashCopy();
|
||||||
|
|
||||||
const auto& views = qApp->getConicalViews();
|
const auto& views = qApp->getConicalViews();
|
||||||
PrioritySortUtil::PriorityQueue<SortableAvatar> sortedAvatars(views,
|
// Prepare 2 queues for heros and for crowd avatars
|
||||||
AvatarData::_avatarSortCoefficientSize,
|
using AvatarPriorityQueue = PrioritySortUtil::PriorityQueue<SortableAvatar>;
|
||||||
AvatarData::_avatarSortCoefficientCenter,
|
// Keep two independent queues, one for heroes and one for the riff-raff.
|
||||||
AvatarData::_avatarSortCoefficientAge);
|
enum PriorityVariants
|
||||||
sortedAvatars.reserve(avatarMap.size() - 1); // don't include MyAvatar
|
{
|
||||||
|
kHero = 0,
|
||||||
|
kNonHero,
|
||||||
|
NumVariants
|
||||||
|
};
|
||||||
|
AvatarPriorityQueue avatarPriorityQueues[NumVariants] = {
|
||||||
|
{ views,
|
||||||
|
AvatarData::_avatarSortCoefficientSize,
|
||||||
|
AvatarData::_avatarSortCoefficientCenter,
|
||||||
|
AvatarData::_avatarSortCoefficientAge },
|
||||||
|
{ views,
|
||||||
|
AvatarData::_avatarSortCoefficientSize,
|
||||||
|
AvatarData::_avatarSortCoefficientCenter,
|
||||||
|
AvatarData::_avatarSortCoefficientAge } };
|
||||||
|
// Reserve space
|
||||||
|
//avatarPriorityQueues[kHero].reserve(10); // just few
|
||||||
|
avatarPriorityQueues[kNonHero].reserve(avatarMap.size() - 1); // don't include MyAvatar
|
||||||
|
|
||||||
// Build vector and compute priorities
|
// Build vector and compute priorities
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
AvatarHash::iterator itr = avatarMap.begin();
|
AvatarHash::iterator itr = avatarMap.begin();
|
||||||
while (itr != avatarMap.end()) {
|
while (itr != avatarMap.end()) {
|
||||||
const auto& avatar = std::static_pointer_cast<Avatar>(*itr);
|
auto avatar = std::static_pointer_cast<Avatar>(*itr);
|
||||||
// DO NOT update _myAvatar! Its update has already been done earlier in the main loop.
|
// DO NOT update _myAvatar! Its update has already been done earlier in the main loop.
|
||||||
// DO NOT update or fade out uninitialized Avatars
|
// DO NOT update or fade out uninitialized Avatars
|
||||||
if (avatar != _myAvatar && avatar->isInitialized() && !nodeList->isPersonalMutingNode(avatar->getID())) {
|
if (avatar != _myAvatar && avatar->isInitialized() && !nodeList->isPersonalMutingNode(avatar->getID())) {
|
||||||
sortedAvatars.push(SortableAvatar(avatar));
|
if (avatar->getHasPriority()) {
|
||||||
|
avatarPriorityQueues[kHero].push(SortableAvatar(avatar));
|
||||||
|
} else {
|
||||||
|
avatarPriorityQueues[kNonHero].push(SortableAvatar(avatar));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
++itr;
|
++itr;
|
||||||
}
|
}
|
||||||
// Sort
|
|
||||||
const auto& sortedAvatarVector = sortedAvatars.getSortedVector();
|
_numHeroAvatars = (int)avatarPriorityQueues[kHero].size();
|
||||||
|
|
||||||
// process in sorted order
|
// process in sorted order
|
||||||
uint64_t startTime = usecTimestampNow();
|
uint64_t startTime = usecTimestampNow();
|
||||||
uint64_t updateExpiry = startTime + MAX_UPDATE_AVATARS_TIME_BUDGET;
|
|
||||||
|
const uint64_t MAX_UPDATE_HEROS_TIME_BUDGET = uint64_t(0.8 * MAX_UPDATE_AVATARS_TIME_BUDGET);
|
||||||
|
|
||||||
|
uint64_t updatePriorityExpiries[NumVariants] = { startTime + MAX_UPDATE_HEROS_TIME_BUDGET, startTime + MAX_UPDATE_AVATARS_TIME_BUDGET };
|
||||||
|
int numHerosUpdated = 0;
|
||||||
int numAvatarsUpdated = 0;
|
int numAvatarsUpdated = 0;
|
||||||
int numAVatarsNotUpdated = 0;
|
int numAvatarsNotUpdated = 0;
|
||||||
|
|
||||||
render::Transaction renderTransaction;
|
render::Transaction renderTransaction;
|
||||||
workload::Transaction workloadTransaction;
|
workload::Transaction workloadTransaction;
|
||||||
for (auto it = sortedAvatarVector.begin(); it != sortedAvatarVector.end(); ++it) {
|
|
||||||
const SortableAvatar& sortData = *it;
|
for (int p = kHero; p < NumVariants; p++) {
|
||||||
const auto avatar = std::static_pointer_cast<OtherAvatar>(sortData.getAvatar());
|
auto& priorityQueue = avatarPriorityQueues[p];
|
||||||
if (!avatar->_isClientAvatar) {
|
// Sorting the current queue HERE as part of the measured timing.
|
||||||
avatar->setIsClientAvatar(true);
|
const auto& sortedAvatarVector = priorityQueue.getSortedVector();
|
||||||
}
|
|
||||||
// TODO: to help us scale to more avatars it would be nice to not have to poll this stuff every update
|
|
||||||
if (avatar->getSkeletonModel()->isLoaded()) {
|
|
||||||
// remove the orb if it is there
|
|
||||||
avatar->removeOrb();
|
|
||||||
if (avatar->needsPhysicsUpdate()) {
|
|
||||||
_avatarsToChangeInPhysics.insert(avatar);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
avatar->updateOrbPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
// for ALL avatars...
|
auto passExpiry = updatePriorityExpiries[p];
|
||||||
if (_shouldRender) {
|
|
||||||
avatar->ensureInScene(avatar, qApp->getMain3DScene());
|
|
||||||
}
|
|
||||||
avatar->animateScaleChanges(deltaTime);
|
|
||||||
|
|
||||||
uint64_t now = usecTimestampNow();
|
for (auto it = sortedAvatarVector.begin(); it != sortedAvatarVector.end(); ++it) {
|
||||||
if (now < updateExpiry) {
|
const SortableAvatar& sortData = *it;
|
||||||
// we're within budget
|
const auto avatar = std::static_pointer_cast<OtherAvatar>(sortData.getAvatar());
|
||||||
bool inView = sortData.getPriority() > OUT_OF_VIEW_THRESHOLD;
|
if (!avatar->_isClientAvatar) {
|
||||||
if (inView && avatar->hasNewJointData()) {
|
avatar->setIsClientAvatar(true);
|
||||||
numAvatarsUpdated++;
|
|
||||||
}
|
}
|
||||||
auto transitStatus = avatar->_transit.update(deltaTime, avatar->_serverPosition, _transitConfig);
|
// TODO: to help us scale to more avatars it would be nice to not have to poll this stuff every update
|
||||||
if (avatar->getIsNewAvatar() && (transitStatus == AvatarTransit::Status::START_TRANSIT || transitStatus == AvatarTransit::Status::ABORT_TRANSIT)) {
|
if (avatar->getSkeletonModel()->isLoaded()) {
|
||||||
avatar->_transit.reset();
|
// remove the orb if it is there
|
||||||
avatar->setIsNewAvatar(false);
|
avatar->removeOrb();
|
||||||
}
|
if (avatar->needsPhysicsUpdate()) {
|
||||||
avatar->simulate(deltaTime, inView);
|
_avatarsToChangeInPhysics.insert(avatar);
|
||||||
if (avatar->getSkeletonModel()->isLoaded() && avatar->getWorkloadRegion() == workload::Region::R1) {
|
|
||||||
_myAvatar->addAvatarHandsToFlow(avatar);
|
|
||||||
}
|
|
||||||
avatar->updateRenderItem(renderTransaction);
|
|
||||||
avatar->updateSpaceProxy(workloadTransaction);
|
|
||||||
avatar->setLastRenderUpdateTime(startTime);
|
|
||||||
} else {
|
|
||||||
// we've spent our full time budget --> bail on the rest of the avatar updates
|
|
||||||
// --> more avatars may freeze until their priority trickles up
|
|
||||||
// --> some scale animations may glitch
|
|
||||||
// --> some avatar velocity measurements may be a little off
|
|
||||||
|
|
||||||
// no time to simulate, but we take the time to count how many were tragically missed
|
|
||||||
while (it != sortedAvatarVector.end()) {
|
|
||||||
const SortableAvatar& newSortData = *it;
|
|
||||||
const auto& newAvatar = newSortData.getAvatar();
|
|
||||||
bool inView = newSortData.getPriority() > OUT_OF_VIEW_THRESHOLD;
|
|
||||||
// Once we reach an avatar that's not in view, all avatars after it will also be out of view
|
|
||||||
if (!inView) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
numAVatarsNotUpdated += (int)(newAvatar->hasNewJointData());
|
} else {
|
||||||
++it;
|
avatar->updateOrbPosition();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
// for ALL avatars...
|
||||||
|
if (_shouldRender) {
|
||||||
|
avatar->ensureInScene(avatar, qApp->getMain3DScene());
|
||||||
|
}
|
||||||
|
|
||||||
|
avatar->animateScaleChanges(deltaTime);
|
||||||
|
|
||||||
|
uint64_t now = usecTimestampNow();
|
||||||
|
if (now < passExpiry) {
|
||||||
|
// we're within budget
|
||||||
|
bool inView = sortData.getPriority() > OUT_OF_VIEW_THRESHOLD;
|
||||||
|
if (inView && avatar->hasNewJointData()) {
|
||||||
|
numAvatarsUpdated++;
|
||||||
|
}
|
||||||
|
auto transitStatus = avatar->_transit.update(deltaTime, avatar->_serverPosition, _transitConfig);
|
||||||
|
if (avatar->getIsNewAvatar() && (transitStatus == AvatarTransit::Status::START_TRANSIT ||
|
||||||
|
transitStatus == AvatarTransit::Status::ABORT_TRANSIT)) {
|
||||||
|
avatar->_transit.reset();
|
||||||
|
avatar->setIsNewAvatar(false);
|
||||||
|
}
|
||||||
|
avatar->simulate(deltaTime, inView);
|
||||||
|
if (avatar->getSkeletonModel()->isLoaded() && avatar->getWorkloadRegion() == workload::Region::R1) {
|
||||||
|
_myAvatar->addAvatarHandsToFlow(avatar);
|
||||||
|
}
|
||||||
|
avatar->updateRenderItem(renderTransaction);
|
||||||
|
avatar->updateSpaceProxy(workloadTransaction);
|
||||||
|
avatar->setLastRenderUpdateTime(startTime);
|
||||||
|
} else {
|
||||||
|
// we've spent our time budget for this priority bucket
|
||||||
|
// let's deal with the reminding avatars if this pass and BREAK from the for loop
|
||||||
|
|
||||||
|
if (p == kHero) {
|
||||||
|
// Hero,
|
||||||
|
// --> put them back in the non hero queue
|
||||||
|
|
||||||
|
auto& crowdQueue = avatarPriorityQueues[kNonHero];
|
||||||
|
while (it != sortedAvatarVector.end()) {
|
||||||
|
crowdQueue.push(SortableAvatar((*it).getAvatar()));
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Non Hero
|
||||||
|
// --> bail on the rest of the avatar updates
|
||||||
|
// --> more avatars may freeze until their priority trickles up
|
||||||
|
// --> some scale animations may glitch
|
||||||
|
// --> some avatar velocity measurements may be a little off
|
||||||
|
|
||||||
|
// no time to simulate, but we take the time to count how many were tragically missed
|
||||||
|
numAvatarsNotUpdated = sortedAvatarVector.end() - it;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We had to cut short this pass, we must break out of the for loop here
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p == kHero) {
|
||||||
|
numHerosUpdated = numAvatarsUpdated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +383,8 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
||||||
_space->enqueueTransaction(workloadTransaction);
|
_space->enqueueTransaction(workloadTransaction);
|
||||||
|
|
||||||
_numAvatarsUpdated = numAvatarsUpdated;
|
_numAvatarsUpdated = numAvatarsUpdated;
|
||||||
_numAvatarsNotUpdated = numAVatarsNotUpdated;
|
_numAvatarsNotUpdated = numAvatarsNotUpdated;
|
||||||
|
_numHeroAvatarsUpdated = numHerosUpdated;
|
||||||
|
|
||||||
simulateAvatarFades(deltaTime);
|
simulateAvatarFades(deltaTime);
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,8 @@ public:
|
||||||
|
|
||||||
int getNumAvatarsUpdated() const { return _numAvatarsUpdated; }
|
int getNumAvatarsUpdated() const { return _numAvatarsUpdated; }
|
||||||
int getNumAvatarsNotUpdated() const { return _numAvatarsNotUpdated; }
|
int getNumAvatarsNotUpdated() const { return _numAvatarsNotUpdated; }
|
||||||
|
int getNumHeroAvatars() const { return _numHeroAvatars; }
|
||||||
|
int getNumHeroAvatarsUpdated() const { return _numHeroAvatarsUpdated; }
|
||||||
float getAvatarSimulationTime() const { return _avatarSimulationTime; }
|
float getAvatarSimulationTime() const { return _avatarSimulationTime; }
|
||||||
|
|
||||||
void updateMyAvatar(float deltaTime);
|
void updateMyAvatar(float deltaTime);
|
||||||
|
@ -242,6 +244,8 @@ private:
|
||||||
RateCounter<> _myAvatarSendRate;
|
RateCounter<> _myAvatarSendRate;
|
||||||
int _numAvatarsUpdated { 0 };
|
int _numAvatarsUpdated { 0 };
|
||||||
int _numAvatarsNotUpdated { 0 };
|
int _numAvatarsNotUpdated { 0 };
|
||||||
|
int _numHeroAvatars{ 0 };
|
||||||
|
int _numHeroAvatarsUpdated{ 0 };
|
||||||
float _avatarSimulationTime { 0.0f };
|
float _avatarSimulationTime { 0.0f };
|
||||||
bool _shouldRender { true };
|
bool _shouldRender { true };
|
||||||
bool _myAvatarDataPacketsPaused { false };
|
bool _myAvatarDataPacketsPaused { false };
|
||||||
|
|
|
@ -200,17 +200,6 @@ void OtherAvatar::resetDetailedMotionStates() {
|
||||||
|
|
||||||
void OtherAvatar::setWorkloadRegion(uint8_t region) {
|
void OtherAvatar::setWorkloadRegion(uint8_t region) {
|
||||||
_workloadRegion = region;
|
_workloadRegion = region;
|
||||||
QString printRegion = "";
|
|
||||||
if (region == workload::Region::R1) {
|
|
||||||
printRegion = "R1";
|
|
||||||
} else if (region == workload::Region::R2) {
|
|
||||||
printRegion = "R2";
|
|
||||||
} else if (region == workload::Region::R3) {
|
|
||||||
printRegion = "R3";
|
|
||||||
} else {
|
|
||||||
printRegion = "invalid";
|
|
||||||
}
|
|
||||||
qCDebug(avatars) << "Setting workload region to " << printRegion;
|
|
||||||
computeShapeLOD();
|
computeShapeLOD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +224,6 @@ void OtherAvatar::computeShapeLOD() {
|
||||||
if (newLOD != _bodyLOD) {
|
if (newLOD != _bodyLOD) {
|
||||||
_bodyLOD = newLOD;
|
_bodyLOD = newLOD;
|
||||||
if (isInPhysicsSimulation()) {
|
if (isInPhysicsSimulation()) {
|
||||||
qCDebug(avatars) << "Changing to body LOD " << newLOD;
|
|
||||||
_needsReinsertion = true;
|
_needsReinsertion = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ QString Audio::DESKTOP { "Desktop" };
|
||||||
QString Audio::HMD { "VR" };
|
QString Audio::HMD { "VR" };
|
||||||
|
|
||||||
Setting::Handle<bool> enableNoiseReductionSetting { QStringList { Audio::AUDIO, "NoiseReduction" }, true };
|
Setting::Handle<bool> enableNoiseReductionSetting { QStringList { Audio::AUDIO, "NoiseReduction" }, true };
|
||||||
|
Setting::Handle<bool> enableWarnWhenMutedSetting { QStringList { Audio::AUDIO, "WarnWhenMuted" }, true };
|
||||||
|
|
||||||
|
|
||||||
float Audio::loudnessToLevel(float loudness) {
|
float Audio::loudnessToLevel(float loudness) {
|
||||||
float level = loudness * (1/32768.0f); // level in [0, 1]
|
float level = loudness * (1/32768.0f); // level in [0, 1]
|
||||||
|
@ -37,10 +39,13 @@ Audio::Audio() : _devices(_contextIsHMD) {
|
||||||
auto client = DependencyManager::get<AudioClient>().data();
|
auto client = DependencyManager::get<AudioClient>().data();
|
||||||
connect(client, &AudioClient::muteToggled, this, &Audio::setMuted);
|
connect(client, &AudioClient::muteToggled, this, &Audio::setMuted);
|
||||||
connect(client, &AudioClient::noiseReductionChanged, this, &Audio::enableNoiseReduction);
|
connect(client, &AudioClient::noiseReductionChanged, this, &Audio::enableNoiseReduction);
|
||||||
|
connect(client, &AudioClient::warnWhenMutedChanged, this, &Audio::enableWarnWhenMuted);
|
||||||
connect(client, &AudioClient::inputLoudnessChanged, this, &Audio::onInputLoudnessChanged);
|
connect(client, &AudioClient::inputLoudnessChanged, this, &Audio::onInputLoudnessChanged);
|
||||||
connect(client, &AudioClient::inputVolumeChanged, this, &Audio::setInputVolume);
|
connect(client, &AudioClient::inputVolumeChanged, this, &Audio::setInputVolume);
|
||||||
connect(this, &Audio::contextChanged, &_devices, &AudioDevices::onContextChanged);
|
connect(this, &Audio::contextChanged, &_devices, &AudioDevices::onContextChanged);
|
||||||
|
connect(this, &Audio::pushingToTalkChanged, this, &Audio::handlePushedToTalk);
|
||||||
enableNoiseReduction(enableNoiseReductionSetting.get());
|
enableNoiseReduction(enableNoiseReductionSetting.get());
|
||||||
|
enableWarnWhenMuted(enableWarnWhenMutedSetting.get());
|
||||||
onContextChanged();
|
onContextChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,26 +68,174 @@ void Audio::stopRecording() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Audio::isMuted() const {
|
bool Audio::isMuted() const {
|
||||||
return resultWithReadLock<bool>([&] {
|
bool isHMD = qApp->isHMDMode();
|
||||||
return _isMuted;
|
if (isHMD) {
|
||||||
});
|
return getMutedHMD();
|
||||||
|
} else {
|
||||||
|
return getMutedDesktop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::setMuted(bool isMuted) {
|
void Audio::setMuted(bool isMuted) {
|
||||||
|
bool isHMD = qApp->isHMDMode();
|
||||||
|
if (isHMD) {
|
||||||
|
setMutedHMD(isMuted);
|
||||||
|
} else {
|
||||||
|
setMutedDesktop(isMuted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::setMutedDesktop(bool isMuted) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
if (_isMuted != isMuted) {
|
if (_desktopMuted != isMuted) {
|
||||||
_isMuted = isMuted;
|
changed = true;
|
||||||
|
_desktopMuted = isMuted;
|
||||||
auto client = DependencyManager::get<AudioClient>().data();
|
auto client = DependencyManager::get<AudioClient>().data();
|
||||||
QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted), Q_ARG(bool, false));
|
QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted), Q_ARG(bool, false));
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (changed) {
|
if (changed) {
|
||||||
emit mutedChanged(isMuted);
|
emit mutedChanged(isMuted);
|
||||||
|
emit desktopMutedChanged(isMuted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Audio::getMutedDesktop() const {
|
||||||
|
return resultWithReadLock<bool>([&] {
|
||||||
|
return _desktopMuted;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::setMutedHMD(bool isMuted) {
|
||||||
|
bool changed = false;
|
||||||
|
withWriteLock([&] {
|
||||||
|
if (_hmdMuted != isMuted) {
|
||||||
|
changed = true;
|
||||||
|
_hmdMuted = isMuted;
|
||||||
|
auto client = DependencyManager::get<AudioClient>().data();
|
||||||
|
QMetaObject::invokeMethod(client, "setMuted", Q_ARG(bool, isMuted), Q_ARG(bool, false));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (changed) {
|
||||||
|
emit mutedChanged(isMuted);
|
||||||
|
emit hmdMutedChanged(isMuted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Audio::getMutedHMD() const {
|
||||||
|
return resultWithReadLock<bool>([&] {
|
||||||
|
return _hmdMuted;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Audio::getPTT() {
|
||||||
|
bool isHMD = qApp->isHMDMode();
|
||||||
|
if (isHMD) {
|
||||||
|
return getPTTHMD();
|
||||||
|
} else {
|
||||||
|
return getPTTDesktop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void scripting::Audio::setPushingToTalk(bool pushingToTalk) {
|
||||||
|
bool changed = false;
|
||||||
|
withWriteLock([&] {
|
||||||
|
if (_pushingToTalk != pushingToTalk) {
|
||||||
|
changed = true;
|
||||||
|
_pushingToTalk = pushingToTalk;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (changed) {
|
||||||
|
emit pushingToTalkChanged(pushingToTalk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Audio::getPushingToTalk() const {
|
||||||
|
return resultWithReadLock<bool>([&] {
|
||||||
|
return _pushingToTalk;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::setPTT(bool enabled) {
|
||||||
|
bool isHMD = qApp->isHMDMode();
|
||||||
|
if (isHMD) {
|
||||||
|
setPTTHMD(enabled);
|
||||||
|
} else {
|
||||||
|
setPTTDesktop(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::setPTTDesktop(bool enabled) {
|
||||||
|
bool changed = false;
|
||||||
|
withWriteLock([&] {
|
||||||
|
if (_pttDesktop != enabled) {
|
||||||
|
changed = true;
|
||||||
|
_pttDesktop = enabled;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!enabled) {
|
||||||
|
// Set to default behavior (unmuted for Desktop) on Push-To-Talk disable.
|
||||||
|
setMutedDesktop(true);
|
||||||
|
} else {
|
||||||
|
// Should be muted when not pushing to talk while PTT is enabled.
|
||||||
|
setMutedDesktop(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
emit pushToTalkChanged(enabled);
|
||||||
|
emit pushToTalkDesktopChanged(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Audio::getPTTDesktop() const {
|
||||||
|
return resultWithReadLock<bool>([&] {
|
||||||
|
return _pttDesktop;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::setPTTHMD(bool enabled) {
|
||||||
|
bool changed = false;
|
||||||
|
withWriteLock([&] {
|
||||||
|
if (_pttHMD != enabled) {
|
||||||
|
changed = true;
|
||||||
|
_pttHMD = enabled;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!enabled) {
|
||||||
|
// Set to default behavior (unmuted for HMD) on Push-To-Talk disable.
|
||||||
|
setMutedHMD(false);
|
||||||
|
} else {
|
||||||
|
// Should be muted when not pushing to talk while PTT is enabled.
|
||||||
|
setMutedHMD(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
emit pushToTalkChanged(enabled);
|
||||||
|
emit pushToTalkHMDChanged(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::saveData() {
|
||||||
|
_desktopMutedSetting.set(getMutedDesktop());
|
||||||
|
_hmdMutedSetting.set(getMutedHMD());
|
||||||
|
_pttDesktopSetting.set(getPTTDesktop());
|
||||||
|
_pttHMDSetting.set(getPTTHMD());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::loadData() {
|
||||||
|
_desktopMuted = _desktopMutedSetting.get();
|
||||||
|
_hmdMuted = _hmdMutedSetting.get();
|
||||||
|
_pttDesktop = _pttDesktopSetting.get();
|
||||||
|
_pttHMD = _pttHMDSetting.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Audio::getPTTHMD() const {
|
||||||
|
return resultWithReadLock<bool>([&] {
|
||||||
|
return _pttHMD;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bool Audio::noiseReductionEnabled() const {
|
bool Audio::noiseReductionEnabled() const {
|
||||||
return resultWithReadLock<bool>([&] {
|
return resultWithReadLock<bool>([&] {
|
||||||
return _enableNoiseReduction;
|
return _enableNoiseReduction;
|
||||||
|
@ -105,6 +258,28 @@ void Audio::enableNoiseReduction(bool enable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Audio::warnWhenMutedEnabled() const {
|
||||||
|
return resultWithReadLock<bool>([&] {
|
||||||
|
return _enableWarnWhenMuted;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Audio::enableWarnWhenMuted(bool enable) {
|
||||||
|
bool changed = false;
|
||||||
|
withWriteLock([&] {
|
||||||
|
if (_enableWarnWhenMuted != enable) {
|
||||||
|
_enableWarnWhenMuted = enable;
|
||||||
|
auto client = DependencyManager::get<AudioClient>().data();
|
||||||
|
QMetaObject::invokeMethod(client, "setWarnWhenMuted", Q_ARG(bool, enable), Q_ARG(bool, false));
|
||||||
|
enableWarnWhenMutedSetting.set(enable);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (changed) {
|
||||||
|
emit warnWhenMutedChanged(enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float Audio::getInputVolume() const {
|
float Audio::getInputVolume() const {
|
||||||
return resultWithReadLock<bool>([&] {
|
return resultWithReadLock<bool>([&] {
|
||||||
return _inputVolume;
|
return _inputVolume;
|
||||||
|
@ -179,11 +354,26 @@ void Audio::onContextChanged() {
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (isHMD) {
|
||||||
|
setMuted(getMutedHMD());
|
||||||
|
} else {
|
||||||
|
setMuted(getMutedDesktop());
|
||||||
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
emit contextChanged(isHMD ? Audio::HMD : Audio::DESKTOP);
|
emit contextChanged(isHMD ? Audio::HMD : Audio::DESKTOP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Audio::handlePushedToTalk(bool enabled) {
|
||||||
|
if (getPTT()) {
|
||||||
|
if (enabled) {
|
||||||
|
setMuted(false);
|
||||||
|
} else {
|
||||||
|
setMuted(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Audio::setReverb(bool enable) {
|
void Audio::setReverb(bool enable) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
DependencyManager::get<AudioClient>()->setReverb(enable);
|
DependencyManager::get<AudioClient>()->setReverb(enable);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#ifndef hifi_scripting_Audio_h
|
#ifndef hifi_scripting_Audio_h
|
||||||
#define hifi_scripting_Audio_h
|
#define hifi_scripting_Audio_h
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include "AudioScriptingInterface.h"
|
#include "AudioScriptingInterface.h"
|
||||||
#include "AudioDevices.h"
|
#include "AudioDevices.h"
|
||||||
#include "AudioEffectOptions.h"
|
#include "AudioEffectOptions.h"
|
||||||
|
@ -19,6 +20,9 @@
|
||||||
#include "AudioFileWav.h"
|
#include "AudioFileWav.h"
|
||||||
#include <shared/ReadWriteLockable.h>
|
#include <shared/ReadWriteLockable.h>
|
||||||
|
|
||||||
|
using MutedGetter = std::function<bool()>;
|
||||||
|
using MutedSetter = std::function<void(bool)>;
|
||||||
|
|
||||||
namespace scripting {
|
namespace scripting {
|
||||||
|
|
||||||
class Audio : public AudioScriptingInterface, protected ReadWriteLockable {
|
class Audio : public AudioScriptingInterface, protected ReadWriteLockable {
|
||||||
|
@ -37,16 +41,16 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable {
|
||||||
* @hifi-assignment-client
|
* @hifi-assignment-client
|
||||||
*
|
*
|
||||||
* @property {boolean} muted - <code>true</code> if the audio input is muted, otherwise <code>false</code>.
|
* @property {boolean} muted - <code>true</code> if the audio input is muted, otherwise <code>false</code>.
|
||||||
* @property {boolean} noiseReduction - <code>true</code> if noise reduction is enabled, otherwise <code>false</code>. When
|
* @property {boolean} noiseReduction - <code>true</code> if noise reduction is enabled, otherwise <code>false</code>. When
|
||||||
* enabled, the input audio signal is blocked (fully attenuated) when it falls below an adaptive threshold set just
|
* enabled, the input audio signal is blocked (fully attenuated) when it falls below an adaptive threshold set just
|
||||||
* above the noise floor.
|
* above the noise floor.
|
||||||
* @property {number} inputLevel - The loudness of the audio input, range <code>0.0</code> (no sound) –
|
* @property {number} inputLevel - The loudness of the audio input, range <code>0.0</code> (no sound) –
|
||||||
* <code>1.0</code> (the onset of clipping). <em>Read-only.</em>
|
* <code>1.0</code> (the onset of clipping). <em>Read-only.</em>
|
||||||
* @property {boolean} clipping - <code>true</code> if the audio input is clipping, otherwise <code>false</code>.
|
* @property {boolean} clipping - <code>true</code> if the audio input is clipping, otherwise <code>false</code>.
|
||||||
* @property {number} inputVolume - Adjusts the volume of the input audio; range <code>0.0</code> – <code>1.0</code>.
|
* @property {number} inputVolume - Adjusts the volume of the input audio; range <code>0.0</code> – <code>1.0</code>.
|
||||||
* If set to a value, the resulting value depends on the input device: for example, the volume can't be changed on some
|
* If set to a value, the resulting value depends on the input device: for example, the volume can't be changed on some
|
||||||
* devices, and others might only support values of <code>0.0</code> and <code>1.0</code>.
|
* devices, and others might only support values of <code>0.0</code> and <code>1.0</code>.
|
||||||
* @property {boolean} isStereoInput - <code>true</code> if the input audio is being used in stereo, otherwise
|
* @property {boolean} isStereoInput - <code>true</code> if the input audio is being used in stereo, otherwise
|
||||||
* <code>false</code>. Some devices do not support stereo, in which case the value is always <code>false</code>.
|
* <code>false</code>. Some devices do not support stereo, in which case the value is always <code>false</code>.
|
||||||
* @property {string} context - The current context of the audio: either <code>"Desktop"</code> or <code>"HMD"</code>.
|
* @property {string} context - The current context of the audio: either <code>"Desktop"</code> or <code>"HMD"</code>.
|
||||||
* <em>Read-only.</em>
|
* <em>Read-only.</em>
|
||||||
|
@ -58,11 +62,18 @@ class Audio : public AudioScriptingInterface, protected ReadWriteLockable {
|
||||||
|
|
||||||
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
|
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
|
||||||
Q_PROPERTY(bool noiseReduction READ noiseReductionEnabled WRITE enableNoiseReduction NOTIFY noiseReductionChanged)
|
Q_PROPERTY(bool noiseReduction READ noiseReductionEnabled WRITE enableNoiseReduction NOTIFY noiseReductionChanged)
|
||||||
|
Q_PROPERTY(bool warnWhenMuted READ warnWhenMutedEnabled WRITE enableWarnWhenMuted NOTIFY warnWhenMutedChanged)
|
||||||
Q_PROPERTY(float inputVolume READ getInputVolume WRITE setInputVolume NOTIFY inputVolumeChanged)
|
Q_PROPERTY(float inputVolume READ getInputVolume WRITE setInputVolume NOTIFY inputVolumeChanged)
|
||||||
Q_PROPERTY(float inputLevel READ getInputLevel NOTIFY inputLevelChanged)
|
Q_PROPERTY(float inputLevel READ getInputLevel NOTIFY inputLevelChanged)
|
||||||
Q_PROPERTY(bool clipping READ isClipping NOTIFY clippingChanged)
|
Q_PROPERTY(bool clipping READ isClipping NOTIFY clippingChanged)
|
||||||
Q_PROPERTY(QString context READ getContext NOTIFY contextChanged)
|
Q_PROPERTY(QString context READ getContext NOTIFY contextChanged)
|
||||||
Q_PROPERTY(AudioDevices* devices READ getDevices NOTIFY nop)
|
Q_PROPERTY(AudioDevices* devices READ getDevices NOTIFY nop)
|
||||||
|
Q_PROPERTY(bool desktopMuted READ getMutedDesktop WRITE setMutedDesktop NOTIFY desktopMutedChanged)
|
||||||
|
Q_PROPERTY(bool hmdMuted READ getMutedHMD WRITE setMutedHMD NOTIFY hmdMutedChanged)
|
||||||
|
Q_PROPERTY(bool pushToTalk READ getPTT WRITE setPTT NOTIFY pushToTalkChanged);
|
||||||
|
Q_PROPERTY(bool pushToTalkDesktop READ getPTTDesktop WRITE setPTTDesktop NOTIFY pushToTalkDesktopChanged)
|
||||||
|
Q_PROPERTY(bool pushToTalkHMD READ getPTTHMD WRITE setPTTHMD NOTIFY pushToTalkHMDChanged)
|
||||||
|
Q_PROPERTY(bool pushingToTalk READ getPushingToTalk WRITE setPushingToTalk NOTIFY pushingToTalkChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QString AUDIO;
|
static QString AUDIO;
|
||||||
|
@ -75,6 +86,7 @@ public:
|
||||||
|
|
||||||
bool isMuted() const;
|
bool isMuted() const;
|
||||||
bool noiseReductionEnabled() const;
|
bool noiseReductionEnabled() const;
|
||||||
|
bool warnWhenMutedEnabled() const;
|
||||||
float getInputVolume() const;
|
float getInputVolume() const;
|
||||||
float getInputLevel() const;
|
float getInputLevel() const;
|
||||||
bool isClipping() const;
|
bool isClipping() const;
|
||||||
|
@ -82,10 +94,30 @@ public:
|
||||||
|
|
||||||
void showMicMeter(bool show);
|
void showMicMeter(bool show);
|
||||||
|
|
||||||
|
// Mute setting setters and getters
|
||||||
|
void setMutedDesktop(bool isMuted);
|
||||||
|
bool getMutedDesktop() const;
|
||||||
|
void setMutedHMD(bool isMuted);
|
||||||
|
bool getMutedHMD() const;
|
||||||
|
void setPTT(bool enabled);
|
||||||
|
bool getPTT();
|
||||||
|
void setPushingToTalk(bool pushingToTalk);
|
||||||
|
bool getPushingToTalk() const;
|
||||||
|
|
||||||
|
// Push-To-Talk setters and getters
|
||||||
|
void setPTTDesktop(bool enabled);
|
||||||
|
bool getPTTDesktop() const;
|
||||||
|
void setPTTHMD(bool enabled);
|
||||||
|
bool getPTTHMD() const;
|
||||||
|
|
||||||
|
// Settings handlers
|
||||||
|
void saveData();
|
||||||
|
void loadData();
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* @function Audio.setInputDevice
|
* @function Audio.setInputDevice
|
||||||
* @param {object} device
|
* @param {object} device
|
||||||
* @param {boolean} isHMD
|
* @param {boolean} isHMD
|
||||||
* @deprecated This function is deprecated and will be removed.
|
* @deprecated This function is deprecated and will be removed.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void setInputDevice(const QAudioDeviceInfo& device, bool isHMD);
|
Q_INVOKABLE void setInputDevice(const QAudioDeviceInfo& device, bool isHMD);
|
||||||
|
@ -99,8 +131,8 @@ public:
|
||||||
Q_INVOKABLE void setOutputDevice(const QAudioDeviceInfo& device, bool isHMD);
|
Q_INVOKABLE void setOutputDevice(const QAudioDeviceInfo& device, bool isHMD);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Enable or disable reverberation. Reverberation is done by the client, on the post-mix audio. The reverberation options
|
* Enable or disable reverberation. Reverberation is done by the client, on the post-mix audio. The reverberation options
|
||||||
* come from either the domain's audio zone if used — configured on the server — or as scripted by
|
* come from either the domain's audio zone if used — configured on the server — or as scripted by
|
||||||
* {@link Audio.setReverbOptions|setReverbOptions}.
|
* {@link Audio.setReverbOptions|setReverbOptions}.
|
||||||
* @function Audio.setReverb
|
* @function Audio.setReverb
|
||||||
* @param {boolean} enable - <code>true</code> to enable reverberation, <code>false</code> to disable.
|
* @param {boolean} enable - <code>true</code> to enable reverberation, <code>false</code> to disable.
|
||||||
|
@ -110,13 +142,13 @@ public:
|
||||||
* var injectorOptions = {
|
* var injectorOptions = {
|
||||||
* position: MyAvatar.position
|
* position: MyAvatar.position
|
||||||
* };
|
* };
|
||||||
*
|
*
|
||||||
* Script.setTimeout(function () {
|
* Script.setTimeout(function () {
|
||||||
* print("Reverb OFF");
|
* print("Reverb OFF");
|
||||||
* Audio.setReverb(false);
|
* Audio.setReverb(false);
|
||||||
* injector = Audio.playSound(sound, injectorOptions);
|
* injector = Audio.playSound(sound, injectorOptions);
|
||||||
* }, 1000);
|
* }, 1000);
|
||||||
*
|
*
|
||||||
* Script.setTimeout(function () {
|
* Script.setTimeout(function () {
|
||||||
* var reverbOptions = new AudioEffectOptions();
|
* var reverbOptions = new AudioEffectOptions();
|
||||||
* reverbOptions.roomSize = 100;
|
* reverbOptions.roomSize = 100;
|
||||||
|
@ -124,26 +156,26 @@ public:
|
||||||
* print("Reverb ON");
|
* print("Reverb ON");
|
||||||
* Audio.setReverb(true);
|
* Audio.setReverb(true);
|
||||||
* }, 4000);
|
* }, 4000);
|
||||||
*
|
*
|
||||||
* Script.setTimeout(function () {
|
* Script.setTimeout(function () {
|
||||||
* print("Reverb OFF");
|
* print("Reverb OFF");
|
||||||
* Audio.setReverb(false);
|
* Audio.setReverb(false);
|
||||||
* }, 8000); */
|
* }, 8000); */
|
||||||
Q_INVOKABLE void setReverb(bool enable);
|
Q_INVOKABLE void setReverb(bool enable);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Configure reverberation options. Use {@link Audio.setReverb|setReverb} to enable or disable reverberation.
|
* Configure reverberation options. Use {@link Audio.setReverb|setReverb} to enable or disable reverberation.
|
||||||
* @function Audio.setReverbOptions
|
* @function Audio.setReverbOptions
|
||||||
* @param {AudioEffectOptions} options - The reverberation options.
|
* @param {AudioEffectOptions} options - The reverberation options.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void setReverbOptions(const AudioEffectOptions* options);
|
Q_INVOKABLE void setReverbOptions(const AudioEffectOptions* options);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Starts making an audio recording of the audio being played in-world (i.e., not local-only audio) to a file in WAV format.
|
* Starts making an audio recording of the audio being played in-world (i.e., not local-only audio) to a file in WAV format.
|
||||||
* @function Audio.startRecording
|
* @function Audio.startRecording
|
||||||
* @param {string} filename - The path and name of the file to make the recording in. Should have a <code>.wav</code>
|
* @param {string} filename - The path and name of the file to make the recording in. Should have a <code>.wav</code>
|
||||||
* extension. The file is overwritten if it already exists.
|
* extension. The file is overwritten if it already exists.
|
||||||
* @returns {boolean} <code>true</code> if the specified file could be opened and audio recording has started, otherwise
|
* @returns {boolean} <code>true</code> if the specified file could be opened and audio recording has started, otherwise
|
||||||
* <code>false</code>.
|
* <code>false</code>.
|
||||||
* @example <caption>Make a 10 second audio recording.</caption>
|
* @example <caption>Make a 10 second audio recording.</caption>
|
||||||
* var filename = File.getTempDir() + "/audio.wav";
|
* var filename = File.getTempDir() + "/audio.wav";
|
||||||
|
@ -152,13 +184,13 @@ public:
|
||||||
* Audio.stopRecording();
|
* Audio.stopRecording();
|
||||||
* print("Audio recording made in: " + filename);
|
* print("Audio recording made in: " + filename);
|
||||||
* }, 10000);
|
* }, 10000);
|
||||||
*
|
*
|
||||||
* } else {
|
* } else {
|
||||||
* print("Could not make an audio recording in: " + filename);
|
* print("Could not make an audio recording in: " + filename);
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE bool startRecording(const QString& filename);
|
Q_INVOKABLE bool startRecording(const QString& filename);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Finish making an audio recording started with {@link Audio.startRecording|startRecording}.
|
* Finish making an audio recording started with {@link Audio.startRecording|startRecording}.
|
||||||
* @function Audio.stopRecording
|
* @function Audio.stopRecording
|
||||||
|
@ -193,6 +225,46 @@ signals:
|
||||||
*/
|
*/
|
||||||
void mutedChanged(bool isMuted);
|
void mutedChanged(bool isMuted);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when desktop audio input is muted or unmuted.
|
||||||
|
* @function Audio.desktopMutedChanged
|
||||||
|
* @param {boolean} isMuted - <code>true</code> if the audio input is muted for desktop mode, otherwise <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void desktopMutedChanged(bool isMuted);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when HMD audio input is muted or unmuted.
|
||||||
|
* @function Audio.hmdMutedChanged
|
||||||
|
* @param {boolean} isMuted - <code>true</code> if the audio input is muted for HMD mode, otherwise <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void hmdMutedChanged(bool isMuted);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when Push-to-Talk has been enabled or disabled.
|
||||||
|
* @function Audio.pushToTalkChanged
|
||||||
|
* @param {boolean} enabled - <code>true</code> if Push-to-Talk is enabled, otherwise <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void pushToTalkChanged(bool enabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when Push-to-Talk has been enabled or disabled for desktop mode.
|
||||||
|
* @function Audio.pushToTalkDesktopChanged
|
||||||
|
* @param {boolean} enabled - <code>true</code> if Push-to-Talk is emabled for Desktop mode, otherwise <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void pushToTalkDesktopChanged(bool enabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered when Push-to-Talk has been enabled or disabled for HMD mode.
|
||||||
|
* @function Audio.pushToTalkHMDChanged
|
||||||
|
* @param {boolean} enabled - <code>true</code> if Push-to-Talk is emabled for HMD mode, otherwise <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void pushToTalkHMDChanged(bool enabled);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when the audio input noise reduction is enabled or disabled.
|
* Triggered when the audio input noise reduction is enabled or disabled.
|
||||||
* @function Audio.noiseReductionChanged
|
* @function Audio.noiseReductionChanged
|
||||||
|
@ -201,12 +273,20 @@ signals:
|
||||||
*/
|
*/
|
||||||
void noiseReductionChanged(bool isEnabled);
|
void noiseReductionChanged(bool isEnabled);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when "warn when muted" is enabled or disabled.
|
||||||
|
* @function Audio.warnWhenMutedChanged
|
||||||
|
* @param {boolean} isEnabled - <code>true</code> if "warn when muted" is enabled, otherwise <code>false</code>.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void warnWhenMutedChanged(bool isEnabled);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when the input audio volume changes.
|
* Triggered when the input audio volume changes.
|
||||||
* @function Audio.inputVolumeChanged
|
* @function Audio.inputVolumeChanged
|
||||||
* @param {number} volume - The requested volume to be applied to the audio input, range <code>0.0</code> –
|
* @param {number} volume - The requested volume to be applied to the audio input, range <code>0.0</code> –
|
||||||
* <code>1.0</code>. The resulting value of <code>Audio.inputVolume</code> depends on the capabilities of the device:
|
* <code>1.0</code>. The resulting value of <code>Audio.inputVolume</code> depends on the capabilities of the device:
|
||||||
* for example, the volume can't be changed on some devices, and others might only support values of <code>0.0</code>
|
* for example, the volume can't be changed on some devices, and others might only support values of <code>0.0</code>
|
||||||
* and <code>1.0</code>.
|
* and <code>1.0</code>.
|
||||||
* @returns {Signal}
|
* @returns {Signal}
|
||||||
*/
|
*/
|
||||||
|
@ -215,7 +295,7 @@ signals:
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when the input audio level changes.
|
* Triggered when the input audio level changes.
|
||||||
* @function Audio.inputLevelChanged
|
* @function Audio.inputLevelChanged
|
||||||
* @param {number} level - The loudness of the input audio, range <code>0.0</code> (no sound) – <code>1.0</code> (the
|
* @param {number} level - The loudness of the input audio, range <code>0.0</code> (no sound) – <code>1.0</code> (the
|
||||||
* onset of clipping).
|
* onset of clipping).
|
||||||
* @returns {Signal}
|
* @returns {Signal}
|
||||||
*/
|
*/
|
||||||
|
@ -237,6 +317,14 @@ signals:
|
||||||
*/
|
*/
|
||||||
void contextChanged(const QString& context);
|
void contextChanged(const QString& context);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when pushing to talk.
|
||||||
|
* @function Audio.pushingToTalkChanged
|
||||||
|
* @param {boolean} talking - <code>true</code> if broadcasting with PTT, <code>false</code> otherwise.
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void pushingToTalkChanged(bool talking);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
@ -245,9 +333,12 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void onContextChanged();
|
void onContextChanged();
|
||||||
|
|
||||||
|
void handlePushedToTalk(bool enabled);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setMuted(bool muted);
|
void setMuted(bool muted);
|
||||||
void enableNoiseReduction(bool enable);
|
void enableNoiseReduction(bool enable);
|
||||||
|
void enableWarnWhenMuted(bool enable);
|
||||||
void setInputVolume(float volume);
|
void setInputVolume(float volume);
|
||||||
void onInputLoudnessChanged(float loudness, bool isClipping);
|
void onInputLoudnessChanged(float loudness, bool isClipping);
|
||||||
|
|
||||||
|
@ -260,11 +351,20 @@ private:
|
||||||
float _inputVolume { 1.0f };
|
float _inputVolume { 1.0f };
|
||||||
float _inputLevel { 0.0f };
|
float _inputLevel { 0.0f };
|
||||||
bool _isClipping { false };
|
bool _isClipping { false };
|
||||||
bool _isMuted { false };
|
|
||||||
bool _enableNoiseReduction { true }; // Match default value of AudioClient::_isNoiseGateEnabled.
|
bool _enableNoiseReduction { true }; // Match default value of AudioClient::_isNoiseGateEnabled.
|
||||||
|
bool _enableWarnWhenMuted { true };
|
||||||
bool _contextIsHMD { false };
|
bool _contextIsHMD { false };
|
||||||
AudioDevices* getDevices() { return &_devices; }
|
AudioDevices* getDevices() { return &_devices; }
|
||||||
AudioDevices _devices;
|
AudioDevices _devices;
|
||||||
|
Setting::Handle<bool> _desktopMutedSetting{ QStringList { Audio::AUDIO, "desktopMuted" }, true };
|
||||||
|
Setting::Handle<bool> _hmdMutedSetting{ QStringList { Audio::AUDIO, "hmdMuted" }, true };
|
||||||
|
Setting::Handle<bool> _pttDesktopSetting{ QStringList { Audio::AUDIO, "pushToTalkDesktop" }, false };
|
||||||
|
Setting::Handle<bool> _pttHMDSetting{ QStringList { Audio::AUDIO, "pushToTalkHMD" }, false };
|
||||||
|
bool _desktopMuted{ true };
|
||||||
|
bool _hmdMuted{ false };
|
||||||
|
bool _pttDesktop{ false };
|
||||||
|
bool _pttHMD{ false };
|
||||||
|
bool _pushingToTalk{ false };
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -125,8 +125,10 @@ void Stats::updateStats(bool force) {
|
||||||
auto avatarManager = DependencyManager::get<AvatarManager>();
|
auto avatarManager = DependencyManager::get<AvatarManager>();
|
||||||
// we need to take one avatar out so we don't include ourselves
|
// we need to take one avatar out so we don't include ourselves
|
||||||
STAT_UPDATE(avatarCount, avatarManager->size() - 1);
|
STAT_UPDATE(avatarCount, avatarManager->size() - 1);
|
||||||
|
STAT_UPDATE(heroAvatarCount, avatarManager->getNumHeroAvatars());
|
||||||
STAT_UPDATE(physicsObjectCount, qApp->getNumCollisionObjects());
|
STAT_UPDATE(physicsObjectCount, qApp->getNumCollisionObjects());
|
||||||
STAT_UPDATE(updatedAvatarCount, avatarManager->getNumAvatarsUpdated());
|
STAT_UPDATE(updatedAvatarCount, avatarManager->getNumAvatarsUpdated());
|
||||||
|
STAT_UPDATE(updatedHeroAvatarCount, avatarManager->getNumHeroAvatarsUpdated());
|
||||||
STAT_UPDATE(notUpdatedAvatarCount, avatarManager->getNumAvatarsNotUpdated());
|
STAT_UPDATE(notUpdatedAvatarCount, avatarManager->getNumAvatarsNotUpdated());
|
||||||
STAT_UPDATE(serverCount, (int)nodeList->size());
|
STAT_UPDATE(serverCount, (int)nodeList->size());
|
||||||
STAT_UPDATE_FLOAT(renderrate, qApp->getRenderLoopRate(), 0.1f);
|
STAT_UPDATE_FLOAT(renderrate, qApp->getRenderLoopRate(), 0.1f);
|
||||||
|
|
|
@ -49,8 +49,10 @@ private: \
|
||||||
* @property {number} presentdroprate - <em>Read-only.</em>
|
* @property {number} presentdroprate - <em>Read-only.</em>
|
||||||
* @property {number} gameLoopRate - <em>Read-only.</em>
|
* @property {number} gameLoopRate - <em>Read-only.</em>
|
||||||
* @property {number} avatarCount - <em>Read-only.</em>
|
* @property {number} avatarCount - <em>Read-only.</em>
|
||||||
|
* @property {number} heroAvatarCount - <em>Read-only.</em>
|
||||||
* @property {number} physicsObjectCount - <em>Read-only.</em>
|
* @property {number} physicsObjectCount - <em>Read-only.</em>
|
||||||
* @property {number} updatedAvatarCount - <em>Read-only.</em>
|
* @property {number} updatedAvatarCount - <em>Read-only.</em>
|
||||||
|
* @property {number} updatedHeroAvatarCount - <em>Read-only.</em>
|
||||||
* @property {number} notUpdatedAvatarCount - <em>Read-only.</em>
|
* @property {number} notUpdatedAvatarCount - <em>Read-only.</em>
|
||||||
* @property {number} packetInCount - <em>Read-only.</em>
|
* @property {number} packetInCount - <em>Read-only.</em>
|
||||||
* @property {number} packetOutCount - <em>Read-only.</em>
|
* @property {number} packetOutCount - <em>Read-only.</em>
|
||||||
|
@ -203,8 +205,10 @@ class Stats : public QQuickItem {
|
||||||
STATS_PROPERTY(float, presentdroprate, 0)
|
STATS_PROPERTY(float, presentdroprate, 0)
|
||||||
STATS_PROPERTY(int, gameLoopRate, 0)
|
STATS_PROPERTY(int, gameLoopRate, 0)
|
||||||
STATS_PROPERTY(int, avatarCount, 0)
|
STATS_PROPERTY(int, avatarCount, 0)
|
||||||
|
STATS_PROPERTY(int, heroAvatarCount, 0)
|
||||||
STATS_PROPERTY(int, physicsObjectCount, 0)
|
STATS_PROPERTY(int, physicsObjectCount, 0)
|
||||||
STATS_PROPERTY(int, updatedAvatarCount, 0)
|
STATS_PROPERTY(int, updatedAvatarCount, 0)
|
||||||
|
STATS_PROPERTY(int, updatedHeroAvatarCount, 0)
|
||||||
STATS_PROPERTY(int, notUpdatedAvatarCount, 0)
|
STATS_PROPERTY(int, notUpdatedAvatarCount, 0)
|
||||||
STATS_PROPERTY(int, packetInCount, 0)
|
STATS_PROPERTY(int, packetInCount, 0)
|
||||||
STATS_PROPERTY(int, packetOutCount, 0)
|
STATS_PROPERTY(int, packetOutCount, 0)
|
||||||
|
@ -436,6 +440,13 @@ signals:
|
||||||
*/
|
*/
|
||||||
void avatarCountChanged();
|
void avatarCountChanged();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when the value of the <code>heroAvatarCount</code> property changes.
|
||||||
|
* @function Stats.heroAvatarCountChanged
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void heroAvatarCountChanged();
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when the value of the <code>updatedAvatarCount</code> property changes.
|
* Triggered when the value of the <code>updatedAvatarCount</code> property changes.
|
||||||
* @function Stats.updatedAvatarCountChanged
|
* @function Stats.updatedAvatarCountChanged
|
||||||
|
@ -443,6 +454,13 @@ signals:
|
||||||
*/
|
*/
|
||||||
void updatedAvatarCountChanged();
|
void updatedAvatarCountChanged();
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Triggered when the value of the <code>updatedHeroAvatarCount</code> property changes.
|
||||||
|
* @function Stats.updatedHeroAvatarCountChanged
|
||||||
|
* @returns {Signal}
|
||||||
|
*/
|
||||||
|
void updatedHeroAvatarCountChanged();
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when the value of the <code>notUpdatedAvatarCount</code> property changes.
|
* Triggered when the value of the <code>notUpdatedAvatarCount</code> property changes.
|
||||||
* @function Stats.notUpdatedAvatarCountChanged
|
* @function Stats.notUpdatedAvatarCountChanged
|
||||||
|
|
|
@ -1531,6 +1531,15 @@ void AudioClient::setNoiseReduction(bool enable, bool emitSignal) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioClient::setWarnWhenMuted(bool enable, bool emitSignal) {
|
||||||
|
if (_warnWhenMuted != enable) {
|
||||||
|
_warnWhenMuted = enable;
|
||||||
|
if (emitSignal) {
|
||||||
|
emit warnWhenMutedChanged(_warnWhenMuted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool AudioClient::setIsStereoInput(bool isStereoInput) {
|
bool AudioClient::setIsStereoInput(bool isStereoInput) {
|
||||||
bool stereoInputChanged = false;
|
bool stereoInputChanged = false;
|
||||||
if (isStereoInput != _isStereoInput && _inputDeviceInfo.supportedChannelCounts().contains(2)) {
|
if (isStereoInput != _isStereoInput && _inputDeviceInfo.supportedChannelCounts().contains(2)) {
|
||||||
|
|
|
@ -210,6 +210,9 @@ public slots:
|
||||||
void setNoiseReduction(bool isNoiseGateEnabled, bool emitSignal = true);
|
void setNoiseReduction(bool isNoiseGateEnabled, bool emitSignal = true);
|
||||||
bool isNoiseReductionEnabled() const { return _isNoiseGateEnabled; }
|
bool isNoiseReductionEnabled() const { return _isNoiseGateEnabled; }
|
||||||
|
|
||||||
|
void setWarnWhenMuted(bool isNoiseGateEnabled, bool emitSignal = true);
|
||||||
|
bool isWarnWhenMutedEnabled() const { return _warnWhenMuted; }
|
||||||
|
|
||||||
virtual bool getLocalEcho() override { return _shouldEchoLocally; }
|
virtual bool getLocalEcho() override { return _shouldEchoLocally; }
|
||||||
virtual void setLocalEcho(bool localEcho) override { _shouldEchoLocally = localEcho; }
|
virtual void setLocalEcho(bool localEcho) override { _shouldEchoLocally = localEcho; }
|
||||||
virtual void toggleLocalEcho() override { _shouldEchoLocally = !_shouldEchoLocally; }
|
virtual void toggleLocalEcho() override { _shouldEchoLocally = !_shouldEchoLocally; }
|
||||||
|
@ -246,6 +249,7 @@ signals:
|
||||||
void inputVolumeChanged(float volume);
|
void inputVolumeChanged(float volume);
|
||||||
void muteToggled(bool muted);
|
void muteToggled(bool muted);
|
||||||
void noiseReductionChanged(bool noiseReductionEnabled);
|
void noiseReductionChanged(bool noiseReductionEnabled);
|
||||||
|
void warnWhenMutedChanged(bool warnWhenMutedEnabled);
|
||||||
void mutedByMixer();
|
void mutedByMixer();
|
||||||
void inputReceived(const QByteArray& inputSamples);
|
void inputReceived(const QByteArray& inputSamples);
|
||||||
void inputLoudnessChanged(float loudness, bool isClipping);
|
void inputLoudnessChanged(float loudness, bool isClipping);
|
||||||
|
@ -365,6 +369,7 @@ private:
|
||||||
bool _shouldEchoLocally;
|
bool _shouldEchoLocally;
|
||||||
bool _shouldEchoToServer;
|
bool _shouldEchoToServer;
|
||||||
bool _isNoiseGateEnabled;
|
bool _isNoiseGateEnabled;
|
||||||
|
bool _warnWhenMuted;
|
||||||
|
|
||||||
bool _reverb;
|
bool _reverb;
|
||||||
AudioEffectOptions _scriptReverbOptions;
|
AudioEffectOptions _scriptReverbOptions;
|
||||||
|
|
|
@ -564,6 +564,11 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
|
||||||
setAtBit16(flags, COLLIDE_WITH_OTHER_AVATARS);
|
setAtBit16(flags, COLLIDE_WITH_OTHER_AVATARS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Avatar has hero priority
|
||||||
|
if (getHasPriority()) {
|
||||||
|
setAtBit16(flags, HAS_HERO_PRIORITY);
|
||||||
|
}
|
||||||
|
|
||||||
data->flags = flags;
|
data->flags = flags;
|
||||||
destinationBuffer += sizeof(AvatarDataPacket::AdditionalFlags);
|
destinationBuffer += sizeof(AvatarDataPacket::AdditionalFlags);
|
||||||
|
|
||||||
|
@ -1152,7 +1157,8 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
auto newHasProceduralEyeFaceMovement = oneAtBit16(bitItems, PROCEDURAL_EYE_FACE_MOVEMENT);
|
auto newHasProceduralEyeFaceMovement = oneAtBit16(bitItems, PROCEDURAL_EYE_FACE_MOVEMENT);
|
||||||
auto newHasProceduralBlinkFaceMovement = oneAtBit16(bitItems, PROCEDURAL_BLINK_FACE_MOVEMENT);
|
auto newHasProceduralBlinkFaceMovement = oneAtBit16(bitItems, PROCEDURAL_BLINK_FACE_MOVEMENT);
|
||||||
auto newCollideWithOtherAvatars = oneAtBit16(bitItems, COLLIDE_WITH_OTHER_AVATARS);
|
auto newCollideWithOtherAvatars = oneAtBit16(bitItems, COLLIDE_WITH_OTHER_AVATARS);
|
||||||
|
auto newHasPriority = oneAtBit16(bitItems, HAS_HERO_PRIORITY);
|
||||||
|
|
||||||
bool keyStateChanged = (_keyState != newKeyState);
|
bool keyStateChanged = (_keyState != newKeyState);
|
||||||
bool handStateChanged = (_handState != newHandState);
|
bool handStateChanged = (_handState != newHandState);
|
||||||
bool faceStateChanged = (_headData->_isFaceTrackerConnected != newFaceTrackerConnected);
|
bool faceStateChanged = (_headData->_isFaceTrackerConnected != newFaceTrackerConnected);
|
||||||
|
@ -1161,8 +1167,10 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
bool proceduralEyeFaceMovementChanged = (_headData->getHasProceduralEyeFaceMovement() != newHasProceduralEyeFaceMovement);
|
bool proceduralEyeFaceMovementChanged = (_headData->getHasProceduralEyeFaceMovement() != newHasProceduralEyeFaceMovement);
|
||||||
bool proceduralBlinkFaceMovementChanged = (_headData->getHasProceduralBlinkFaceMovement() != newHasProceduralBlinkFaceMovement);
|
bool proceduralBlinkFaceMovementChanged = (_headData->getHasProceduralBlinkFaceMovement() != newHasProceduralBlinkFaceMovement);
|
||||||
bool collideWithOtherAvatarsChanged = (_collideWithOtherAvatars != newCollideWithOtherAvatars);
|
bool collideWithOtherAvatarsChanged = (_collideWithOtherAvatars != newCollideWithOtherAvatars);
|
||||||
|
bool hasPriorityChanged = (getHasPriority() != newHasPriority);
|
||||||
bool somethingChanged = keyStateChanged || handStateChanged || faceStateChanged || eyeStateChanged || audioEnableFaceMovementChanged ||
|
bool somethingChanged = keyStateChanged || handStateChanged || faceStateChanged || eyeStateChanged || audioEnableFaceMovementChanged ||
|
||||||
proceduralEyeFaceMovementChanged || proceduralBlinkFaceMovementChanged || collideWithOtherAvatarsChanged;
|
proceduralEyeFaceMovementChanged ||
|
||||||
|
proceduralBlinkFaceMovementChanged || collideWithOtherAvatarsChanged || hasPriorityChanged;
|
||||||
|
|
||||||
_keyState = newKeyState;
|
_keyState = newKeyState;
|
||||||
_handState = newHandState;
|
_handState = newHandState;
|
||||||
|
@ -1172,6 +1180,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
_headData->setHasProceduralEyeFaceMovement(newHasProceduralEyeFaceMovement);
|
_headData->setHasProceduralEyeFaceMovement(newHasProceduralEyeFaceMovement);
|
||||||
_headData->setHasProceduralBlinkFaceMovement(newHasProceduralBlinkFaceMovement);
|
_headData->setHasProceduralBlinkFaceMovement(newHasProceduralBlinkFaceMovement);
|
||||||
_collideWithOtherAvatars = newCollideWithOtherAvatars;
|
_collideWithOtherAvatars = newCollideWithOtherAvatars;
|
||||||
|
setHasPriorityWithoutTimestampReset(newHasPriority);
|
||||||
|
|
||||||
sourceBuffer += sizeof(AvatarDataPacket::AdditionalFlags);
|
sourceBuffer += sizeof(AvatarDataPacket::AdditionalFlags);
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,9 @@ const quint32 AVATAR_MOTION_SCRIPTABLE_BITS =
|
||||||
// Procedural audio to mouth movement is enabled 8th bit
|
// Procedural audio to mouth movement is enabled 8th bit
|
||||||
// Procedural Blink is enabled 9th bit
|
// Procedural Blink is enabled 9th bit
|
||||||
// Procedural Eyelid is enabled 10th bit
|
// Procedural Eyelid is enabled 10th bit
|
||||||
|
// Procedural PROCEDURAL_BLINK_FACE_MOVEMENT is enabled 11th bit
|
||||||
|
// Procedural Collide with other avatars is enabled 12th bit
|
||||||
|
// Procedural Has Hero Priority is enabled 13th bit
|
||||||
|
|
||||||
const int KEY_STATE_START_BIT = 0; // 1st and 2nd bits
|
const int KEY_STATE_START_BIT = 0; // 1st and 2nd bits
|
||||||
const int HAND_STATE_START_BIT = 2; // 3rd and 4th bits
|
const int HAND_STATE_START_BIT = 2; // 3rd and 4th bits
|
||||||
|
@ -111,7 +114,7 @@ const int AUDIO_ENABLED_FACE_MOVEMENT = 8; // 9th bit
|
||||||
const int PROCEDURAL_EYE_FACE_MOVEMENT = 9; // 10th bit
|
const int PROCEDURAL_EYE_FACE_MOVEMENT = 9; // 10th bit
|
||||||
const int PROCEDURAL_BLINK_FACE_MOVEMENT = 10; // 11th bit
|
const int PROCEDURAL_BLINK_FACE_MOVEMENT = 10; // 11th bit
|
||||||
const int COLLIDE_WITH_OTHER_AVATARS = 11; // 12th bit
|
const int COLLIDE_WITH_OTHER_AVATARS = 11; // 12th bit
|
||||||
|
const int HAS_HERO_PRIORITY = 12; // 13th bit (be scared)
|
||||||
|
|
||||||
const char HAND_STATE_NULL = 0;
|
const char HAND_STATE_NULL = 0;
|
||||||
const char LEFT_HAND_POINTING_FLAG = 1;
|
const char LEFT_HAND_POINTING_FLAG = 1;
|
||||||
|
@ -1121,6 +1124,18 @@ public:
|
||||||
int getAverageBytesReceivedPerSecond() const;
|
int getAverageBytesReceivedPerSecond() const;
|
||||||
int getReceiveRate() const;
|
int getReceiveRate() const;
|
||||||
|
|
||||||
|
// An Avatar can be set Priority from the AvatarMixer side.
|
||||||
|
bool getHasPriority() const { return _hasPriority; }
|
||||||
|
// regular setHasPriority does a check of state changed and if true reset 'additionalFlagsChanged' timestamp
|
||||||
|
void setHasPriority(bool hasPriority) {
|
||||||
|
if (_hasPriority != hasPriority) {
|
||||||
|
_additionalFlagsChanged = usecTimestampNow();
|
||||||
|
_hasPriority = hasPriority;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// In some cases, we want to assign the hasPRiority flag without reseting timestamp
|
||||||
|
void setHasPriorityWithoutTimestampReset(bool hasPriority) { _hasPriority = hasPriority; }
|
||||||
|
|
||||||
const glm::vec3& getTargetVelocity() const { return _targetVelocity; }
|
const glm::vec3& getTargetVelocity() const { return _targetVelocity; }
|
||||||
|
|
||||||
void clearRecordingBasis();
|
void clearRecordingBasis();
|
||||||
|
@ -1498,6 +1513,7 @@ protected:
|
||||||
bool _isNewAvatar { true };
|
bool _isNewAvatar { true };
|
||||||
bool _isClientAvatar { false };
|
bool _isClientAvatar { false };
|
||||||
bool _collideWithOtherAvatars { true };
|
bool _collideWithOtherAvatars { true };
|
||||||
|
bool _hasPriority{ false };
|
||||||
|
|
||||||
// null unless MyAvatar or ScriptableAvatar sending traits data to mixer
|
// null unless MyAvatar or ScriptableAvatar sending traits data to mixer
|
||||||
std::unique_ptr<ClientTraitsHandler, LaterDeleter> _clientTraitsHandler;
|
std::unique_ptr<ClientTraitsHandler, LaterDeleter> _clientTraitsHandler;
|
||||||
|
|
|
@ -180,6 +180,7 @@ namespace controller {
|
||||||
* third person, to full screen mirror, then back to first person and repeat.</td></tr>
|
* third person, to full screen mirror, then back to first person and repeat.</td></tr>
|
||||||
* <tr><td><code>ContextMenu</code></td><td>number</td><td>number</td><td>Show / hide the tablet.</td></tr>
|
* <tr><td><code>ContextMenu</code></td><td>number</td><td>number</td><td>Show / hide the tablet.</td></tr>
|
||||||
* <tr><td><code>ToggleMute</code></td><td>number</td><td>number</td><td>Toggle the microphone mute.</td></tr>
|
* <tr><td><code>ToggleMute</code></td><td>number</td><td>number</td><td>Toggle the microphone mute.</td></tr>
|
||||||
|
* <tr><td><code>TogglePushToTalk</code></td><td>number</td><td>number</td><td>Toggle push to talk.</td></tr>
|
||||||
* <tr><td><code>ToggleOverlay</code></td><td>number</td><td>number</td><td>Toggle the display of overlays.</td></tr>
|
* <tr><td><code>ToggleOverlay</code></td><td>number</td><td>number</td><td>Toggle the display of overlays.</td></tr>
|
||||||
* <tr><td><code>Sprint</code></td><td>number</td><td>number</td><td>Set avatar sprint mode.</td></tr>
|
* <tr><td><code>Sprint</code></td><td>number</td><td>number</td><td>Set avatar sprint mode.</td></tr>
|
||||||
* <tr><td><code>ReticleClick</code></td><td>number</td><td>number</td><td>Set mouse-pressed.</td></tr>
|
* <tr><td><code>ReticleClick</code></td><td>number</td><td>number</td><td>Set mouse-pressed.</td></tr>
|
||||||
|
@ -245,6 +246,8 @@ namespace controller {
|
||||||
* <code>ContextMenu</code> instead.</td></tr>
|
* <code>ContextMenu</code> instead.</td></tr>
|
||||||
* <tr><td><code>TOGGLE_MUTE</code></td><td>number</td><td>number</td><td><strong>Deprecated:</strong> Use
|
* <tr><td><code>TOGGLE_MUTE</code></td><td>number</td><td>number</td><td><strong>Deprecated:</strong> Use
|
||||||
* <code>ToggleMute</code> instead.</td></tr>
|
* <code>ToggleMute</code> instead.</td></tr>
|
||||||
|
* <tr><td><code>TOGGLE_PUSHTOTALK</code></td><td>number</td><td>number</td><td><strong>Deprecated:</strong> Use
|
||||||
|
* <code>TogglePushToTalk</code> instead.</td></tr>
|
||||||
* <tr><td><code>SPRINT</code></td><td>number</td><td>number</td><td><strong>Deprecated:</strong> Use
|
* <tr><td><code>SPRINT</code></td><td>number</td><td>number</td><td><strong>Deprecated:</strong> Use
|
||||||
* <code>Sprint</code> instead.</td></tr>
|
* <code>Sprint</code> instead.</td></tr>
|
||||||
* <tr><td><code>LONGITUDINAL_BACKWARD</code></td><td>number</td><td>number</td><td><strong>Deprecated:</strong> Use
|
* <tr><td><code>LONGITUDINAL_BACKWARD</code></td><td>number</td><td>number</td><td><strong>Deprecated:</strong> Use
|
||||||
|
@ -411,6 +414,7 @@ namespace controller {
|
||||||
makeButtonPair(Action::ACTION2, "SecondaryAction"),
|
makeButtonPair(Action::ACTION2, "SecondaryAction"),
|
||||||
makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"),
|
makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"),
|
||||||
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
|
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
|
||||||
|
makeButtonPair(Action::TOGGLE_PUSHTOTALK, "TogglePushToTalk"),
|
||||||
makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"),
|
makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"),
|
||||||
makeButtonPair(Action::TOGGLE_OVERLAY, "ToggleOverlay"),
|
makeButtonPair(Action::TOGGLE_OVERLAY, "ToggleOverlay"),
|
||||||
makeButtonPair(Action::SPRINT, "Sprint"),
|
makeButtonPair(Action::SPRINT, "Sprint"),
|
||||||
|
|
|
@ -60,6 +60,7 @@ enum class Action {
|
||||||
|
|
||||||
CONTEXT_MENU,
|
CONTEXT_MENU,
|
||||||
TOGGLE_MUTE,
|
TOGGLE_MUTE,
|
||||||
|
TOGGLE_PUSHTOTALK,
|
||||||
CYCLE_CAMERA,
|
CYCLE_CAMERA,
|
||||||
TOGGLE_OVERLAY,
|
TOGGLE_OVERLAY,
|
||||||
|
|
||||||
|
|
|
@ -181,9 +181,11 @@ void RenderableModelEntityItem::updateModelBounds() {
|
||||||
updateRenderItems = true;
|
updateRenderItems = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model->getScaleToFitDimensions() != getScaledDimensions() ||
|
bool overridingModelTransform = model->isOverridingModelTransformAndOffset();
|
||||||
model->getRegistrationPoint() != getRegistrationPoint() ||
|
if (!overridingModelTransform &&
|
||||||
!model->getIsScaledToFit()) {
|
(model->getScaleToFitDimensions() != getScaledDimensions() ||
|
||||||
|
model->getRegistrationPoint() != getRegistrationPoint() ||
|
||||||
|
!model->getIsScaledToFit())) {
|
||||||
// The machinery for updateModelBounds will give existing models the opportunity to fix their
|
// The machinery for updateModelBounds will give existing models the opportunity to fix their
|
||||||
// translation/rotation/scale/registration. The first two are straightforward, but the latter two
|
// translation/rotation/scale/registration. The first two are straightforward, but the latter two
|
||||||
// have guards to make sure they don't happen after they've already been set. Here we reset those guards.
|
// have guards to make sure they don't happen after they've already been set. Here we reset those guards.
|
||||||
|
|
|
@ -1923,25 +1923,19 @@ void EntityItem::setRotation(glm::quat rotation) {
|
||||||
void EntityItem::setVelocity(const glm::vec3& value) {
|
void EntityItem::setVelocity(const glm::vec3& value) {
|
||||||
glm::vec3 velocity = getLocalVelocity();
|
glm::vec3 velocity = getLocalVelocity();
|
||||||
if (velocity != value) {
|
if (velocity != value) {
|
||||||
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
|
float speed = glm::length(value);
|
||||||
if (velocity != Vectors::ZERO) {
|
if (!glm::isnan(speed)) {
|
||||||
setLocalVelocity(Vectors::ZERO);
|
const float MIN_LINEAR_SPEED = 0.001f;
|
||||||
}
|
const float MAX_LINEAR_SPEED = 270.0f; // 3m per step at 90Hz
|
||||||
} else {
|
if (speed < MIN_LINEAR_SPEED) {
|
||||||
float speed = glm::length(value);
|
velocity = ENTITY_ITEM_ZERO_VEC3;
|
||||||
if (!glm::isnan(speed)) {
|
} else if (speed > MAX_LINEAR_SPEED) {
|
||||||
const float MIN_LINEAR_SPEED = 0.001f;
|
velocity = (MAX_LINEAR_SPEED / speed) * value;
|
||||||
const float MAX_LINEAR_SPEED = 270.0f; // 3m per step at 90Hz
|
} else {
|
||||||
if (speed < MIN_LINEAR_SPEED) {
|
velocity = value;
|
||||||
velocity = ENTITY_ITEM_ZERO_VEC3;
|
|
||||||
} else if (speed > MAX_LINEAR_SPEED) {
|
|
||||||
velocity = (MAX_LINEAR_SPEED / speed) * value;
|
|
||||||
} else {
|
|
||||||
velocity = value;
|
|
||||||
}
|
|
||||||
setLocalVelocity(velocity);
|
|
||||||
_flags |= Simulation::DIRTY_LINEAR_VELOCITY;
|
|
||||||
}
|
}
|
||||||
|
setLocalVelocity(velocity);
|
||||||
|
_flags |= Simulation::DIRTY_LINEAR_VELOCITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1959,19 +1953,15 @@ void EntityItem::setDamping(float value) {
|
||||||
void EntityItem::setGravity(const glm::vec3& value) {
|
void EntityItem::setGravity(const glm::vec3& value) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
if (_gravity != value) {
|
if (_gravity != value) {
|
||||||
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
|
float magnitude = glm::length(value);
|
||||||
_gravity = Vectors::ZERO;
|
if (!glm::isnan(magnitude)) {
|
||||||
} else {
|
const float MAX_ACCELERATION_OF_GRAVITY = 10.0f * 9.8f; // 10g
|
||||||
float magnitude = glm::length(value);
|
if (magnitude > MAX_ACCELERATION_OF_GRAVITY) {
|
||||||
if (!glm::isnan(magnitude)) {
|
_gravity = (MAX_ACCELERATION_OF_GRAVITY / magnitude) * value;
|
||||||
const float MAX_ACCELERATION_OF_GRAVITY = 10.0f * 9.8f; // 10g
|
} else {
|
||||||
if (magnitude > MAX_ACCELERATION_OF_GRAVITY) {
|
_gravity = value;
|
||||||
_gravity = (MAX_ACCELERATION_OF_GRAVITY / magnitude) * value;
|
|
||||||
} else {
|
|
||||||
_gravity = value;
|
|
||||||
}
|
|
||||||
_flags |= Simulation::DIRTY_LINEAR_VELOCITY;
|
|
||||||
}
|
}
|
||||||
|
_flags |= Simulation::DIRTY_LINEAR_VELOCITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1980,23 +1970,19 @@ void EntityItem::setGravity(const glm::vec3& value) {
|
||||||
void EntityItem::setAngularVelocity(const glm::vec3& value) {
|
void EntityItem::setAngularVelocity(const glm::vec3& value) {
|
||||||
glm::vec3 angularVelocity = getLocalAngularVelocity();
|
glm::vec3 angularVelocity = getLocalAngularVelocity();
|
||||||
if (angularVelocity != value) {
|
if (angularVelocity != value) {
|
||||||
if (getShapeType() == SHAPE_TYPE_STATIC_MESH) {
|
float speed = glm::length(value);
|
||||||
setLocalAngularVelocity(Vectors::ZERO);
|
if (!glm::isnan(speed)) {
|
||||||
} else {
|
const float MIN_ANGULAR_SPEED = 0.0002f;
|
||||||
float speed = glm::length(value);
|
const float MAX_ANGULAR_SPEED = 9.0f * TWO_PI; // 1/10 rotation per step at 90Hz
|
||||||
if (!glm::isnan(speed)) {
|
if (speed < MIN_ANGULAR_SPEED) {
|
||||||
const float MIN_ANGULAR_SPEED = 0.0002f;
|
angularVelocity = ENTITY_ITEM_ZERO_VEC3;
|
||||||
const float MAX_ANGULAR_SPEED = 9.0f * TWO_PI; // 1/10 rotation per step at 90Hz
|
} else if (speed > MAX_ANGULAR_SPEED) {
|
||||||
if (speed < MIN_ANGULAR_SPEED) {
|
angularVelocity = (MAX_ANGULAR_SPEED / speed) * value;
|
||||||
angularVelocity = ENTITY_ITEM_ZERO_VEC3;
|
} else {
|
||||||
} else if (speed > MAX_ANGULAR_SPEED) {
|
angularVelocity = value;
|
||||||
angularVelocity = (MAX_ANGULAR_SPEED / speed) * value;
|
|
||||||
} else {
|
|
||||||
angularVelocity = value;
|
|
||||||
}
|
|
||||||
setLocalAngularVelocity(angularVelocity);
|
|
||||||
_flags |= Simulation::DIRTY_ANGULAR_VELOCITY;
|
|
||||||
}
|
}
|
||||||
|
setLocalAngularVelocity(angularVelocity);
|
||||||
|
_flags |= Simulation::DIRTY_ANGULAR_VELOCITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,11 +203,6 @@ PhysicsMotionType EntityMotionState::computePhysicsMotionType() const {
|
||||||
}
|
}
|
||||||
assert(entityTreeIsLocked());
|
assert(entityTreeIsLocked());
|
||||||
|
|
||||||
if (_entity->getShapeType() == SHAPE_TYPE_STATIC_MESH
|
|
||||||
|| (_body && _body->getCollisionShape()->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)) {
|
|
||||||
return MOTION_TYPE_STATIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_entity->getLocked()) {
|
if (_entity->getLocked()) {
|
||||||
if (_entity->isMoving()) {
|
if (_entity->isMoving()) {
|
||||||
return MOTION_TYPE_KINEMATIC;
|
return MOTION_TYPE_KINEMATIC;
|
||||||
|
|
|
@ -32,7 +32,8 @@ var DEFAULT_SCRIPTS_COMBINED = [
|
||||||
"system/firstPersonHMD.js",
|
"system/firstPersonHMD.js",
|
||||||
"system/tablet-ui/tabletUI.js",
|
"system/tablet-ui/tabletUI.js",
|
||||||
"system/emote.js",
|
"system/emote.js",
|
||||||
"system/miniTablet.js"
|
"system/miniTablet.js",
|
||||||
|
"system/audioMuteOverlay.js"
|
||||||
];
|
];
|
||||||
var DEFAULT_SCRIPTS_SEPARATE = [
|
var DEFAULT_SCRIPTS_SEPARATE = [
|
||||||
"system/controllers/controllerScripts.js",
|
"system/controllers/controllerScripts.js",
|
||||||
|
|
|
@ -26,9 +26,15 @@ var UNMUTE_ICONS = {
|
||||||
icon: "icons/tablet-icons/mic-unmute-i.svg",
|
icon: "icons/tablet-icons/mic-unmute-i.svg",
|
||||||
activeIcon: "icons/tablet-icons/mic-unmute-a.svg"
|
activeIcon: "icons/tablet-icons/mic-unmute-a.svg"
|
||||||
};
|
};
|
||||||
|
var PTT_ICONS = {
|
||||||
|
icon: "icons/tablet-icons/mic-ptt-i.svg",
|
||||||
|
activeIcon: "icons/tablet-icons/mic-ptt-a.svg"
|
||||||
|
};
|
||||||
|
|
||||||
function onMuteToggled() {
|
function onMuteToggled() {
|
||||||
if (Audio.muted) {
|
if (Audio.pushToTalk) {
|
||||||
|
button.editProperties(PTT_ICONS);
|
||||||
|
} else if (Audio.muted) {
|
||||||
button.editProperties(MUTE_ICONS);
|
button.editProperties(MUTE_ICONS);
|
||||||
} else {
|
} else {
|
||||||
button.editProperties(UNMUTE_ICONS);
|
button.editProperties(UNMUTE_ICONS);
|
||||||
|
@ -57,8 +63,8 @@ function onScreenChanged(type, url) {
|
||||||
|
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
var button = tablet.addButton({
|
var button = tablet.addButton({
|
||||||
icon: Audio.muted ? MUTE_ICONS.icon : UNMUTE_ICONS.icon,
|
icon: Audio.pushToTalk ? PTT_ICONS.icon : Audio.muted ? MUTE_ICONS.icon : UNMUTE_ICONS.icon,
|
||||||
activeIcon: Audio.muted ? MUTE_ICONS.activeIcon : UNMUTE_ICONS.activeIcon,
|
activeIcon: Audio.pushToTalk ? PTT_ICONS.activeIcon : Audio.muted ? MUTE_ICONS.activeIcon : UNMUTE_ICONS.activeIcon,
|
||||||
text: TABLET_BUTTON_NAME,
|
text: TABLET_BUTTON_NAME,
|
||||||
sortOrder: 1
|
sortOrder: 1
|
||||||
});
|
});
|
||||||
|
@ -68,6 +74,7 @@ onMuteToggled();
|
||||||
button.clicked.connect(onClicked);
|
button.clicked.connect(onClicked);
|
||||||
tablet.screenChanged.connect(onScreenChanged);
|
tablet.screenChanged.connect(onScreenChanged);
|
||||||
Audio.mutedChanged.connect(onMuteToggled);
|
Audio.mutedChanged.connect(onMuteToggled);
|
||||||
|
Audio.pushToTalkChanged.connect(onMuteToggled);
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
if (onAudioScreen) {
|
if (onAudioScreen) {
|
||||||
|
@ -76,6 +83,7 @@ Script.scriptEnding.connect(function () {
|
||||||
button.clicked.disconnect(onClicked);
|
button.clicked.disconnect(onClicked);
|
||||||
tablet.screenChanged.disconnect(onScreenChanged);
|
tablet.screenChanged.disconnect(onScreenChanged);
|
||||||
Audio.mutedChanged.disconnect(onMuteToggled);
|
Audio.mutedChanged.disconnect(onMuteToggled);
|
||||||
|
Audio.pushToTalkChanged.disconnect(onMuteToggled);
|
||||||
tablet.removeButton(button);
|
tablet.removeButton(button);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,104 +1,144 @@
|
||||||
"use strict";
|
|
||||||
/* jslint vars: true, plusplus: true, forin: true*/
|
|
||||||
/* globals Tablet, Script, AvatarList, Users, Entities, MyAvatar, Camera, Overlays, Vec3, Quat, Controller, print, getControllerWorldLocation */
|
|
||||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
|
||||||
//
|
//
|
||||||
// audioMuteOverlay.js
|
// audioMuteOverlay.js
|
||||||
//
|
//
|
||||||
// client script that creates an overlay to provide mute feedback
|
// client script that creates an overlay to provide mute feedback
|
||||||
//
|
//
|
||||||
// Created by Triplelexx on 17/03/09
|
// Created by Triplelexx on 17/03/09
|
||||||
|
// Reworked by Seth Alves on 2019-2-17
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
"use strict";
|
||||||
var utilsPath = Script.resolvePath('../developer/libraries/utils.js');
|
|
||||||
Script.include(utilsPath);
|
|
||||||
|
|
||||||
var TWEEN_SPEED = 0.025;
|
/* global Audio, Script, Overlays, Quat, MyAvatar, HMD */
|
||||||
var MIX_AMOUNT = 0.25;
|
|
||||||
|
|
||||||
var overlayPosition = Vec3.ZERO;
|
(function() { // BEGIN LOCAL_SCOPE
|
||||||
var tweenPosition = 0;
|
|
||||||
var startColor = {
|
|
||||||
red: 170,
|
|
||||||
green: 170,
|
|
||||||
blue: 170
|
|
||||||
};
|
|
||||||
var endColor = {
|
|
||||||
red: 255,
|
|
||||||
green: 0,
|
|
||||||
blue: 0
|
|
||||||
};
|
|
||||||
var overlayID;
|
|
||||||
|
|
||||||
Script.update.connect(update);
|
var lastShortTermInputLoudness = 0.0;
|
||||||
Script.scriptEnding.connect(cleanup);
|
var lastLongTermInputLoudness = 0.0;
|
||||||
|
var sampleRate = 8.0; // Hz
|
||||||
|
|
||||||
function update(dt) {
|
var shortTermAttackTC = Math.exp(-1.0 / (sampleRate * 0.500)); // 500 milliseconds attack
|
||||||
if (!Audio.muted) {
|
var shortTermReleaseTC = Math.exp(-1.0 / (sampleRate * 1.000)); // 1000 milliseconds release
|
||||||
if (hasOverlay()) {
|
|
||||||
deleteOverlay();
|
var longTermAttackTC = Math.exp(-1.0 / (sampleRate * 5.0)); // 5 second attack
|
||||||
}
|
var longTermReleaseTC = Math.exp(-1.0 / (sampleRate * 10.0)); // 10 seconds release
|
||||||
} else if (!hasOverlay()) {
|
|
||||||
createOverlay();
|
var activationThreshold = 0.05; // how much louder short-term needs to be than long-term to trigger warning
|
||||||
|
|
||||||
|
var holdReset = 2.0 * sampleRate; // 2 seconds hold
|
||||||
|
var holdCount = 0;
|
||||||
|
var warningOverlayID = null;
|
||||||
|
var pollInterval = null;
|
||||||
|
var warningText = "Muted";
|
||||||
|
|
||||||
|
function showWarning() {
|
||||||
|
if (warningOverlayID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HMD.active) {
|
||||||
|
warningOverlayID = Overlays.addOverlay("text3d", {
|
||||||
|
name: "Muted-Warning",
|
||||||
|
localPosition: { x: 0.0, y: -0.5, z: -1.0 },
|
||||||
|
localOrientation: Quat.fromVec3Degrees({ x: 0.0, y: 0.0, z: 0.0, w: 1.0 }),
|
||||||
|
text: warningText,
|
||||||
|
textAlpha: 1,
|
||||||
|
textColor: { red: 226, green: 51, blue: 77 },
|
||||||
|
backgroundAlpha: 0,
|
||||||
|
lineHeight: 0.042,
|
||||||
|
dimensions: { x: 0.11, y: 0.05 },
|
||||||
|
visible: true,
|
||||||
|
ignoreRayIntersection: true,
|
||||||
|
drawInFront: true,
|
||||||
|
grabbable: false,
|
||||||
|
parentID: MyAvatar.SELF_ID,
|
||||||
|
parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX")
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
updateOverlay();
|
var textDimensions = { x: 100, y: 50 };
|
||||||
|
warningOverlayID = Overlays.addOverlay("text", {
|
||||||
|
name: "Muted-Warning",
|
||||||
|
font: { size: 36 },
|
||||||
|
text: warningText,
|
||||||
|
x: (Window.innerWidth - textDimensions.x) / 2,
|
||||||
|
y: (Window.innerHeight - textDimensions.y),
|
||||||
|
width: textDimensions.x,
|
||||||
|
height: textDimensions.y,
|
||||||
|
textColor: { red: 226, green: 51, blue: 77 },
|
||||||
|
backgroundAlpha: 0,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOffsetPosition() {
|
function hideWarning() {
|
||||||
return Vec3.sum(Camera.position, Quat.getFront(Camera.orientation));
|
if (!warningOverlayID) {
|
||||||
}
|
return;
|
||||||
|
|
||||||
function createOverlay() {
|
|
||||||
overlayPosition = getOffsetPosition();
|
|
||||||
overlayID = Overlays.addOverlay("sphere", {
|
|
||||||
position: overlayPosition,
|
|
||||||
rotation: Camera.orientation,
|
|
||||||
alpha: 0.9,
|
|
||||||
dimensions: 0.1,
|
|
||||||
solid: true,
|
|
||||||
ignoreRayIntersection: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasOverlay() {
|
|
||||||
return Overlays.getProperty(overlayID, "position") !== undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateOverlay() {
|
|
||||||
// increase by TWEEN_SPEED until completion
|
|
||||||
if (tweenPosition < 1) {
|
|
||||||
tweenPosition += TWEEN_SPEED;
|
|
||||||
} else {
|
|
||||||
// after tween completion reset to zero and flip values to ping pong
|
|
||||||
tweenPosition = 0;
|
|
||||||
for (var component in startColor) {
|
|
||||||
var storedColor = startColor[component];
|
|
||||||
startColor[component] = endColor[component];
|
|
||||||
endColor[component] = storedColor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// mix previous position with new and mix colors
|
Overlays.deleteOverlay(warningOverlayID);
|
||||||
overlayPosition = Vec3.mix(overlayPosition, getOffsetPosition(), MIX_AMOUNT);
|
warningOverlayID = null;
|
||||||
Overlays.editOverlay(overlayID, {
|
|
||||||
color: colorMix(startColor, endColor, easeIn(tweenPosition)),
|
|
||||||
position: overlayPosition,
|
|
||||||
rotation: Camera.orientation
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteOverlay() {
|
function startPoll() {
|
||||||
Overlays.deleteOverlay(overlayID);
|
if (pollInterval) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pollInterval = Script.setInterval(function() {
|
||||||
|
var shortTermInputLoudness = Audio.inputLevel;
|
||||||
|
var longTermInputLoudness = shortTermInputLoudness;
|
||||||
|
|
||||||
|
var shortTc = (shortTermInputLoudness > lastShortTermInputLoudness) ? shortTermAttackTC : shortTermReleaseTC;
|
||||||
|
var longTc = (longTermInputLoudness > lastLongTermInputLoudness) ? longTermAttackTC : longTermReleaseTC;
|
||||||
|
|
||||||
|
shortTermInputLoudness += shortTc * (lastShortTermInputLoudness - shortTermInputLoudness);
|
||||||
|
longTermInputLoudness += longTc * (lastLongTermInputLoudness - longTermInputLoudness);
|
||||||
|
|
||||||
|
lastShortTermInputLoudness = shortTermInputLoudness;
|
||||||
|
lastLongTermInputLoudness = longTermInputLoudness;
|
||||||
|
|
||||||
|
if (shortTermInputLoudness > lastLongTermInputLoudness + activationThreshold) {
|
||||||
|
holdCount = holdReset;
|
||||||
|
} else {
|
||||||
|
holdCount = Math.max(holdCount - 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (holdCount > 0) {
|
||||||
|
showWarning();
|
||||||
|
} else {
|
||||||
|
hideWarning();
|
||||||
|
}
|
||||||
|
}, 1000.0 / sampleRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopPoll() {
|
||||||
|
if (!pollInterval) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Script.clearInterval(pollInterval);
|
||||||
|
pollInterval = null;
|
||||||
|
hideWarning();
|
||||||
|
}
|
||||||
|
|
||||||
|
function startOrStopPoll() {
|
||||||
|
if (Audio.warnWhenMuted && Audio.muted) {
|
||||||
|
startPoll();
|
||||||
|
} else {
|
||||||
|
stopPoll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
deleteOverlay();
|
stopPoll();
|
||||||
Audio.muted.disconnect(onMuteToggled);
|
|
||||||
Script.update.disconnect(update);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
|
||||||
|
startOrStopPoll();
|
||||||
|
Audio.mutedChanged.connect(startOrStopPoll);
|
||||||
|
Audio.warnWhenMutedChanged.connect(startOrStopPoll);
|
||||||
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
|
@ -58,6 +58,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
// not set to false (not in use), a module cannot start. When a module is using a slot, that module's name
|
// not set to false (not in use), a module cannot start. When a module is using a slot, that module's name
|
||||||
// is stored as the value, rather than false.
|
// is stored as the value, rather than false.
|
||||||
this.activitySlots = {
|
this.activitySlots = {
|
||||||
|
head: false,
|
||||||
leftHand: false,
|
leftHand: false,
|
||||||
rightHand: false,
|
rightHand: false,
|
||||||
rightHandTrigger: false,
|
rightHandTrigger: false,
|
||||||
|
|
64
scripts/system/controllers/controllerModules/pushToTalk.js
Normal file
64
scripts/system/controllers/controllerModules/pushToTalk.js
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Created by Jason C. Najera on 3/7/2019
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Handles Push-to-Talk functionality for HMD mode.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
Script.include("/~/system/libraries/controllers.js");
|
||||||
|
|
||||||
|
(function() { // BEGIN LOCAL_SCOPE
|
||||||
|
function PushToTalkHandler() {
|
||||||
|
var _this = this;
|
||||||
|
this.active = false;
|
||||||
|
|
||||||
|
this.shouldTalk = function (controllerData) {
|
||||||
|
// Set up test against controllerData here...
|
||||||
|
var gripVal = controllerData.secondaryValues[LEFT_HAND] && controllerData.secondaryValues[RIGHT_HAND];
|
||||||
|
return (gripVal) ? true : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.shouldStopTalking = function (controllerData) {
|
||||||
|
var gripVal = controllerData.secondaryValues[LEFT_HAND] && controllerData.secondaryValues[RIGHT_HAND];
|
||||||
|
return (gripVal) ? false : true;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.isReady = function (controllerData, deltaTime) {
|
||||||
|
if (HMD.active && Audio.pushToTalk && this.shouldTalk(controllerData)) {
|
||||||
|
Audio.pushingToTalk = true;
|
||||||
|
return makeRunningValues(true, [], []);
|
||||||
|
}
|
||||||
|
|
||||||
|
return makeRunningValues(false, [], []);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.run = function (controllerData, deltaTime) {
|
||||||
|
if (this.shouldStopTalking(controllerData) || !Audio.pushToTalk) {
|
||||||
|
Audio.pushingToTalk = false;
|
||||||
|
print("Stop pushing to talk.");
|
||||||
|
return makeRunningValues(false, [], []);
|
||||||
|
}
|
||||||
|
|
||||||
|
return makeRunningValues(true, [], []);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
|
950,
|
||||||
|
["head"],
|
||||||
|
[],
|
||||||
|
100);
|
||||||
|
}
|
||||||
|
|
||||||
|
var pushToTalk = new PushToTalkHandler();
|
||||||
|
enableDispatcherModule("PushToTalk", pushToTalk);
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
disableDispatcherModule("PushToTalk");
|
||||||
|
};
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
}()); // END LOCAL_SCOPE
|
|
@ -33,7 +33,8 @@ var CONTOLLER_SCRIPTS = [
|
||||||
"controllerModules/nearGrabHyperLinkEntity.js",
|
"controllerModules/nearGrabHyperLinkEntity.js",
|
||||||
"controllerModules/nearTabletHighlight.js",
|
"controllerModules/nearTabletHighlight.js",
|
||||||
"controllerModules/nearGrabEntity.js",
|
"controllerModules/nearGrabEntity.js",
|
||||||
"controllerModules/farGrabEntity.js"
|
"controllerModules/farGrabEntity.js",
|
||||||
|
"controllerModules/pushToTalk.js"
|
||||||
];
|
];
|
||||||
|
|
||||||
var DEBUG_MENU_ITEM = "Debug defaultScripts.js";
|
var DEBUG_MENU_ITEM = "Debug defaultScripts.js";
|
||||||
|
|
744
scripts/system/html/js/marketplacesInject.js
Normal file
744
scripts/system/html/js/marketplacesInject.js
Normal file
|
@ -0,0 +1,744 @@
|
||||||
|
/* global $, window, MutationObserver */
|
||||||
|
|
||||||
|
//
|
||||||
|
// marketplacesInject.js
|
||||||
|
//
|
||||||
|
// Created by David Rowe on 12 Nov 2016.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Injected into marketplace Web pages.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
// Event bridge messages.
|
||||||
|
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
||||||
|
var CLARA_IO_STATUS = "CLARA.IO STATUS";
|
||||||
|
var CLARA_IO_CANCEL_DOWNLOAD = "CLARA.IO CANCEL DOWNLOAD";
|
||||||
|
var CLARA_IO_CANCELLED_DOWNLOAD = "CLARA.IO CANCELLED DOWNLOAD";
|
||||||
|
var GOTO_DIRECTORY = "GOTO_DIRECTORY";
|
||||||
|
var GOTO_MARKETPLACE = "GOTO_MARKETPLACE";
|
||||||
|
var QUERY_CAN_WRITE_ASSETS = "QUERY_CAN_WRITE_ASSETS";
|
||||||
|
var CAN_WRITE_ASSETS = "CAN_WRITE_ASSETS";
|
||||||
|
var WARN_USER_NO_PERMISSIONS = "WARN_USER_NO_PERMISSIONS";
|
||||||
|
|
||||||
|
var canWriteAssets = false;
|
||||||
|
var xmlHttpRequest = null;
|
||||||
|
var isPreparing = false; // Explicitly track download request status.
|
||||||
|
|
||||||
|
var limitedCommerce = false;
|
||||||
|
var commerceMode = false;
|
||||||
|
var userIsLoggedIn = false;
|
||||||
|
var walletNeedsSetup = false;
|
||||||
|
var marketplaceBaseURL = "https://highfidelity.com";
|
||||||
|
var messagesWaiting = false;
|
||||||
|
|
||||||
|
function injectCommonCode(isDirectoryPage) {
|
||||||
|
// Supporting styles from marketplaces.css.
|
||||||
|
// Glyph font family, size, and spacing adjusted because HiFi-Glyphs cannot be used cross-domain.
|
||||||
|
$("head").append(
|
||||||
|
'<style>' +
|
||||||
|
'#marketplace-navigation { font-family: Arial, Helvetica, sans-serif; width: 100%; height: 50px; background: #00b4ef; position: fixed; bottom: 0; z-index: 1000; }' +
|
||||||
|
'#marketplace-navigation .glyph { margin-left: 10px; margin-right: 3px; font-family: sans-serif; color: #fff; font-size: 24px; line-height: 50px; }' +
|
||||||
|
'#marketplace-navigation .text { color: #fff; font-size: 16px; line-height: 50px; vertical-align: top; position: relative; top: 1px; }' +
|
||||||
|
'#marketplace-navigation input#back-button { position: absolute; left: 20px; margin-top: 12px; padding-left: 0; padding-right: 5px; }' +
|
||||||
|
'#marketplace-navigation input#all-markets { position: absolute; right: 20px; margin-top: 12px; padding-left: 15px; padding-right: 15px; }' +
|
||||||
|
'#marketplace-navigation .right { position: absolute; right: 20px; }' +
|
||||||
|
'</style>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Supporting styles from edit-style.css.
|
||||||
|
// Font family, size, and position adjusted because Raleway-Bold cannot be used cross-domain.
|
||||||
|
$("head").append(
|
||||||
|
'<style>' +
|
||||||
|
'input[type=button] { font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 12px; text-transform: uppercase; vertical-align: center; height: 28px; min-width: 100px; padding: 0 15px; border-radius: 5px; border: none; color: #fff; background-color: #000; background: linear-gradient(#343434 20%, #000 100%); cursor: pointer; }' +
|
||||||
|
'input[type=button].white { color: #121212; background-color: #afafaf; background: linear-gradient(#fff 20%, #afafaf 100%); }' +
|
||||||
|
'input[type=button].white:enabled:hover { background: linear-gradient(#fff, #fff); border: none; }' +
|
||||||
|
'input[type=button].white:active { background: linear-gradient(#afafaf, #afafaf); }' +
|
||||||
|
'</style>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Footer.
|
||||||
|
var isInitialHiFiPage = location.href === (marketplaceBaseURL + "/marketplace?");
|
||||||
|
$("body").append(
|
||||||
|
'<div id="marketplace-navigation">' +
|
||||||
|
(!isInitialHiFiPage ? '<input id="back-button" type="button" class="white" value="< Back" />' : '') +
|
||||||
|
(isInitialHiFiPage ? '<span class="glyph">🛈</span> <span class="text">Get items from Clara.io!</span>' : '') +
|
||||||
|
(!isDirectoryPage ? '<input id="all-markets" type="button" class="white" value="See All Markets" />' : '') +
|
||||||
|
(isDirectoryPage ? '<span class="right"><span class="glyph">🛈</span> <span class="text">Select a marketplace to explore.</span><span>' : '') +
|
||||||
|
'</div>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Footer actions.
|
||||||
|
$("#back-button").on("click", function () {
|
||||||
|
if (document.referrer !== "") {
|
||||||
|
window.history.back();
|
||||||
|
} else {
|
||||||
|
var params = { type: GOTO_MARKETPLACE };
|
||||||
|
var itemIdMatch = location.search.match(/itemId=([^&]*)/);
|
||||||
|
if (itemIdMatch && itemIdMatch.length === 2) {
|
||||||
|
params.itemId = itemIdMatch[1];
|
||||||
|
}
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify(params));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#all-markets").on("click", function () {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: GOTO_DIRECTORY
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function injectDirectoryCode() {
|
||||||
|
|
||||||
|
// Remove e-mail hyperlink.
|
||||||
|
var letUsKnow = $("#letUsKnow");
|
||||||
|
letUsKnow.replaceWith(letUsKnow.html());
|
||||||
|
|
||||||
|
// Add button links.
|
||||||
|
|
||||||
|
$('#exploreClaraMarketplace').on('click', function () {
|
||||||
|
window.location = "https://clara.io/library?gameCheck=true&public=true";
|
||||||
|
});
|
||||||
|
$('#exploreHifiMarketplace').on('click', function () {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: GOTO_MARKETPLACE
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
emitWalletSetupEvent = function () {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "WALLET_SETUP"
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
function maybeAddSetupWalletButton() {
|
||||||
|
if (!$('body').hasClass("walletsetup-injected") && userIsLoggedIn && walletNeedsSetup) {
|
||||||
|
$('body').addClass("walletsetup-injected");
|
||||||
|
|
||||||
|
var resultsElement = document.getElementById('results');
|
||||||
|
var setupWalletElement = document.createElement('div');
|
||||||
|
setupWalletElement.classList.add("row");
|
||||||
|
setupWalletElement.id = "setupWalletDiv";
|
||||||
|
setupWalletElement.style = "height:60px;margin:20px 10px 10px 10px;padding:12px 5px;" +
|
||||||
|
"background-color:#D6F4D8;border-color:#aee9b2;border-width:2px;border-style:solid;border-radius:5px;";
|
||||||
|
|
||||||
|
var span = document.createElement('span');
|
||||||
|
span.style = "margin:10px 5px;color:#1b6420;font-size:15px;";
|
||||||
|
span.innerHTML = "<a href='#' onclick='emitWalletSetupEvent(); return false;'>Activate your Wallet</a> to get money and shop in Marketplace.";
|
||||||
|
|
||||||
|
var xButton = document.createElement('a');
|
||||||
|
xButton.id = "xButton";
|
||||||
|
xButton.setAttribute('href', "#");
|
||||||
|
xButton.style = "width:50px;height:100%;margin:0;color:#ccc;font-size:20px;";
|
||||||
|
xButton.innerHTML = "X";
|
||||||
|
xButton.onclick = function () {
|
||||||
|
setupWalletElement.remove();
|
||||||
|
dummyRow.remove();
|
||||||
|
};
|
||||||
|
|
||||||
|
setupWalletElement.appendChild(span);
|
||||||
|
setupWalletElement.appendChild(xButton);
|
||||||
|
|
||||||
|
resultsElement.insertBefore(setupWalletElement, resultsElement.firstChild);
|
||||||
|
|
||||||
|
// Dummy row for padding
|
||||||
|
var dummyRow = document.createElement('div');
|
||||||
|
dummyRow.classList.add("row");
|
||||||
|
dummyRow.style = "height:15px;";
|
||||||
|
resultsElement.insertBefore(dummyRow, resultsElement.firstChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function maybeAddLogInButton() {
|
||||||
|
if (!$('body').hasClass("login-injected") && !userIsLoggedIn) {
|
||||||
|
$('body').addClass("login-injected");
|
||||||
|
var resultsElement = document.getElementById('results');
|
||||||
|
if (!resultsElement) { // If we're on the main page, this will evaluate to `true`
|
||||||
|
resultsElement = document.getElementById('item-show');
|
||||||
|
resultsElement.style = 'margin-top:0;';
|
||||||
|
}
|
||||||
|
var logInElement = document.createElement('div');
|
||||||
|
logInElement.classList.add("row");
|
||||||
|
logInElement.id = "logInDiv";
|
||||||
|
logInElement.style = "height:60px;margin:20px 10px 10px 10px;padding:5px;" +
|
||||||
|
"background-color:#D6F4D8;border-color:#aee9b2;border-width:2px;border-style:solid;border-radius:5px;";
|
||||||
|
|
||||||
|
var button = document.createElement('a');
|
||||||
|
button.classList.add("btn");
|
||||||
|
button.classList.add("btn-default");
|
||||||
|
button.id = "logInButton";
|
||||||
|
button.setAttribute('href', "#");
|
||||||
|
button.innerHTML = "LOG IN";
|
||||||
|
button.style = "width:80px;height:100%;margin-top:0;margin-left:10px;padding:13px;font-weight:bold;background:linear-gradient(white, #ccc);";
|
||||||
|
button.onclick = function () {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "LOGIN"
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
var span = document.createElement('span');
|
||||||
|
span.style = "margin:10px;color:#1b6420;font-size:15px;";
|
||||||
|
span.innerHTML = "to get items from the Marketplace.";
|
||||||
|
|
||||||
|
var xButton = document.createElement('a');
|
||||||
|
xButton.id = "xButton";
|
||||||
|
xButton.setAttribute('href', "#");
|
||||||
|
xButton.style = "width:50px;height:100%;margin:0;color:#ccc;font-size:20px;";
|
||||||
|
xButton.innerHTML = "X";
|
||||||
|
xButton.onclick = function () {
|
||||||
|
logInElement.remove();
|
||||||
|
dummyRow.remove();
|
||||||
|
};
|
||||||
|
|
||||||
|
logInElement.appendChild(button);
|
||||||
|
logInElement.appendChild(span);
|
||||||
|
logInElement.appendChild(xButton);
|
||||||
|
|
||||||
|
resultsElement.insertBefore(logInElement, resultsElement.firstChild);
|
||||||
|
|
||||||
|
// Dummy row for padding
|
||||||
|
var dummyRow = document.createElement('div');
|
||||||
|
dummyRow.classList.add("row");
|
||||||
|
dummyRow.style = "height:15px;";
|
||||||
|
resultsElement.insertBefore(dummyRow, resultsElement.firstChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeDropdownMenu() {
|
||||||
|
var logInOrOutButton = document.createElement('a');
|
||||||
|
logInOrOutButton.id = "logInOrOutButton";
|
||||||
|
logInOrOutButton.setAttribute('href', "#");
|
||||||
|
logInOrOutButton.innerHTML = userIsLoggedIn ? "Log Out" : "Log In";
|
||||||
|
logInOrOutButton.onclick = function () {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "LOGIN"
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
$($('.dropdown-menu').find('li')[0]).append(logInOrOutButton);
|
||||||
|
|
||||||
|
$('a[href="/marketplace?view=mine"]').each(function () {
|
||||||
|
$(this).attr('href', '#');
|
||||||
|
$(this).on('click', function () {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "MY_ITEMS"
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function buyButtonClicked(id, referrer, edition) {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "CHECKOUT",
|
||||||
|
itemId: id,
|
||||||
|
referrer: referrer,
|
||||||
|
itemEdition: edition
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function injectBuyButtonOnMainPage() {
|
||||||
|
var cost;
|
||||||
|
|
||||||
|
// Unbind original mouseenter and mouseleave behavior
|
||||||
|
$('body').off('mouseenter', '#price-or-edit .price');
|
||||||
|
$('body').off('mouseleave', '#price-or-edit .price');
|
||||||
|
|
||||||
|
$('.grid-item').find('#price-or-edit').each(function () {
|
||||||
|
$(this).css({ "margin-top": "0" });
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.grid-item').find('#price-or-edit').find('a').each(function() {
|
||||||
|
if ($(this).attr('href') !== '#') { // Guard necessary because of the AJAX nature of Marketplace site
|
||||||
|
$(this).attr('data-href', $(this).attr('href'));
|
||||||
|
$(this).attr('href', '#');
|
||||||
|
}
|
||||||
|
cost = $(this).closest('.col-xs-3').find('.item-cost').text();
|
||||||
|
var costInt = parseInt(cost, 10);
|
||||||
|
|
||||||
|
$(this).closest('.col-xs-3').prev().attr("class", 'col-xs-6');
|
||||||
|
$(this).closest('.col-xs-3').attr("class", 'col-xs-6');
|
||||||
|
|
||||||
|
var priceElement = $(this).find('.price');
|
||||||
|
var available = true;
|
||||||
|
|
||||||
|
if (priceElement.text() === 'invalidated' ||
|
||||||
|
priceElement.text() === 'sold out' ||
|
||||||
|
priceElement.text() === 'not for sale') {
|
||||||
|
available = false;
|
||||||
|
priceElement.css({
|
||||||
|
"padding": "3px 5px 10px 5px",
|
||||||
|
"height": "40px",
|
||||||
|
"background": "linear-gradient(#a2a2a2, #fefefe)",
|
||||||
|
"color": "#000",
|
||||||
|
"font-weight": "600",
|
||||||
|
"line-height": "34px"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
priceElement.css({
|
||||||
|
"padding": "3px 5px",
|
||||||
|
"height": "40px",
|
||||||
|
"background": "linear-gradient(#00b4ef, #0093C5)",
|
||||||
|
"color": "#FFF",
|
||||||
|
"font-weight": "600",
|
||||||
|
"line-height": "34px"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parseInt(cost) > 0) {
|
||||||
|
priceElement.css({ "width": "auto" });
|
||||||
|
|
||||||
|
if (available) {
|
||||||
|
priceElement.html('<span class="hifi-glyph hifi-glyph-hfc" style="filter:invert(1);background-size:20px;' +
|
||||||
|
'width:20px;height:20px;position:relative;top:5px;"></span> ' + cost);
|
||||||
|
}
|
||||||
|
|
||||||
|
priceElement.css({ "min-width": priceElement.width() + 30 });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// change pricing to GET/BUY on button hover
|
||||||
|
$('body').on('mouseenter', '#price-or-edit .price', function () {
|
||||||
|
var $this = $(this);
|
||||||
|
var buyString = "BUY";
|
||||||
|
var getString = "GET";
|
||||||
|
// Protection against the button getting stuck in the "BUY"/"GET" state.
|
||||||
|
// That happens when the browser gets two MOUSEENTER events before getting a
|
||||||
|
// MOUSELEAVE event. Also, if not available for sale, just return.
|
||||||
|
if ($this.text() === buyString ||
|
||||||
|
$this.text() === getString ||
|
||||||
|
$this.text() === 'invalidated' ||
|
||||||
|
$this.text() === 'sold out' ||
|
||||||
|
$this.text() === 'not for sale' ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this.data('initialHtml', $this.html());
|
||||||
|
|
||||||
|
var cost = $(this).parent().siblings().text();
|
||||||
|
if (parseInt(cost) > 0) {
|
||||||
|
$this.text(buyString);
|
||||||
|
}
|
||||||
|
if (parseInt(cost) == 0) {
|
||||||
|
$this.text(getString);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('body').on('mouseleave', '#price-or-edit .price', function () {
|
||||||
|
var $this = $(this);
|
||||||
|
$this.html($this.data('initialHtml'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('.grid-item').find('#price-or-edit').find('a').on('click', function () {
|
||||||
|
var price = $(this).closest('.grid-item').find('.price').text();
|
||||||
|
if (price === 'invalidated' ||
|
||||||
|
price === 'sold out' ||
|
||||||
|
price === 'not for sale') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
buyButtonClicked($(this).closest('.grid-item').attr('data-item-id'),
|
||||||
|
"mainPage",
|
||||||
|
-1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function injectUnfocusOnSearch() {
|
||||||
|
// unfocus input field on search, thus hiding virtual keyboard
|
||||||
|
$('#search-box').on('submit', function () {
|
||||||
|
if (document.activeElement) {
|
||||||
|
document.activeElement.blur();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix for 10108 - marketplace category cannot scroll
|
||||||
|
function injectAddScrollbarToCategories() {
|
||||||
|
$('#categories-dropdown').on('show.bs.dropdown', function () {
|
||||||
|
$('body > div.container').css('display', 'none')
|
||||||
|
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': 'auto', 'height': 'calc(100vh - 110px)' });
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#categories-dropdown').on('hide.bs.dropdown', function () {
|
||||||
|
$('body > div.container').css('display', '');
|
||||||
|
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': '', 'height': '' });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function injectHiFiCode() {
|
||||||
|
if (commerceMode) {
|
||||||
|
maybeAddLogInButton();
|
||||||
|
maybeAddSetupWalletButton();
|
||||||
|
|
||||||
|
if (!$('body').hasClass("code-injected")) {
|
||||||
|
|
||||||
|
$('body').addClass("code-injected");
|
||||||
|
changeDropdownMenu();
|
||||||
|
|
||||||
|
var target = document.getElementById('templated-items');
|
||||||
|
// MutationObserver is necessary because the DOM is populated after the page is loaded.
|
||||||
|
// We're searching for changes to the element whose ID is '#templated-items' - this is
|
||||||
|
// the element that gets filled in by the AJAX.
|
||||||
|
var observer = new MutationObserver(function (mutations) {
|
||||||
|
mutations.forEach(function (mutation) {
|
||||||
|
injectBuyButtonOnMainPage();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
var config = { attributes: true, childList: true, characterData: true };
|
||||||
|
observer.observe(target, config);
|
||||||
|
|
||||||
|
// Try this here in case it works (it will if the user just pressed the "back" button,
|
||||||
|
// since that doesn't trigger another AJAX request.
|
||||||
|
injectBuyButtonOnMainPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
injectUnfocusOnSearch();
|
||||||
|
injectAddScrollbarToCategories();
|
||||||
|
}
|
||||||
|
|
||||||
|
function injectHiFiItemPageCode() {
|
||||||
|
if (commerceMode) {
|
||||||
|
maybeAddLogInButton();
|
||||||
|
|
||||||
|
if (!$('body').hasClass("code-injected")) {
|
||||||
|
|
||||||
|
$('body').addClass("code-injected");
|
||||||
|
changeDropdownMenu();
|
||||||
|
|
||||||
|
var purchaseButton = $('#side-info').find('.btn').first();
|
||||||
|
|
||||||
|
var href = purchaseButton.attr('href');
|
||||||
|
purchaseButton.attr('href', '#');
|
||||||
|
var cost = $('.item-cost').text();
|
||||||
|
var costInt = parseInt(cost, 10);
|
||||||
|
var availability = $.trim($('.item-availability').text());
|
||||||
|
if (limitedCommerce && (costInt > 0)) {
|
||||||
|
availability = '';
|
||||||
|
}
|
||||||
|
if (availability === 'available') {
|
||||||
|
purchaseButton.css({
|
||||||
|
"background": "linear-gradient(#00b4ef, #0093C5)",
|
||||||
|
"color": "#FFF",
|
||||||
|
"font-weight": "600",
|
||||||
|
"padding-bottom": "10px"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
purchaseButton.css({
|
||||||
|
"background": "linear-gradient(#a2a2a2, #fefefe)",
|
||||||
|
"color": "#000",
|
||||||
|
"font-weight": "600",
|
||||||
|
"padding-bottom": "10px"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var type = $('.item-type').text();
|
||||||
|
var isUpdating = window.location.href.indexOf('edition=') > -1;
|
||||||
|
var urlParams = new URLSearchParams(window.location.search);
|
||||||
|
if (isUpdating) {
|
||||||
|
purchaseButton.html('UPDATE FOR FREE');
|
||||||
|
} else if (availability !== 'available') {
|
||||||
|
purchaseButton.html('UNAVAILABLE ' + (availability ? ('(' + availability + ')') : ''));
|
||||||
|
} else if (parseInt(cost) > 0 && $('#side-info').find('#buyItemButton').size() === 0) {
|
||||||
|
purchaseButton.html('PURCHASE <span class="hifi-glyph hifi-glyph-hfc" style="filter:invert(1);background-size:20px;' +
|
||||||
|
'width:20px;height:20px;position:relative;top:5px;"></span> ' + cost);
|
||||||
|
}
|
||||||
|
|
||||||
|
purchaseButton.on('click', function () {
|
||||||
|
if ('available' === availability || isUpdating) {
|
||||||
|
buyButtonClicked(window.location.pathname.split("/")[3],
|
||||||
|
"itemPage",
|
||||||
|
urlParams.get('edition'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
injectUnfocusOnSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateClaraCode() {
|
||||||
|
// Have to repeatedly update Clara page because its content can change dynamically without location.href changing.
|
||||||
|
|
||||||
|
// Clara library page.
|
||||||
|
if (location.href.indexOf("clara.io/library") !== -1) {
|
||||||
|
// Make entries navigate to "Image" view instead of default "Real Time" view.
|
||||||
|
var elements = $("a.thumbnail");
|
||||||
|
for (var i = 0, length = elements.length; i < length; i++) {
|
||||||
|
var value = elements[i].getAttribute("href");
|
||||||
|
if (value.slice(-6) !== "/image") {
|
||||||
|
elements[i].setAttribute("href", value + "/image");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clara item page.
|
||||||
|
if (location.href.indexOf("clara.io/view/") !== -1) {
|
||||||
|
// Make site navigation links retain gameCheck etc. parameters.
|
||||||
|
var element = $("a[href^=\'/library\']")[0];
|
||||||
|
var parameters = "?gameCheck=true&public=true";
|
||||||
|
var href = element.getAttribute("href");
|
||||||
|
if (href.slice(-parameters.length) !== parameters) {
|
||||||
|
element.setAttribute("href", href + parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove unwanted buttons and replace download options with a single "Download to High Fidelity" button.
|
||||||
|
var buttons = $("a.embed-button").parent("div");
|
||||||
|
var downloadFBX;
|
||||||
|
if (buttons.find("div.btn-group").length > 0) {
|
||||||
|
buttons.children(".btn-primary, .btn-group , .embed-button").each(function () { this.remove(); });
|
||||||
|
if ($("#hifi-download-container").length === 0) { // Button hasn't been moved already.
|
||||||
|
downloadFBX = $('<a class="btn btn-primary"><i class=\'glyphicon glyphicon-download-alt\'></i> Download to High Fidelity</a>');
|
||||||
|
buttons.prepend(downloadFBX);
|
||||||
|
downloadFBX[0].addEventListener("click", startAutoDownload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move the "Download to High Fidelity" button to be more visible on tablet.
|
||||||
|
if ($("#hifi-download-container").length === 0 && window.innerWidth < 700) {
|
||||||
|
var downloadContainer = $('<div id="hifi-download-container"></div>');
|
||||||
|
$(".top-title .col-sm-4").append(downloadContainer);
|
||||||
|
downloadContainer.append(downloadFBX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Automatic download to High Fidelity.
|
||||||
|
function startAutoDownload() {
|
||||||
|
// One file request at a time.
|
||||||
|
if (isPreparing) {
|
||||||
|
console.log("WARNING: Clara.io FBX: Prepare only one download at a time");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// User must be able to write to Asset Server.
|
||||||
|
if (!canWriteAssets) {
|
||||||
|
console.log("ERROR: Clara.io FBX: File download cancelled because no permissions to write to Asset Server");
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: WARN_USER_NO_PERMISSIONS
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// User must be logged in.
|
||||||
|
var loginButton = $("#topnav a[href='/signup']");
|
||||||
|
if (loginButton.length > 0) {
|
||||||
|
loginButton[0].click();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain zip file to download for requested asset.
|
||||||
|
// Reference: https://clara.io/learn/sdk/api/export
|
||||||
|
|
||||||
|
//var XMLHTTPREQUEST_URL = "https://clara.io/api/scenes/{uuid}/export/fbx?zip=true¢erScene=true&alignSceneGround=true&fbxUnit=Meter&fbxVersion=7&fbxEmbedTextures=true&imageFormat=WebGL";
|
||||||
|
// 13 Jan 2017: Specify FBX version 5 and remove some options in order to make Clara.io site more likely to
|
||||||
|
// be successful in generating zip files.
|
||||||
|
var XMLHTTPREQUEST_URL = "https://clara.io/api/scenes/{uuid}/export/fbx?fbxUnit=Meter&fbxVersion=5&fbxEmbedTextures=true&imageFormat=WebGL";
|
||||||
|
|
||||||
|
var uuid = location.href.match(/\/view\/([a-z0-9\-]*)/)[1];
|
||||||
|
var url = XMLHTTPREQUEST_URL.replace("{uuid}", uuid);
|
||||||
|
|
||||||
|
xmlHttpRequest = new XMLHttpRequest();
|
||||||
|
var responseTextIndex = 0;
|
||||||
|
var zipFileURL = "";
|
||||||
|
|
||||||
|
xmlHttpRequest.onreadystatechange = function () {
|
||||||
|
// Messages are appended to responseText; process the new ones.
|
||||||
|
var message = this.responseText.slice(responseTextIndex);
|
||||||
|
var statusMessage = "";
|
||||||
|
|
||||||
|
if (isPreparing) { // Ignore messages in flight after finished/cancelled.
|
||||||
|
var lines = message.split(/[\n\r]+/);
|
||||||
|
|
||||||
|
for (var i = 0, length = lines.length; i < length; i++) {
|
||||||
|
if (lines[i].slice(0, 5) === "data:") {
|
||||||
|
// Parse line.
|
||||||
|
var data;
|
||||||
|
try {
|
||||||
|
data = JSON.parse(lines[i].slice(5));
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
data = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract zip file URL.
|
||||||
|
if (data.hasOwnProperty("files") && data.files.length > 0) {
|
||||||
|
zipFileURL = data.files[0].url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statusMessage !== "") {
|
||||||
|
// Update the UI with the most recent status message.
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: CLARA_IO_STATUS,
|
||||||
|
status: statusMessage
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
responseTextIndex = this.responseText.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Note: onprogress doesn't have computable total length so can't use it to determine % complete.
|
||||||
|
|
||||||
|
xmlHttpRequest.onload = function () {
|
||||||
|
var statusMessage = "";
|
||||||
|
|
||||||
|
if (!isPreparing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isPreparing = false;
|
||||||
|
|
||||||
|
var HTTP_OK = 200;
|
||||||
|
if (this.status !== HTTP_OK) {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: CLARA_IO_STATUS,
|
||||||
|
status: statusMessage
|
||||||
|
}));
|
||||||
|
} else if (zipFileURL.slice(-4) !== ".zip") {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: CLARA_IO_STATUS,
|
||||||
|
status: (statusMessage + ": " + zipFileURL)
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: CLARA_IO_DOWNLOAD
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlHttpRequest = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
isPreparing = true;
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: CLARA_IO_STATUS,
|
||||||
|
status: "Initiating download"
|
||||||
|
}));
|
||||||
|
|
||||||
|
xmlHttpRequest.open("POST", url, true);
|
||||||
|
xmlHttpRequest.setRequestHeader("Accept", "text/event-stream");
|
||||||
|
xmlHttpRequest.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function injectClaraCode() {
|
||||||
|
|
||||||
|
// Make space for marketplaces footer in Clara pages.
|
||||||
|
$("head").append(
|
||||||
|
'<style>' +
|
||||||
|
'#app { margin-bottom: 135px; }' +
|
||||||
|
'.footer { bottom: 50px; }' +
|
||||||
|
'</style>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Condense space.
|
||||||
|
$("head").append(
|
||||||
|
'<style>' +
|
||||||
|
'div.page-title { line-height: 1.2; font-size: 13px; }' +
|
||||||
|
'div.page-title-row { padding-bottom: 0; }' +
|
||||||
|
'</style>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Move "Download to High Fidelity" button.
|
||||||
|
$("head").append(
|
||||||
|
'<style>' +
|
||||||
|
'#hifi-download-container { position: absolute; top: 6px; right: 16px; }' +
|
||||||
|
'</style>'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update code injected per page displayed.
|
||||||
|
var updateClaraCodeInterval = undefined;
|
||||||
|
updateClaraCode();
|
||||||
|
updateClaraCodeInterval = setInterval(function () {
|
||||||
|
updateClaraCode();
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
window.addEventListener("unload", function () {
|
||||||
|
clearInterval(updateClaraCodeInterval);
|
||||||
|
updateClaraCodeInterval = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: QUERY_CAN_WRITE_ASSETS
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelClaraDownload() {
|
||||||
|
isPreparing = false;
|
||||||
|
|
||||||
|
if (xmlHttpRequest) {
|
||||||
|
xmlHttpRequest.abort();
|
||||||
|
xmlHttpRequest = null;
|
||||||
|
console.log("Clara.io FBX: File download cancelled");
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: CLARA_IO_CANCELLED_DOWNLOAD
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function injectCode() {
|
||||||
|
var DIRECTORY = 0;
|
||||||
|
var HIFI = 1;
|
||||||
|
var CLARA = 2;
|
||||||
|
var HIFI_ITEM_PAGE = 3;
|
||||||
|
var pageType = DIRECTORY;
|
||||||
|
|
||||||
|
if (location.href.indexOf(marketplaceBaseURL + "/") !== -1) { pageType = HIFI; }
|
||||||
|
if (location.href.indexOf("clara.io/") !== -1) { pageType = CLARA; }
|
||||||
|
if (location.href.indexOf(marketplaceBaseURL + "/marketplace/items/") !== -1) { pageType = HIFI_ITEM_PAGE; }
|
||||||
|
|
||||||
|
injectCommonCode(pageType === DIRECTORY);
|
||||||
|
switch (pageType) {
|
||||||
|
case DIRECTORY:
|
||||||
|
injectDirectoryCode();
|
||||||
|
break;
|
||||||
|
case HIFI:
|
||||||
|
injectHiFiCode();
|
||||||
|
break;
|
||||||
|
case CLARA:
|
||||||
|
injectClaraCode();
|
||||||
|
break;
|
||||||
|
case HIFI_ITEM_PAGE:
|
||||||
|
injectHiFiItemPageCode();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onLoad() {
|
||||||
|
EventBridge.scriptEventReceived.connect(function (message) {
|
||||||
|
message = JSON.parse(message);
|
||||||
|
if (message.type === CAN_WRITE_ASSETS) {
|
||||||
|
canWriteAssets = message.canWriteAssets;
|
||||||
|
} else if (message.type === CLARA_IO_CANCEL_DOWNLOAD) {
|
||||||
|
cancelClaraDownload();
|
||||||
|
} else if (message.type === "marketplaces") {
|
||||||
|
if (message.action === "commerceSetting") {
|
||||||
|
limitedCommerce = !!message.data.limitedCommerce;
|
||||||
|
commerceMode = !!message.data.commerceMode;
|
||||||
|
userIsLoggedIn = !!message.data.userIsLoggedIn;
|
||||||
|
walletNeedsSetup = !!message.data.walletNeedsSetup;
|
||||||
|
marketplaceBaseURL = message.data.metaverseServerURL;
|
||||||
|
if (marketplaceBaseURL.indexOf('metaverse.') !== -1) {
|
||||||
|
marketplaceBaseURL = marketplaceBaseURL.replace('metaverse.', '');
|
||||||
|
}
|
||||||
|
messagesWaiting = message.data.messagesWaiting;
|
||||||
|
injectCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Request commerce setting
|
||||||
|
// Code is injected into the webpage after the setting comes back.
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "REQUEST_SETTING"
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load / unload.
|
||||||
|
window.addEventListener("load", onLoad); // More robust to Web site issues than using $(document).ready().
|
||||||
|
window.addEventListener("page:change", onLoad); // Triggered after Marketplace HTML is changed
|
||||||
|
}());
|
|
@ -5,8 +5,8 @@
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
/* global entityIsCloneable:true, getGrabbableData:true, cloneEntity:true, propsAreCloneDynamic:true, Script,
|
/* global entityIsCloneable:true, cloneEntity:true, propsAreCloneDynamic:true, Script,
|
||||||
propsAreCloneDynamic:true, Entities*/
|
propsAreCloneDynamic:true, Entities, Uuid */
|
||||||
|
|
||||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
|
|
||||||
|
@ -47,13 +47,10 @@ propsAreCloneDynamic = function(props) {
|
||||||
};
|
};
|
||||||
|
|
||||||
cloneEntity = function(props) {
|
cloneEntity = function(props) {
|
||||||
var entityToClone = props.id;
|
var entityIDToClone = props.id;
|
||||||
var props = Entities.getEntityProperties(entityToClone, ['certificateID', 'certificateType'])
|
if (entityIsCloneable(props) &&
|
||||||
var certificateID = props.certificateID;
|
(Uuid.isNull(props.certificateID) || props.certificateType.indexOf('domainUnlimited') >= 0)) {
|
||||||
// ensure entity is cloneable and does not have a certificate ID, whereas cloneable limits
|
var cloneID = Entities.cloneEntity(entityIDToClone);
|
||||||
// will now be handled by the server where the entity add will fail if limit reached
|
|
||||||
if (entityIsCloneable(props) && (!!certificateID || props.certificateType.indexOf('domainUnlimited') >= 0)) {
|
|
||||||
var cloneID = Entities.cloneEntity(entityToClone);
|
|
||||||
return cloneID;
|
return cloneID;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -156,7 +156,9 @@ DISPATCHER_PROPERTIES = [
|
||||||
"grab.equippableIndicatorOffset",
|
"grab.equippableIndicatorOffset",
|
||||||
"userData",
|
"userData",
|
||||||
"avatarEntity",
|
"avatarEntity",
|
||||||
"owningAvatarID"
|
"owningAvatarID",
|
||||||
|
"certificateID",
|
||||||
|
"certificateType"
|
||||||
];
|
];
|
||||||
|
|
||||||
// priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step
|
// priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step
|
||||||
|
|
|
@ -1048,6 +1048,7 @@
|
||||||
// Track grabbed state and item.
|
// Track grabbed state and item.
|
||||||
switch (message.action) {
|
switch (message.action) {
|
||||||
case "grab":
|
case "grab":
|
||||||
|
case "equip":
|
||||||
grabbingHand = HAND_NAMES.indexOf(message.joint);
|
grabbingHand = HAND_NAMES.indexOf(message.joint);
|
||||||
grabbedItem = message.grabbedEntity;
|
grabbedItem = message.grabbedEntity;
|
||||||
break;
|
break;
|
||||||
|
@ -1056,7 +1057,7 @@
|
||||||
grabbedItem = null;
|
grabbedItem = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error("Unexpected grab message!");
|
error("Unexpected grab message: " + JSON.stringify(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,4 +1145,4 @@
|
||||||
setUp();
|
setUp();
|
||||||
Script.scriptEnding.connect(tearDown);
|
Script.scriptEnding.connect(tearDown);
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
Loading…
Reference in a new issue