const MANAGER = new THREE.LoadingManager();
function sceneCreator(url,rootPath,assetMap) {
const baseURL = LoaderUtils.extractUrlBase(url);
const blobURLs = [];
return new Promise((resolve, reject)=>{
MANAGER.setURLModifier((url,path)=>{
const normalizedURL = rootPath + decodeURI(url)
.replace(baseURL,'')
.replace(/^(\.?\/)/, '');
if(assetMap.has(normalizedURL)){
const blob = assetMap.get(normalizedURL);
const blobURL = URL.createObjectURL(blob);
blobURLs.push(blobURL);
return blobURL;
}
return (path || '') + url;
});
const loader = new GLTFLoader(MANAGER)
.setCrossOrigin('anonymous');
loader.load(url, (gltf)=>{
const root = gltf.scene;
console.log(root);
})
})
function to create simple dropzone
const input1 = document.querySelector("#file-input");
const dropArea = document.querySelector('.wrap') as HTMLElement || null;
const dropArea1 = document.querySelector('#c') as HTMLElement || null;
function createDropzone(){
const drpCntrl = new SimpleDropzone(dropArea,dropArea1,input1);
drpCntrl.on('drop',({files})=> load(files));
}
function load(fileMap){
let rootPath;
let rootFile;
Array.from(fileMap).forEach(([path,file])=>{
console.log('gggg',file.name);
if(file.name.match(/\.(gltf|glb)$/)){
rootFile = file;
rootPath = path.replace(file.name, '');
}
})
console.log(rootFile,rootPath);
view(rootFile, rootPath, fileMap);
}
function view(rootFile, rootPath, fileMap){
const fileURL = typeof rootFile === 'string'
? rootFile
: URL.createObjectURL(rootFile);
sceneCreator(rootFile,rootPath,fileMap);
}
Below image it underlines url,path
Error -
(parameter) url: any
Parameter ‘url’ implicitly has an ‘any’ type, but a better type may be inferred from usage.ts(7044)
Argument of type ‘(url: any, path: any) => any’ is not assignable to parameter of type ‘(url: string) => string’.ts(2345)
(parameter) path: any
Parameter ‘path’ implicitly has an ‘any’ type, but a better type may be inferred from usage.ts(7044)
Argument of type ‘(url: any, path: any) => any’ is not assignable to parameter of type ‘(url: string) => string’.ts(2345)
Where is the issue or where I am doing wrong?