2016-09-20 2 views
0

저는 three.js에서 새로 왔으며 ShapeGeometry를 업데이트하려고했지만 작동하지 않았습니다. 이제는 형상 메쉬를 제거하고 읽어야합니다. 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는 해당 설명을 사용하여 실제로 geometry-buffers를 만듭니다 (이 단계에서는 곡선이 선분 목록으로 분해되고 닫힌 경로는 삼각형으로 변환됩니다. ShapeGeometry.addShape() 구현 참조) .

성능면에서 너무 복잡하지 않은 모양이라면 모든 업데이트에 대해 새로운 지오메트리를 만들 수 있지만이 프로세스가 너무 비쌀 수 있으므로 자신의 기하학을 구현해야한다고 생각해야합니다. 또는 BufferGeometry를 사용하여 수행해야 할 작업을 수행 할 수 있습니다 (복잡한 것은 아닙니다. 예를 들어 Cylinder [Buffer] Geometry와 같은 간단한 것을 살펴보십시오).

관련 문제