xrforge-v2/src/page/janusxr.html

166 lines
7.1 KiB
HTML
Raw Normal View History

2026-08-06 16:43:17 +02:00
{if true then
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-08-24 13:29:35 +02:00
if defined(item) and item.janusxr and item.janusxr.wrap then
pos = '0 0 2'
room = app.plugin.janusxr.wrapRoomAroundFile(item)
end
if 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 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}
<light js_id="dan9-janus:light/light_cone_angle=0-6" pos="0 3 2" collision_trigger="false" />
{if true then
2026-08-18 22:21:48 +02:00
function addPortal(id,x,v,url,i,z,thumb,rotation,scale)
local title = v.title
print('\t<object js_id="' .. id .. '_' .. i .. '" pos="' .. x .. ' 0 ' .. z .. '" rotation="' .. rotation .. '">')
print('\t <link url="' .. util.baseURLify(url) .. '" ' .. thumb .. ' title_col="0.4 0.37 0.4" pos="0 0 0.001" draw_glow="' .. (thumb:match("shader") and 'false' or 'true') .. '" scale="3 3 0.1" />')
print('\t <text text="' .. util.truncate(title,20) .. '" pos="0 3.4 0" col="1 1 1" font_scale="false" scale="' .. scale .. '" />')
2026-08-18 15:30:10 +02:00
--TODO: fix janusweb paragraph for markdown urls
2026-08-18 22:21:48 +02:00
--if v.README ~= nil then
-- print('\t <paragraph js_id="README" url="' .. v.README .. '" width="600" height="900" pos="0 1 2" transparent="true"/>')
2026-08-18 15:30:10 +02:00
--end
print('\t</object>')
2026-08-04 12:17:33 +02:00
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 not defined(item) and defined(items) and #items > 0 then
2026-08-04 12:17:33 +02:00
for i,v in pairs(items) do
local width = 3.2
local center = -((#items*width)/1.3) + (i*width)
local url = v.url
local thumb = ' shader_id="defaultportal"'
if #v.thumbnail > 0 then
thumb = ' thumb_id="img' .. i .. '" '
end
2026-08-04 12:17:33 +02:00
if v.dir then url = url .. "/" end
if v.redirect then url = v.redirect end -- dont wrap standalone glb's in janusxr
2026-08-18 22:21:48 +02:00
addPortal('dir',center, v, url,i, -4, thumb, '0 0 0', '0.2 0.2 0.2')
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
2026-08-18 22:21:48 +02:00
local width = 3.2
local center = -((#itemsremote*width)/1.3) + (i*width)
local url = v.url
2026-08-24 13:29:35 +02:00
--if url:match("://") then
-- url = url .. ( url:match("#") and '&' or '#' ) .. 'janus.referrer=' ..
-- EscapeFragment( util.getURL() )
--end
local thumb = ' shader_id="defaultportal"'
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
2026-08-18 22:21:48 +02:00
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,
}
2026-08-24 13:29:35 +02:00
addPortal('parent',5, v, v.url, 0, 0, ' shader_id="defaultportal"', '0 -90 0', '0.2 0.2 0.2')
end}
{if isroot 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) then
print('${janusxr_jml_deco}')
end}
${opts.plugin_janusxr_jml}
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}