mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-06 18:13:54 +02:00
Merge pull request #10272 from Triplelexx/21292
21292 - Implement a script to hand-raise while in desktop mode
This commit is contained in:
commit
c40e3d6ac9
3 changed files with 232 additions and 0 deletions
70
interface/resources/icons/tablet-icons/raise-hand-a.svg
Normal file
70
interface/resources/icons/tablet-icons/raise-hand-a.svg
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
|
||||
<svg
|
||||
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
|
||||
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"
|
||||
version="1.1"
|
||||
width="50"
|
||||
height="50"
|
||||
viewBox="0 0 50 50"
|
||||
id="svg3713"
|
||||
sodipodi:docname="raise-hand-a.svg"
|
||||
inkscape:version="0.92.1 r15371">
|
||||
<metadata
|
||||
id="metadata3719">
|
||||
<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 />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs3717">
|
||||
<linearGradient
|
||||
id="linearGradient6484"
|
||||
osb:paint="solid">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop6482" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1001"
|
||||
id="namedview3715"
|
||||
showgrid="false"
|
||||
inkscape:zoom="11.8"
|
||||
inkscape:cx="-20"
|
||||
inkscape:cy="23.559322"
|
||||
inkscape:window-x="-9"
|
||||
inkscape:window-y="-9"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg3713" />
|
||||
<path
|
||||
d="m 38.064897,12.746263 c -0.728,0 -1.412,0.196 -2,0.538 v -2.538 c 0,-2.2060002 -1.794,-4.0000002 -4,-4.0000002 -0.824,0 -1.588,0.25 -2.226,0.678 -0.548,-1.558 -2.032,-2.678 -3.774,-2.678 -1.742,0 -3.228,1.12 -3.774,2.678 -0.636,-0.428 -1.402,-0.678 -2.226,-0.678 -2.206,0 -4,1.794 -4,4.0000002 v 14.746 l -2.692,-4.666 c -0.522,-0.95 -1.374,-1.626 -2.398,-1.906 -0.9980001,-0.272 -2.0360001,-0.128 -2.9240001,0.404 -1.814,1.088 -2.506,3.548 -1.54,5.484 0.06,0.122 1.336,2.736 5.3200001,10.7 1.876,3.75 3.934,6.432 6.118,7.968 1.714,1.206 2.898,1.268 3.118,1.268 h 10 c 1.702,0 3.284,-0.554 4.704,-1.644 1.334,-1.026 2.492,-2.51 3.44,-4.408 1.868,-3.736 2.856,-8.904 2.856,-14.948 v -7 c 0,-2.206 -1.794,-4 -4,-4 z m 2,11 c 0,5.734 -0.914,10.592 -2.644,14.052 -1.128,2.256 -3.148,4.948 -6.356,4.948 h -9.98 c -0.078,-0.006 -0.92,-0.1 -2.19,-1.05 -1.266,-0.948 -3.21,-2.944 -5.276,-7.08 -4.0540001,-8.108 -5.3000001,-10.662 -5.3120001,-10.686 -0.002,-0.004 -0.002,-0.006 -0.004,-0.008 -0.502,-1.006 -0.146,-2.324 0.778,-2.878 0.416,-0.25 0.902,-0.316 1.3700001,-0.19 0.498,0.136 0.916,0.472 1.174,0.944 0.004,0.006 0.008,0.014 0.012,0.02 l 3.122,5.41 c 0.638,1.166 1.356,1.656 2.134,1.458 0.78,-0.198 1.174,-0.978 1.174,-2.314 v -15.626 c 0,-1.1020002 0.898,-2.0000002 2,-2.0000002 1.102,0 2,0.898 2,2.0000002 v 13 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 V 8.7462628 c 0,-1.102 0.898,-2 2,-2 1.102,0 2,0.898 2,2 V 23.746263 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 v -13 c 0,-1.1020002 0.898,-2.0000002 2,-2.0000002 1.102,0 2,0.898 2,2.0000002 v 15 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 v -9 c 0,-1.102 0.898,-2 2,-2 1.102,0 2,0.898 2,2 v 7 z"
|
||||
id="path3711"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#000000;stroke-width:1;stroke:#000000;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
inkscape:transform-center-x="0.33898322"
|
||||
inkscape:transform-center-y="-0.6779661" />
|
||||
</svg>
|
After Width: | Height: | Size: 3.6 KiB |
60
interface/resources/icons/tablet-icons/raise-hand-i.svg
Normal file
60
interface/resources/icons/tablet-icons/raise-hand-i.svg
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
|
||||
<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"
|
||||
version="1.1"
|
||||
width="50"
|
||||
height="50"
|
||||
viewBox="0 0 50 50"
|
||||
id="svg3713"
|
||||
sodipodi:docname="raise-hand-i.svg"
|
||||
inkscape:version="0.92.1 r15371">
|
||||
<metadata
|
||||
id="metadata3719">
|
||||
<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 />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs3717" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1001"
|
||||
id="namedview3715"
|
||||
showgrid="false"
|
||||
inkscape:zoom="11.8"
|
||||
inkscape:cx="-20"
|
||||
inkscape:cy="23.559322"
|
||||
inkscape:window-x="-9"
|
||||
inkscape:window-y="-9"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg3713" />
|
||||
<path
|
||||
d="m 38.064897,12.746263 c -0.728,0 -1.412,0.196 -2,0.538 v -2.538 c 0,-2.2060002 -1.794,-4.0000002 -4,-4.0000002 -0.824,0 -1.588,0.25 -2.226,0.678 -0.548,-1.558 -2.032,-2.678 -3.774,-2.678 -1.742,0 -3.228,1.12 -3.774,2.678 -0.636,-0.428 -1.402,-0.678 -2.226,-0.678 -2.206,0 -4,1.794 -4,4.0000002 v 14.746 l -2.692,-4.666 c -0.522,-0.95 -1.374,-1.626 -2.398,-1.906 -0.9980001,-0.272 -2.0360001,-0.128 -2.9240001,0.404 -1.814,1.088 -2.506,3.548 -1.54,5.484 0.06,0.122 1.336,2.736 5.3200001,10.7 1.876,3.75 3.934,6.432 6.118,7.968 1.714,1.206 2.898,1.268 3.118,1.268 h 10 c 1.702,0 3.284,-0.554 4.704,-1.644 1.334,-1.026 2.492,-2.51 3.44,-4.408 1.868,-3.736 2.856,-8.904 2.856,-14.948 v -7 c 0,-2.206 -1.794,-4 -4,-4 z m 2,11 c 0,5.734 -0.914,10.592 -2.644,14.052 -1.128,2.256 -3.148,4.948 -6.356,4.948 h -9.98 c -0.078,-0.006 -0.92,-0.1 -2.19,-1.05 -1.266,-0.948 -3.21,-2.944 -5.276,-7.08 -4.0540001,-8.108 -5.3000001,-10.662 -5.3120001,-10.686 -0.002,-0.004 -0.002,-0.006 -0.004,-0.008 -0.502,-1.006 -0.146,-2.324 0.778,-2.878 0.416,-0.25 0.902,-0.316 1.3700001,-0.19 0.498,0.136 0.916,0.472 1.174,0.944 0.004,0.006 0.008,0.014 0.012,0.02 l 3.122,5.41 c 0.638,1.166 1.356,1.656 2.134,1.458 0.78,-0.198 1.174,-0.978 1.174,-2.314 v -15.626 c 0,-1.1020002 0.898,-2.0000002 2,-2.0000002 1.102,0 2,0.898 2,2.0000002 v 13 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 V 8.7462628 c 0,-1.102 0.898,-2 2,-2 1.102,0 2,0.898 2,2 V 23.746263 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 v -13 c 0,-1.1020002 0.898,-2.0000002 2,-2.0000002 1.102,0 2,0.898 2,2.0000002 v 15 c 0,0.552 0.448,1 1,1 0.552,0 1,-0.448 1,-1 v -9 c 0,-1.102 0.898,-2 2,-2 1.102,0 2,0.898 2,2 v 7 z"
|
||||
id="path3711"
|
||||
inkscape:connector-curvature="0"
|
||||
style="fill:#ffffff;stroke-width:1;fill-opacity:1;stroke:#fdfdfc;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
inkscape:transform-center-x="0.33898322"
|
||||
inkscape:transform-center-y="-0.6779661" />
|
||||
</svg>
|
After Width: | Height: | Size: 3.4 KiB |
|
@ -0,0 +1,102 @@
|
|||
"use strict";
|
||||
//
|
||||
// tablet-raiseHand.js
|
||||
//
|
||||
// client script that creates a tablet button to raise hand
|
||||
//
|
||||
// Created by Triplelexx on 17/04/22
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Hand icons adapted from https://linearicons.com, created by Perxis https://perxis.com CC BY-SA 4.0 license.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
var BUTTON_NAME = "RAISE\nHAND";
|
||||
var USERCONNECTION_MESSAGE_CHANNEL = "io.highfidelity.makeUserConnection";
|
||||
var DEBUG_PREFIX = "TABLET RAISE HAND: ";
|
||||
var isRaiseHandButtonActive = false;
|
||||
var animHandlerId;
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var button = tablet.addButton({
|
||||
text: BUTTON_NAME,
|
||||
icon: "icons/tablet-icons/raise-hand-i.svg",
|
||||
activeIcon: "icons/tablet-icons/raise-hand-a.svg"
|
||||
});
|
||||
|
||||
function onClicked() {
|
||||
isRaiseHandButtonActive = !isRaiseHandButtonActive;
|
||||
button.editProperties({ isActive: isRaiseHandButtonActive });
|
||||
if (isRaiseHandButtonActive) {
|
||||
removeAnimation();
|
||||
animHandlerId = MyAvatar.addAnimationStateHandler(raiseHandAnimation, []);
|
||||
Messages.subscribe(USERCONNECTION_MESSAGE_CHANNEL);
|
||||
Messages.messageReceived.connect(messageHandler);
|
||||
} else {
|
||||
removeAnimation();
|
||||
Messages.unsubscribe(USERCONNECTION_MESSAGE_CHANNEL);
|
||||
Messages.messageReceived.disconnect(messageHandler);
|
||||
}
|
||||
}
|
||||
|
||||
function removeAnimation() {
|
||||
if (animHandlerId) {
|
||||
animHandlerId = MyAvatar.removeAnimationStateHandler(animHandlerId);
|
||||
}
|
||||
}
|
||||
|
||||
function raiseHandAnimation(animationProperties) {
|
||||
// all we are doing here is moving the right hand to a spot that is above the hips.
|
||||
var headIndex = MyAvatar.getJointIndex("Head");
|
||||
var offset = 0.0;
|
||||
var result = {};
|
||||
if (headIndex) {
|
||||
offset = 0.85 * MyAvatar.getAbsoluteJointTranslationInObjectFrame(headIndex).y;
|
||||
}
|
||||
var handPos = Vec3.multiply(offset, { x: -0.7, y: 1.25, z: 0.25 });
|
||||
result.rightHandPosition = handPos;
|
||||
result.rightHandRotation = Quat.fromPitchYawRollDegrees(0, 0, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
function messageHandler(channel, messageString, senderID) {
|
||||
if (channel !== USERCONNECTION_MESSAGE_CHANNEL && senderID !== MyAvatar.sessionUUID) {
|
||||
return;
|
||||
}
|
||||
var message = {};
|
||||
try {
|
||||
message = JSON.parse(messageString);
|
||||
} catch (e) {
|
||||
print(DEBUG_PREFIX + "messageHandler error: " + e);
|
||||
}
|
||||
switch (message.key) {
|
||||
case "waiting":
|
||||
case "connecting":
|
||||
case "connectionAck":
|
||||
case "connectionRequest":
|
||||
case "done":
|
||||
removeAnimation();
|
||||
if (isRaiseHandButtonActive) {
|
||||
isRaiseHandButtonActive = false;
|
||||
button.editProperties({ isActive: isRaiseHandButtonActive });
|
||||
}
|
||||
break;
|
||||
default:
|
||||
print(DEBUG_PREFIX + "messageHandler unknown message: " + message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
button.clicked.connect(onClicked);
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
Messages.unsubscribe(USERCONNECTION_MESSAGE_CHANNEL);
|
||||
Messages.messageReceived.disconnect(messageHandler);
|
||||
button.clicked.disconnect(onClicked);
|
||||
tablet.removeButton(button);
|
||||
removeAnimation();
|
||||
});
|
||||
}()); // END LOCAL_SCOPE
|
Loading…
Reference in a new issue