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. 引导网格偏移量
- 2. 从网格偏移Div
- 3. JQuery ...调整网格偏移中拖动
- 4. 在three.js中定位网格
- 5. 引导网格和列偏移
- 6. 引导网格偏移量差距
- 7. 偏移表格单元格
- 8. three.js中的LOD(合并网格)
- 9. 更新Three.js中的网格几何?
- 10. 为什么我的网格在这个例子中偏移?
- 11. Bootstrap网格系统中推/拉和偏移的作用
- 12. 如何用three.js在不同的方向移动多个网格?
- 13. THREE.js +网格修改器
- 14. Three.js网格不AnimationHandler动画
- 15. NSOutlineView单元格偏移
- 16. 嵌套格造型偏移
- 17. Excel中的单元格在不同的表格中的偏移
- 18. 更改字体大小时的自举网格行偏移量
- 19. Python - 问题等高线绘制数据的偏移网格
- 20. Three.js ShaderMaterial从Blender导入的网格灯
- 21. 为three.js检测子网格的碰撞
- 22. “粘”导入的文件到网格 - three.js
- 23. 移调偏移
- 24. 引导网格偏移行高度扩展
- 25. 在Three.JS中移动阴影
- 26. Three.js移动几何中心
- 27. 偏移的div
- 28. 从偏移量中选择一部分数据从偏移量到偏移量
- 29. 动态地用three.js中的另一个新网格替换一个网格
- 30. JSONLoader raycaster和碰撞网格 - three.js
可以想像,THREE.FaceNormalsHelper或THREE.VertexNormalsHelper。 – VVK