Hi! it’s my first question, for my first project with three.js, i hope it’s not too simple, i already researched but with no success.
So i’m creating a Line2 because i need to control the fatness, so i followed this example (https://threejs.org/examples/?q=line#webgl_lines_fat) and it was working.
But then i saw that i also need to update the points of my geometry, so made some modifications following this example: https://threejs.org/docs/index.html#manual/en/introduction/How-to-update-things
And now my mesh it’s not showing anymore, here is a relevant code, i’m inside a vue component, so it has some different syntax.
//mounted()
this.arcGeometry1 = new LineGeometry()
// set maximum size for buffer of LineGeometry,
var positions = new Float32Array( MAX_POINTS * 3 ); // 3 vertices per point
this.arcGeometry1.setAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); // the number of values of the array, not drawRange
this.matLine2 = new LineMaterial({
color: 0x000000,
linewidth: 3,
dashed: false
});
this.matLine2.resolution.set(( this.container.clientWidth, this.container.clientHeight ))
this.arcMesh = new Line2(this.arcGeometry1, this.matLine2 );
update()
init()
render()
//update()
var positions = this.arcMesh.geometry.attributes.position.array;
for (let x = 0; x < arcPath.length; x++) {
positions[x] = arcPath[x]
}
this.arcMesh.geometry.setDrawRange( 0, arcPath.length );
this.arcMesh.geometry.computeBoundingSphere();
//this.arcMesh.computeLineDistances();
this.earthArcMesh.scale.set( 1, 1, 1 );
//init()
this.scene.add(this.arcMesh);
//render()
this.renderer.render(this.scene, this.camera);
this.arcMesh.geometry.computeBoundingSphere();
this.arcMesh.geometry.attributes.position.needsUpdate = true;
Since i implemented bufferGeometry the mesh is not showing in the render, but when i debug it, seems fine because the geometry points are correctly loaded
Line2 {…}
castShadow: (...)
children: (...)
frustumCulled: (...)
geometry: LineGeometry
attributes: Object
position: BufferAttribute
array: Float32Array(135)
[0 … 99]
0: -148.2235870361328
1: -17.804668426513672
2: 0.0008591873338446021
3: -147.93746948242188
4: -20.358715057373047
5: 0.0009825639426708221
6: -147.60552978515625
7: -22.92180633544922
8: 0.0011064092395827174
9: -147.22335815429688
10: -25.517356872558594
11: 0.0012318536173552275
...
boundingSphere: Sphere
center: Vector3
radius: 0
A hint may be that always in the console debugging i see that the bounding sphere has radius 0? Even if did compute it in the snippet before. Any help would be very appreciated, thanks