immersive mode for score and remix meta-data

This commit is contained in:
Utopiah
2026-07-06 15:16:20 +02:00
parent 14dc137dcd
commit 9c4cf1dfb9
2 changed files with 76 additions and 4 deletions

View File

@@ -339,6 +339,7 @@ function voteInXR( score ){
Array.from( document.querySelectorAll('.votingui') ).map( (e,n) => e.remove() )
voted = true
}
// consider moving to dedicated library, e.g. contentxr.js instead, and then be usable in games.html
var nofly = false // could be a query parameter instead
nofly = true

View File

@@ -109,17 +109,88 @@ function getRemixes(instance=''){
nodes.map( (file, i) => {
// should add a class to be able to manipulate them
// TODO test support different instance
if (instance)
addNewNote( 'jxr loadRemix("' + file + '", "' + instance + '")', "1 "+ (1.4+i/10) +" -0.5" )
else
addNewNote( 'jxr loadRemix("' + file + '")', "1 "+ (1.4+i/10) +" -0.5" )
if (instance){
el = addNewNote( 'jxr loadRemix("' + file + '", "' + instance + '")', "1 "+ (1.4+i/10) +" -0.5" )
} else {
el = addNewNote( 'jxr loadRemix("' + file + '")', "1 "+ (1.4+i/10) +" -0.5" )
}
el.classList.add('remixloader')
el.remixFilename = file
})
AFRAME.scenes[0].emit('remixesloaded')
})
// returns nothing and async
// store result in global scope data structures
}
setTimeout( c => {
AFRAME.scenes[0].addEventListener('remixesloaded', ev => {
let els = Array.from( document.querySelectorAll('.remixloader') )
console.log( els )
els.map( el => {
rootServerURL = ''
fetch( rootServerURL + remixesPath + '/' + el.remixFilename).then( res => res.json() ).then( json => {
el.data = structuredRemixData( json )
if ( el.data.screenshot ){
console.log( el.data.screenshot )
let sel = document.createElement("a-image")
sel.setAttribute("src", '/screenshots/'+el.data.screenshot )
sel.setAttribute("height", .1)
sel.setAttribute("width", .2)
sel.setAttribute("scale", '10 10 10')
sel.setAttribute("position", "-1 0 -0.1")
el.appendChild(sel)
}
})
})
fetch( rootServerURL + '/scores' ).then( res => res.json() ).then( scores => {
let scored = [...new Set( scores.map( e => e.filename ).filter( e => e.length > 5 ) )]
.map( f => { return { filename:f, scores: scores.filter( e => f == e.filename ).map( e => e.score ) } } )
els.map( el => {
scored.filter( s => s.filename == el.remixFilename ).map( s => {
console.log( el.remixFilename, s.scores )
s.scores.map( (score, i) => {
let sel = document.createElement("a-troika-text")
let y = 0 + i/10
sel.setAttribute("position", "-3 "+y+" -0.1")
sel.setAttribute("value", score+"/3")
el.appendChild(sel)
})
})
})
})
})
})
function structuredRemixData( rmxcontent ){
let data = {}
data.iterations = rmxcontent.filter( l => l.includes(" author ") ).length
data.source = []
rmxcontent.filter( l => l.includes(' source ') ).map( s => {
data.source.push( s.replace(/.*source /,'').replace(/ .*/,'') )
})
rmxcontent.filter( l => l.includes(' date ') ).map( s => {
data.date = s.replace(/.*date /,'').replace(/ .*/,'')
})
rmxcontent.filter( l => l.includes(' author ') ).map( s => {
let author = s.replace(/.*author /,'').replace(/ .*/,'')
data.author = author
if (author == nickname) {
data.ownremix = true
} else {
data.ownremix = false
}
})
rmxcontent.filter( l => l.includes('screenshot') ).map( s => {
data.screenshot = s.replace(/.*screenshot /,'').replace(/ .*/,'')
})
data.unstructured = rmxcontent
return data
}
function loadRemix( filename = 'example_replace.json', rootServerURL = '' ){
loadedRemixes.push( { filename, rootServerURL} )
// fetch( webdavServerRoot + remixesPath + filename).then( res => res.json() ).then( json => {