diff --git a/.gitignore b/.gitignore index 22053dd..06ece14 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ result src/janusweb janusweb* ./myverse +src/myverse/tronverse/tronverse-icosagallery diff --git a/run.sh b/run.sh index 8f43100..3b52810 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,5 @@ #!/bin/sh source ./.env rebuild +rm result/bin/xrforge.lua || true DEBUG=1 result/bin/xrforge.com -c 0 "$@" --nobrowser diff --git a/src/.init.lua b/src/.init.lua index 4f3dd31..3630b16 100644 --- a/src/.init.lua +++ b/src/.init.lua @@ -58,9 +58,14 @@ app.addExperience = function(experience, ino) end end -app.markViewable = function(exp) - exp.view3D = true - exp.parent.redirect = exp.url -- mark parent to redirect to this standalone url instead (not glb assets e.g.) +app.markViewable = function(exp, priority) + -- priority decides which 3D viewable wins (in case of multiple candidates inside same dir) + -- 0-100 markup experiences (high prio) + -- 100-200 3D model files + exp.view3D = priority or 300 + if exp.parent.view3D == nil or exp.parent.view3D > priority then + exp.parent.redirect = exp.url -- mark parent to redirect to this standalone url instead (not glb assets e.g.) + end end -- api skeleton (implemented via soakbean's app.on(...)) diff --git a/src/myverse/janusxr_tutorial/arwindow/Walk in the Woods by Don Carson - 38m6Q1H12DU.glb b/src/myverse/janusxr_tutorial/arwindow/Walk in the Woods by Don Carson - 38m6Q1H12DU.glb new file mode 100644 index 0000000..c1fe12d Binary files /dev/null and b/src/myverse/janusxr_tutorial/arwindow/Walk in the Woods by Don Carson - 38m6Q1H12DU.glb differ diff --git a/src/myverse/janusxr_tutorial/arwindow/index.html b/src/myverse/janusxr_tutorial/arwindow/index.html new file mode 100644 index 0000000..5af3725 --- /dev/null +++ b/src/myverse/janusxr_tutorial/arwindow/index.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/myverse/janusxr_tutorial/arwindow/occludebox.glb b/src/myverse/janusxr_tutorial/arwindow/occludebox.glb new file mode 100644 index 0000000..f6f0fe9 Binary files /dev/null and b/src/myverse/janusxr_tutorial/arwindow/occludebox.glb differ diff --git a/src/myverse/tronverse/tronverse-icosagallery/README.md b/src/myverse/tronverse/tronverse-icosagallery/README.md index 3464c2d..05746e3 100644 --- a/src/myverse/tronverse/tronverse-icosagallery/README.md +++ b/src/myverse/tronverse/tronverse-icosagallery/README.md @@ -57,4 +57,4 @@ You've got this! This virtual world is generated in realtime via icosa.gallery. You can add/create parcels in icosa.gallery, by publishing via OpenBrush, OpenBlocks, or Blender.
-> NOTE: Make sure to add hashtag **#tronverse-icosagallery** to the title (and re-run xrforge for fast re-sync). \ No newline at end of file +> NOTE: Make sure to add hashtag **#tronverse-icosagallery** to the title (and re-run xrforge for fast re-sync). diff --git a/src/myverse/tronverse/tronverse-icosagallery/_0dycp4HDxf4-tronverse_floor-overlay-tronverse-icosagallery.jpg b/src/myverse/tronverse/tronverse-icosagallery/_0dycp4HDxf4-tronverse_floor-overlay-tronverse-icosagallery.jpg deleted file mode 100644 index 4e41bc7..0000000 Binary files a/src/myverse/tronverse/tronverse-icosagallery/_0dycp4HDxf4-tronverse_floor-overlay-tronverse-icosagallery.jpg and /dev/null differ diff --git a/src/myverse/tronverse/tronverse-icosagallery/_0dycp4HDxf4-tronverse_floor-overlay-tronverse-icosagallery/asset.json b/src/myverse/tronverse/tronverse-icosagallery/_0dycp4HDxf4-tronverse_floor-overlay-tronverse-icosagallery/asset.json deleted file mode 100644 index a14e1d0..0000000 --- a/src/myverse/tronverse/tronverse-icosagallery/_0dycp4HDxf4-tronverse_floor-overlay-tronverse-icosagallery/asset.json +++ /dev/null @@ -1 +0,0 @@ -{"assetId":"0dycp4HDxf4","authorId":"9Vkr0htmSzc","authorName":"coderofsalvation","createTime":"2026-09-15T13:03:05.314Z","description":"","displayName":"tronverse_floor #overlay #tronverse-icosagallery","formats":[{"formatComplexity":{},"formatType":"GLTF2","isCorsAllowed":true,"isPreferredForDownload":true,"isPreferredForGalleryViewer":true,"resources":[],"role":"USER_SUPPLIED_GLTF","root":{"contentType":"model\/gltf-binary","relativePath":"tronverse_floor.glb","url":"https:\/\/s3.us-east-005.backblazeb2.com\/icosa-gallery\/icosa\/28534\/755050994710086613\/GLTF2\/tronverse_floor.glb"}}],"isCurated":false,"isIcosaGalleryCompatible":true,"license":"CREATIVE_COMMONS_BY","licenseVersion":"4.0","name":"assets\/0dycp4HDxf4","thumbnail":{"relativePath":"preview_image.jpg","url":"https:\/\/s3.us-east-005.backblazeb2.com\/icosa-gallery\/icosa\/28534\/755050994710086613\/preview_image.jpg"},"triangleCount":0,"updateTime":"2026-09-16T11:21:33.683Z","url":"http:\/\/api.icosa.gallery\/v1\/assets\/0dycp4HDxf4","visibility":"PUBLIC"} \ No newline at end of file diff --git a/src/myverse/tronverse/tronverse-icosagallery/_0dycp4HDxf4-tronverse_floor-overlay-tronverse-icosagallery/tronverse_floor.glb b/src/myverse/tronverse/tronverse-icosagallery/_0dycp4HDxf4-tronverse_floor-overlay-tronverse-icosagallery/tronverse_floor.glb deleted file mode 100644 index a47f7f8..0000000 Binary files a/src/myverse/tronverse/tronverse-icosagallery/_0dycp4HDxf4-tronverse_floor-overlay-tronverse-icosagallery/tronverse_floor.glb and /dev/null differ diff --git a/src/myverse/tronverse/tronverse-icosagallery/_C9J0_dyCzd8-tronverse_parcel_empty-tronverse-icosagallery.jpg b/src/myverse/tronverse/tronverse-icosagallery/_C9J0_dyCzd8-tronverse_parcel_empty-tronverse-icosagallery.jpg deleted file mode 100644 index 3be4612..0000000 Binary files a/src/myverse/tronverse/tronverse-icosagallery/_C9J0_dyCzd8-tronverse_parcel_empty-tronverse-icosagallery.jpg and /dev/null differ diff --git a/src/myverse/tronverse/tronverse-icosagallery/_C9J0_dyCzd8-tronverse_parcel_empty-tronverse-icosagallery/asset.json b/src/myverse/tronverse/tronverse-icosagallery/_C9J0_dyCzd8-tronverse_parcel_empty-tronverse-icosagallery/asset.json deleted file mode 100644 index d00768d..0000000 --- a/src/myverse/tronverse/tronverse-icosagallery/_C9J0_dyCzd8-tronverse_parcel_empty-tronverse-icosagallery/asset.json +++ /dev/null @@ -1 +0,0 @@ -{"assetId":"C9J0_dyCzd8","authorId":"9Vkr0htmSzc","authorName":"coderofsalvation","createTime":"2026-09-15T18:22:06.894Z","description":"copy this asset as a starting point to paint into","displayName":"tronverse_parcel_empty #tronverse-icosagallery","formats":[{"formatComplexity":{},"formatType":"GLTF2","isCorsAllowed":true,"isPreferredForDownload":true,"isPreferredForGalleryViewer":true,"resources":[],"role":"USER_SUPPLIED_GLTF","root":{"contentType":"model\/gltf-binary","relativePath":"tronverse_parcel_empty.glb","url":"https:\/\/s3.us-east-005.backblazeb2.com\/icosa-gallery\/icosa\/28534\/755131280311452630\/GLTF2\/tronverse_parcel_empty.glb"}}],"isCurated":false,"isIcosaGalleryCompatible":true,"license":"CREATIVE_COMMONS_BY","licenseVersion":"4.0","name":"assets\/C9J0_dyCzd8","thumbnail":{"relativePath":"preview_image.jpg","url":"https:\/\/s3.us-east-005.backblazeb2.com\/icosa-gallery\/icosa\/28534\/755131280311452630\/preview_image.jpg"},"triangleCount":0,"updateTime":"2026-09-16T11:21:20.762Z","url":"http:\/\/api.icosa.gallery\/v1\/assets\/C9J0_dyCzd8","visibility":"PUBLIC"} \ No newline at end of file diff --git a/src/myverse/tronverse/tronverse-icosagallery/_C9J0_dyCzd8-tronverse_parcel_empty-tronverse-icosagallery/tronverse_parcel_empty.glb b/src/myverse/tronverse/tronverse-icosagallery/_C9J0_dyCzd8-tronverse_parcel_empty-tronverse-icosagallery/tronverse_parcel_empty.glb deleted file mode 100644 index ae2bda2..0000000 Binary files a/src/myverse/tronverse/tronverse-icosagallery/_C9J0_dyCzd8-tronverse_parcel_empty-tronverse-icosagallery/tronverse_parcel_empty.glb and /dev/null differ diff --git a/src/myverse/tronverse/tronverse-icosagallery/_igTGJIhJcSw-tronverse_parcel3-tronverse-icosagallery.jpg b/src/myverse/tronverse/tronverse-icosagallery/_igTGJIhJcSw-tronverse_parcel3-tronverse-icosagallery.jpg deleted file mode 100644 index 77c8489..0000000 Binary files a/src/myverse/tronverse/tronverse-icosagallery/_igTGJIhJcSw-tronverse_parcel3-tronverse-icosagallery.jpg and /dev/null differ diff --git a/src/myverse/tronverse/tronverse-icosagallery/_igTGJIhJcSw-tronverse_parcel3-tronverse-icosagallery/asset.json b/src/myverse/tronverse/tronverse-icosagallery/_igTGJIhJcSw-tronverse_parcel3-tronverse-icosagallery/asset.json deleted file mode 100644 index 5a760af..0000000 --- a/src/myverse/tronverse/tronverse-icosagallery/_igTGJIhJcSw-tronverse_parcel3-tronverse-icosagallery/asset.json +++ /dev/null @@ -1 +0,0 @@ -{"assetId":"igTGJIhJcSw","authorId":"9Vkr0htmSzc","authorName":"coderofsalvation","createTime":"2026-09-16T10:16:05.148Z","description":"","displayName":"tronverse_parcel3 #tronverse-icosagallery","formats":[{"formatComplexity":{},"formatType":"GLTF2","isCorsAllowed":true,"isPreferredForDownload":true,"isPreferredForGalleryViewer":true,"resources":[],"role":"USER_SUPPLIED_GLTF","root":{"contentType":"model\/gltf-binary","relativePath":"tronverse_parcel3.glb","url":"https:\/\/s3.us-east-005.backblazeb2.com\/icosa-gallery\/icosa\/28534\/755371354949157841\/GLTF2\/tronverse_parcel3.glb"}}],"isCurated":false,"isIcosaGalleryCompatible":true,"license":"CREATIVE_COMMONS_BY","licenseVersion":"4.0","name":"assets\/igTGJIhJcSw","thumbnail":{"relativePath":"preview_image.jpg","url":"https:\/\/s3.us-east-005.backblazeb2.com\/icosa-gallery\/icosa\/28534\/755371354949157841\/preview_image.jpg"},"triangleCount":0,"updateTime":"2026-09-16T11:20:41.832Z","url":"http:\/\/api.icosa.gallery\/v1\/assets\/igTGJIhJcSw","visibility":"PUBLIC"} \ No newline at end of file diff --git a/src/myverse/tronverse/tronverse-icosagallery/_igTGJIhJcSw-tronverse_parcel3-tronverse-icosagallery/tronverse_parcel3.glb b/src/myverse/tronverse/tronverse-icosagallery/_igTGJIhJcSw-tronverse_parcel3-tronverse-icosagallery/tronverse_parcel3.glb deleted file mode 100644 index 47a82db..0000000 Binary files a/src/myverse/tronverse/tronverse-icosagallery/_igTGJIhJcSw-tronverse_parcel3-tronverse-icosagallery/tronverse_parcel3.glb and /dev/null differ diff --git a/src/myverse/tronverse/tronverse-icosagallery/_mRU7wJh9BLQ-tronverse_parcel1-tronverse-icosagallery.jpg b/src/myverse/tronverse/tronverse-icosagallery/_mRU7wJh9BLQ-tronverse_parcel1-tronverse-icosagallery.jpg deleted file mode 100644 index e7cbafd..0000000 Binary files a/src/myverse/tronverse/tronverse-icosagallery/_mRU7wJh9BLQ-tronverse_parcel1-tronverse-icosagallery.jpg and /dev/null differ diff --git a/src/myverse/tronverse/tronverse-icosagallery/_mRU7wJh9BLQ-tronverse_parcel1-tronverse-icosagallery/asset.json b/src/myverse/tronverse/tronverse-icosagallery/_mRU7wJh9BLQ-tronverse_parcel1-tronverse-icosagallery/asset.json deleted file mode 100644 index ea5de32..0000000 --- a/src/myverse/tronverse/tronverse-icosagallery/_mRU7wJh9BLQ-tronverse_parcel1-tronverse-icosagallery/asset.json +++ /dev/null @@ -1 +0,0 @@ -{"assetId":"mRU7wJh9BLQ","authorId":"9Vkr0htmSzc","authorName":"coderofsalvation","createTime":"2026-09-15T11:44:11.217Z","description":"","displayName":"tronverse_parcel1 #tronverse-icosagallery","formats":[{"formatComplexity":{},"formatType":"GLTF2","isCorsAllowed":true,"isPreferredForDownload":true,"isPreferredForGalleryViewer":true,"resources":[],"role":"USER_SUPPLIED_GLTF","root":{"contentType":"model\/gltf-binary","relativePath":"tronverse_parcel1.glb","url":"https:\/\/s3.us-east-005.backblazeb2.com\/icosa-gallery\/icosa\/28534\/755031138472297450\/GLTF2\/tronverse_parcel1.glb"}}],"isCurated":false,"isIcosaGalleryCompatible":true,"license":"CREATIVE_COMMONS_BY","licenseVersion":"4.0","name":"assets\/mRU7wJh9BLQ","thumbnail":{"relativePath":"preview_image.jpg","url":"https:\/\/s3.us-east-005.backblazeb2.com\/icosa-gallery\/icosa\/28534\/755031138472297450\/preview_image.jpg"},"triangleCount":0,"updateTime":"2026-09-16T11:21:48.917Z","url":"http:\/\/api.icosa.gallery\/v1\/assets\/mRU7wJh9BLQ","visibility":"PUBLIC"} \ No newline at end of file diff --git a/src/myverse/tronverse/tronverse-icosagallery/_mRU7wJh9BLQ-tronverse_parcel1-tronverse-icosagallery/tronverse_parcel1.glb b/src/myverse/tronverse/tronverse-icosagallery/_mRU7wJh9BLQ-tronverse_parcel1-tronverse-icosagallery/tronverse_parcel1.glb deleted file mode 100644 index 2a9b91b..0000000 Binary files a/src/myverse/tronverse/tronverse-icosagallery/_mRU7wJh9BLQ-tronverse_parcel1-tronverse-icosagallery/tronverse_parcel1.glb and /dev/null differ diff --git a/src/myverse/tronverse/tronverse-icosagallery/_oiIu1aNn6Ek-tronverse_parcel2-overlay-tronverse-icosagallery.jpg b/src/myverse/tronverse/tronverse-icosagallery/_oiIu1aNn6Ek-tronverse_parcel2-overlay-tronverse-icosagallery.jpg deleted file mode 100644 index 9e37069..0000000 Binary files a/src/myverse/tronverse/tronverse-icosagallery/_oiIu1aNn6Ek-tronverse_parcel2-overlay-tronverse-icosagallery.jpg and /dev/null differ diff --git a/src/myverse/tronverse/tronverse-icosagallery/_oiIu1aNn6Ek-tronverse_parcel2-overlay-tronverse-icosagallery/asset.json b/src/myverse/tronverse/tronverse-icosagallery/_oiIu1aNn6Ek-tronverse_parcel2-overlay-tronverse-icosagallery/asset.json deleted file mode 100644 index af66c17..0000000 --- a/src/myverse/tronverse/tronverse-icosagallery/_oiIu1aNn6Ek-tronverse_parcel2-overlay-tronverse-icosagallery/asset.json +++ /dev/null @@ -1 +0,0 @@ -{"assetId":"oiIu1aNn6Ek","authorId":"9Vkr0htmSzc","authorName":"coderofsalvation","createTime":"2026-09-16T10:06:44.019Z","description":"","displayName":"tronverse_parcel2 #overlay #tronverse-icosagallery","formats":[{"formatComplexity":{},"formatType":"GLTF2","isCorsAllowed":true,"isPreferredForDownload":true,"isPreferredForGalleryViewer":true,"resources":[],"role":"USER_SUPPLIED_GLTF","root":{"contentType":"model\/gltf-binary","relativePath":"tronverse_parcel2.glb","url":"https:\/\/s3.us-east-005.backblazeb2.com\/icosa-gallery\/icosa\/28534\/755369001416131548\/GLTF2\/tronverse_parcel2.glb"}}],"isCurated":false,"isIcosaGalleryCompatible":true,"license":"CREATIVE_COMMONS_BY","licenseVersion":"4.0","name":"assets\/oiIu1aNn6Ek","thumbnail":{"relativePath":"preview_image.jpg","url":"https:\/\/s3.us-east-005.backblazeb2.com\/icosa-gallery\/icosa\/28534\/755369001416131548\/preview_image.jpg"},"triangleCount":0,"updateTime":"2026-09-16T11:20:54.904Z","url":"http:\/\/api.icosa.gallery\/v1\/assets\/oiIu1aNn6Ek","visibility":"PUBLIC"} \ No newline at end of file diff --git a/src/myverse/tronverse/tronverse-icosagallery/_oiIu1aNn6Ek-tronverse_parcel2-overlay-tronverse-icosagallery/tronverse_parcel2.glb b/src/myverse/tronverse/tronverse-icosagallery/_oiIu1aNn6Ek-tronverse_parcel2-overlay-tronverse-icosagallery/tronverse_parcel2.glb deleted file mode 100644 index 8721763..0000000 Binary files a/src/myverse/tronverse/tronverse-icosagallery/_oiIu1aNn6Ek-tronverse_parcel2-overlay-tronverse-icosagallery/tronverse_parcel2.glb and /dev/null differ diff --git a/src/page/dir.lua b/src/page/dir.lua index 6b21820..148403d 100644 --- a/src/page/dir.lua +++ b/src/page/dir.lua @@ -23,7 +23,7 @@ return { and not urlpath:gsub(".*/",""):match("%.") -- no regular file with extension then - local redirect = false + local http_redirect = false if not app.cache.url[ urlhash ] or util.count(req.params) > 0 then local matchpath = urlpath -- generate janusxr footer / rss for root url @@ -65,6 +65,8 @@ return { end end) + -- see if we can get a viewable 3D item + local data = util.merge({ janusurl = req.param.url, -- query hint to render janus.url in iframe (index.html) items = {}, @@ -82,20 +84,26 @@ return { i=i+1 if v.view3D then local isMarkupExperience = function(v) - return v.janusxr and (v.janusxr.jml or v.janusxr.wrap) + v = v or {} + return v.janusxr and v.janusxr.wrap end + + -- *TODO* modularize this logic into plugins better + -- prioritize markup experience above binary 3D files as experience containers - if not data.item or (isMarkupExperience(v) and not isMarkupExperience(data.item)) then + if data.item == nil or (isMarkupExperience(v) and not isMarkupExperience(data.item)) then -- update referrer url data.referrer = util.baseURLify(v.view3D and (v.parent.parent and v.parent.parent.url) or v.parent.url) data.item = v data.title = data.item.title data.parent = v.parent - data.janusurl = (v.janusxr and v.janusxr.wrap) and - app.opts.baseurl .. util.stripPath(v.parent.url) - or - app.opts.baseurl .. util.stripPath(v.url) - if v.janusxr and (v.janusxr.jml or v.janusxr.wrap and v.janusxr.wrap.aframe) then + -- *TODO* modularize this logic into plugins better + data.janusurl = (v.janusxr and v.janusxr.wrap) and app.opts.baseurl .. util.stripPath(v.url) + -- if parent has redirect to item set, use parent url + if not data.janusurl or v.parent.redirect == v.url then + data.janusurl = app.opts.baseurl .. util.stripPath(v.parent.url) + end + if v.janusxr and v.janusxr.wrap and v.janusxr.wrap.file then -- what to do here? no generated portals? data.janusxr = app.tpl( util.readfile(v.path), data ) end @@ -108,14 +116,14 @@ return { res.template = 'page/rss.xml' end app.pub("dir", nil, {res=res,data=data, urlpath=urlpath, isroot=isroot, isdir=isdir}) - if not redirect then + if not http_redirect then app.cache.url[ urlhash ] = util.templateFile( res.template, data) end end - if redirect then - print("REDIRECT! " .. redirect ) + if http_redirect then + print("REDIRECT! " .. http_redirect ) res.status(303) - res.header('Location', redirect ) + res.header('Location', http_redirect ) next() else res.status(200) diff --git a/src/page/janusxr.html b/src/page/janusxr.html index 1113cf0..9f9973e 100644 --- a/src/page/janusxr.html +++ b/src/page/janusxr.html @@ -61,6 +61,10 @@ end} room = '' -- xrfragments 3D files dont need to be wrapped with room end print(' ') + if room == 'empty_floor' then + print(' ') + print(' ') + end if defined(item) then print(' ') end @@ -80,7 +84,7 @@ end} local width = v.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"' + local thumb = ' shader_id="defaultportal" round="true"' if #v.thumbnail > 0 then thumb = ' thumb_id="imgremote' .. i .. '" ' end @@ -99,7 +103,7 @@ end} url = referrer, title = app.opts.plugin_janusxr_portal_up, } - print( app.plugin.janusxr.addPortal('parent',5, v, v.url, 0, 0, ' shader_id="defaultportal"', '0 -90 0', '0.2 0.2 0.2') ) + 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 diff --git a/src/plugin/janusxr.lua b/src/plugin/janusxr.lua index f3db9a1..e9f4798 100644 --- a/src/plugin/janusxr.lua +++ b/src/plugin/janusxr.lua @@ -21,23 +21,6 @@ app.on('scan_experience_file', function(exp) local size = exp.file.attr:size() local wrap = false - if app.opts.plugin_janusxr_wrap_3dfile ~= "disabled" - and not (exp.tag.xrfragments and exp.tag.xrfragments.qualify) then -- dont wrap xrfragments experience - foreach( me.ext.object, function(k,ext) - if exp.path:lower():match("."..ext.."$") then - wrap = ext - end - end) - if wrap then - app.markViewable(exp) - exp.janusxr = { wrap = { object = true }} - exp.janusxr.room = me.wrapRoomAroundFile( exp ) - app.pub("scan_experience_janusxr", nil, {exp=exp, item=item}) -- be nice to other plugins - app.addExperience( exp, exp.file.ino ) - print("✅ └─ plugin/janusxr: wrapping " .. exp.path) - end - end - if (not me.isWrapFile(exp.path)) and size < 100000 then -- skip large binary files > 100kb local data = util.readfile( exp.file.fullpath) if data then @@ -47,12 +30,18 @@ app.on('scan_experience_file', function(exp) if title then exp.title = title:gsub("<.*","") end - app.markViewable(exp) exp.janusxr = exp.janusxr or {} + exp.janusxr.wrap = nil -- erase previous 3D models print("✅ └─ plugin/janusxr: " .. exp.file.name) if data:match(pattern_aframe) and app.opts.plugin_janusxr_wrap_aframe == 'enabled' then - exp.janusxr.wrap = {aframe = true } + exp.janusxr.wrap = {file = true } + app.markViewable(exp,50) + -- *TODO* assign room if no sky or equirect print("✅ └─ plugin/janusxr: AFRAME markup detected") + else + exp.janusxr.wrap = {redirect = true} + app.markViewable(exp,10) + print("✅ └─ plugin/janusxr: JML markup detected") end app.pub("scan_experience_janusxr", nil, {exp=exp, item=item}) -- be nice to other plugins app.addExperience( exp, exp.file.ino ) @@ -61,12 +50,29 @@ app.on('scan_experience_file', function(exp) -- symlink to directory end end + + if exp.parent.redirect == nil and app.opts.plugin_janusxr_wrap_3dfile ~= "disabled" + and not (exp.tag.xrfragments and exp.tag.xrfragments.qualify) then -- dont wrap xrfragments experience + foreach( me.ext.object, function(k,ext) + if exp.path:lower():match("."..ext.."$") then + wrap = ext + end + end) + if wrap and not (exp.janusxr and exp.janusxr.jml ~= nil) then + app.markViewable(exp) + exp.janusxr = { wrap = { object = true }} + exp.janusxr.room = me.wrapRoomAroundFile( exp ) + app.pub("scan_experience_janusxr", nil, {exp=exp, item=item}) -- be nice to other plugins + app.addExperience( exp, exp.file.ino ) + print("✅ └─ plugin/janusxr: wrapping " .. exp.path) + end + end end) app.on('set', function(k,v) end) -- this registers the plugin UI -local rooms = { [""]="empty",random="random room",randomurl="random room (URL-deterministic)",room_plane="wirefloor",room1="room1",room2="room2",room3="room3",room4="room4",room5="room5",room6="room6",room7="room7"} +local rooms = { [""]="empty",empty_plane="empty (+floorcollider)",random="random room",randomurl="random room (URL-deterministic)",room_plane="wirefloor",room1="room1",room2="room2",room3="room3",room4="room4",room5="room5",room6="room6",room7="room7"} local plugin = { name = "JanusXR", @@ -225,8 +231,8 @@ local plugin = { if v.key == 'app.opts.plugin_janusxr_portalroom' then local ordered = {} foreach( v.values, function(k,v) - if not v:match("random") then - table.insert(ordered,v) + if not v:match("random") and not v:match("empty") then + table.insert(ordered,k) end end) table.sort(ordered) -- ensure same order diff --git a/src/plugin/janusxr/layout/grid.lua b/src/plugin/janusxr/layout/grid.lua index 678d5eb..0aef867 100644 --- a/src/plugin/janusxr/layout/grid.lua +++ b/src/plugin/janusxr/layout/grid.lua @@ -15,7 +15,7 @@ local grid = { local index = 0 for i, v in pairs(items) do local url = v.redirect and v.redirect or v.url - local overlay = v.title:match('#overlay') and true or false + local overlay = v.title:match('overlay') and true or false -- Position current item local pos = { x = overlay and 0 or x * gridsize, diff --git a/src/plugin/openbrush.lua b/src/plugin/openbrush.lua index b109b09..4da1533 100644 --- a/src/plugin/openbrush.lua +++ b/src/plugin/openbrush.lua @@ -24,7 +24,7 @@ local function scanForOpenBrush(exp) if not exp.parent.janusxr then exp.parent.janusxr = {} end - exp.parent.janusxr.room = app.opts.plugin_openbrush_wrap_room + 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 @@ -58,13 +58,6 @@ local plugin = { -- { label = "resync now!", href="/reset" } --}, opts = { - { - key='app.opts.plugin_openbrush_wrap_room', - title='Wrap VR space', - info='render 3D files in janusxr.xml room', - default="", - values= app.plugin.janusxr.opts[4].values -- reuse rooms from janusxr plugin - }, { key='app.opts.plugin_openbrush_layout', title='Layout assets', @@ -72,6 +65,20 @@ local plugin = { default="grid", values={portals="As portals", grid="As grid"} }, + { + key='app.opts.plugin_openbrush_wrap_room_portals', + title='grid: wrap', + info='render 3D files in janusxr.xml room', + default="room_plane", + values= app.plugin.janusxr.opts[4].values -- reuse rooms from janusxr plugin + }, + { + key='app.opts.plugin_openbrush_wrap_room_grid', + title='portals: wrap', + info='render 3D files in janusxr.xml room', + default="empty_floor", + values= app.plugin.janusxr.opts[4].values -- reuse rooms from janusxr plugin + }, { key='app.opts.plugin_openbrush_layout_grid_size', title='Grid size', diff --git a/src/plugin/xrfragments.lua b/src/plugin/xrfragments.lua index 1090c64..790717f 100644 --- a/src/plugin/xrfragments.lua +++ b/src/plugin/xrfragments.lua @@ -45,7 +45,7 @@ app.on('scan_experience_file', function(exp) href = hasHref } if exp.tag.xrfragments.qualify then - app.markViewable(exp) + app.markViewable(exp, 100) print("✅ └─ plugin/xrfragments: detected xrfragments experience") end if exp.tag.xrfragments.href then diff --git a/src/test/main.lua b/src/test/main.lua index 655feea..538631b 100644 --- a/src/test/main.lua +++ b/src/test/main.lua @@ -9,8 +9,9 @@ lust.queueServerRequest = util.queueServerRequest --require('test/plugin_git')(lust) --require('test/plugin_diskscan')(lust) --require('test/plugin_xrfragment')(lust) -require('test/plugin_openbrush')(lust) -require('test/util')(lust) +require('test/plugin_janusxr')(lust) +--require('test/plugin_openbrush')(lust) +--require('test/util')(lust) if lust.errors == 0 then print("✅ all tests passed") diff --git a/src/test/plugin_janusxr.lua b/src/test/plugin_janusxr.lua new file mode 100644 index 0000000..fc8d8a2 --- /dev/null +++ b/src/test/plugin_janusxr.lua @@ -0,0 +1,45 @@ +return function(lust) + + + local describe, it, expect = lust.describe, lust.it, lust.expect + + describe('src/plugin/janusxr.lua', function() + + describe('ℹ️ wrap 3D file', function() -- Can be nested + it('detect & serve to iframe', function() + -- *TODO* + end) + end) + + describe('ℹ️ wrap AFRAME file', function() -- Can be nested + it('detect & serve to iframe', function() + -- *TODO* + end) + end) + + describe('ℹ️ wrap JML', function() -- Can be nested + + it('detect & serve to iframe', function() + app.init() + app.use( require('page/dir').middleware ) + app.use( app.response() ) + app.on('response', function(opts) + expect( opts.res._body:match('janus.url=/myverse/janusxr_tutorial/arwindow') ).to.be.truthy() + end) + + foreach(app.cache.items, function(k,exp) + if exp.url:match("arwindow") then + if exp.url:match("arwindow$") then + expect( exp.redirect:match("index.html$") ).to.be.truthy() + lust.queueServerRequest('GET', exp.url, nil, nil, nil, nil, nil, 8080 ) + app.run() + end + end + end) + end) + + end) + + end) + +end diff --git a/src/util/build.sh b/src/util/build.sh index e3b8623..4532609 100755 --- a/src/util/build.sh +++ b/src/util/build.sh @@ -32,12 +32,15 @@ download(){ janusweb(){ set -x - version=1.7.5 - test -f janusweb-${version}.tar.gz || { - wget "https://github.com/coderofsalvation/janusweb/releases/download/v${version}-rc/janusweb-${version}.tar.gz" + test -d janusweb || { + version=1.7.5 + test -f janusweb-${version}.tar.gz || { + wget "https://github.com/coderofsalvation/janusweb/releases/download/v${version}-rc/janusweb-${version}.tar.gz" + } + test -d janusweb-${version} || tar -xvf janusweb-${version}.tar.gz + mv janusweb-${version} janusweb } - test -d janusweb-${version} || tar -xvf janusweb-${version}.tar.gz - test -d src/janusweb || cp -Lr janusweb-${version} src/janusweb + test -d src/janusweb || cp -Lr janusweb src/janusweb } "$@"