Last active
November 4, 2019 19:36
-
-
Save hyperlogic/3a39189dd108ee643e52a5016d62f227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { // BEGIN LOCAL_SCOPE | |
var TABLET_BUTTON_NAME = "BLENDSHAPE"; | |
var HTML_URL = "https://hifi-public.s3.amazonaws.com/tony/html/blendshapetest_arkit.html?2"; | |
var BLENDSHAPETEST_CHANNEL = "com.highfidelity.blendshapetest"; | |
var IS_LOCAL = true; | |
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); | |
var tabletButton = tablet.addButton({ | |
text: TABLET_BUTTON_NAME, | |
icon: "https://s3.amazonaws.com/hifi-public/tony/icons/tpose-i.svg", | |
activeIcon: "https://s3.amazonaws.com/hifi-public/tony/icons/tpose-a.svg" | |
}); | |
tabletButton.clicked.connect(function () { | |
if (shown) { | |
tablet.gotoHomeScreen(); | |
} else { | |
tablet.gotoWebScreen(HTML_URL); | |
} | |
}); | |
var shown = false; | |
function onScreenChanged(type, url) { | |
if (type === "Web" && url === HTML_URL) { | |
tabletButton.editProperties({isActive: true}); | |
if (!shown) { | |
// hook up to event bridge | |
tablet.webEventReceived.connect(onWebEventReceived); | |
} | |
shown = true; | |
} else { | |
tabletButton.editProperties({isActive: false}); | |
if (shown) { | |
// disconnect from event bridge | |
tablet.webEventReceived.disconnect(onWebEventReceived); | |
} | |
shown = false; | |
} | |
} | |
tablet.screenChanged.connect(onScreenChanged); | |
function onWebEventReceived(msg) { | |
if (IS_LOCAL) { | |
if (msg.name === "hasScriptedBlendshapes") { | |
MyAvatar.hasScriptedBlendshapes = (msg.value === "on"); | |
} else if (msg.name === "hasProceduralBlinkFaceMovement") { | |
MyAvatar.hasProceduralBlinkFaceMovement = (msg.value === "on"); | |
} else if (msg.name === "hasProceduralEyeFaceMovement") { | |
MyAvatar.hasProceduralEyeFaceMovement = (msg.value === "on"); | |
} else if (msg.name === "hasAudioEnabledFaceMovement") { | |
MyAvatar.hasAudioEnabledFaceMovement = (msg.value === "on"); | |
} else { | |
MyAvatar.setBlendshape(msg.name, parseInt(msg.value, 10) / 100); | |
} | |
} else { | |
Messages.sendMessage(BLENDSHAPETEST_CHANNEL, JSON.stringify(msg)); | |
} | |
} | |
Script.scriptEnding.connect(function () { | |
tablet.removeButton(tabletButton); | |
if (shown) { | |
tablet.webEventReceived.disconnect(onWebEventReceived); | |
tablet.gotoHomeScreen(); | |
} | |
tablet.screenChanged.disconnect(onScreenChanged); | |
}); | |
}()); // END LOCAL_SCOPE | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment