THREE.js OBJLoader - load into geometry, control, and then save to BufferGeometry

I am trying to establish why I cannot smooth the shadow geometry loaded by OBJLoader.

var loader = new THREE.OBJLoader(manager);
loader.load('/manmodel/js/man.obj', function (object, materials) {
    console.log(object);
    console.log(materials);
    man = object;
    man.traverse(function (child) {
        if (child instanceof THREE.Mesh) {
            child.geometry.computeFaceNormals();
            child.geometry.computeVertexNormals( true );
            child.material = new THREE.MeshPhongMaterial({
                color: 'white',
                shading: THREE.SmoothShading // <-----------  THIS IS THE PROBLEM
            });
        }
    });
    man.position.y = -10;
    scene.add(man);
});

This is the result:

apparently Flat Shading

If I delete the line computeFaceNormals (), the model displays the same. If I remove computeVertexNormals (true), the object displays without lighting (black) - so I know that it does something.

If I change the color attribute of MeshPhongMaterial in this code, the color changes, so I also know that it works.

I tried using the top and normal helpers to find out what the problem is, but they fail because with BufferGeometry, faces and vertices are not saved as arrays.

I also tried changing the man.obj file to change the 's' values ​​from 'off' to 1. This did nothing.

.obj , Blender, 2 , , "" , .

(): - ? , .obj , , , BufferGeometry?

. .

+4
2

ObjLoader .obj BufferGeometry . GitHub, , :

https://github.com/mrdoob/three.js/blob/a321ba05f02ae3a1586a4060a53f5ad63b90729b/examples/js/loaders/OBJLoader.js

.obj, , , , BufferGeometry BufferGeometry.fromGeometry(geometry), . .

+6

(r73), BufferGeometry Geometry, !

, , . , , -.

 var geometry = new THREE.Geometry().fromBufferGeometry( child.geometry );
 geometry.computeFaceNormals();
 geometry.mergeVertices();
 geometry.computeVertexNormals();
 child.geometry = new THREE.BufferGeometry().fromGeometry( geometry );
+4

All Articles