xterm improvment
This commit is contained in:
parent
9d69ef9c57
commit
bc82d87541
|
@ -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
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue