ArrowHelper

优质
小牛编辑
127浏览
2023-12-01

用于模拟方向的3维箭头对象.

代码示例

const dir = new THREE.Vector3( 1, 2, 0 );
//normalize the direction vector (convert to vector of length 1)
dir.normalize();
const origin = new THREE.Vector3( 0, 0, 0 );
const length = 1;
const hex = 0xffff00;
const arrowHelper = new THREE.ArrowHelper( dir, origin, length, hex );
scene.add( arrowHelper );

例子

WebGL / shadowmesh

构造函数

ArrowHelper(dir : Vector3, origin : Vector3, length : Number, hex : Number, headLength : Number, headWidth : Number )

dir -- 基于箭头原点的方向. 必须为单位向量.
origin -- 箭头的原点.
length -- 箭头的长度. 默认为 1.
hex -- 定义的16进制颜色值. 默认为 0xffff00.
headLength -- 箭头头部(锥体)的长度. 默认为箭头长度的0.2倍(0.2 * length).
headWidth -- The width of the head of the arrow. Default is 0.2 * headLength.

属性

请到基类 Object3D 页面查看公共属性.

.line : Line

包含箭头辅助对象的线段部分.

.cone : Mesh

包含箭头辅助对象的锥体部分.

方法

请到基类 Object3D 页面查看公共方法.

.setColor (color : Color) : null

color -- 所需的颜色。

设置箭头辅助对象的颜色.

.setLength (length : Number, headLength : Number, headWidth : Number) : null

length -- 要设置的长度.
headLength -- 要设置的箭头头部(锥体)的长度.
headWidth -- The width of the head of the arrow.

设置箭头辅助对象的长度.

.setDirection (dir : Vector3) : null

dir -- 要设置的方向. 必须为单位向量.

设置箭头辅助对象的方向.

源码

src/helpers/ArrowHelper.js