mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:17:02 +02:00
add an example script for the portal
This commit is contained in:
parent
219e78425b
commit
0b10d0d1dc
1 changed files with 41 additions and 0 deletions
41
examples/entityScripts/portal.js
Normal file
41
examples/entityScripts/portal.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
(function(){
|
||||||
|
var teleport;
|
||||||
|
var portalDestination;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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: "http://hifi-public.s3.amazonaws.com/models/content/phonebooth.fbx",
|
||||||
|
animationSettings: '{ "frameIndex": 1, "running": false }'
|
||||||
|
});
|
||||||
|
|
||||||
|
playSound();
|
||||||
|
};
|
||||||
|
|
||||||
|
this.hoverEnterEntity = function(entityID) {
|
||||||
|
Entities.editEntity(entityID, {
|
||||||
|
animationURL: "http://hifi-public.s3.amazonaws.com/models/content/phonebooth.fbx",
|
||||||
|
animationSettings: '{ "fps": 24, "firstFrame": 1, "lastFrame": 25, "frameIndex": 1, "running": true, "hold": true }'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})
|
Loading…
Reference in a new issue