File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,17 @@ import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
66// @ts -ignore
77import 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` ;
1020const RAD_TO_DEG = 180 / Math . PI ;
1121const 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 ,
You can’t perform that action at this time.
0 commit comments