Render WebGL non-contiguous lines as a single object(将 WebGL 非连续行渲染为单个对象)
问题描述
我有多个要渲染的 WebGL 行,它们都具有相同的渲染样式.因此,为了提高性能,我想在一次绘制调用中将它们全部渲染为一个对象.
但问题是这些线路并非都相互连接.
在此处查看示例:.
three.js r.58
附:three.js 包括 requestAnimationFrame()
垫片.您不需要自己包含它.
I have multiple WebGL lines to render, and they all have the same rendering style. So for performance, I want to render them all as a single object, in a single draw call.
But the problem is that the lines don't all connect to each other.
See example here: http://jsfiddle.net/b6jgS/6/
As you can see the rings connect, but I don't want them to. Yet I still want to draw them in a single draw call.
The relevant code is this, which simply generates some geometry for some rings:
# Pardon the coffeescript!
ringsGeom = new THREE.Geometry()
for u in [-2..2]
for v in [0..100]
ringsGeom.vertices.push new THREE.Vector3(
Math.sin(v/100 * 2 * Math.PI)
Math.cos(v/100 * 2 * Math.PI)
u
)
rings = new THREE.Line(
ringsGeom
new THREE.LineBasicMaterial(
color: 0xffff00
linewidth: 1
)
)
scene.add rings
How do I have a single object draw multiple discreet disconnected lines?
You construct your geometry as an array of pairs of points representing individual line segments, and then create your line like so:
var line = new THREE.Line( geometry, material, THREE.LinePieces );
For an example, see GridHelper.js.
three.js r.58
P.S. three.js includes the requestAnimationFrame()
shim. You do not need to include it yourself.
这篇关于将 WebGL 非连续行渲染为单个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 WebGL 非连续行渲染为单个对象


- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01