diff --git a/viewer/loaders.js b/viewer/loaders.js index e6e23d5..d551d77 100644 --- a/viewer/loaders.js +++ b/viewer/loaders.js @@ -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; }; diff --git a/viewer/main.js b/viewer/main.js index 3493a91..69b4fdf 100644 --- a/viewer/main.js +++ b/viewer/main.js @@ -3662,10 +3662,6 @@ export const Viewer = { setCore('mainCanvas', Viewer.mainCanvas); if (!core.PRESENTATION_MODE) { - const scriptUrl = document.currentScript?.src || import.meta.url; - Viewer.DFG_ASSETS = scriptUrl.replace(/\/[^\/]*$/, ''); - - setCore('DFG_ASSETS', Viewer.DFG_ASSETS); getModuleAssetBasePath(); Viewer.actionMenu = document.createElement("div");