fixed merge conflict

This commit is contained in:
druiz17 2017-09-13 15:55:04 -07:00
commit 310dbce65d
23 changed files with 1559 additions and 81 deletions

View file

@ -58,6 +58,7 @@ module.exports = {
"RayPick": false,
"LaserPointers": false,
"ContextOverlay": false
"module": false
},
"rules": {
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],

View file

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="225pt"
height="225pt"
viewBox="0 0 79.374998 79.374998"
version="1.1"
id="svg8"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="clap-a.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8"
inkscape:cx="240.0566"
inkscape:cy="147.59313"
inkscape:document-units="mm"
inkscape:current-layer="g3790"
showgrid="false"
inkscape:window-width="2560"
inkscape:window-height="1377"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="true"
units="pt" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-217.62501)">
<g
id="g3790"
transform="translate(-276.67857,-1.5119048)"
style="fill:#000000">
<path
sodipodi:nodetypes="ccscccsccscssscscsscsccc"
inkscape:connector-curvature="0"
id="path3764"
d="m 287.04656,288.04665 23.71378,9.0592 c 0,0 0.39967,-4.79605 4.5296,-6.92762 4.12992,-2.13158 7.40168,-15.99614 7.40168,-15.99614 l 2.5266,-9.92668 4.1934,-9.24819 c 0,0 -1.13082,-3.82467 -4.67519,-0.19524 -8.8408,9.05294 -3.51813,14.25651 -8.14833,14.16202 -3.77977,-0.75596 -0.13245,-10.86933 0.26722,-16.16497 0.26644,-3.06413 0.69941,-12.98928 0.29974,-18.85112 -0.39966,-5.86184 -0.93256,-6.66118 -2.66446,-6.52795 -1.73191,0.13322 -2.93093,0.93257 -4.39638,9.05919 -1.46546,8.12664 -3.33058,15.72038 -3.06414,18.91774 0.26644,3.19737 -4.36307,0.64443 -2.89762,-5.48385 1.46546,-6.12827 4.82299,-19.49577 4.95621,-21.36089 0.13322,-1.86512 -0.52548,-5.99423 -3.45641,-1.46464 -2.93091,4.52961 -8.39307,31.77464 -8.39307,31.77464 0,0 -4.61911,1.35544 4.75249,-29.62183 0.37058,-1.22492 -1.2231,-1.82036 -2.02245,-0.35491 -0.79933,1.46547 -2.93556,6.41177 -3.60169,9.47592 -0.66612,3.06413 -4.12526,18.76747 -5.99039,20.76582 -1.86514,1.99836 -0.77914,-1.64516 2.43172,-19.62594 -3.46015,-8.7099 -7.6029,16.6051 -8.29355,25.75422 -1.73191,11.05755 2.66446,14.65459 2.53124,22.78122 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
sodipodi:nodetypes="ccscsssccccccssc"
inkscape:connector-curvature="0"
id="path3766"
d="m 326.28601,276.79194 4.85752,2.59518 c 0,0 5.99506,0.26645 7.86018,1.19902 1.86513,0.93256 14.52136,-19.31742 14.52136,-19.31742 0,0 -1.59867,-0.39967 -3.19735,-5.32893 -1.59868,-4.92926 -7.59374,-19.98353 -9.45888,-23.44734 -1.86513,-3.46381 -2.53124,-4.66283 -3.4638,-7.46051 -0.93257,-2.7977 -2.13159,-5.0625 -3.73027,-0.13323 -1.59868,4.92927 -1.66343,10.45537 -0.46441,13.91919 1.38613,5.18454 3.8952,15.07683 1.97631,17.7369 -3.13067,-0.0635 -4.1718,-8.94257 -4.84078,-11.98701 l -10.45574,-8.48036 -1.15458,18.13553 c 0,0 3.30736,-4.0697 9.65298,-5.19422 4.51067,-0.79933 2.81751,6.4678 1.21188,14.09965 -1.34794,6.40707 -3.31442,13.66355 -3.31442,13.66355 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0"
id="path3768"
d="m 291.74698,236.36722 c 0,0 -1.36535,-0.56172 -0.0701,-3.22296 1.29528,-2.66125 3.72103,-1.62503 4.12138,-1.41306 -1.04349,0.50764 -3.37926,4.82292 -4.05132,4.63602 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path3770"
d="m 278.60514,277.01718 c 0,0 -0.98806,-8.05217 1.36702,-17.09567 5.11868,-12.29479 -7.76345,3.61446 -1.36702,17.09567 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
<path
inkscape:connector-curvature="0"
id="path3772"
d="m 283.64252,261.72126 c 0,-0.0431 -1.44898,3.96362 -0.80247,9.53246 0.42679,3.67631 0.64575,8.36037 1.90705,11.72782 3.10143,7.14376 -8.41694,-7.43352 -1.10458,-21.26028 z"
style="fill:#000000;stroke:#000000;stroke-width:0.11350404px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="cscc" />
<path
inkscape:connector-curvature="0"
id="path3774"
d="m 318.12446,294.21149 c 0,0 6.68844,-4.71017 9.13772,-13.37686 -5.91279,4.63412 -6.77642,9.57974 -9.13772,13.37686 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
<path
inkscape:connector-curvature="0"
id="path3778"
d="m 344.21877,231.00112 c 0,0 1.60041,9.36884 7.07841,21.7522 5.35526,12.10587 4.05178,-4.80879 -7.07841,-21.7522 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="csc" />
<path
inkscape:connector-curvature="0"
id="path3780"
d="m 349.44951,230.90023 c -0.11119,-0.0477 0.96041,8.99393 4.75948,15.37263 1.48524,4.17497 3.73499,-6.08181 -4.75948,-15.37263 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.3 KiB

