THREE.ObjectLoader的Three.js错误

路易斯·E·福格

我似乎在Three.ObjectLoader中遇到问题。我正在以JSON格式4.3导出场景。该场景包括几何形状,材质和灯光。场景将在Three.js编辑器中打开,没有任何错误。

我正在使用Three.js r70 master开发Firefox。这是生成的json的链接:https : //gist.github.com/fraguada/d86637f7987096b361ea

在查看器中,我试图编写代码,并使用以下代码进行加载:

var manager = new THREE.LoadingManager();
manager.onProgress = function ( item, loaded, total ) {

    console.log( item, loaded, total );

};

// instantiate a loader 

var loader = new THREE.ObjectLoader(manager);

loader.load( 
    // resource URL coming from other file
    Name, 
    // Function when resource is loaded 
    function ( result ) 
    { scene.add( result.scene ); }, 
    // Function called when download progresses 
    function ( xhr ) 
    { console.log( (xhr.loaded / xhr.total * 100) + '% loaded' ); }, 
    // Function called when download errors 
    function ( xhr ) 
    { console.log( 'An error happened' ); } 
);

在控制台中,我看到以下内容:

THREE.WebGLRenderer 70  three.min.js (line 513)
100% loaded content.js (line 117)
THREE.Object3D.add: undefined is not an instance of THREE.Object3D. three.min.js (line 164)
js/Test83.js 1 1    content.js (line 86)

该错误也出现在7674行中未缩小的three.js中

如果我在Three.js编辑器中创建几何图形和其他对象并将其导出为场景,也会出现此问题。

问题似乎在这里:scene.add( result.scene );假设THREE.ObjectLoader可以使用文件中的JSON是不正确的吗?在我发布的代码中,如果删除scene.add( result.scene );,似乎文件至少加载了(数据加载,没有可见的几何图形),因为没有错误出现。如果我的场景具有多个网格,则进度将输出到控制台(已加载10%,已加载20%等)。

任何见解将不胜感激。

Mrdoob

我认为您应该scene.add( result )改为这样做

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章