我正在尝试更新 arrowHelper。我尝试过操作箭头对象线中的顶点,设置所有内容dynamic = true
等等,但我似乎能做到的唯一方法就是删除旧线并绘制新线。有没有办法更新 arrowHelper?
因此,您无法通过更改用于创建对象的值来以通常的更新方式更新 arrowHelper 本身。
但是:您可以移动箭头的位置,这会移动其明显的起点,并且您可以给它一个新的方向和长度,这会移动其明显的终点。
操作方法如下:
// new arrowHelper
var sourcePos = new THREE.Vector3(0, 0, 0);
var targetPos = new THREE.Vector3(0, 50, 0);
var direction = new THREE.Vector3().sub(targetPos, sourcePos);
var arrow = new THREE.ArrowHelper(direction.clone().normalize(), sourcePos, direction.length(), 0x00ff00);
scene.add(arrow);
// update the arrow
var newSourcePos = new THREE.Vector3(10, 10, 10);
var newTargetPos = new THREE.Vector3(60, 10, 10);
arrow.position.set(newSourcePos);
direction = new THREE.Vector3().sub(newTargetPos, newSourcePos);
arrow.setDirection(direction.normalize());
arrow.setLength(direction.length());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)