2024-09-16 13:28:28 +02:00
|
|
|
|
2024-10-02 21:03:04 +02:00
|
|
|
if( typeof emulator != 'undefined' ){
|
|
|
|
// inside worker-thread
|
2024-09-16 13:28:28 +02:00
|
|
|
|
2024-10-15 12:32:16 +02:00
|
|
|
this.listenIndexHTML = () => {
|
|
|
|
const file = "dev/browser/html"
|
|
|
|
emulator.readFromPipe( file, async (data) => {
|
|
|
|
const buf = await emulator.read_file( file )
|
|
|
|
const decoder = new TextDecoder('utf-8');
|
|
|
|
const html = decoder.decode(buf).replace(/^#!\/bin\/html/,'') // remove leftover shebangs if any
|
|
|
|
try{
|
|
|
|
this.postMessage({event:'runHTML',data:[html]})
|
|
|
|
}catch(e){
|
|
|
|
console.error(file)
|
|
|
|
console.error(e)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2024-10-02 21:03:04 +02:00
|
|
|
|
2024-09-16 13:28:28 +02:00
|
|
|
|
2024-10-02 21:03:04 +02:00
|
|
|
}else{
|
|
|
|
// inside browser-thread
|
2024-09-16 13:28:28 +02:00
|
|
|
|
2024-10-15 12:32:16 +02:00
|
|
|
ISOTerminal.addEventListener('emulator-started', function(){
|
|
|
|
this.addEventListener('ready', async () => {
|
|
|
|
this.worker.listenIndexHTML()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2024-10-02 21:03:04 +02:00
|
|
|
ISOTerminal.prototype.runHTML = function(html){
|
|
|
|
let $scene = document.querySelector("a-scene")
|
|
|
|
let $root = document.querySelector("a-entity#root")
|
|
|
|
if( !$root ){
|
|
|
|
$root = document.createElement("a-entity")
|
|
|
|
$root.id = "root"
|
|
|
|
$scene.appendChild($root)
|
|
|
|
}
|
2024-10-15 12:32:16 +02:00
|
|
|
console.log(html)
|
2024-10-02 21:03:04 +02:00
|
|
|
$root.innerHTML = html
|
|
|
|
}
|
2024-09-16 13:28:28 +02:00
|
|
|
|
2024-09-23 16:58:48 +02:00
|
|
|
}
|