View file

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="225pt"
height="225pt"
viewBox="0 0 79.374998 79.374998"
version="1.1"
id="svg8"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="clap-i.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8"
inkscape:cx="240.0566"
inkscape:cy="147.59313"
inkscape:document-units="mm"
inkscape:current-layer="g3790"
showgrid="false"
inkscape:window-width="2560"
inkscape:window-height="1377"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="true"
units="pt" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-217.62501)">
<g
id="g3790"
transform="translate(-276.67857,-1.5119048)"
style="fill:#000000">
<path
sodipodi:nodetypes="ccscccsccscssscscsscsccc"
inkscape:connector-curvature="0"
id="path3764"
d="m 287.04656,288.04665 23.71378,9.0592 c 0,0 0.39967,-4.79605 4.5296,-6.92762 4.12992,-2.13158 7.40168,-15.99614 7.40168,-15.99614 l 2.5266,-9.92668 4.1934,-9.24819 c 0,0 -1.13082,-3.82467 -4.67519,-0.19524 -8.8408,9.05294 -3.51813,14.25651 -8.14833,14.16202 -3.77977,-0.75596 -0.13245,-10.86933 0.26722,-16.16497 0.26644,-3.06413 0.69941,-12.98928 0.29974,-18.85112 -0.39966,-5.86184 -0.93256,-6.66118 -2.66446,-6.52795 -1.73191,0.13322 -2.93093,0.93257 -4.39638,9.05919 -1.46546,8.12664 -3.33058,15.72038 -3.06414,18.91774 0.26644,3.19737 -4.36307,0.64443 -2.89762,-5.48385 1.46546,-6.12827 4.82299,-19.49577 4.95621,-21.36089 0.13322,-1.86512 -0.52548,-5.99423 -3.45641,-1.46464 -2.93091,4.52961 -8.39307,31.77464 -8.39307,31.77464 0,0 -4.61911,1.35544 4.75249,-29.62183 0.37058,-1.22492 -1.2231,-1.82036 -2.02245,-0.35491 -0.79933,1.46547 -2.93556,6.41177 -3.60169,9.47592 -0.66612,3.06413 -4.12526,18.76747 -5.99039,20.76582 -1.86514,1.99836 -0.77914,-1.64516 2.43172,-19.62594 -3.46015,-8.7099 -7.6029,16.6051 -8.29355,25.75422 -1.73191,11.05755 2.66446,14.65459 2.53124,22.78122 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
sodipodi:nodetypes="ccscsssccccccssc"
inkscape:connector-curvature="0"
id="path3766"
d="m 326.28601,276.79194 4.85752,2.59518 c 0,0 5.99506,0.26645 7.86018,1.19902 1.86513,0.93256 14.52136,-19.31742 14.52136,-19.31742 0,0 -1.59867,-0.39967 -3.19735,-5.32893 -1.59868,-4.92926 -7.59374,-19.98353 -9.45888,-23.44734 -1.86513,-3.46381 -2.53124,-4.66283 -3.4638,-7.46051 -0.93257,-2.7977 -2.13159,-5.0625 -3.73027,-0.13323 -1.59868,4.92927 -1.66343,10.45537 -0.46441,13.91919 1.38613,5.18454 3.8952,15.07683 1.97631,17.7369 -3.13067,-0.0635 -4.1718,-8.94257 -4.84078,-11.98701 l -10.45574,-8.48036 -1.15458,18.13553 c 0,0 3.30736,-4.0697 9.65298,-5.19422 4.51067,-0.79933 2.81751,6.4678 1.21188,14.09965 -1.34794,6.40707 -3.31442,13.66355 -3.31442,13.66355 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0"
id="path3768"
d="m 291.74698,236.36722 c 0,0 -1.36535,-0.56172 -0.0701,-3.22296 1.29528,-2.66125 3.72103,-1.62503 4.12138,-1.41306 -1.04349,0.50764 -3.37926,4.82292 -4.05132,4.63602 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path3770"
d="m 278.60514,277.01718 c 0,0 -0.98806,-8.05217 1.36702,-17.09567 5.11868,-12.29479 -7.76345,3.61446 -1.36702,17.09567 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
<path
inkscape:connector-curvature="0"
id="path3772"
d="m 283.64252,261.72126 c 0,-0.0431 -1.44898,3.96362 -0.80247,9.53246 0.42679,3.67631 0.64575,8.36037 1.90705,11.72782 3.10143,7.14376 -8.41694,-7.43352 -1.10458,-21.26028 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.11350404px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="cscc" />
<path
inkscape:connector-curvature="0"
id="path3774"
d="m 318.12446,294.21149 c 0,0 6.68844,-4.71017 9.13772,-13.37686 -5.91279,4.63412 -6.77642,9.57974 -9.13772,13.37686 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
<path
inkscape:connector-curvature="0"
id="path3778"
d="m 344.21877,231.00112 c 0,0 1.60041,9.36884 7.07841,21.7522 5.35526,12.10587 4.05178,-4.80879 -7.07841,-21.7522 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="csc" />
<path
inkscape:connector-curvature="0"
id="path3780"
d="m 349.44951,230.90023 c -0.11119,-0.0477 0.96041,8.99393 4.75948,15.37263 1.48524,4.17497 3.73499,-6.08181 -4.75948,-15.37263 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.3 KiB

View file

