javascript - Three.js - how to draw a discontinuous line using BufferGeometry? -
i have following situation: need draw line holes (a discontinuous line). means line consists of several segments not combined visually belong in other context. these segments consists of more 2 points, not way three.linepieces
works.
at time, using buffergeometry
store vertices. colleague told me, in webgl possible create 2 arrays additional vertices: 1 contains indices of vertices , 1 contains order of how vertices should combined. here example of mean:
indices = [0,1,2,3,4,5] vertices = [x0, y0, z0, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4, x5, y5, z5] order = [0,1,1,2,3,4,4,5]
with 2 lines: first 1 point 0 on 1 2, hole, second line 3 on 4 5.
so this:
.___.___. .___.___. 0 1 2 3 4 5
i not familiar webgl, i'm trusting colleague possible create such construct. possible three.js? if yes, how do it?
edit: talked once more colleague , got code snippet
indexbufferdata = [0,1,1,2,3,4,4,5]; gl.glbindbuffer(gl.gl_element_array_buffer, indexbufferid); gl.glbufferdata(gl.gl_element_array_buffer, indexbufferdata.limit() * buffers.sizeof_int, indexbufferdata, gl.gl_static_draw);
he said have duplicate indices , not vertices (would possible not recommended) line segments.
so searched in webglrenderer
, saw on line 2380 if there attribute index
in buffergeometry
, necessary buffer created. setting attribute has no effect. when using three.linepieces
still connecting 2 points.
if trying draw series of connected line segments, followed gap, , series of connected line segments, use three.linepieces
-- segments connect, , not.
for example, pattern line 3 segments, followed line 1 segment:
v0, v1, v1, v2, v2, v3, v4, v5
looks this:
.___.___.___. .___. 0 1 2 3 4 5
three.js r.61
Comments
Post a Comment