如何将完整的JSON场景或多部件模型加载到three.js中(使用blender导出)

时间:2017-02-22 01:07:33

标签: json three.js blender 3d-modelling

我试图加载一个分为轮胎 body windows 的简单汽车模型到三.js ,我使用 Blender 导出为.json但是当我使用 JSONloader 时,它只会加载正文。

然后我尝试将其导出为场景,但是当我使用 JSONloader 时,没有任何内容显示在场景中。

所以我有两个问题:

  1. 从Blender JSON导出和加载多部件模型的正确方法是什么?
  2. 如何将从Blender导出的JSON场景加载到three.js?
  3. 关注@larsenhupin建议继承我尝试使用objectloader,但场景并没有显示

    //LOAD A JSON SCENE
    
    var loader = new THREE.ObjectLoader();
    
    loader.load(
        // resource URL
        "models/stockcarb.json"
    
        // pass the loaded data to the onLoad function.
    //Here it is assumed to be an object
        function ( obj ) {
            //add the loaded object to the scene
            scene.add( obj );
        },
    
        // Function called when download progresses
        function ( xhr ) {
            console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
        },
    
        // Function called when download errors
        function ( xhr ) {
            console.error( 'An error happened' );
        }
    );
    

1 个答案:

答案 0 :(得分:0)

根据我的经验,当我从Blender导出场景时,它使用ObjectLoader();代替JSONLoader();

https://threejs.org/docs/api/loaders/ObjectLoader.html

你打算使用动画吗?我问,因为我从来没有能够使用ObjectLoader的动画,它可以工作,但它从来没有发生在我身上。