xurfer/xurfer/main.lua

57 lines
1.8 KiB
Lua
Executable file

#!/usr/bin/env lua
-- -- GLB URLS
-- ./lovr xurfer https://coderofsalvation.codeberg.page/xrfragment-haxe/example/assets/example.glb?bar=1&f=2#foo'
-- ./lovr xurfer https://codeberg.org/coderofsalvation/xrfragment/raw/branch/main/assets/template/website/website.glb'
-- ./lovr xurfer https://codeberg.org/coderofsalvation/xrfragment/raw/branch/main/assets/simple-a.glb'
-- ./lovr xurfer https://xrforge.isvery.ninja/models/zzswz4qlqw8w/model_files/test.xrf.glb'
--
-- -- JANUS JML URLS
-- ./lovr xurfer https://janusxr.org/index.html'
-- ./lovr xurfer https://snips.sh/f/rHFLg-cewi?r=1' -- cube
-- ./lovr xurfer https://snips.sh/f/_U5-XctEVE?r=1' -- cube, monkey, scene
print("\n X U R F Ξ R")
print(" ⠭ ⠥ ⠗ ⠋ ⠑ ⠗\n")
package.path = package.path .. ';' .. '?.lua;'
require('conf')
local runtime = require("runtime/detect")
local util = require("util")
local ecs = require("ecs")
api = {
runtime = runtime,
parser = {
json = require("json"),
xml = require("xmlSimple"),
},
url = require("url"),
util = require("util"),
ecs = ecs,
world = ecs.world(),
protocol = {},
ext = { -- all extensions are loaded here from disk at runtime
exec = function(...) util.exec(api.ext,...) end -- util function to call func on each extension
}
}
api = util.merge( api, runtime.api ) -- overlay api onto lovr/love-compatible runtime api
require( runtime.path .. "/main")
util.loaddir( "ext", api, api.ext )
util.loaddir( "media", api, api.media )
ecs.init(api)
api.ext.exec('init')
-- load urls passed on the cli
foreach( arg, function(k,uri)
if uri:find(".") and k ~= 0 and k ~= -1 then
api.ecs.add( api.world, { URI = { url = uri, method = 'GET', target = '_top' } })
end
end)
-- for runtimes (runtime/lua) which dont automatically run an update-loop (like love/lovr)
api.ext.exec('main')