more tests + add tree-icon to playables
This commit is contained in:
parent
ebe8eb3cfb
commit
eab426e8b5
10 changed files with 114 additions and 34 deletions
BIN
src/myverse/tronverse/tronverse-icosagallery.jpg
Normal file
BIN
src/myverse/tronverse/tronverse-icosagallery.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
|
|
@ -39,7 +39,7 @@ end}
|
|||
<div class="grid">
|
||||
{if items then
|
||||
|
||||
function getURL(url)
|
||||
function getURL(url, item)
|
||||
if app.arg[1] == 'generate' or url:match("://") then
|
||||
url = '?view=3D#janus.url=' .. EscapeFragment( url )
|
||||
url = util.baseURLify(url)
|
||||
|
|
@ -54,15 +54,29 @@ end}
|
|||
local visible = item.view2D == nil or (item.view2D ~= nil and item.view2D ~= false)
|
||||
if visible then
|
||||
local icon = 'list-tree'
|
||||
local url = item.url
|
||||
local thumbnail = ''
|
||||
if #item.thumbnail > 0 then thumbnail = 'style="background-image: url(' .. EscapeFragment( util.stripPath(item.thumbnail) ) .. ');"' end
|
||||
if item.view3D or item.portal3D == false then icon = 'play' end
|
||||
if (item.view3D or item.portal3D == false)
|
||||
or (item.janusxr and item.janusxr.room)
|
||||
or (item.xrfragment and item.xrfragment.href)
|
||||
then
|
||||
url = url .. '?view=3D'
|
||||
icon = 'play'
|
||||
end
|
||||
print([[
|
||||
<div class="tile">
|
||||
<a href="]] .. getURL(item.url) .. [[">
|
||||
<a href="]] .. getURL(url) .. [[">
|
||||
<div class="img" ]] .. util.stripPath(thumbnail) .. [[></div>
|
||||
<div class="text">
|
||||
<img src="img/]] .. icon .. [[.svg" class="icon ]] .. icon .. [["/> <a href="]] .. getURL(item.url) .. [[">]] .. item.title .. [[</a>
|
||||
]] .. (
|
||||
item.janusxr and item.janusxr.room and [[
|
||||
<a href="]] .. getURL(item.url) .. [[" style="float:right">
|
||||
<img src="img/list-tree.svg" class="icon tree"/>
|
||||
</a>
|
||||
]] or ''
|
||||
) .. [[
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ end}
|
|||
<!-- <light js_id="dan9-janus:light/light_cone_angle=0-6" pos="0 3 2" collision_trigger="false" /> -->
|
||||
<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 ''
|
||||
local layout = (itemdir.janusxr and itemdir.janusxr.layout) or ''
|
||||
if #layout > 0 and app.plugin.janusxr.layout[ layout ] then
|
||||
print( app.plugin.janusxr.layout[ layout ].render(items) )
|
||||
else
|
||||
|
|
@ -81,7 +81,7 @@ 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 )
|
||||
local width = (v.janusxr and v.janusxr.portal_width) or tonumber( app.opts.plugin_global_portal_width )
|
||||
local center = -((#itemsremote*width)/1.3) + (i*width)
|
||||
local url = v.url
|
||||
local thumb = ' shader_id="defaultportal" round="true"'
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ local grid = {
|
|||
local turns = 0
|
||||
local index = 0
|
||||
for i, v in pairs(items) do
|
||||
jml = '<!-- ' .. util.dump(v) .. ' -->\n'
|
||||
local url = v.redirect and v.redirect or v.url
|
||||
local overlay = v.title:match('overlay') and true or false
|
||||
-- Position current item
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ local portals = {
|
|||
local jml = ''
|
||||
for i,v in pairs(items) do
|
||||
local url = v.url
|
||||
local width = tonumber(app.opts.plugin_global_portal_width )
|
||||
local width = util.pluck('parent.janusxr.portal_width', v, false) or app.opts.plugin_global_portal_width
|
||||
width = tonumber(width)
|
||||
local thumb = ' shader_id="defaultportal"'
|
||||
if #v.thumbnail > 0 then
|
||||
thumb = ' thumb_id="img' .. i .. '" '
|
||||
if v.portal_width then width = tonumber(v.portal_width) end
|
||||
end
|
||||
local center = -((#items*width)/1.3) + (i*width)
|
||||
if v.dir then url = url .. "/" end
|
||||
|
|
|
|||
|
|
@ -11,32 +11,42 @@ local function scanTiltFile(exp)
|
|||
end
|
||||
end
|
||||
|
||||
local function scanForOpenBrush(exp)
|
||||
local tags = app.plugin.openbrush.tags
|
||||
if not tags then
|
||||
tags = util.split( app.opts.plugin_openbrush_sync_hashtag, ' ')
|
||||
table.insert( tags,"openbrush")
|
||||
app.plugin.openbrush.tags = tags
|
||||
end
|
||||
local function scanForOpenBrush(exp,opts)
|
||||
local tags = app.plugin.openbrush.getTags()
|
||||
foreach( tags, function(k,tag)
|
||||
tag = tag:gsub("#","")
|
||||
if exp.path:match('/' .. tag:gsub("-","%%-") .. '/') then -- might not be precise enough
|
||||
if not exp.parent.janusxr then
|
||||
exp.parent.janusxr = {}
|
||||
if exp.url:match( app.plugin.openbrush.pattern.collection(tag) ) then -- collection
|
||||
if not exp.janusxr then
|
||||
exp.janusxr = {}
|
||||
end
|
||||
exp.parent.janusxr.room = app.opts[ "plugin_openbrush_wrap_room_" .. app.opts.plugin_openbrush_layout ] or 'empty'
|
||||
exp.parent.portal_width = tonumber( app.opts.plugin_openbrush_portal_width )
|
||||
exp.parent.grid_size = tonumber( app.opts.plugin_openbrush_grid_size )
|
||||
exp.parent.layout = app.opts.plugin_openbrush_layout
|
||||
exp.janusxr.layout = app.opts.plugin_openbrush_layout
|
||||
exp.janusxr.room = app.opts[ "plugin_openbrush_wrap_room_" .. app.opts.plugin_openbrush_layout ] or 'empty'
|
||||
exp.janusxr.portal_width = tonumber( app.opts.plugin_openbrush_portal_width )
|
||||
exp.janusxr.grid_size = tonumber( app.opts.plugin_openbrush_grid_size )
|
||||
end
|
||||
end)
|
||||
scanTiltFile(exp)
|
||||
end
|
||||
|
||||
|
||||
app.on('scan_experience', scanForOpenBrush )
|
||||
app.on('scan_experience_file', scanForOpenBrush )
|
||||
app.on("scan_experience_janusxr", function(opts) scanForOpenBrush(opts.exp) end)
|
||||
app.on('scan_experience', function(exp) scanForOpenBrush(exp,{dir=true}) end)
|
||||
app.on('scan_experience_janusxr', function(opts)
|
||||
local exp = opts.exp
|
||||
if exp then
|
||||
local tags = app.plugin.openbrush.getTags()
|
||||
foreach( tags, function(k,tag)
|
||||
tag = tag:gsub("#","")
|
||||
if exp.url:match( app.plugin.openbrush.pattern.asset(tag) ) then -- asset
|
||||
-- disable janusxr room wrapping (if any)
|
||||
exp.janusxr = nil
|
||||
-- also for the parent, and redirect to indirect child asset
|
||||
if exp.parent.layout == nil and exp.parent.janusxr then
|
||||
exp.parent.janusxr = nil
|
||||
exp.parent.redirect = exp.url
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
app.on('set', function(k,v)
|
||||
end)
|
||||
|
|
@ -62,7 +72,7 @@ local plugin = {
|
|||
key='app.opts.plugin_openbrush_layout',
|
||||
title='Layout assets',
|
||||
info='NOTE: use #overlay in asset-title to skip layout (sky/floor/e.g.)',
|
||||
default="grid",
|
||||
default="portals",
|
||||
values={portals="As portals", grid="As grid"}
|
||||
},
|
||||
{
|
||||
|
|
@ -205,6 +215,21 @@ local plugin = {
|
|||
}
|
||||
},
|
||||
|
||||
pattern = {
|
||||
collection = function(tag) return '/' .. tag:gsub("-","%%-") .. '$' end,
|
||||
asset = function(tag) return '/' .. tag:gsub("-","%%-") .. '/' end,
|
||||
},
|
||||
|
||||
getTags = function()
|
||||
local tags = app.plugin.openbrush.tags
|
||||
if not tags then
|
||||
tags = util.split( app.opts.plugin_openbrush_sync_hashtag, ' ')
|
||||
table.insert( tags,"openbrush")
|
||||
app.plugin.openbrush.tags = tags
|
||||
end
|
||||
return tags
|
||||
end,
|
||||
|
||||
-- expected by src/.lua/apiSync.lua
|
||||
apiCall = function(tag)
|
||||
return 'https://api.' .. app.opts.plugin_openbrush_sync_URL .. '/v1/assets?xrforge=' .. EscapeFragment(app.host)
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ local describe, it, expect = lust.describe, lust.it, lust.expect
|
|||
|
||||
lust.queueServerRequest = util.queueServerRequest
|
||||
|
||||
--require('test/plugin_global')(lust)
|
||||
--require('test/plugin_git')(lust)
|
||||
--require('test/plugin_diskscan')(lust)
|
||||
--require('test/plugin_xrfragment')(lust)
|
||||
require('test/plugin_global')(lust)
|
||||
require('test/plugin_git')(lust)
|
||||
require('test/plugin_diskscan')(lust)
|
||||
require('test/plugin_xrfragment')(lust)
|
||||
require('test/plugin_janusxr')(lust)
|
||||
--require('test/plugin_openbrush')(lust)
|
||||
--require('test/util')(lust)
|
||||
require('test/plugin_openbrush')(lust)
|
||||
require('test/util')(lust)
|
||||
|
||||
if lust.errors == 0 then
|
||||
print("✅ all tests passed")
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ return function(lust)
|
|||
app.init()
|
||||
local destdir = app.opts.plugin_diskscan_dir .. '/' .. 'xrfragment'
|
||||
expect( util.fileExist( destdir ) ).to.be.truthy()
|
||||
os.execute('rm -rf ' .. destdir)
|
||||
end)
|
||||
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,25 @@ return function(lust)
|
|||
|
||||
describe('ℹ️ wrap AFRAME file', function() -- Can be nested
|
||||
it('detect & serve to iframe', function()
|
||||
-- *TODO*
|
||||
app.init()
|
||||
app.use( require('page/dir').middleware )
|
||||
app.use( app.response() )
|
||||
app.on('response', function(opts)
|
||||
expect( not opts.res._body:match('use_local_asset=""') ).to.be.truthy()
|
||||
expect( not opts.res._body:match('<object id="/myverse/janusxr_tutorial/AFRAME/index.html"/>') ).to.be.truthy()
|
||||
end)
|
||||
|
||||
local url = '/myverse/janusxr_tutorial/AFRAME'
|
||||
|
||||
foreach(app.cache.items, function(k,exp)
|
||||
if exp.url:match(url) then
|
||||
if exp.url:match( url .. "$") then
|
||||
--print_r(exp)
|
||||
lust.queueServerRequest('GET', url, nil, nil, nil, nil, nil, 8080 )
|
||||
app.run()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,29 @@ return function(lust)
|
|||
expect( t.assets and #t.assets > 0 ).to.be.truthy()
|
||||
end)
|
||||
|
||||
describe('ℹ️ grid-layout', function() -- Can be nested
|
||||
it('unwrap janusxr-room for assets', function()
|
||||
app.init()
|
||||
app.use( require('page/dir').middleware )
|
||||
app.use( app.response() )
|
||||
app.on('response', function(opts)
|
||||
expect( not opts.res._body:match('/myverse/tronverse/tronverse-icosagallery/_0dycp4HDxf4-tronverse_floor-overlay-tronverse-icosagallery/tronverse_floor.glb') ).to.be.truthy()
|
||||
end)
|
||||
|
||||
local url = '/myverse/tronverse/tronverse-icosagallery'
|
||||
|
||||
foreach(app.cache.items, function(k,exp)
|
||||
if exp.url:match(url) then
|
||||
if exp.url:match( url .. "$") then
|
||||
--print_r(exp)
|
||||
lust.queueServerRequest('GET', url, nil, nil, nil, nil, nil, 8080 )
|
||||
app.run()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
--describe('download icosa.gallery assets', function() -- Can be nested
|
||||
-- local json = util.readfile('/zip/test/json/icosagallery.json')
|
||||
-- local opts = {body=json}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue