added xrsh transcript example
This commit is contained in:
parent
f6e7178dc3
commit
8774cbcb69
4 changed files with 43 additions and 26 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
<!-- AFRAME v1.5.0 + extra THREE.js extra loaders -->
|
<!-- AFRAME v1.5.0 + extra THREE.js extra loaders -->
|
||||||
<script src="./../../../dist/aframe.min.js"></script>
|
<script src="./../../../dist/aframe.min.js"></script>
|
||||||
<script src="./../../../dist/xrfragment.aframe.js"></script>
|
<script src="./../../../dist/xrfragment.aframe.js"></script>
|
||||||
|
<script src="./../../../src/3rd/js/plugin/frontend/tab-to-href.js"></script>
|
||||||
<script src="https://xrsh.isvery.ninja/xrsh.js"></script>
|
<script src="https://xrsh.isvery.ninja/xrsh.js"></script>
|
||||||
|
|
||||||
<!-- important: allow touchevents in AR -->
|
<!-- important: allow touchevents in AR -->
|
||||||
|
|
@ -33,7 +34,7 @@
|
||||||
</a-entity>
|
</a-entity>
|
||||||
|
|
||||||
<a-entity id="home" xrf="./../../assets/elearning.glb"></a-entity>
|
<a-entity id="home" xrf="./../../assets/elearning.glb"></a-entity>
|
||||||
<a-entity isoterminal position="0 1.6 -0.3"></a-entity>
|
<a-entity isoterminal="width: 600; height:300" position="0 1.6 -0.3"></a-entity>
|
||||||
</a-scene>
|
</a-scene>
|
||||||
|
|
||||||
<!-- initialize XRSH -->
|
<!-- initialize XRSH -->
|
||||||
|
|
@ -42,35 +43,51 @@
|
||||||
|
|
||||||
const isoterminal = document.querySelector('[isoterminal]').components.isoterminal
|
const isoterminal = document.querySelector('[isoterminal]').components.isoterminal
|
||||||
|
|
||||||
|
const sanitizeTranscript = (str) => {
|
||||||
|
return str
|
||||||
|
.replaceAll("<[^>]*>", "") // strip html
|
||||||
|
.split('\n')
|
||||||
|
.map( (l) => String(l+'.').replace(/(^|:|;|!|\?|\.)\.$/g,'\$1') ) // add dot if needed
|
||||||
|
.join('. ')
|
||||||
|
}
|
||||||
|
|
||||||
|
const transcriptToText = (t) => t.map( (o) => `[36m${o.name}[0m ${o.description}`).join(" ")
|
||||||
|
|
||||||
|
// describe current scene
|
||||||
|
xrf.addEventListener('navigateLoaded', () => {
|
||||||
|
let subscene = xrf.frag.pos.last || xrf.navigator.URI.XRF?.pos?.string
|
||||||
|
subscene = subscene ? subscene = xrf.scene.getObjectByName( subscene ) : false
|
||||||
|
let transcript = transcriptToText( xrf.sceneToTranscript(subscene) )
|
||||||
|
term.send(`\r${transcript}\n\r`)
|
||||||
|
})
|
||||||
|
|
||||||
isoterminal.el.addEventListener('init', () => {
|
isoterminal.el.addEventListener('init', () => {
|
||||||
// override/extend bootmenu-array with your own REPL(s)
|
// clear bootmenu-array
|
||||||
// see com/isoterminal/feat/boot.REPL.*.js for examples
|
// see com/isoterminal/feat/boot.REPL.*.js for REPL examples
|
||||||
ISOTerminal.prototype.boot.menu = [] // reset options
|
ISOTerminal.prototype.boot.menu = []
|
||||||
window.term = isoterminal.term
|
|
||||||
|
|
||||||
const sanitizeTranscript = (str) => {
|
// we've received our terminal \o/
|
||||||
return str
|
term = window.term = isoterminal.term
|
||||||
.replaceAll("<[^>]*>", "") // strip html
|
|
||||||
.split('\n')
|
|
||||||
.map( (l) => String(l+'.').replace(/(^|:|;|!|\?|\.)\.$/g,'\$1') ) // add dot if needed
|
|
||||||
.join('. ')
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// describe mouseover button (and scene to be teleported to, if any)
|
||||||
xrf.addEventListener('href', (e) => {
|
xrf.addEventListener('href', (e) => {
|
||||||
if( typeof e.selected == 'undefined' || !e.mesh ) return; // only process mouse-overs
|
if( typeof e.selected == 'undefined' || !e.mesh ) return; // only process mouse-overs
|
||||||
let name = "object"
|
let name = "object"
|
||||||
let info = ""
|
let info = ""
|
||||||
|
let subscene = false
|
||||||
if( e.mesh.userData ){
|
if( e.mesh.userData ){
|
||||||
if( e.mesh.userData.href && e.mesh.userData.href.match("pos=") ){
|
if( e.mesh.userData.href && e.mesh.userData.href.match("pos=") ){
|
||||||
name = "portal: "
|
name = "action: "
|
||||||
info = "to "+ xrfragment.URI.parse( e.mesh.userData.href ).XRF.pos.string
|
subscene = xrfragment.URI.parse( e.mesh.userData.href ).XRF.pos.string
|
||||||
|
info = "to "+ subscene
|
||||||
}
|
}
|
||||||
if( e.mesh.userData['aria-description'] ){
|
if( e.mesh.userData['aria-description'] ){
|
||||||
info = sanitizeTranscript(e.mesh.userData['aria-description'])
|
info += "\n\r"+sanitizeTranscript(e.mesh.userData['aria-description'])
|
||||||
|
}
|
||||||
|
if( subscene ){
|
||||||
|
info += `\n\r${transcriptToText( xrf.sceneToTranscript(subscene,false,true) )}`
|
||||||
}
|
}
|
||||||
if( !info && e.mesh.name ) name = e.mesh.name
|
if( !info && e.mesh.name ) name = e.mesh.name
|
||||||
// traverse ancestors to nearest aria-description
|
|
||||||
// info: scene description
|
|
||||||
}
|
}
|
||||||
term.send(`\r\n${name} ${info}\n\r`)
|
term.send(`\r\n${name} ${info}\n\r`)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
10
index.html
10
index.html
File diff suppressed because one or more lines are too long
2
make
2
make
|
|
@ -123,7 +123,7 @@ build(){
|
||||||
cp src/3rd/js/plugin/frontend/\$editor.js dist/xrfragment.plugin.editor.js
|
cp src/3rd/js/plugin/frontend/\$editor.js dist/xrfragment.plugin.editor.js
|
||||||
|
|
||||||
cp src/3rd/js/plugin/frontend/css.js dist/xrfragment.plugin.frontend.css.js
|
cp src/3rd/js/plugin/frontend/css.js dist/xrfragment.plugin.frontend.css.js
|
||||||
jscat src/3rd/js/plugin/frontend/{snackbar,accessibility,\$menu,frontend,chatcommand/*,joystick}.js > dist/xrfragment.plugin.frontend.js
|
jscat src/3rd/js/plugin/frontend/{snackbar,accessibility,\$menu,frontend,chatcommand/*,joystick,tab-to-href}.js > dist/xrfragment.plugin.frontend.js
|
||||||
|
|
||||||
jscat src/3rd/js/plugin/matrix/{matrix-crdt,matrix}.js > dist/xrfragment.plugin.matrix.js
|
jscat src/3rd/js/plugin/matrix/{matrix-crdt,matrix}.js > dist/xrfragment.plugin.matrix.js
|
||||||
jscat src/3rd/js/plugin/p2p/{trystero-torrent.min,trystero}.js > dist/xrfragment.plugin.p2p.js
|
jscat src/3rd/js/plugin/p2p/{trystero-torrent.min,trystero}.js > dist/xrfragment.plugin.p2p.js
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
xrf.sceneToTranscript = (scene, node, currentPosition ) => {
|
xrf.sceneToTranscript = (scene, node, currentPosition ) => {
|
||||||
let items = []
|
let items = []
|
||||||
scene = currentPosition && xrf.frag.pos.last ? xrf.scene.getObjectByName(xrf.frag.pos.last) : scene || xrf.scene
|
scene = currentPosition && xrf.frag.pos.last ? xrf.scene.getObjectByName(xrf.frag.pos.last) : (scene || xrf.scene)
|
||||||
scene.traverse( (n) => {
|
scene.traverse( (n) => {
|
||||||
let isSRC = false
|
let isSRC = false
|
||||||
n.traverseAncestors( (m) => m.userData.src ? isSRC = true : false )
|
n.traverseAncestors( (m) => m.userData.src ? isSRC = true : false )
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue