在 webgl 中缩放不变对象
WebGl 不支持线宽。因此,当我需要突出显示某条线时,我只需在其周围绘制矩形即可。但当我放大场景时,它看起来非常可怕。
我现在看到的有两种方法:
1)根据canvas.width重新计算矩形宽度到模型坐标中。
2)将所有缩放不变的对象放在单独的矩阵下(我使用scenejs)并在每个鼠标滚轮后重新计算它们的位置
我不喜欢这个解决方案。所以我想知道:是否有好的解决方法可以使项目缩放不变?
WebGl doesn't support line thickness. So when I need to highlight some line, I just draw rectangle around it. But when I zoom scene it looks pretty scary.
There are two ways I see now:
1) Recalculate rectangle width according to canvas.width into model coordinates.
2) Place all zoom-invariant objects under separate matrix (I use scenejs) and recalculate their positions after each mousewheel
I don't like both of this solution. So I wonder: is there good workaround to make items zoom invariant?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
另一种解决方法(尽管不是最有效的方法)可能是使用着色器。在我们的 WebGL 应用程序中,我们将突出显示的基元渲染为纹理,然后将其模糊回到屏幕上以添加“选择发光效果”。
Another way around that (not the most efficient one though) might be to use shaders. In our WebGL app, we render highlighted primitives into a texture and then blur it back on screen to add a "selection glow effect".