作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试更新一个 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());
关于Three.js - 如何更新 arrowHelper?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20554946/
我是一名优秀的程序员,十分优秀!