work in progress [might break]
This commit is contained in:
parent
ac85f4b713
commit
82c439696d
|
@ -19,7 +19,7 @@ AFRAME.registerComponent('helloworld-html', {
|
||||||
<div class="pad"> helloworld-html: ${me.data.foo} <b>${me.data.myvalue}</b></span>
|
<div class="pad"> helloworld-html: ${me.data.foo} <b>${me.data.myvalue}</b></span>
|
||||||
</div>`,
|
</div>`,
|
||||||
|
|
||||||
css: `.helloworld-html {
|
css: (me) => `.helloworld-html {
|
||||||
color: var(--xrsh-light-gray); /* see index.css */
|
color: var(--xrsh-light-gray); /* see index.css */
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
|
|
|
@ -31,7 +31,7 @@ AFRAME.registerComponent('helloworld-htmlform', {
|
||||||
<button>hello</button>
|
<button>hello</button>
|
||||||
</div>`,
|
</div>`,
|
||||||
|
|
||||||
css: `.helloworld-htmlform > div { padding:11px; }`
|
css: (me) => `.helloworld-htmlform > div { padding:11px; }`
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ AFRAME.registerComponent('helloworld-iframe', {
|
||||||
<iframe src=""></iframe>
|
<iframe src=""></iframe>
|
||||||
</div>`,
|
</div>`,
|
||||||
|
|
||||||
css: `
|
css: (me) => `
|
||||||
.XR #overlay .winbox.iframe{ visibility: visible; } /* don't hide in XR mode */
|
.XR #overlay .winbox.iframe{ visibility: visible; } /* don't hide in XR mode */
|
||||||
.winbox.iframe iframe { background:#FFF; }
|
.winbox.iframe iframe { background:#FFF; }
|
||||||
`
|
`
|
||||||
|
|
|
@ -18,7 +18,7 @@ AFRAME.registerComponent('helloworld-window', {
|
||||||
<div class="pad"> ${me.data.foo} <b>${me.data.myvalue}</b></span>
|
<div class="pad"> ${me.data.foo} <b>${me.data.myvalue}</b></span>
|
||||||
</div>`,
|
</div>`,
|
||||||
|
|
||||||
css: `.helloworld-window div.pad { padding:11px; }`
|
css: (me) => `.helloworld-window div.pad { padding:11px; }`
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events:{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
AFRAME.registerComponent('isoterminal', {
|
AFRAME.registerComponent('isoterminal', {
|
||||||
schema: {
|
schema: {
|
||||||
cols: { type: 'number', default: 80 },
|
cols: { type: 'number', default: 120 },
|
||||||
rows: { type: 'number', default: 25 },
|
rows: { type: 'number', default: 50 },
|
||||||
transparent: { type:'boolean', default:false } // need good gpu
|
transparent: { type:'boolean', default:false } // need good gpu
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -23,9 +23,7 @@ AFRAME.registerComponent('isoterminal', {
|
||||||
events: ['click','keydown'],
|
events: ['click','keydown'],
|
||||||
html: (me) => `<div></div>`,
|
html: (me) => `<div></div>`,
|
||||||
|
|
||||||
css: `.isoterminal{
|
css: (me) => `.isoterminal{
|
||||||
width:512px;
|
|
||||||
height:256px;
|
|
||||||
overflow:hidden;
|
overflow:hidden;
|
||||||
}`
|
}`
|
||||||
},
|
},
|
||||||
|
@ -39,7 +37,7 @@ AFRAME.registerComponent('isoterminal', {
|
||||||
disableStdin: false,
|
disableStdin: false,
|
||||||
rows: this.data.rows,
|
rows: this.data.rows,
|
||||||
cols: this.data.cols,
|
cols: this.data.cols,
|
||||||
fontSize: 64
|
fontSize: 16
|
||||||
})
|
})
|
||||||
|
|
||||||
term.open(this.el.dom)
|
term.open(this.el.dom)
|
||||||
|
@ -49,14 +47,10 @@ AFRAME.registerComponent('isoterminal', {
|
||||||
|
|
||||||
this.cursorCanvas = this.el.dom.querySelector('.xterm-cursor-layer')
|
this.cursorCanvas = this.el.dom.querySelector('.xterm-cursor-layer')
|
||||||
|
|
||||||
this.el.setAttribute('material', 'transparent', this.data.transparent )
|
//this.el.setAttribute('material', `transparent: ${this.data.transparent?'true':'false'}; src: #${this.canvas.id}` )
|
||||||
this.el.setAttribute('material', 'src', '#' + this.canvas.id)
|
|
||||||
|
|
||||||
term.on('refresh', () => {
|
term.on('refresh', () => {
|
||||||
const material = this.el.getObject3D('mesh').material
|
console.log("refresh")
|
||||||
if (!material.map) return
|
|
||||||
this.canvasContext.drawImage(this.cursorCanvas, 0,0)
|
|
||||||
material.map.needsUpdate = true
|
|
||||||
})
|
})
|
||||||
|
|
||||||
term.on('data', (data) => {
|
term.on('data', (data) => {
|
||||||
|
@ -86,10 +80,11 @@ AFRAME.registerComponent('isoterminal', {
|
||||||
|
|
||||||
launcher: function(){
|
launcher: function(){
|
||||||
this.el.dom.style.display = ''
|
this.el.dom.style.display = ''
|
||||||
|
this.createTerminal()
|
||||||
|
|
||||||
new WinBox( this.manifest.iso + ' ' + this.manifest.name, {
|
new WinBox( this.manifest.iso + ' ' + this.manifest.name, {
|
||||||
width: '512px',
|
width: window.innerWidth*0.8,
|
||||||
height: '256px',
|
height: window.innerHeight*0.8,
|
||||||
x:"center",
|
x:"center",
|
||||||
y:"center",
|
y:"center",
|
||||||
id: this.el.uid, // important hint for html-mesh
|
id: this.el.uid, // important hint for html-mesh
|
||||||
|
@ -102,8 +97,6 @@ AFRAME.registerComponent('isoterminal', {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.createTerminal()
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
@ -40,47 +40,53 @@ AFRAME.registerComponent('launcher', {
|
||||||
<div id="iconmenu"></div>
|
<div id="iconmenu"></div>
|
||||||
</div>`,
|
</div>`,
|
||||||
|
|
||||||
css: `#iconmenu {
|
css: (me) => `#iconmenu {
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column-reverse;
|
flex-direction: row;
|
||||||
align-items: flex-end;
|
align-items: flex-start;
|
||||||
height: 100%;
|
height: 50px;
|
||||||
|
overflow:hidden;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0px;
|
right: 162px;
|
||||||
right: 20px;
|
bottom: 0px;
|
||||||
bottom: 0;
|
left:20px;
|
||||||
padding-bottom: 72px;
|
background: transparent;
|
||||||
|
padding-bottom: 54px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
visibility: visible !important;
|
visibility: visible !important;
|
||||||
}
|
}
|
||||||
#iconmenu > button {
|
#iconmenu > button {
|
||||||
|
line-height:0px;
|
||||||
pointer-events:all;
|
pointer-events:all;
|
||||||
width: 58px;
|
width: 58px;
|
||||||
height: 39px;
|
height: 34px;
|
||||||
padding: 12px 0px 20px 0px;
|
padding: 12px 0px 12px 0px;
|
||||||
border-radius: 0px;
|
border-radius: 0px;
|
||||||
color: var(--xrsh-primary);
|
color: var(--xrsh-primary);
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
border-left: 5px solid var(--xrsh-primary);
|
border-top: 2px solid #BBB;
|
||||||
border-right: 5px solid var(--xrsh-primary);
|
border-bottom: 2px solid #BBB;
|
||||||
|
font-size:18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#iconmenu > button:first-child {
|
#iconmenu > button:first-child {
|
||||||
border-radius:0px 0px 30px 30px;
|
border-radius: 5px 0px 0px 5px;
|
||||||
border-bottom: 5px solid var(--xrsh-primary);
|
border-bottom: 2px solid #BBB;
|
||||||
padding-bottom:35px;
|
border-left: 2px solid #BBB;
|
||||||
|
padding-bottom:16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#iconmenu > button:last-child {
|
#iconmenu > button:last-child {
|
||||||
border-radius:30px 30px 0px 0px;
|
border-radius:0px 5px 5px 0px;
|
||||||
border-top: 5px solid var(--xrsh-primary);
|
border-top: 2px solid #BBB;
|
||||||
|
border-right: 2px solid #BBB;
|
||||||
padding-top:13px;
|
padding-top:13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#iconmenu > button > img {
|
#iconmenu > button > img {
|
||||||
transform: translate(0px,-5px);
|
transform: translate(0px,-14px);
|
||||||
opacity:0.5;
|
opacity:0.5;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
border-radius: 0px;
|
border-radius: 0px;
|
||||||
|
@ -109,11 +115,9 @@ AFRAME.registerComponent('launcher', {
|
||||||
render: function(app){
|
render: function(app){
|
||||||
clearTimeout(this.timeout)
|
clearTimeout(this.timeout)
|
||||||
this.timeout = setTimeout( () => {
|
this.timeout = setTimeout( () => {
|
||||||
AFRAME.app.foreach( (app) => {
|
const drawButton = (app) => {
|
||||||
if( !app.manifest ) return
|
if( !app.manifest ) return
|
||||||
|
|
||||||
console.log(app.data.uri+" "+app.data.order)
|
console.log(app.data.uri+" "+app.data.order)
|
||||||
|
|
||||||
let btn = app.btn = document.createElement('button')
|
let btn = app.btn = document.createElement('button')
|
||||||
if( app.manifest.icons?.length > 0){
|
if( app.manifest.icons?.length > 0){
|
||||||
let img = document.createElement('img')
|
let img = document.createElement('img')
|
||||||
|
@ -121,15 +125,26 @@ AFRAME.registerComponent('launcher', {
|
||||||
img.title = app.manifest.name + ": " + app.manifest.description
|
img.title = app.manifest.name + ": " + app.manifest.description
|
||||||
btn.appendChild(img)
|
btn.appendChild(img)
|
||||||
}else btn.innerText = app.manifest.short_name
|
}else btn.innerText = app.manifest.short_name
|
||||||
btn.addEventListener('click', () => app.el.emit('launcher',app) )
|
btn.addEventListener('click', () => {
|
||||||
this.el.dom.querySelector('#iconmenu').appendChild(btn)
|
app.el.emit('launcher',app)
|
||||||
|
app.el.sceneEl.emit('launched',app)
|
||||||
})
|
})
|
||||||
|
this.el.dom.querySelector('#iconmenu').appendChild(btn)
|
||||||
|
}
|
||||||
|
|
||||||
|
const drawCategory = (app,c) => app.manifest &&
|
||||||
|
app.manifest.short_name != "launcher" &&
|
||||||
|
app.manifest.category == c ? drawButton(app) : false
|
||||||
|
|
||||||
|
AFRAME.app.foreach( (app) => drawCategory(app,undefined) )
|
||||||
|
AFRAME.app.foreach( (app) => drawCategory(app,"system") )
|
||||||
|
|
||||||
},100)
|
},100)
|
||||||
},
|
},
|
||||||
|
|
||||||
manifest: { // HTML5 manifest to identify app to xrsh
|
manifest: { // HTML5 manifest to identify app to xrsh
|
||||||
"short_name": "Hello world",
|
"short_name": "launcher",
|
||||||
"name": "Hello world",
|
"name": "App Launcher",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "https://css.gg/browser.svg",
|
"src": "https://css.gg/browser.svg",
|
||||||
|
@ -137,6 +152,7 @@ AFRAME.registerComponent('launcher', {
|
||||||
"sizes": "512x512"
|
"sizes": "512x512"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"category":"system",
|
||||||
"id": "/?source=pwa",
|
"id": "/?source=pwa",
|
||||||
"start_url": "/?source=pwa",
|
"start_url": "/?source=pwa",
|
||||||
"background_color": "#3367D6",
|
"background_color": "#3367D6",
|
||||||
|
|
|
@ -35,7 +35,7 @@ AFRAME.registerComponent('manual', {
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>`,
|
</div>`,
|
||||||
css: `.manual > div { padding:11px }`
|
css: (me) => `.manual > div { padding:11px }`
|
||||||
},
|
},
|
||||||
|
|
||||||
events:{
|
events:{
|
||||||
|
|
|
@ -20,6 +20,14 @@ AFRAME.registerComponent('spatialize', {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
</style>`
|
</style>`
|
||||||
|
|
||||||
|
this.el.sceneEl.addEventListener('launched',(e) => {
|
||||||
|
console.dir(e)
|
||||||
|
let appEl = e.detail.el.dom
|
||||||
|
if( appEl.style.display != 'none' && appEl.innerHTML ){
|
||||||
|
this.btn.style.display = '' // show button
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
requires:{
|
requires:{
|
||||||
|
@ -30,7 +38,9 @@ AFRAME.registerComponent('spatialize', {
|
||||||
|
|
||||||
// component events
|
// component events
|
||||||
ready: function(e){
|
ready: function(e){
|
||||||
|
this.btn.style.display = 'none'
|
||||||
this.btn.style.background = 'var(--xrsh-primary)'
|
this.btn.style.background = 'var(--xrsh-primary)'
|
||||||
|
this.btn.style.color = '#FFF'
|
||||||
},
|
},
|
||||||
|
|
||||||
launcher: function(e){ this.toggle() },
|
launcher: function(e){ this.toggle() },
|
||||||
|
@ -42,27 +52,20 @@ AFRAME.registerComponent('spatialize', {
|
||||||
state = state || !document.body.className.match(/XR/)
|
state = state || !document.body.className.match(/XR/)
|
||||||
document.body.classList[ state ? 'add' : 'remove'](['XR'])
|
document.body.classList[ state ? 'add' : 'remove'](['XR'])
|
||||||
AFRAME.scenes[0].emit( state ? 'apps:XR' : 'apps:2D')
|
AFRAME.scenes[0].emit( state ? 'apps:XR' : 'apps:2D')
|
||||||
this.btn.querySelector('img').src = state ? this.manifest.icons[0].src_2D
|
this.btn.innerHTML = state ? "<s>2D</s>" : "2D"
|
||||||
: this.manifest.icons[0].src
|
|
||||||
},
|
},
|
||||||
|
|
||||||
manifest: { // HTML5 manifest to identify app to xrsh
|
manifest: { // HTML5 manifest to identify app to xrsh
|
||||||
"short_name": "spatialize",
|
"short_name": "2D",
|
||||||
"name": "spatialize",
|
"name": "spatialize",
|
||||||
"icons": [
|
"icons": [],
|
||||||
{
|
|
||||||
"src": "https://css.gg/display-grid.svg",
|
|
||||||
"src_2D": "https://css.gg/stack.svg",
|
|
||||||
"type": "image/svg+xml",
|
|
||||||
"sizes": "512x512"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"id": "/?source=pwa",
|
"id": "/?source=pwa",
|
||||||
"start_url": "/?source=pwa",
|
"start_url": "/?source=pwa",
|
||||||
"background_color": "#3367D6",
|
"background_color": "#3367D6",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"scope": "/",
|
"scope": "/",
|
||||||
"theme_color": "#3367D6",
|
"theme_color": "#3367D6",
|
||||||
|
"category":"system",
|
||||||
"shortcuts": [
|
"shortcuts": [
|
||||||
{
|
{
|
||||||
"name": "What is the latest news?",
|
"name": "What is the latest news?",
|
||||||
|
|
|
@ -33,6 +33,7 @@ AFRAME.registerComponent('vconsole', {
|
||||||
},
|
},
|
||||||
|
|
||||||
launcher: function(){
|
launcher: function(){
|
||||||
|
if( !this.vConsole ) return
|
||||||
let panel = document.querySelector('.vc-panel')
|
let panel = document.querySelector('.vc-panel')
|
||||||
if( panel.style.display == 'none' ) this.vConsole.show()
|
if( panel.style.display == 'none' ) this.vConsole.show()
|
||||||
else this.vConsole.hide()
|
else this.vConsole.hide()
|
||||||
|
|
|
@ -188,7 +188,7 @@ AFRAME.AComponent.prototype.updateProperties = function(updateProperties){
|
||||||
|
|
||||||
addCSS: () => {
|
addCSS: () => {
|
||||||
if( this.dom.css && !document.head.querySelector(`style#${this.attrName}`) ){
|
if( this.dom.css && !document.head.querySelector(`style#${this.attrName}`) ){
|
||||||
document.head.innerHTML += `<style id="${this.attrName}">${this.dom.css}</style>`
|
document.head.innerHTML += `<style id="${this.attrName}">${this.dom.css(this)}</style>`
|
||||||
}
|
}
|
||||||
return tasks
|
return tasks
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue