repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 4fa7926bb8995cf41f80b9101e309332a78a2bf6:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 4fa7926bb8995cf41f80b9101e309332a78a2bf6
Author: James Baicoianu 
Date:   Mon May 27 13:26:34 2024 -0700

    Added preload option to portals

diff --git a/scripts/portal.js b/scripts/portal.js
index 70c88138f61c9cb17b0735f4381d06b990fd1321..
index ..e40635968a66b0a67f7b13df88cb96c96277b366 100644
--- a/scripts/portal.js
+++ b/scripts/portal.js
@@ -21,6 +21,7 @@ elation.require(['janusweb.janusbase'], function() {
         'mirror_recursion': { type: 'integer', default: 2, set: this.updateGeometry },
         'mirror_texturesize': { type: 'integer', default: 1024, set: this.updateGeometry },
         'external': { type: 'boolean', default: false },
+        'preload': { type: 'boolean', default: false },
         'target': { type: 'string', default: '' },
         'round': { type: 'boolean', default: false },
         'cooldown': { type: 'float', default: 1000 },
@@ -289,7 +290,12 @@ elation.require(['janusweb.janusbase'], function() {
               this.closePortal();
             }
           } else if (this.url) {
-            this.properties.janus.setActiveRoom(this.url, room.url);
+            if (this.preload) {
+              let newroom = this.properties.janus.preload(this.url);
+              elation.events.add(newroom, 'room_load_complete', ev => this.properties.janus.setActiveRoom(newroom));
+            } else {
+              this.properties.janus.setActiveRoom(this.url, room.url);
+            }
           }
         }
         var gamepads = this.engine.systems.controls.gamepads;
@@ -320,6 +326,7 @@ elation.require(['janusweb.janusbase'], function() {
           shader_id: ['property', 'shader_id'],
           size: ['property', 'size'],
           round: ['property', 'round'],
+          preload: ['property', 'preload'],
         };
       }
       return this._proxyobject;

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