在 webgl 中缩放不变对象

发布于 2025-01-06 10:36:26 字数 235 浏览 5 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷情 2025-01-13 10:36:27

另一种解决方法(尽管不是最有效的方法)可能是使用着色器。在我们的 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".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文