三动态更新ConvexGeometry
Three Update ConvexGeometry dynamically
我在 Aframe 中使用 THREE.js 并尝试通过单击点来构建网格。
这是有效的,但是我正在努力更新几何以显示更改。
this._shapeEl = make('a-entity', {
material: {color: 'blue'},
geometry: this._vertices.length > 3 ? new THREE.ConvexGeometry( this._vertices ) : new THREE.Geometry(),
}, this.el)
点击时:
var target = e.detail.intersection.point
this.el.object3D.worldToLocal(target)
make('a-sphere', {
color: darkViolet,
radius: 0.01,
position: target,
}, this.el)
this._vertices.push(target)
if(this._vertices.length > 3){
this._shapeEl.object3D.geometry = new THREE.ConvexGeometry( this._vertices )
this._shapeEl.object3D.geometry.dynamic = true
}
显示球体,并且正在添加点,但 _shapeEl 没有从蓝色立方体改变。
感谢@Mugen87 很有用。
答案是使用object3Dmap.mesh
this._shapeEl.object3DMap.mesh.geometry.dispose()
this._shapeEl.object3DMap.mesh.geometry = new THREE.ConvexGeometry( this._vertices )
我在 Aframe 中使用 THREE.js 并尝试通过单击点来构建网格。
这是有效的,但是我正在努力更新几何以显示更改。
this._shapeEl = make('a-entity', {
material: {color: 'blue'},
geometry: this._vertices.length > 3 ? new THREE.ConvexGeometry( this._vertices ) : new THREE.Geometry(),
}, this.el)
点击时:
var target = e.detail.intersection.point
this.el.object3D.worldToLocal(target)
make('a-sphere', {
color: darkViolet,
radius: 0.01,
position: target,
}, this.el)
this._vertices.push(target)
if(this._vertices.length > 3){
this._shapeEl.object3D.geometry = new THREE.ConvexGeometry( this._vertices )
this._shapeEl.object3D.geometry.dynamic = true
}
显示球体,并且正在添加点,但 _shapeEl 没有从蓝色立方体改变。
感谢@Mugen87 很有用。
答案是使用object3Dmap.mesh
this._shapeEl.object3DMap.mesh.geometry.dispose()
this._shapeEl.object3DMap.mesh.geometry = new THREE.ConvexGeometry( this._vertices )