From 0b10d0d1dc9cc98d7a4cf728c0ebeb36f1a1687e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 6 Feb 2015 10:38:23 -0800 Subject: [PATCH] add an example script for the portal --- examples/entityScripts/portal.js | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 examples/entityScripts/portal.js diff --git a/examples/entityScripts/portal.js b/examples/entityScripts/portal.js new file mode 100644 index 0000000000..e1f00b0afc --- /dev/null +++ b/examples/entityScripts/portal.js @@ -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 }' + }); + }; +}) \ No newline at end of file