overte/examples/entityScripts/portal.js
2015-02-19 13:14:46 -08:00

43 lines
No EOL
1.3 KiB
JavaScript

(function(){
var teleport;
var portalDestination;
var animationURL;
function playSound() {
Audio.playSound(teleport, { volume: 0.40, localOnly: true });
};
this.preload = function(entityID) {
teleport = SoundCache.getSound("http://s3.amazonaws.com/hifi-public/birarda/teleport.raw");
var properties = Entities.getEntityProperties(entityID);
portalDestination = properties.userData;
animationURL = properties.modelURL;
print("The portal destination is " + portalDestination);
}
this.enterEntity = function(entityID) {
if (portalDestination.length > 0) {
print("Teleporting to hifi://" + portalDestination);
Window.location = "hifi://" + portalDestination;
}
};
this.leaveEntity = function(entityID) {
Entities.editEntity(entityID, {
animationURL: animationURL,
animationSettings: '{ "frameIndex": 1, "running": false }'
});
playSound();
};
this.hoverEnterEntity = function(entityID) {
Entities.editEntity(entityID, {
animationURL: animationURL,
animationSettings: '{ "fps": 24, "firstFrame": 1, "lastFrame": 25, "frameIndex": 1, "running": true, "hold": true }'
});
};
})