nx: number = 0
ny: number = 0
onPan (e) {
this.nx = e.srcEvent.layerY //滑动事件Y位置
this.ny = e.srcEvent.layerX //滑动事件X位置
this.normalize()
// console.log(this.nx,this.ny)
}
multiplyScalar ( scalar: number ) {
this.nx *= scalar;
this.ny *= scalar;
return this;
}
divideScalar ( scalar: number ) {
return this.multiplyScalar( 1 / scalar );
}
normalize () {
return this.divideScalar( this.length() || 1 );
}
length () {
return Math.sqrt( this.nx * this.nx + this.ny * this.ny );
}
three.js JS方向向量
最新推荐文章于 2024-05-26 16:18:25 发布