var data = [2]
var rectW = 1
var ran = 90
data = data.map(e=>{
let point1 = new THREE.Vector2(- rectW / 2, 0)
let point2 = new THREE.Vector2(- rectW / 2, e)
let point3 = new THREE.Vector2(rectW / 2, e)
let point4 = new THREE.Vector2(rectW / 2, 0)
rotatePoint(point1,ran,0)
rotatePoint(point2,ran,0)
rotatePoint(point3,ran,0)
rotatePoint(point4,ran,0)
return [[point1.x,point1.y],[point2.x,point2.y],[point3.x,point3.y],[point4.x,point4.y]]
})
console.log(data)
function rotatePoint(point,degree,offset)
{
var offsetVec = new THREE.Vector2(0,offset)
var matrix = new THREE.Matrix3();
var radian = degree* Math.PI / 180
point.add(offsetVec)
matrix.set(Math.cos(radian),-Math.sin(radian),0,
Math.sin(radian),Math.cos(radian),0,
0,0,0
)
point.applyMatrix3(matrix)
return point
}
console