简体   繁体   English

WebGL - 剔除网格并隐藏边框

[英]WebGL - culling mesh and hide the border

I have the following problem in WebGL.我在 WebGL 中有以下问题。 I 'm drawing aa simple mesh with a border in the 3D space with the culling activated.我在激活剔除的 3D 空间中绘制一个带有边框的简单网格。

gl.frontFace(gl.CCW);
gl.enable(gl.CULL_FACE);
gl.cullFace(gl.FRONT)

If the camera is set in front of the mesh, it is correcly visualized with the border FrontView如果将相机设置在网格前面,则正确地用边框FrontView可视化

But if the camere is set back the mesh the border does not disappear BackView但是如果camere被设置回网格边界不会消失BackView

The internal part of the mesh is draw as triangles网格的内部部分绘制为三角形

gl.drawElements(gl.TRIANGLES, indexBuffer.numberOfItems, gl.UNSIGNED_SHORT, 0);        

while the border as LINE_STRIP而边界为 LINE_STRIP

gl.drawElements(gl.LINE_STRIP, borderIndex.numberOfItems, gl.UNSIGNED_SHORT, 0);        

Is there any option for lines to have the same behavior of the mesh without using normals in the shader?在不使用着色器中的法线的情况下,是否有任何选项可以让线条具有相同的网格行为?

虽然三角形根据其缠绕顺序线具有固有的正面和背面,但没有这种情况,因此它们不受硬件剔除的影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM