I’m integrating Needle Engine into a SvelteKit project and ran into a routing issue:
When I navigate to a nested route like /path1 or /path2, Needle tries to load assets from a relative path like /path1/assets/ instead of from /assets/ at the root.
This causes asset loading to fail when accessing routes directly or refreshing the page.
Is there a recommended way to configure Needle Engine or the project build so that all assets (e.g. glb, textures) are always loaded from the root path (i.e. /assets/...), regardless of the current route?
I’m currently using the SvelteKit static adapter.
Hi oot4chi, the simplest solution is to set your assets base path as an absolute URL. Right now your config uses a relative path (“assets”), which means that when you’re on a nested route the browser will resolve it relative to that route (e.g. “/path1/assets”). To fix this, update your needle.config.json so that the baseUrl includes a leading slash (“/assets”):
This tells Needle Engine to always load assets from the root, regardless of the current route in your SvelteKit project. After making this change, rebuild your project and the assets (glb, textures, etc.) should load correctly in all routes.
For more details on how Needle Engine uses the baseUrl setting, you can refer to the documentation and the Needle config examples (see at needle-engine-unity—NeedleProjectConfig.cs.txt).
1 replies left - Become PRO for more replies. thread_sTpzgBB2X0OJ23GYZp7QTTMK Reply to this post directly if you need further help (bottom right button)