How to draw rectangle that is always horizontal to the eyes

Hello,

I am trying to draw an rectangle that is horizontal always to the eyes. I mean not follow the orbit control

Please take a look at the picture.

This is my rectangle tilted

I am getting this with this formula

getRectPoints = (startPoint, endPoint) => {
const sPoint = new THREE.Vector3(startPoint.x, 0.002, startPoint.z)
const ePoint = new THREE.Vector3(endPoint.x, 0.002, endPoint.z)
const subVec = new THREE.Vector3().subVectors(ePoint, sPoint)
const p1 = new THREE.Vector3().copy(sPoint)
p1.x += subVec.x
const p2 = new THREE.Vector3().copy(sPoint)
p2.z += subVec.z

return {p1: p1, p2: p2, sPoint: sPoint, ePoint: ePoint}
}

I want it horizontal always irrespective of that cube view that is using orbit control

I need it like this

Thanks

Adding the rectangle mesh to the camera should do the trick - it should then not be affected by the controls :eyes:

u mean camera.add(mesh)

If yes so than how it will reflect in scene , because camera is not the child of scene

Hello! Maybe you mean rotating like into games bullet trace always look to camera by rotating aroung one axe.

well make it one then? scene.add(camera) :exploding_head:

1 Like

To keep your rectangle horizontal and not follow the orbit control, you need to ensure that its orientation is always aligned with the world’s XY plane. One way to achieve this is to use the lookAt method to point your rectangle towards the camera’s position