けん@学生

自分が独学で学んだことを発信する

gltfで出した時のエラー[THREE.Object3D.add: object not an instance of THREE.Object3D.]

THREE.Object3D.add: object not an instance of THREE.Object3D.

 

const loader = new GLTFLoader();
  loader.load(glbmodel, (gltf) => {
   scene.add(gltf);
});

上のコードでエラーが出たので、

調べてみたら

const loader = new GLTFLoader();
 
let example = new THREE.Object3D();
loader.load(glbmodel, (gltf) => {
  example = gltf.scene;
  const radian = (i / this.index) * Math.PI * 2;
    scene.add(example);
  });

 

この2行を追加するらしい〜

let example = new THREE.Object3D();

example = gltf.scene;

 

以上。

 

 

 

参考

stackoverflow.com