xrforge-v2/src/page/janusxr.html

128 lines
5.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-04 12:17:33 +02:00
local room = app.opts.plugin_janusxr_portalroom
if defined(item) and item.janusxr and item.janusxr.room then
room = item.janusxr.room
end
2026-08-04 12:17:33 +02:00
if room == 'random' then room = app.plugin.janusxr.getRandomRoom() end
if defined(item) and item.tag.xrfragments and item.tag.xrfragments.qualify then
room = '' -- xrfragments 3D files dont need to be wrapped with room
end
print(' <room skybox="true" showavatar="false" use_local_asset="' .. room .. '">')
if defined(item) then
print(' <object id="${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
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,
}
addPortal('parent',4, v, v.url, 0, 0, ' shader_id="defaultportal"', '0 -90 0', '0.2 0.2 0.2')
end}
<object id="cube" rotation="0 0 0" position="0 0 0" 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}