0
A
回答
0
这是一些代码,我只是很快写下来,并没有testet。但这将是我如何做到的方法。也许这是一开始。
var geo = mesh.geometry; // assuming this Geometry and not BufferGeometry
var verts = geo.vertices;
var faces = geo.faces;
// vertices are used in multiple faces with different normals
// we want to translate the vertex along the average normal
// first, I collect all normals for each vertex
// (it's a bit quick and dirty as I add a normals property to the Vector3 object)
for(var i=0; i<faces.length; i++) {
// vertex a
var va = verts[faces[i].a];
if(va.normals) va.normals.push(faces[i].vertexNormals[0]); // add normal to collection
else va.normals = [ faces[i].vertexNormals[0] ]; // otherwise create array with first element
// vertex b
var vb = verts[faces[i].b];
if(vb.normals) vb.normals.push(faces[i].vertexNormals[1]);
else vb.normals = [ faces[i].vertexNormals[1] ];
// vertex c
var vc = verts[faces[i].c];
if(vc.normals) vc.normals.push(faces[i].vertexNormals[2]);
else vc.normals = [ faces[i].vertexNormals[2] ];
}
// then iterate over vertices, compute average normal, and translate vertex
for(i=0; i<verts.length; i++) {
var v = verts[i];
var normal = computeAverageNormal(v.normals);
normal.multiplyScalar(offsetAmount);
v.add(normal);
}
geo.verticesNeedUpdate = true;
function computeAverageNormal(normals) {
var n = new THREE.Vector3();
for(var i=0; i<normals.length; i++) {
n.add(normals[i]);
}
n.normalize();
return n;
}
相关问题
- 1. XNA中网格的偏移
- 2. 从网格偏移Div
- 3. 引导网格偏移量
- 4. 在网格中找到偏移
- 5. JQuery ...调整网格偏移中拖动
- 6. Three.js移动相机平行于网格
- 7. 引导网格偏移量差距
- 8. 引导网格和列偏移
- 9. 在three.js中定位网格
- 10. Three.js - 2D + 3D网格
- 11. 将位移贴图应用于当前Three.js中的网格?
- 12. 偏移表格单元格
- 13. 在three.js中规格化网格
- 14. Bootstrap网格系统中推/拉和偏移的作用
- 15. 无法更改GIMP中的网格间距和偏移量
- 16. 为什么我的网格在这个例子中偏移?
- 17. 更新Three.js中的网格几何?
- 18. 在Three.js中绘制网格的边线
- 19. Three.js中的交互式网格
- 20. Three.js组中的网格动画
- 21. three.js中的LOD(合并网格)
- 22. 如何用three.js在不同的方向移动多个网格?
- 23. Three.js网格不AnimationHandler动画
- 24. 在Three.js上选择网格
- 25. THREE.js +网格修改器
- 26. 从点生成网格Three.js
- 27. 嵌套格造型偏移
- 28. NSOutlineView单元格偏移
- 29. 偏移二进制格式
- 30. 在Three.js中合并纹理网格
可以想像,THREE.FaceNormalsHelper或THREE.VertexNormalsHelper。 – VVK