2016-09-20 7 views
0

私はthree.jsで新しく、ShapeGeometryを更新しようとしましたが動作しませんでした。今、私は形状メッシュを取り除いてreaddしなければならない。 Shapeが作成されたジオメトリのちょうどより高いレベルの記述があるので、あなたはShapeGeometryで使用される形状を更新することはできません、three.jsでShapeGeometryを更新するには

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) 

アイブ氏はthis.mesh.geometry.verticesNeedUpdate = trueを書き込もうとしましたが、それは

答えて

0

残念ながら動作しないようですそこから、幾何学自体の一部ではありません。

ここでのポイントは次のとおりです。シェイプは、ベクターグラフィックス、カーブなどで表現されます。 ShapeGeometryを作成すると、three.jsはこの記述を使用してジオメトリバッファを実際に作成します(このステップでは、曲線は線分のリストに分解され、閉じたパスは三角形になります)。ShapeGeometry.addShape()の実装を参照してください。 。

パフォーマンスが優れていれば(形状はあまり複雑ではないなど)、すべての更新に対して新しいジオメトリを作成できますが、このプロセスも非常に高価になる可能性があります。独自のジオメトリまたはBufferGeometryを使用して、必要な作業を行います(これは複雑ではありません)。例としてシリンダー[Buffer] Geometryのような単純なものを見てください。

関連する問題