xrforge-v2/src/page/janusxr.html

165 lines
7.1 KiB
HTML
Raw Normal View History

2026-08-06 16:43:17 +02:00
{if true then
wrapperfile = (parent and parent.path or '') .. '/' .. app.opts.plugin_janusxr_wrap_custom
hasWrapperfile = util.fileExist(wrapperfile) and true or false
showfediportals = app.opts.plugin_federation_strategy == 'always' or
(app.opts.plugin_federation_strategy == 'homepage' and urlpath == '/')
2026-08-18 22:21:48 +02:00
-- optimize janus resource URLs for archive.org
app.plugin.archive.flush()
function URL(url)
url = util.baseURLify(url)
2026-08-18 22:21:48 +02:00
app.plugin.archive.add(url)
return url
end
2026-08-06 16:43:17 +02:00
end}
2026-08-06 16:43:17 +02:00
2026-08-04 12:17:33 +02:00
<fireboxroom>
<assets>
{if defined(items) and #items > 0 then
2026-08-04 12:17:33 +02:00
for i,v in pairs(items) do
if #v.thumbnail > 0 then
2026-08-18 22:21:48 +02:00
print('\t<assetimage src="' .. URL(v.thumbnail) .. '" id="img' .. i .. '"/>')
end
2026-08-04 12:17:33 +02:00
end
end}
{if defined(itemsremote) and #itemsremote > 0 then
for i,v in pairs(itemsremote) do
if #v.thumbnail > 0 then
2026-08-18 22:21:48 +02:00
print('\t<assetimage src="' .. URL(v.thumbnail) .. '" id="imgremote' .. i .. '"/>')
end
end
end}
2026-08-06 16:43:17 +02:00
{if showfediportals then
for i=1,5 do
local urls = app.opts[ 'plugin_federation_url_' .. i]
if #urls > 0 then
local fediurl = urls:gsub(' .*','')
local thumburl = urls:gsub('.* ','')
2026-08-18 22:21:48 +02:00
print('\t<assetimage src="' .. URL(thumburl) .. '" id="federated' .. i .. '"/>')
2026-08-06 16:43:17 +02:00
end
2026-08-04 12:17:33 +02:00
end
end}
</assets>
{if true then
2026-08-24 13:29:35 +02:00
local room = ''
pos = '0 0 0'
if not defined(item) and defined(items) then
room = app.opts.plugin_janusxr_portalroom
end
2026-09-24 18:17:25 +02:00
function initRoom(r)
if r.janusxr and r.janusxr.room then
2026-09-27 12:41:12 +02:00
pos = '0 0 2' -- todo make startup location configurable
2026-09-24 18:17:25 +02:00
room = r.janusxr.room
end
2026-08-24 13:29:35 +02:00
end
initRoom(item or {})
initRoom(itemdir or {})
if (hasWrapperfile == true) or (defined(item) and item.tag.xrfragments and item.tag.xrfragments.href) then
room = '' -- xrfragments 3D files dont need to be wrapped with room
end
2026-08-24 13:29:35 +02:00
print(' <room skybox="true" pos="' .. pos .. '" showavatar="false" use_local_asset="' .. room .. '">')
if room == 'empty_floor' then
print(' <!-- helper to be able to walk/teleport -->')
print(' <object id="plane" color_write="false" rotation="90 0 0" collision_id="plane" scale="100 100 1" collision_scale="100 100 1"/>')
end
if defined(item) then
2026-08-24 13:29:35 +02:00
print(' <object id="${item.url}"/>')
end
2026-08-04 12:17:33 +02:00
end}
2026-09-16 13:43:33 +02:00
<!-- <light js_id="dan9-janus:light/light_cone_angle=0-6" pos="0 3 2" collision_trigger="false" /> -->
2026-08-04 12:17:33 +02:00
<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 not defined(item) and defined(items) and #items > 0 then
local layout = itemdir.layout or ''
if #layout > 0 and app.plugin.janusxr.layout[ layout ] then
print( app.plugin.janusxr.layout[ layout ].render(items) )
else
print( app.plugin.janusxr.layout.portals.render(items) )
2026-08-04 12:17:33 +02:00
end
end}
{if not defined(item) and defined(itemsremote) and #itemsremote > 0 then
for i,v in pairs(itemsremote) do
local width = v.portal_width or tonumber( app.opts.plugin_global_portal_width )
2026-08-18 22:21:48 +02:00
local center = -((#itemsremote*width)/1.3) + (i*width)
local url = v.url
local thumb = ' shader_id="defaultportal" round="true"'
if #v.thumbnail > 0 then
thumb = ' thumb_id="imgremote' .. i .. '" '
end
if v.dir then url = url .. "/" end
if v.redirect then url = v.redirect end -- dont wrap standalone glb's in janusxr
print( app.plugin.janusxr.addPortal('remote',center, v, url,i, 4, thumb, '0 180 0', '0.2 0.2 0.2') )
2026-08-04 12:17:33 +02:00
end
print([[
<text js_id="locationremote" pos="0 6 5" billboard="y" col="#BBFFFF" scale="10 10 1" text="${opts.plugin_global_remote_title}" emissive="0 0 0" roughness="0.3" metalness="0" />
]])
2026-08-04 12:17:33 +02:00
end}
{if #referrer > 0 then
-- hardcoded reciprocal portal
local v = {
url = referrer,
title = app.opts.plugin_janusxr_portal_up,
}
print( app.plugin.janusxr.addPortal('parent',5, v, v.url, 0, 0, ' shader_id="defaultportal" round="true"', '0 -90 0', '0.2 0.2 0.2') )
end}
{if os.getenv('DEBUG') then
local plugins = {}
foreach(app.plugin, function(name,p)
if not tostring(name):match("[0-9]") then table.insert(plugins,name) end
end)
local embedsrc = EscapeFragment(
"config\n======\n" ..
util.dump({
plugins = plugins,
host = app.host,
protocol = app.scheme,
convert_assimp_filetypes_in = app.opts.plugin_convert_assimp_filetypes_in,
convert_assimp_filetypes_out = app.opts.plugin_convert_assimp_filetypes_out,
janusxr_portalroom = app.opts.plugin_janusxr_wrap_video,
janusxr_wrap_3dfile = app.opts.plugin_janusxr_wrap_3dfile,
janusxr_wrap_video = app.opts.plugin_janusxr_wrap_video,
janusxr_wrap_aframe = app.opts.plugin_janusxr_wrap_aframe,
janusxr_janusweb_corsproxies = util.split("https://p.janusxr.org https://cors.xrforge.org"," ")
})
)
print([[
<text text="Server statistics" position="-3 2.5 0" scale="3 3 3" rotation="0 90 0"/>
<paragraph id="encoded" url="/statusz" rotation="0 90 0" use_proxy="false" cull_face='none' position="-3 1 0.7" width="400" height="900" scale="0.6 1.2 1" lighting="false" css=".paragraphcontainer{height:100%; white-space: pre ; display: block; unicode-bidi: embed; border-radius:10px; background:#000; color:#AFF; font-family:monospace; padding:20px;}"/>
<paragraph id="encoded" rotation="0 90 0" url="data:text/plain,]] .. embedsrc .. [[" use_proxy="false" cull_face='none' position="-3 1 -0.7" width="400" height="900" scale="0.6 1.2 1" lighting="false" css=".paragraphcontainer{height:100%; white-space: pre ; display: block; unicode-bidi: embed; border-radius:10px; background:#000; color:#FAF; font-family:monospace; padding:20px;"/>
]])
end}
2026-08-24 13:29:35 +02:00
<object id="cube" rotation="0 45 0" pos="${pos}" scale="2 0.1 2"/> <!-- something to stand on -->
{if not defined(item) and hasWrapperfile == false then
print('${janusxr_jml_deco}')
end}
{if hasWrapperfile == true then
local wrapperURL = util.stripPath( parent.path .. '/' .. app.opts.plugin_janusxr_wrap_custom)
print(' <!-- inserted by XRForge server: ' .. app.opts.plugin_janusxr_wrap_custom .. ' -->')
print(' <link url="' .. wrapperURL .. '" url_pos="0 0 0" pos="0 0 1" url_scale="1 1 1" js_id="index_jml" auto_load="true" />')
end}
{if #opts.plugin_janusxr_jml > 0 then
print(' <!-- inserted by XRForge server: janusxr admin (Extra JML) -->')
print(' ' .. app.opts.plugin_janusxr_jml)
end}
2026-08-04 12:17:33 +02:00
</room>
</fireboxroom>
2026-08-18 22:21:48 +02:00
{if #app.plugin.archive.url > 0 then
print('<!-- this is purely to optimize JanusXR resource-URLs to (archive.org) scrapers -->')
print("<div style='display:none'>")
for k,url in pairs(app.plugin.archive.url) do
print(' <a href="' .. url .. '"></a>')
end
print("</div>")
end}