Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution to allow dollhouse/floorplan on static hosting #41

Open
nebkat opened this issue Feb 2, 2022 · 9 comments
Open

Solution to allow dollhouse/floorplan on static hosting #41

nebkat opened this issue Feb 2, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@nebkat
Copy link

nebkat commented Feb 2, 2022

The following line can be inserted into showcase.js to replace the functionality currently present in the HTTP server:

if (s&&s.crop) {
    e = e.replace(".jpg", `.jpg${s.width ? `width=${s.width}_` : ''}crop=${s.crop}.jpg`)};
}

It is placed at the beginning of async getImageBitmap(e,t,i,n,s){ like so:

async getImageBitmap(e,t,i,n,s){if(s&&s.crop){e=e.replace(".jpg",`.jpg${s.width ? `width=${s.width}_` : ''}crop=${s.crop}.jpg`)}

This could probably be added to showcase.js by the script.

@mitchcapper
Copy link
Collaborator

This is a good work around, I still like the idea of trying to implement a javascript xhr proxy as noted in #8 (comment) 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.

@rebane2001 rebane2001 added the enhancement New feature or request label Feb 4, 2022
@minhvunguyenj
Copy link

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

@mu-ramadan
Copy link
Contributor

How we could host it on apache/nginx ?

@smee
Copy link

smee commented Jun 30, 2022

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() 

@michaelasg
Copy link

michaelasg commented Sep 13, 2024

any workarounds for Apache / Ngnix??

@mitchcapper
Copy link
Collaborator

@michaelasg it isn't super complex to emulate what at the simple server in code does so look at that or @smee seems to have the logic as well (although it has changed some now so pay attention to the main code too).

The good news is per the earlier comment I have actually implemented the javascript proxy. When I get enough time I will be able to generate rules to have it modify the requests so we can avoid post requests and rewrite the and not need a custom web server.

@michaelasg
Copy link

@mitchcapper

When I get enough time I will be able to generate rules to have it modify the requests so we can avoid post requests and rewrite the and not need a custom web server.

That would be great. I can't install redbean on my shared hosting...

Would be great to have each space folder being able to be hosted as a standard page under Apache, having multiple tours available at the same time. the python server works great for one thou!

@dev4lifes
Copy link

Hi! what is the best solution now for uploading to static hosting? Thanks

@mitchcapper
Copy link
Collaborator

Hi! what is the best solution now for uploading to static hosting? Thanks

#41 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants