Skip to content

Commit 3cf4d5b

Browse files
committed
fixing the urdf path
Signed-off-by: Falah Naufal Zaki <falahnzk.dev@gmail.com>
1 parent 3212190 commit 3cf4d5b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

app/anime/page.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
66
// @ts-ignore
77
import URDFLoader, { URDFRobot } from "@/lib/urdf-loaders/javascript/src/URDFLoader";
88

9-
const URDF_PATH = "/altair.urdf";
9+
const getBasePath = () => {
10+
if (typeof window !== "undefined") {
11+
// Next.js exposes __NEXT_DATA__.assetPrefix at runtime
12+
// fallback to '' if not set
13+
// @ts-ignore
14+
return (window.__NEXT_DATA__?.assetPrefix || "");
15+
}
16+
return "";
17+
};
18+
19+
const URDF_PATH = `${getBasePath()}/altair.urdf`;
1020
const RAD_TO_DEG = 180 / Math.PI;
1121
const DEG_TO_RAD = Math.PI / 180;
1222

@@ -77,6 +87,14 @@ export default function AnimatorPage() {
7787

7888
// Load URDF
7989
const manager = new THREE.LoadingManager();
90+
// Use setURLModifier to prepend basePath to all asset URLs
91+
manager.setURLModifier((url) => {
92+
const basePath = getBasePath();
93+
if (url.startsWith("/")) {
94+
return basePath + url;
95+
}
96+
return basePath + "/" + url;
97+
});
8098
const loader = new URDFLoader(manager);
8199
loader.load(
82100
URDF_PATH,

0 commit comments

Comments
 (0)