(function() { var TELEPORT_SOUND_VOLUME = 0.40; var teleportSound; var portalDestination; var position; var canTeleport; function playSound(entityID) { if (teleportSound.downloaded) { if (!position) { getProps(entityID); } Audio.playSound(teleportSound, { position: position, volume: TELEPORT_SOUND_VOLUME, localOnly: true }); } } function getProps(entityID) { var properties = Entities.getEntityProperties(entityID); if (properties) { position = properties.position; portalDestination = JSON.parse(properties.userData).location; } } this.preload = function(entityID) { teleportSound = SoundCache.getSound("http://s3.amazonaws.com/hifi-public/birarda/teleport.raw"); getProps(entityID); }; this.mouseReleaseOnEntity = function(entityID) { // get latest props in case we changed the destination getProps(entityID); if (portalDestination.length > 0) { playSound(entityID); Window.location = "hifi://" + portalDestination; } }; });