🔧 master: work in progress [might break]

This commit is contained in:
Leon van Kammen 2026-08-05 10:24:11 +02:00
parent 5c5e0827e4
commit b52b157eff
3 changed files with 13 additions and 4 deletions

View file

@ -74,7 +74,9 @@ return {
res.template = 'page/index.html' res.template = 'page/index.html'
end end
app.pub("dir", nil, {res=res,data=data, urlpath=urlpath, isdir=isdir}) app.pub("dir", nil, {res=res,data=data, urlpath=urlpath, isdir=isdir})
app.cache.url[ urlpath ] = util.templateFile( res.template, data) if not redirect then
app.cache.url[ urlpath ] = util.templateFile( res.template, data)
end
end end
if redirect then if redirect then
print("REDIRECT! " .. redirect ) print("REDIRECT! " .. redirect )

View file

@ -45,6 +45,7 @@
local center = -((#items*width)/1.3) + (i*width) local center = -((#items*width)/1.3) + (i*width)
local url = v.url local url = v.url
if v.dir then url = url .. "/" end if v.dir then url = url .. "/" end
if v.redirect then url = v.redirect end -- dont wrap standalone glb's in janusxr
addPortal('dir',center, v, url,i, -4, 'img', '0 0 0', '0.2 0.2 0.2') addPortal('dir',center, v, url,i, -4, 'img', '0 0 0', '0.2 0.2 0.2')
end end
end} end}

View file

@ -3,13 +3,16 @@ local json = require('json')
app.on('init', function() app.on('init', function()
end) end)
app.on('dir', function(opts)
end)
app.on('scan_experience_file', function(exp) app.on('scan_experience_file', function(exp)
local me = app.plugin.xrfragments local me = app.plugin.xrfragments
foreach( util.split( app.opts.plugin_xrfragments_filetypes, ' '), function(k,ext) foreach( util.split( app.opts.plugin_xrfragments_filetypes, ' '), function(k,ext)
if exp.path:lower():match("."..ext.."$") then if exp.path:lower():match("."..ext.."$") then
exp.view3D = true
local hasHref = false local hasHref = false
if ext == 'glb' then if ext == 'glb' then
exp.view3D = true
-- detect XR Fragment exp https://xrfragment.org/#%F0%9F%93%9C%20level0%3A%20File -- detect XR Fragment exp https://xrfragment.org/#%F0%9F%93%9C%20level0%3A%20File
local tree = me.extract_glb_json( util.stripPath(exp.path) ) local tree = me.extract_glb_json( util.stripPath(exp.path) )
hasHref = me.detectHrefInStruct(tree) hasHref = me.detectHrefInStruct(tree)
@ -32,10 +35,13 @@ app.on('scan_experience_file', function(exp)
if util.fileExist( jsonfile ) then if util.fileExist( jsonfile ) then
exp.sidecarfile.JSONXRF = me.detectHrefInStruct( json.decode( util.readfile(jsonfile) ) ) exp.sidecarfile.JSONXRF = me.detectHrefInStruct( json.decode( util.readfile(jsonfile) ) )
end end
exp.tag.xrfragments = hasHref or hasPNG or hasWebVTT or hasOGG or hasJSONref exp.tag.xrfragments = { qualify = hasHref or hasPNG or hasWebVTT or hasOGG or hasJSONref, href = hasHref }
if exp.tag.xrfragments then if exp.tag.xrfragments.qualify then
print("✅ └─ plugin/xrfragments: detected xrfragments experience") print("✅ └─ plugin/xrfragments: detected xrfragments experience")
end end
if exp.tag.xrfragments.href then
exp.parent.redirect = exp.url -- mark parent to redirect to this standalone url instead
end
foreach(exp.sidecarfile, function(ext,v) foreach(exp.sidecarfile, function(ext,v)
print("✅ └─ plugin/xrfragments: detected .".. ext:lower() .. " sidecarfile") print("✅ └─ plugin/xrfragments: detected .".. ext:lower() .. " sidecarfile")
end) end)