Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
AR: reuse the model already made for the relay, don't swap it mid-session; fixed ICE port falls back when taken
islandmedfae63bb43c51
diff --git a/src/link/PhoneLink.cpp b/src/link/PhoneLink.cppindex cebe63a6..6519893a 100644--- a/src/link/PhoneLink.cpp+++ b/src/link/PhoneLink.cpp@@ -1085,7 +1085,7 @@ bool PhoneLink::createFaceLink(std::string& faceUrl, std::string& error, bool ar// Everything after '#' stays on the phone: the website never sees the offer, the token or the key.std::string page = options_.siteUrl;// ?v= changes with each page change that SculptForge depends on, so phones don't use a cached older copy.- if (ar) page = page.substr(0, page.rfind('/') + 1) + "ar.html?v=3";+ if (ar) page = page.substr(0, page.rfind('/') + 1) + "ar.html?v=4";// AR: the model also goes through our relay (its /blob/ path), for phones whose browser can't reach this computer.std::string blobUrl;if (ar)@@ -1106,11 +1106,14 @@ bool PhoneLink::createFaceLink(std::string& faceUrl, std::string& error, bool ararBlobVersion_ = 0;if (!blobUrl.empty()) {faceUrl += "&b=" + percentEncode(blobUrl);- // A fresh model for the relay now (over the direct link the page asks for one itself once connected).- PhoneEvent e = PhoneEvent::make(PhoneEvent::Type::ArRequested);- e.wholeScene = arScope == "scene";- e.sizeCm = arSizeCm;- pushEvent(e);+ // The model for the relay: the one already made (the capture page's Get the model), else a new one.+ // (Over the direct link the page asks for one itself once connected.)+ if (arVersion_ == 0) {+ PhoneEvent e = PhoneEvent::make(PhoneEvent::Type::ArRequested);+ e.wholeScene = arScope == "scene";+ e.sizeCm = arSizeCm;+ pushEvent(e);+ }arBlobUntil_ = Clock::now() + std::chrono::minutes(10);arViewed_ = Clock::now();arViewedEver_ = true;@@ -1123,6 +1126,7 @@ bool PhoneLink::createFaceLink(std::string& faceUrl, std::string& error, bool arrelayStop_ = false;relayThread_ = std::thread([this, topic, key, since] { relayLoop(topic, key, since); });}+ if (ar) uploadArModel(); // the current model, if there is onereturn true;}diff --git a/src/link/PhoneRtc.cpp b/src/link/PhoneRtc.cppindex 17dd4e7f..5c8e3fea 100644--- a/src/link/PhoneRtc.cpp+++ b/src/link/PhoneRtc.cpp@@ -269,6 +269,13 @@ bool FaceRtc::createOffer(std::string& sdp, std::string& error, int timeoutMs) {impl->state = State::Offered;return true;} catch (const std::exception& e) {+ if (icePort_) { // the fixed port is taken (another SculptForge): any port+ const uint16_t port = icePort_;+ icePort_ = 0;+ const bool ok = createOffer(sdp, error, timeoutMs);+ icePort_ = port;+ return ok;+ }error = std::string("WebRTC: ") + e.what();return false;}diff --git a/tests/test_phone_link.cpp b/tests/test_phone_link.cppindex 23cfdf85..c44090e0 100644--- a/tests/test_phone_link.cpp+++ b/tests/test_phone_link.cpp@@ -588,7 +588,7 @@ TEST(ar_link_sends_the_model_over_webrtc) {HttpRequest r = request("GET", "/api/face-link", link.token());r.query = "mode=ar&scope=scene&size=35";const std::string url = parseJson(link.handle(r).body)["url"].asString();- CHECK(url.rfind("https://example.org/link/ar.html?v=3#v=1&", 0) == 0);+ CHECK(url.rfind("https://example.org/link/ar.html?v=4#v=1&", 0) == 0);const std::string fragment = url.substr(url.find('#') + 1);CHECK(queryParameter(fragment, "m") == "ar");CHECK(queryParameter(fragment, "s") == "scene");diff --git a/website/link/ar.html b/website/link/ar.htmlindex f31e5bfd..813b9998 100644--- a/website/link/ar.html+++ b/website/link/ar.html@@ -221,7 +221,10 @@ function receive(data) {incoming = null;}}+// While the camera view is open a new model waits: swapping the model mid-session loses it in WebXR.+let inAr = false, waiting = null;function showModel(blob, version, summary) {+ if (inAr) { waiting = [blob, version, summary]; shownVersion = version; return; }const first = !shownVersion;shownVersion = version;if (modelUrl) URL.revokeObjectURL(modelUrl);@@ -265,6 +268,8 @@ mv.addEventListener("load", () => {else note($("liveMsg"), "Chrome can't start AR on this phone. AR needs Google Play Services for AR: install or update it from the Play Store, then reload this page.", "bad");});mv.addEventListener("ar-status", (e) => {+ inAr = e.detail.status === "session-started" || e.detail.status === "object-placed";+ if (e.detail.status === "not-presenting" && waiting) { const w = waiting; waiting = null; shownVersion = 0; showModel(...w); }if (e.detail.status === "failed") note($("liveMsg"), "AR couldn't start. Check that Google Play Services for AR is installed and up to date, and that Chrome may use the camera.", "bad");});$("enter").onclick = () => mv.activateAR();