repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 2213ca076944f14babb81c28577f2f7d970c90b4:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 2213ca076944f14babb81c28577f2f7d970c90b4
Author: James Baicoianu 
Date:   Sat Feb 27 15:08:47 2021 -0800

    Added portal cooldown time

diff --git a/scripts/portal.js b/scripts/portal.js
index 455af941f532a5c58abc64bf4a144bcc8546c3c3..
index ..73dc9e0b5076e5ce507b05e914b5a6159bd5a41e 100644
--- a/scripts/portal.js
+++ b/scripts/portal.js
@@ -25,6 +25,7 @@ elation.require(['janusweb.janusbase'], function() {
         'external': { type: 'boolean', default: false },
         'target': { type: 'string', default: '' },
         'round': { type: 'boolean', default: false },
+        'cooldown': { type: 'float', default: 1000 },
       });
       this.addTag('usable');
       elation.engine.things.janusportal.extendclass.postinit.call(this);
@@ -32,6 +33,8 @@ elation.require(['janusweb.janusbase'], function() {
       elation.events.add(this, 'thing_use_blur', elation.bind(this, this.useBlur));
       elation.events.add(player, 'player_enable', elation.bind(this, this.disableDebounce));
       elation.events.add(player, 'player_disable', elation.bind(this, this.enableDebounce));
+
+      this.lastactivatetime = 0;
     }
     this.createObject3D = function() {
       this.objects['3d'] = new THREE.Object3D();
@@ -258,6 +261,12 @@ elation.require(['janusweb.janusbase'], function() {
     }
     this.activate = function(ev) {
       //console.log('activate', ev, this.seamless);
+
+      let now = Date.now();
+      if (now - this.lastactivatetime < this.cooldown) {
+        return;
+      }
+      this.lastactivatetime = now;
       if (this.frame) {
         this.frame.material.emissive.setHex(0x662222);
         setTimeout(elation.bind(this, function() { this.frame.material.emissive.setHex(0x222222); }), 250);

-----END OF PAGE-----