three.js - 三 动态更新 ConvexGeometry
问题描述
我在 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 )
推荐阅读
- rust - 如何在没有 Box::from_raw 的情况下将 *mut *mut c_void 转换为 &str?
- python - 有没有办法遍历python中的列表?
- javascript - 多个元素上的鼠标悬停事件闪烁
- ubuntu - 在最新的 ubuntu 上编译和安装旧内核
- javascript - 用 debounce 反应回调:子组件没有将回调返回给父组件
- spring - JwtAuthorizationFilter 实现不起作用
- angular - Angular 应用程序是否可以与 Braintree API 集成以在没有传统服务器端便利的情况下管理经常性计费?
- javascript - Firebase '.get()' 不返回任何数据
- java - 试图填充数组但分配没有通过
- mininet - 如何通过 Opendaylight 控制器(GUI)更改开关配置