fix the asset path resolving
This commit is contained in:
parent
9b10181d11
commit
1efcf41b50
2 changed files with 6 additions and 14 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue