How to create geometry using vertices?

How to create geometry using below vertices/coordinates using buffergeometry:
var v = [6.194472771137953, 1.9201370514929295, 0.0, 9.28397100046277, -1.24986123573035, 0.0, 5.2639788798987865, -5.059866288676858, 0.0, 4.543979845941067, -5.739866957999766, 0.0, 1.3639824986457825, -8.749869089573622, 0.0, -0.8860172145068645, -10.879869756288826, 0.0, -4.836014334112406, -6.839866225607693, 0.0, -1.7360151074826717, -3.899866792373359, 0.0, 1.373981598764658, -0.9798660473898053, 0.0, 1.983980879187584, -1.6098662270233035, 0.0, 2.0339808240532875, -1.6598662389442325, 0.0, 2.763979706913233, -1.029865836724639, 0.0]

Thanks

Try it with BufferGeometry.setFromPoints(). However, you have to change the data of your array so it holds Vector3 objects (not just numbers).

Thanks @Mugen87,

I am new to Three.js, I am trying your solution.

Or add a buffer attribute.

var v = [ _your_data_array_ ];
var geom = new THREE.BufferGeometry();
geom.setAttribute("position", new THREE.BufferAttribute(new Float32Array(v), 3));
1 Like

@prisoner849 This is actually the better solution in this use case :+1:

1 Like