Skip to content

Commit 7a7f57b

Browse files
committed
🔮 use 8thwall standalone sdk
ref: https://www.8thwall.com/docs/migration/self-hosted/
1 parent 5feb08c commit 7a7f57b

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
- run: bun type
1818
- run: bun lint
1919
- run: bun test
20+
- run: bun run download-8th-sdk
2021
- run: bunx vite build --base yAR-htzee
2122
env:
2223
VITE_XR8_API_KEY: ${{ secrets.VITE_XR8_API_KEY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ dist
33
.env.local
44
.dev.vars
55
.wrangler
6+
public/8thwall-sdk

bun.lockb

2.13 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"wrangler": "4.11.0"
3131
},
3232
"scripts": {
33+
"download-8th-sdk": "( mkdir -p public/8thwall-sdk ; cd public/8thwall-sdk ; wget https://github.com/8thwall/engine/raw/refs/heads/main/xr-standalone.zip?download= && unzip xr-standalone.zip?download= && rm xr-standalone.zip?download=)",
3334
"type": "tsc --noEmit",
3435
"lint": "prettier -c '**/*.{ts,tsx,js,jsx,json,md,html}' '!**/{build,web_modules}/**'",
3536
"dev": "vite",

src/App/App.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import { LoadingScreen } from "./Ui/LoadingScreen";
2020
// @ts-ignore
2121
import { Visualizer } from "react-touch-visualizer";
2222

23-
// @ts-ignore
24-
const xr8ApiKey: string | undefined = import.meta.env.VITE_XR8_API_KEY;
2523
const touchSupported =
2624
typeof document !== "undefined" && "ontouchend" in document;
2725

@@ -76,7 +74,7 @@ export const App = () => {
7674

7775
const startXR8 = () => {
7876
setState({ type: "xr8" });
79-
loadXR8(xr8ApiKey)
77+
loadXR8()
8078
.then((xr8) => setState({ type: "xr8", xr8 }))
8179
.catch(setError);
8280
};
@@ -85,7 +83,7 @@ export const App = () => {
8583

8684
const webXRSupported = useIsWebXRSupported();
8785

88-
const xr8Supported = (!!xr8ApiKey || xr8Hosted) && touchSupported;
86+
const xr8Supported = (xr8Hosted || true) && touchSupported;
8987

9088
const sceneAssetLoaded = useProgress(({ active }) => !active);
9189

src/XR8Canvas/XR8.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export type XR8 = {
2+
loadChunk: (feature: "slam") => Promise<void>;
3+
24
run: (o: any) => void;
35
stop: () => void;
46
pause: () => void;

src/XR8Canvas/getXR8.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ export const xr8Hosted =
1515
* load 8th wall sdk once
1616
* resolve with XR8 when it's ready
1717
*/
18-
export const loadXR8 = async (apiKey?: string) => {
18+
export const loadXR8 = async () => {
1919
// in 8thwall demo page, the script is loaded automatically
2020
if (!xr8Hosted) {
21-
const src = `//apps.8thwall.com/xrweb?appKey=${apiKey}`;
22-
await loadScript(src);
21+
const xrUrl = "./8thwall-sdk/xr.js";
22+
await loadScript(xrUrl);
2323
}
2424

25-
const xr8 = getXR8();
26-
if (xr8) return xr8;
27-
else {
25+
let xr8 = getXR8();
26+
if (!xr8) {
2827
await new Promise((resolve: any) =>
2928
window.addEventListener("xrloaded", resolve)
3029
);
31-
return getXR8()!;
30+
xr8 = getXR8()!;
3231
}
32+
await xr8.loadChunk("slam");
33+
34+
return xr8;
3335
};
3436

3537
export const loadScript = (src: string) =>

0 commit comments

Comments
 (0)