microsoft / HoloJS

Provides a framework for creating holographic apps using JavaScript and WebGL.
MIT License
1.19k stars 113 forks source link

Cannot load FBX models #67

Closed adam-clarey closed 7 years ago

adam-clarey commented 7 years ago

What i thought would be somewhat simple, seems to not work.

I added a basic .fbx file in the ThreeJS/Scripts folder (alongside texture.png). I then added the reference to the file in the Solution Explorer, I ensured that Content was set to true. So at this point my 'example.fbx' should behave the same as 'texture.png'.

However when I try to load the fbx like so:

var fbxLoader = new THREE.FBXLoader();
var path = 'example.fbx';
fbxLoader.load(path, function (object) {
   //scene.add(object);
    //onLoad();
}, onProgressModel, onErrorModel);

There is an exception saying it cannot find the file.

Please help! Thank you

dadvav commented 7 years ago

It looks that your file is not compiled as content of project. Check file 'example.fbx' Properties in Visual Studio and change property Content to 'True'.

adam-clarey commented 7 years ago

It is compiled as content as mentioned above. I've also cleaned and rebuilt the project afterwards

adam-clarey commented 7 years ago

It should be simple enough to test. I've attached a simple fbx file green.fbx.zip

Almost-Done commented 7 years ago

Can you please try a new variant of the ThreeJS sample app in the develop/sample-threejs-fbxloader branch and let me know if it works properly for you.

The FBX loader (FbxLoader.js) is not part of ThreeJS, it needs to be added to the scripts list explicitly. The FBX loader in turn requires parts of Zlib.js that also have to be referenced in the scripts list. The branch above is adding these required scripts, the FBX file itself and updating the script to make use of them.

I don't know if the latest version of ThreeJS is required for the FBXLoader to work, but I'll upgrade it anyway.

dadvav commented 7 years ago

Latest version of three.js for STLLoader is needed. I think it will be same behaviour for FBXLoader. You need to download latest library. Next problem could be if there is more than one shader in fbx (I dont know this format), but it is already different issue.

Almost-Done commented 7 years ago

We have a fix for the multiple shaders issue, in PR.

I created a sample script for the FBX loader. Look in the WebSamples folder.