几天以来,我试图用输入文件本地的材料加载.fbx文件,但没有成功。 我发现此代码可与collada文件一起使用,我已将其更改为可与.fbx一起使用,但没什么...
$("#campoFile3dNascosto").change(function (e) {
var files = e.currentTarget.files;
var dae_path;
var extraFiles = {}, file;
for (var i = 0; i < files.length; i++) {
file = files[i];
extraFiles[file.name] = file;
//Filename ends in .dae/.DAE
if (files[i].name.match(/\w*.dae\b/i)) {
dae_path = files[i].name;
}
}
const manager = new THREE.LoadingManager();
manager.setURLModifier(function (url, path) {
url = url.split('/');
url = url[url.length - 1];
if (extraFiles[url] !== undefined) {
var blobURL = URL.createObjectURL(extraFiles[url]);
console.log("blob: "+blobURL); //Blob location created from files selected from file input
return blobURL;
}
return url;
});
var loader = new THREE.FBXLoader(manager);
loader.load(dae_path, function (object) {
object.traverse(function (child) {
if (child.isMesh) {
child.castShadow = true;
child.receiveShadow = true;
}
});
});
});
我该怎么做?