1

I'm creating a disc golf game for the browser. A friend of mine is assisting me by creating objects in Trimble Sketchup, so that I can import them into the game. He has exported a .dae file and the textures, and I have imported them using the ColladaLoader.js. The textures and object load, and the object is rendered, but the object is black, and, sometimes, the javascript console says some textures cannot be rendered.

Here is some code :

   var loader = new THREE.ColladaLoader();
   var dae;
   loader.options.convertUpAxis = true;

   loader.load( '/discgolf/static/models/BelmontDreamCourse.dae', function ( collada ) {

       dae = collada.scene;

       dae.scale.x = dae.scale.y = dae.scale.z = 2.0;

       dae.position.set( 5, 5, 5 ); 

       scene.add( dae );
   } );

What else do I need to do? I will be happy to provide more information.

4

1 回答 1

2

没有更多信息,这是一项艰巨的任务,但我首先要检查三件事:

  • 确保纹理路径正确(检查 Firebug Net 面板或它试图加载纹理的路径)。您可能需要在 DAE 中搜索和替换纹理路径,如果我没记错的话,SU 有时可以将绝对路径放在那里。

  • 场景中有灯光吗?如果我没记错的话,ColladaLoader 将 SU DAE 材质转换为 MeshPhongMaterial,与 MeshBasicMaterial 不同,它确实需要一些灯光才能显示出来。

  • 您是否有动画循环,以便不断渲染事物?如果不是这样,请确保不仅在加载模型之后重新渲染场景,而且在加载纹理之后(它们在模型之后延迟加载)。

  • 确保将纹理文件的大小调整为二维的幂(256x512、256x256、1024x1024 等)。WebGL 不喜欢任意大小的纹理。

于 2013-08-05T17:46:06.967 回答