@ -18,10 +18,12 @@
#include <PathUtils.h>
#include <OffscreenUi.h>
#include <AccountManager.h>
#include <QFile>
#include <QCryptographicHash>
#include <QQmlContext>
#include <QBuffer>
#include <openssl/ssl.h>
#include <openssl/err.h>
@ -39,7 +41,8 @@
#endif
static const char* KEY_FILE = "hifikey";
static const char* IMAGE_FILE = "hifi_image"; // eventually this will live in keyfile
static const char* IMAGE_HEADER = "-----BEGIN SECURITY IMAGE-----\n";
static const char* IMAGE_FOOTER = "-----END SECURITY IMAGE-----\n";
void initialize() {
static bool initialized = false;
@ -52,11 +55,8 @@ void initialize() {
}
QString keyFilePath() {
return PathUtils::getAppDataFilePath(KEY_FILE);
}
QString imageFilePath() {
return PathUtils::getAppDataFilePath(IMAGE_FILE);
auto accountManager = DependencyManager::get<AccountManager>();
return PathUtils::getAppDataFilePath(QString("%1.%2").arg(accountManager->getAccountInfo().getUsername(), KEY_FILE));
}
// use the cached _passphrase if it exists, otherwise we need to prompt
@ -131,13 +131,12 @@ bool writeKeys(const char* filename, RSA* keys) {
return retval;
}
// BEGIN copied code - this will be removed/changed at some point soon
// copied (without emits for various signals) from libraries/networking/src/RSAKeypairGenerator.cpp.
// We will have a different implementation in practice, but this gives us a start for now
//
// NOTE: we don't really use the private keys returned - we can see how this evolves, but probably
// TODO: we don't really use the private keys returned - we can see how this evolves, but probably
// we should just return a list of public keys?
// or perhaps return the RSA* instead?
QPair<QByteArray*, QByteArray*> generateRSAKeypair() {
RSA* keyPair = RSA_new();
@ -265,6 +264,15 @@ RSA* readPrivateKey(const char* filename) {
return key;
}
// QT's QByteArray will convert to Base64 without any embedded newlines. This just
// writes it with embedded newlines, which is more readable.
void outputBase64WithNewlines(QFile& file, const QByteArray& b64Array) {
for (int i = 0; i < b64Array.size(); i += 64) {
file.write(b64Array.mid(i, 64));
file.write("\n");
}
}
void initializeAESKeys(unsigned char* ivec, unsigned char* ckey, const QByteArray& salt) {
// use the ones in the wallet
auto wallet = DependencyManager::get<Wallet>();
@ -287,8 +295,7 @@ void Wallet::setPassphrase(const QString& passphrase) {
_publicKeys.clear();
}
// encrypt some stuff
bool Wallet::encryptFile(const QString& inputFilePath, const QString& outputFilePath) {
bool Wallet::writeSecurityImage(const QPixmap* pixmap, const QString& outputFilePath) {
// aes requires a couple 128-bit keys (ckey and ivec). For now, I'll just
// use the md5 of the salt as the ckey (md5 is 128-bit), and ivec will be
// a constant. We can review this later - there are ways to generate keys
@ -299,16 +306,12 @@ bool Wallet::encryptFile(const QString& inputFilePath, const QString& outputFile
initializeAESKeys(ivec, ckey, _salt);
int tempSize, outSize;
QByteArray inputFileBuffer;
QBuffer buffer(&inputFileBuffer);
buffer.open(QIODevice::WriteOnly);
// read entire unencrypted file into memory
QFile inputFile(inputFilePath);
if (!inputFile.exists()) {
qCDebug(commerce) << "cannot encrypt" << inputFilePath << "file doesn't exist";
return false;
}
inputFile.open(QIODevice::ReadOnly);
QByteArray inputFileBuffer = inputFile.readAll();
inputFile.close();
// another spot where we are assuming only jpgs
pixmap->save(&buffer, "jpg");
// reserve enough capacity for encrypted bytes
unsigned char* outputFileBuffer = new unsigned char[inputFileBuffer.size() + AES_BLOCK_SIZE];
@ -337,16 +340,21 @@ bool Wallet::encryptFile(const QString& inputFilePath, const QString& outputFile
EVP_CIPHER_CTX_free(ctx);
qCDebug(commerce) << "encrypted buffer size" << outSize;
QByteArray output((const char*)outputFileBuffer, outSize);
// now APPEND to the file,
QByteArray b64output = output.toBase64();
QFile outputFile(outputFilePath);
outputFile.open(QIODevice::WriteOnly);
outputFile.write(output);
outputFile.open(QIODevice::Append);
outputFile.write(IMAGE_HEADER);
outputBase64WithNewlines(outputFile, b64output);
outputFile.write(IMAGE_FOOTER);
outputFile.close();
delete[] outputFileBuffer;
return true;
}
bool Wallet::decryptFile(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferSize) {
bool Wallet::readSecurityImage(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferSize) {
unsigned char ivec[16];
unsigned char ckey[32];
initializeAESKeys(ivec, ckey, _salt);
@ -357,9 +365,31 @@ bool Wallet::decryptFile(const QString& inputFilePath, unsigned char** outputBuf
qCDebug(commerce) << "cannot decrypt file" << inputFilePath << "it doesn't exist";
return false;
}
inputFile.open(QIODevice::ReadOnly);
QByteArray encryptedBuffer = inputFile.readAll();
inputFile.open(QIODevice::ReadOnly | QIODevice::Text);
bool foundHeader = false;
bool foundFooter = false;
QByteArray base64EncryptedBuffer;
while (!inputFile.atEnd()) {
QString line(inputFile.readLine());
if (!foundHeader) {
foundHeader = (line == IMAGE_HEADER);
} else {
foundFooter = (line == IMAGE_FOOTER);
if (!foundFooter) {
base64EncryptedBuffer.append(line);
}
}
}
inputFile.close();
if (! (foundHeader && foundFooter)) {
qCDebug(commerce) << "couldn't parse" << inputFilePath << foundHeader << foundFooter;
return false;
}
// convert to bytes
auto encryptedBuffer = QByteArray::fromBase64(base64EncryptedBuffer);
// setup decrypted buffer
unsigned char* outputBuffer = new unsigned char[encryptedBuffer.size()];
@ -428,6 +458,9 @@ bool Wallet::generateKeyPair() {
qCInfo(commerce) << "Generating keypair.";
auto keyPair = generateRSAKeypair();
// TODO: redo this soon -- need error checking and so on
writeSecurityImage(_securityImage, keyFilePath());
sendKeyFilePathIfExists();
QString oldKey = _publicKeys.count() == 0 ? "" : _publicKeys.last();
QString key = keyPair.first->toBase64();
@ -493,27 +526,30 @@ void Wallet::chooseSecurityImage(const QString& filename) {
if (_securityImage) {
delete _securityImage;
}
// temporary...
QString path = qApp->applicationDirPath();
path.append("/resources/qml/hifi/commerce/wallet/");
path.append(filename);
// now create a new security image pixmap
_securityImage = new QPixmap();
qCDebug(commerce) << "loading data for pixmap from" << path;
_securityImage->load(path);
// encrypt it and save.
if (encryptFile(path, imageFilePath())) {
qCDebug(commerce) << "emitting pixmap";
updateImageProvider();
// update the image now
updateImageProvider();
// we could be choosing the _inital_ security image. If so, there
// will be no hifikey file yet. If that is the case, we are done. If
// there _is_ a keyfile, we need to update it (similar to changing the
// passphrase, we need to do so into a temp file and move it).
if (!QFile(keyFilePath()).exists()) {
emit securityImageResult(true);
} else {
qCDebug(commerce) << "failed to encrypt security image";
emit securityImageResult(false);
return;
}
bool success = writeWallet();
emit securityImageResult(success);
}
void Wallet::getSecurityImage() {
@ -526,10 +562,11 @@ void Wallet::getSecurityImage() {
return;
}
// decrypt and return
QString filePath(imageFilePath());
QFileInfo fileInfo(filePath);
if (fileInfo.exists() && decryptFile(filePath, &data, &dataLen)) {
bool success = false;
// decrypt and return. Don't bother if we have no file to decrypt, or
// no salt set yet.
QFileInfo fileInfo(keyFilePath());
if (fileInfo.exists() && _salt.size() > 0 && readSecurityImage(keyFilePath(), &data, &dataLen)) {
// create the pixmap
_securityImage = new QPixmap();
_securityImage->loadFromData(data, dataLen, "jpg");
@ -538,11 +575,9 @@ void Wallet::getSecurityImage() {
updateImageProvider();
delete[] data;
emit securityImageResult(true);
} else {
qCDebug(commerce) << "failed to decrypt security image (maybe none saved yet?)";
emit securityImageResult(false);
success = true;
}
emit securityImageResult(success);
}
void Wallet::sendKeyFilePathIfExists() {
QString filePath(keyFilePath());
@ -566,35 +601,47 @@ void Wallet::reset() {
QFile keyFile(keyFilePath());
QFile imageFile(imageFilePath());
keyFile.remove();
imageFile.remove();
}
bool Wallet::writeWallet(const QString& newPassphrase) {
RSA* keys = readKeys(keyFilePath().toStdString().c_str());
if (keys) {
// we read successfully, so now write to a new temp file
QString tempFileName = QString("%1.%2").arg(keyFilePath(), QString("temp"));
QString oldPassphrase = *_passphrase;
if (!newPassphrase.isEmpty()) {
setPassphrase(newPassphrase);
}
if (writeKeys(tempFileName.toStdString().c_str(), keys)) {
if (writeSecurityImage(_securityImage, tempFileName)) {
// ok, now move the temp file to the correct spot
QFile(QString(keyFilePath())).remove();
QFile(tempFileName).rename(QString(keyFilePath()));
qCDebug(commerce) << "wallet written successfully";
return true;
} else {
qCDebug(commerce) << "couldn't write security image to temp wallet";
}
} else {
qCDebug(commerce) << "couldn't write keys to temp wallet";
}
// if we are here, we failed, so cleanup
QFile(tempFileName).remove();
if (!newPassphrase.isEmpty()) {
setPassphrase(oldPassphrase);
}
} else {
qCDebug(commerce) << "couldn't read wallet - bad passphrase?";
// TODO: review this, but it seems best to reset the passphrase
// since we couldn't decrypt the existing wallet (or is doesn't
// exist perhaps).
setPassphrase("");
}
return false;
}
bool Wallet::changePassphrase(const QString& newPassphrase) {
qCDebug(commerce) << "changing passphrase";
RSA* keys = readKeys(keyFilePath().toStdString().c_str());
if (keys) {
// we read successfully, so now write to a new temp file
// save old passphrase just in case
// TODO: force re-enter?
QString oldPassphrase = *_passphrase;
setPassphrase(newPassphrase);
QString tempFileName = QString("%1.%2").arg(keyFilePath(), QString("temp"));
if (writeKeys(tempFileName.toStdString().c_str(), keys)) {
// ok, now move the temp file to the correct spot
QFile(QString(keyFilePath())).remove();
QFile(tempFileName).rename(QString(keyFilePath()));
qCDebug(commerce) << "passphrase changed successfully";
return true;
} else {
qCDebug(commerce) << "couldn't write keys";
QFile(tempFileName).remove();
setPassphrase(oldPassphrase);
return false;
}
}
qCDebug(commerce) << "couldn't decrypt keys with current passphrase, clearing";
setPassphrase(QString(""));
return false;
return writeWallet(newPassphrase);
}

View file

@ -55,14 +55,15 @@ signals:
private:
QStringList _publicKeys{};
QPixmap* _securityImage { nullptr };
QByteArray _salt {"iamsalt!"};
QByteArray _salt;
QByteArray _iv;
QByteArray _ckey;
QString* _passphrase { new QString("") };
bool writeWallet(const QString& newPassphrase = QString(""));
void updateImageProvider();
bool encryptFile(const QString& inputFilePath, const QString& outputFilePath);
bool decryptFile(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferLen);
bool writeSecurityImage(const QPixmap* pixmap, const QString& outputFilePath);
bool readSecurityImage(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferLen);
};
#endif // hifi_Wallet_h

View file

@ -909,9 +909,6 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
QVector<JointData> jointsData;
const QVector<FBXAnimationFrame>& frames = _animation->getFramesReference(); // NOTE: getFrames() is too heavy
auto& fbxJoints = _animation->getGeometry().joints;
auto& originalFbxJoints = _model->getFBXGeometry().joints;
bool allowTranslation = entity->getAnimationAllowTranslation();
int frameCount = frames.size();
if (frameCount <= 0) {
return;
@ -946,19 +943,37 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
return;
}
QStringList animationJointNames = _animation->getGeometry().getJointNames();
auto& fbxJoints = _animation->getGeometry().joints;
auto& originalFbxJoints = _model->getFBXGeometry().joints;
auto& originalFbxIndices = _model->getFBXGeometry().jointIndices;
bool allowTranslation = entity->getAnimationAllowTranslation();
const QVector<glm::quat>& rotations = frames[_lastKnownCurrentFrame].rotations;
const QVector<glm::vec3>& translations = frames[_lastKnownCurrentFrame].translations;
jointsData.resize(_jointMapping.size());
for (int j = 0; j < _jointMapping.size(); j++) {
int index = _jointMapping[j];
if (index >= 0) {
glm::mat4 translationMat;
if (!allowTranslation){
translationMat = glm::translate(originalFbxJoints[index].translation);
} else if (index < translations.size()) {
translationMat = glm::translate(translations[index]);
}
if (allowTranslation) {
if(index < translations.size()){
translationMat = glm::translate(translations[index]);
}
} else if (index < animationJointNames.size()){
QString jointName = fbxJoints[index].name; // Pushing this here so its not done on every entity, with the exceptions of those allowing for translation
if (originalFbxIndices.contains(jointName)) {
// Making sure the joint names exist in the original model the animation is trying to apply onto. If they do, then remap and get it's translation.
int remappedIndex = originalFbxIndices[jointName] - 1; // JointIndeces seem to always start from 1 and the found index is always 1 higher than actual.
translationMat = glm::translate(originalFbxJoints[remappedIndex].translation);
}
}
glm::mat4 rotationMat;
if (index < rotations.size()) {
rotationMat = glm::mat4_cast(fbxJoints[index].preRotation * rotations[index] * fbxJoints[index].postRotation);
@ -975,7 +990,6 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
jointData.rotationSet = true;
}
}
// Set the data in the entity
entity->setAnimationJointsData(jointsData);

View file

@ -761,6 +761,7 @@ QScriptValue rayPickResultToScriptValue(QScriptEngine* engine, const RayPickResu
obj.setProperty("distance", rayPickResult.distance);
QScriptValue intersection = vec3toScriptValue(engine, rayPickResult.intersection);
obj.setProperty("intersection", intersection);
obj.setProperty("intersects", rayPickResult.type != NONE);
QScriptValue surfaceNormal = vec3toScriptValue(engine, rayPickResult.surfaceNormal);
obj.setProperty("surfaceNormal", surfaceNormal);
return obj;

View file

@ -51,5 +51,9 @@ QPixmap ImageProvider::requestPixmap(const QString& id, QSize* size, const QSize
return _securityImage->copy();
}
}
return QPixmap();
// otherwise just return a grey pixmap. This avoids annoying error messages in qml we would get
// when sending a 'null' pixmap (QPixmap())
QPixmap greyPixmap(200, 200);
greyPixmap.fill(QColor("darkGrey"));
return greyPixmap;
}

View file

@ -0,0 +1,386 @@
{
"RightShoulder": {
"rotations": {
"x": 0.5578474402427673,
"y": -0.44214877486228943,
"z": 0.4979960322380066,
"w": 0.4952884614467621
}
},
"RightArm": {
"rotations": {
"x": 0.6266362071037292,
"y": -0.02882515825331211,
"z": -0.3233867585659027,
"w": 0.7084611654281616
}
},
"RightForeArm": {
"rotations": {
"x": 0.00004018074105260894,
"y": 0.06418406218290329,
"z": -0.5193823575973511,
"w": 0.8521281480789185
}
},
"RightHand": {
"rotations": {
"x": -0.21368850767612457,
"y": 0.02043931558728218,
"z": -0.02227853797376156,
"w": 0.9764339923858643
}
},
"RightHandPinky1": {
"rotations": {
"x": -0.003497191471979022,
"y": -0.01721140556037426,
"z": 0.19736060500144958,
"w": 0.980173647403717
}
},
"RightHandPinky2": {
"rotations": {
"x": 0.000005483317181642633,
"y": -0.00008023700502235442,
"z": -0.06867633014917374,
"w": 0.997639000415802
}
},
"RightHandPinky3": {
"rotations": {
"x": 7.18885644346301e-8,
"y": -2.7131383717460267e-7,
"z": 0.007620905060321093,
"w": 0.9999709725379944
}
},
"RightHandPinky4": {
"rotations": {
"x": -5.719068774112657e-9,
"y": 5.142213126418937e-7,
"z": -0.0075718737207353115,
"w": 0.999971330165863
}
},
"RightHandRing1": {
"rotations": {
"x": -0.0013452530838549137,
"y": -0.017564140260219574,
"z": 0.0761696845293045,
"w": 0.9969393610954285
}
},
"RightHandRing2": {
"rotations": {
"x": 0.0000010375651982030831,
"y": -0.00002211921673733741,
"z": -0.04599710553884506,
"w": 0.9989416003227234
}
},
"RightHandRing3": {
"rotations": {
"x": -2.7102969868408877e-10,
"y": 1.9202734335976857e-7,
"z": 0.0016911650309339166,
"w": 0.9999985694885254
}
},
"RightHandRing4": {
"rotations": {
"x": 2.3246689018208144e-9,
"y": -3.364403156069784e-8,
"z": 0.0004951066803187132,
"w": 0.9999998807907104
}
},
"RightHandMiddle1": {
"rotations": {
"x": 0.0012630893616005778,
"y": -0.017612185329198837,
"z": -0.07168931514024734,
"w": 0.9972707033157349
}
},
"RightHandMiddle2": {
"rotations": {
"x": 2.3561028683616314e-7,
"y": 0.000020313073036959395,
"z": 0.011195243336260319,
"w": 0.9999373555183411
}
},
"RightHandMiddle3": {
"rotations": {
"x": 6.375214667286855e-8,
"y": 4.750924631480302e-7,
"z": 0.00237679248675704,
"w": 0.9999971985816956
}
},
"RightHandMiddle4": {
"rotations": {
"x": 6.717256439969788e-8,
"y": 3.876683507542111e-8,
"z": -0.005236906465142965,
"w": 0.9999862909317017
}
},
"RightHandIndex1": {
"rotations": {
"x": 0.002164300065487623,
"y": -0.017346171662211418,
"z": -0.12158434838056564,
"w": 0.9924271702766418
}
},
"RightHandIndex2": {
"rotations": {
"x": -0.00000143755482895358,
"y": -0.0001614764187252149,
"z": 0.008941099047660828,
"w": 0.9999601244926453
}
},
"RightHandIndex3": {
"rotations": {
"x": 7.458467621290765e-8,
"y": 5.365728839024086e-7,
"z": 0.03373909369111061,
"w": 0.999430775642395
}
},
"RightHandIndex4": {
"rotations": {
"x": 4.511302997833866e-10,
"y": -2.259726272768603e-7,
"z": -0.009632252156734467,
"w": 0.9999536275863647
}
},
"RightHandThumb1": {
"rotations": {
"x": -0.0783928632736206,
"y": -0.3033908009529114,
"z": -0.26653754711151123,
"w": 0.9114638566970825
}
},
"RightHandThumb2": {
"rotations": {
"x": 0.0031029442325234413,
"y": 0.07382386922836304,
"z": 0.005253761075437069,
"w": 0.9972526431083679
}
},
"RightHandThumb3": {
"rotations": {
"x": 0.0040440745651721954,
"y": -0.04943573474884033,
"z": 0.007246015593409538,
"w": 0.9987428188323975
}
},
"RightHandThumb4": {
"rotations": {
"x": -0.00009280416270485148,
"y": -0.01658034883439541,
"z": -0.00014316302258521318,
"w": 0.999862551689148
}
},
"LeftShoulder": {
"rotations": {
"x": 0.5578474402427673,
"y": 0.44214877486228943,
"z": -0.4979960322380066,
"w": 0.4952884614467621
}
},
"LeftArm": {
"rotations": {
"x": 0.626636266708374,
"y": 0.028824958950281143,
"z": 0.3233867585659027,
"w": 0.7084611654281616
}
},
"LeftForeArm": {
"rotations": {
"x": 0.00004015670492663048,
"y": -0.06418408453464508,
"z": 0.5193824768066406,
"w": 0.8521282076835632
}
},
"LeftHand": {
"rotations": {
"x": -0.21368853747844696,
"y": -0.02043931558728218,
"z": 0.02227853797376156,
"w": 0.9764339923858643
}
},
"LeftHandPinky1": {
"rotations": {
"x": -0.003497188910841942,
"y": 0.01721140556037426,
"z": -0.19736060500144958,
"w": 0.980173647403717
}
},
"LeftHandPinky2": {
"rotations": {
"x": 0.000005479304491018411,
"y": 0.00008023556438274682,
"z": 0.06867631524801254,
"w": 0.997639000415802
}
},
"LeftHandPinky3": {
"rotations": {
"x": 7.229602516645173e-8,
"y": 2.709063835482084e-7,
"z": -0.007620909716933966,
"w": 0.9999709725379944
}
},
"LeftHandPinky4": {
"rotations": {
"x": -5.52988677071653e-9,
"y": -5.13755651354586e-7,
"z": 0.007571868598461151,
"w": 0.999971330165863
}
},
"LeftHandRing1": {
"rotations": {
"x": -0.001345252152532339,
"y": 0.017564138397574425,
"z": -0.0761696845293045,
"w": 0.9969393610954285
}
},
"LeftHandRing2": {
"rotations": {
"x": 0.000001034482806971937,
"y": 0.000022119218556326814,
"z": 0.04599710553884506,
"w": 0.9989416003227234
}
},
"LeftHandRing3": {
"rotations": {
"x": -2.8012464570181805e-10,
"y": -1.923183816643359e-7,
"z": -0.0016911652637645602,
"w": 0.9999985694885254
}
},
"LeftHandRing4": {
"rotations": {
"x": -1.1168596047994583e-9,
"y": 3.33529932561305e-8,
"z": -0.0004951058072037995,
"w": 0.9999998807907104
}
},
"LeftHandMiddle1": {
"rotations": {
"x": 0.0012630895944312215,
"y": 0.01761218160390854,
"z": 0.07168931514024734,
"w": 0.9972707033157349
}
},
"LeftHandMiddle2": {
"rotations": {
"x": 2.37378529277521e-7,
"y": -0.00002031277836067602,
"z": -0.011195233091711998,
"w": 0.9999373555183411
}
},
"LeftHandMiddle3": {
"rotations": {
"x": 7.146466884933034e-8,
"y": -4.7555812443533796e-7,
"z": -0.0023767934180796146,
"w": 0.9999971985816956
}
},
"LeftHandMiddle4": {
"rotations": {
"x": 6.549178976911207e-8,
"y": -3.865041975359418e-8,
"z": 0.005236904136836529,
"w": 0.9999862909317017
}
},
"LeftHandIndex1": {
"rotations": {
"x": 0.002164299599826336,
"y": 0.017346171662211418,
"z": 0.12158433347940445,
"w": 0.9924271702766418
}
},
"LeftHandIndex2": {
"rotations": {
"x": -0.000001437780269952782,
"y": 0.00016147761198226362,
"z": -0.008941099047660828,
"w": 0.9999601244926453
}
},
"LeftHandIndex3": {
"rotations": {
"x": 7.61426193207626e-8,
"y": -5.373883027459669e-7,
"z": -0.03373908996582031,
"w": 0.999430775642395
}
},
"LeftHandIndex4": {
"rotations": {
"x": -5.311697748311417e-10,
"y": 2.26380109324964e-7,
"z": 0.009632255882024765,
"w": 0.9999536275863647
}
},
"LeftHandThumb1": {
"rotations": {
"x": -0.07839284837245941,
"y": 0.3033908009529114,
"z": 0.26653754711151123,
"w": 0.9114638566970825
}
},
"LeftHandThumb2": {
"rotations": {
"x": 0.0031029372476041317,
"y": -0.07382386922836304,
"z": -0.005253763869404793,
"w": 0.9972526431083679
}
},
"LeftHandThumb3": {
"rotations": {
"x": 0.004044072702527046,
"y": 0.049435727298259735,
"z": -0.0072460174560546875,
"w": 0.9987428188323975
}
},
"LeftHandThumb4": {
"rotations": {
"x": -0.00009280881931772456,
"y": 0.016580356284976006,
"z": 0.00014314628788270056,
"w": 0.999862551689148
}
}
}

View file

@ -0,0 +1,61 @@
"use strict";
/*
clapApp.js
unpublishedScripts/marketplace/clap/clapApp.js
Created by Matti 'Menithal' Lahtinen on 9/11/2017
Copyright 2017 High Fidelity, Inc.
Distributed under the Apache License, Version 2.0.
See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
*/
// Entry Script for the clap app
// Load up engine
var APP_NAME = "CLAP";
var ClapEngine = Script.require(Script.resolvePath("scripts/ClapEngine.js?v9"));
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
// Define Menu
var blackIcon = Script.resolvePath("icons/tablet-icons/clap-a.svg?foxv2");
var whiteIcon = Script.resolvePath("icons/tablet-icons/clap-i.svg?foxv2");
if (Settings.getValue("clapAppEnabled") === undefined) {
Settings.setValue("clapAppEnabled", true);
}
var isActive = Settings.getValue("clapAppEnabled");
var activeButton = tablet.addButton({
icon: whiteIcon,
activeIcon: blackIcon,
text: APP_NAME,
isActive: isActive,
sortOrder: 11
});
if (isActive) {
ClapEngine.connectEngine();
}
function onClick(enabled) {
isActive = !isActive;
Settings.setValue("clapAppEnabled", isActive);
activeButton.editProperties({
isActive: isActive
});
if (isActive) {
ClapEngine.connectEngine();
} else {
ClapEngine.disconnectEngine();
}
}
activeButton.clicked.connect(onClick);
Script.scriptEnding.connect(function () {
ClapEngine.disconnectEngine();
activeButton.clicked.disconnect(onClick);
tablet.removeButton(activeButton);
});

View file

@ -0,0 +1,58 @@
{
"alpha": 0.01,
"alphaFinish": 0.0,
"alphaSpread": 1,
"alphaStart": 0.05,
"color": {
"blue": 200,
"green": 200,
"red": 200
},
"colorFinish": {
"blue": 200,
"green": 200,
"red": 200
},
"colorStart": {
"blue": 200,
"green": 200,
"red": 200
},
"created": "2017-09-09T16:01:38Z",
"dimensions": {
"x": 0.5,
"y": 0.5,
"z": 0.5
},
"emitAcceleration": {
"x": 0,
"y": 0,
"z": 0
},
"emitDimensions": {
"x": 0.25,
"y": 0.25,
"z": 0.25
},
"emitOrientation": {
"w": 1,
"x": 0,
"y": 0,
"z": 0
},
"emitRate": 100,
"emitSpeed": 0.125,
"lifespan": 0.5,
"lifetime": 2,
"script": "(function(){return{preload:function(id){Script.setTimeout(function(){Entities.editEntity(id,{isEmitting:false});},200);}}})",
"maxParticles": 100,
"particleRadius": 0.05,
"polarFinish": 1.4311699867248535,
"polarStart": 1.3962633609771729,
"radiusFinish": 0.01,
"radiusSpread": 0.2,
"radiusStart": 0.05,
"speedSpread": 0,
"emitShouldTrail": true,
"type": "ParticleEffect"
}

View file

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="225pt"
height="225pt"
viewBox="0 0 79.374998 79.374998"
version="1.1"
id="svg8"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="clap-a.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8"
inkscape:cx="240.0566"
inkscape:cy="147.59313"
inkscape:document-units="mm"
inkscape:current-layer="g3790"
showgrid="false"
inkscape:window-width="2560"
inkscape:window-height="1377"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="true"
units="pt" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-217.62501)">
<g
id="g3790"
transform="translate(-276.67857,-1.5119048)"
style="fill:#000000">
<path
sodipodi:nodetypes="ccscccsccscssscscsscsccc"
inkscape:connector-curvature="0"
id="path3764"
d="m 287.04656,288.04665 23.71378,9.0592 c 0,0 0.39967,-4.79605 4.5296,-6.92762 4.12992,-2.13158 7.40168,-15.99614 7.40168,-15.99614 l 2.5266,-9.92668 4.1934,-9.24819 c 0,0 -1.13082,-3.82467 -4.67519,-0.19524 -8.8408,9.05294 -3.51813,14.25651 -8.14833,14.16202 -3.77977,-0.75596 -0.13245,-10.86933 0.26722,-16.16497 0.26644,-3.06413 0.69941,-12.98928 0.29974,-18.85112 -0.39966,-5.86184 -0.93256,-6.66118 -2.66446,-6.52795 -1.73191,0.13322 -2.93093,0.93257 -4.39638,9.05919 -1.46546,8.12664 -3.33058,15.72038 -3.06414,18.91774 0.26644,3.19737 -4.36307,0.64443 -2.89762,-5.48385 1.46546,-6.12827 4.82299,-19.49577 4.95621,-21.36089 0.13322,-1.86512 -0.52548,-5.99423 -3.45641,-1.46464 -2.93091,4.52961 -8.39307,31.77464 -8.39307,31.77464 0,0 -4.61911,1.35544 4.75249,-29.62183 0.37058,-1.22492 -1.2231,-1.82036 -2.02245,-0.35491 -0.79933,1.46547 -2.93556,6.41177 -3.60169,9.47592 -0.66612,3.06413 -4.12526,18.76747 -5.99039,20.76582 -1.86514,1.99836 -0.77914,-1.64516 2.43172,-19.62594 -3.46015,-8.7099 -7.6029,16.6051 -8.29355,25.75422 -1.73191,11.05755 2.66446,14.65459 2.53124,22.78122 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
sodipodi:nodetypes="ccscsssccccccssc"
inkscape:connector-curvature="0"
id="path3766"
d="m 326.28601,276.79194 4.85752,2.59518 c 0,0 5.99506,0.26645 7.86018,1.19902 1.86513,0.93256 14.52136,-19.31742 14.52136,-19.31742 0,0 -1.59867,-0.39967 -3.19735,-5.32893 -1.59868,-4.92926 -7.59374,-19.98353 -9.45888,-23.44734 -1.86513,-3.46381 -2.53124,-4.66283 -3.4638,-7.46051 -0.93257,-2.7977 -2.13159,-5.0625 -3.73027,-0.13323 -1.59868,4.92927 -1.66343,10.45537 -0.46441,13.91919 1.38613,5.18454 3.8952,15.07683 1.97631,17.7369 -3.13067,-0.0635 -4.1718,-8.94257 -4.84078,-11.98701 l -10.45574,-8.48036 -1.15458,18.13553 c 0,0 3.30736,-4.0697 9.65298,-5.19422 4.51067,-0.79933 2.81751,6.4678 1.21188,14.09965 -1.34794,6.40707 -3.31442,13.66355 -3.31442,13.66355 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0"
id="path3768"
d="m 291.74698,236.36722 c 0,0 -1.36535,-0.56172 -0.0701,-3.22296 1.29528,-2.66125 3.72103,-1.62503 4.12138,-1.41306 -1.04349,0.50764 -3.37926,4.82292 -4.05132,4.63602 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path3770"
d="m 278.60514,277.01718 c 0,0 -0.98806,-8.05217 1.36702,-17.09567 5.11868,-12.29479 -7.76345,3.61446 -1.36702,17.09567 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
<path
inkscape:connector-curvature="0"
id="path3772"
d="m 283.64252,261.72126 c 0,-0.0431 -1.44898,3.96362 -0.80247,9.53246 0.42679,3.67631 0.64575,8.36037 1.90705,11.72782 3.10143,7.14376 -8.41694,-7.43352 -1.10458,-21.26028 z"
style="fill:#000000;stroke:#000000;stroke-width:0.11350404px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="cscc" />
<path
inkscape:connector-curvature="0"
id="path3774"
d="m 318.12446,294.21149 c 0,0 6.68844,-4.71017 9.13772,-13.37686 -5.91279,4.63412 -6.77642,9.57974 -9.13772,13.37686 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
<path
inkscape:connector-curvature="0"
id="path3778"
d="m 344.21877,231.00112 c 0,0 1.60041,9.36884 7.07841,21.7522 5.35526,12.10587 4.05178,-4.80879 -7.07841,-21.7522 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="csc" />
<path
inkscape:connector-curvature="0"
id="path3780"
d="m 349.44951,230.90023 c -0.11119,-0.0477 0.96041,8.99393 4.75948,15.37263 1.48524,4.17497 3.73499,-6.08181 -4.75948,-15.37263 z"
style="fill:#000000;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.3 KiB

View file

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="225pt"
height="225pt"
viewBox="0 0 79.374998 79.374998"
version="1.1"
id="svg8"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="clap-i.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8"
inkscape:cx="240.0566"
inkscape:cy="147.59313"
inkscape:document-units="mm"
inkscape:current-layer="g3790"
showgrid="false"
inkscape:window-width="2560"
inkscape:window-height="1377"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="true"
units="pt" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-217.62501)">
<g
id="g3790"
transform="translate(-276.67857,-1.5119048)"
style="fill:#000000">
<path
sodipodi:nodetypes="ccscccsccscssscscsscsccc"
inkscape:connector-curvature="0"
id="path3764"
d="m 287.04656,288.04665 23.71378,9.0592 c 0,0 0.39967,-4.79605 4.5296,-6.92762 4.12992,-2.13158 7.40168,-15.99614 7.40168,-15.99614 l 2.5266,-9.92668 4.1934,-9.24819 c 0,0 -1.13082,-3.82467 -4.67519,-0.19524 -8.8408,9.05294 -3.51813,14.25651 -8.14833,14.16202 -3.77977,-0.75596 -0.13245,-10.86933 0.26722,-16.16497 0.26644,-3.06413 0.69941,-12.98928 0.29974,-18.85112 -0.39966,-5.86184 -0.93256,-6.66118 -2.66446,-6.52795 -1.73191,0.13322 -2.93093,0.93257 -4.39638,9.05919 -1.46546,8.12664 -3.33058,15.72038 -3.06414,18.91774 0.26644,3.19737 -4.36307,0.64443 -2.89762,-5.48385 1.46546,-6.12827 4.82299,-19.49577 4.95621,-21.36089 0.13322,-1.86512 -0.52548,-5.99423 -3.45641,-1.46464 -2.93091,4.52961 -8.39307,31.77464 -8.39307,31.77464 0,0 -4.61911,1.35544 4.75249,-29.62183 0.37058,-1.22492 -1.2231,-1.82036 -2.02245,-0.35491 -0.79933,1.46547 -2.93556,6.41177 -3.60169,9.47592 -0.66612,3.06413 -4.12526,18.76747 -5.99039,20.76582 -1.86514,1.99836 -0.77914,-1.64516 2.43172,-19.62594 -3.46015,-8.7099 -7.6029,16.6051 -8.29355,25.75422 -1.73191,11.05755 2.66446,14.65459 2.53124,22.78122 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
sodipodi:nodetypes="ccscsssccccccssc"
inkscape:connector-curvature="0"
id="path3766"
d="m 326.28601,276.79194 4.85752,2.59518 c 0,0 5.99506,0.26645 7.86018,1.19902 1.86513,0.93256 14.52136,-19.31742 14.52136,-19.31742 0,0 -1.59867,-0.39967 -3.19735,-5.32893 -1.59868,-4.92926 -7.59374,-19.98353 -9.45888,-23.44734 -1.86513,-3.46381 -2.53124,-4.66283 -3.4638,-7.46051 -0.93257,-2.7977 -2.13159,-5.0625 -3.73027,-0.13323 -1.59868,4.92927 -1.66343,10.45537 -0.46441,13.91919 1.38613,5.18454 3.8952,15.07683 1.97631,17.7369 -3.13067,-0.0635 -4.1718,-8.94257 -4.84078,-11.98701 l -10.45574,-8.48036 -1.15458,18.13553 c 0,0 3.30736,-4.0697 9.65298,-5.19422 4.51067,-0.79933 2.81751,6.4678 1.21188,14.09965 -1.34794,6.40707 -3.31442,13.66355 -3.31442,13.66355 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0"
id="path3768"
d="m 291.74698,236.36722 c 0,0 -1.36535,-0.56172 -0.0701,-3.22296 1.29528,-2.66125 3.72103,-1.62503 4.12138,-1.41306 -1.04349,0.50764 -3.37926,4.82292 -4.05132,4.63602 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path3770"
d="m 278.60514,277.01718 c 0,0 -0.98806,-8.05217 1.36702,-17.09567 5.11868,-12.29479 -7.76345,3.61446 -1.36702,17.09567 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
<path
inkscape:connector-curvature="0"
id="path3772"
d="m 283.64252,261.72126 c 0,-0.0431 -1.44898,3.96362 -0.80247,9.53246 0.42679,3.67631 0.64575,8.36037 1.90705,11.72782 3.10143,7.14376 -8.41694,-7.43352 -1.10458,-21.26028 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.11350404px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="cscc" />
<path
inkscape:connector-curvature="0"
id="path3774"
d="m 318.12446,294.21149 c 0,0 6.68844,-4.71017 9.13772,-13.37686 -5.91279,4.63412 -6.77642,9.57974 -9.13772,13.37686 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
<path
inkscape:connector-curvature="0"
id="path3778"
d="m 344.21877,231.00112 c 0,0 1.60041,9.36884 7.07841,21.7522 5.35526,12.10587 4.05178,-4.80879 -7.07841,-21.7522 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="csc" />
<path
inkscape:connector-curvature="0"
id="path3780"
d="m 349.44951,230.90023 c -0.11119,-0.0477 0.96041,8.99393 4.75948,15.37263 1.48524,4.17497 3.73499,-6.08181 -4.75948,-15.37263 z"
style="fill:#ffffff;stroke:#000000;stroke-width:0.09325644px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
sodipodi:nodetypes="ccc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.3 KiB

View file

@ -0,0 +1,144 @@
"use strict";
/*
clapApp.js
unpublishedScripts/marketplace/clap/scripts/clapDebugger.js
Created by Matti 'Menithal' Lahtinen on 9/11/2017
Copyright 2017 High Fidelity, Inc.
Distributed under the Apache License, Version 2.0.
See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
*/
var DEBUG_RIGHT_HAND;
var DEBUG_LEFT_HAND;
var DEBUG_CLAP_LEFT;
var DEBUG_CLAP_RIGHT;
var DEBUG_CLAP;
var DEBUG_CLAP_DIRECTION;
// Debug Values:
var DEBUG_CORRECT = {
red: 0,
green: 255,
blue: 0
};
var DEBUG_WRONG = {
red: 255,
green: 0,
blue: 0
};
var DEBUG_VOLUME = {
red: 255,
green: 255,
blue: 128
};
module.exports = {
disableDebug: function () {
Overlays.deleteOverlay(DEBUG_RIGHT_HAND);
Overlays.deleteOverlay(DEBUG_LEFT_HAND);
Overlays.deleteOverlay(DEBUG_CLAP_LEFT);
Overlays.deleteOverlay(DEBUG_CLAP_RIGHT);
Overlays.deleteOverlay(DEBUG_CLAP_DIRECTION);
},
debugPositions: function (leftAlignmentWorld, leftHandPositionOffset, leftHandDownWorld, rightAlignmentWorld, rightHandPositionOffset, rightHandDownWorld, tolerance) {
Overlays.editOverlay(DEBUG_CLAP_LEFT, {
color: leftAlignmentWorld > tolerance ? DEBUG_CORRECT : DEBUG_WRONG,
position: leftHandPositionOffset
});
Overlays.editOverlay(DEBUG_CLAP_RIGHT, {
color: rightAlignmentWorld > tolerance ? DEBUG_CORRECT : DEBUG_WRONG,
position: rightHandPositionOffset
});
Overlays.editOverlay(DEBUG_LEFT_HAND, {
color: leftAlignmentWorld > tolerance ? DEBUG_CORRECT : DEBUG_WRONG,
start: leftHandPositionOffset,
end: Vec3.sum(leftHandPositionOffset, Vec3.multiply(leftHandDownWorld, 0.2))
});
Overlays.editOverlay(DEBUG_RIGHT_HAND, {
color: rightAlignmentWorld > tolerance ? DEBUG_CORRECT : DEBUG_WRONG,
start: rightHandPositionOffset,
end: Vec3.sum(rightHandPositionOffset, Vec3.multiply(rightHandDownWorld, 0.2))
});
},
debugClapLine: function (start, end, visible) {
Overlays.editOverlay(DEBUG_CLAP_DIRECTION, {
start: start,
end: end,
visible: visible
});
},
enableDebug: function () {
DEBUG_RIGHT_HAND = Overlays.addOverlay("line3d", {
color: DEBUG_WRONG,
start: MyAvatar.position,
end: Vec3.sum(MyAvatar.position, {
x: 0,
y: 1,
z: 0
}),
dimensions: {
x: 2,
y: 2,
z: 2
}
});
DEBUG_LEFT_HAND = Overlays.addOverlay("line3d", {
color: DEBUG_WRONG,
start: MyAvatar.position,
end: Vec3.sum(MyAvatar.position, {
x: 0,
y: 1,
z: 0
}),
dimensions: {
x: 2,
y: 2,
z: 2
}
});
DEBUG_CLAP_LEFT = Overlays.addOverlay("sphere", {
position: MyAvatar.position,
color: DEBUG_WRONG,
scale: {
x: 0.05,
y: 0.05,
z: 0.05
}
});
DEBUG_CLAP_RIGHT = Overlays.addOverlay("sphere", {
position: MyAvatar.position,
color: DEBUG_WRONG,
scale: {
x: 0.05,
y: 0.05,
z: 0.05
}
});
DEBUG_CLAP_DIRECTION = Overlays.addOverlay("line3d", {
color: DEBUG_VOLUME,
start: MyAvatar.position,
end: MyAvatar.position,
dimensions: {
x: 2,
y: 2,
z: 2
}
});
}
};

View file

@ -0,0 +1,313 @@
"use strict";
/*
clapEngine.js
unpublishedScripts/marketplace/clap/clapApp.js
Created by Matti 'Menithal' Lahtinen on 9/11/2017
Copyright 2017 High Fidelity, Inc.
Distributed under the Apache License, Version 2.0.
See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
Main Heart of the clap script> Does both keyboard binding and tracking of the gear..
*/
var DEG_TO_RAD = Math.PI / 180;
// If angle is closer to 0 from 25 degrees, then "clap" can happen;
var COS_OF_TOLERANCE = Math.cos(25 * DEG_TO_RAD);
var DISTANCE = 0.3;
var CONTROL_MAP_PACKAGE = "com.highfidelity.avatar.clap.active";
var CLAP_MENU = "Clap";
var ENABLE_PARTICLE_MENU = "Enable Clap Particles";
var ENABLE_DEBUG_MENU = "Enable Claping Helper";
var sounds = [
"clap1.wav",
"clap2.wav",
"clap3.wav",
"clap4.wav",
"clap5.wav",
"clap6.wav"
];
var ClapParticle = Script.require(Script.resolvePath("../entities/ClapParticle.json?V3"));
var ClapAnimation = Script.require(Script.resolvePath("../animations/ClapAnimation.json?V3"));
var ClapDebugger = Script.require(Script.resolvePath("ClapDebugger.js?V3"));
var settingDebug = false;
var settingParticlesOn = true;
function setJointRotation(map) {
Object.keys(map).forEach(function (key, index) {
MyAvatar.setJointRotation(MyAvatar.getJointIndex(key), map[key].rotations);
});
}
// Load Sounds to Cache
var cache = [];
for (var index in sounds) {
cache.push(SoundCache.getSound(Script.resolvePath("../sounds/" + sounds[index])));
}
var previousIndex;
var clapOn = false;
var animClap = false;
var animThrottle;
function clap(volume, position, rotation) {
var index;
// Make sure one does not generate consequtive sounds
do {
index = Math.floor(Math.random() * cache.length);
} while (index === previousIndex);
previousIndex = index;
Audio.playSound(cache[index], {
position: position,
volume: volume / 4 + Math.random() * (volume / 3)
});
if (settingParticlesOn) {
ClapParticle.orientation = Quat.multiply(MyAvatar.orientation, rotation);
ClapParticle.position = position;
ClapParticle.emitSpeed = volume > 1 ? 1 : volume;
Entities.addEntity(ClapParticle, true);
}
}
// Helper Functions
function getHandFingerAnim(side) {
return Script.resolvePath("../animations/Clap_" + side + '.fbx');
}
// Disable all role animations related to fingers for side
function overrideFingerRoleAnimation(side) {
var anim = getHandFingerAnim(side);
MyAvatar.overrideRoleAnimation(side + "HandGraspOpen", anim, 30, true, 0, 0);
MyAvatar.overrideRoleAnimation(side + "HandGraspClosed", anim, 30, true, 0, 0);
if (HMD.active) {
MyAvatar.overrideRoleAnimation(side + "HandPointIntro", anim, 30, true, 0, 0);
MyAvatar.overrideRoleAnimation(side + "HandPointHold", anim, 30, true, 0, 0);
MyAvatar.overrideRoleAnimation(side + "HandPointOutro", anim, 30, true, 0, 0);
MyAvatar.overrideRoleAnimation(side + "IndexPointOpen", anim, 30, true, 0, 0);
MyAvatar.overrideRoleAnimation(side + "IndexPointClosed", anim, 30, true, 0, 0);
MyAvatar.overrideRoleAnimation(side + "IndexPointAndThumbRaiseOpen", anim, 30, true, 0, 0);
MyAvatar.overrideRoleAnimation(side + "IndexPointAndThumbRaiseClosed", anim, 30, true, 0, 0);
MyAvatar.overrideRoleAnimation(side + "ThumbRaiseOpen", anim, 30, true, 0, 0);
MyAvatar.overrideRoleAnimation(side + "ThumbRaiseClosed", anim, 30, true, 0, 0);
}
}
// Re-enable all role animations for fingers
function restoreFingerRoleAnimation(side) {
MyAvatar.restoreRoleAnimation(side + "HandGraspOpen");
MyAvatar.restoreRoleAnimation(side + "HandGraspClosed");
if (HMD.active) {
MyAvatar.restoreRoleAnimation(side + "HandPointIntro");
MyAvatar.restoreRoleAnimation(side + "HandPointHold");
MyAvatar.restoreRoleAnimation(side + "HandPointOutro");
MyAvatar.restoreRoleAnimation(side + "IndexPointOpen");
MyAvatar.restoreRoleAnimation(side + "IndexPointClosed");
MyAvatar.restoreRoleAnimation(side + "IndexPointAndThumbRaiseOpen");
MyAvatar.restoreRoleAnimation(side + "IndexPointAndThumbRaiseClosed");
MyAvatar.restoreRoleAnimation(side + "ThumbRaiseOpen");
MyAvatar.restoreRoleAnimation(side + "ThumbRaiseClosed");
}
}
function menuListener(menuItem) {
if (menuItem === ENABLE_PARTICLE_MENU) {
settingParticlesOn = Menu.isOptionChecked(ENABLE_PARTICLE_MENU);
} else if (menuItem === ENABLE_DEBUG_MENU) {
var debugOn = Menu.isOptionChecked(ENABLE_DEBUG_MENU);
if (debugOn) {
settingDebug = true;
ClapDebugger.enableDebug();
} else {
settingDebug = false;
ClapDebugger.disableDebug();
}
}
}
function update(dt) {
// NOTICE: Someof this stuff is unnessary for the actual: But they are done for Debug Purposes!
// Forexample, the controller doesnt really need to know where it is in the world, only its relation to the other controller!
var leftHand = Controller.getPoseValue(Controller.Standard.LeftHand);
var rightHand = Controller.getPoseValue(Controller.Standard.RightHand);
// Get Offset position for palms, not the controllers that are at the wrists (7.5 cm up)
var leftWorldRotation = Quat.multiply(MyAvatar.orientation, leftHand.rotation);
var rightWorldRotation = Quat.multiply(MyAvatar.orientation, rightHand.rotation);
var leftWorldUpNormal = Quat.getUp(leftWorldRotation);
var rightWorldUpNormal = Quat.getUp(rightWorldRotation);
var leftHandDownWorld = Vec3.multiply(-1, Quat.getForward(leftWorldRotation));
var rightHandDownWorld = Vec3.multiply(-1, Quat.getForward(rightWorldRotation));
//
var leftHandWorldPosition = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, leftHand.translation));
var rightHandWorldPosition = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, rightHand.translation));
var rightHandPositionOffset = Vec3.sum(rightHandWorldPosition, Vec3.multiply(rightWorldUpNormal, 0.035));
var leftHandPositionOffset = Vec3.sum(leftHandWorldPosition, Vec3.multiply(leftWorldUpNormal, 0.035));
var leftToRightWorld = Vec3.subtract(leftHandPositionOffset, rightHandPositionOffset);
var rightToLeftWorld = Vec3.subtract(rightHandPositionOffset, leftHandPositionOffset);
var leftAlignmentWorld = -1 * Vec3.dot(Vec3.normalize(leftToRightWorld), leftHandDownWorld);
var rightAlignmentWorld = -1 * Vec3.dot(Vec3.normalize(rightToLeftWorld), rightHandDownWorld);
var distance = Vec3.distance(rightHandPositionOffset, leftHandPositionOffset);
var matchTolerance = leftAlignmentWorld > COS_OF_TOLERANCE && rightAlignmentWorld > COS_OF_TOLERANCE;
if (settingDebug) {
ClapDebugger.debugPositions(leftAlignmentWorld,
leftHandPositionOffset, leftHandDownWorld,
rightAlignmentWorld, rightHandPositionOffset,
rightHandDownWorld, COS_OF_TOLERANCE);
}
// Using subtract, because these will be heading to opposite directions
var angularVelocity = Vec3.length(Vec3.subtract(leftHand.angularVelocity, rightHand.angularVelocity));
var velocity = Vec3.length(Vec3.subtract(leftHand.velocity, rightHand.velocity));
if (matchTolerance && distance < DISTANCE && !animClap) {
if (settingDebug) {
ClapDebugger.debugClapLine(leftHandPositionOffset, rightHandPositionOffset, true);
}
if (!animThrottle) {
overrideFingerRoleAnimation("left");
overrideFingerRoleAnimation("right");
animClap = true;
} else {
Script.clearTimeout(animThrottle);
animThrottle = false;
}
} else if (animClap && distance > DISTANCE) {
if (settingDebug) {
ClapDebugger.debugClapLine(leftHandPositionOffset, rightHandPositionOffset, false);
}
animThrottle = Script.setTimeout(function () {
restoreFingerRoleAnimation("left");
restoreFingerRoleAnimation("right");
animClap = false;
}, 500);
}
if (distance < DISTANCE && matchTolerance && !clapOn) {
clapOn = true;
var midClap = Vec3.mix(rightHandPositionOffset, leftHandPositionOffset, 0.5);
var volume = velocity / 2 + angularVelocity / 5;
clap(volume, midClap, Quat.lookAtSimple(rightHandPositionOffset, leftHandPositionOffset));
} else if (distance > DISTANCE && !matchTolerance) {
clapOn = false;
}
}
module.exports = {
connectEngine: function () {
if (!Menu.menuExists(CLAP_MENU)) {
Menu.addMenu(CLAP_MENU);
}
if (!Menu.menuItemExists(CLAP_MENU, ENABLE_PARTICLE_MENU)) {
Menu.addMenuItem({
menuName: CLAP_MENU,
menuItemName: ENABLE_PARTICLE_MENU,
isCheckable: true,
isChecked: settingParticlesOn
});
}
if (!Menu.menuItemExists(CLAP_MENU, ENABLE_DEBUG_MENU)) {
Menu.addMenuItem({
menuName: CLAP_MENU,
menuItemName: ENABLE_DEBUG_MENU,
isCheckable: true,
isChecked: settingDebug
});
}
Menu.menuItemEvent.connect(menuListener);
var controls = Controller.newMapping(CONTROL_MAP_PACKAGE);
var Keyboard = Controller.Hardware.Keyboard;
controls.from(Keyboard.K).to(function (down) {
if (down) {
setJointRotation(ClapAnimation);
Script.setTimeout(function () {
// As soon as an animation bug is fixed, this will kick and get fixed.s.
overrideFingerRoleAnimation("left");
overrideFingerRoleAnimation("right");
var lh = MyAvatar.getJointPosition("LeftHand");
var rh = MyAvatar.getJointPosition("RightHand");
var midClap = Vec3.mix(rh, lh, 0.5);
var volume = 0.5 + Math.random() * 0.5;
var position = midClap;
clap(volume, position, Quat.fromVec3Degrees(0, 0, 0));
}, 50); // delay is present to allow for frames to catch up.
} else {
restoreFingerRoleAnimation("left");
restoreFingerRoleAnimation("right");
MyAvatar.clearJointsData();
}
});
Controller.enableMapping(CONTROL_MAP_PACKAGE);
if (settingDebug) {
ClapDebugger.enableDebug();
}
Script.update.connect(update);
Script.scriptEnding.connect(this.disconnectEngine);
},
disconnectEngine: function () {
if (settingDebug) {
ClapDebugger.disableDebug();
}
if (Menu.menuItemExists(CLAP_MENU, ENABLE_PARTICLE_MENU)) {
Menu.removeMenuItem(CLAP_MENU, ENABLE_PARTICLE_MENU);
}
if (Menu.menuItemExists(CLAP_MENU, ENABLE_DEBUG_MENU)) {
Menu.removeMenuItem(CLAP_MENU, ENABLE_DEBUG_MENU);
}
if (Menu.menuExists(CLAP_MENU)) {
Menu.removeMenu(CLAP_MENU);
}
restoreFingerRoleAnimation('left');
restoreFingerRoleAnimation('right');
Controller.disableMapping(CONTROL_MAP_PACKAGE);
try {
Script.update.disconnect(update);
} catch (e) {
print("Script.update connection did not exist on disconnection. Skipping");
}
}
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.