任何人都知道为什么 .obj 没有像盒子一样反射定向光?
两者都使用相同的材料。
以下是GitHub中的代码:https://github.com/triple-verge/triple-verge-website/blob/master/src/js/modules/logo-3d.js#L52
这是代码片段:
logo.addLogo = function () {
loader.load('img/logo.obj', function (obj) {
var material = new THREE.MeshLambertMaterial({
color: 0xff0000
}),
cube; // Test
_logo.obj = obj;
obj.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.geometry.applyMatrix(
new THREE.Matrix4().makeTranslation(-0.5, 0, 0)
);
child.material = material;
// Test
cube = new THREE.Mesh(
new THREE.BoxGeometry(0.5, 0.5, 0.5),
material
);
$(_logo.container).on('frame', function () {
child.position.set(0, Math.sin(Date.now() / 750) * 0.1, 0);
child.rotation.set(
Math.PI * 0.5,
0,
Math.sin(Date.now() / 500) * 0.8
);
cube.rotation.set(
Math.PI * 0.5,
0,
Math.sin(Date.now() / 500) * 0.8
);
});
}
});
_logo.scene.add(obj);
_logo.scene.add(cube); // Test
});
};
谢谢!
three.js r.70
答案 0 :(得分:1)
您需要在obj文件中导出顶点法线,或者调用
child.geometry.computeVertexNormals();
在加载程序回调函数内的traverse()
方法中。
three.js r.70