disabled other menuitems
/ mirror_to_github (push) Successful in 20s Details
/ test (push) Successful in 5s Details

This commit is contained in:
Leon van Kammen 2024-09-06 08:30:24 +00:00
parent 98c3adb791
commit 658e113853
5 changed files with 79 additions and 84 deletions

View File

@ -37,7 +37,7 @@ if( typeof AFRAME != 'undefined '){
transparent: { type:'boolean', "default":false } // need good gpu transparent: { type:'boolean', "default":false } // need good gpu
}, },
init: function(){ init: async function(){
this.el.object3D.visible = false 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:{ events:{
@ -122,70 +189,7 @@ if( typeof AFRAME != 'undefined '){
}, },
launcher: async function(){ launcher: async function(){
if( this.instance ){ this.initTerminal()
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
} }
}, },
@ -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 <a-scene>
observer = new MutationObserver( (a,b) => {
console.log("change")
})
observer.observe( this.sceneEl, {characterData: false, childList: true, attributes: false});
}
})
} }

View File

@ -8,7 +8,7 @@ source /mnt/profile.xrsh
source /mnt/profile.sh source /mnt/profile.sh
# source js functions # source js functions
js "$(cat ~/.profile.js)" &>/dev/null & ./.profile.js
## forward not-found commands to javascript (via jsh) ## forward not-found commands to javascript (via jsh)
command_not_found_handle(){ command_not_found_handle(){

View File

@ -1,3 +1,5 @@
#!/bin/js
window.helloworld = function(){ window.helloworld = function(){
alert("hello world") alert("hello world")
return "hello world" return "hello world"

View File

@ -15,6 +15,8 @@ test -d /dev/browser || {
ln -s /mnt/profile.browser ~/.profile.browser ln -s /mnt/profile.browser ~/.profile.browser
ln -s /mnt/profile.sh ~/.profile.sh ln -s /mnt/profile.sh ~/.profile.sh
ln -s /mnt/motd ~/.motd ln -s /mnt/motd ~/.motd
ln -s ~/.profile.js ~/index.js
chmod +x ~/.profile.js
} }
setup_browser_dev(){ setup_browser_dev(){

View File

@ -45,9 +45,12 @@ AFRAME.registerComponent('launcher', {
cols: { type:"number", "default": 5 } cols: { type:"number", "default": 5 }
}, },
dependencies:['dom'], dependencies:{
dom: "com/dom.js"
},
init: async function () { init: async function () {
await AFRAME.utils.require(this.dependencies)
this.worldPosition = new THREE.Vector3() this.worldPosition = new THREE.Vector3()
await AFRAME.utils.require({ await AFRAME.utils.require({
@ -377,7 +380,7 @@ AFRAME.registerSystem('launcher',{
updateLauncher: function(){ updateLauncher: function(){
let launcher = document.querySelector('[launcher]') let launcher = document.querySelector('[launcher]')
if( launcher ) launcher.components['launcher'].render() if( launcher ) launcher.components.launcher.render()
} }
}) })