// copyright (c) 2018 humbletim // need to standardize and modularize this stuff -- // so please let me know if you want to share any improvements (humbletim @ hifi forums) (function() { var virtualWeb = Script.require('./hifi.virtual-webview.js#'+Date.now()); virtualWeb.UNIT_ASPECT = { x: 1.600, y: .900, z: .001 }; return { __proto__: { // non-standard (local) properties (accessible via 'this'; see JS prototypical inheritance) popup: false, togglePopup: function() { this.overlayID = virtualWeb.cleanup(this.overlayID); this.popup = !this.popup; if (this.popup) { this.overlayID = virtualWeb.activatePopup(this.entityID); this.overlayID.closed.connect(this, 'togglePopup'); } else { this.overlayID = virtualWeb.activateEntity(this.entityID); } }, }, // standard Entity properties unload: function(uuid) { this.overlayID = virtualWeb.cleanup(this.overlayID); }, preload: function(uuid) { this.entityID = uuid; this.overlayID = virtualWeb.activateEntity(this.entityID); }, clickDownOnEntity: function(uuid, evt) { var shifted = Controller.getValue(Controller.Hardware.Keyboard.Shift); if (evt.isPrimaryButton && shifted) { console.info('clickDownOnEntity...', uuid, this.overlayID, evt.isPrimaryButton, shifted); this.togglePopup(); } }, }; })