fix the asset path resolving

This commit is contained in:
Robert Nasarek 2026-06-25 10:28:16 +02:00
parent 9b10181d11
commit 1efcf41b50
2 changed files with 6 additions and 14 deletions

View file

@ -254,7 +254,7 @@ function getEnvironmentTextureForPreset(renderer, preset = "neutral") {
// Load HDR map for other presets
const HDRLoader = await loadHDRLoader();
const loader = new HDRLoader();
const baseModulePath = core.DFG_ASSETS || core.CONFIG?.baseModulePath || '/assets';
const baseModulePath = core.CONFIG?.baseModulePath || core.DFG_ASSETS || '/assets';
const mapFilename = preset === "goldenHour" ? "golden_hour.hdr" : `${preset}.hdr`;
const mapUrl = `${baseModulePath.replace(/\/$/, '')}/maps/${mapFilename}`;
@ -676,28 +676,24 @@ export async function loadModel() {
}
export const getModuleAssetBasePath = function() {
let basePath = sanitizeModuleAssetBasePath(core.DFG_ASSETS || core.CONFIG?.baseModulePath);
const configuredPath = sanitizeModuleAssetBasePath(core.CONFIG?.baseModulePath);
let basePath = configuredPath || sanitizeModuleAssetBasePath(core.DFG_ASSETS);
if (!basePath && typeof import.meta !== 'undefined' && import.meta.url) {
const moduleUrl = new URL(import.meta.url);
basePath = moduleUrl.pathname.includes('/assets/')
? new URL('../assets/', moduleUrl).pathname.replace(/\/$/, '')
: new URL('./assets/', moduleUrl).pathname.replace(/\/$/, '');
}
if (!basePath) {
basePath = '/assets';
}
// Override for localhost
if (core.isLocalPreview) {
// Standalone local dev servers expose assets at /assets; embedded hosts provide baseModulePath.
if (core.isLocalPreview && !configuredPath) {
basePath = '/assets';
}
basePath = sanitizeModuleAssetBasePath(basePath);
console.log('[loaders] resolved ModuleAssetBasePath:', basePath);
core.CONFIG.baseModulePath = basePath; // Cache for future use
core.CONFIG.baseModulePath = basePath;
core.DFG_ASSETS = basePath;
return basePath;
};