11

THREE.OBJLoader メソッドを使用して OBJ ファイルをレンダリングする方法、サンプルの OBJ 形式がありますが、何もレンダリングされず、chrome dev ツールでエラーが表示されます

4

2 に答える 2

10

https://github.com/mrdoob/three.js/blob/master/examples/webgl_loader_obj.html#L75で OBJLoader の使用例を確認してください。

(動作中http://mrdoob.github.com/three.js/examples/webgl_loader_obj.html )

var loader = new THREE.OBJLoader();
loader.load( objURL, function ( object ) {
  scene.add( object );
} );
于 2012-07-04T21:20:51.040 に答える
4

Try adding a light into the scene or just assign the Obj a MeshBasicMaterial to see its shape:

    var objLoader = new THREE.OBJLoader();
    var material = new THREE.MeshBasicMaterial({color: 'yellow', side: THREE.DoubleSide});
    objLoader.load('file.obj', function (obj) {
        obj.traverse(function (child) {

            if (child instanceof THREE.Mesh) {
                child.material = material;
            }

        });
        scene.add(obj);
    });

Then you are able to see that the model has actually already been loaded. If not, try adjusting the position of your camera.

The documentation has left out the light so that it seems quite confusing at this point for beginners including me. :)

于 2015-02-17T04:33:20.957 に答える