我有这个对象,我正在用 THREE.objLoader 加载,然后用它创建一个网格,如下所示:
mesh = new THREE.SceneUtils.createMultiMaterialObject(
geometry,
[
new THREE.MeshBasicMaterial({color: 0xFEC1EA}),
new THREE.MeshBasicMaterial({
color: 0x999999,
wireframe: true,
transparent: true,
opacity: 0.85
})
]
);
在我的场景中,我添加了一个 DirectionalLight,它可以工作并且我可以看到我的对象,但是它就像 DirectionalLight 是一个环境光。没有一张脸像它应该的那样变得更黑或更亮。
对象填充了颜色,但没有对其应用照明。
如果有人可以帮助我,我将不胜感激:)
我会错过什么?
Jsfiddle在这里:http://jsfiddle.net/5hcDs/
最佳答案
好的伙计们,感谢 Maël Nison 和 doob 先生,我能够理解我遗漏的一些东西,作为我的 3d 菜鸟......我相信人们开始进入 3d 可能会发现一些有用的回顾:
基本的 3d 概念
Three.js 提示和技巧
/* Compute normals */
geometry.computeFaceNormals();
geometry.computeVertexNormals();
/* Next 3 lines seems not to be mandatory */
mesh.geometry.dynamic = true
mesh.geometry.__dirtyVertices = true;
mesh.geometry.__dirtyNormals = true;
mesh.flipSided = true;
mesh.doubleSided = true;
/* Flip normals*/
for(var i = 0; i<mesh.geometry.faces.length; i++) {
mesh.geometry.faces[i].normal.x = -1*mesh.geometry.faces[i].normal.x;
mesh.geometry.faces[i].normal.y = -1*mesh.geometry.faces[i].normal.y;
mesh.geometry.faces[i].normal.z = -1*mesh.geometry.faces[i].normal.z;
}
关于Three.js 自定义 objLoader 几何光照,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11032145/