added janusxml jml insertion admin-field + iframe<>parent urlsync now works!

This commit is contained in:
Leon van Kammen 2026-08-04 14:09:17 +02:00
parent fee621bc71
commit 5c5e0827e4
4 changed files with 29 additions and 18 deletions

View file

@ -21,19 +21,19 @@ ${header}
end}
<script>
//// minimal JS to sync parent/iframe URL-locations
//const iframe = document.querySelector("#viewer")
//iframe.addEventListener('load', () => {
// const iframeWindow = iframe.contentWindow;
// iframeWindow.addEventListener('hashchange', (event) => {
// const params = new URLSearchParams( String(iframeWindow.location.hash).replace(/^#/,'?') )
// const url = params.get('janus.url')
// window.history.pushState( url, iframe.contentDocument.title, url );
// setTimeout( () => {
// document.title = iframe.contentDocument.title
// }, 1000 )
// });
//});
// minimal JS to sync parent/iframe URL-locations
const iframe = document.querySelector("#viewer")
iframe.addEventListener('load', () => {
const iframeWindow = iframe.contentWindow;
iframeWindow.addEventListener('hashchange', (event) => {
const params = new URLSearchParams( String(iframeWindow.location.hash).replace(/^#/,'?') )
const url = params.get('janus.url')
window.history.replaceState( url, iframe.contentDocument.title, url );
setTimeout( () => {
document.title = iframe.contentDocument.title
}, 1000 )
});
});
</script>

View file

@ -36,7 +36,7 @@
end
end}
<text js_id="location" pos="0 6 -5" billboard="y" col="#BBFFFF" scale="10 10 1" text="${url}" emissive="0 0 0" roughness="0.3" metalness="0" />
{if items and #items > 0 then
{if not item and items and #items > 0 then
local portals = {}
for i,v in pairs(items) do table.insert(portals, v) end
if parent then table.insert(portals, p) end
@ -48,7 +48,7 @@
addPortal('dir',center, v, url,i, -4, 'img', '0 0 0', '0.2 0.2 0.2')
end
end}
{if true then
{if not item then
local portals = {}
for i=1,5 do
local urls = app.opts[ 'plugin_federation_url_' .. i]
@ -68,5 +68,7 @@
addPortal('federated',center, {title=fediurl}, fediurl,i, 4, 'federated', '0 180 0', '0.1 0.1 0.1')
end
end}
<object id="cube" rotation="0 0 0" position="0 0 0" scale="2 0.1 2"/> <!-- something to stand on -->
${opts.plugin_janusxr_jml}
</room>
</fireboxroom>

View file

@ -101,6 +101,14 @@ local plugin = {
default='https://xrforge.isvery.ninja https://www.janusxr.org',
values=''
},
{
key='app.opts.plugin_janusxr_jml',
title='Extra JML',
info='Add extra <a href="https://coderofsalvation.github.io/janus-guide/#/build/room" target="_blank">JML</a> markup to each experience',
default = '<!-- see https://coderofsalvation.github.io/janus-guide for markup -->',
control='textarea',
values=''
}
},
getRandomRoom = function()
local me = app.plugin.janusxr

View file

@ -7,10 +7,12 @@ app.on('scan_experience_file', function(exp)
local me = app.plugin.xrfragments
foreach( util.split( app.opts.plugin_xrfragments_filetypes, ' '), function(k,ext)
if exp.path:lower():match("."..ext.."$") then
local hasHref = false
if ext == 'glb' then
exp.view3D = true
-- 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 hasHref = me.detectHrefInStruct(tree)
hasHref = me.detectHrefInStruct(tree)
end
-- check sidecarfiles: https://xrfragment.org/#sidecar%20files
local sidecarExts = {"png","vtt","ogg","json"}
@ -18,7 +20,6 @@ app.on('scan_experience_file', function(exp)
local sfile = exp.path:gsub("."..ext.."$", "."..sidecarExt)
if util.fileExist( sfile ) then
exp.sidecarfile[ sidecarExt ] = "/" .. util.stripPath(sfile)
exp.view3D = true
exp.parent.portal3D = false
end
end)
@ -31,7 +32,7 @@ app.on('scan_experience_file', function(exp)
if util.fileExist( jsonfile ) then
exp.sidecarfile.JSONXRF = me.detectHrefInStruct( json.decode( util.readfile(jsonfile) ) )
end
exp.tag.xrfragments = hasPNG or hasWebVTT or hasOGG or hasJSONref
exp.tag.xrfragments = hasHref or hasPNG or hasWebVTT or hasOGG or hasJSONref
if exp.tag.xrfragments then
print("✅ └─ plugin/xrfragments: detected xrfragments experience")
end