Open nebkat opened 2 years ago
This is a good work around, I still like the idea of trying to implement a javascript xhr proxy as noted in https://github.com/rebane2001/matterport-dl/issues/8#issuecomment-962530817 for long term external hosting. It could easily use the same rule set as the internal hosting and would be pretty robust against changes. Right now 99% of all the network requests matterport makes are XHR and would flow through it.
The static hosting doesn't seem to load for me when I replace async getImageBitmap(e,t,i,n,s){const r=this.isSigned(e)?e:await this.getSignedUrl(e),o=(0,d.bf)(r,s);return this.api.getImageBitmap(o,t,i,n)}
with the code above. Am I doing something wrong? I still can't get the dollhouse and floorplan to work correctly
How we could host it on apache/nginx ?
Actually, I had some success using the Readbean webserver: a standalone binary that runs on Linux, Windows, Mac and BSD. I took the main ideas from the python webserver and ported them to Lua.
Download Redbean 1:
curl -o redbean.com https://justine.lol/redbean/redbean-latest.com
Add lua code and web framework from fullmoon:
zip -r redbean.com .init.lua .lua/fullmoon.lua`
Add downloaded Matterport files:
cd <matterport folder>
zip -r ../redbean.com *
The lua code itself is rather simple:
local fm = require "fullmoon"
fm.setRoute("/api/mp/models/graph", function(r)
local op = r.params.operationName
local file = "/api/mp/models/graph_" .. op .. ".json"
-- fm.logInfo("serving graph for operation " .. op .. ", serving file " .. file)
if GetAssetMode(file) == nil
then return fm.servePath("/api/mp/models/graph")
else return fm.servePath(file)
end
end)
fm.setRoute("/js/showcase.js","/js/showcase-internal.js")
fm.setRoute("/models/*/*.jpg", function(r)
local crop = r.params.crop
local width = r.params.width
local path = r.path
if width ~= nil then path = path .. "width=" .. width .. "_" end
if crop ~= nil then path = path .. "crop=" .. crop end
if crop == nil and width == nil then path = r.path else path = path..".jpg" end
-- fm.logInfo("cropped image: " .. path)
if GetAssetMode(path) == nil
then return fm.servePath(r.path)
else return fm.servePath(path)
end
end)
fm.setRoute("/v2/users/current",fm.servePath("/api/v2/users/current"))
fm.setRoute("/",fm.servePath("/index.html"))
fm.setRoute("/*", fm.serveAsset)
fm.run()
The following line can be inserted into
showcase.js
to replace the functionality currently present in the HTTP server:It is placed at the beginning of
async getImageBitmap(e,t,i,n,s){
like so:This could probably be added to
showcase.js
by the script.