在运行时更新 TubeGeometry 的半径 [英] Update radius of TubeGeometry at runtime

查看:27
本文介绍了在运行时更新 TubeGeometry 的半径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在运行时根据 TubeGeometry 动态更改网格的半径.

How to dynamically change the radius of a mesh based on the TubeGeometry at runtime.

这是我创建网格的方法:

Here is how I create the mesh:

var points = new THREE.SplineCurve3([
  new THREE.Vector3(source.x, source.y, source.z),
  new THREE.Vector3(target.x, target.y, target.z)
]);
var geometry = new THREE.TubeGeometry(points, 10, 1, 10, false, false);
geometry.dynamic = true;
var material =  new THREE.MeshLambertMaterial({color:0x0000cc});
var mesh = new THREE.Mesh(geometry, material);

这里是我如何尝试更新管子的半径:

And here how I try to update the radius of the tube:

var geometry = mesh.geometry;
geometry.radius = 200;
geometry.verticesNeedUpdate = true;
mesh.updateMatrix();

不幸的是,它不会更新管半径.它是如何正确完成的?有可能吗?

Unfortunately it does not update the tube radius. How is it done correctly? Is it possible at all?

推荐答案

radius 参数仅在构造几何图形时使用.更改它不会有任何影响.

The radius parameter is only used during construction of the geometry. Changing it will have no effect.

您可以更改 mesh.scale,但由于样条曲线,这可能不会像您希望的那样工作.(它适用于 CyllinderGeometry.)

You could change mesh.scale, but that will likely not work as you would like in your case due to the spline curve. ( It would work for a CyllinderGeometry. )

three.js r.58

three.js r.58

这篇关于在运行时更新 TubeGeometry 的半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