Error importing FBX

An error:
TypeError: Cannot read property ‘add’ of undefined
at index.html:30
at Object.onLoad (FBXLoader.js:44)
at XMLHttpRequest. (three.js:26570)

How to solve it?

Do you mind sharing the FBX asset in this topic?

Maybe try this? That way you’ll be able to see if the model is loading at all. This is a TS version, might need to do some simple changes here and there.

// FBX model loading
const fbxLoader: FBXLoader = new THREE.FBXLoader();
fbxLoader.load(
  'weixing1.fbx',
  (object) => {
    // do some stuff to the object before adding it to the scene, e.g. set scale.
    // object.scale.set(0.02, 0.02, 0.02);

    this.scene.add(object);
  },
  (xhr) => {
    console.log((xhr.loaded / xhr.total) * 100 + '% FBX loaded');
  },
  (error) => {
    console.log(error);
  }
);

Uncaught SyntaxError: Missing initializer in const declaration

In your case you might need to use the fbxLoader initialisation like above. If your error is what I’m thinking. What you code looks like now?

Uploading: 卫星FBX.zip…
Upload failure is too big

Follow the code you sent

remove the
: FBXLoader
That part with the red squigly under it including the colon in front of it.

That is a typescript annotation and not supported in javascript.

Also, you appear to be using the commonjs version of threejs.
Try declaring the fbxloader using something like
const fbxLoader = new THREE.FBXLoader()

I think your 1st version of code was ok. The problem is likely with your model

Edit:
I just noticed that you haven’t instantiated a scene, camera or renderer in your 1st version of the code.

1 Like

Consider to share the model with a service like Google Drive.