63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
const CLIP_URL = "atp:6a4866aed4f717933bb5ac6e4824e56f49fedf635550ac7baa84b6ccb1bb6ab4.hfr";
|
|
|
|
|
|
const RECORDING_CHANNEL_PLAY_MESSAGE = 'PlayBackOnAssignment';
|
|
const RECORDING_CHANNEL_STOP_MESSAGE = 'StopPlayBackOnAssignment';
|
|
const RECORDING_CHANNEL = 'HydraTutorialChannel'; // For each different assignment add a different message here.
|
|
const PLAY_FROM_CURRENT_LOCATION = false;
|
|
const USE_DISPLAY_NAME = true;
|
|
const USE_ATTACHMENTS = true;
|
|
const USE_AVATAR_MODEL = true;
|
|
const AUDIO_OFFSET = 0.0;
|
|
const STARTING_TIME = 0.0;
|
|
const COOLDOWN_PERIOD = 0; // The period in ms that no animations can be played after one has been played already
|
|
|
|
var isPlaying = false;
|
|
var isPlayable = true;
|
|
|
|
var stopRecording = function() {
|
|
Recording.stopRecording();
|
|
isPlayable = true;
|
|
isPlaying = false;
|
|
Agent.isAvatar = false;
|
|
}
|
|
|
|
var playRecording = function() {
|
|
if (!isPlayable || isPlaying) {
|
|
return;
|
|
}
|
|
Agent.isAvatar = true;
|
|
Avatar.position = {
|
|
x: 555.0,
|
|
y: 495.77,
|
|
z: 471.6
|
|
};
|
|
Avatar.orientation = Quat.fromPitchYawRollDegrees(0, 150, 0);
|
|
Avatar.scale = 0.9;
|
|
|
|
Recording.setPlayFromCurrentLocation(PLAY_FROM_CURRENT_LOCATION);
|
|
Recording.setPlayerUseDisplayName(USE_DISPLAY_NAME);
|
|
Recording.setPlayerUseAttachments(USE_ATTACHMENTS);
|
|
Recording.setPlayerUseHeadModel(false);
|
|
Recording.setPlayerUseSkeletonModel(USE_AVATAR_MODEL);
|
|
Recording.setPlayerLoop(false);
|
|
Recording.setPlayerTime(STARTING_TIME);
|
|
Recording.setPlayerAudioOffset(AUDIO_OFFSET);
|
|
Recording.loadRecording(CLIP_URL);
|
|
Recording.startPlaying();
|
|
isPlaying = true;
|
|
isPlayable = false; // Set this true again after the cooldown period
|
|
};
|
|
|
|
|
|
Messages.subscribe(RECORDING_CHANNEL);
|
|
|
|
Messages.messageReceived.connect(function(channel, message, senderID) {
|
|
print('channel: ' + channel);
|
|
print('message: ' + message);
|
|
if (channel === RECORDING_CHANNEL && message === RECORDING_CHANNEL_PLAY_MESSAGE) {
|
|
playRecording();
|
|
} else if (channel === RECORDING_CHANNEL && message === RECORDING_CHANNEL_STOP_MESSAGE) {
|
|
stopRecording();
|
|
}
|
|
});
|