(function(){ var teleport; var portalDestination; var position; function playSound(entityID) { print("playing teleport sound"); if (teleport.downloaded) { Audio.playSound(teleport, { position: position, volume: 0.80, localOnly: true }); } }; this.preload = function(entityID) { print("loading teleport script"); teleport = SoundCache.getSound("http://s3.amazonaws.com/hifi-public/birarda/teleport.raw"); props = Entities.getEntityProperties(entityID, ["position", "userData"]); position = props.position; portalDestination = props.userData; }; this.enterEntity = function(entityID) { // get latest props in case we changed the destination print("enterEntity() .... The portal destination is " + portalDestination); if (portalDestination.length > 0) { print("Teleporting to hifi://" + portalDestination); Window.location = "hifi://" + portalDestination; } }; this.leaveEntity = function(entityID) { print("leaveEntity() called ...."); playSound(entityID); }; this.unload = function() { print("unloading teleport script"); }; })