From 658e11385374418f119d98711b44bbe32b4da10c Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Fri, 6 Sep 2024 08:30:24 +0000 Subject: [PATCH] disabled other menuitems --- com/isoterminal.js | 150 ++++++++++++++----------------- com/isoterminal/mnt/profile | 2 +- com/isoterminal/mnt/profile.js | 2 + com/isoterminal/mnt/profile.xrsh | 2 + com/launcher.js | 7 +- 5 files changed, 79 insertions(+), 84 deletions(-) diff --git a/com/isoterminal.js b/com/isoterminal.js index 9ec2682..e1ed1fe 100644 --- a/com/isoterminal.js +++ b/com/isoterminal.js @@ -37,7 +37,7 @@ if( typeof AFRAME != 'undefined '){ transparent: { type:'boolean', "default":false } // need good gpu }, - init: function(){ + init: async function(){ this.el.object3D.visible = false }, @@ -107,6 +107,73 @@ if( typeof AFRAME != 'undefined '){ ` }, + initTerminal: async function(){ + if( this.instance ){ + const el = document.querySelector('.isoterminal') + return console.warn('TODO: allow multiple terminals (see v86 examples)') + } + + let s = await AFRAME.utils.require(this.requires) + + // instance this component + const instance = this.instance = this.el.cloneNode(false) + this.el.sceneEl.appendChild( instance ) + + // init isoterminal + this.isoterminal = new ISOTerminal() + + instance.addEventListener('DOMready', () => { + instance.setAttribute("window", `title: ${this.data.iso}; uid: ${instance.uid}; attach: #overlay; dom: #${instance.dom.id}`) + }) + + instance.addEventListener('window.oncreate', (e) => { + instance.dom.classList.add('blink') + // run iso + let opts = {dom:instance.dom} + for( let i in this.data ) opts[i] = this.data[i] + this.isoterminal.runISO(opts) + }) + + this.isoterminal.addEventListener('ready', function(e){ + instance.dom.classList.remove('blink') + instance.winbox.maximize() + setTimeout( () => { // important: after window maximize animation to get true size + instance.setAttribute("html-as-texture-in-xr", `domid: #${instance.uid}`) // only show aframe-html in xr + },1500) + }) + + this.isoterminal.addEventListener('status', function(e){ + let msg = e.detail + const w = instance.winbox + if(!w) return + w.titleBak = w.titleBak || w.title + instance.winbox.setTitle( `${w.titleBak} [${msg}]` ) + }) + + instance.addEventListener('window.onclose', (e) => { + if( !confirm('do you want to kill this virtual machine and all its processes?') ) e.halt = true + }) + + const resize = (w,h) => { + if( this.isoterminal.emulator && this.isoterminal.emulator.serial_adapter ){ + setTimeout( () => { + this.isoterminal.xtermAutoResize(this.isoterminal.emulator.serial_adapter.term,instance,-5) + },800) // wait for resize anim + } + } + instance.addEventListener('window.onresize', resize ) + instance.addEventListener('window.onmaximize', resize ) + + instance.setAttribute("dom", "") + + const focus = () => document.querySelector('canvas.a-canvas').focus() + instance.addEventListener('obbcollisionstarted', focus ) + this.el.sceneEl.addEventListener('enter-vr', focus ) + this.el.sceneEl.addEventListener('enter-ar', focus ) + + instance.object3D.quaternion.copy( AFRAME.scenes[0].camera.quaternion ) // face towards camera + }, + events:{ @@ -122,70 +189,7 @@ if( typeof AFRAME != 'undefined '){ }, launcher: async function(){ - if( this.instance ){ - const el = document.querySelector('.isoterminal') - return console.warn('TODO: allow multiple terminals (see v86 examples)') - } - - let s = await AFRAME.utils.require(this.requires) - - // instance this component - const instance = this.instance = this.el.cloneNode(false) - this.el.sceneEl.appendChild( instance ) - - // init isoterminal - this.isoterminal = new ISOTerminal() - - instance.addEventListener('DOMready', () => { - instance.setAttribute("window", `title: ${this.data.iso}; uid: ${instance.uid}; attach: #overlay; dom: #${instance.dom.id}`) - }) - - instance.addEventListener('window.oncreate', (e) => { - instance.dom.classList.add('blink') - // run iso - let opts = {dom:instance.dom} - for( let i in this.data ) opts[i] = this.data[i] - this.isoterminal.runISO(opts) - }) - - this.isoterminal.addEventListener('ready', function(e){ - instance.dom.classList.remove('blink') - instance.winbox.maximize() - setTimeout( () => { // important: after window maximize animation to get true size - instance.setAttribute("html-as-texture-in-xr", `domid: #${instance.uid}`) // only show aframe-html in xr - },1500) - }) - - this.isoterminal.addEventListener('status', function(e){ - let msg = e.detail - const w = instance.winbox - if(!w) return - w.titleBak = w.titleBak || w.title - instance.winbox.setTitle( `${w.titleBak} [${msg}]` ) - }) - - instance.addEventListener('window.onclose', (e) => { - if( !confirm('do you want to kill this virtual machine and all its processes?') ) e.halt = true - }) - - const resize = (w,h) => { - if( this.isoterminal.emulator && this.isoterminal.emulator.serial_adapter ){ - setTimeout( () => { - this.isoterminal.xtermAutoResize(this.isoterminal.emulator.serial_adapter.term,instance,-5) - },800) // wait for resize anim - } - } - instance.addEventListener('window.onresize', resize ) - instance.addEventListener('window.onmaximize', resize ) - - instance.setAttribute("dom", "") - - const focus = () => document.querySelector('canvas.a-canvas').focus() - instance.addEventListener('obbcollisionstarted', focus ) - this.el.sceneEl.addEventListener('enter-vr', focus ) - this.el.sceneEl.addEventListener('enter-ar', focus ) - - instance.object3D.quaternion.copy( AFRAME.scenes[0].camera.quaternion ) // face towards camera + this.initTerminal() } }, @@ -244,20 +248,4 @@ if( typeof AFRAME != 'undefined '){ } }); - - // reflect HTML changes to /dev/browser/html - AFRAME.registerSystem('isoterminal',{ - - init: function(){ - this.components = [] - // observe HTML changes in - observer = new MutationObserver( (a,b) => { - - console.log("change") - }) - observer.observe( this.sceneEl, {characterData: false, childList: true, attributes: false}); - } - - }) } - diff --git a/com/isoterminal/mnt/profile b/com/isoterminal/mnt/profile index 67e6be5..995c556 100644 --- a/com/isoterminal/mnt/profile +++ b/com/isoterminal/mnt/profile @@ -8,7 +8,7 @@ source /mnt/profile.xrsh source /mnt/profile.sh # source js functions -js "$(cat ~/.profile.js)" &>/dev/null & +./.profile.js ## forward not-found commands to javascript (via jsh) command_not_found_handle(){ diff --git a/com/isoterminal/mnt/profile.js b/com/isoterminal/mnt/profile.js index ab44e7f..794b8ca 100644 --- a/com/isoterminal/mnt/profile.js +++ b/com/isoterminal/mnt/profile.js @@ -1,3 +1,5 @@ +#!/bin/js + window.helloworld = function(){ alert("hello world") return "hello world" diff --git a/com/isoterminal/mnt/profile.xrsh b/com/isoterminal/mnt/profile.xrsh index df7c4cb..2115b3f 100644 --- a/com/isoterminal/mnt/profile.xrsh +++ b/com/isoterminal/mnt/profile.xrsh @@ -15,6 +15,8 @@ test -d /dev/browser || { ln -s /mnt/profile.browser ~/.profile.browser ln -s /mnt/profile.sh ~/.profile.sh ln -s /mnt/motd ~/.motd + ln -s ~/.profile.js ~/index.js + chmod +x ~/.profile.js } setup_browser_dev(){ diff --git a/com/launcher.js b/com/launcher.js index bab964c..1148575 100644 --- a/com/launcher.js +++ b/com/launcher.js @@ -45,9 +45,12 @@ AFRAME.registerComponent('launcher', { cols: { type:"number", "default": 5 } }, - dependencies:['dom'], + dependencies:{ + dom: "com/dom.js" + }, init: async function () { + await AFRAME.utils.require(this.dependencies) this.worldPosition = new THREE.Vector3() await AFRAME.utils.require({ @@ -377,7 +380,7 @@ AFRAME.registerSystem('launcher',{ updateLauncher: function(){ let launcher = document.querySelector('[launcher]') - if( launcher ) launcher.components['launcher'].render() + if( launcher ) launcher.components.launcher.render() } })