As a beginner in three.js, I encountered an issue where updating a ShapeGeometry wasn't working as expected. This resulted in me having to remove and re-add the ShapeMesh every time.
this.mesh.geometry.dispose()
this.mesh.material.dispose()
this.scene.remove(this.mesh)
//vertex
this.triangleShape = new THREE.Shape()
this.triangleShape.moveTo( -612+this.Eposition.left, 310-this.Eposition.top-25 )
for(let i = 0 ; i < length ; i++) {
this.triangleShape.lineTo(data[i][0],data[i][1])
}
this.triangleShape.lineTo( -612+this.Eposition.left+141, 310-this.Eposition.top-25 )
this.triangleShape.lineTo( -612+this.Eposition.left+141, 310-this.Eposition.top )
this.triangleShape.lineTo( -612+this.Eposition.left, 310-this.Eposition.top )
this.triangleShape.lineTo( -612+this.Eposition.left, 310-this.Eposition.top-25 )// close path
let geometry = new THREE.ShapeGeometry( this.triangleShape )
this.mesh = new THREE.Mesh(geometry,this.material)
this.scene.add(this.mesh)
Despite trying
this.mesh.geometry.verticesNeedUpdate = true
, it appears that the issue persists.