xterm improvment
/ mirror_to_github (push) Successful in 20s Details
/ test (push) Successful in 4s Details

This commit is contained in:
Leon van Kammen 2024-09-24 09:53:23 +00:00
parent 9d69ef9c57
commit bc82d87541
1 changed files with 25 additions and 14 deletions

View File

@ -27,21 +27,32 @@ ISOTerminal.prototype.xtermInit = function(){
}) })
term.onRender( () => { term.onRender( () => {
console.log("render")
// xterm relies on requestAnimationFrame (which does not called in immersive mode) let _window = term._core._coreBrowserService._window
const _window = term._core._coreBrowserService._window if( !_window.requestAnimationFrameAFRAME ){ // patch the planet!
const requestAnimationFrame = _window.requestAnimationFrame
// luckily xterm allows a swappable window object // xterm relies on requestAnimationFrame (which does not called in immersive mode)
let newWindow = function(){}.bind(window) _window.requestAnimationFrameAFRAME =
for( var i in window ) newWindow[i] = window[i] AFRAME.utils.throttleLeadingAndTrailing( function(cb){
newWindow.requestAnimationFrame = (cb) => { cb()
if( term.tid != null ) return },150 )
setTimeout( () => {
cb() // we proxy the _window object of xterm, and reroute
term.tid = null // requestAnimationFrame to requestAnimationFrameAFRAME
},200) _window = new Proxy(_window,{
get(me,k){
if( k == 'requestAnimationFrame' ){
return me.requestAnimationFrameAFRAME
}
return me[k]
},
set(me,k,v){
me[k] = v
return true
}
})
term._core._coreBrowserService._window = _window
} }
term._core._coreBrowserService._window = newWindow
}) })