|
const manager: LoadingManager = DefaultLoadingManager |
Summary
I fixed a texture loading error by refactoring buildMaterials into a plugin-style hook
and injecting a custom LoadingManager.
The issue was caused by a single line that indirectly produced an invalid blob URL.
Environment
- THREE (jsdelivr cdn, esm, latest)
- MMDLoader (jsdelivr cdn, esm, latest)
What I changed
I copied the original buildMaterials implementation and modified only the manager
injection part to make it work as a plugin.
// custom manager
const cm = new THREE.DefaultLoadingManager();
// Plugin for allow the custom Manager.
const p = (_deps) => {
return {
buildMaterials: (pmx, geometry, resourcePath, onProgress, onError) => {
return buildMaterial(pmx, geometry, resourcePath, onProgress, onError, cm);
}
};
};
function buildMaterial(data, geometry, resourcePath, onProgress, onError, customManager) {
const crossOrigin = "anonymous";
const manager = customManager || DefaultLoadingManager;
// rest of code...
}
Error
Fetch API cannot load "blob:./tex/hair_Mikuv4x.tga"
URL scheme "blob" is not supported.
Root cause
This was caused by one line inside buildMaterial / loadTexture that generated an
invalid blob: relative URL when DefaultLoadingManager was not used.
After routing everything through my custom manager, the problem disappeared.
Notes
I did NOT change any logic besides the manager-related part.
All other code is identical to the original buildMaterials.
three-mmd/packages/three-mmd/src/utils/build-material/index.ts
Line 177 in 2332c1f
Summary
I fixed a texture loading error by refactoring
buildMaterialsinto a plugin-style hookand injecting a custom
LoadingManager.The issue was caused by a single line that indirectly produced an invalid blob URL.
Environment
What I changed
I copied the original
buildMaterialsimplementation and modified only the managerinjection part to make it work as a plugin.
Error
Root cause
This was caused by one line inside
buildMaterial/loadTexturethat generated aninvalid
blob:relative URL whenDefaultLoadingManagerwas not used.After routing everything through my custom manager, the problem disappeared.
Notes
I did NOT change any logic besides the manager-related part.
All other code is identical to the original
buildMaterials.